tmex-cli 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/runtime/server.js +736 -186
  2. package/package.json +1 -1
  3. package/resources/fe-dist/assets/DevicePage-CKaPUo7L.js +26 -0
  4. package/resources/fe-dist/assets/DevicePage-CKaPUo7L.js.map +1 -0
  5. package/resources/fe-dist/assets/DevicesPage-FqU-Dxhu.js +17 -0
  6. package/resources/fe-dist/assets/{DevicesPage-CtNzaW_c.js.map → DevicesPage-FqU-Dxhu.js.map} +1 -1
  7. package/resources/fe-dist/assets/SettingsPage-BfkOW0fc.js +17 -0
  8. package/resources/fe-dist/assets/SettingsPage-BfkOW0fc.js.map +1 -0
  9. package/resources/fe-dist/assets/index-EgHfq93I.js +449 -0
  10. package/resources/fe-dist/assets/index-EgHfq93I.js.map +1 -0
  11. package/resources/fe-dist/assets/index-Ytlj3p_q.css +1 -0
  12. package/resources/fe-dist/assets/select-CNlE6MiW.js +17 -0
  13. package/resources/fe-dist/assets/{select-BNsiC9zT.js.map → select-CNlE6MiW.js.map} +1 -1
  14. package/resources/fe-dist/assets/switch-CxkzOIL6.js +12 -0
  15. package/resources/fe-dist/assets/{switch-CIU4AisU.js.map → switch-CxkzOIL6.js.map} +1 -1
  16. package/resources/fe-dist/assets/useValueChanged-CO2U5MoL.js +7 -0
  17. package/resources/fe-dist/assets/{useValueChanged-V23H0VpC.js.map → useValueChanged-CO2U5MoL.js.map} +1 -1
  18. package/resources/fe-dist/index.html +2 -2
  19. package/resources/gateway-drizzle/0002_broad_vengeance.sql +3 -0
  20. package/resources/gateway-drizzle/meta/0000_snapshot.json +17 -6
  21. package/resources/gateway-drizzle/meta/0001_snapshot.json +17 -6
  22. package/resources/gateway-drizzle/meta/0002_snapshot.json +535 -0
  23. package/resources/gateway-drizzle/meta/_journal.json +8 -1
  24. package/resources/fe-dist/assets/DevicePage-iSkEDEpS.js +0 -4570
  25. package/resources/fe-dist/assets/DevicePage-iSkEDEpS.js.map +0 -1
  26. package/resources/fe-dist/assets/DevicesPage-CtNzaW_c.js +0 -2143
  27. package/resources/fe-dist/assets/SettingsPage-D25_d6j9.js +0 -1144
  28. package/resources/fe-dist/assets/SettingsPage-D25_d6j9.js.map +0 -1
  29. package/resources/fe-dist/assets/index-CJaX5rlK.css +0 -4527
  30. package/resources/fe-dist/assets/index-dsVN7rgz.js +0 -200
  31. package/resources/fe-dist/assets/index-dsVN7rgz.js.map +0 -1
  32. package/resources/fe-dist/assets/select-BNsiC9zT.js +0 -2805
  33. package/resources/fe-dist/assets/switch-CIU4AisU.js +0 -234
  34. package/resources/fe-dist/assets/useValueChanged-V23H0VpC.js +0 -351
