@wandelbots/wandelbots-js-react-components 6.3.0 → 6.4.0-pr.feat-jogging-gizmo.649.8c3cbf8

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 (99) hide show
  1. package/README.md +202 -120
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +3 -3
  4. package/dist/3d.js +19 -22
  5. package/dist/SafetyBar/index.cjs +1 -1
  6. package/dist/SafetyBar/index.js +1 -1
  7. package/dist/chunks/ConnectedMotionGroup-_YUOhOLL.cjs +4 -0
  8. package/dist/chunks/ConnectedMotionGroup-neDeA3uW.js +2617 -0
  9. package/dist/chunks/Robot-CvviE5MR.js +1684 -0
  10. package/dist/chunks/Robot-VZaqKPxi.cjs +1 -0
  11. package/dist/chunks/{SafetyBar-Cy9DiXp9.js → SafetyBar-B9OQgerp.js} +1 -1
  12. package/dist/chunks/{SafetyBar-DPrv_OQA.cjs → SafetyBar-D7QT6J0m.cjs} +1 -1
  13. package/dist/chunks/{externalizeComponent-EDymnaGR.js → externalizeComponent-CZu38L-d.js} +29 -105
  14. package/dist/chunks/externalizeComponent-CdX5L_lW.cjs +2 -0
  15. package/dist/chunks/useSmoothedMotionState-BidFV3kQ.js +255 -0
  16. package/dist/chunks/useSmoothedMotionState-CdhkBCqt.cjs +1 -0
  17. package/dist/components/AppHeader.d.ts +1 -1
  18. package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +1 -1
  19. package/dist/components/jogging/JoggingJointTab.d.ts +1 -1
  20. package/dist/components/jogging/JoggingPanel.d.ts +6 -3
  21. package/dist/components/jogging/JoggingStore.d.ts +5 -1
  22. package/dist/components/jogging/gizmo/JoggingGizmo.d.ts +42 -0
  23. package/dist/components/jogging/gizmo/JoggingGizmoOrientation.d.ts +31 -0
  24. package/dist/components/jogging/gizmo/gizmoShared.d.ts +60 -0
  25. package/dist/components/jogging/gizmo/gizmoTranslation.d.ts +11 -0
  26. package/dist/components/jogging/gizmo/jogGizmoProjection.d.ts +65 -0
  27. package/dist/components/jogging/jogHandle.d.ts +26 -0
  28. package/dist/components/jogging/joggingColors.d.ts +18 -0
  29. package/dist/components/jogging/useHold.d.ts +33 -0
  30. package/dist/components/jogging/useHoldToJog.d.ts +23 -0
  31. package/dist/components/robots/GenericRobot.d.ts +2 -1
  32. package/dist/components/robots/LinearAxis.d.ts +1 -1
  33. package/dist/components/robots/LinearAxisAnimator.d.ts +11 -2
  34. package/dist/components/robots/Robot.d.ts +1 -1
  35. package/dist/components/robots/robotModelLogic.d.ts +11 -9
  36. package/dist/components/utils/hooks.d.ts +1 -6
  37. package/dist/core.cjs +1 -1
  38. package/dist/core.d.ts +3 -18
  39. package/dist/core.js +27 -54
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.js +42 -72
  42. package/dist/lib/ConnectedMotionGroup.d.ts +5 -7
  43. package/dist/lib/JoggerConnection.d.ts +29 -5
  44. package/dist/lib/MotionStreamConnection.d.ts +4 -6
  45. package/dist/lib/novaConnection.d.ts +23 -0
  46. package/package.json +31 -66
  47. package/dist/Setup.d.ts +0 -11
  48. package/dist/chunks/MotionGroupVisualizer-DshWR1wY.js +0 -1653
  49. package/dist/chunks/MotionGroupVisualizer-eD7yFEcF.cjs +0 -1
  50. package/dist/chunks/externalizeComponent-OO4jcrz5.cjs +0 -2
  51. package/dist/chunks/theming-DfSy4-Ic.cjs +0 -4
  52. package/dist/chunks/theming-mF9Rt8SS.js +0 -5542
  53. package/dist/chunks/useSmoothedMotionState-DyDgSVYX.js +0 -478
  54. package/dist/chunks/useSmoothedMotionState-VYxEIyfr.cjs +0 -1
  55. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +0 -11
  56. package/dist/components/AdornedTextField.d.ts +0 -7
  57. package/dist/components/CopyableText.d.ts +0 -6
  58. package/dist/components/CycleTimer/CycleTimer.d.ts +0 -3
  59. package/dist/components/CycleTimer/DefaultVariant.d.ts +0 -9
  60. package/dist/components/CycleTimer/SmallVariant.d.ts +0 -10
  61. package/dist/components/CycleTimer/index.d.ts +0 -27
  62. package/dist/components/CycleTimer/types.d.ts +0 -49
  63. package/dist/components/CycleTimer/useAnimations.d.ts +0 -14
  64. package/dist/components/CycleTimer/useTimerLogic.d.ts +0 -24
  65. package/dist/components/CycleTimer/utils.d.ts +0 -21
  66. package/dist/components/CycleTimer.d.ts +0 -3
  67. package/dist/components/DataGrid.d.ts +0 -66
  68. package/dist/components/LogPanel.d.ts +0 -38
  69. package/dist/components/LogStore.d.ts +0 -12
  70. package/dist/components/LogViewer.d.ts +0 -46
  71. package/dist/components/ProgramControl.d.ts +0 -55
  72. package/dist/components/ProgramStateIndicator.d.ts +0 -26
  73. package/dist/components/RobotCard.d.ts +0 -98
  74. package/dist/components/RobotListItem.d.ts +0 -34
  75. package/dist/components/RobotSetupReadinessIndicator.d.ts +0 -37
  76. package/dist/components/SelectableFab.d.ts +0 -7
  77. package/dist/components/TabBar.d.ts +0 -45
  78. package/dist/components/ThemeSelect.d.ts +0 -6
  79. package/dist/components/Timer/Timer.d.ts +0 -3
  80. package/dist/components/Timer/TimerDefaultVariant.d.ts +0 -9
  81. package/dist/components/Timer/TimerSmallVariant.d.ts +0 -10
  82. package/dist/components/Timer/index.d.ts +0 -19
  83. package/dist/components/Timer/types.d.ts +0 -35
  84. package/dist/components/Timer/useTimerAnimations.d.ts +0 -10
  85. package/dist/components/Timer/useTimerLogic.d.ts +0 -19
  86. package/dist/components/Timer/utils.d.ts +0 -17
  87. package/dist/components/Timer.d.ts +0 -3
  88. package/dist/components/TransparentOverlay.d.ts +0 -4
  89. package/dist/components/jogging/JoggingFreedriveTab.d.ts +0 -1
  90. package/dist/components/jogging/PoseCartesianValues.d.ts +0 -9
  91. package/dist/components/jogging/PoseJointValues.d.ts +0 -8
  92. package/dist/components/robots/AxisConfig.d.ts +0 -2
  93. package/dist/components/robots/manufacturerHomePositions.d.ts +0 -20
  94. package/dist/icons/DropdownArrowIcon.d.ts +0 -2
  95. package/dist/icons/index.d.ts +0 -12
  96. package/dist/lib/novaCompat.d.ts +0 -16
  97. package/dist/themes/createDarkTheme.d.ts +0 -7
  98. package/dist/themes/themeTypes.d.ts +0 -40
  99. package/dist/themes/theming.d.ts +0 -24