@@ -1,2143 +0,0 @@
1
- var Bt = Object.defineProperty;
2
- var zt = (e, n, r) =>
3
- n in e ? Bt(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : (e[n] = r);
4
- var Xe = (e, n, r) => zt(e, typeof n != 'symbol' ? n + '' : n, r);
5
- import {
6
- av as $e,
7
- aB as $n,
8
- v as Ae,
9
- aw as An,
10
- c as Be,
11
- aD as Bn,
12
- a9 as Cn,
13
- ar as Ct,
14
- az as De,
15
- at as Dn,
16
- ao as En,
17
- au as Fn,
18
- aI as Gn,
19
- X as Gt,
20
- a5 as He,
21
- ax as Hn,
22
- ah as In,
23
- aP as Jn,
24
- o as Jt,
25
- a0 as K,
26
- ag as Ke,
27
- ay as Kn,
28
- an as Le,
29
- aA as Ln,
30
- O as Me,
31
- ai as Mn,
32
- am as Nn,
33
- as as On,
34
- aa as Pe,
35
- aj as Pn,
36
- e as Qn,
37
- n as Qt,
38
- af as Rn,
39
- aO as Rt,
40
- Z as Se,
41
- al as Sn,
42
- ak as Tn,
43
- aR as Ue,
44
- aC as Un,
45
- aL as Vn,
46
- l as Vt,
47
- aS as Wn,
48
- z as Wt,
49
- k as X,
50
- aT as Xn,
51
- A as Xt,
52
- aM as Yn,
53
- m as Yt,
54
- ad as Ze,
55
- C as Zt,
56
- aG as _n,
57
- D as _t,
58
- P as an,
59
- u as be,
60
- a8 as bn,
61
- ap as bt,
62
- f as ce,
63
- Q as cn,
64
- S as dn,
65
- h as dt,
66
- F as en,
67
- aE as et,
68
- Y as fn,
69
- x as ft,
70
- $ as gn,
71
- H as gt,
72
- a1 as hn,
73
- K as ht,
74
- T as je,
75
- ab as jn,
76
- a as jt,
77
- aq as kn,
78
- R as ln,
79
- W as mn,
80
- w as mt,
81
- J as nn,
82
- aK as nt,
83
- r as o,
84
- M as on,
85
- B as pe,
86
- V as pn,
87
- s as pt,
88
- aH as qn,
89
- g as qt,
90
- N as rn,
91
- L as sn,
92
- aQ as st,
93
- j as t,
94
- G as tn,
95
- aJ as tt,
96
- E as ue,
97
- U as un,
98
- q as ut,
99
- p as ve,
100
- a6 as vn,
101
- a3 as vt,
102
- ac as we,
103
- ae as wn,
104
- aN as wt,
105
- a2 as xn,
106
- _ as xt,
107
- y as ye,
108
- a7 as yn,
109
- a4 as yt,
110
- aF as zn,
111
- } from './index-dsVN7rgz.js';
112
- import {
113
- n as os,
114
- c as Ie,
115
- h as It,
116
- C as Re,
117
- u as Te,
118
- i as Zn,
119
- a as as,
120
- d as at,
121
- j as es,
122
- g as he,
123
- I as ie,
124
- o as is,
125
- f as it,
126
- l as ns,
127
- S as ot,
128
- b as rs,
129
- e as rt,
130
- m as ss,
131
- k as ts,
132
- } from './select-BNsiC9zT.js';
133
- import {
134
- e as fs,
135
- T as Mt,
136
- A as cs,
137
- b as ds,
138
- f as gs,
139
- g as hs,
140
- a as ls,
141
- d as ms,
142
- c as ps,
143
- h as us,
144
- } from './useValueChanged-V23H0VpC.js'; /**
145
- * @license lucide-react v0.564.0 - ISC
146
- *
147
- * This source code is licensed under the ISC license.
148
- * See the LICENSE file in the root directory of this source tree.
149
- */
150
- const xs = [
151
- ['circle', { cx: '12', cy: '12', r: '1', key: '41hilf' }],
152
- ['circle', { cx: '19', cy: '12', r: '1', key: '1wjl8i' }],
153
- ['circle', { cx: '5', cy: '12', r: '1', key: '1pcz8c' }],
154
- ],
155
- vs = Be('ellipsis', xs); /**
156
- * @license lucide-react v0.564.0 - ISC
157
- *
158
- * This source code is licensed under the ISC license.
159
- * See the LICENSE file in the root directory of this source tree.
160
- */
161
- const ys = [
162
- [
163
- 'path',
164
- {
165
- d: 'M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z',
166
- key: '1a8usu',
167
- },
168
- ],
169
- ['path', { d: 'm15 5 4 4', key: '1mk7zo' }],
170
- ],
171
- bs = Be('pencil', ys); /**
172
- * @license lucide-react v0.564.0 - ISC
173
- *
174
- * This source code is licensed under the ISC license.
175
- * See the LICENSE file in the root directory of this source tree.
176
- */
177
- const Cs = [
178
- [
179
- 'path',
180
- {
181
- d: 'M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z',
182
- key: '1xq2db',
183
- },
184
- ],
185
- ],
186
- js = Be('zap', Cs);
187
- function ws({ ...e }) {
188
- return t.jsx(_t, { 'data-slot': 'dialog', ...e });
189
- }
190
- function Rs({ ...e }) {
191
- return t.jsx(Qt, { 'data-slot': 'dialog-portal', ...e });
192
- }
193
- function Is({ className: e, ...n }) {
194
- return t.jsx(Jt, {
195
- 'data-slot': 'dialog-overlay',
196
- className: X(
197
- 'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50',
198
- e
199
- ),
200
- ...n,
201
- });
202
- }
203
- function Ms({ className: e, children: n, showCloseButton: r = !0, ...s }) {
204
- return t.jsxs(Rs, {
205
- children: [
206
- t.jsx(Is, {}),
207
- t.jsxs(qt, {
208
- 'data-slot': 'dialog-content',
209
- className: X(
210
- 'bg-background data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 grid max-w-[calc(100%-2rem)] gap-4 rounded-xl p-4 text-sm ring-1 duration-100 sm:max-w-sm fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none',
211
- e
212
- ),
213
- ...s,
214
- children: [
215
- n,
216
- r &&
217
- t.jsxs(dt, {
218
- 'data-slot': 'dialog-close',
219
- render: t.jsx(pe, {
220
- variant: 'ghost',
221
- className: 'absolute top-2 right-2',
222
- size: 'icon-sm',
223
- }),
224
- children: [t.jsx(Gt, {}), t.jsx('span', { className: 'sr-only', children: 'Close' })],
225
- }),
226
- ],
227
- }),
228
- ],
229
- });
230
- }
231
- function Ps({ className: e, ...n }) {
232
- return t.jsx('div', {
233
- 'data-slot': 'dialog-header',
234
- className: X('gap-2 flex flex-col', e),
235
- ...n,
236
- });
237
- }
238
- function Ts({ className: e, showCloseButton: n = !1, children: r, ...s }) {
239
- return t.jsxs('div', {
240
- 'data-slot': 'dialog-footer',
241
- className: X(
242
- 'bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',
243
- e
244
- ),
245
- ...s,
246
- children: [r, n && t.jsx(dt, { render: t.jsx(pe, { variant: 'outline' }), children: 'Close' })],
247
- });
248
- }
249
- function Ss({ className: e, ...n }) {
250
- return t.jsx(Vt, {
251
- 'data-slot': 'dialog-title',
252
- className: X('text-base leading-none font-medium', e),
253
- ...n,
254
- });
255
- }
256
- function Ns({ className: e, ...n }) {
257
- return t.jsx(Yt, {
258
- 'data-slot': 'dialog-description',
259
- className: X(
260
- 'text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3',
261
- e
262
- ),
263
- ...n,
264
- });
265
- }
266
- const Pt = o.createContext(void 0);
267
- function Tt(e) {
268
- const n = o.useContext(Pt);
269
- if (n === void 0 && !e) throw new Error(ve(33));
270
- return n;
271
- }
272
- const St = o.createContext(void 0);
273
- function me(e) {
274
- const n = o.useContext(St);
275
- if (n === void 0 && !e) throw new Error(ve(36));
276
- return n;
277
- }
278
- const Es = o.createContext(void 0);
279
- function Ne(e = !0) {
280
- const n = o.useContext(Es);
281
- if (n === void 0 && !e) throw new Error(ve(25));
282
- return n;
283
- }
284
- function ks(e) {
285
- const {
286
- closeOnClick: n,
287
- highlighted: r,
288
- id: s,
289
- nodeId: p,
290
- store: i,
291
- itemRef: m,
292
- itemMetadata: c,
293
- } = e,
294
- { events: y } = i.useState('floatingTreeRoot'),
295
- b = Ne(!0),
296
- C = b !== void 0;
297
- return o.useMemo(
298
- () => ({
299
- id: s,
300
- role: 'menuitem',
301
- tabIndex: r ? 0 : -1,
302
- onMouseMove(v) {
303
- p && y.emit('itemhover', { nodeId: p, target: v.currentTarget });
304
- },
305
- onClick(v) {
306
- n && y.emit('close', { domEvent: v, reason: ut });
307
- },
308
- onMouseUp(v) {
309
- if (b) {
310
- const I = b.initialCursorPointRef.current;
311
- if (
312
- ((b.initialCursorPointRef.current = null),
313
- C && I && Math.abs(v.clientX - I.x) <= 1 && Math.abs(v.clientY - I.y) <= 1)
314
- )
315
- return;
316
- }
317
- m.current &&
318
- i.context.allowMouseUpTriggerRef.current &&
319
- (!C || v.button === 2) &&
320
- (!c || c.type === 'regular-item') &&
321
- m.current.click();
322
- },
323
- }),
324
- [n, r, s, y, p, i, m, b, C, c]
325
- );
326
- }
327
- const Os = { type: 'regular-item' };
328
- function Ds(e) {
329
- const {
330
- closeOnClick: n,
331
- disabled: r = !1,
332
- highlighted: s,
333
- id: p,
334
- store: i,
335
- nativeButton: m,
336
- itemMetadata: c,
337
- nodeId: y,
338
- } = e,
339
- b = o.useRef(null),
340
- { getButtonProps: C, buttonRef: v } = pt({ disabled: r, focusableWhenDisabled: !0, native: m }),
341
- I = ks({
342
- closeOnClick: n,
343
- highlighted: s,
344
- id: p,
345
- nodeId: y,
346
- store: i,
347
- itemRef: b,
348
- itemMetadata: c,
349
- }),
350
- x = o.useCallback(
351
- (g) =>
352
- Ae(
353
- I,
354
- {
355
- onMouseEnter() {
356
- c.type === 'submenu-trigger' && c.setActive();
357
- },
358
- onKeyUp(M) {
359
- M.key === ' ' && i.context.typingRef.current && M.preventBaseUIHandler();
360
- },
361
- },
362
- g,
363
- C
364
- ),
365
- [I, C, i, c]
366
- ),
367
- S = mt(b, v);
368
- return o.useMemo(() => ({ getItemProps: x, itemRef: S }), [x, S]);
369
- }
370
- const Fs = o.forwardRef((n, r) => {
371
- const {
372
- render: s,
373
- className: p,
374
- id: i,
375
- label: m,
376
- nativeButton: c = !1,
377
- disabled: y = !1,
378
- closeOnClick: b = !0,
379
- ...C
380
- } = n,
381
- v = It({ label: m }),
382
- I = Tt(!0),
383
- x = ft(i),
384
- { store: S } = me(),
385
- g = S.useState('isActive', v.index),
386
- M = S.useState('itemProps'),
387
- { getItemProps: j, itemRef: u } = Ds({
388
- closeOnClick: b,
389
- disabled: y,
390
- highlighted: g,
391
- id: x,
392
- store: S,
393
- nativeButton: c,
394
- nodeId: I == null ? void 0 : I.nodeId,
395
- itemMetadata: Os,
396
- });
397
- return ye('div', n, {
398
- state: { disabled: y, highlighted: g },
399
- props: [M, C, j],
400
- ref: [u, r, v.ref],
401
- });
402
- }),
403
- As = { ...gt, ...tn },
404
- Hs = o.forwardRef((n, r) => {
405
- const { render: s, className: p, finalFocus: i, ...m } = n,
406
- { store: c } = me(),
407
- { side: y, align: b } = Tt(),
408
- C = Zn() != null,
409
- v = c.useState('open'),
410
- I = c.useState('transitionStatus'),
411
- x = c.useState('popupProps'),
412
- S = c.useState('mounted'),
413
- g = c.useState('instantType'),
414
- M = c.useState('activeTriggerElement'),
415
- j = c.useState('parent'),
416
- u = c.useState('lastOpenChangeReason'),
417
- N = c.useState('rootId'),
418
- $ = c.useState('floatingRootContext'),
419
- f = c.useState('floatingTreeRoot'),
420
- a = c.useState('closeDelay'),
421
- w = c.useState('activeTriggerElement'),
422
- l = j.type === 'context-menu';
423
- Wt({
424
- open: v,
425
- ref: c.context.popupRef,
426
- onComplete() {
427
- var O, H;
428
- v && ((H = (O = c.context).onOpenChangeComplete) == null || H.call(O, !0));
429
- },
430
- }),
431
- o.useEffect(() => {
432
- function O(H) {
433
- c.setOpen(!1, ue(H.reason, H.domEvent));
434
- }
435
- return (
436
- f.events.on('close', O),
437
- () => {
438
- f.events.off('close', O);
439
- }
440
- );
441
- }, [f.events, c]);
442
- const d = c.useState('hoverEnabled'),
443
- k = c.useState('disabled');
444
- Xt($, { enabled: d && !k && !l && j.type !== 'menubar', closeDelay: a });
445
- const q = {
446
- transitionStatus: I,
447
- side: y,
448
- align: b,
449
- open: v,
450
- nested: j.type === 'menu',
451
- instant: g,
452
- },
453
- V = ye('div', n, {
454
- state: q,
455
- ref: [r, c.context.popupRef],
456
- stateAttributesMapping: As,
457
- props: [
458
- x,
459
- {
460
- onKeyDown(O) {
461
- C && nn.has(O.key) && O.stopPropagation();
462
- },
463
- },
464
- ht(I),
465
- m,
466
- { 'data-rootownerid': N },
467
- ],
468
- });
469
- let A = j.type === void 0 || l;
470
- return (
471
- (M || (j.type === 'menubar' && u !== Zt)) && (A = !0),
472
- t.jsx(en, {
473
- context: $,
474
- modal: l,
475
- disabled: !S,
476
- returnFocus: i === void 0 ? A : i,
477
- initialFocus: j.type !== 'menu',
478
- restoreFocus: !0,
479
- externalTree: j.type !== 'menubar' ? f : void 0,
480
- previousFocusableElement: w,
481
- nextFocusableElement: j.type === void 0 ? c.context.triggerFocusTargetRef : void 0,
482
- beforeContentFocusGuardRef:
483
- j.type === void 0 ? c.context.beforeContentFocusGuardRef : void 0,
484
- children: V,
485
- })
486
- );
487
- }),
488
- Nt = o.createContext(void 0);
489
- function Ks() {
490
- const e = o.useContext(Nt);
491
- if (e === void 0) throw new Error(ve(32));
492
- return e;
493
- }
494
- const Ls = o.forwardRef((n, r) => {
495
- const { keepMounted: s = !1, ...p } = n,
496
- { store: i } = me();
497
- return i.useState('mounted') || s
498
- ? t.jsx(Nt.Provider, { value: s, children: t.jsx(sn, { ref: r, ...p }) })
499
- : null;
500
- }),
501
- $s = o.forwardRef((n, r) => {
502
- var ae;
503
- const {
504
- anchor: s,
505
- positionMethod: p = 'absolute',
506
- className: i,
507
- render: m,
508
- side: c,
509
- align: y,
510
- sideOffset: b = 0,
511
- alignOffset: C = 0,
512
- collisionBoundary: v = 'clipping-ancestors',
513
- collisionPadding: I = 5,
514
- arrowPadding: x = 5,
515
- sticky: S = !1,
516
- disableAnchorTracking: g = !1,
517
- collisionAvoidance: M = on,
518
- ...j
519
- } = n,
520
- { store: u } = me(),
521
- N = Ks(),
522
- $ = Ne(!0),
523
- f = u.useState('parent'),
524
- a = u.useState('floatingRootContext'),
525
- w = u.useState('floatingTreeRoot'),
526
- l = u.useState('mounted'),
527
- d = u.useState('open'),
528
- k = u.useState('modal'),
529
- q = u.useState('activeTriggerElement'),
530
- V = u.useState('transitionStatus'),
531
- A = u.useState('lastOpenChangeReason'),
532
- O = u.useState('floatingNodeId'),
533
- H = u.useState('floatingParentNodeId');
534
- let le = s,
535
- P = b,
536
- U = C,
537
- Z = y,
538
- Y = M;
539
- f.type === 'context-menu' &&
540
- ((le = s ?? ((ae = f.context) == null ? void 0 : ae.anchor)),
541
- (Z = Z ?? 'start'),
542
- !c && Z !== 'center' && ((U = n.alignOffset ?? 2), (P = n.sideOffset ?? -5)));
543
- let _ = c,
544
- Q = Z;
545
- f.type === 'menu'
546
- ? ((_ = _ ?? 'inline-end'), (Q = Q ?? 'start'), (Y = n.collisionAvoidance ?? an))
547
- : f.type === 'menubar' && ((_ = _ ?? 'bottom'), (Q = Q ?? 'start'));
548
- const B = f.type === 'context-menu',
549
- E = rn({
550
- anchor: le,
551
- floatingRootContext: a,
552
- positionMethod: $ ? 'fixed' : p,
553
- mounted: l,
554
- side: _,
555
- sideOffset: P,
556
- align: Q,
557
- alignOffset: U,
558
- arrowPadding: B ? 0 : x,
559
- collisionBoundary: v,
560
- collisionPadding: I,
561
- sticky: S,
562
- nodeId: O,
563
- keepMounted: N,
564
- disableAnchorTracking: g,
565
- collisionAvoidance: Y,
566
- shiftCrossAxis: B && !('side' in Y && Y.side === 'flip'),
567
- externalTree: w,
568
- }),
569
- se = o.useMemo(() => {
570
- const T = {};
571
- return (
572
- d || (T.pointerEvents = 'none'),
573
- { role: 'presentation', hidden: !l, style: { ...E.positionerStyles, ...T } }
574
- );
575
- }, [d, l, E.positionerStyles]);
576
- o.useEffect(() => {
577
- function T(D) {
578
- D.open &&
579
- (D.parentNodeId === O && u.set('hoverEnabled', !1),
580
- D.nodeId !== O &&
581
- D.parentNodeId === u.select('floatingParentNodeId') &&
582
- u.setOpen(!1, ue(je)));
583
- }
584
- return (
585
- w.events.on('menuopenchange', T),
586
- () => {
587
- w.events.off('menuopenchange', T);
588
- }
589
- );
590
- }, [u, w.events, O]),
591
- o.useEffect(() => {
592
- if (u.select('floatingParentNodeId') == null) return;
593
- function T(D) {
594
- if (D.open || D.nodeId !== u.select('floatingParentNodeId')) return;
595
- const ge = D.reason ?? je;
596
- u.setOpen(!1, ue(ge));
597
- }
598
- return (
599
- w.events.on('menuopenchange', T),
600
- () => {
601
- w.events.off('menuopenchange', T);
602
- }
603
- );
604
- }, [w.events, u]),
605
- o.useEffect(() => {
606
- function T(D) {
607
- !d ||
608
- D.nodeId !== u.select('floatingParentNodeId') ||
609
- (D.target && q && q !== D.target && u.setOpen(!1, ue(je)));
610
- }
611
- return (
612
- w.events.on('itemhover', T),
613
- () => {
614
- w.events.off('itemhover', T);
615
- }
616
- );
617
- }, [w.events, d, q, u]),
618
- o.useEffect(() => {
619
- const T = { open: d, nodeId: O, parentNodeId: H, reason: u.select('lastOpenChangeReason') };
620
- w.events.emit('menuopenchange', T);
621
- }, [w.events, d, u, O, H]);
622
- const xe = {
623
- open: d,
624
- side: E.side,
625
- align: E.align,
626
- anchorHidden: E.anchorHidden,
627
- nested: f.type === 'menu',
628
- },
629
- fe = o.useMemo(
630
- () => ({
631
- side: E.side,
632
- align: E.align,
633
- arrowRef: E.arrowRef,
634
- arrowUncentered: E.arrowUncentered,
635
- arrowStyles: E.arrowStyles,
636
- nodeId: E.context.nodeId,
637
- }),
638
- [E.side, E.align, E.arrowRef, E.arrowUncentered, E.arrowStyles, E.context.nodeId]
639
- ),
640
- de = ye('div', n, {
641
- state: xe,
642
- stateAttributesMapping: gt,
643
- ref: [r, u.useStateSetter('positionerElement')],
644
- props: [se, ht(V), j],
645
- }),
646
- oe =
647
- l &&
648
- f.type !== 'menu' &&
649
- ((f.type !== 'menubar' && k && A !== Me) || (f.type === 'menubar' && f.context.modal));
650
- let J = null;
651
- return (
652
- f.type === 'menubar' ? (J = f.context.contentElement) : f.type === void 0 && (J = q),
653
- t.jsxs(Pt.Provider, {
654
- value: fe,
655
- children: [
656
- oe &&
657
- t.jsx(cn, {
658
- ref:
659
- f.type === 'context-menu' || f.type === 'nested-context-menu'
660
- ? f.context.internalBackdropRef
661
- : null,
662
- inert: ln(!d),
663
- cutout: J,
664
- }),
665
- t.jsx(dn, {
666
- id: O,
667
- children: t.jsx(es, {
668
- elementsRef: u.context.itemDomElements,
669
- labelsRef: u.context.itemLabels,
670
- children: de,
671
- }),
672
- }),
673
- ],
674
- })
675
- );
676
- }),
677
- Us = o.createContext(null);
678
- function Et(e) {
679
- return o.useContext(Us);
680
- }
681
- const Bs = {
682
- ...mn,
683
- disabled: K((e) => (e.parent.type === 'menubar' && e.parent.context.disabled) || e.disabled),
684
- modal: K(
685
- (e) => (e.parent.type === void 0 || e.parent.type === 'context-menu') && (e.modal ?? !0)
686
- ),
687
- allowMouseEnter: K((e) => e.allowMouseEnter),
688
- stickIfOpen: K((e) => e.stickIfOpen),
689
- parent: K((e) => e.parent),
690
- rootId: K((e) =>
691
- e.parent.type === 'menu'
692
- ? e.parent.store.select('rootId')
693
- : e.parent.type !== void 0
694
- ? e.parent.context.rootId
695
- : e.rootId
696
- ),
697
- activeIndex: K((e) => e.activeIndex),
698
- isActive: K((e, n) => e.activeIndex === n),
699
- hoverEnabled: K((e) => e.hoverEnabled),
700
- instantType: K((e) => e.instantType),
701
- lastOpenChangeReason: K((e) => e.openChangeReason),
702
- floatingTreeRoot: K((e) =>
703
- e.parent.type === 'menu' ? e.parent.store.select('floatingTreeRoot') : e.floatingTreeRoot
704
- ),
705
- floatingNodeId: K((e) => e.floatingNodeId),
706
- floatingParentNodeId: K((e) => e.floatingParentNodeId),
707
- itemProps: K((e) => e.itemProps),
708
- closeDelay: K((e) => e.closeDelay),
709
- keyboardEventRelay: K((e) => {
710
- if (e.keyboardEventRelay) return e.keyboardEventRelay;
711
- if (e.parent.type === 'menu') return e.parent.store.select('keyboardEventRelay');
712
- }),
713
- };
714
- class ze extends un {
715
- constructor(r) {
716
- super(
717
- { ...zs(), ...r },
718
- {
719
- positionerRef: o.createRef(),
720
- popupRef: o.createRef(),
721
- typingRef: { current: !1 },
722
- itemDomElements: { current: [] },
723
- itemLabels: { current: [] },
724
- allowMouseUpTriggerRef: { current: !1 },
725
- triggerFocusTargetRef: o.createRef(),
726
- beforeContentFocusGuardRef: o.createRef(),
727
- onOpenChangeComplete: void 0,
728
- triggerElements: new pn(),
729
- },
730
- Bs
731
- );
732
- Xe(this, 'unsubscribeParentListener', null);
733
- this.unsubscribeParentListener = this.observe('parent', (s) => {
734
- var p;
735
- if (((p = this.unsubscribeParentListener) == null || p.call(this), s.type === 'menu')) {
736
- (this.unsubscribeParentListener = s.store.subscribe(() => {
737
- this.notifyAll();
738
- })),
739
- (this.context.allowMouseUpTriggerRef = s.store.context.allowMouseUpTriggerRef);
740
- return;
741
- }
742
- s.type !== void 0 && (this.context.allowMouseUpTriggerRef = s.context.allowMouseUpTriggerRef),
743
- (this.unsubscribeParentListener = null);
744
- });
745
- }
746
- setOpen(r, s) {
747
- this.state.floatingRootContext.context.events.emit('setOpen', { open: r, eventDetails: s });
748
- }
749
- static useStore(r, s) {
750
- const p = fn(() => new ze(s)).current;
751
- return r ?? p;
752
- }
753
- }
754
- function zs() {
755
- return {
756
- ...gn(),
757
- disabled: !1,
758
- modal: !0,
759
- allowMouseEnter: !1,
760
- stickIfOpen: !0,
761
- parent: { type: void 0 },
762
- rootId: void 0,
763
- activeIndex: null,
764
- hoverEnabled: !0,
765
- instantType: void 0,
766
- openChangeReason: null,
767
- floatingTreeRoot: new xt(),
768
- floatingNodeId: void 0,
769
- floatingParentNodeId: null,
770
- itemProps: Se,
771
- keyboardEventRelay: void 0,
772
- closeDelay: 0,
773
- };
774
- }
775
- const _s = o.createContext(void 0);
776
- function qs() {
777
- return o.useContext(_s);
778
- }
779
- const Gs = hn((n) => {
780
- const {
781
- children: r,
782
- open: s,
783
- onOpenChange: p,
784
- onOpenChangeComplete: i,
785
- defaultOpen: m = !1,
786
- disabled: c = !1,
787
- modal: y,
788
- loopFocus: b = !0,
789
- orientation: C = 'vertical',
790
- actionsRef: v,
791
- closeParentOnEsc: I = !1,
792
- handle: x,
793
- triggerId: S,
794
- defaultTriggerId: g = null,
795
- highlightItemOnHover: M = !0,
796
- } = n,
797
- j = Ne(!0),
798
- u = me(!0),
799
- N = Et(!0),
800
- $ = qs(),
801
- f = o.useMemo(
802
- () =>
803
- $ && u
804
- ? { type: 'menu', store: u.store }
805
- : N
806
- ? { type: 'menubar', context: N }
807
- : j && !u
808
- ? { type: 'context-menu', context: j }
809
- : { type: void 0 },
810
- [j, u, N, $]
811
- ),
812
- a = ze.useStore(x == null ? void 0 : x.store, {
813
- open: m,
814
- openProp: s,
815
- activeTriggerId: g,
816
- triggerIdProp: S,
817
- parent: f,
818
- });
819
- xn(() => {
820
- s === void 0 && a.state.open === !1 && m === !0 && a.update({ open: !0, activeTriggerId: g });
821
- }),
822
- a.useControlledProp('openProp', s),
823
- a.useControlledProp('triggerIdProp', S),
824
- a.useContextCallback('onOpenChangeComplete', i);
825
- const w = a.useState('floatingTreeRoot'),
826
- l = vt(w),
827
- d = yt();
828
- He(() => {
829
- j && !u
830
- ? a.update({
831
- parent: { type: 'context-menu', context: j },
832
- floatingNodeId: l,
833
- floatingParentNodeId: d,
834
- })
835
- : u && a.update({ floatingNodeId: l, floatingParentNodeId: d });
836
- }, [j, u, l, d, a]);
837
- const k = a.useState('open'),
838
- q = a.useState('activeTriggerElement'),
839
- V = a.useState('positionerElement'),
840
- A = a.useState('hoverEnabled'),
841
- O = a.useState('modal'),
842
- H = a.useState('disabled'),
843
- le = a.useState('lastOpenChangeReason'),
844
- P = a.useState('parent'),
845
- U = a.useState('activeIndex'),
846
- Z = a.useState('payload'),
847
- Y = a.useState('floatingParentNodeId'),
848
- _ = o.useRef(null),
849
- Q = Y != null;
850
- let B;
851
- a.useSyncedValues({ disabled: c, modal: P.type === void 0 ? y : void 0, rootId: vn() });
852
- const { openMethod: E, triggerProps: se, reset: xe } = yn(k);
853
- bn(a);
854
- const { forceUnmount: fe } = Cn(k, a, () => {
855
- a.update({ allowMouseEnter: !1, stickIfOpen: !0 }), xe();
856
- }),
857
- de = o.useRef(P.type !== 'context-menu'),
858
- oe = Pe();
859
- o.useEffect(() => {
860
- if ((k || (_.current = null), P.type === 'context-menu')) {
861
- if (!k) {
862
- oe.clear(), (de.current = !1);
863
- return;
864
- }
865
- oe.start(500, () => {
866
- de.current = !0;
867
- });
868
- }
869
- }, [oe, k, P.type]),
870
- jn(k && O && le !== Me && E !== 'touch', V),
871
- He(() => {
872
- !k && !A && a.set('hoverEnabled', !0);
873
- }, [k, A, a]);
874
- const J = o.useRef(!0),
875
- ae = Pe(),
876
- T = we((h, R) => {
877
- var We;
878
- const z = R.reason;
879
- if (
880
- (k === h && R.trigger === q && le === z) ||
881
- ((R.preventUnmountOnClose = () => {
882
- a.set('preventUnmountingOnClose', !0);
883
- }),
884
- !h && R.trigger == null && (R.trigger = q ?? void 0),
885
- p == null || p(h, R),
886
- R.isCanceled)
887
- )
888
- return;
889
- const $t = { open: h, nativeEvent: R.event, reason: R.reason, nested: Q };
890
- B == null || B.emit('openchange', $t);
891
- const re = R.event;
892
- if (
893
- h === !1 &&
894
- (re == null ? void 0 : re.type) === 'click' &&
895
- re.pointerType === 'touch' &&
896
- !J.current
897
- )
898
- return;
899
- if (!h && U !== null) {
900
- const Oe = a.context.itemDomElements.current[U];
901
- queueMicrotask(() => {
902
- Oe == null || Oe.setAttribute('tabindex', '-1');
903
- });
904
- }
905
- h && z === Ze
906
- ? ((J.current = !1),
907
- ae.start(300, () => {
908
- J.current = !0;
909
- }))
910
- : ((J.current = !0), ae.clear());
911
- const Qe = (z === wn || z === ut) && re.detail === 0 && (re == null ? void 0 : re.isTrusted),
912
- Ut = !h && (z === Rn || z == null),
913
- ke = { open: h, openChangeReason: z };
914
- _.current = R.event ?? null;
915
- const Je = ((We = R.trigger) == null ? void 0 : We.id) ?? null;
916
- (Je || h) && ((ke.activeTriggerId = Je), (ke.activeTriggerElement = R.trigger ?? null)),
917
- a.update(ke),
918
- P.type === 'menubar' && (z === Ze || z === Ke || z === Me || z === In || z === je)
919
- ? a.set('instantType', 'group')
920
- : Qe || Ut
921
- ? a.set('instantType', Qe ? 'click' : 'dismiss')
922
- : a.set('instantType', void 0);
923
- }),
924
- D = o.useCallback(
925
- (h) => {
926
- const R = ue(h);
927
- return (
928
- (R.preventUnmountOnClose = () => {
929
- a.set('preventUnmountingOnClose', !0);
930
- }),
931
- R
932
- );
933
- },
934
- [a]
935
- ),
936
- ge = o.useCallback(() => {
937
- a.setOpen(!1, D(Mn));
938
- }, [a, D]);
939
- o.useImperativeHandle(v, () => ({ unmount: fe, close: ge }), [fe, ge]);
940
- let ee;
941
- P.type === 'context-menu' && (ee = P.context),
942
- o.useImperativeHandle(ee == null ? void 0 : ee.positionerRef, () => V, [V]),
943
- o.useImperativeHandle(ee == null ? void 0 : ee.actionsRef, () => ({ setOpen: T }), [T]);
944
- const te = Pn({ popupStore: a, onOpenChange: T });
945
- (B = te.context.events),
946
- o.useEffect(() => {
947
- const h = ({ open: R, eventDetails: z }) => T(R, z);
948
- return (
949
- B.on('setOpen', h),
950
- () => {
951
- B == null || B.off('setOpen', h);
952
- }
953
- );
954
- }, [B, T]);
955
- const F = Tn(te, {
956
- enabled: !H,
957
- bubbles: { escapeKey: I && P.type === 'menu' },
958
- outsidePress() {
959
- var h;
960
- return P.type !== 'context-menu' ||
961
- ((h = _.current) == null ? void 0 : h.type) === 'contextmenu'
962
- ? !0
963
- : de.current;
964
- },
965
- externalTree: Q ? w : void 0,
966
- }),
967
- L = Sn(te, { role: 'menu' }),
968
- ne = Nn(),
969
- G = o.useCallback(
970
- (h) => {
971
- a.select('activeIndex') !== h && a.set('activeIndex', h);
972
- },
973
- [a]
974
- ),
975
- Ee = ts(te, {
976
- enabled: !H,
977
- listRef: a.context.itemDomElements,
978
- activeIndex: U,
979
- nested: P.type !== void 0,
980
- loopFocus: b,
981
- orientation: C,
982
- parentOrientation: P.type === 'menubar' ? P.context.orientation : void 0,
983
- rtl: ne === 'rtl',
984
- disabledIndices: Le,
985
- onNavigate: G,
986
- openOnArrowKeyDown: P.type !== 'context-menu',
987
- externalTree: Q ? w : void 0,
988
- focusItemOnHover: M,
989
- }),
990
- Ot = o.useCallback(
991
- (h) => {
992
- a.context.typingRef.current = h;
993
- },
994
- [a]
995
- ),
996
- Dt = ns(te, {
997
- listRef: a.context.itemLabels,
998
- activeIndex: U,
999
- resetMs: En,
1000
- onMatch: (h) => {
1001
- k && h !== U && a.set('activeIndex', h);
1002
- },
1003
- onTypingChange: Ot,
1004
- }),
1005
- {
1006
- getReferenceProps: _e,
1007
- getFloatingProps: qe,
1008
- getItemProps: Ge,
1009
- getTriggerProps: Ve,
1010
- } = bt([F, L, Ee, Dt]),
1011
- Ft = o.useMemo(() => {
1012
- const h = Ae(
1013
- _e(),
1014
- {
1015
- onMouseMove() {
1016
- a.set('allowMouseEnter', !0);
1017
- },
1018
- },
1019
- se
1020
- );
1021
- return delete h.role, h;
1022
- }, [_e, a, se]),
1023
- At = o.useMemo(() => {
1024
- const h = Ve();
1025
- if (!h) return h;
1026
- const R = Ae(h, se);
1027
- return delete R.role, delete R['aria-controls'], R;
1028
- }, [Ve, se]),
1029
- Ht = o.useMemo(
1030
- () =>
1031
- qe({
1032
- onMouseMove() {
1033
- a.set('allowMouseEnter', !0), P.type === 'menu' && a.set('hoverEnabled', !1);
1034
- },
1035
- onClick() {
1036
- a.select('hoverEnabled') && a.set('hoverEnabled', !1);
1037
- },
1038
- onKeyDown(h) {
1039
- const R = a.select('keyboardEventRelay');
1040
- R && !h.isPropagationStopped() && R(h);
1041
- },
1042
- }),
1043
- [qe, P.type, a]
1044
- ),
1045
- Kt = o.useMemo(() => Ge(), [Ge]);
1046
- a.useSyncedValues({
1047
- floatingRootContext: te,
1048
- activeTriggerProps: Ft,
1049
- inactiveTriggerProps: At,
1050
- popupProps: Ht,
1051
- itemProps: Kt,
1052
- });
1053
- const Lt = o.useMemo(() => ({ store: a, parent: f }), [a, f]),
1054
- Ye = t.jsx(St.Provider, {
1055
- value: Lt,
1056
- children: typeof r == 'function' ? r({ payload: Z }) : r,
1057
- });
1058
- return P.type === void 0 || P.type === 'context-menu'
1059
- ? t.jsx(kn, { externalTree: w, children: Ye })
1060
- : Ye;
1061
- });
1062
- function Vs(e = {}) {
1063
- const { highlightItemOnHover: n, highlightedIndex: r, onHighlightedIndexChange: s } = Ct(),
1064
- { ref: p, index: i } = It(e),
1065
- m = r === i,
1066
- c = o.useRef(null),
1067
- y = mt(p, c);
1068
- return {
1069
- compositeProps: o.useMemo(
1070
- () => ({
1071
- tabIndex: m ? 0 : -1,
1072
- onFocus() {
1073
- s(i);
1074
- },
1075
- onMouseMove() {
1076
- const C = c.current;
1077
- if (!n || !C) return;
1078
- const v = C.hasAttribute('disabled') || C.ariaDisabled === 'true';
1079
- !m && !v && C.focus();
1080
- },
1081
- }),
1082
- [m, s, i, n]
1083
- ),
1084
- compositeRef: y,
1085
- index: i,
1086
- };
1087
- }
1088
- function Ys(e) {
1089
- const {
1090
- render: n,
1091
- className: r,
1092
- state: s = Se,
1093
- props: p = Le,
1094
- refs: i = Le,
1095
- metadata: m,
1096
- stateAttributesMapping: c,
1097
- tag: y = 'div',
1098
- ...b
1099
- } = e,
1100
- { compositeProps: C, compositeRef: v } = Vs({ metadata: m });
1101
- return ye(y, e, { state: s, ref: [...i, v], props: [C, ...p, b], stateAttributesMapping: c });
1102
- }
1103
- function kt(e) {
1104
- if (On(e) && e.hasAttribute('data-rootownerid'))
1105
- return e.getAttribute('data-rootownerid') ?? void 0;
1106
- if (!Dn(e)) return kt(Fn(e));
1107
- }
1108
- function Qs(e) {
1109
- const { enabled: n = !0, mouseDownAction: r, open: s } = e,
1110
- p = o.useRef(!1);
1111
- return o.useMemo(
1112
- () =>
1113
- n
1114
- ? {
1115
- onMouseDown: (i) => {
1116
- ((r === 'open' && !s) || (r === 'close' && s)) &&
1117
- ((p.current = !0),
1118
- $e(i.currentTarget).addEventListener(
1119
- 'click',
1120
- () => {
1121
- p.current = !1;
1122
- },
1123
- { once: !0 }
1124
- ));
1125
- },
1126
- onClick: (i) => {
1127
- p.current && ((p.current = !1), i.preventBaseUIHandler());
1128
- },
1129
- }
1130
- : Se,
1131
- [n, r, s]
1132
- );
1133
- }
1134
- const Ce = 2,
1135
- Js = An((n, r) => {
1136
- const {
1137
- render: s,
1138
- className: p,
1139
- disabled: i = !1,
1140
- nativeButton: m = !0,
1141
- id: c,
1142
- openOnHover: y,
1143
- delay: b = 100,
1144
- closeDelay: C = 0,
1145
- handle: v,
1146
- payload: I,
1147
- ...x
1148
- } = n,
1149
- S = me(!0),
1150
- g = (v == null ? void 0 : v.store) ?? (S == null ? void 0 : S.store);
1151
- if (!g) throw new Error(ve(85));
1152
- const M = ft(c),
1153
- j = g.useState('isTriggerActive', M),
1154
- u = g.useState('floatingRootContext'),
1155
- N = g.useState('isOpenedByTrigger', M),
1156
- $ = o.useRef(null),
1157
- f = Xs(),
1158
- a = Ct(!0),
1159
- w = Hn(),
1160
- l = o.useMemo(() => w ?? new xt(), [w]),
1161
- d = vt(l),
1162
- k = yt(),
1163
- { registerTrigger: q, isMountedByThisTrigger: V } = Kn(M, $, g, {
1164
- payload: I,
1165
- closeDelay: C,
1166
- parent: f,
1167
- floatingTreeRoot: l,
1168
- floatingNodeId: d,
1169
- floatingParentNodeId: k,
1170
- keyboardEventRelay: a == null ? void 0 : a.relayKeyboardEvent,
1171
- }),
1172
- A = f.type === 'menubar',
1173
- O = g.useState('disabled'),
1174
- H = i || O || (A && f.context.disabled),
1175
- { getButtonProps: le, buttonRef: P } = pt({ disabled: H, native: m });
1176
- o.useEffect(() => {
1177
- !N && f.type === void 0 && (g.context.allowMouseUpTriggerRef.current = !1);
1178
- }, [g, N, f.type]);
1179
- const U = o.useRef(null),
1180
- Z = Pe(),
1181
- Y = we((F) => {
1182
- if (!U.current) return;
1183
- Z.clear(), (g.context.allowMouseUpTriggerRef.current = !1);
1184
- const L = F.target;
1185
- if (
1186
- De(U.current, L) ||
1187
- De(g.select('positionerElement'), L) ||
1188
- L === U.current ||
1189
- (L != null && kt(L) === g.select('rootId'))
1190
- )
1191
- return;
1192
- const ne = ss(U.current);
1193
- (F.clientX >= ne.left - Ce &&
1194
- F.clientX <= ne.right + Ce &&
1195
- F.clientY >= ne.top - Ce &&
1196
- F.clientY <= ne.bottom + Ce) ||
1197
- l.events.emit('close', { domEvent: F, reason: Ln });
1198
- });
1199
- o.useEffect(() => {
1200
- N &&
1201
- g.select('lastOpenChangeReason') === Me &&
1202
- $e(U.current).addEventListener('mouseup', Y, { once: !0 });
1203
- }, [N, Y, g]);
1204
- const _ = A && f.context.hasSubmenuOpen,
1205
- B = $n(u, {
1206
- enabled: (y ?? _) && !H && f.type !== 'context-menu' && (!A || (_ && !V)),
1207
- handleClose: Un({ blockPointerEvents: !A }),
1208
- mouseOnly: !0,
1209
- move: !1,
1210
- restMs: f.type === void 0 ? b : void 0,
1211
- delay: { close: C },
1212
- triggerElementRef: $,
1213
- externalTree: l,
1214
- isActiveTrigger: j,
1215
- }),
1216
- E = Ws(N, g.select('lastOpenChangeReason')),
1217
- se = os(u, {
1218
- enabled: !H && f.type !== 'context-menu',
1219
- event: N && A ? 'click' : 'mousedown',
1220
- toggle: !0,
1221
- ignoreMouse: !1,
1222
- stickIfOpen: f.type === void 0 ? E : !1,
1223
- }),
1224
- xe = Bn(u, { enabled: !H && _ }),
1225
- fe = Qs({ open: N, enabled: A, mouseDownAction: 'open' }),
1226
- de = bt([se, xe]),
1227
- oe = { disabled: H, open: N },
1228
- J = g.useState('triggerProps', V),
1229
- ae = [U, r, P, q, $],
1230
- T = [
1231
- de.getReferenceProps(),
1232
- B ?? Se,
1233
- J,
1234
- {
1235
- 'aria-haspopup': 'menu',
1236
- id: M,
1237
- onMouseDown: (F) => {
1238
- if (g.select('open')) return;
1239
- Z.start(200, () => {
1240
- g.context.allowMouseUpTriggerRef.current = !0;
1241
- }),
1242
- $e(F.currentTarget).addEventListener('mouseup', Y, { once: !0 });
1243
- },
1244
- },
1245
- A ? { role: 'menuitem' } : {},
1246
- fe,
1247
- x,
1248
- le,
1249
- ],
1250
- D = o.useRef(null),
1251
- ge = we((F) => {
1252
- et.flushSync(() => {
1253
- g.setOpen(!1, ue(Ke, F.nativeEvent, F.currentTarget));
1254
- });
1255
- const L = zn(D.current);
1256
- L == null || L.focus();
1257
- }),
1258
- ee = we((F) => {
1259
- var ne;
1260
- const L = g.select('positionerElement');
1261
- if (L && _n(F, L))
1262
- (ne = g.context.beforeContentFocusGuardRef.current) == null || ne.focus();
1263
- else {
1264
- et.flushSync(() => {
1265
- g.setOpen(!1, ue(Ke, F.nativeEvent, F.currentTarget));
1266
- });
1267
- let G = qn(g.context.triggerFocusTargetRef.current || $.current);
1268
- while (G !== null && De(L, G)) {
1269
- const Ee = G;
1270
- if (((G = Gn(G)), G === Ee)) break;
1271
- }
1272
- G == null || G.focus();
1273
- }
1274
- }),
1275
- te = ye('button', n, {
1276
- enabled: !A,
1277
- stateAttributesMapping: tt,
1278
- state: oe,
1279
- ref: ae,
1280
- props: T,
1281
- });
1282
- return A
1283
- ? t.jsx(Ys, {
1284
- tag: 'button',
1285
- render: s,
1286
- className: p,
1287
- state: oe,
1288
- refs: ae,
1289
- props: T,
1290
- stateAttributesMapping: tt,
1291
- })
1292
- : N
1293
- ? t.jsxs(o.Fragment, {
1294
- children: [
1295
- t.jsx(nt, { ref: D, onFocus: ge }, `${M}-pre-focus-guard`),
1296
- t.jsx(o.Fragment, { children: te }, M),
1297
- t.jsx(
1298
- nt,
1299
- { ref: g.context.triggerFocusTargetRef, onFocus: ee },
1300
- `${M}-post-focus-guard`
1301
- ),
1302
- ],
1303
- })
1304
- : t.jsx(o.Fragment, { children: te }, M);
1305
- });
1306
- function Ws(e, n) {
1307
- const r = Pe(),
1308
- [s, p] = o.useState(!1);
1309
- return (
1310
- He(() => {
1311
- e && n === 'trigger-hover'
1312
- ? (p(!0),
1313
- r.start(Vn, () => {
1314
- p(!1);
1315
- }))
1316
- : e || (r.clear(), p(!1));
1317
- }, [e, n, r]),
1318
- s
1319
- );
1320
- }
1321
- function Xs() {
1322
- const e = Ne(!0),
1323
- n = me(!0),
1324
- r = Et();
1325
- return o.useMemo(
1326
- () =>
1327
- r
1328
- ? { type: 'menubar', context: r }
1329
- : e && !n
1330
- ? { type: 'context-menu', context: e }
1331
- : { type: void 0 },
1332
- [e, n, r]
1333
- );
1334
- }
1335
- function Zs({ ...e }) {
1336
- return t.jsx(Gs, { 'data-slot': 'dropdown-menu', ...e });
1337
- }
1338
- function eo({ ...e }) {
1339
- return t.jsx(Js, { 'data-slot': 'dropdown-menu-trigger', ...e });
1340
- }
1341
- function to({
1342
- align: e = 'start',
1343
- alignOffset: n = 0,
1344
- side: r = 'bottom',
1345
- sideOffset: s = 4,
1346
- className: p,
1347
- ...i
1348
- }) {
1349
- return t.jsx(Ls, {
1350
- children: t.jsx($s, {
1351
- className: 'isolate z-50 outline-none',
1352
- align: e,
1353
- alignOffset: n,
1354
- side: r,
1355
- sideOffset: s,
1356
- children: t.jsx(Hs, {
1357
- 'data-slot': 'dropdown-menu-content',
1358
- className: X(
1359
- 'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden',
1360
- p
1361
- ),
1362
- ...i,
1363
- }),
1364
- }),
1365
- });
1366
- }
1367
- function Fe({ className: e, inset: n, variant: r = 'default', ...s }) {
1368
- return t.jsx(Fs, {
1369
- 'data-slot': 'dropdown-menu-item',
1370
- 'data-inset': n,
1371
- 'data-variant': r,
1372
- className: X(
1373
- "focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground gap-1.5 rounded-md px-1.5 py-1 text-sm data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
1374
- e
1375
- ),
1376
- ...s,
1377
- });
1378
- }
1379
- function no({ className: e, ...n }) {
1380
- return t.jsx(Yn, {
1381
- 'data-slot': 'dropdown-menu-separator',
1382
- className: X('bg-border -mx-1 my-1 h-px', e),
1383
- ...n,
1384
- });
1385
- }
1386
- function so({ className: e, ...n }) {
1387
- return t.jsx('textarea', {
1388
- 'data-slot': 'textarea',
1389
- className: X(
1390
- 'border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 rounded-lg border bg-transparent px-2.5 py-2 text-base transition-colors focus-visible:ring-3 aria-invalid:ring-3 md:text-sm placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full outline-none disabled:cursor-not-allowed disabled:opacity-50',
1391
- e
1392
- ),
1393
- ...n,
1394
- });
1395
- }
1396
- function W(e) {
1397
- const n = e.trim();
1398
- return n || void 0;
1399
- }
1400
- function oo(e) {
1401
- return e
1402
- ? {
1403
- name: e.name,
1404
- type: e.type,
1405
- host: e.host ?? '',
1406
- port: e.port ?? 22,
1407
- username: e.username ?? '',
1408
- sshConfigRef: e.sshConfigRef ?? '',
1409
- session: e.session ?? 'tmex',
1410
- authMode: e.type === 'local' ? 'auto' : e.authMode,
1411
- password: '',
1412
- privateKey: '',
1413
- privateKeyPassphrase: '',
1414
- }
1415
- : {
1416
- name: '',
1417
- type: 'local',
1418
- host: '',
1419
- port: 22,
1420
- username: '',
1421
- sshConfigRef: '',
1422
- session: 'tmex',
1423
- authMode: 'auto',
1424
- password: '',
1425
- privateKey: '',
1426
- privateKeyPassphrase: '',
1427
- };
1428
- }
1429
- function ao(e) {
1430
- if (e.type === 'local')
1431
- return {
1432
- name: e.name.trim(),
1433
- type: 'local',
1434
- session: W(e.session) ?? 'tmex',
1435
- authMode: 'auto',
1436
- };
1437
- const n = {
1438
- name: e.name.trim(),
1439
- type: 'ssh',
1440
- host: W(e.host),
1441
- port: e.port,
1442
- username: W(e.username),
1443
- sshConfigRef: W(e.sshConfigRef),
1444
- session: W(e.session) ?? 'tmex',
1445
- authMode: e.authMode,
1446
- };
1447
- return (
1448
- e.authMode === 'password' && (n.password = e.password),
1449
- e.authMode === 'key' &&
1450
- ((n.privateKey = e.privateKey), (n.privateKeyPassphrase = e.privateKeyPassphrase || void 0)),
1451
- n
1452
- );
1453
- }
1454
- function ro(e) {
1455
- if (e.type === 'local')
1456
- return { name: e.name.trim(), session: W(e.session) ?? 'tmex', authMode: 'auto' };
1457
- const n = {
1458
- name: e.name.trim(),
1459
- host: W(e.host),
1460
- port: e.port,
1461
- username: W(e.username),
1462
- sshConfigRef: W(e.sshConfigRef),
1463
- session: W(e.session) ?? 'tmex',
1464
- authMode: e.authMode,
1465
- };
1466
- return (
1467
- e.authMode === 'password' && e.password && (n.password = e.password),
1468
- e.authMode === 'key' &&
1469
- e.privateKey &&
1470
- ((n.privateKey = e.privateKey), (n.privateKeyPassphrase = e.privateKeyPassphrase || void 0)),
1471
- n
1472
- );
1473
- }
1474
- async function ct(e, n) {
1475
- try {
1476
- return (await e.json()).error ?? n;
1477
- } catch {
1478
- return n;
1479
- }
1480
- }
1481
- function mo() {
1482
- const { t: e } = be(),
1483
- [n, r] = o.useState(!1),
1484
- [s, p] = o.useState(null),
1485
- [i, m] = o.useState(null),
1486
- c = jt();
1487
- o.useEffect(() => {
1488
- const x = () => r(!0);
1489
- return (
1490
- window.addEventListener('tmex:open-add-device', x),
1491
- () => window.removeEventListener('tmex:open-add-device', x)
1492
- );
1493
- }, []);
1494
- const {
1495
- data: y,
1496
- isLoading: b,
1497
- isError: C,
1498
- } = Qn({
1499
- queryKey: ['devices'],
1500
- queryFn: async () => {
1501
- const x = await fetch('/api/devices');
1502
- if (!x.ok) throw new Error(e('device.loadFailed'));
1503
- return x.json();
1504
- },
1505
- throwOnError: !1,
1506
- }),
1507
- v = Te({
1508
- mutationFn: async (x) => {
1509
- if (!(await fetch(`/api/devices/${x}`, { method: 'DELETE' })).ok)
1510
- throw new Error(e('device.deleteFailed'));
1511
- },
1512
- onSuccess: () => {
1513
- c.invalidateQueries({ queryKey: ['devices'] }), ce.success(e('common.success'));
1514
- },
1515
- onError: (x) => {
1516
- ce.error(x instanceof Error ? x.message : e('common.error'));
1517
- },
1518
- }),
1519
- I = (y == null ? void 0 : y.devices) ?? [];
1520
- return t.jsxs('div', {
1521
- className:
1522
- 'mx-auto flex w-full max-w-6xl flex-col gap-3 p-3 pb-[calc(1rem+env(safe-area-inset-bottom))] sm:gap-4 sm:p-5',
1523
- 'data-testid': 'devices-page',
1524
- children: [
1525
- b
1526
- ? t.jsx(Re, {
1527
- children: t.jsx(Ie, {
1528
- className: 'py-16 text-center text-sm text-muted-foreground',
1529
- children: e('common.loading'),
1530
- }),
1531
- })
1532
- : C
1533
- ? t.jsx(Re, {
1534
- children: t.jsx(Ie, {
1535
- className: 'py-16 text-center text-sm text-destructive',
1536
- children: e('device.loadFailed'),
1537
- }),
1538
- })
1539
- : I.length === 0
1540
- ? t.jsx(Re, {
1541
- children: t.jsxs(Ie, {
1542
- className: 'space-y-4 py-14 text-center',
1543
- children: [
1544
- t.jsx('div', {
1545
- className:
1546
- 'mx-auto flex h-12 w-12 items-center justify-center rounded-xl border border-border bg-muted',
1547
- children: t.jsx(wt, { className: 'h-6 w-6 text-muted-foreground' }),
1548
- }),
1549
- t.jsxs('div', {
1550
- className: 'space-y-1',
1551
- children: [
1552
- t.jsx('h2', {
1553
- className: 'text-lg font-medium',
1554
- children: e('device.noDevices'),
1555
- }),
1556
- t.jsx('p', {
1557
- className: 'text-sm text-muted-foreground',
1558
- children: e('device.addDevice'),
1559
- }),
1560
- ],
1561
- }),
1562
- t.jsxs(pe, {
1563
- variant: 'default',
1564
- 'data-testid': 'devices-add-empty',
1565
- onClick: () => r(!0),
1566
- children: [t.jsx(Rt, { className: 'h-4 w-4' }), e('device.addDevice')],
1567
- }),
1568
- ],
1569
- }),
1570
- })
1571
- : t.jsx('div', {
1572
- className: 'grid gap-3 lg:grid-cols-2',
1573
- children: I.map((x) =>
1574
- t.jsx(io, { device: x, onEdit: () => p(x), onDelete: () => m(x) }, x.id)
1575
- ),
1576
- }),
1577
- n && t.jsx(lt, { mode: 'create', onClose: () => r(!1) }),
1578
- s && t.jsx(lt, { mode: 'edit', device: s, onClose: () => p(null) }),
1579
- t.jsx(cs, {
1580
- open: i !== null,
1581
- onOpenChange: (x) => !x && m(null),
1582
- children: t.jsxs(ls, {
1583
- children: [
1584
- t.jsxs(ds, {
1585
- children: [
1586
- t.jsx(us, { children: t.jsx(Mt, { className: 'h-5 w-5 text-muted-foreground' }) }),
1587
- t.jsx(ps, { children: e('device.deleteConfirm') }),
1588
- t.jsx(ms, { children: (i == null ? void 0 : i.name) ?? '' }),
1589
- ],
1590
- }),
1591
- t.jsxs(fs, {
1592
- children: [
1593
- t.jsx(gs, { children: e('common.cancel') }),
1594
- t.jsx(hs, {
1595
- variant: 'destructive',
1596
- disabled: !i || v.isPending,
1597
- onClick: () => {
1598
- i && (v.mutate(i.id), m(null));
1599
- },
1600
- children: e('common.delete'),
1601
- }),
1602
- ],
1603
- }),
1604
- ],
1605
- }),
1606
- }),
1607
- ],
1608
- });
1609
- }
1610
- function io({ device: e, onEdit: n, onDelete: r }) {
1611
- const { t: s } = be(),
1612
- p =
1613
- e.type === 'local'
1614
- ? t.jsx(wt, { className: 'h-5 w-5' })
1615
- : t.jsx(Jn, { className: 'h-5 w-5' }),
1616
- i =
1617
- e.type === 'local'
1618
- ? s('device.typeLocal')
1619
- : `${e.username ?? '-'}@${e.host ?? '-'}:${e.port ?? 22}`,
1620
- m = Te({
1621
- mutationFn: async () => {
1622
- const c = await fetch(`/api/devices/${e.id}/test-connection`, { method: 'POST' });
1623
- let y = null;
1624
- try {
1625
- y = await c.json();
1626
- } catch {
1627
- y = null;
1628
- }
1629
- if (!c.ok) {
1630
- const b = y;
1631
- throw new Error((b == null ? void 0 : b.error) ?? s('common.error'));
1632
- }
1633
- return y;
1634
- },
1635
- onSuccess: (c) => {
1636
- ce.success(c.message ?? s('common.success'));
1637
- },
1638
- onError: (c) => {
1639
- ce.error(c instanceof Error ? c.message : s('common.error'));
1640
- },
1641
- });
1642
- return t.jsxs(Re, {
1643
- 'data-testid': 'device-card',
1644
- 'data-device-id': e.id,
1645
- 'data-device-name': e.name,
1646
- className: 'overflow-hidden',
1647
- children: [
1648
- t.jsxs(as, {
1649
- className: 'space-y-3 pb-3',
1650
- children: [
1651
- t.jsxs('div', {
1652
- className: 'flex items-start justify-between gap-3',
1653
- children: [
1654
- t.jsxs('div', {
1655
- className: 'flex min-w-0 items-center gap-3',
1656
- children: [
1657
- t.jsx('div', {
1658
- className:
1659
- 'flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-muted text-muted-foreground',
1660
- children: p,
1661
- }),
1662
- t.jsxs('div', {
1663
- className: 'min-w-0 space-y-1',
1664
- children: [
1665
- t.jsx(rs, {
1666
- className: 'line-clamp-1 text-base',
1667
- title: e.name,
1668
- children: e.name,
1669
- }),
1670
- t.jsx(is, { className: 'line-clamp-1', children: i }),
1671
- ],
1672
- }),
1673
- ],
1674
- }),
1675
- t.jsx('div', {
1676
- className: 'flex shrink-0 items-center gap-1',
1677
- children: t.jsxs(Zs, {
1678
- children: [
1679
- t.jsx(eo, {
1680
- render: t.jsx(pe, {
1681
- variant: 'ghost',
1682
- size: 'icon-sm',
1683
- 'data-testid': `device-card-actions-${e.id}`,
1684
- 'aria-label': s('common.edit'),
1685
- title: s('common.edit'),
1686
- }),
1687
- children: t.jsx(vs, { className: 'h-4 w-4' }),
1688
- }),
1689
- t.jsxs(to, {
1690
- align: 'end',
1691
- children: [
1692
- t.jsxs(Fe, {
1693
- 'data-testid': `device-card-edit-${e.id}`,
1694
- onClick: n,
1695
- children: [t.jsx(bs, { className: 'h-4 w-4' }), s('common.edit')],
1696
- }),
1697
- e.type === 'ssh' &&
1698
- t.jsxs(Fe, {
1699
- 'data-testid': `device-card-test-${e.id}`,
1700
- onClick: () => m.mutate(),
1701
- disabled: m.isPending,
1702
- children: [t.jsx(js, { className: 'h-4 w-4' }), s('common.test')],
1703
- }),
1704
- t.jsx(no, {}),
1705
- t.jsxs(Fe, {
1706
- 'data-testid': `device-card-delete-${e.id}`,
1707
- variant: 'destructive',
1708
- onClick: r,
1709
- children: [t.jsx(Mt, { className: 'h-4 w-4' }), s('common.delete')],
1710
- }),
1711
- ],
1712
- }),
1713
- ],
1714
- }),
1715
- }),
1716
- ],
1717
- }),
1718
- t.jsxs('div', {
1719
- className: 'flex flex-wrap items-center gap-2',
1720
- children: [
1721
- t.jsx(st, {
1722
- variant: 'outline',
1723
- children: e.type === 'local' ? s('device.typeLocal') : s('device.typeSSHBadge'),
1724
- }),
1725
- e.session && t.jsx(st, { variant: 'outline', children: e.session }),
1726
- ],
1727
- }),
1728
- ],
1729
- }),
1730
- t.jsxs(Ie, {
1731
- className: 'pt-0',
1732
- children: [
1733
- t.jsx(Ue, { className: 'mb-3' }),
1734
- t.jsx('div', {
1735
- className: 'flex items-center justify-end',
1736
- children: t.jsx(Wn, {
1737
- to: `/devices/${e.id}`,
1738
- 'data-testid': `device-card-connect-${e.id}`,
1739
- className: Xn({ variant: 'default', size: 'sm' }),
1740
- children: s('device.connect'),
1741
- }),
1742
- }),
1743
- ],
1744
- }),
1745
- ],
1746
- });
1747
- }
1748
- function lt({ mode: e, device: n, onClose: r }) {
1749
- const { t: s } = be(),
1750
- p = jt(),
1751
- [i, m] = o.useState(oo(n)),
1752
- [c, y] = o.useState(!1),
1753
- b = e === 'edit',
1754
- C = i.type === 'ssh',
1755
- v = Te({
1756
- mutationFn: async (l) => {
1757
- const d = await fetch('/api/devices', {
1758
- method: 'POST',
1759
- headers: { 'Content-Type': 'application/json' },
1760
- body: JSON.stringify(l),
1761
- });
1762
- if (!d.ok) throw new Error(await ct(d, s('device.createFailed')));
1763
- return d.json();
1764
- },
1765
- onSuccess: () => {
1766
- p.invalidateQueries({ queryKey: ['devices'] }), ce.success(s('common.success')), r();
1767
- },
1768
- onError: (l) => {
1769
- ce.error(l instanceof Error ? l.message : s('common.error'));
1770
- },
1771
- }),
1772
- I = Te({
1773
- mutationFn: async (l) => {
1774
- if (!n) throw new Error(s('apiError.deviceNotFound'));
1775
- const d = await fetch(`/api/devices/${n.id}`, {
1776
- method: 'PATCH',
1777
- headers: { 'Content-Type': 'application/json' },
1778
- body: JSON.stringify(l),
1779
- });
1780
- if (!d.ok) throw new Error(await ct(d, s('device.updateFailed')));
1781
- return d.json();
1782
- },
1783
- onSuccess: () => {
1784
- p.invalidateQueries({ queryKey: ['devices'] }), ce.success(s('common.success')), r();
1785
- },
1786
- onError: (l) => {
1787
- ce.error(l instanceof Error ? l.message : s('common.error'));
1788
- },
1789
- }),
1790
- x = async (l) => {
1791
- l.preventDefault(), y(!0);
1792
- try {
1793
- e === 'create' ? await v.mutateAsync(ao(i)) : await I.mutateAsync(ro(i));
1794
- } catch {
1795
- } finally {
1796
- y(!1);
1797
- }
1798
- },
1799
- S = `${e}-device-name`,
1800
- g = `${e}-device-type`,
1801
- M = `${e}-device-host`,
1802
- j = `${e}-device-port`,
1803
- u = `${e}-device-username`,
1804
- N = `${e}-device-session`,
1805
- $ = `${e}-device-auth-mode`,
1806
- f = `${e}-device-password`,
1807
- a = `${e}-device-private-key`,
1808
- w = `${e}-device-private-key-passphrase`;
1809
- return t.jsx(ws, {
1810
- open: !0,
1811
- onOpenChange: (l) => !l && r(),
1812
- children: t.jsxs(Ms, {
1813
- 'data-testid': 'device-dialog',
1814
- className: 'w-full max-w-2xl',
1815
- children: [
1816
- t.jsxs(Ps, {
1817
- children: [
1818
- t.jsx(Ss, { children: s(b ? 'device.editDevice' : 'device.addDevice') }),
1819
- t.jsx(Ns, { children: s(b ? 'device.editDevice' : 'device.addDevice') }),
1820
- ],
1821
- }),
1822
- t.jsxs('form', {
1823
- onSubmit: x,
1824
- children: [
1825
- t.jsxs('div', {
1826
- className: 'max-h-[min(70vh,720px)] space-y-4 overflow-y-auto pr-1',
1827
- children: [
1828
- t.jsxs('div', {
1829
- className: 'grid gap-3 sm:grid-cols-2',
1830
- children: [
1831
- t.jsxs('div', {
1832
- className: 'space-y-1.5 sm:col-span-2',
1833
- children: [
1834
- t.jsx('label', {
1835
- className: 'block text-sm font-medium',
1836
- htmlFor: S,
1837
- children: s('device.name'),
1838
- }),
1839
- t.jsx(ie, {
1840
- id: S,
1841
- 'data-testid': 'device-name-input',
1842
- type: 'text',
1843
- value: i.name,
1844
- onChange: (l) => m((d) => ({ ...d, name: l.target.value })),
1845
- placeholder: s('device.namePlaceholder'),
1846
- required: !0,
1847
- }),
1848
- ],
1849
- }),
1850
- t.jsxs('div', {
1851
- className: 'space-y-1.5',
1852
- children: [
1853
- t.jsx('label', {
1854
- className: 'block text-sm font-medium',
1855
- htmlFor: g,
1856
- children: s('device.type'),
1857
- }),
1858
- t.jsxs(ot, {
1859
- value: i.type,
1860
- onValueChange: (l) => {
1861
- if (!l) return;
1862
- const d = l;
1863
- m((k) => ({
1864
- ...k,
1865
- type: d,
1866
- authMode:
1867
- d === 'local'
1868
- ? 'auto'
1869
- : k.authMode === 'auto'
1870
- ? 'password'
1871
- : k.authMode,
1872
- }));
1873
- },
1874
- disabled: b,
1875
- children: [
1876
- t.jsx(at, {
1877
- id: g,
1878
- 'data-testid': 'device-type-select',
1879
- className: 'w-full',
1880
- children: t.jsx(rt, { placeholder: s('device.type') }),
1881
- }),
1882
- t.jsxs(it, {
1883
- children: [
1884
- t.jsx(he, { value: 'local', children: s('device.typeLocal') }),
1885
- t.jsxs(he, { value: 'ssh', children: ['SSH ', s('device.type')] }),
1886
- ],
1887
- }),
1888
- ],
1889
- }),
1890
- ],
1891
- }),
1892
- t.jsxs('div', {
1893
- className: 'space-y-1.5',
1894
- children: [
1895
- t.jsx('label', {
1896
- className: 'block text-sm font-medium',
1897
- htmlFor: N,
1898
- children: s('device.session'),
1899
- }),
1900
- t.jsx(ie, {
1901
- id: N,
1902
- 'data-testid': 'device-session-input',
1903
- type: 'text',
1904
- value: i.session,
1905
- onChange: (l) => m((d) => ({ ...d, session: l.target.value })),
1906
- placeholder: s('device.sessionPlaceholder'),
1907
- }),
1908
- ],
1909
- }),
1910
- ],
1911
- }),
1912
- C &&
1913
- t.jsxs(t.Fragment, {
1914
- children: [
1915
- t.jsx(Ue, {}),
1916
- t.jsxs('div', {
1917
- className: 'grid gap-3 sm:grid-cols-3',
1918
- children: [
1919
- t.jsxs('div', {
1920
- className: 'space-y-1.5 sm:col-span-2',
1921
- children: [
1922
- t.jsx('label', {
1923
- className: 'block text-sm font-medium',
1924
- htmlFor: M,
1925
- children: s('device.host'),
1926
- }),
1927
- t.jsx(ie, {
1928
- id: M,
1929
- type: 'text',
1930
- value: i.host,
1931
- onChange: (l) => m((d) => ({ ...d, host: l.target.value })),
1932
- placeholder: s('device.hostPlaceholder'),
1933
- }),
1934
- ],
1935
- }),
1936
- t.jsxs('div', {
1937
- className: 'space-y-1.5',
1938
- children: [
1939
- t.jsx('label', {
1940
- className: 'block text-sm font-medium',
1941
- htmlFor: j,
1942
- children: s('device.port'),
1943
- }),
1944
- t.jsx(ie, {
1945
- id: j,
1946
- type: 'number',
1947
- value: i.port,
1948
- onChange: (l) =>
1949
- m((d) => ({
1950
- ...d,
1951
- port: Number.parseInt(l.target.value || '22', 10),
1952
- })),
1953
- min: 1,
1954
- max: 65535,
1955
- }),
1956
- ],
1957
- }),
1958
- t.jsxs('div', {
1959
- className: 'space-y-1.5 sm:col-span-2',
1960
- children: [
1961
- t.jsx('label', {
1962
- className: 'block text-sm font-medium',
1963
- htmlFor: u,
1964
- children: s('device.username'),
1965
- }),
1966
- t.jsx(ie, {
1967
- id: u,
1968
- type: 'text',
1969
- value: i.username,
1970
- onChange: (l) => m((d) => ({ ...d, username: l.target.value })),
1971
- placeholder: s('device.usernamePlaceholder'),
1972
- }),
1973
- ],
1974
- }),
1975
- t.jsxs('div', {
1976
- className: 'space-y-1.5',
1977
- children: [
1978
- t.jsx('label', {
1979
- className: 'block text-sm font-medium',
1980
- htmlFor: `${e}-device-ssh-config-ref`,
1981
- children: 'SSH Config',
1982
- }),
1983
- t.jsx(ie, {
1984
- id: `${e}-device-ssh-config-ref`,
1985
- type: 'text',
1986
- value: i.sshConfigRef,
1987
- onChange: (l) => m((d) => ({ ...d, sshConfigRef: l.target.value })),
1988
- placeholder: '~/.ssh/config',
1989
- }),
1990
- ],
1991
- }),
1992
- ],
1993
- }),
1994
- t.jsx(Ue, {}),
1995
- t.jsxs('div', {
1996
- className: 'space-y-3',
1997
- children: [
1998
- t.jsxs('div', {
1999
- className: 'space-y-1.5',
2000
- children: [
2001
- t.jsx('label', {
2002
- className: 'block text-sm font-medium',
2003
- htmlFor: $,
2004
- children: s('device.authMode'),
2005
- }),
2006
- t.jsxs(ot, {
2007
- value: i.authMode,
2008
- onValueChange: (l) => {
2009
- l && m((d) => ({ ...d, authMode: l }));
2010
- },
2011
- children: [
2012
- t.jsx(at, {
2013
- id: $,
2014
- className: 'w-full',
2015
- children: t.jsx(rt, { placeholder: s('device.authMode') }),
2016
- }),
2017
- t.jsxs(it, {
2018
- children: [
2019
- t.jsx(he, {
2020
- value: 'password',
2021
- children: s('device.authPassword'),
2022
- }),
2023
- t.jsx(he, { value: 'key', children: s('device.authKey') }),
2024
- t.jsx(he, {
2025
- value: 'agent',
2026
- children: s('device.authAgent'),
2027
- }),
2028
- t.jsx(he, { value: 'configRef', children: 'SSH Config' }),
2029
- ],
2030
- }),
2031
- ],
2032
- }),
2033
- ],
2034
- }),
2035
- i.authMode === 'password' &&
2036
- t.jsxs('div', {
2037
- className: 'space-y-1.5',
2038
- children: [
2039
- t.jsx('label', {
2040
- className: 'block text-sm font-medium',
2041
- htmlFor: f,
2042
- children: s('device.password'),
2043
- }),
2044
- t.jsx(ie, {
2045
- id: f,
2046
- type: 'password',
2047
- value: i.password,
2048
- onChange: (l) => m((d) => ({ ...d, password: l.target.value })),
2049
- }),
2050
- ],
2051
- }),
2052
- i.authMode === 'key' &&
2053
- t.jsxs(t.Fragment, {
2054
- children: [
2055
- t.jsxs('div', {
2056
- className: 'space-y-1.5',
2057
- children: [
2058
- t.jsx('label', {
2059
- className: 'block text-sm font-medium',
2060
- htmlFor: a,
2061
- children: s('device.privateKey'),
2062
- }),
2063
- t.jsx(so, {
2064
- id: a,
2065
- value: i.privateKey,
2066
- onChange: (l) =>
2067
- m((d) => ({ ...d, privateKey: l.target.value })),
2068
- className: 'h-28 font-mono text-xs',
2069
- placeholder: s('device.privateKeyPlaceholder'),
2070
- }),
2071
- ],
2072
- }),
2073
- t.jsxs('div', {
2074
- className: 'space-y-1.5',
2075
- children: [
2076
- t.jsx('label', {
2077
- className: 'block text-sm font-medium',
2078
- htmlFor: w,
2079
- children: s('device.passphrase'),
2080
- }),
2081
- t.jsx(ie, {
2082
- id: w,
2083
- type: 'password',
2084
- value: i.privateKeyPassphrase,
2085
- onChange: (l) =>
2086
- m((d) => ({ ...d, privateKeyPassphrase: l.target.value })),
2087
- }),
2088
- ],
2089
- }),
2090
- ],
2091
- }),
2092
- ],
2093
- }),
2094
- ],
2095
- }),
2096
- ],
2097
- }),
2098
- t.jsxs(Ts, {
2099
- children: [
2100
- t.jsx(pe, {
2101
- type: 'button',
2102
- variant: 'outline',
2103
- className: 'flex-1',
2104
- onClick: r,
2105
- children: s('common.cancel'),
2106
- }),
2107
- t.jsx(pe, {
2108
- type: 'submit',
2109
- variant: 'default',
2110
- className: 'flex-1',
2111
- 'data-testid': 'device-dialog-save',
2112
- disabled: c,
2113
- children: s(c ? 'common.saving' : 'common.save'),
2114
- }),
2115
- ],
2116
- }),
2117
- ],
2118
- }),
2119
- ],
2120
- }),
2121
- });
2122
- }
2123
- function fo() {
2124
- const { t: e } = be();
2125
- return t.jsx(t.Fragment, { children: e('sidebar.manageDevices') });
2126
- }
2127
- function go() {
2128
- const { t: e } = be(),
2129
- n = () => {
2130
- window.dispatchEvent(new CustomEvent('tmex:open-add-device'));
2131
- };
2132
- return t.jsx(pe, {
2133
- variant: 'ghost',
2134
- size: 'icon-sm',
2135
- 'data-testid': 'devices-add',
2136
- onClick: n,
2137
- 'aria-label': e('sidebar.addDevice'),
2138
- title: e('sidebar.addDevice'),
2139
- children: t.jsx(Rt, { className: 'h-4 w-4' }),
2140
- });
2141
- }
2142
- export { go as PageActions, fo as PageTitle, mo as default };
2143
- //# sourceMappingURL=DevicesPage-CtNzaW_c.js.map