@@ -0,0 +1,2617 @@
1
+ import { jsxs as b, Fragment as tt, jsx as r } from "react/jsx-runtime";
2
+ import At from "@mui/material/AppBar";
3
+ import It from "@mui/material/Backdrop";
4
+ import V from "@mui/material/Box";
5
+ import Vt from "@mui/material/Menu";
6
+ import B from "@mui/material/MenuItem";
7
+ import Lt from "@mui/material/Toolbar";
8
+ import j from "@mui/material/Typography";
9
+ import { ZeroGravityComponentsBackdropFill as $t } from "@wandelbots/design-tokens";
10
+ import { ExpandMoreFilled as Bt } from "@wandelbots/icons/ExpandMoreFilled";
11
+ import { RoundedIconButton as Ft } from "@wandelbots/mui";
12
+ import { observer as k, useLocalObservable as Mt } from "mobx-react-lite";
13
+ import * as C from "react";
14
+ import { useState as q, forwardRef as N, useEffect as et, useRef as it, useId as Nt } from "react";
15
+ import { e as Y } from "./externalizeComponent-CZu38L-d.js";
16
+ import zt from "@mui/icons-material/OpenWith";
17
+ import Gt from "@mui/icons-material/Share";
18
+ import w from "@mui/material/Stack";
19
+ import Ut from "@mui/material/Tab";
20
+ import Wt from "@mui/material/Tabs";
21
+ import { runInAction as x, makeAutoObservable as dt, when as Q, autorun as pt } from "mobx";
22
+ import { useTranslation as D } from "react-i18next";
23
+ import { radiansToDegrees as jt, tryParseJson as P, XYZ_TO_VECTOR as W, degreesToRadians as Ht } from "@wandelbots/nova-js";
24
+ import { JointTypeEnum as A } from "@wandelbots/nova-js/v2";
25
+ import { Vector3 as nt } from "three/src/math/Vector3.js";
26
+ import { b as gt, j as ft, c as H, d as at, v as qt, e as rt } from "./useSmoothedMotionState-BidFV3kQ.js";
27
+ import _t from "@mui/material/CircularProgress";
28
+ import { capitalize as Yt } from "@mui/material/utils";
29
+ import { lowerFirst as Zt, countBy as Kt } from "lodash-es";
30
+ import { m as Xt } from "./SafetyBar-B9OQgerp.js";
31
+ import Qt from "@mui/material/Alert";
32
+ import te from "@mui/material/AlertTitle";
33
+ import st from "@mui/material/Button";
34
+ import { useTheme as z, styled as kt } from "@mui/material/styles";
35
+ import F from "@mui/material/Divider";
36
+ import yt from "@mui/material/ToggleButton";
37
+ import ot from "@mui/material/IconButton";
38
+ import ee from "lodash-es/isEqual.js";
39
+ import oe from "@mui/material/InputAdornment";
40
+ import ie from "@mui/material/FormControl";
41
+ import ne from "@mui/material/InputLabel";
42
+ import re from "@mui/material/Select";
43
+ import K from "lodash-es/keyBy.js";
44
+ import ae from "lodash-es/uniqueId.js";
45
+ import se from "@mui/material/ToggleButtonGroup";
46
+ import Et from "@mui/material/Slider";
47
+ import le from "lodash-es/isNumber.js";
48
+ import ce from "@mui/icons-material/ChevronLeft";
49
+ import de from "@mui/icons-material/ChevronRight";
50
+ import ge from "lodash-es/throttle.js";
51
+ import he from "@mui/material/Dialog";
52
+ import me from "@mui/material/DialogActions";
53
+ import ue from "@mui/material/DialogContent";
54
+ import pe from "@mui/material/DialogTitle";
55
+ import * as St from "three";
56
+ import { Vector3 as bt } from "three";
57
+ const Wo = Y(
58
+ k((e) => {
59
+ const {
60
+ appIcon: t,
61
+ appName: o,
62
+ apps: i = [],
63
+ onAppSelect: n,
64
+ disabled: a = !1,
65
+ sx: l
66
+ } = e, [s, h] = q(null), d = !!s, p = (c) => {
67
+ h(c.currentTarget);
68
+ }, m = () => {
69
+ h(null);
70
+ }, g = (c) => {
71
+ m(), c.onClick ? c.onClick() : c.href && (window.location.href = c.href), n == null || n(c);
72
+ };
73
+ return /* @__PURE__ */ b(tt, { children: [
74
+ /* @__PURE__ */ r(
75
+ At,
76
+ {
77
+ position: "static",
78
+ sx: {
79
+ boxShadow: "none",
80
+ backgroundImage: "none",
81
+ "& .MuiAppBar-root": {
82
+ backgroundImage: "none",
83
+ backgroundColor: "transparent"
84
+ },
85
+ ...l
86
+ },
87
+ children: /* @__PURE__ */ b(Lt, { sx: { minHeight: "62px !important" }, children: [
88
+ /* @__PURE__ */ r(V, { sx: { mr: 1, display: "flex", alignItems: "center" }, children: t }),
89
+ /* @__PURE__ */ b(V, { sx: { display: "flex", alignItems: "center", flexGrow: 1 }, children: [
90
+ /* @__PURE__ */ r(j, { component: "h1", variant: "subtitle1", children: o }),
91
+ i.length > 0 && /* @__PURE__ */ r(
92
+ Ft,
93
+ {
94
+ icon: /* @__PURE__ */ r(Bt, { size: 20 }),
95
+ ariaLabel: "switch app",
96
+ "aria-controls": "app-menu",
97
+ "aria-haspopup": "true",
98
+ onClick: p,
99
+ disabled: a,
100
+ sx: { ml: 1 }
101
+ }
102
+ )
103
+ ] })
104
+ ] })
105
+ }
106
+ ),
107
+ /* @__PURE__ */ r(
108
+ It,
109
+ {
110
+ open: d,
111
+ onClick: m,
112
+ sx: {
113
+ backdropFilter: "blur(4px)",
114
+ backgroundColor: $t,
115
+ zIndex: (c) => c.zIndex.modal - 1
116
+ }
117
+ }
118
+ ),
119
+ /* @__PURE__ */ r(
120
+ Vt,
121
+ {
122
+ id: "app-menu",
123
+ anchorEl: s,
124
+ open: d,
125
+ onClose: m,
126
+ anchorOrigin: {
127
+ vertical: "bottom",
128
+ horizontal: "left"
129
+ },
130
+ transformOrigin: {
131
+ vertical: "top",
132
+ horizontal: "left"
133
+ },
134
+ sx: {
135
+ zIndex: (c) => c.zIndex.modal,
136
+ "& .MuiPaper-root": {
137
+ minWidth: 200,
138
+ mt: 1
139
+ }
140
+ },
141
+ children: i.map((c) => /* @__PURE__ */ b(B, { onClick: () => g(c), children: [
142
+ /* @__PURE__ */ r(V, { sx: { display: "flex", alignItems: "center" }, children: c.icon }),
143
+ /* @__PURE__ */ r(j, { variant: "body1", sx: { ml: 2 }, children: c.name })
144
+ ] }, c.id))
145
+ }
146
+ )
147
+ ] });
148
+ })
149
+ ), fe = ({
150
+ title: e,
151
+ titleId: t,
152
+ ...o
153
+ }, i) => /* @__PURE__ */ C.createElement("svg", { width: 21, height: 21, viewBox: "0 0 21 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("g", { id: "JogMinus" }, /* @__PURE__ */ C.createElement("path", { id: "Minus", d: "M0 13V8H21V13H0Z", fill: "white" }))), ye = N(fe), Se = ({
154
+ title: e,
155
+ titleId: t,
156
+ ...o
157
+ }, i) => /* @__PURE__ */ C.createElement("svg", { width: 21, height: 21, viewBox: "0 0 21 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("g", { id: "JogPlus" }, /* @__PURE__ */ C.createElement("g", { id: "Plus" }, /* @__PURE__ */ C.createElement("path", { d: "M0 13V8H8V13H0Z", fill: "white" }), /* @__PURE__ */ C.createElement("path", { d: "M8 0L13 2.18557e-07L13 21H8L8 0Z", fill: "white" }), /* @__PURE__ */ C.createElement("path", { d: "M13 13V8H21V13H13Z", fill: "white" })))), be = N(Se), vt = Y(
158
+ k(
159
+ ({
160
+ colors: e,
161
+ label: t,
162
+ getDisplayedValue: o,
163
+ startJogging: i,
164
+ stopJogging: n,
165
+ disabled: a,
166
+ activeJoggingDirection: l,
167
+ ...s
168
+ }) => {
169
+ var M, _, J, E, R, L, $;
170
+ gt(() => {
171
+ const T = o(), O = g.current;
172
+ O && (O.textContent = T);
173
+ });
174
+ const h = z(), [d, p] = q(null);
175
+ et(() => {
176
+ a && I();
177
+ }, [a]);
178
+ const m = l || d, g = it(null);
179
+ e || (e = {
180
+ color: "#fff",
181
+ backgroundColor: "#000",
182
+ borderColor: "#000",
183
+ buttonBackgroundColor: {
184
+ disabled: "#000",
185
+ default: "#000",
186
+ hovered: "#000",
187
+ pressed: "#000"
188
+ },
189
+ labelColor: "#000"
190
+ });
191
+ const c = m ? (M = e.buttonBackgroundColor) == null ? void 0 : M.pressed : e.borderColor, f = {
192
+ width: "55px",
193
+ color: e.color,
194
+ path: { fill: e.color },
195
+ alignContent: "center",
196
+ fontSize: "37px",
197
+ svg: {
198
+ pointerEvents: "none"
199
+ }
200
+ }, y = {
201
+ ...f,
202
+ backgroundColor: (_ = e.buttonBackgroundColor) == null ? void 0 : _.default,
203
+ ":hover": {
204
+ backgroundColor: (J = e.buttonBackgroundColor) == null ? void 0 : J.hovered
205
+ },
206
+ ":active": {
207
+ backgroundColor: (E = e.buttonBackgroundColor) == null ? void 0 : E.pressed,
208
+ color: e.backgroundColor,
209
+ path: { fill: e.backgroundColor }
210
+ },
211
+ ":disabled": {
212
+ backgroundColor: (R = e.buttonBackgroundColor) == null ? void 0 : R.disabled,
213
+ "svg path": { fill: h.palette.action.disabled }
214
+ }
215
+ }, u = {
216
+ ...f,
217
+ backgroundColor: (L = e.buttonBackgroundColor) == null ? void 0 : L.pressed,
218
+ color: e.backgroundColor,
219
+ path: { fill: e.backgroundColor },
220
+ ":disabled": {
221
+ backgroundColor: ($ = e.buttonBackgroundColor) == null ? void 0 : $.pressed,
222
+ "svg path": { fill: h.palette.action.disabled }
223
+ }
224
+ };
225
+ function S(T, O) {
226
+ a || T.button === 0 && (p(O), i(O));
227
+ }
228
+ function I() {
229
+ p(null), n();
230
+ }
231
+ return /* @__PURE__ */ b(w, { height: "64px", direction: "row", justifyContent: "center", ...s, children: [
232
+ /* @__PURE__ */ r(
233
+ ot,
234
+ {
235
+ disabled: a,
236
+ disableRipple: !0,
237
+ onPointerDown: (T) => S(T, "-"),
238
+ onPointerUp: I,
239
+ onPointerOut: I,
240
+ size: "large",
241
+ sx: {
242
+ ...m === "-" ? u : y,
243
+ borderRadius: "16px 0px 0px 16px",
244
+ borderLeft: `2px solid ${c ?? "#fff"}`,
245
+ borderBottom: `2px solid ${c ?? "#fff"}`,
246
+ borderTop: `2px solid ${c ?? "#fff"}`
247
+ },
248
+ children: /* @__PURE__ */ r(ye, {})
249
+ }
250
+ ),
251
+ /* @__PURE__ */ b(
252
+ w,
253
+ {
254
+ spacing: "6px",
255
+ sx: {
256
+ width: "150px",
257
+ backgroundColor: e.backgroundColor,
258
+ alignItems: "center",
259
+ justifyContent: "center",
260
+ opacity: "0.9",
261
+ borderBottom: `2px solid ${c ?? "#fff"}`,
262
+ borderTop: `2px solid ${c ?? "#fff"}`
263
+ },
264
+ children: [
265
+ /* @__PURE__ */ r(
266
+ w,
267
+ {
268
+ height: "22px",
269
+ direction: "row",
270
+ alignItems: "center",
271
+ justifyItems: "center",
272
+ spacing: 1,
273
+ sx: {
274
+ userSelect: "none",
275
+ color: e.color,
276
+ ".MuiTypography-root": {
277
+ fontWeight: 700,
278
+ ...a ? { color: h.palette.action.disabled } : {}
279
+ },
280
+ ...a ? { "svg path": { fill: h.palette.action.disabled } } : {}
281
+ },
282
+ children: t
283
+ }
284
+ ),
285
+ /* @__PURE__ */ r(
286
+ j,
287
+ {
288
+ height: "22px",
289
+ sx: {
290
+ fontSize: "15px",
291
+ color: a ? h.palette.action.disabled : e.color,
292
+ fontWeight: 700,
293
+ fontVariantNumeric: "tabular-nums",
294
+ minWidth: "80px",
295
+ textAlign: "center"
296
+ },
297
+ ref: g,
298
+ children: o()
299
+ }
300
+ )
301
+ ]
302
+ }
303
+ ),
304
+ /* @__PURE__ */ r(
305
+ ot,
306
+ {
307
+ disableRipple: !0,
308
+ disabled: a,
309
+ onPointerDown: (T) => S(T, "+"),
310
+ onPointerUp: I,
311
+ onPointerOut: I,
312
+ size: "large",
313
+ sx: {
314
+ ...m === "+" ? u : y,
315
+ borderRadius: "0px 16px 16px 0px",
316
+ borderRight: `2px solid ${c ?? "#fff"}`,
317
+ borderBottom: `2px solid ${c ?? "#fff"}`,
318
+ borderTop: `2px solid ${c ?? "#fff"}`
319
+ },
320
+ children: /* @__PURE__ */ r(be, {})
321
+ }
322
+ )
323
+ ] });
324
+ }
325
+ )
326
+ ), ve = Y(
327
+ k(
328
+ ({
329
+ startJogging: e,
330
+ stopJogging: t,
331
+ lowerLimit: o,
332
+ upperLimit: i,
333
+ useDegree: n,
334
+ getValue: a,
335
+ disabled: l,
336
+ ...s
337
+ }) => {
338
+ var E, R, L, $, T, O, Z;
339
+ const { t: h } = D(), [d, p] = q(), m = z(), g = {
340
+ background: (E = m.palette.backgroundPaperElevation) == null ? void 0 : E[4],
341
+ color: (R = m.palette.backgroundPaperElevation) == null ? void 0 : R[11]
342
+ }, c = Mt(() => ({
343
+ activeJoggingDir: null,
344
+ startJogging(v) {
345
+ this.activeJoggingDir = v, e(v);
346
+ },
347
+ stopJogging() {
348
+ this.activeJoggingDir = null, t();
349
+ }
350
+ })), f = ge(() => {
351
+ const v = n ? y(a()) : a();
352
+ (v === void 0 || d === void 0 || Math.abs(d - v) > 1e-9) && p(v);
353
+ }, 50);
354
+ gt(f);
355
+ function y(v) {
356
+ if (v !== void 0)
357
+ return jt(v);
358
+ }
359
+ function u(v) {
360
+ v.button === 0 && c.startJogging("-");
361
+ }
362
+ function S(v) {
363
+ v.button === 0 && c.startJogging("+");
364
+ }
365
+ function I(v) {
366
+ c.stopJogging();
367
+ }
368
+ function M(v) {
369
+ c.stopJogging();
370
+ }
371
+ function _(v, G = 1) {
372
+ if (v === void 0 || Number.isNaN(v)) return "";
373
+ const U = h("General.degree.variable", {
374
+ amount: v.toFixed(G)
375
+ });
376
+ return v > 0 && G === 0 ? `+${U}` : U;
377
+ }
378
+ function J(v, G = 1) {
379
+ if (v === void 0 || Number.isNaN(v)) return "";
380
+ const U = h("General.mm.variable", {
381
+ amount: v.toFixed(G)
382
+ });
383
+ return v > 0 && G === 0 ? `+${U}` : U;
384
+ }
385
+ return /* @__PURE__ */ b(
386
+ w,
387
+ {
388
+ height: "64px",
389
+ width: "100%",
390
+ maxWidth: "260px",
391
+ direction: "row",
392
+ ...s,
393
+ sx: {
394
+ "& .MuiIconButton-root": {
395
+ width: "52px",
396
+ color: m.palette.text.primary,
397
+ alignContent: "center",
398
+ backgroundColor: (L = m.palette.backgroundPaperElevation) == null ? void 0 : L[11],
399
+ "& svg": {
400
+ width: "42px",
401
+ height: "42px"
402
+ },
403
+ "&.Mui-disabled": {
404
+ backgroundColor: ($ = m.palette.backgroundPaperElevation) == null ? void 0 : $[11],
405
+ color: m.palette.action.disabled,
406
+ opacity: 1
407
+ },
408
+ "&:hover": {
409
+ backgroundColor: (T = m.palette.backgroundPaperElevation) == null ? void 0 : T[9]
410
+ },
411
+ "&:active": {
412
+ ...g
413
+ }
414
+ }
415
+ },
416
+ children: [
417
+ /* @__PURE__ */ r(
418
+ ot,
419
+ {
420
+ onPointerDown: u,
421
+ onPointerUp: I,
422
+ onPointerOut: M,
423
+ disabled: l,
424
+ disableRipple: !0,
425
+ sx: {
426
+ borderRadius: "16px 0px 0px 16px",
427
+ ...c.activeJoggingDir === "-" ? g : {}
428
+ },
429
+ children: /* @__PURE__ */ r(
430
+ ce,
431
+ {
432
+ sx: {
433
+ pointerEvents: "none",
434
+ color: ft
435
+ }
436
+ }
437
+ )
438
+ }
439
+ ),
440
+ /* @__PURE__ */ b(
441
+ w,
442
+ {
443
+ flexGrow: 1,
444
+ alignItems: "center",
445
+ justifyContent: "center",
446
+ sx: {
447
+ borderStyle: "solid",
448
+ borderLeftWidth: 0,
449
+ borderRightWidth: 0,
450
+ border: "none",
451
+ backgroundColor: (O = m.palette.backgroundPaperElevation) == null ? void 0 : O[11],
452
+ paddingLeft: "20px",
453
+ paddingRight: "20px",
454
+ zIndex: 1
455
+ },
456
+ children: [
457
+ /* @__PURE__ */ r(
458
+ j,
459
+ {
460
+ sx: {
461
+ fontSize: "15px",
462
+ fontWeight: 700,
463
+ position: "relative",
464
+ top: "5px",
465
+ fontVariantNumeric: "tabular-nums",
466
+ minWidth: "80px",
467
+ textAlign: "center",
468
+ color: l ? m.palette.action.disabled : m.palette.text.primary
469
+ },
470
+ children: n ? _(d) : J(d)
471
+ }
472
+ ),
473
+ /* @__PURE__ */ r(
474
+ Et,
475
+ {
476
+ disabled: !0,
477
+ "aria-label": "Joint position",
478
+ min: n ? y(o) : o,
479
+ max: n ? y(i) : i,
480
+ value: d || 0,
481
+ track: !1,
482
+ sx: {
483
+ "& .MuiSlider-mark": {
484
+ display: "none"
485
+ },
486
+ "& .MuiSlider-thumb": {
487
+ width: "5px",
488
+ height: "12px",
489
+ borderRadius: "2px",
490
+ color: l ? m.palette.action.disabled : m.palette.text.primary
491
+ },
492
+ "& .MuiSlider-markLabel": {
493
+ top: "20px",
494
+ fontSize: "12px",
495
+ color: l ? m.palette.action.disabled : m.palette.text.secondary
496
+ },
497
+ "& .MuiSlider-rail": {
498
+ backgroundColor: (Z = m.palette.backgroundPaperElevation) == null ? void 0 : Z[5],
499
+ opacity: 1
500
+ }
501
+ },
502
+ marks: o !== void 0 && i !== void 0 && [
503
+ {
504
+ value: n ? y(o) : o,
505
+ label: n ? _(y(o), 0) : J(o)
506
+ },
507
+ {
508
+ value: n ? y(i) : i,
509
+ label: n ? _(y(i), 0) : J(i)
510
+ }
511
+ ]
512
+ }
513
+ )
514
+ ]
515
+ }
516
+ ),
517
+ /* @__PURE__ */ r(
518
+ ot,
519
+ {
520
+ onPointerDown: S,
521
+ onPointerUp: I,
522
+ onPointerOut: M,
523
+ disabled: l,
524
+ disableRipple: !0,
525
+ sx: {
526
+ borderRadius: "0px 16px 16px 0px",
527
+ ...c.activeJoggingDir === "+" ? g : {}
528
+ },
529
+ children: /* @__PURE__ */ r(
530
+ de,
531
+ {
532
+ sx: {
533
+ pointerEvents: "none",
534
+ color: ft
535
+ }
536
+ }
537
+ )
538
+ }
539
+ )
540
+ ]
541
+ }
542
+ );
543
+ }
544
+ )
545
+ );
546
+ function Tt(e, t, o) {
547
+ if (t.length !== e.length)
548
+ return !0;
549
+ for (let i = 0; i < t.length; i++)
550
+ if (
551
+ // biome-ignore lint/style/noNonNullAssertion: legacy code
552
+ Math.abs(t[i] - e[i]) > o
553
+ )
554
+ return !1;
555
+ return !0;
556
+ }
557
+ function xe(e, t, o) {
558
+ if (e === void 0 && t || e && t === void 0 || (e == null ? void 0 : e.orientation) === void 0 || (t == null ? void 0 : t.orientation) === void 0 || (e == null ? void 0 : e.position) === void 0 || (t == null ? void 0 : t.position) === void 0)
559
+ return !1;
560
+ if (e === void 0 || t === void 0)
561
+ return !0;
562
+ let i = 0;
563
+ return i += Math.abs(e.orientation[0] - t.orientation[0]), i += Math.abs(e.orientation[1] - t.orientation[1]), i += Math.abs(e.orientation[2] - t.orientation[2]), i += Math.abs(e.position[0] - t.position[0]), i += Math.abs(e.position[1] - t.position[1]), i += Math.abs(e.position[2] - t.position[2]), i <= o;
564
+ }
565
+ function Jt(e, t, o) {
566
+ return e.coordinate_system === t.coordinate_system && e.tcp === t.tcp && xe(
567
+ e.tcp_pose,
568
+ t.tcp_pose,
569
+ o
570
+ );
571
+ }
572
+ function Ce(e, t) {
573
+ const o = new bt(
574
+ t[0],
575
+ t[1],
576
+ t[2]
577
+ ), i = new bt(
578
+ e[0],
579
+ e[1],
580
+ e[2]
581
+ ), n = o.length(), a = o.normalize();
582
+ let l = i.length(), s = i.normalize();
583
+ s.dot(a) < 0 && (l = -l, s = s.multiplyScalar(-1));
584
+ let h = l - n;
585
+ return h -= 2 * Math.PI * Math.floor((h + Math.PI) / (2 * Math.PI)), l = n + h, [...s.multiplyScalar(l)];
586
+ }
587
+ const xt = 1e-4;
588
+ class ht {
589
+ constructor(t, o, i, n, a, l, s = "cell") {
590
+ this.controller = o, this.motionGroup = i, this.description = n, this.initialMotionState = a, this.motionStateSocket = l, this.cellId = s, this.nova = H(t), this.rapidlyChangingMotionState = a, l.addEventListener("message", (h) => {
591
+ var g;
592
+ const d = (g = P(h.data)) == null ? void 0 : g.result;
593
+ if (!d)
594
+ throw new Error(
595
+ `Failed to get motion state for ${this.motionGroupId}: ${h.data}`
596
+ );
597
+ Tt(
598
+ this.rapidlyChangingMotionState.joint_position,
599
+ d.joint_position,
600
+ xt
601
+ ) || x(() => {
602
+ this.rapidlyChangingMotionState.joint_position = d.joint_position;
603
+ }), Jt(
604
+ this.rapidlyChangingMotionState,
605
+ d,
606
+ xt
607
+ ) || x(() => {
608
+ var c, f, y;
609
+ this.rapidlyChangingMotionState.tcp_pose == null ? this.rapidlyChangingMotionState.tcp_pose = d.tcp_pose : (c = d.tcp_pose) != null && c.orientation && ((f = d.tcp_pose) != null && f.position) && ((y = this.rapidlyChangingMotionState.tcp_pose) != null && y.orientation) ? this.rapidlyChangingMotionState.tcp_pose = {
610
+ position: d.tcp_pose.position,
611
+ orientation: Ce(
612
+ d.tcp_pose.orientation,
613
+ this.rapidlyChangingMotionState.tcp_pose.orientation
614
+ )
615
+ } : console.warn(
616
+ "Received incomplete tcp_pose, ignoring",
617
+ d.tcp_pose
618
+ );
619
+ }), d.tcp !== void 0 && this.rapidlyChangingMotionState.tcp !== d.tcp && x(() => {
620
+ this.rapidlyChangingMotionState.tcp = d.tcp;
621
+ }), this.rapidlyChangingMotionState.standstill !== d.standstill && x(() => {
622
+ this.rapidlyChangingMotionState.standstill = d.standstill;
623
+ });
624
+ const p = this.rapidlyChangingMotionState.joint_limit_reached.limit_reached, m = d.joint_limit_reached.limit_reached;
625
+ p.some((c, f) => c !== m[f]) && x(() => {
626
+ this.rapidlyChangingMotionState.joint_limit_reached = d.joint_limit_reached;
627
+ }), this.rapidlyChangingMotionState.execute !== d.execute && x(() => {
628
+ this.rapidlyChangingMotionState.execute = d.execute;
629
+ });
630
+ }), dt(this);
631
+ }
632
+ static async open(t, o, i = {}) {
633
+ var f;
634
+ const n = H(t), a = i.cellId ?? at(t) ?? "cell", [l, s] = o.split("@"), h = await n.api.controller.getCurrentRobotControllerState(
635
+ a,
636
+ s
637
+ ), d = h == null ? void 0 : h.motion_groups.find(
638
+ (y) => y.motion_group === o
639
+ );
640
+ if (!h || !d)
641
+ throw new Error(
642
+ `Controller ${s} or motion group ${o} not found`
643
+ );
644
+ const p = n.openReconnectingWebsocket(
645
+ `/cells/${a}/controllers/${s}/motion-groups/${o}/state-stream`
646
+ ), m = await p.firstMessage(), g = (f = P(m.data)) == null ? void 0 : f.result;
647
+ if (!g)
648
+ throw new Error(
649
+ `Unable to parse initial motion state message ${m.data}`
650
+ );
651
+ console.log(
652
+ `Connected motion state websocket to motion group ${d.motion_group}. Initial state:
653
+ `,
654
+ g
655
+ );
656
+ const c = await n.api.motionGroup.getMotionGroupDescription(
657
+ a,
658
+ s,
659
+ d.motion_group
660
+ );
661
+ return new ht(
662
+ n,
663
+ h,
664
+ d,
665
+ c,
666
+ g,
667
+ p,
668
+ a
669
+ );
670
+ }
671
+ get motionGroupId() {
672
+ return this.motionGroup.motion_group;
673
+ }
674
+ get controllerId() {
675
+ return this.controller.controller;
676
+ }
677
+ get joints() {
678
+ return this.initialMotionState.joint_position.map((t, o) => ({
679
+ index: o
680
+ }));
681
+ }
682
+ dispose() {
683
+ this.motionStateSocket.close();
684
+ }
685
+ }
686
+ const Ct = "Movement request rejected. Another client is currently executing a 'Jogging' motion!";
687
+ class mt {
688
+ constructor(t, o = {}) {
689
+ this.motionStream = t, this.options = o, this.DEFAULT_MODE = "off", this.DEFAULT_TCP = "Flange", this.NO_TCP = void 0, this.DEFAULT_INIT_TIMEOUT = 5e3, this.DEFAULT_ORIENTATION = "coordsys", this.mode = "off", this.joggingSocket = null, this.trajectorySocket = null, this.timeout = this.DEFAULT_INIT_TIMEOUT, this.ownsMotionStream = !1, this.tcp = (o == null ? void 0 : o.tcp) || t.motionGroup.tcp || this.getDefaultTcp(t), this.orientation = (o == null ? void 0 : o.orientation) || this.DEFAULT_ORIENTATION, this.timeout = (o == null ? void 0 : o.timeout) || this.DEFAULT_INIT_TIMEOUT, this.mode = (o == null ? void 0 : o.mode) || this.DEFAULT_MODE, this.onError = o == null ? void 0 : o.onError;
690
+ }
691
+ /**
692
+ * Initialize the jogging connection using jogging endpoint or trajectory endpoint depending on the selected mode.
693
+ *
694
+ * @param connection - The base URL of a NOVA instance, or a NOVA client of the app (see `NovaConnection`)
695
+ * @param motionGroupId - The ID of the motion group to connect to
696
+ * @param options - Configuration options for the jogger connection
697
+ * @param options.mode - The jogging mode to initialize:
698
+ * - "jogging": Continuous jogging mode with persistent websocket for real-time velocity commands
699
+ * - "trajectory": Incremental jogging mode for fixed-distance motions via trajectory planning
700
+ * - "off": No jogging enabled, all websockets closed (default)
701
+ * @param options.timeout - Timeout in milliseconds for websocket initialization (default: 5000ms)
702
+ * @param options.tcp - TCP frame to use for motions (default: from motion group)
703
+ * //param options.coordinateSystem - Coordinate system for jogging commands (default: "world"). Please note: Currently not implemented
704
+ * @param options.orientation - If set to "tool", jogging TcpVelocityRequest will use `use_tool_coordinate_system` option (default: "coordsys")
705
+ * @param options.onError - Error handler for websocket errors
706
+ * @returns Promise resolving to initialized JoggerConnection instance. Its
707
+ * `dispose()` also closes the motion stream that this function opens.
708
+ */
709
+ static async open(t, o, i = {}) {
710
+ const n = await ht.open(
711
+ t,
712
+ o,
713
+ {
714
+ cellId: i.cellId
715
+ }
716
+ ), a = new mt(n, i);
717
+ a.ownsMotionStream = !0;
718
+ try {
719
+ await a.setJoggingMode(a.mode);
720
+ } catch (l) {
721
+ throw a.dispose(), l;
722
+ }
723
+ return a;
724
+ }
725
+ getDefaultTcp(t) {
726
+ var i, n;
727
+ const o = (n = (i = t.description.dh_parameters) == null ? void 0 : i[0]) == null ? void 0 : n.type;
728
+ return t.joints.length < 6 && (o === A.RevoluteJoint || o === A.PrismaticJoint) ? this.NO_TCP : this.DEFAULT_TCP;
729
+ }
730
+ // Set a new tcp or other options. If current mode is jogging, will reinitialize the jogging websocket
731
+ async setOptions(t) {
732
+ return t.tcp && (this.tcp = t.tcp), t.orientation && (this.orientation = t.orientation), t.timeout && (this.timeout = t.timeout), t.mode && (this.mode = t.mode), t.onError && (this.onError = t.onError), this.setJoggingMode(this.mode, !1);
733
+ }
734
+ get motionGroupId() {
735
+ return this.motionStream.motionGroupId;
736
+ }
737
+ /**
738
+ * The library's own NOVA client of the motion stream
739
+ * @internal
740
+ */
741
+ get nova() {
742
+ return this.motionStream.nova;
743
+ }
744
+ get cellId() {
745
+ return this.motionStream.cellId;
746
+ }
747
+ get numJoints() {
748
+ return this.motionStream.joints.length;
749
+ }
750
+ // get activeJoggingMode() {
751
+ // return this.mode
752
+ // }
753
+ // get activeWebsocket() {
754
+ // return this.mode === "jogging" ? this.joggingSocket : this.trajectorySocket;
755
+ // }
756
+ // Sends stop movement command to robot
757
+ async stop() {
758
+ if (this.joggingSocket) {
759
+ const t = new Array(this.numJoints).fill(0);
760
+ this.joggingSocket.sendJson({
761
+ message_type: "JointVelocityRequest",
762
+ velocity: t
763
+ });
764
+ }
765
+ this.trajectorySocket && this.trajectorySocket.sendJson({
766
+ message_type: "PauseMovementRequest"
767
+ });
768
+ }
769
+ /**
770
+ * Dispose the jogger, closing all open websockets: the jogging websockets,
771
+ * and the motion stream if the jogger opened it (in `open()`). A motion
772
+ * stream given to the constructor stays open: its caller closes it.
773
+ */
774
+ async dispose() {
775
+ const t = this.closeJoggingSockets();
776
+ return this.ownsMotionStream && this.motionStream.dispose(), t;
777
+ }
778
+ /** Closes the jogging and trajectory websockets */
779
+ closeJoggingSockets() {
780
+ var o;
781
+ (o = this.endJoggingInit) == null || o.call(this);
782
+ const t = [this.joggingSocket, this.trajectorySocket].filter(
783
+ (i) => i !== null
784
+ );
785
+ return t.forEach((i) => {
786
+ i.dispose();
787
+ }), this.joggingSocket = null, this.trajectorySocket = null, Promise.all(t.map((i) => i.closed()));
788
+ }
789
+ // Activate jogger in one of the supported modes
790
+ // Will iniitialize or close websockets as necessary
791
+ // If mode is unchanged, does nothing (unless skipReinitializeIfSameMode is false)
792
+ async setJoggingMode(t, o = !0) {
793
+ if (!(this.mode === t && o) && (this.closeJoggingSockets(), this.mode = t, this.mode === "jogging"))
794
+ return this.initializeJoggingWebsocket();
795
+ }
796
+ /**
797
+ * Opens the continuous jogging websocket and initializes it; called by
798
+ * `setJoggingMode("jogging")`. The promise settles once:
799
+ * - it resolves when NOVA confirms the initialization (INITIALIZE_RECEIVED),
800
+ * when the jogger closes the websocket before that (`setJoggingMode`,
801
+ * `dispose`), or when an error message goes to `onBlocked` or `onError`;
802
+ * - it rejects on an error message without such a handler, and when NOVA
803
+ * does not confirm the initialization within `timeout` milliseconds.
804
+ */
805
+ async initializeJoggingWebsocket() {
806
+ return new Promise((t, o) => {
807
+ const i = this.nova.openReconnectingWebsocket(
808
+ `/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`
809
+ );
810
+ this.joggingSocket = i;
811
+ let n = !1;
812
+ const a = setTimeout(() => {
813
+ l(
814
+ new Error(`Jogging initialization timeout after ${this.timeout} ms`)
815
+ );
816
+ }, this.timeout), l = (d) => {
817
+ n || (n = !0, clearTimeout(a), i.removeEventListener("close", h), this.endJoggingInit === s && (this.endJoggingInit = void 0), d ? o(d) : t());
818
+ }, s = () => l(), h = () => {
819
+ i.disposed && l();
820
+ };
821
+ this.endJoggingInit = s, i.addEventListener("close", h), i.addEventListener("message", (d) => {
822
+ var m, g, c;
823
+ const p = P(d.data);
824
+ if (((m = p == null ? void 0 : p.result) == null ? void 0 : m.kind) === "INITIALIZE_RECEIVED") {
825
+ l();
826
+ return;
827
+ }
828
+ if (((g = p == null ? void 0 : p.result) == null ? void 0 : g.kind) === "MOTION_ERROR")
829
+ if (this.onBlocked && ((c = p == null ? void 0 : p.result) != null && c.message.includes(Ct))) {
830
+ l(), i.dispose(), this.onBlocked();
831
+ return;
832
+ } else this.onError ? (l(), this.onError(d.data)) : l(new Error(d.data));
833
+ }), i.sendJson({
834
+ message_type: "InitializeJoggingRequest",
835
+ motion_group: this.motionGroupId,
836
+ ...this.tcp ? { tcp: this.tcp } : {}
837
+ });
838
+ });
839
+ }
840
+ /**
841
+ * Jogging: Start rotation of a single robot joint at the specified velocity
842
+ */
843
+ async rotateJoints({
844
+ joint: t,
845
+ direction: o,
846
+ velocityValue: i,
847
+ velocityUnit: n
848
+ }) {
849
+ if (!this.joggingSocket || this.mode !== "jogging")
850
+ throw new Error(
851
+ "Joint jogging websocket not connected; create one by setting jogging mode to 'jogging'"
852
+ );
853
+ const a = new Array(this.numJoints).fill(0);
854
+ a[t] = o === "-" ? -i : i, this.joggingSocket.sendJson({
855
+ message_type: "JointVelocityRequest",
856
+ velocity: a
857
+ });
858
+ }
859
+ /**
860
+ * Jogging: Start the TCP moving along a specified axis at a given velocity
861
+ */
862
+ async translateTCP({
863
+ axis: t,
864
+ direction: o,
865
+ velocityMmPerSec: i
866
+ }) {
867
+ if (!this.joggingSocket || this.mode !== "jogging")
868
+ throw new Error(
869
+ "Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'"
870
+ );
871
+ const n = [0, 0, 0], a = [0, 0, 0];
872
+ a[W[t]] = o === "-" ? -i : i, this.joggingSocket.sendJson({
873
+ message_type: "TcpVelocityRequest",
874
+ translation: a,
875
+ rotation: n,
876
+ use_tool_coordinate_system: this.orientation === "tool"
877
+ });
878
+ }
879
+ /**
880
+ * Jogging: Start the TCP rotating around a specified axis at a given velocity
881
+ */
882
+ async rotateTCP({
883
+ axis: t,
884
+ direction: o,
885
+ velocityRadsPerSec: i
886
+ }) {
887
+ if (!this.joggingSocket || this.mode !== "jogging")
888
+ throw new Error(
889
+ "Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'"
890
+ );
891
+ const n = [0, 0, 0], a = [0, 0, 0];
892
+ n[W[t]] = o === "-" ? -i : i, this.joggingSocket.sendJson({
893
+ message_type: "TcpVelocityRequest",
894
+ translation: a,
895
+ rotation: n,
896
+ use_tool_coordinate_system: this.orientation === "tool"
897
+ });
898
+ }
899
+ /**
900
+ * Trajectory jogging:
901
+ *
902
+ * Move the robot by a fixed distance in a single cartesian
903
+ * axis, either rotating or translating relative to the TCP.
904
+ * Promise resolves only after the motion has completed.
905
+ */
906
+ async runIncrementalCartesianMotion({
907
+ currentTcpPose: t,
908
+ currentJoints: o,
909
+ // coordSystemId,
910
+ velocityInRelevantUnits: i,
911
+ axis: n,
912
+ direction: a,
913
+ motion: l
914
+ }) {
915
+ const s = [];
916
+ if (this.mode !== "trajectory")
917
+ throw new Error(
918
+ "Set jogging mode to 'trajectory' to run incremental cartesian motions"
919
+ );
920
+ if (l.type === "translate") {
921
+ if (!t.position)
922
+ throw new Error(
923
+ "Current pose has no position, cannot perform translation"
924
+ );
925
+ const u = [...t.position];
926
+ u[W[n]] += l.distanceMm * (a === "-" ? -1 : 1), s.push({
927
+ limits_override: {
928
+ tcp_velocity_limit: i
929
+ },
930
+ path: {
931
+ path_definition_name: "PathLine",
932
+ target_pose: {
933
+ position: u,
934
+ orientation: t.orientation
935
+ }
936
+ }
937
+ });
938
+ } else if (l.type === "rotate") {
939
+ if (!t.orientation)
940
+ throw new Error(
941
+ "Current pose has no orientation, cannot perform rotation"
942
+ );
943
+ const u = new nt(
944
+ t.orientation[0],
945
+ t.orientation[1],
946
+ t.orientation[2]
947
+ ), S = u.length(), I = u.clone().normalize(), M = l.distanceRads * (a === "-" ? -1 : 1), _ = new nt(0, 0, 0);
948
+ _[n] = 1;
949
+ const J = Math.cos(0.5 * M) * Math.cos(0.5 * S), E = Math.sin(0.5 * M) * Math.sin(0.5 * S), R = Math.sin(0.5 * M) * Math.cos(0.5 * S), L = Math.cos(0.5 * M) * Math.sin(0.5 * S), $ = _.dot(
950
+ I
951
+ ), T = _.clone().cross(I), O = 2 * Math.acos(J - E * $), Z = O / Math.sin(0.5 * O), v = new nt().addScaledVector(T, E).addScaledVector(_, R).addScaledVector(I, L).multiplyScalar(Z);
952
+ s.push({
953
+ limits_override: {
954
+ tcp_orientation_velocity_limit: i
955
+ },
956
+ path: {
957
+ path_definition_name: "PathLine",
958
+ target_pose: {
959
+ position: t.position,
960
+ orientation: [...v]
961
+ }
962
+ }
963
+ });
964
+ }
965
+ const h = this.motionStream.description;
966
+ if (h.cycle_time === void 0) {
967
+ console.warn(
968
+ "Current motion group has no cycle time, cannot plan jogging motion"
969
+ );
970
+ return;
971
+ }
972
+ const d = {
973
+ motion_group_model: h.motion_group_model,
974
+ cycle_time: h.cycle_time,
975
+ mounting: h.mounting,
976
+ // tcp_offset: description.tcp_offset, TODO: implement tcp_offset handling
977
+ // FIXME use proper mode's limits if set
978
+ global: h.operation_limits.auto_limits
979
+ }, p = await this.nova.api.trajectoryPlanning.planTrajectory(
980
+ this.cellId,
981
+ {
982
+ motion_group_setup: d,
983
+ start_joint_position: o,
984
+ motion_commands: s
985
+ }
986
+ ), m = p.response;
987
+ if (!m)
988
+ throw new Error(
989
+ `Failed to plan jogging increment motion ${JSON.stringify(p)}`
990
+ );
991
+ this.trajectorySocket && (console.warn("Trajectory jogging websocket already open; will close"), this.trajectorySocket.dispose()), this.trajectorySocket = this.nova.openReconnectingWebsocket(
992
+ `/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`
993
+ );
994
+ const g = (u) => {
995
+ var S;
996
+ if (!u || u.add_trajectory_error || u.message)
997
+ if (this.onError)
998
+ this.onError(u);
999
+ else
1000
+ throw new Error(
1001
+ ((S = u == null ? void 0 : u.add_trajectory_error) == null ? void 0 : S.message) || (u == null ? void 0 : u.message) || "Failed to execute trajectory, unknown error"
1002
+ );
1003
+ if (!this.trajectorySocket)
1004
+ throw new Error(
1005
+ "Failed to execute trajectory, websocket not available anymore"
1006
+ );
1007
+ this.trajectorySocket.sendJson({
1008
+ message_type: "StartMovementRequest",
1009
+ direction: "DIRECTION_FORWARD"
1010
+ });
1011
+ }, c = async () => {
1012
+ var u;
1013
+ await Q(() => !this.motionStream.rapidlyChangingMotionState.standstill), await Q(() => this.motionStream.rapidlyChangingMotionState.standstill), (u = this.trajectorySocket) == null || u.dispose(), this.trajectorySocket = null;
1014
+ }, f = async () => {
1015
+ var u;
1016
+ await Q(() => this.motionStream.rapidlyChangingMotionState.standstill), (u = this.trajectorySocket) == null || u.dispose(), this.trajectorySocket = null;
1017
+ }, y = async (u) => {
1018
+ if (u != null && u.message)
1019
+ if (this.onError) {
1020
+ this.onError(u);
1021
+ return;
1022
+ } else
1023
+ throw new Error(
1024
+ u.message || "Failed to execute trajectory, unknown error"
1025
+ );
1026
+ this.motionStream.rapidlyChangingMotionState.standstill ? await c() : await f();
1027
+ };
1028
+ this.trajectorySocket.addEventListener("message", (u) => {
1029
+ var I, M;
1030
+ const S = P(u.data);
1031
+ if (!((I = S == null ? void 0 : S.result) != null && I.kind))
1032
+ throw new Error(
1033
+ `Failed to execute trajectory: Received invalid message ${u.data}`
1034
+ );
1035
+ if (this.onBlocked && ((M = S.result.message) != null && M.includes(Ct))) {
1036
+ this.onBlocked();
1037
+ return;
1038
+ }
1039
+ if (S.result.kind === "INITIALIZE_RECEIVED")
1040
+ g(S.result);
1041
+ else if (S.result.kind === "START_RECEIVED")
1042
+ y(S);
1043
+ else if (S.result.kind !== "PAUSE_RECEIVED") if (S.result.kind === "MOTION_ERROR" && S.result.message)
1044
+ if (this.onError) {
1045
+ this.onError(S);
1046
+ return;
1047
+ } else
1048
+ throw new Error(S.result.message);
1049
+ else
1050
+ throw new Error(
1051
+ `Failed to execute trajectory, cannot handle message type "${S.result.kind}"`
1052
+ );
1053
+ }), this.trajectorySocket.sendJson({
1054
+ message_type: "InitializeMovementRequest",
1055
+ trajectory: {
1056
+ message_type: "TrajectoryData",
1057
+ motion_group: this.motionGroupId,
1058
+ data: m,
1059
+ tcp: this.tcp
1060
+ }
1061
+ });
1062
+ }
1063
+ }
1064
+ const we = (e) => {
1065
+ const t = e.softTimeout || 3e3, [o, i] = q(!1);
1066
+ return et(() => {
1067
+ const n = setTimeout(() => {
1068
+ i(!0);
1069
+ }, t);
1070
+ return () => clearTimeout(n);
1071
+ }), /* @__PURE__ */ r(
1072
+ w,
1073
+ {
1074
+ width: "100%",
1075
+ height: "100%",
1076
+ alignItems: "center",
1077
+ justifyContent: "center",
1078
+ sx: { color: "text.primary" },
1079
+ children: e.error ? /* @__PURE__ */ r(
1080
+ Ie,
1081
+ {
1082
+ loadingMessage: e.message,
1083
+ error: e.error
1084
+ }
1085
+ ) : /* @__PURE__ */ b(tt, { children: [
1086
+ /* @__PURE__ */ r(_t, { sx: { mb: 3 } }),
1087
+ !!e.message && /* @__PURE__ */ r(j, { variant: "body1", children: e.message }),
1088
+ /* @__PURE__ */ r(
1089
+ j,
1090
+ {
1091
+ variant: "body2",
1092
+ sx: {
1093
+ visibility: o ? "visible" : "hidden",
1094
+ mt: 2,
1095
+ color: "text.secondary"
1096
+ },
1097
+ children: "This is taking longer than expected..."
1098
+ }
1099
+ )
1100
+ ] })
1101
+ }
1102
+ );
1103
+ }, Ie = (e) => {
1104
+ const t = Xt(e.error), o = e.error instanceof Error ? e.error.stack : null;
1105
+ return /* @__PURE__ */ b(
1106
+ w,
1107
+ {
1108
+ sx: {
1109
+ maxHeight: "100%",
1110
+ maxWidth: "min(100%, 800px)",
1111
+ p: 2,
1112
+ overflow: "auto",
1113
+ color: "error.main"
1114
+ },
1115
+ children: [
1116
+ /* @__PURE__ */ r(j, { variant: "body1", children: (e.loadingMessage ? `Error while ${Zt(Yt(e.loadingMessage))} - ` : "") + t }),
1117
+ o && /* @__PURE__ */ r(
1118
+ V,
1119
+ {
1120
+ component: "pre",
1121
+ sx: {
1122
+ typography: "body2",
1123
+ fontFamily: "monospace",
1124
+ whiteSpace: "pre-wrap",
1125
+ wordBreak: "break-word",
1126
+ mt: 2,
1127
+ pb: 6
1128
+ },
1129
+ children: o
1130
+ }
1131
+ )
1132
+ ]
1133
+ }
1134
+ );
1135
+ }, Me = k(({ store: e }) => {
1136
+ const { t } = D();
1137
+ return /* @__PURE__ */ r(
1138
+ It,
1139
+ {
1140
+ "data-testid": "jogging-blocked",
1141
+ "aria-label": "jogging-blocked",
1142
+ open: !0,
1143
+ sx: {
1144
+ position: "absolute",
1145
+ zIndex: (o) => o.zIndex.drawer + 1,
1146
+ color: "#fff",
1147
+ background: "rgba(15, 15, 15, 0.88)",
1148
+ justifyContent: "flex-start",
1149
+ alignItems: "flex-start"
1150
+ },
1151
+ children: /* @__PURE__ */ b(w, { sx: { m: 2, width: "100%" }, children: [
1152
+ /* @__PURE__ */ b(Qt, { severity: "error", sx: { mb: 2 }, children: [
1153
+ /* @__PURE__ */ r(te, { children: t("Jogging.Blocked.ti") }),
1154
+ t("Jogging.Blocked.lb")
1155
+ ] }),
1156
+ /* @__PURE__ */ r(
1157
+ st,
1158
+ {
1159
+ variant: "contained",
1160
+ color: "secondary",
1161
+ onClick: () => e.unblock(),
1162
+ children: t("Jogging.Blocked.Reenable.bt")
1163
+ }
1164
+ )
1165
+ ] })
1166
+ }
1167
+ );
1168
+ }), je = ({
1169
+ title: e,
1170
+ titleId: t,
1171
+ ...o
1172
+ }, i) => /* @__PURE__ */ C.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 19, height: 10, fill: "none", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("path", { fill: "#fff", fillRule: "evenodd", d: "M5.131.312a.9.9 0 0 1 0 1.272L3.07 3.645h12.44l-2.06-2.061A.9.9 0 0 1 14.72.313l3.596 3.596a.9.9 0 0 1 0 1.271l-3.596 3.597a.9.9 0 0 1-1.271-1.272l2.061-2.062H3.07L5.13 7.505A.9.9 0 0 1 3.86 8.777L.263 5.18a.9.9 0 0 1 0-1.271L3.86.312a.9.9 0 0 1 1.271 0", clipRule: "evenodd" })), _e = N(je), ke = ({
1173
+ title: e,
1174
+ titleId: t,
1175
+ ...o
1176
+ }, i) => /* @__PURE__ */ C.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 19, height: 10, fill: "none", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("path", { fill: "#fff", fillRule: "evenodd", d: "M5.131.312a.9.9 0 0 1 0 1.272L3.07 3.645h12.44l-2.06-2.061A.9.9 0 0 1 14.72.313l3.596 3.596a.9.9 0 0 1 0 1.271l-3.596 3.597a.9.9 0 0 1-1.271-1.272l2.061-2.062H3.07L5.13 7.505A.9.9 0 0 1 3.86 8.777L.263 5.18a.9.9 0 0 1 0-1.271L3.86.312a.9.9 0 0 1 1.271 0", clipRule: "evenodd" })), Ee = N(ke), Te = ({
1177
+ title: e,
1178
+ titleId: t,
1179
+ ...o
1180
+ }, i) => /* @__PURE__ */ C.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 10, height: 19, fill: "none", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("path", { fill: "#fff", fillRule: "evenodd", d: "M9.522 14.811A.899.899 0 1 0 8.25 13.54L6.19 15.601V3.16L8.25 5.221A.9.9 0 0 0 9.522 3.95L5.926.354a.9.9 0 0 0-1.272 0L1.058 3.95a.9.9 0 1 0 1.271 1.271L4.391 3.16v12.442L2.329 13.54a.899.899 0 1 0-1.271 1.271l3.596 3.597a.9.9 0 0 0 1.272 0z", clipRule: "evenodd" })), Je = N(Te), Re = ({
1181
+ title: e,
1182
+ titleId: t,
1183
+ ...o
1184
+ }, i) => /* @__PURE__ */ C.createElement("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("path", { d: "M8 16C5.76667 16 3.875 15.225 2.325 13.675C0.775 12.125 0 10.2333 0 8C0 5.76667 0.775 3.875 2.325 2.325C3.875 0.775 5.76667 0 8 0C9.15 0 10.25 0.2375 11.3 0.7125C12.35 1.1875 13.25 1.86667 14 2.75V0H16V7H9V5H13.2C12.6667 4.06667 11.9375 3.33333 11.0125 2.8C10.0875 2.26667 9.08333 2 8 2C6.33333 2 4.91667 2.58333 3.75 3.75C2.58333 4.91667 2 6.33333 2 8C2 9.66667 2.58333 11.0833 3.75 12.25C4.91667 13.4167 6.33333 14 8 14C9.28333 14 10.4417 13.6333 11.475 12.9C11.0583 14.1 12.5083 12.1667 11.475 12.9L12.9 14.325C11.4667 15.4417 9.83333 16 8 16Z", fill: "white" })), Oe = N(Re), Rt = k(
1185
+ ({ store: e }) => {
1186
+ const { t } = D(), [o, i] = q(
1187
+ e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached
1188
+ ), n = it(o);
1189
+ gt(() => {
1190
+ const l = e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;
1191
+ ee(n.current, l) || (n.current = l, i(l));
1192
+ });
1193
+ const a = [];
1194
+ for (const [l, s] of o.entries())
1195
+ s && a.push(l);
1196
+ return /* @__PURE__ */ r(
1197
+ V,
1198
+ {
1199
+ sx: {
1200
+ display: "flex",
1201
+ flexDirection: "row",
1202
+ justifyContent: "center"
1203
+ },
1204
+ children: /* @__PURE__ */ r(
1205
+ j,
1206
+ {
1207
+ "data-testid": "jogging-joint-limit-detector",
1208
+ "aria-label": "jogging-joint-limit-detector",
1209
+ color: "error",
1210
+ variant: "body2",
1211
+ sx: {
1212
+ fontSize: "0.75rem",
1213
+ lineHeight: 1.2,
1214
+ visibility: a.length ? "visible" : "hidden"
1215
+ },
1216
+ children: t("Jogging.JointLimitsReached.lb", {
1217
+ jointNumbers: a.map((l) => l + 1).join(", ")
1218
+ })
1219
+ }
1220
+ )
1221
+ }
1222
+ );
1223
+ }
1224
+ ), Pe = kt(ie)(({ theme: e }) => ({
1225
+ "&.MuiFormControl-root": {
1226
+ ".MuiSelect-select": {
1227
+ paddingTop: "20px",
1228
+ paddingLeft: "12px"
1229
+ },
1230
+ label: {
1231
+ pointerEvents: "none",
1232
+ fontSize: "16px"
1233
+ },
1234
+ ".MuiInputLabel-root": {
1235
+ "&.Mui-focused": {
1236
+ color: e.palette.text.primary
1237
+ }
1238
+ }
1239
+ }
1240
+ }));
1241
+ function X({
1242
+ labelValue: e,
1243
+ ...t
1244
+ }) {
1245
+ return /* @__PURE__ */ b(Pe, { fullWidth: !0, variant: "filled", children: [
1246
+ /* @__PURE__ */ r(ne, { id: t.labelId, children: e }),
1247
+ /* @__PURE__ */ r(re, { ...t })
1248
+ ] });
1249
+ }
1250
+ const lt = [
1251
+ { id: "0.1", mm: 0.1, degrees: 0.05 },
1252
+ { id: "1", mm: 1, degrees: 0.5 },
1253
+ { id: "5", mm: 5, degrees: 2.5 },
1254
+ { id: "10", mm: 10, degrees: 5 }
1255
+ ], De = [
1256
+ { id: "continuous" },
1257
+ ...lt
1258
+ ], Ae = ["coordsys", "tool"];
1259
+ class ut {
1260
+ constructor(t, o, i, n, a) {
1261
+ var l, s, h;
1262
+ this.jogger = t, this.coordSystems = o, this.motionGroupDescription = i, this.tcps = n, this.inverseSolverValue = a, this.selectedTabId = "cartesian", this.locks = /* @__PURE__ */ new Set(), this.blocked = !1, this.selectedCoordSystemId = "world", this.selectedTcpId = "", this.tcpChangeInProgress = !1, this.selectedOrientation = "coordsys", this.selectedIncrementId = "continuous", this.selectedCartesianMotionType = "translate", this.incrementJogInProgress = null, this.translationVelocityMmPerSec = 10, this.rotationVelocityDegPerSec = 1, this.minTranslationVelocityMmPerSec = 5, this.maxTranslationVelocityMmPerSec = 250, this.minRotationVelocityDegPerSec = 1, this.maxRotationVelocityDegPerSec = 60, this.showCoordSystemSelect = !1, this.showTcpSelect = !0, this.showOrientationSelect = !0, this.showIncrementSelect = !0, this.showTabIcons = !1, this.showVelocitySliderLabel = !0, this.showVelocityLegend = !1, this.showJointsLegend = !1, this.disposers = [], this.inverseSolver = void 0, this.jointType = A.RevoluteJoint;
1263
+ for (const d of o)
1264
+ if (d.coordinate_system === "") {
1265
+ d.coordinate_system = "world";
1266
+ break;
1267
+ }
1268
+ this.selectedCoordSystemId = ((l = o[0]) == null ? void 0 : l.coordinate_system) || "world", this.selectedTcpId = t.motionStream.rapidlyChangingMotionState.tcp ?? "", this.tcpChangeInProgress = this.tcps.length > 0 && !this.selectedTcpId, this.inverseSolver = a, this.jointType = ((h = (s = i == null ? void 0 : i.dh_parameters) == null ? void 0 : s[0]) == null ? void 0 : h.type) ?? A.RevoluteJoint, dt(this, {}, { autoBind: !0 }), this.jogger.onBlocked = () => {
1269
+ this.block();
1270
+ }, this.loadFromLocalStorage(), this.disposers.push(pt(() => this.saveToLocalStorage())), this.disposers.push(
1271
+ pt(() => {
1272
+ const d = this.jogger.motionStream.rapidlyChangingMotionState.tcp;
1273
+ d && d !== this.selectedTcpId && x(() => {
1274
+ this.selectedTcpId = d, this.tcpChangeInProgress = !1;
1275
+ });
1276
+ })
1277
+ ), window.joggingStore = this;
1278
+ }
1279
+ /**
1280
+ * Load a jogging store with the relevant data it needs
1281
+ * from the backend
1282
+ */
1283
+ static async loadFor(t) {
1284
+ const { nova: o, cellId: i } = t, [n, a] = await Promise.all([
1285
+ // Fetch coord systems so user can select between them
1286
+ o.api.controller.listCoordinateSystems(
1287
+ i,
1288
+ t.motionStream.controllerId,
1289
+ "ROTATION_VECTOR"
1290
+ ),
1291
+ // Same for TCPs and other info from description
1292
+ o.api.motionGroup.getMotionGroupDescription(
1293
+ i,
1294
+ t.motionStream.controllerId,
1295
+ t.motionGroupId
1296
+ )
1297
+ ]), l = await o.api.motionGroupModels.getMotionGroupKinematicModel(
1298
+ a.motion_group_model
1299
+ ), s = Object.entries(a.tcps || {}).map(([h, d]) => ({
1300
+ id: h,
1301
+ readable_name: d.name,
1302
+ position: d.pose.position,
1303
+ orientation: d.pose.orientation
1304
+ }));
1305
+ return new ut(
1306
+ t,
1307
+ n || [],
1308
+ a,
1309
+ s,
1310
+ l.inverse_solver
1311
+ );
1312
+ }
1313
+ dispose() {
1314
+ for (const t of this.disposers)
1315
+ t();
1316
+ this.jogger.dispose();
1317
+ }
1318
+ get coordSystemCountByName() {
1319
+ return Kt(this.coordSystems, (t) => t.name);
1320
+ }
1321
+ async deactivate() {
1322
+ this.jogger.mode === "jogging" && await this.jogger.setJoggingMode("off");
1323
+ }
1324
+ /**
1325
+ * Activate the jogger with current settings. Resolves when the jogging
1326
+ * websocket is initialized, or when the jogging was stopped before that
1327
+ * (`deactivate`).
1328
+ */
1329
+ async activate() {
1330
+ return this.currentTab.id === "cartesian" ? ((this.jogger.tcp !== this.selectedTcpId || this.jogger.orientation !== this.selectedOrientation) && await this.jogger.setOptions({
1331
+ tcp: this.selectedTcpId || void 0,
1332
+ orientation: this.selectedOrientation
1333
+ }), this.activeDiscreteIncrement ? await this.jogger.setJoggingMode("trajectory") : await this.jogger.setJoggingMode("jogging")) : await this.jogger.setJoggingMode("jogging"), this.jogger;
1334
+ }
1335
+ loadFromLocalStorage() {
1336
+ const t = P(localStorage.getItem("joggingToolStore"));
1337
+ t && (this.tabsById[t.selectedTabId] && (this.selectedTabId = t.selectedTabId), this.coordSystemsById[t.selectedCoordSystemId] && (this.selectedCoordSystemId = t.selectedCoordSystemId), this.incrementOptionsById[t.selectedIncrementId] && (this.selectedIncrementId = t.selectedIncrementId), ["translate", "rotate"].includes(t.selectedCartesianMotionType) && (this.selectedCartesianMotionType = t.selectedCartesianMotionType), ["coordsys", "tool"].includes(t.selectedOrientation) && (this.selectedOrientation = t.selectedOrientation));
1338
+ }
1339
+ saveToLocalStorage() {
1340
+ localStorage.setItem(
1341
+ "joggingToolStore",
1342
+ JSON.stringify(this.localStorageSave)
1343
+ );
1344
+ }
1345
+ get isLocked() {
1346
+ return this.locks.size > 0;
1347
+ }
1348
+ get localStorageSave() {
1349
+ return {
1350
+ selectedTabId: this.selectedTabId,
1351
+ selectedCoordSystemId: this.selectedCoordSystemId,
1352
+ selectedOrientation: this.selectedOrientation,
1353
+ selectedIncrementId: this.selectedIncrementId,
1354
+ selectedCartesianMotionType: this.selectedCartesianMotionType
1355
+ };
1356
+ }
1357
+ get tabs() {
1358
+ const t = [
1359
+ {
1360
+ id: "joint",
1361
+ label: "Joints"
1362
+ }
1363
+ ];
1364
+ return this.inverseSolver !== null && t.unshift({
1365
+ id: "cartesian",
1366
+ label: "Cartesian"
1367
+ }), t;
1368
+ }
1369
+ get incrementOptions() {
1370
+ return De;
1371
+ }
1372
+ get discreteIncrementOptions() {
1373
+ return lt;
1374
+ }
1375
+ get incrementOptionsById() {
1376
+ return K(this.incrementOptions, (t) => t.id);
1377
+ }
1378
+ get tabsById() {
1379
+ return K(this.tabs, (t) => t.id);
1380
+ }
1381
+ get currentTab() {
1382
+ return this.tabsById[this.selectedTabId] || this.tabs[0];
1383
+ }
1384
+ get tabIndex() {
1385
+ return this.tabs.indexOf(this.currentTab);
1386
+ }
1387
+ get coordSystemsById() {
1388
+ return K(this.coordSystems, (t) => t.coordinate_system);
1389
+ }
1390
+ /**
1391
+ * The id of the coordinate system to use for jogging.
1392
+ * If in tool orientation, this is set to "tool", not the
1393
+ * selected coordinate system.
1394
+ */
1395
+ get activeCoordSystemId() {
1396
+ return this.selectedOrientation === "tool" ? "tool" : this.selectedCoordSystemId;
1397
+ }
1398
+ get tcpsById() {
1399
+ return K(this.tcps, (t) => t.id);
1400
+ }
1401
+ get activeDiscreteIncrement() {
1402
+ return this.selectedOrientation === "tool" ? void 0 : lt.find((t) => t.id === this.selectedIncrementId);
1403
+ }
1404
+ /** The selected rotation velocity converted to radians per second */
1405
+ get rotationVelocityRadsPerSec() {
1406
+ return this.rotationVelocityDegPerSec * Math.PI / 180;
1407
+ }
1408
+ /** Selected velocity in mm/sec or deg/sec */
1409
+ velocityInDisplayUnits(t) {
1410
+ return t ? this.rotationVelocityDegPerSec : this.translationVelocityMmPerSec;
1411
+ }
1412
+ /** Minimum selectable velocity in mm/sec or deg/sec */
1413
+ minVelocityInDisplayUnits(t) {
1414
+ return t ? this.minRotationVelocityDegPerSec : this.minTranslationVelocityMmPerSec;
1415
+ }
1416
+ /** Maximum selectable velocity in mm/sec or deg/sec */
1417
+ maxVelocityInDisplayUnits(t) {
1418
+ return t ? this.maxRotationVelocityDegPerSec : this.maxTranslationVelocityMmPerSec;
1419
+ }
1420
+ onTabChange(t, o) {
1421
+ const i = this.tabs[o] || this.tabs[0];
1422
+ this.selectedTabId = i.id;
1423
+ }
1424
+ setSelectedCoordSystemId(t) {
1425
+ this.selectedCoordSystemId = t;
1426
+ }
1427
+ /**
1428
+ * @deprecated Use {@link JoggingStore.requestTcpChange} instead. This method now delegates
1429
+ * to `requestTcpChange` which properly communicates the TCP change to the server.
1430
+ */
1431
+ setSelectedTcpId(t) {
1432
+ this.requestTcpChange(t).catch((o) => {
1433
+ console.error("Failed to change TCP:", o);
1434
+ });
1435
+ }
1436
+ /**
1437
+ * Request a TCP change on the server. Sends an InitializeJoggingRequest
1438
+ * with the new TCP to the backend via the jogging websocket.
1439
+ *
1440
+ * If the jogger is actively jogging, the websocket is reinitialised with the new TCP.
1441
+ * If the jogger is idle, a jogging websocket is briefly opened to communicate the
1442
+ * TCP change. The websocket is kept open until the state-stream confirms the
1443
+ * change (or a 1s timeout), to ensure the backend has time to process it.
1444
+ */
1445
+ async requestTcpChange(t) {
1446
+ if (t === this.selectedTcpId) return;
1447
+ this.tcpChangeInProgress = !0;
1448
+ const o = this.jogger.tcp, i = this.jogger.mode !== "jogging";
1449
+ try {
1450
+ this.jogger.tcp = t, i ? await this.jogger.setJoggingMode("jogging") : await this.jogger.setJoggingMode("jogging", !1);
1451
+ let n = await this.waitForTcpConfirmation(t, 1e3);
1452
+ i && await this.jogger.setJoggingMode("off"), n || (n = await this.waitForTcpConfirmation(t, 2e3)), x(() => {
1453
+ n ? this.selectedTcpId = t : (this.jogger.tcp = o, this.selectedTcpId = this.jogger.motionStream.rapidlyChangingMotionState.tcp ?? "");
1454
+ });
1455
+ } catch (n) {
1456
+ throw i && await this.jogger.setJoggingMode("off").catch(() => {
1457
+ }), x(() => {
1458
+ this.jogger.tcp = o, this.selectedTcpId = this.jogger.motionStream.rapidlyChangingMotionState.tcp ?? "";
1459
+ }), n;
1460
+ } finally {
1461
+ x(() => {
1462
+ this.tcpChangeInProgress = !1;
1463
+ });
1464
+ }
1465
+ }
1466
+ waitForTcpConfirmation(t, o) {
1467
+ return new Promise((i) => {
1468
+ const n = setTimeout(() => {
1469
+ a(), i(!1);
1470
+ }, o), a = Q(
1471
+ () => this.jogger.motionStream.rapidlyChangingMotionState.tcp === t,
1472
+ () => {
1473
+ clearTimeout(n), i(!0);
1474
+ }
1475
+ );
1476
+ });
1477
+ }
1478
+ setSelectedOrientation(t) {
1479
+ this.selectedOrientation = t;
1480
+ }
1481
+ setSelectedIncrementId(t) {
1482
+ this.selectedIncrementId = t;
1483
+ }
1484
+ setCurrentIncrementJog(t) {
1485
+ this.incrementJogInProgress = t;
1486
+ }
1487
+ setVelocityFromSlider(t, o) {
1488
+ o ? this.rotationVelocityDegPerSec = t : this.translationVelocityMmPerSec = t;
1489
+ }
1490
+ setSelectedCartesianMotionType(t) {
1491
+ this.selectedCartesianMotionType = t;
1492
+ }
1493
+ lock(t) {
1494
+ this.locks.add(t);
1495
+ }
1496
+ unlock(t) {
1497
+ this.locks.delete(t);
1498
+ }
1499
+ block() {
1500
+ this.blocked = !0;
1501
+ }
1502
+ unblock() {
1503
+ this.blocked = !1, this.jogger.mode === "jogging" && this.jogger.initializeJoggingWebsocket().catch((t) => {
1504
+ console.error("Failed to initialize jogging:", t);
1505
+ });
1506
+ }
1507
+ /** Lock the UI until the given async callback resolves */
1508
+ async withMotionLock(t) {
1509
+ const o = ae();
1510
+ this.lock(o);
1511
+ try {
1512
+ return await t();
1513
+ } finally {
1514
+ this.unlock(o);
1515
+ }
1516
+ }
1517
+ }
1518
+ const Ve = k(
1519
+ ({ store: e, useDegree: t }) => {
1520
+ var l;
1521
+ const { t: o } = D(), i = Nt(), n = [];
1522
+ function a(s) {
1523
+ switch (s) {
1524
+ case "coordsys":
1525
+ return o("Jogging.Orientation.coordsys");
1526
+ case "tool":
1527
+ return o("Jogging.Orientation.tool");
1528
+ default:
1529
+ return s;
1530
+ }
1531
+ }
1532
+ return e.showCoordSystemSelect && n.push(
1533
+ /* @__PURE__ */ r(
1534
+ X,
1535
+ {
1536
+ labelId: `jogging-coord-select-${i}`,
1537
+ labelValue: o("Jogging.CoordinateSystem.hlb"),
1538
+ value: e.selectedCoordSystemId,
1539
+ size: "small",
1540
+ variant: "filled",
1541
+ displayEmpty: !0,
1542
+ onChange: (s) => e.setSelectedCoordSystemId(s.target.value),
1543
+ children: e.coordSystems.map((s) => /* @__PURE__ */ r(B, { value: s.coordinate_system, children: s.name && e.coordSystemCountByName[s.name] > 1 ? `${s.name} / ${s.coordinate_system}` : s.name || s.coordinate_system }, s.coordinate_system))
1544
+ },
1545
+ "coord"
1546
+ )
1547
+ ), e.showTcpSelect && n.push(
1548
+ /* @__PURE__ */ r(
1549
+ X,
1550
+ {
1551
+ labelId: `jogging-tcp-select-${i}`,
1552
+ labelValue: "TCP",
1553
+ value: e.selectedTcpId,
1554
+ size: "small",
1555
+ variant: "filled",
1556
+ displayEmpty: e.tcpChangeInProgress,
1557
+ onChange: (s) => {
1558
+ e.requestTcpChange(s.target.value).catch((h) => {
1559
+ console.error("Failed to change TCP:", h);
1560
+ });
1561
+ },
1562
+ disabled: e.tcpChangeInProgress,
1563
+ endAdornment: e.tcpChangeInProgress ? /* @__PURE__ */ r(oe, { position: "end", children: /* @__PURE__ */ r(_t, { size: 16 }) }) : void 0,
1564
+ children: e.tcps.map((s) => /* @__PURE__ */ r(B, { value: s.id, children: s.id }, s.id))
1565
+ },
1566
+ "tcp"
1567
+ )
1568
+ ), e.showOrientationSelect && n.push(
1569
+ /* @__PURE__ */ r(
1570
+ X,
1571
+ {
1572
+ labelValue: o("Jogging.Cartesian.Orientation.lb"),
1573
+ labelId: `orientation-select-${i}`,
1574
+ value: e.selectedOrientation,
1575
+ onChange: (s) => e.setSelectedOrientation(s.target.value),
1576
+ children: Ae.map((s) => /* @__PURE__ */ r(B, { value: s, children: a(s) }, s))
1577
+ },
1578
+ "orientation"
1579
+ )
1580
+ ), e.showIncrementSelect && n.push(
1581
+ /* @__PURE__ */ b(
1582
+ X,
1583
+ {
1584
+ labelValue: o("Jogging.Increment.hlb"),
1585
+ labelId: `jogging-increment-select-${i}`,
1586
+ size: "small",
1587
+ variant: "filled",
1588
+ value: ((l = e.activeDiscreteIncrement) == null ? void 0 : l.id) || "continuous",
1589
+ onChange: (s) => e.setSelectedIncrementId(
1590
+ s.target.value
1591
+ ),
1592
+ children: [
1593
+ /* @__PURE__ */ r(B, { value: "continuous", children: o("Jogging.Increment.Continuous.dd") }, "continuous"),
1594
+ e.selectedOrientation === "tool" ? null : e.discreteIncrementOptions.map((s) => /* @__PURE__ */ r(B, { value: s.id, children: t ? `${s.degrees}°` : `${s.mm}mm` }, s.id))
1595
+ ]
1596
+ },
1597
+ "increment"
1598
+ )
1599
+ ), /* @__PURE__ */ r(
1600
+ V,
1601
+ {
1602
+ component: "div",
1603
+ "data-testid": "jogging-options",
1604
+ "aria-label": "jogging-options",
1605
+ sx: {
1606
+ display: "grid",
1607
+ gap: "16px",
1608
+ gridTemplateColumns: "1fr 1fr",
1609
+ gridAutoRows: "min-content",
1610
+ "& label": { opacity: 0.7, fontSize: "12px", marginBottom: "4px" }
1611
+ },
1612
+ children: n.map((s, h) => /* @__PURE__ */ r(
1613
+ V,
1614
+ {
1615
+ sx: {
1616
+ gridColumn: n.length % 2 === 1 && h === n.length - 1 ? "span 2" : "auto"
1617
+ },
1618
+ children: s
1619
+ },
1620
+ h
1621
+ ))
1622
+ }
1623
+ );
1624
+ }
1625
+ ), Le = kt(se)(({ theme: e }) => {
1626
+ var t;
1627
+ return {
1628
+ "&.MuiToggleButtonGroup-root": {
1629
+ background: (t = e.palette.backgroundPaperElevation) == null ? void 0 : t[8],
1630
+ borderRadius: "8px",
1631
+ padding: "4px",
1632
+ gap: "4px",
1633
+ button: {
1634
+ border: "none",
1635
+ borderRadius: "4px",
1636
+ flex: "1 1 0px",
1637
+ minWidth: 0,
1638
+ "&.MuiToggleButtonGroup-firstButton": {
1639
+ borderRadius: "8px 4px 4px 8px"
1640
+ },
1641
+ "&.MuiToggleButtonGroup-lastButton": {
1642
+ borderRadius: "4px 8px 8px 4px"
1643
+ }
1644
+ }
1645
+ }
1646
+ };
1647
+ }), $e = Y(
1648
+ k((e) => {
1649
+ const { store: t } = e, { t: o } = D();
1650
+ function i(n, a) {
1651
+ a === e.velocity || !le(a) || e.onVelocityChange(a, e.useDegree);
1652
+ }
1653
+ return /* @__PURE__ */ b(
1654
+ w,
1655
+ {
1656
+ direction: "row",
1657
+ gap: 2,
1658
+ alignItems: "center",
1659
+ "data-testid": "velocity-slider",
1660
+ "aria-label": "velocity-slider",
1661
+ children: [
1662
+ t.showVelocityLegend && /* @__PURE__ */ r(
1663
+ j,
1664
+ {
1665
+ sx: {
1666
+ color: qt,
1667
+ fontSize: "14px"
1668
+ },
1669
+ children: o("Jogging.Velocity.bt")
1670
+ }
1671
+ ),
1672
+ /* @__PURE__ */ r(
1673
+ Et,
1674
+ {
1675
+ value: e.velocity,
1676
+ color: "secondary",
1677
+ onChange: i,
1678
+ min: e.min,
1679
+ max: e.max,
1680
+ "aria-labelledby": "input-slider",
1681
+ disabled: e.disabled,
1682
+ sx: {
1683
+ "& .MuiSlider-valueLabelOpen": {
1684
+ zIndex: 100,
1685
+ backgroundColor: "transparent",
1686
+ top: "0px"
1687
+ }
1688
+ }
1689
+ }
1690
+ ),
1691
+ t.showVelocitySliderLabel && (e.renderValue ? e.renderValue(e.velocity) : /* @__PURE__ */ r(Ot, { value: e.velocity.toString() }))
1692
+ ]
1693
+ }
1694
+ );
1695
+ })
1696
+ );
1697
+ function Ot({ value: e, sx: t }) {
1698
+ var i;
1699
+ const o = z();
1700
+ return /* @__PURE__ */ r(
1701
+ w,
1702
+ {
1703
+ direction: "row",
1704
+ justifyContent: "center",
1705
+ alignItems: "center",
1706
+ gap: "5px",
1707
+ sx: {
1708
+ padding: "6px 12px",
1709
+ background: (i = o.palette.backgroundPaperElevation) == null ? void 0 : i[8],
1710
+ borderRadius: "10px",
1711
+ minWidth: "111px",
1712
+ ...t
1713
+ },
1714
+ children: /* @__PURE__ */ r(
1715
+ j,
1716
+ {
1717
+ component: "span",
1718
+ sx: {
1719
+ textAlign: "right",
1720
+ fontSize: "14px",
1721
+ opacity: 0.8,
1722
+ color: o.palette.text.primary,
1723
+ whiteSpace: "nowrap"
1724
+ },
1725
+ children: e
1726
+ }
1727
+ )
1728
+ }
1729
+ );
1730
+ }
1731
+ const Pt = k(
1732
+ ({ store: e, useDegree: t }) => {
1733
+ const { t: o } = D();
1734
+ function i(n, a) {
1735
+ return a ? `ω = ${o("Jogging.Cartesian.Rotation.velocityDegPerSec.lb", { amount: n })}` : `v = ${o("Jogging.Cartesian.Translation.velocityMmPerSec.lb", { amount: n })}`;
1736
+ }
1737
+ return /* @__PURE__ */ r(
1738
+ $e,
1739
+ {
1740
+ store: e,
1741
+ velocity: e.velocityInDisplayUnits(t),
1742
+ min: e.minVelocityInDisplayUnits(t),
1743
+ max: e.maxVelocityInDisplayUnits(t),
1744
+ onVelocityChange: e.setVelocityFromSlider,
1745
+ useDegree: t,
1746
+ disabled: e.isLocked,
1747
+ renderValue: (n) => /* @__PURE__ */ r(
1748
+ Ot,
1749
+ {
1750
+ value: i(n, t),
1751
+ sx: {
1752
+ minWidth: "111px",
1753
+ span: {
1754
+ transform: "translateY(-1.5px)"
1755
+ }
1756
+ }
1757
+ }
1758
+ )
1759
+ }
1760
+ );
1761
+ }
1762
+ ), Dt = k(({ store: e }) => {
1763
+ var n, a, l;
1764
+ const { t } = D(), o = z(), i = ((l = (a = (n = e.jogger.motionStream.rapidlyChangingMotionState.execute) == null ? void 0 : n.details) == null ? void 0 : a.state) == null ? void 0 : l.kind) ?? "KIND_UNKNOWN";
1765
+ return /* @__PURE__ */ b(
1766
+ V,
1767
+ {
1768
+ sx: {
1769
+ display: "flex",
1770
+ flexDirection: "row",
1771
+ justifyContent: "space-between",
1772
+ color: o.palette.text.primary
1773
+ },
1774
+ children: [
1775
+ /* @__PURE__ */ r(
1776
+ j,
1777
+ {
1778
+ variant: "body2",
1779
+ sx: {
1780
+ fontSize: "0.75rem",
1781
+ // Smaller than body2
1782
+ lineHeight: 1.2
1783
+ },
1784
+ children: t("Jogging.StreamStateSection.lb")
1785
+ }
1786
+ ),
1787
+ /* @__PURE__ */ r(
1788
+ j,
1789
+ {
1790
+ variant: "body2",
1791
+ sx: {
1792
+ fontSize: "0.75rem",
1793
+ // Smaller than body2
1794
+ lineHeight: 1.2
1795
+ },
1796
+ "data-testid": i,
1797
+ children: t(`Jogging.StreamStateSection.${i}.lb`)
1798
+ }
1799
+ )
1800
+ ]
1801
+ }
1802
+ );
1803
+ }), Be = k(
1804
+ ({
1805
+ store: e,
1806
+ children: t
1807
+ }) => {
1808
+ const { t: o } = D(), i = z(), n = it(0);
1809
+ function a(g, c) {
1810
+ (c === "translate" || c === "rotate") && e.setSelectedCartesianMotionType(c);
1811
+ }
1812
+ async function l(g, c) {
1813
+ const f = await e.activate(), y = f.motionStream.rapidlyChangingMotionState.tcp_pose, u = f.motionStream.rapidlyChangingMotionState.joint_position;
1814
+ y && await e.withMotionLock(async () => {
1815
+ try {
1816
+ e.setCurrentIncrementJog({
1817
+ axis: g.axis,
1818
+ direction: g.direction
1819
+ }), await e.jogger.runIncrementalCartesianMotion({
1820
+ currentTcpPose: y,
1821
+ currentJoints: u,
1822
+ coordSystemId: e.activeCoordSystemId,
1823
+ velocityInRelevantUnits: e.selectedCartesianMotionType === "translate" ? e.translationVelocityMmPerSec : e.rotationVelocityRadsPerSec,
1824
+ axis: g.axis,
1825
+ direction: g.direction,
1826
+ motion: e.selectedCartesianMotionType === "translate" ? {
1827
+ type: "translate",
1828
+ distanceMm: c.mm
1829
+ } : {
1830
+ type: "rotate",
1831
+ distanceRads: Ht(c.degrees)
1832
+ }
1833
+ });
1834
+ } finally {
1835
+ e.setCurrentIncrementJog(null), await e.deactivate();
1836
+ }
1837
+ });
1838
+ }
1839
+ async function s(g) {
1840
+ if (e.isLocked) return;
1841
+ const c = ++n.current;
1842
+ try {
1843
+ if (await e.activate(), c !== n.current) return;
1844
+ if (e.activeDiscreteIncrement)
1845
+ return await l(
1846
+ g,
1847
+ e.activeDiscreteIncrement
1848
+ );
1849
+ g.motionType === "translate" ? await e.jogger.translateTCP({
1850
+ axis: g.axis,
1851
+ direction: g.direction,
1852
+ velocityMmPerSec: e.translationVelocityMmPerSec
1853
+ }) : await e.jogger.rotateTCP({
1854
+ axis: g.axis,
1855
+ direction: g.direction,
1856
+ velocityRadsPerSec: e.rotationVelocityRadsPerSec
1857
+ });
1858
+ } catch (f) {
1859
+ console.error("Jogging failed:", f);
1860
+ }
1861
+ }
1862
+ async function h() {
1863
+ e.isLocked || e.activeDiscreteIncrement || (n.current++, await e.deactivate());
1864
+ }
1865
+ const d = [
1866
+ {
1867
+ id: "x",
1868
+ icon: /* @__PURE__ */ r(_e, {}),
1869
+ colors: rt.X
1870
+ },
1871
+ {
1872
+ id: "y",
1873
+ icon: /* @__PURE__ */ r(Ee, {}),
1874
+ colors: rt.Y
1875
+ },
1876
+ {
1877
+ id: "z",
1878
+ icon: /* @__PURE__ */ r(Je, {}),
1879
+ colors: rt.Z
1880
+ }
1881
+ ];
1882
+ function p(g) {
1883
+ return o("General.mm.variable", { amount: g.toFixed(1) });
1884
+ }
1885
+ function m(g) {
1886
+ return o("General.degree.variable", {
1887
+ amount: jt(g).toFixed(1)
1888
+ });
1889
+ }
1890
+ return /* @__PURE__ */ b(
1891
+ w,
1892
+ {
1893
+ "data-testid": "jogging-cartesian-tab",
1894
+ "aria-label": "jogging-cartesian-tab",
1895
+ flexGrow: 1,
1896
+ gap: 2,
1897
+ sx: { padding: "18px 24px" },
1898
+ children: [
1899
+ /* @__PURE__ */ b(w, { gap: 2, children: [
1900
+ /* @__PURE__ */ r(
1901
+ Ve,
1902
+ {
1903
+ store: e,
1904
+ useDegree: e.selectedCartesianMotionType === "rotate"
1905
+ }
1906
+ ),
1907
+ /* @__PURE__ */ r(
1908
+ Pt,
1909
+ {
1910
+ store: e,
1911
+ useDegree: e.selectedCartesianMotionType === "rotate"
1912
+ }
1913
+ ),
1914
+ /* @__PURE__ */ r(F, {})
1915
+ ] }),
1916
+ /* @__PURE__ */ r(
1917
+ w,
1918
+ {
1919
+ marginLeft: "auto",
1920
+ marginRight: "auto",
1921
+ gap: "24px",
1922
+ justifyContent: "center",
1923
+ sx: { flexGrow: "1" },
1924
+ children: /* @__PURE__ */ b(
1925
+ w,
1926
+ {
1927
+ alignItems: "center",
1928
+ justifyContent: "center",
1929
+ gap: "24px",
1930
+ sx: { flexGrow: 1 },
1931
+ children: [
1932
+ /* @__PURE__ */ b(
1933
+ Le,
1934
+ {
1935
+ value: e.selectedCartesianMotionType,
1936
+ onChange: a,
1937
+ exclusive: !0,
1938
+ "aria-label": o("Jogging.Cartesian.MotionType.lb"),
1939
+ sx: { justifyContent: "center" },
1940
+ children: [
1941
+ /* @__PURE__ */ r(yt, { value: "translate", children: o("Jogging.Cartesian.Translation.bt") }),
1942
+ /* @__PURE__ */ r(yt, { value: "rotate", children: o("Jogging.Cartesian.Rotation.bt") })
1943
+ ]
1944
+ }
1945
+ ),
1946
+ e.selectedCartesianMotionType === "translate" && d.map((g) => {
1947
+ var c, f;
1948
+ return /* @__PURE__ */ r(
1949
+ vt,
1950
+ {
1951
+ "data-testid": `jogging-cartesian-axis-control-${g.id}`,
1952
+ "aria-label": `jogging-cartesian-axis-control-${g.id}`,
1953
+ colors: g.colors,
1954
+ disabled: e.isLocked,
1955
+ activeJoggingDirection: ((c = e.incrementJogInProgress) == null ? void 0 : c.axis) === g.id ? e.incrementJogInProgress.direction : void 0,
1956
+ label: /* @__PURE__ */ b(tt, { children: [
1957
+ g.icon,
1958
+ /* @__PURE__ */ r(
1959
+ j,
1960
+ {
1961
+ sx: {
1962
+ fontSize: "24px",
1963
+ color: ((f = g.colors) == null ? void 0 : f.labelColor) ?? i.palette.text.primary
1964
+ },
1965
+ children: g.id.toUpperCase()
1966
+ }
1967
+ )
1968
+ ] }),
1969
+ getDisplayedValue: () => {
1970
+ var y, u;
1971
+ return p(
1972
+ ((u = (y = e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose) == null ? void 0 : y.position) == null ? void 0 : u[W[g.id]]) || 0
1973
+ );
1974
+ },
1975
+ startJogging: (y) => s({
1976
+ axis: g.id,
1977
+ motionType: "translate",
1978
+ direction: y
1979
+ }),
1980
+ stopJogging: h
1981
+ },
1982
+ g.id
1983
+ );
1984
+ }),
1985
+ e.selectedCartesianMotionType === "rotate" && d.map((g) => {
1986
+ var c, f;
1987
+ return /* @__PURE__ */ r(
1988
+ vt,
1989
+ {
1990
+ "data-testid": `jogging-cartesian-axis-control-${g.id}`,
1991
+ "aria-label": `jogging-cartesian-axis-control-${g.id}`,
1992
+ colors: g.colors,
1993
+ disabled: e.isLocked,
1994
+ activeJoggingDirection: ((c = e.incrementJogInProgress) == null ? void 0 : c.axis) === g.id ? e.incrementJogInProgress.direction : void 0,
1995
+ label: /* @__PURE__ */ b(tt, { children: [
1996
+ /* @__PURE__ */ r(Oe, {}),
1997
+ /* @__PURE__ */ r(
1998
+ j,
1999
+ {
2000
+ sx: {
2001
+ fontSize: "24px",
2002
+ color: ((f = g.colors) == null ? void 0 : f.labelColor) ?? i.palette.text.primary
2003
+ },
2004
+ children: g.id.toUpperCase()
2005
+ }
2006
+ )
2007
+ ] }),
2008
+ getDisplayedValue: () => {
2009
+ var y, u;
2010
+ return m(
2011
+ ((u = (y = e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose) == null ? void 0 : y.orientation) == null ? void 0 : u[W[g.id]]) || 0
2012
+ );
2013
+ },
2014
+ startJogging: (y) => s({
2015
+ axis: g.id,
2016
+ motionType: "rotate",
2017
+ direction: y
2018
+ }),
2019
+ stopJogging: h
2020
+ },
2021
+ g.id
2022
+ );
2023
+ })
2024
+ ]
2025
+ }
2026
+ )
2027
+ }
2028
+ ),
2029
+ /* @__PURE__ */ r(Rt, { store: e }),
2030
+ /* @__PURE__ */ r(F, {}),
2031
+ /* @__PURE__ */ r(Dt, { store: e }),
2032
+ t && /* @__PURE__ */ r(F, {}),
2033
+ t
2034
+ ]
2035
+ }
2036
+ );
2037
+ }
2038
+ ), Fe = k(
2039
+ ({ store: e, children: t }) => {
2040
+ const o = z(), i = it(0);
2041
+ async function n(l) {
2042
+ const s = ++i.current;
2043
+ try {
2044
+ if (await e.activate(), s !== i.current) return;
2045
+ await e.jogger.rotateJoints({
2046
+ joint: l.joint,
2047
+ direction: l.direction,
2048
+ velocityUnit: e.jointType === A.PrismaticJoint ? "mm/s" : "rad/s",
2049
+ velocityValue: e.jointType === A.PrismaticJoint ? e.translationVelocityMmPerSec : e.rotationVelocityRadsPerSec
2050
+ });
2051
+ } catch (h) {
2052
+ console.error("Jogging failed:", h);
2053
+ }
2054
+ }
2055
+ async function a() {
2056
+ i.current++, await e.jogger.stop(), await e.deactivate();
2057
+ }
2058
+ return /* @__PURE__ */ b(
2059
+ w,
2060
+ {
2061
+ "data-testid": "jogging-joint-tab",
2062
+ "aria-label": "jogging-joint-tab",
2063
+ flexGrow: 1,
2064
+ gap: 2,
2065
+ sx: { padding: "18px 24px" },
2066
+ children: [
2067
+ /* @__PURE__ */ r(
2068
+ Pt,
2069
+ {
2070
+ store: e,
2071
+ useDegree: e.jointType === A.RevoluteJoint
2072
+ }
2073
+ ),
2074
+ /* @__PURE__ */ r(F, {}),
2075
+ /* @__PURE__ */ r(
2076
+ w,
2077
+ {
2078
+ justifyContent: "center",
2079
+ alignItems: "stretch",
2080
+ sx: { flexGrow: "1" },
2081
+ children: /* @__PURE__ */ r(
2082
+ w,
2083
+ {
2084
+ "data-testid": "jogging-joint-value-controls-wrapper",
2085
+ "aria-label": "jogging-joint-value-controls-wrapper",
2086
+ alignItems: "center",
2087
+ gap: "24px",
2088
+ children: e.jogger.motionStream.joints.map((l) => {
2089
+ var h, d, p;
2090
+ const s = (p = (d = (h = e.motionGroupDescription.operation_limits.auto_limits) == null ? void 0 : h.joints) == null ? void 0 : d[l.index]) == null ? void 0 : p.position;
2091
+ return /* @__PURE__ */ b(
2092
+ w,
2093
+ {
2094
+ "data-testid": `jogging-joint-value-control-${l.index}`,
2095
+ "aria-label": `jogging-joint-value-control-${l.index}`,
2096
+ direction: "row",
2097
+ alignItems: "center",
2098
+ justifyContent: "center",
2099
+ spacing: 1.5,
2100
+ width: "100%",
2101
+ children: [
2102
+ e.showJointsLegend && /* @__PURE__ */ r(
2103
+ j,
2104
+ {
2105
+ color: e.isLocked ? o.palette.text.disabled : o.palette.text.secondary,
2106
+ children: `G${l.index + 1}`
2107
+ }
2108
+ ),
2109
+ /* @__PURE__ */ r(
2110
+ ve,
2111
+ {
2112
+ disabled: e.isLocked,
2113
+ lowerLimit: s == null ? void 0 : s.lower_limit,
2114
+ upperLimit: s == null ? void 0 : s.upper_limit,
2115
+ useDegree: e.jointType === A.RevoluteJoint,
2116
+ getValue: () => {
2117
+ const m = e.jogger.motionStream.rapidlyChangingMotionState.joint_position[l.index];
2118
+ return m !== void 0 ? m : void 0;
2119
+ },
2120
+ startJogging: (m) => n({
2121
+ joint: l.index,
2122
+ direction: m
2123
+ }),
2124
+ stopJogging: a
2125
+ }
2126
+ )
2127
+ ]
2128
+ },
2129
+ `joint-${l.index}`
2130
+ );
2131
+ })
2132
+ }
2133
+ )
2134
+ }
2135
+ ),
2136
+ /* @__PURE__ */ r(Rt, { store: e }),
2137
+ /* @__PURE__ */ r(F, {}),
2138
+ /* @__PURE__ */ r(Dt, { store: e }),
2139
+ t && /* @__PURE__ */ r(F, {}),
2140
+ t
2141
+ ]
2142
+ }
2143
+ );
2144
+ }
2145
+ ), Ho = Y(
2146
+ k((e) => {
2147
+ const t = Mt(() => ({
2148
+ joggingStore: null,
2149
+ loadingError: null
2150
+ }));
2151
+ return et(() => {
2152
+ let o = !1, i;
2153
+ async function n() {
2154
+ x(() => {
2155
+ t.loadingError = null, t.joggingStore = null;
2156
+ });
2157
+ try {
2158
+ let a = e.store;
2159
+ if (!a) {
2160
+ const l = await mt.open(
2161
+ e.nova,
2162
+ e.motionGroupId,
2163
+ {
2164
+ cellId: e.cellId
2165
+ }
2166
+ );
2167
+ if (o) {
2168
+ l.dispose();
2169
+ return;
2170
+ }
2171
+ try {
2172
+ a = await ut.loadFor(l);
2173
+ } catch (s) {
2174
+ throw l.dispose(), s;
2175
+ }
2176
+ if (i = a, o) {
2177
+ a.dispose();
2178
+ return;
2179
+ }
2180
+ }
2181
+ x(() => {
2182
+ t.joggingStore = a;
2183
+ }), e.onSetup && e.onSetup(a);
2184
+ } catch (a) {
2185
+ if (o) return;
2186
+ x(() => {
2187
+ t.loadingError = a;
2188
+ });
2189
+ }
2190
+ }
2191
+ return n(), () => {
2192
+ o = !0, i == null || i.dispose();
2193
+ };
2194
+ }, [e.store, e.nova, e.motionGroupId, e.cellId]), et(() => {
2195
+ const o = t.joggingStore;
2196
+ o && (e.locked ? o.lock("external") : o.unlock("external"));
2197
+ }, [t.joggingStore, e.locked]), /* @__PURE__ */ r(
2198
+ w,
2199
+ {
2200
+ "data-testid": "jogging-panel",
2201
+ "aria-label": "jogging-panel",
2202
+ sx: {
2203
+ maxWidth: "460px",
2204
+ minWidth: "320px",
2205
+ position: "relative",
2206
+ ...e.sx
2207
+ },
2208
+ children: t.joggingStore ? /* @__PURE__ */ r(Ne, { store: t.joggingStore, children: e.children }) : /* @__PURE__ */ r(we, { message: "Loading jogging", error: t.loadingError })
2209
+ }
2210
+ );
2211
+ })
2212
+ ), Ne = k(
2213
+ ({
2214
+ store: e,
2215
+ children: t
2216
+ }) => {
2217
+ const { t: o } = D();
2218
+ function i() {
2219
+ if (e.currentTab.id === "cartesian")
2220
+ return /* @__PURE__ */ r(Be, { store: e, children: t });
2221
+ if (e.currentTab.id === "joint")
2222
+ return /* @__PURE__ */ r(Fe, { store: e, children: t });
2223
+ }
2224
+ return /* @__PURE__ */ b(w, { flexGrow: 1, sx: { overflow: "hidden" }, children: [
2225
+ /* @__PURE__ */ r(
2226
+ Wt,
2227
+ {
2228
+ "data-testid": "jogging-tabs",
2229
+ "aria-label": "jogging-tabs",
2230
+ value: e.tabIndex,
2231
+ onChange: e.onTabChange,
2232
+ variant: "fullWidth",
2233
+ children: e.tabs.map((n) => {
2234
+ const a = n.label === "Cartesian" ? o("Jogging.Cartesian.bt") : o("Jogging.Joints.bt"), l = n.label === "cartesian" ? /* @__PURE__ */ r(zt, { fontSize: "small", sx: { mr: 1 } }) : /* @__PURE__ */ r(Gt, { fontSize: "small", sx: { mr: 1 } });
2235
+ return /* @__PURE__ */ r(
2236
+ Ut,
2237
+ {
2238
+ "data-testid": `jogging-tab-${n.id}`,
2239
+ "aria-label": `jogging-tab-${n.id}`,
2240
+ label: e.showTabIcons ? /* @__PURE__ */ b(w, { direction: "row", alignItems: "center", children: [
2241
+ l,
2242
+ a
2243
+ ] }) : a,
2244
+ id: `jogging-tab-${n.id}`,
2245
+ "aria-controls": `jogging-tab-${n.id}`
2246
+ },
2247
+ n.id
2248
+ );
2249
+ })
2250
+ }
2251
+ ),
2252
+ /* @__PURE__ */ r(
2253
+ w,
2254
+ {
2255
+ flexGrow: 1,
2256
+ position: "relative",
2257
+ sx: { overflowY: "auto", overflowX: "hidden" },
2258
+ children: i()
2259
+ }
2260
+ ),
2261
+ e.blocked && /* @__PURE__ */ r(Me, { store: e })
2262
+ ] });
2263
+ }
2264
+ );
2265
+ function ze() {
2266
+ const e = window.location.href;
2267
+ return e.substring(
2268
+ 0,
2269
+ e.indexOf("/", e.indexOf("//") + 2)
2270
+ );
2271
+ }
2272
+ function qo({
2273
+ baseUrl: e = ze(),
2274
+ ...t
2275
+ }) {
2276
+ return /* @__PURE__ */ b(
2277
+ he,
2278
+ {
2279
+ "aria-labelledby": "no-motion-group-modal-title",
2280
+ open: !0,
2281
+ fullWidth: !0,
2282
+ sx: {
2283
+ "& .MuiModal-backdrop": {
2284
+ backdropFilter: "blur(10px)"
2285
+ },
2286
+ "& .MuiDialog-paper": {
2287
+ "::before": {
2288
+ content: '""',
2289
+ height: "8px",
2290
+ width: "100%",
2291
+ background: "linear-gradient(90deg, #FF0E65 0%, #47D3FF 100%)"
2292
+ },
2293
+ background: "#101629"
2294
+ }
2295
+ },
2296
+ children: [
2297
+ /* @__PURE__ */ r(pe, { id: "no-motion-group-modal-title", children: "No motion group found" }),
2298
+ /* @__PURE__ */ b(
2299
+ ue,
2300
+ {
2301
+ sx: {
2302
+ marginTop: "3rem",
2303
+ marginBottom: "1.5rem",
2304
+ textAlign: "center"
2305
+ },
2306
+ children: [
2307
+ /* @__PURE__ */ r(j, { color: "#fff", children: "Found no devices to connect to." }),
2308
+ /* @__PURE__ */ r(j, { color: "#fff", children: "Please ensure a motion group has been created." })
2309
+ ]
2310
+ }
2311
+ ),
2312
+ /* @__PURE__ */ r(me, { children: /* @__PURE__ */ b(w, { width: "100%", maxWidth: "300px", margin: "auto", marginBottom: "2rem", children: [
2313
+ /* @__PURE__ */ r(
2314
+ st,
2315
+ {
2316
+ href: `${e}/settings`,
2317
+ variant: "contained",
2318
+ sx: {
2319
+ borderRadius: "8px",
2320
+ width: "100%"
2321
+ },
2322
+ children: "Go to settings app"
2323
+ }
2324
+ ),
2325
+ /* @__PURE__ */ r(
2326
+ st,
2327
+ {
2328
+ href: `${e}`,
2329
+ variant: "text",
2330
+ sx: {
2331
+ marginTop: "1rem",
2332
+ color: "#fff",
2333
+ textDecoration: "underline",
2334
+ fontSize: "0.75rem"
2335
+ },
2336
+ children: "Back to Homescreen"
2337
+ }
2338
+ )
2339
+ ] }) })
2340
+ ]
2341
+ }
2342
+ );
2343
+ }
2344
+ const wt = 1e-4, Ge = {
2345
+ a: 0,
2346
+ d: 0,
2347
+ alpha: 0,
2348
+ theta: 0,
2349
+ reverse_rotation_direction: !1
2350
+ };
2351
+ class ct {
2352
+ constructor(t, o, i, n, a, l, s, h, d, p, m = "cell") {
2353
+ this.controller = o, this.motionGroup = i, this.initialMotionState = n, this.motionStateSocket = a, this.isVirtual = l, this.tcps = s, this.description = h, this.initialControllerState = d, this.controllerStateSocket = p, this.cellId = m, this.connectedJoggingSocket = null, this.joggingVelocity = 10, this.activationState = "inactive", this.nova = H(t), this.rapidlyChangingMotionState = n, this.controllerState = d, p.addEventListener("message", (g) => {
2354
+ var f;
2355
+ const c = (f = P(g.data)) == null ? void 0 : f.result;
2356
+ c && x(() => {
2357
+ this.controllerState = c;
2358
+ });
2359
+ }), a.addEventListener("message", (g) => {
2360
+ var f;
2361
+ const c = (f = P(g.data)) == null ? void 0 : f.result;
2362
+ if (!c)
2363
+ throw new Error(
2364
+ `Failed to get motion state for ${this.motionGroupId}: ${g.data}`
2365
+ );
2366
+ Tt(
2367
+ this.rapidlyChangingMotionState.joint_position,
2368
+ c.joint_position,
2369
+ wt
2370
+ ) || x(() => {
2371
+ this.rapidlyChangingMotionState.joint_position = c.joint_position;
2372
+ }), Jt(
2373
+ this.rapidlyChangingMotionState,
2374
+ c,
2375
+ wt
2376
+ ) || x(() => {
2377
+ this.rapidlyChangingMotionState.tcp_pose = c.tcp_pose;
2378
+ }), c.tcp !== void 0 && this.rapidlyChangingMotionState.tcp !== c.tcp && x(() => {
2379
+ this.rapidlyChangingMotionState.tcp = c.tcp;
2380
+ }), this.rapidlyChangingMotionState.standstill !== c.standstill && x(() => {
2381
+ this.rapidlyChangingMotionState.standstill = c.standstill;
2382
+ });
2383
+ }), dt(this);
2384
+ }
2385
+ static async connectMultiple(t, o, i = {}) {
2386
+ const n = H(t), a = i.cellId ?? at(t);
2387
+ return Promise.all(
2388
+ o.map(
2389
+ (l) => ct.connect(n, l, {
2390
+ ...i,
2391
+ cellId: a
2392
+ })
2393
+ )
2394
+ );
2395
+ }
2396
+ static async connect(t, o, i = {}) {
2397
+ var _, J;
2398
+ const n = H(t), a = i.cellId ?? at(t) ?? "cell", [l, s] = o.split("@"), h = await n.api.controller.getCurrentRobotControllerState(
2399
+ a,
2400
+ s
2401
+ ), d = h == null ? void 0 : h.motion_groups.find(
2402
+ (E) => E.motion_group === o
2403
+ );
2404
+ if (!h || !d)
2405
+ throw new Error(
2406
+ `Controller ${s} or motion group ${o} not found`
2407
+ );
2408
+ const p = n.openReconnectingWebsocket(
2409
+ `/cells/${a}/controllers/${s}/motion-groups/${o}/state-stream`
2410
+ ), m = await p.firstMessage(), g = (_ = P(m.data)) == null ? void 0 : _.result;
2411
+ if (!g)
2412
+ throw new Error(
2413
+ `Unable to parse initial motion state message ${m.data}`
2414
+ );
2415
+ console.log(
2416
+ `Connected motion state websocket to motion group ${d.motion_group}. Initial state:
2417
+ `,
2418
+ g
2419
+ );
2420
+ const f = (await n.api.controller.getRobotController(
2421
+ a,
2422
+ h.controller
2423
+ )).configuration.kind === "VirtualController", y = await n.api.motionGroup.getMotionGroupDescription(
2424
+ a,
2425
+ s,
2426
+ d.motion_group
2427
+ ), u = Object.entries(y.tcps || {}).map(
2428
+ ([E, R]) => ({
2429
+ id: E,
2430
+ readable_name: R.name,
2431
+ position: R.pose.position,
2432
+ orientation: R.pose.orientation
2433
+ })
2434
+ ), S = n.openReconnectingWebsocket(
2435
+ `/cells/${a}/controllers/${h.controller}/state-stream?response_rate=1000`
2436
+ ), I = await S.firstMessage(), M = (J = P(I.data)) == null ? void 0 : J.result;
2437
+ if (!M)
2438
+ throw new Error(
2439
+ `Unable to parse initial controller state message ${I.data}`
2440
+ );
2441
+ return console.log(
2442
+ `Connected controller state websocket to controller ${h.controller}. Initial state:
2443
+ `,
2444
+ M
2445
+ ), new ct(
2446
+ n,
2447
+ h,
2448
+ d,
2449
+ g,
2450
+ p,
2451
+ f,
2452
+ u,
2453
+ y,
2454
+ M,
2455
+ S,
2456
+ a
2457
+ );
2458
+ }
2459
+ get motionGroupId() {
2460
+ return this.motionGroup.motion_group;
2461
+ }
2462
+ get controllerId() {
2463
+ return this.controller.controller;
2464
+ }
2465
+ get modelFromController() {
2466
+ return this.description.motion_group_model;
2467
+ }
2468
+ /** Jogging velocity in radians for rotation and joint movement */
2469
+ get joggingVelocityRads() {
2470
+ return this.joggingVelocity * Math.PI / 180;
2471
+ }
2472
+ get joints() {
2473
+ return this.initialMotionState.joint_position.map((t, o) => ({
2474
+ index: o
2475
+ }));
2476
+ }
2477
+ // Please note that API v2 omits 0 values
2478
+ get dhParameters() {
2479
+ if (this.description.dh_parameters !== void 0)
2480
+ return this.description.dh_parameters.map((t) => ({
2481
+ ...Ge,
2482
+ ...t
2483
+ }));
2484
+ }
2485
+ get safetyZones() {
2486
+ return this.description.safety_zones;
2487
+ }
2488
+ /** Gets the robot mounting position offset in 3D viz coordinates */
2489
+ get mountingPosition() {
2490
+ var t, o, i;
2491
+ return this.description.mounting ? [
2492
+ (((t = this.description.mounting.position) == null ? void 0 : t[0]) || 0) / 1e3,
2493
+ (((o = this.description.mounting.position) == null ? void 0 : o[1]) || 0) / 1e3,
2494
+ (((i = this.description.mounting.position) == null ? void 0 : i[2]) || 0) / 1e3
2495
+ ] : [0, 0, 0];
2496
+ }
2497
+ /** Gets the robot mounting position rotation in 3D viz coordinates */
2498
+ get mountingQuaternion() {
2499
+ var n, a, l, s, h, d;
2500
+ const t = new St.Vector3(
2501
+ ((a = (n = this.description.mounting) == null ? void 0 : n.orientation) == null ? void 0 : a[0]) || 0,
2502
+ ((s = (l = this.description.mounting) == null ? void 0 : l.orientation) == null ? void 0 : s[1]) || 0,
2503
+ ((d = (h = this.description.mounting) == null ? void 0 : h.orientation) == null ? void 0 : d[2]) || 0
2504
+ ), o = t.length(), i = t.normalize();
2505
+ return new St.Quaternion().setFromAxisAngle(i, o);
2506
+ }
2507
+ /**
2508
+ * Whether the controller is currently in a safety state
2509
+ * corresponding to an emergency stop
2510
+ */
2511
+ get isEstopActive() {
2512
+ return [
2513
+ "SAFETY_STATE_ROBOT_EMERGENCY_STOP",
2514
+ "SAFETY_STATE_DEVICE_EMERGENCY_STOP"
2515
+ ].includes(this.controllerState.safety_state);
2516
+ }
2517
+ /**
2518
+ * Whether the controller is in a safety state
2519
+ * that may be non-functional for robot pad purposes
2520
+ */
2521
+ get isMoveableSafetyState() {
2522
+ return [
2523
+ "SAFETY_STATE_NORMAL",
2524
+ "SAFETY_STATE_REDUCED"
2525
+ ].includes(this.controllerState.safety_state);
2526
+ }
2527
+ /**
2528
+ * Whether the controller is in an operation mode that allows movement
2529
+ */
2530
+ get isMoveableOperationMode() {
2531
+ return [
2532
+ "OPERATION_MODE_AUTO",
2533
+ "OPERATION_MODE_MANUAL",
2534
+ "OPERATION_MODE_MANUAL_T1",
2535
+ "OPERATION_MODE_MANUAL_T2"
2536
+ ].includes(this.controllerState.operation_mode);
2537
+ }
2538
+ /**
2539
+ * Whether the robot is currently active and can be moved, based on the
2540
+ * safety state, operation mode and servo toggle activation state.
2541
+ */
2542
+ get canBeMoved() {
2543
+ return this.isMoveableSafetyState && this.isMoveableOperationMode && this.activationState === "active";
2544
+ }
2545
+ async deactivate() {
2546
+ if (this.activationState !== "active") {
2547
+ console.error("Tried to deactivate while already deactivating");
2548
+ return;
2549
+ }
2550
+ x(() => {
2551
+ this.activationState = "deactivating";
2552
+ });
2553
+ try {
2554
+ await this.nova.api.controller.setDefaultMode(
2555
+ this.cellId,
2556
+ this.controllerId,
2557
+ "ROBOT_SYSTEM_MODE_MONITOR"
2558
+ ), x(() => {
2559
+ this.activationState = "inactive";
2560
+ });
2561
+ } catch (t) {
2562
+ throw x(() => {
2563
+ this.activationState = "active";
2564
+ }), t;
2565
+ }
2566
+ }
2567
+ async activate() {
2568
+ if (this.activationState !== "inactive") {
2569
+ console.error("Tried to activate while already activating");
2570
+ return;
2571
+ }
2572
+ x(() => {
2573
+ this.activationState = "activating";
2574
+ });
2575
+ try {
2576
+ await this.nova.api.controller.setDefaultMode(
2577
+ this.cellId,
2578
+ this.controllerId,
2579
+ "ROBOT_SYSTEM_MODE_CONTROL"
2580
+ ), x(() => {
2581
+ this.activationState = "active";
2582
+ });
2583
+ } catch (t) {
2584
+ throw x(() => {
2585
+ this.activationState = "inactive";
2586
+ }), t;
2587
+ }
2588
+ }
2589
+ toggleActivation() {
2590
+ this.activationState === "inactive" ? this.activate() : this.activationState === "active" && this.deactivate();
2591
+ }
2592
+ dispose() {
2593
+ this.motionStateSocket.close(), this.controllerStateSocket.close(), this.connectedJoggingSocket && this.connectedJoggingSocket.close();
2594
+ }
2595
+ setJoggingVelocity(t) {
2596
+ this.joggingVelocity = t;
2597
+ }
2598
+ }
2599
+ export {
2600
+ Wo as A,
2601
+ ct as C,
2602
+ mt as J,
2603
+ we as L,
2604
+ ht as M,
2605
+ qo as N,
2606
+ $e as V,
2607
+ vt as a,
2608
+ ve as b,
2609
+ Ho as c,
2610
+ ut as d,
2611
+ Ie as e,
2612
+ Ot as f,
2613
+ Tt as j,
2614
+ xe as p,
2615
+ Jt as t,
2616
+ Ce as u
2617
+ };