@wandelbots/wandelbots-js-react-components 6.4.0-pr.feat-robot-control-panel.656.3cbb3cf → 6.4.0-pr.feat-robot-control-panel.656.64cbc22

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 (47) hide show
  1. package/README.md +3 -3
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +1 -1
  4. package/dist/3d.js +4 -4
  5. package/dist/JoggingButtons/index.cjs +1 -1
  6. package/dist/JoggingButtons/index.js +1 -1
  7. package/dist/JoggingGizmo/index.cjs +1 -1
  8. package/dist/JoggingGizmo/index.js +2 -2
  9. package/dist/JoggingJointSlider/index.cjs +1 -1
  10. package/dist/JoggingJointSlider/index.js +1 -1
  11. package/dist/RobotControlPanel/index.cjs +1 -1
  12. package/dist/RobotControlPanel/index.d.ts +1 -1
  13. package/dist/RobotControlPanel/index.js +1 -1
  14. package/dist/SafetyBar/index.cjs +1 -1
  15. package/dist/SafetyBar/index.js +1 -1
  16. package/dist/chunks/{ConnectedMotionGroup-BT0e6N-2.js → ConnectedMotionGroup-B_Mg1jSN.js} +2 -2
  17. package/dist/chunks/{ConnectedMotionGroup-D62eHEPL.cjs → ConnectedMotionGroup-CNYRk4fK.cjs} +1 -1
  18. package/dist/chunks/{JoggingButtons-Bd3AO1Z3.cjs → JoggingButtons-B341nDtX.cjs} +1 -1
  19. package/dist/chunks/{JoggingButtons-D2MdiJCa.js → JoggingButtons-DllZXh9D.js} +1 -1
  20. package/dist/chunks/{JoggingGizmo-B2e8sWhW.js → JoggingGizmo-CR-9mcYX.js} +1 -1
  21. package/dist/chunks/{JoggingGizmo-B7JRrD75.cjs → JoggingGizmo-xvCp3LCB.cjs} +1 -1
  22. package/dist/chunks/{JoggingGizmoOrientation-DDn9aNpX.cjs → JoggingGizmoOrientation-BTKo84_4.cjs} +1 -1
  23. package/dist/chunks/{JoggingGizmoOrientation-CxuMt9pY.js → JoggingGizmoOrientation-DoMYMVlT.js} +1 -1
  24. package/dist/chunks/{JoggingJointSlider-BZVhL4ls.cjs → JoggingJointSlider-D6ZF4AHZ.cjs} +1 -1
  25. package/dist/chunks/{JoggingJointSlider-pRSm7hTH.js → JoggingJointSlider-oTxF8u1r.js} +1 -1
  26. package/dist/chunks/{Robot-DTcBHpnd.cjs → Robot-BpCo1iYt.cjs} +1 -1
  27. package/dist/chunks/{Robot-CAei2Ekp.js → Robot-DS2W4y1f.js} +1 -1
  28. package/dist/chunks/RobotControlPanel-BYWjL0i2.js +923 -0
  29. package/dist/chunks/RobotControlPanel-DOCMrzoW.cjs +1 -0
  30. package/dist/chunks/{SafetyBar-9wpT47BT.js → SafetyBar-CO9JPuKQ.js} +1 -1
  31. package/dist/chunks/{SafetyBar-CiRmGiak.cjs → SafetyBar-Cy-uqTmC.cjs} +1 -1
  32. package/dist/chunks/externalizeComponent-BBWF9CMB.cjs +2 -0
  33. package/dist/chunks/{externalizeComponent-BbDa5SzK.js → externalizeComponent-DBRjUP0q.js} +40 -26
  34. package/dist/components/robotControl/HoldToMoveButton.d.ts +20 -12
  35. package/dist/components/robotControl/MoveToTab.d.ts +7 -8
  36. package/dist/components/robotControl/PoseField.d.ts +21 -0
  37. package/dist/components/robotControl/RobotControlPanel.d.ts +29 -11
  38. package/dist/components/robotControl/atPose.d.ts +8 -0
  39. package/dist/components/robotControl/useEveryFrame.d.ts +6 -0
  40. package/dist/core.cjs +1 -1
  41. package/dist/core.js +5 -5
  42. package/dist/index.cjs +1 -1
  43. package/dist/index.js +9 -9
  44. package/package.json +1 -1
  45. package/dist/chunks/RobotControlPanel-COV4Pvv2.cjs +0 -1
  46. package/dist/chunks/RobotControlPanel-hSv5MsAe.js +0 -711
  47. package/dist/chunks/externalizeComponent-Cr89LZ90.cjs +0 -2
package/README.md CHANGED
@@ -264,7 +264,7 @@ const [active, setActive] = useState<number | null>(null)
264
264
  - `disabled` turns off every control: nothing may move. `jogDisabled` turns off only the jogging of Translate, Rotate and Joint, e.g. while a trajectory moves the robot; Move to stays usable, so a move of its own does not end when the app locks jogging during it.
265
265
  - The panel keeps its tab, jog mode and step size itself. An app that keeps them in its own store (to remember them, or because its jogging depends on them) gives `tab`, `jogMode` and `increments.step`, and gets `onTabChange`, `onJogModeChange` and `increments.onStepChange`; each also works alone, to follow a choice without keeping it.
266
266
  - `joints` gives the Joint tab: the joints' values and limits (rad, or mm with `linear`), their names, the joint velocity, and `onJogStart(index, direction)` and `onJogStop`. The panel jogs one joint at a time; the turn-around of a slider brings `onJogStop` and `onJogStart` in the same event, as described for `JoggingJointSlider`. Without `joints`, there is no Joint tab.
267
- - `moveTo` gives the Move to tab. The panel keeps the typed text `(x, y, z, rx, ry, rz)` (mm, rotation vector in rad: the format RobotPad copies and pastes) and reports each change as a pose, or null, in `onTargetChange`: the app plans the move then, and gives back `planning` and an `error` (e.g. out of reach). Holding the button calls `onMoveStart(pose)`, the release `onMoveStop`: the app starts and pauses its trajectory. `getCurrentPose` fills in "Use current pose", and `frame` is the "Relative to" select. It moves with `velocity.translate`. Without `moveTo`, there is no Move to tab.
267
+ - `moveTo` gives the Move to tab. It works as RobotPad's pose field: the coordinates `(x, y, z, rx, ry, rz)` (mm, rotation vector in rad: the format RobotPad copies and pastes) show the TCP's current pose (`getCurrentPose`, read every animation frame), with Copy and Edit pose, and Move to, off until a pose is the target. Edit pose, or a click on the field, makes it editable; Save pose edit (Enter) makes the typed pose the target (`onTargetChange(pose)`): the app plans the move and loads it, and reports `state` (`"planning"`, `"planned"`, `"moving"`, `"stopping"` or `"idle"`, as RobotPad's trajectory) and an `error` (e.g. out of reach). Then Reset shows. Held for 200 ms while `"planned"`, Move to calls `onMoveStart(pose)`, the release `onMoveStop`: the app starts and pauses its trajectory; the button says Moving… and Stopping…. At the target (within 0.5 mm and 0.01 rad) it turns off; once the move no longer runs, the field shows the current pose again (`onTargetChange(null)`), as do Reset and another tab. `frame` is the "Relative to" select. It moves with `velocity.translate`. Without `moveTo`, there is no Move to tab.
268
268
 
269
269
  ```tsx
270
270
  const orientation = useRef<Quaternion | null>(null)
@@ -298,8 +298,8 @@ const orientation = useRef<Quaternion | null>(null)
298
298
  }}
299
299
  moveTo={{
300
300
  getCurrentPose: () => currentTcpPose(),
301
- onTargetChange: (pose) => planMoveTo(pose), // sets planning and error
302
- planning,
301
+ onTargetChange: (pose) => planAndLoad(pose), // or drop the plan (null)
302
+ state: trajectoryState, // "planning" | "planned" | "moving" | "stopping" | "idle"
303
303
  error,
304
304
  onMoveStart: () => startTrajectory(),
305
305
  onMoveStop: () => pauseTrajectory(),
package/dist/3d.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/Robot-DTcBHpnd.cjs"),t=require("./chunks/JoggingGizmo-B7JRrD75.cjs"),i=require("./chunks/JoggingGizmoOrientation-DDn9aNpX.cjs"),r=require("./chunks/RobotControlPanel-COV4Pvv2.cjs"),e=require("./chunks/useSmoothedMotionState-Con0E5Bx.cjs");exports.CollisionSceneRenderer=o.CollisionSceneRenderer;exports.JointLimitGizmo=o.JointLimitGizmo;exports.LinearAxis=o.LinearAxis;exports.MotionGroupVisualizer=o.MotionGroupVisualizer;exports.MotionGroupVisualizerExact=o.MotionGroupVisualizerExact;exports.PresetEnvironment=o.PresetEnvironment;exports.Robot=o.Robot;exports.SafetyZonesRenderer=o.SafetyZonesRenderer;exports.SupportedLinearAxis=o.SupportedLinearAxis;exports.SupportedLinearAxisExact=o.SupportedLinearAxisExact;exports.SupportedRobot=o.SupportedRobot;exports.SupportedRobotExact=o.SupportedRobotExact;exports.TrajectoryRenderer=o.TrajectoryRenderer;exports.defaultGetModel=o.defaultGetModel;exports.JoggingGizmo=t.JoggingGizmo;exports.JoggingGizmoOrientation=i.JoggingGizmoOrientation;exports.RobotControlPanel=r.RobotControlPanel;exports.ValueInterpolator=e.ValueInterpolator;exports.useSmoothedMotionState=e.useSmoothedMotionState;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/Robot-BpCo1iYt.cjs"),t=require("./chunks/JoggingGizmo-xvCp3LCB.cjs"),i=require("./chunks/JoggingGizmoOrientation-BTKo84_4.cjs"),r=require("./chunks/RobotControlPanel-DOCMrzoW.cjs"),e=require("./chunks/useSmoothedMotionState-Con0E5Bx.cjs");exports.CollisionSceneRenderer=o.CollisionSceneRenderer;exports.JointLimitGizmo=o.JointLimitGizmo;exports.LinearAxis=o.LinearAxis;exports.MotionGroupVisualizer=o.MotionGroupVisualizer;exports.MotionGroupVisualizerExact=o.MotionGroupVisualizerExact;exports.PresetEnvironment=o.PresetEnvironment;exports.Robot=o.Robot;exports.SafetyZonesRenderer=o.SafetyZonesRenderer;exports.SupportedLinearAxis=o.SupportedLinearAxis;exports.SupportedLinearAxisExact=o.SupportedLinearAxisExact;exports.SupportedRobot=o.SupportedRobot;exports.SupportedRobotExact=o.SupportedRobotExact;exports.TrajectoryRenderer=o.TrajectoryRenderer;exports.defaultGetModel=o.defaultGetModel;exports.JoggingGizmo=t.JoggingGizmo;exports.JoggingGizmoOrientation=i.JoggingGizmoOrientation;exports.RobotControlPanel=r.RobotControlPanel;exports.ValueInterpolator=e.ValueInterpolator;exports.useSmoothedMotionState=e.useSmoothedMotionState;
package/dist/3d.d.ts CHANGED
@@ -7,7 +7,7 @@ export { JoggingGizmo, type JoggingGizmoProps, } from "./components/jogging/gizm
7
7
  export { JoggingGizmoOrientation, type JoggingGizmoOrientationProps, } from "./components/jogging/gizmo/JoggingGizmoOrientation";
8
8
  export type { JogAxis, JogDirection, JogHandle, } from "./components/jogging/jogHandle";
9
9
  export type { JogControlsProps } from "./components/jogging/useJogControls";
10
- export { type JogMotion, RobotControlPanel, type RobotControlIncrements, type RobotControlJogMode, type RobotControlJoint, type RobotControlJoints, type RobotControlMoveTo, type RobotControlOption, type RobotControlPanelProps, type RobotControlPose, type RobotControlSelect, type RobotControlTab, type RobotControlVelocity, } from "./components/robotControl/RobotControlPanel";
10
+ export { type JogMotion, RobotControlPanel, type RobotControlIncrements, type RobotControlJogMode, type RobotControlJoint, type RobotControlJoints, type RobotControlMoveState, type RobotControlMoveTo, type RobotControlOption, type RobotControlPanelProps, type RobotControlPose, type RobotControlSelect, type RobotControlTab, type RobotControlVelocity, } from "./components/robotControl/RobotControlPanel";
11
11
  export * from "./components/robots/LinearAxis";
12
12
  export * from "./components/robots/MotionGroupVisualizer";
13
13
  export * from "./components/robots/Robot";
package/dist/3d.js CHANGED
@@ -1,7 +1,7 @@
1
- import { C as a, J as r, L as t, M as s, a as i, P as n, R as p, S as d, b as m, c as u, d as x, e as l, T as R, f as S } from "./chunks/Robot-CAei2Ekp.js";
2
- import { J as c } from "./chunks/JoggingGizmo-B2e8sWhW.js";
3
- import { J as G } from "./chunks/JoggingGizmoOrientation-CxuMt9pY.js";
4
- import { R as b } from "./chunks/RobotControlPanel-hSv5MsAe.js";
1
+ import { C as a, J as r, L as t, M as s, a as i, P as n, R as p, S as d, b as m, c as u, d as x, e as l, T as R, f as S } from "./chunks/Robot-DS2W4y1f.js";
2
+ import { J as c } from "./chunks/JoggingGizmo-CR-9mcYX.js";
3
+ import { J as G } from "./chunks/JoggingGizmoOrientation-DoMYMVlT.js";
4
+ import { R as b } from "./chunks/RobotControlPanel-BYWjL0i2.js";
5
5
  import { V as L, a as M } from "./chunks/useSmoothedMotionState-COMJRcOt.js";
6
6
  export {
7
7
  a as CollisionSceneRenderer,
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../chunks/JoggingButtons-Bd3AO1Z3.cjs");exports.JoggingButtons=t.JoggingButtons;exports.default=t.JoggingButtons;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../chunks/JoggingButtons-B341nDtX.cjs");exports.JoggingButtons=t.JoggingButtons;exports.default=t.JoggingButtons;
@@ -1,4 +1,4 @@
1
- import { J as a, J as g } from "../chunks/JoggingButtons-D2MdiJCa.js";
1
+ import { J as a, J as g } from "../chunks/JoggingButtons-DllZXh9D.js";
2
2
  export {
3
3
  a as JoggingButtons,
4
4
  g as default
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../chunks/JoggingGizmo-B7JRrD75.cjs"),o=require("../chunks/JoggingGizmoOrientation-DDn9aNpX.cjs");exports.JoggingGizmo=i.JoggingGizmo;exports.default=i.JoggingGizmo;exports.JoggingGizmoOrientation=o.JoggingGizmoOrientation;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../chunks/JoggingGizmo-xvCp3LCB.cjs"),o=require("../chunks/JoggingGizmoOrientation-BTKo84_4.cjs");exports.JoggingGizmo=i.JoggingGizmo;exports.default=i.JoggingGizmo;exports.JoggingGizmoOrientation=o.JoggingGizmoOrientation;
@@ -1,5 +1,5 @@
1
- import { J as i, J as a } from "../chunks/JoggingGizmo-B2e8sWhW.js";
2
- import { J as t } from "../chunks/JoggingGizmoOrientation-CxuMt9pY.js";
1
+ import { J as i, J as a } from "../chunks/JoggingGizmo-CR-9mcYX.js";
2
+ import { J as t } from "../chunks/JoggingGizmoOrientation-DoMYMVlT.js";
3
3
  export {
4
4
  i as JoggingGizmo,
5
5
  t as JoggingGizmoOrientation,
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/JoggingJointSlider-BZVhL4ls.cjs");exports.JoggingJointSlider=e.JoggingJointSlider;exports.default=e.JoggingJointSlider;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/JoggingJointSlider-D6ZF4AHZ.cjs");exports.JoggingJointSlider=e.JoggingJointSlider;exports.default=e.JoggingJointSlider;
@@ -1,4 +1,4 @@
1
- import { J as a, J as e } from "../chunks/JoggingJointSlider-pRSm7hTH.js";
1
+ import { J as a, J as e } from "../chunks/JoggingJointSlider-oTxF8u1r.js";
2
2
  export {
3
3
  a as JoggingJointSlider,
4
4
  e as default
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../chunks/RobotControlPanel-COV4Pvv2.cjs");exports.RobotControlPanel=o.RobotControlPanel;exports.default=o.RobotControlPanel;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../chunks/RobotControlPanel-DOCMrzoW.cjs");exports.RobotControlPanel=o.RobotControlPanel;exports.default=o.RobotControlPanel;
@@ -1,2 +1,2 @@
1
- export { type JogMotion, RobotControlPanel, RobotControlPanel as default, type RobotControlIncrements, type RobotControlJogMode, type RobotControlJoint, type RobotControlJoints, type RobotControlMoveTo, type RobotControlOption, type RobotControlPanelProps, type RobotControlPose, type RobotControlSelect, type RobotControlTab, type RobotControlVelocity, } from "../components/robotControl/RobotControlPanel";
1
+ export { type JogMotion, RobotControlPanel, RobotControlPanel as default, type RobotControlIncrements, type RobotControlJogMode, type RobotControlJoint, type RobotControlJoints, type RobotControlMoveState, type RobotControlMoveTo, type RobotControlOption, type RobotControlPanelProps, type RobotControlPose, type RobotControlSelect, type RobotControlTab, type RobotControlVelocity, } from "../components/robotControl/RobotControlPanel";
2
2
  export type { JogAxis, JogDirection, JogHandle, } from "../components/jogging/jogHandle";
@@ -1,4 +1,4 @@
1
- import { R as t, R as e } from "../chunks/RobotControlPanel-hSv5MsAe.js";
1
+ import { R as t, R as e } from "../chunks/RobotControlPanel-BYWjL0i2.js";
2
2
  export {
3
3
  t as RobotControlPanel,
4
4
  e as default
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/SafetyBar-CiRmGiak.cjs");exports.SafetyBar=e.SafetyBar;exports.default=e.SafetyBar;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/SafetyBar-Cy-uqTmC.cjs");exports.SafetyBar=e.SafetyBar;exports.default=e.SafetyBar;
@@ -1,4 +1,4 @@
1
- import { S as f, S as r } from "../chunks/SafetyBar-9wpT47BT.js";
1
+ import { S as f, S as r } from "../chunks/SafetyBar-CO9JPuKQ.js";
2
2
  export {
3
3
  f as SafetyBar,
4
4
  r as default
@@ -12,7 +12,7 @@ import { RoundedIconButton as Ft } from "@wandelbots/mui";
12
12
  import { observer as k, useLocalObservable as Mt } from "mobx-react-lite";
13
13
  import * as C from "react";
14
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-BbDa5SzK.js";
15
+ import { e as Y } from "./externalizeComponent-DBRjUP0q.js";
16
16
  import zt from "@mui/icons-material/OpenWith";
17
17
  import Gt from "@mui/icons-material/Share";
18
18
  import w from "@mui/material/Stack";
@@ -27,7 +27,7 @@ import { d as gt, c as H, e as at } from "./useSmoothedMotionState-COMJRcOt.js";
27
27
  import _t from "@mui/material/CircularProgress";
28
28
  import { capitalize as qt } from "@mui/material/utils";
29
29
  import { lowerFirst as Yt, countBy as Zt } from "lodash-es";
30
- import { m as Kt } from "./SafetyBar-9wpT47BT.js";
30
+ import { m as Kt } from "./SafetyBar-CO9JPuKQ.js";
31
31
  import Xt from "@mui/material/Alert";
32
32
  import Qt from "@mui/material/AlertTitle";
33
33
  import st from "@mui/material/Button";
@@ -1,4 +1,4 @@
1
- "use strict";const n=require("react/jsx-runtime"),Et=require("@mui/material/AppBar"),pt=require("@mui/material/Backdrop"),L=require("@mui/material/Box"),kt=require("@mui/material/Menu"),B=require("@mui/material/MenuItem"),Jt=require("@mui/material/Toolbar"),_=require("@mui/material/Typography"),Rt=require("@wandelbots/design-tokens"),Ot=require("@wandelbots/icons/ExpandMoreFilled"),Pt=require("@wandelbots/mui"),T=require("mobx-react-lite"),C=require("react"),W=require("./externalizeComponent-Cr89LZ90.cjs"),At=require("@mui/icons-material/OpenWith"),Vt=require("@mui/icons-material/Share"),v=require("@mui/material/Stack"),Dt=require("@mui/material/Tab"),Lt=require("@mui/material/Tabs"),y=require("mobx"),V=require("react-i18next"),M=require("@wandelbots/nova-js"),D=require("@wandelbots/nova-js/v2"),ot=require("three/src/math/Vector3.js"),A=require("./useSmoothedMotionState-Con0E5Bx.cjs"),ft=require("@mui/material/CircularProgress"),qt=require("@mui/material/utils"),xt=require("lodash-es"),Ft=require("./SafetyBar-CiRmGiak.cjs"),$t=require("@mui/material/Alert"),Bt=require("@mui/material/AlertTitle"),it=require("@mui/material/Button"),q=require("@mui/material/styles"),N=require("@mui/material/Divider"),gt=require("@mui/material/ToggleButton"),X=require("@mui/material/IconButton"),z=require("./joggingColors-ZDc_2UCp.cjs"),Nt=require("lodash-es/isEqual.js"),zt=require("@mui/material/InputAdornment"),Gt=require("@mui/material/FormControl"),Ut=require("@mui/material/InputLabel"),Wt=require("@mui/material/Select"),Y=require("lodash-es/keyBy.js"),Ht=require("lodash-es/uniqueId.js"),Yt=require("@mui/material/ToggleButtonGroup"),yt=require("@mui/material/Slider"),Zt=require("lodash-es/isNumber.js"),Xt=require("@mui/icons-material/ChevronLeft"),Kt=require("@mui/icons-material/ChevronRight"),Qt=require("lodash-es/throttle.js"),te=require("@mui/material/Dialog"),ee=require("@mui/material/DialogActions"),oe=require("@mui/material/DialogContent"),ie=require("@mui/material/DialogTitle"),nt=require("three");function jt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const b=jt(C),dt=jt(nt),ne=W.externalizeComponent(T.observer(e=>{const{appIcon:t,appName:o,apps:i=[],onAppSelect:r,disabled:s=!1,sx:l}=e,[a,u]=C.useState(null),g=!!a,p=c=>{u(c.currentTarget)},h=()=>{u(null)},d=c=>{h(),c.onClick?c.onClick():c.href&&(window.location.href=c.href),r==null||r(c)};return n.jsxs(n.Fragment,{children:[n.jsx(Et,{position:"static",sx:{boxShadow:"none",backgroundImage:"none","& .MuiAppBar-root":{backgroundImage:"none",backgroundColor:"transparent"},...l},children:n.jsxs(Jt,{sx:{minHeight:"62px !important"},children:[n.jsx(L,{sx:{mr:1,display:"flex",alignItems:"center"},children:t}),n.jsxs(L,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[n.jsx(_,{component:"h1",variant:"subtitle1",children:o}),i.length>0&&n.jsx(Pt.RoundedIconButton,{icon:n.jsx(Ot.ExpandMoreFilled,{size:20}),ariaLabel:"switch app","aria-controls":"app-menu","aria-haspopup":"true",onClick:p,disabled:s,sx:{ml:1}})]})]})}),n.jsx(pt,{open:g,onClick:h,sx:{backdropFilter:"blur(4px)",backgroundColor:Rt.ZeroGravityComponentsBackdropFill,zIndex:c=>c.zIndex.modal-1}}),n.jsx(kt,{id:"app-menu",anchorEl:a,open:g,onClose:h,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{zIndex:c=>c.zIndex.modal,"& .MuiPaper-root":{minWidth:200,mt:1}},children:i.map(c=>n.jsxs(B,{onClick:()=>d(c),children:[n.jsx(L,{sx:{display:"flex",alignItems:"center"},children:c.icon}),n.jsx(_,{variant:"body1",sx:{ml:2},children:c.name})]},c.id))})]})})),re=({title:e,titleId:t,...o},i)=>b.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?b.createElement("title",{id:t},e):null,b.createElement("g",{id:"JogMinus"},b.createElement("path",{id:"Minus",d:"M0 13V8H21V13H0Z",fill:"white"}))),se=C.forwardRef(re),ae=({title:e,titleId:t,...o},i)=>b.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?b.createElement("title",{id:t},e):null,b.createElement("g",{id:"JogPlus"},b.createElement("g",{id:"Plus"},b.createElement("path",{d:"M0 13V8H8V13H0Z",fill:"white"}),b.createElement("path",{d:"M8 0L13 2.18557e-07L13 21H8L8 0Z",fill:"white"}),b.createElement("path",{d:"M13 13V8H21V13H13Z",fill:"white"})))),le=C.forwardRef(ae),rt=W.externalizeComponent(T.observer(({colors:e,label:t,getDisplayedValue:o,startJogging:i,stopJogging:r,disabled:s,activeJoggingDirection:l,...a})=>{var w,E,R,k,O,F,$;A.useAnimationFrame(()=>{const J=o(),P=d.current;P&&(P.textContent=J)});const u=q.useTheme(),[g,p]=C.useState(null);C.useEffect(()=>{s&&I()},[s]);const h=l||g,d=C.useRef(null);e||(e={color:"#fff",backgroundColor:"#000",borderColor:"#000",buttonBackgroundColor:{disabled:"#000",default:"#000",hovered:"#000",pressed:"#000"},labelColor:"#000"});const c=h?(w=e.buttonBackgroundColor)==null?void 0:w.pressed:e.borderColor,f={width:"55px",color:e.color,path:{fill:e.color},alignContent:"center",fontSize:"37px",svg:{pointerEvents:"none"}},x={...f,backgroundColor:(E=e.buttonBackgroundColor)==null?void 0:E.default,":hover":{backgroundColor:(R=e.buttonBackgroundColor)==null?void 0:R.hovered},":active":{backgroundColor:(k=e.buttonBackgroundColor)==null?void 0:k.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor}},":disabled":{backgroundColor:(O=e.buttonBackgroundColor)==null?void 0:O.disabled,"svg path":{fill:u.palette.action.disabled}}},m={...f,backgroundColor:(F=e.buttonBackgroundColor)==null?void 0:F.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor},":disabled":{backgroundColor:($=e.buttonBackgroundColor)==null?void 0:$.pressed,"svg path":{fill:u.palette.action.disabled}}};function j(J,P){s||J.button===0&&(p(P),i(P))}function I(){p(null),r()}return n.jsxs(v,{height:"64px",direction:"row",justifyContent:"center",...a,children:[n.jsx(X,{disabled:s,disableRipple:!0,onPointerDown:J=>j(J,"-"),onPointerUp:I,onPointerOut:I,size:"large",sx:{...h==="-"?m:x,borderRadius:"16px 0px 0px 16px",borderLeft:`2px solid ${c??"#fff"}`,borderBottom:`2px solid ${c??"#fff"}`,borderTop:`2px solid ${c??"#fff"}`},children:n.jsx(se,{})}),n.jsxs(v,{spacing:"6px",sx:{width:"150px",backgroundColor:e.backgroundColor,alignItems:"center",justifyContent:"center",opacity:"0.9",borderBottom:`2px solid ${c??"#fff"}`,borderTop:`2px solid ${c??"#fff"}`},children:[n.jsx(v,{height:"22px",direction:"row",alignItems:"center",justifyItems:"center",spacing:1,sx:{userSelect:"none",color:e.color,".MuiTypography-root":{fontWeight:700,...s?{color:u.palette.action.disabled}:{}},...s?{"svg path":{fill:u.palette.action.disabled}}:{}},children:t}),n.jsx(_,{height:"22px",sx:{fontSize:"15px",color:s?u.palette.action.disabled:e.color,fontWeight:700,fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center"},ref:d,children:o()})]}),n.jsx(X,{disableRipple:!0,disabled:s,onPointerDown:J=>j(J,"+"),onPointerUp:I,onPointerOut:I,size:"large",sx:{...h==="+"?m:x,borderRadius:"0px 16px 16px 0px",borderRight:`2px solid ${c??"#fff"}`,borderBottom:`2px solid ${c??"#fff"}`,borderTop:`2px solid ${c??"#fff"}`},children:n.jsx(le,{})})]})})),St=W.externalizeComponent(T.observer(({startJogging:e,stopJogging:t,lowerLimit:o,upperLimit:i,useDegree:r,getValue:s,disabled:l,...a})=>{var k,O,F,$,J,P,H;const{t:u}=V.useTranslation(),[g,p]=C.useState(),h=q.useTheme(),d={background:(k=h.palette.backgroundPaperElevation)==null?void 0:k[4],color:(O=h.palette.backgroundPaperElevation)==null?void 0:O[11]},c=T.useLocalObservable(()=>({activeJoggingDir:null,startJogging(S){this.activeJoggingDir=S,e(S)},stopJogging(){this.activeJoggingDir=null,t()}})),f=Qt(()=>{const S=r?x(s()):s();(S===void 0||g===void 0||Math.abs(g-S)>1e-9)&&p(S)},50);A.useAnimationFrame(f);function x(S){if(S!==void 0)return M.radiansToDegrees(S)}function m(S){S.button===0&&c.startJogging("-")}function j(S){S.button===0&&c.startJogging("+")}function I(S){c.stopJogging()}function w(S){c.stopJogging()}function E(S,G=1){if(S===void 0||Number.isNaN(S))return"";const U=u("General.degree.variable",{amount:S.toFixed(G)});return S>0&&G===0?`+${U}`:U}function R(S,G=1){if(S===void 0||Number.isNaN(S))return"";const U=u("General.mm.variable",{amount:S.toFixed(G)});return S>0&&G===0?`+${U}`:U}return n.jsxs(v,{height:"64px",width:"100%",maxWidth:"260px",direction:"row",...a,sx:{"& .MuiIconButton-root":{width:"52px",color:h.palette.text.primary,alignContent:"center",backgroundColor:(F=h.palette.backgroundPaperElevation)==null?void 0:F[11],"& svg":{width:"42px",height:"42px"},"&.Mui-disabled":{backgroundColor:($=h.palette.backgroundPaperElevation)==null?void 0:$[11],color:h.palette.action.disabled,opacity:1},"&:hover":{backgroundColor:(J=h.palette.backgroundPaperElevation)==null?void 0:J[9]},"&:active":{...d}}},children:[n.jsx(X,{onPointerDown:m,onPointerUp:I,onPointerOut:w,disabled:l,disableRipple:!0,sx:{borderRadius:"16px 0px 0px 16px",...c.activeJoggingDir==="-"?d:{}},children:n.jsx(Xt,{sx:{pointerEvents:"none",color:z.jointArrowColor}})}),n.jsxs(v,{flexGrow:1,alignItems:"center",justifyContent:"center",sx:{borderStyle:"solid",borderLeftWidth:0,borderRightWidth:0,border:"none",backgroundColor:(P=h.palette.backgroundPaperElevation)==null?void 0:P[11],paddingLeft:"20px",paddingRight:"20px",zIndex:1},children:[n.jsx(_,{sx:{fontSize:"15px",fontWeight:700,position:"relative",top:"5px",fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center",color:l?h.palette.action.disabled:h.palette.text.primary},children:r?E(g):R(g)}),n.jsx(yt,{disabled:!0,"aria-label":"Joint position",min:r?x(o):o,max:r?x(i):i,value:g||0,track:!1,sx:{"& .MuiSlider-mark":{display:"none"},"& .MuiSlider-thumb":{width:"5px",height:"12px",borderRadius:"2px",color:l?h.palette.action.disabled:h.palette.text.primary},"& .MuiSlider-markLabel":{top:"20px",fontSize:"12px",color:l?h.palette.action.disabled:h.palette.text.secondary},"& .MuiSlider-rail":{backgroundColor:(H=h.palette.backgroundPaperElevation)==null?void 0:H[5],opacity:1}},marks:o!==void 0&&i!==void 0&&[{value:r?x(o):o,label:r?E(x(o),0):R(o)},{value:r?x(i):i,label:r?E(x(i),0):R(i)}]})]}),n.jsx(X,{onPointerDown:j,onPointerUp:I,onPointerOut:w,disabled:l,disableRipple:!0,sx:{borderRadius:"0px 16px 16px 0px",...c.activeJoggingDir==="+"?d:{}},children:n.jsx(Kt,{sx:{pointerEvents:"none",color:z.jointArrowColor}})})]})}));function at(e,t,o){if(t.length!==e.length)return!0;for(let i=0;i<t.length;i++)if(Math.abs(t[i]-e[i])>o)return!1;return!0}function bt(e,t,o){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)return!1;if(e===void 0||t===void 0)return!0;let i=0;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}function lt(e,t,o){return e.coordinate_system===t.coordinate_system&&e.tcp===t.tcp&&bt(e.tcp_pose,t.tcp_pose,o)}function vt(e,t){const o=new nt.Vector3(t[0],t[1],t[2]),i=new nt.Vector3(e[0],e[1],e[2]),r=o.length(),s=o.normalize();let l=i.length(),a=i.normalize();a.dot(s)<0&&(l=-l,a=a.multiplyScalar(-1));let u=l-r;return u-=2*Math.PI*Math.floor((u+Math.PI)/(2*Math.PI)),l=r+u,[...a.multiplyScalar(l)]}const ut=1e-4;class Q{constructor(t,o,i,r,s,l,a="cell"){this.controller=o,this.motionGroup=i,this.description=r,this.initialMotionState=s,this.motionStateSocket=l,this.cellId=a,this.nova=A.createNovaClient(t),this.rapidlyChangingMotionState=s,l.addEventListener("message",u=>{var d;const g=(d=M.tryParseJson(u.data))==null?void 0:d.result;if(!g)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${u.data}`);at(this.rapidlyChangingMotionState.joint_position,g.joint_position,ut)||y.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=g.joint_position}),lt(this.rapidlyChangingMotionState,g,ut)||y.runInAction(()=>{var c,f,x;this.rapidlyChangingMotionState.tcp_pose==null?this.rapidlyChangingMotionState.tcp_pose=g.tcp_pose:(c=g.tcp_pose)!=null&&c.orientation&&((f=g.tcp_pose)!=null&&f.position)&&((x=this.rapidlyChangingMotionState.tcp_pose)!=null&&x.orientation)?this.rapidlyChangingMotionState.tcp_pose={position:g.tcp_pose.position,orientation:vt(g.tcp_pose.orientation,this.rapidlyChangingMotionState.tcp_pose.orientation)}:console.warn("Received incomplete tcp_pose, ignoring",g.tcp_pose)}),g.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==g.tcp&&y.runInAction(()=>{this.rapidlyChangingMotionState.tcp=g.tcp}),this.rapidlyChangingMotionState.standstill!==g.standstill&&y.runInAction(()=>{this.rapidlyChangingMotionState.standstill=g.standstill});const p=this.rapidlyChangingMotionState.joint_limit_reached.limit_reached,h=g.joint_limit_reached.limit_reached;p.some((c,f)=>c!==h[f])&&y.runInAction(()=>{this.rapidlyChangingMotionState.joint_limit_reached=g.joint_limit_reached}),this.rapidlyChangingMotionState.execute!==g.execute&&y.runInAction(()=>{this.rapidlyChangingMotionState.execute=g.execute})}),y.makeAutoObservable(this)}static async open(t,o,i={}){var f;const r=A.createNovaClient(t),s=i.cellId??A.cellIdOf(t)??"cell",[l,a]=o.split("@"),u=await r.api.controller.getCurrentRobotControllerState(s,a),g=u==null?void 0:u.motion_groups.find(x=>x.motion_group===o);if(!u||!g)throw new Error(`Controller ${a} or motion group ${o} not found`);const p=r.openReconnectingWebsocket(`/cells/${s}/controllers/${a}/motion-groups/${o}/state-stream`),h=await p.firstMessage(),d=(f=M.tryParseJson(h.data))==null?void 0:f.result;if(!d)throw new Error(`Unable to parse initial motion state message ${h.data}`);console.log(`Connected motion state websocket to motion group ${g.motion_group}. Initial state:
1
+ "use strict";const n=require("react/jsx-runtime"),Et=require("@mui/material/AppBar"),pt=require("@mui/material/Backdrop"),L=require("@mui/material/Box"),kt=require("@mui/material/Menu"),B=require("@mui/material/MenuItem"),Jt=require("@mui/material/Toolbar"),_=require("@mui/material/Typography"),Rt=require("@wandelbots/design-tokens"),Ot=require("@wandelbots/icons/ExpandMoreFilled"),Pt=require("@wandelbots/mui"),T=require("mobx-react-lite"),C=require("react"),W=require("./externalizeComponent-BBWF9CMB.cjs"),At=require("@mui/icons-material/OpenWith"),Vt=require("@mui/icons-material/Share"),v=require("@mui/material/Stack"),Dt=require("@mui/material/Tab"),Lt=require("@mui/material/Tabs"),y=require("mobx"),V=require("react-i18next"),M=require("@wandelbots/nova-js"),D=require("@wandelbots/nova-js/v2"),ot=require("three/src/math/Vector3.js"),A=require("./useSmoothedMotionState-Con0E5Bx.cjs"),ft=require("@mui/material/CircularProgress"),qt=require("@mui/material/utils"),xt=require("lodash-es"),Ft=require("./SafetyBar-Cy-uqTmC.cjs"),$t=require("@mui/material/Alert"),Bt=require("@mui/material/AlertTitle"),it=require("@mui/material/Button"),q=require("@mui/material/styles"),N=require("@mui/material/Divider"),gt=require("@mui/material/ToggleButton"),X=require("@mui/material/IconButton"),z=require("./joggingColors-ZDc_2UCp.cjs"),Nt=require("lodash-es/isEqual.js"),zt=require("@mui/material/InputAdornment"),Gt=require("@mui/material/FormControl"),Ut=require("@mui/material/InputLabel"),Wt=require("@mui/material/Select"),Y=require("lodash-es/keyBy.js"),Ht=require("lodash-es/uniqueId.js"),Yt=require("@mui/material/ToggleButtonGroup"),yt=require("@mui/material/Slider"),Zt=require("lodash-es/isNumber.js"),Xt=require("@mui/icons-material/ChevronLeft"),Kt=require("@mui/icons-material/ChevronRight"),Qt=require("lodash-es/throttle.js"),te=require("@mui/material/Dialog"),ee=require("@mui/material/DialogActions"),oe=require("@mui/material/DialogContent"),ie=require("@mui/material/DialogTitle"),nt=require("three");function jt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const b=jt(C),dt=jt(nt),ne=W.externalizeComponent(T.observer(e=>{const{appIcon:t,appName:o,apps:i=[],onAppSelect:r,disabled:s=!1,sx:l}=e,[a,u]=C.useState(null),g=!!a,p=c=>{u(c.currentTarget)},h=()=>{u(null)},d=c=>{h(),c.onClick?c.onClick():c.href&&(window.location.href=c.href),r==null||r(c)};return n.jsxs(n.Fragment,{children:[n.jsx(Et,{position:"static",sx:{boxShadow:"none",backgroundImage:"none","& .MuiAppBar-root":{backgroundImage:"none",backgroundColor:"transparent"},...l},children:n.jsxs(Jt,{sx:{minHeight:"62px !important"},children:[n.jsx(L,{sx:{mr:1,display:"flex",alignItems:"center"},children:t}),n.jsxs(L,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[n.jsx(_,{component:"h1",variant:"subtitle1",children:o}),i.length>0&&n.jsx(Pt.RoundedIconButton,{icon:n.jsx(Ot.ExpandMoreFilled,{size:20}),ariaLabel:"switch app","aria-controls":"app-menu","aria-haspopup":"true",onClick:p,disabled:s,sx:{ml:1}})]})]})}),n.jsx(pt,{open:g,onClick:h,sx:{backdropFilter:"blur(4px)",backgroundColor:Rt.ZeroGravityComponentsBackdropFill,zIndex:c=>c.zIndex.modal-1}}),n.jsx(kt,{id:"app-menu",anchorEl:a,open:g,onClose:h,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{zIndex:c=>c.zIndex.modal,"& .MuiPaper-root":{minWidth:200,mt:1}},children:i.map(c=>n.jsxs(B,{onClick:()=>d(c),children:[n.jsx(L,{sx:{display:"flex",alignItems:"center"},children:c.icon}),n.jsx(_,{variant:"body1",sx:{ml:2},children:c.name})]},c.id))})]})})),re=({title:e,titleId:t,...o},i)=>b.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?b.createElement("title",{id:t},e):null,b.createElement("g",{id:"JogMinus"},b.createElement("path",{id:"Minus",d:"M0 13V8H21V13H0Z",fill:"white"}))),se=C.forwardRef(re),ae=({title:e,titleId:t,...o},i)=>b.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?b.createElement("title",{id:t},e):null,b.createElement("g",{id:"JogPlus"},b.createElement("g",{id:"Plus"},b.createElement("path",{d:"M0 13V8H8V13H0Z",fill:"white"}),b.createElement("path",{d:"M8 0L13 2.18557e-07L13 21H8L8 0Z",fill:"white"}),b.createElement("path",{d:"M13 13V8H21V13H13Z",fill:"white"})))),le=C.forwardRef(ae),rt=W.externalizeComponent(T.observer(({colors:e,label:t,getDisplayedValue:o,startJogging:i,stopJogging:r,disabled:s,activeJoggingDirection:l,...a})=>{var w,E,R,k,O,F,$;A.useAnimationFrame(()=>{const J=o(),P=d.current;P&&(P.textContent=J)});const u=q.useTheme(),[g,p]=C.useState(null);C.useEffect(()=>{s&&I()},[s]);const h=l||g,d=C.useRef(null);e||(e={color:"#fff",backgroundColor:"#000",borderColor:"#000",buttonBackgroundColor:{disabled:"#000",default:"#000",hovered:"#000",pressed:"#000"},labelColor:"#000"});const c=h?(w=e.buttonBackgroundColor)==null?void 0:w.pressed:e.borderColor,f={width:"55px",color:e.color,path:{fill:e.color},alignContent:"center",fontSize:"37px",svg:{pointerEvents:"none"}},x={...f,backgroundColor:(E=e.buttonBackgroundColor)==null?void 0:E.default,":hover":{backgroundColor:(R=e.buttonBackgroundColor)==null?void 0:R.hovered},":active":{backgroundColor:(k=e.buttonBackgroundColor)==null?void 0:k.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor}},":disabled":{backgroundColor:(O=e.buttonBackgroundColor)==null?void 0:O.disabled,"svg path":{fill:u.palette.action.disabled}}},m={...f,backgroundColor:(F=e.buttonBackgroundColor)==null?void 0:F.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor},":disabled":{backgroundColor:($=e.buttonBackgroundColor)==null?void 0:$.pressed,"svg path":{fill:u.palette.action.disabled}}};function j(J,P){s||J.button===0&&(p(P),i(P))}function I(){p(null),r()}return n.jsxs(v,{height:"64px",direction:"row",justifyContent:"center",...a,children:[n.jsx(X,{disabled:s,disableRipple:!0,onPointerDown:J=>j(J,"-"),onPointerUp:I,onPointerOut:I,size:"large",sx:{...h==="-"?m:x,borderRadius:"16px 0px 0px 16px",borderLeft:`2px solid ${c??"#fff"}`,borderBottom:`2px solid ${c??"#fff"}`,borderTop:`2px solid ${c??"#fff"}`},children:n.jsx(se,{})}),n.jsxs(v,{spacing:"6px",sx:{width:"150px",backgroundColor:e.backgroundColor,alignItems:"center",justifyContent:"center",opacity:"0.9",borderBottom:`2px solid ${c??"#fff"}`,borderTop:`2px solid ${c??"#fff"}`},children:[n.jsx(v,{height:"22px",direction:"row",alignItems:"center",justifyItems:"center",spacing:1,sx:{userSelect:"none",color:e.color,".MuiTypography-root":{fontWeight:700,...s?{color:u.palette.action.disabled}:{}},...s?{"svg path":{fill:u.palette.action.disabled}}:{}},children:t}),n.jsx(_,{height:"22px",sx:{fontSize:"15px",color:s?u.palette.action.disabled:e.color,fontWeight:700,fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center"},ref:d,children:o()})]}),n.jsx(X,{disableRipple:!0,disabled:s,onPointerDown:J=>j(J,"+"),onPointerUp:I,onPointerOut:I,size:"large",sx:{...h==="+"?m:x,borderRadius:"0px 16px 16px 0px",borderRight:`2px solid ${c??"#fff"}`,borderBottom:`2px solid ${c??"#fff"}`,borderTop:`2px solid ${c??"#fff"}`},children:n.jsx(le,{})})]})})),St=W.externalizeComponent(T.observer(({startJogging:e,stopJogging:t,lowerLimit:o,upperLimit:i,useDegree:r,getValue:s,disabled:l,...a})=>{var k,O,F,$,J,P,H;const{t:u}=V.useTranslation(),[g,p]=C.useState(),h=q.useTheme(),d={background:(k=h.palette.backgroundPaperElevation)==null?void 0:k[4],color:(O=h.palette.backgroundPaperElevation)==null?void 0:O[11]},c=T.useLocalObservable(()=>({activeJoggingDir:null,startJogging(S){this.activeJoggingDir=S,e(S)},stopJogging(){this.activeJoggingDir=null,t()}})),f=Qt(()=>{const S=r?x(s()):s();(S===void 0||g===void 0||Math.abs(g-S)>1e-9)&&p(S)},50);A.useAnimationFrame(f);function x(S){if(S!==void 0)return M.radiansToDegrees(S)}function m(S){S.button===0&&c.startJogging("-")}function j(S){S.button===0&&c.startJogging("+")}function I(S){c.stopJogging()}function w(S){c.stopJogging()}function E(S,G=1){if(S===void 0||Number.isNaN(S))return"";const U=u("General.degree.variable",{amount:S.toFixed(G)});return S>0&&G===0?`+${U}`:U}function R(S,G=1){if(S===void 0||Number.isNaN(S))return"";const U=u("General.mm.variable",{amount:S.toFixed(G)});return S>0&&G===0?`+${U}`:U}return n.jsxs(v,{height:"64px",width:"100%",maxWidth:"260px",direction:"row",...a,sx:{"& .MuiIconButton-root":{width:"52px",color:h.palette.text.primary,alignContent:"center",backgroundColor:(F=h.palette.backgroundPaperElevation)==null?void 0:F[11],"& svg":{width:"42px",height:"42px"},"&.Mui-disabled":{backgroundColor:($=h.palette.backgroundPaperElevation)==null?void 0:$[11],color:h.palette.action.disabled,opacity:1},"&:hover":{backgroundColor:(J=h.palette.backgroundPaperElevation)==null?void 0:J[9]},"&:active":{...d}}},children:[n.jsx(X,{onPointerDown:m,onPointerUp:I,onPointerOut:w,disabled:l,disableRipple:!0,sx:{borderRadius:"16px 0px 0px 16px",...c.activeJoggingDir==="-"?d:{}},children:n.jsx(Xt,{sx:{pointerEvents:"none",color:z.jointArrowColor}})}),n.jsxs(v,{flexGrow:1,alignItems:"center",justifyContent:"center",sx:{borderStyle:"solid",borderLeftWidth:0,borderRightWidth:0,border:"none",backgroundColor:(P=h.palette.backgroundPaperElevation)==null?void 0:P[11],paddingLeft:"20px",paddingRight:"20px",zIndex:1},children:[n.jsx(_,{sx:{fontSize:"15px",fontWeight:700,position:"relative",top:"5px",fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center",color:l?h.palette.action.disabled:h.palette.text.primary},children:r?E(g):R(g)}),n.jsx(yt,{disabled:!0,"aria-label":"Joint position",min:r?x(o):o,max:r?x(i):i,value:g||0,track:!1,sx:{"& .MuiSlider-mark":{display:"none"},"& .MuiSlider-thumb":{width:"5px",height:"12px",borderRadius:"2px",color:l?h.palette.action.disabled:h.palette.text.primary},"& .MuiSlider-markLabel":{top:"20px",fontSize:"12px",color:l?h.palette.action.disabled:h.palette.text.secondary},"& .MuiSlider-rail":{backgroundColor:(H=h.palette.backgroundPaperElevation)==null?void 0:H[5],opacity:1}},marks:o!==void 0&&i!==void 0&&[{value:r?x(o):o,label:r?E(x(o),0):R(o)},{value:r?x(i):i,label:r?E(x(i),0):R(i)}]})]}),n.jsx(X,{onPointerDown:j,onPointerUp:I,onPointerOut:w,disabled:l,disableRipple:!0,sx:{borderRadius:"0px 16px 16px 0px",...c.activeJoggingDir==="+"?d:{}},children:n.jsx(Kt,{sx:{pointerEvents:"none",color:z.jointArrowColor}})})]})}));function at(e,t,o){if(t.length!==e.length)return!0;for(let i=0;i<t.length;i++)if(Math.abs(t[i]-e[i])>o)return!1;return!0}function bt(e,t,o){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)return!1;if(e===void 0||t===void 0)return!0;let i=0;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}function lt(e,t,o){return e.coordinate_system===t.coordinate_system&&e.tcp===t.tcp&&bt(e.tcp_pose,t.tcp_pose,o)}function vt(e,t){const o=new nt.Vector3(t[0],t[1],t[2]),i=new nt.Vector3(e[0],e[1],e[2]),r=o.length(),s=o.normalize();let l=i.length(),a=i.normalize();a.dot(s)<0&&(l=-l,a=a.multiplyScalar(-1));let u=l-r;return u-=2*Math.PI*Math.floor((u+Math.PI)/(2*Math.PI)),l=r+u,[...a.multiplyScalar(l)]}const ut=1e-4;class Q{constructor(t,o,i,r,s,l,a="cell"){this.controller=o,this.motionGroup=i,this.description=r,this.initialMotionState=s,this.motionStateSocket=l,this.cellId=a,this.nova=A.createNovaClient(t),this.rapidlyChangingMotionState=s,l.addEventListener("message",u=>{var d;const g=(d=M.tryParseJson(u.data))==null?void 0:d.result;if(!g)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${u.data}`);at(this.rapidlyChangingMotionState.joint_position,g.joint_position,ut)||y.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=g.joint_position}),lt(this.rapidlyChangingMotionState,g,ut)||y.runInAction(()=>{var c,f,x;this.rapidlyChangingMotionState.tcp_pose==null?this.rapidlyChangingMotionState.tcp_pose=g.tcp_pose:(c=g.tcp_pose)!=null&&c.orientation&&((f=g.tcp_pose)!=null&&f.position)&&((x=this.rapidlyChangingMotionState.tcp_pose)!=null&&x.orientation)?this.rapidlyChangingMotionState.tcp_pose={position:g.tcp_pose.position,orientation:vt(g.tcp_pose.orientation,this.rapidlyChangingMotionState.tcp_pose.orientation)}:console.warn("Received incomplete tcp_pose, ignoring",g.tcp_pose)}),g.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==g.tcp&&y.runInAction(()=>{this.rapidlyChangingMotionState.tcp=g.tcp}),this.rapidlyChangingMotionState.standstill!==g.standstill&&y.runInAction(()=>{this.rapidlyChangingMotionState.standstill=g.standstill});const p=this.rapidlyChangingMotionState.joint_limit_reached.limit_reached,h=g.joint_limit_reached.limit_reached;p.some((c,f)=>c!==h[f])&&y.runInAction(()=>{this.rapidlyChangingMotionState.joint_limit_reached=g.joint_limit_reached}),this.rapidlyChangingMotionState.execute!==g.execute&&y.runInAction(()=>{this.rapidlyChangingMotionState.execute=g.execute})}),y.makeAutoObservable(this)}static async open(t,o,i={}){var f;const r=A.createNovaClient(t),s=i.cellId??A.cellIdOf(t)??"cell",[l,a]=o.split("@"),u=await r.api.controller.getCurrentRobotControllerState(s,a),g=u==null?void 0:u.motion_groups.find(x=>x.motion_group===o);if(!u||!g)throw new Error(`Controller ${a} or motion group ${o} not found`);const p=r.openReconnectingWebsocket(`/cells/${s}/controllers/${a}/motion-groups/${o}/state-stream`),h=await p.firstMessage(),d=(f=M.tryParseJson(h.data))==null?void 0:f.result;if(!d)throw new Error(`Unable to parse initial motion state message ${h.data}`);console.log(`Connected motion state websocket to motion group ${g.motion_group}. Initial state:
2
2
  `,d);const c=await r.api.motionGroup.getMotionGroupDescription(s,a,g.motion_group);return new Q(r,u,g,c,d,p,s)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get joints(){return this.initialMotionState.joint_position.map((t,o)=>({index:o}))}dispose(){this.motionStateSocket.close()}}const ht="Movement request rejected. Another client is currently executing a 'Jogging' motion!";class tt{constructor(t,o={}){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}static async open(t,o,i={}){const r=await Q.open(t,o,{cellId:i.cellId}),s=new tt(r,i);s.ownsMotionStream=!0;try{await s.setJoggingMode(s.mode)}catch(l){throw s.dispose(),l}return s}getDefaultTcp(t){var i,r;const o=(r=(i=t.description.dh_parameters)==null?void 0:i[0])==null?void 0:r.type;return t.joints.length<6&&(o===D.JointTypeEnum.RevoluteJoint||o===D.JointTypeEnum.PrismaticJoint)?this.NO_TCP:this.DEFAULT_TCP}async setOptions(t){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)}get motionGroupId(){return this.motionStream.motionGroupId}get nova(){return this.motionStream.nova}get cellId(){return this.motionStream.cellId}get numJoints(){return this.motionStream.joints.length}async stop(){if(this.joggingSocket){const t=new Array(this.numJoints).fill(0);this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:t})}this.trajectorySocket&&this.trajectorySocket.sendJson({message_type:"PauseMovementRequest"})}async dispose(){const t=this.closeJoggingSockets();return this.ownsMotionStream&&this.motionStream.dispose(),t}closeJoggingSockets(){var o;(o=this.endJoggingInit)==null||o.call(this);const t=[this.joggingSocket,this.trajectorySocket].filter(i=>i!==null);return t.forEach(i=>{i.dispose()}),this.joggingSocket=null,this.trajectorySocket=null,Promise.all(t.map(i=>i.closed()))}async setJoggingMode(t,o=!0){if(!(this.mode===t&&o)&&(this.closeJoggingSockets(),this.mode=t,this.mode==="jogging"))return this.initializeJoggingWebsocket()}async initializeJoggingWebsocket(){return new Promise((t,o)=>{const i=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`);this.joggingSocket=i;let r=!1;const s=setTimeout(()=>{l(new Error(`Jogging initialization timeout after ${this.timeout} ms`))},this.timeout),l=g=>{r||(r=!0,clearTimeout(s),i.removeEventListener("close",u),this.endJoggingInit===a&&(this.endJoggingInit=void 0),g?o(g):t())},a=()=>l(),u=()=>{i.disposed&&l()};this.endJoggingInit=a,i.addEventListener("close",u),i.addEventListener("message",g=>{var h,d,c;const p=M.tryParseJson(g.data);if(((h=p==null?void 0:p.result)==null?void 0:h.kind)==="INITIALIZE_RECEIVED"){l();return}if(((d=p==null?void 0:p.result)==null?void 0:d.kind)==="MOTION_ERROR")if(this.onBlocked&&((c=p==null?void 0:p.result)!=null&&c.message.includes(ht))){l(),i.dispose(),this.onBlocked();return}else this.onError?(l(),this.onError(g.data)):l(new Error(g.data))}),i.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:t,direction:o,velocityValue:i,velocityUnit:r}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Joint jogging websocket not connected; create one by setting jogging mode to 'jogging'");const s=new Array(this.numJoints).fill(0);s[t]=o==="-"?-i:i,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:s})}async translateTCP({axis:t,direction:o,velocityMmPerSec:i}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");const r=[0,0,0],s=[0,0,0];s[M.XYZ_TO_VECTOR[t]]=o==="-"?-i:i,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:s,rotation:r,use_tool_coordinate_system:this.orientation==="tool"})}async rotateTCP({axis:t,direction:o,velocityRadsPerSec:i}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'");const r=[0,0,0],s=[0,0,0];r[M.XYZ_TO_VECTOR[t]]=o==="-"?-i:i,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:s,rotation:r,use_tool_coordinate_system:this.orientation==="tool"})}async runIncrementalCartesianMotion({currentTcpPose:t,currentJoints:o,velocityInRelevantUnits:i,axis:r,direction:s,motion:l}){const a=[];if(this.mode!=="trajectory")throw new Error("Set jogging mode to 'trajectory' to run incremental cartesian motions");if(l.type==="translate"){if(!t.position)throw new Error("Current pose has no position, cannot perform translation");const m=[...t.position];m[M.XYZ_TO_VECTOR[r]]+=l.distanceMm*(s==="-"?-1:1),a.push({limits_override:{tcp_velocity_limit:i},path:{path_definition_name:"PathLine",target_pose:{position:m,orientation:t.orientation}}})}else if(l.type==="rotate"){if(!t.orientation)throw new Error("Current pose has no orientation, cannot perform rotation");const m=new ot.Vector3(t.orientation[0],t.orientation[1],t.orientation[2]),j=m.length(),I=m.clone().normalize(),w=l.distanceRads*(s==="-"?-1:1),E=new ot.Vector3(0,0,0);E[r]=1;const R=Math.cos(.5*w)*Math.cos(.5*j),k=Math.sin(.5*w)*Math.sin(.5*j),O=Math.sin(.5*w)*Math.cos(.5*j),F=Math.cos(.5*w)*Math.sin(.5*j),$=E.dot(I),J=E.clone().cross(I),P=2*Math.acos(R-k*$),H=P/Math.sin(.5*P),S=new ot.Vector3().addScaledVector(J,k).addScaledVector(E,O).addScaledVector(I,F).multiplyScalar(H);a.push({limits_override:{tcp_orientation_velocity_limit:i},path:{path_definition_name:"PathLine",target_pose:{position:t.position,orientation:[...S]}}})}const u=this.motionStream.description;if(u.cycle_time===void 0){console.warn("Current motion group has no cycle time, cannot plan jogging motion");return}const g={motion_group_model:u.motion_group_model,cycle_time:u.cycle_time,mounting:u.mounting,global:u.operation_limits.auto_limits},p=await this.nova.api.trajectoryPlanning.planTrajectory(this.cellId,{motion_group_setup:g,start_joint_position:o,motion_commands:a}),h=p.response;if(!h)throw new Error(`Failed to plan jogging increment motion ${JSON.stringify(p)}`);this.trajectorySocket&&(console.warn("Trajectory jogging websocket already open; will close"),this.trajectorySocket.dispose()),this.trajectorySocket=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);const d=m=>{var j;if(!m||m.add_trajectory_error||m.message)if(this.onError)this.onError(m);else throw new Error(((j=m==null?void 0:m.add_trajectory_error)==null?void 0:j.message)||(m==null?void 0:m.message)||"Failed to execute trajectory, unknown error");if(!this.trajectorySocket)throw new Error("Failed to execute trajectory, websocket not available anymore");this.trajectorySocket.sendJson({message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"})},c=async()=>{var m;await y.when(()=>!this.motionStream.rapidlyChangingMotionState.standstill),await y.when(()=>this.motionStream.rapidlyChangingMotionState.standstill),(m=this.trajectorySocket)==null||m.dispose(),this.trajectorySocket=null},f=async()=>{var m;await y.when(()=>this.motionStream.rapidlyChangingMotionState.standstill),(m=this.trajectorySocket)==null||m.dispose(),this.trajectorySocket=null},x=async m=>{if(m!=null&&m.message)if(this.onError){this.onError(m);return}else throw new Error(m.message||"Failed to execute trajectory, unknown error");this.motionStream.rapidlyChangingMotionState.standstill?await c():await f()};this.trajectorySocket.addEventListener("message",m=>{var I,w;const j=M.tryParseJson(m.data);if(!((I=j==null?void 0:j.result)!=null&&I.kind))throw new Error(`Failed to execute trajectory: Received invalid message ${m.data}`);if(this.onBlocked&&((w=j.result.message)!=null&&w.includes(ht))){this.onBlocked();return}if(j.result.kind==="INITIALIZE_RECEIVED")d(j.result);else if(j.result.kind==="START_RECEIVED")x(j);else if(j.result.kind!=="PAUSE_RECEIVED")if(j.result.kind==="MOTION_ERROR"&&j.result.message)if(this.onError){this.onError(j);return}else throw new Error(j.result.message);else throw new Error(`Failed to execute trajectory, cannot handle message type "${j.result.kind}"`)}),this.trajectorySocket.sendJson({message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.motionGroupId,data:h,tcp:this.tcp}})}}const Ct=e=>{const t=e.softTimeout||3e3,[o,i]=C.useState(!1);return C.useEffect(()=>{const r=setTimeout(()=>{i(!0)},t);return()=>clearTimeout(r)}),n.jsx(v,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:"text.primary"},children:e.error?n.jsx(It,{loadingMessage:e.message,error:e.error}):n.jsxs(n.Fragment,{children:[n.jsx(ft,{sx:{mb:3}}),!!e.message&&n.jsx(_,{variant:"body1",children:e.message}),n.jsx(_,{variant:"body2",sx:{visibility:o?"visible":"hidden",mt:2,color:"text.secondary"},children:"This is taking longer than expected..."})]})})},It=e=>{const t=Ft.makeErrorMessage(e.error),o=e.error instanceof Error?e.error.stack:null;return n.jsxs(v,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",p:2,overflow:"auto",color:"error.main"},children:[n.jsx(_,{variant:"body1",children:(e.loadingMessage?`Error while ${xt.lowerFirst(qt.capitalize(e.loadingMessage))} - `:"")+t}),o&&n.jsx(L,{component:"pre",sx:{typography:"body2",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",mt:2,pb:6},children:o})]})},ce=T.observer(({store:e})=>{const{t}=V.useTranslation();return n.jsx(pt,{"data-testid":"jogging-blocked","aria-label":"jogging-blocked",open:!0,sx:{position:"absolute",zIndex:o=>o.zIndex.drawer+1,color:"#fff",background:"rgba(15, 15, 15, 0.88)",justifyContent:"flex-start",alignItems:"flex-start"},children:n.jsxs(v,{sx:{m:2,width:"100%"},children:[n.jsxs($t,{severity:"error",sx:{mb:2},children:[n.jsx(Bt,{children:t("Jogging.Blocked.ti")}),t("Jogging.Blocked.lb")]}),n.jsx(it,{variant:"contained",color:"secondary",onClick:()=>e.unblock(),children:t("Jogging.Blocked.Reenable.bt")})]})})}),ge=({title:e,titleId:t,...o},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:i,"aria-labelledby":t,...o},e?b.createElement("title",{id:t},e):null,b.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"})),de=C.forwardRef(ge),ue=({title:e,titleId:t,...o},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:i,"aria-labelledby":t,...o},e?b.createElement("title",{id:t},e):null,b.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"})),he=C.forwardRef(ue),me=({title:e,titleId:t,...o},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:10,height:19,fill:"none",ref:i,"aria-labelledby":t,...o},e?b.createElement("title",{id:t},e):null,b.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"})),pe=C.forwardRef(me),fe=({title:e,titleId:t,...o},i)=>b.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?b.createElement("title",{id:t},e):null,b.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"})),xe=C.forwardRef(fe),wt=T.observer(({store:e})=>{const{t}=V.useTranslation(),[o,i]=C.useState(e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached),r=C.useRef(o);A.useAnimationFrame(()=>{const l=e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;Nt(r.current,l)||(r.current=l,i(l))});const s=[];for(const[l,a]of o.entries())a&&s.push(l);return n.jsx(L,{sx:{display:"flex",flexDirection:"row",justifyContent:"center"},children:n.jsx(_,{"data-testid":"jogging-joint-limit-detector","aria-label":"jogging-joint-limit-detector",color:"error",variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2,visibility:s.length?"visible":"hidden"},children:t("Jogging.JointLimitsReached.lb",{jointNumbers:s.map(l=>l+1).join(", ")})})})}),ye=q.styled(Gt)(({theme:e})=>({"&.MuiFormControl-root":{".MuiSelect-select":{paddingTop:"20px",paddingLeft:"12px"},label:{pointerEvents:"none",fontSize:"16px"},".MuiInputLabel-root":{"&.Mui-focused":{color:e.palette.text.primary}}}}));function Z({labelValue:e,...t}){return n.jsxs(ye,{fullWidth:!0,variant:"filled",children:[n.jsx(Ut,{id:t.labelId,children:e}),n.jsx(Wt,{...t})]})}const st=[{id:"0.1",mm:.1,degrees:.05},{id:"1",mm:1,degrees:.5},{id:"5",mm:5,degrees:2.5},{id:"10",mm:10,degrees:5}],je=[{id:"continuous"},...st],Se=["coordsys","tool"];class et{constructor(t,o,i,r,s){var l,a,u;this.jogger=t,this.coordSystems=o,this.motionGroupDescription=i,this.tcps=r,this.inverseSolverValue=s,this.selectedTabId="cartesian",this.locks=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=D.JointTypeEnum.RevoluteJoint;for(const g of o)if(g.coordinate_system===""){g.coordinate_system="world";break}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=s,this.jointType=((u=(a=i==null?void 0:i.dh_parameters)==null?void 0:a[0])==null?void 0:u.type)??D.JointTypeEnum.RevoluteJoint,y.makeAutoObservable(this,{},{autoBind:!0}),this.jogger.onBlocked=()=>{this.block()},this.loadFromLocalStorage(),this.disposers.push(y.autorun(()=>this.saveToLocalStorage())),this.disposers.push(y.autorun(()=>{const g=this.jogger.motionStream.rapidlyChangingMotionState.tcp;g&&g!==this.selectedTcpId&&y.runInAction(()=>{this.selectedTcpId=g,this.tcpChangeInProgress=!1})})),window.joggingStore=this}static async loadFor(t){const{nova:o,cellId:i}=t,[r,s]=await Promise.all([o.api.controller.listCoordinateSystems(i,t.motionStream.controllerId,"ROTATION_VECTOR"),o.api.motionGroup.getMotionGroupDescription(i,t.motionStream.controllerId,t.motionGroupId)]),l=await o.api.motionGroupModels.getMotionGroupKinematicModel(s.motion_group_model),a=Object.entries(s.tcps||{}).map(([u,g])=>({id:u,readable_name:g.name,position:g.pose.position,orientation:g.pose.orientation}));return new et(t,r||[],s,a,l.inverse_solver)}dispose(){for(const t of this.disposers)t();this.jogger.dispose()}get coordSystemCountByName(){return xt.countBy(this.coordSystems,t=>t.name)}async deactivate(){this.jogger.mode==="jogging"&&await this.jogger.setJoggingMode("off")}async activate(){return this.currentTab.id==="cartesian"?((this.jogger.tcp!==this.selectedTcpId||this.jogger.orientation!==this.selectedOrientation)&&await this.jogger.setOptions({tcp:this.selectedTcpId||void 0,orientation:this.selectedOrientation}),this.activeDiscreteIncrement?await this.jogger.setJoggingMode("trajectory"):await this.jogger.setJoggingMode("jogging")):await this.jogger.setJoggingMode("jogging"),this.jogger}loadFromLocalStorage(){const t=M.tryParseJson(localStorage.getItem("joggingToolStore"));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))}saveToLocalStorage(){localStorage.setItem("joggingToolStore",JSON.stringify(this.localStorageSave))}get isLocked(){return this.locks.size>0}get localStorageSave(){return{selectedTabId:this.selectedTabId,selectedCoordSystemId:this.selectedCoordSystemId,selectedOrientation:this.selectedOrientation,selectedIncrementId:this.selectedIncrementId,selectedCartesianMotionType:this.selectedCartesianMotionType}}get tabs(){const t=[{id:"joint",label:"Joints"}];return this.inverseSolver!==null&&t.unshift({id:"cartesian",label:"Cartesian"}),t}get incrementOptions(){return je}get discreteIncrementOptions(){return st}get incrementOptionsById(){return Y(this.incrementOptions,t=>t.id)}get tabsById(){return Y(this.tabs,t=>t.id)}get currentTab(){return this.tabsById[this.selectedTabId]||this.tabs[0]}get tabIndex(){return this.tabs.indexOf(this.currentTab)}get coordSystemsById(){return Y(this.coordSystems,t=>t.coordinate_system)}get activeCoordSystemId(){return this.selectedOrientation==="tool"?"tool":this.selectedCoordSystemId}get tcpsById(){return Y(this.tcps,t=>t.id)}get activeDiscreteIncrement(){return this.selectedOrientation==="tool"?void 0:st.find(t=>t.id===this.selectedIncrementId)}get rotationVelocityRadsPerSec(){return this.rotationVelocityDegPerSec*Math.PI/180}velocityInDisplayUnits(t){return t?this.rotationVelocityDegPerSec:this.translationVelocityMmPerSec}minVelocityInDisplayUnits(t){return t?this.minRotationVelocityDegPerSec:this.minTranslationVelocityMmPerSec}maxVelocityInDisplayUnits(t){return t?this.maxRotationVelocityDegPerSec:this.maxTranslationVelocityMmPerSec}onTabChange(t,o){const i=this.tabs[o]||this.tabs[0];this.selectedTabId=i.id}setSelectedCoordSystemId(t){this.selectedCoordSystemId=t}setSelectedTcpId(t){this.requestTcpChange(t).catch(o=>{console.error("Failed to change TCP:",o)})}async requestTcpChange(t){if(t===this.selectedTcpId)return;this.tcpChangeInProgress=!0;const o=this.jogger.tcp,i=this.jogger.mode!=="jogging";try{this.jogger.tcp=t,i?await this.jogger.setJoggingMode("jogging"):await this.jogger.setJoggingMode("jogging",!1);let r=await this.waitForTcpConfirmation(t,1e3);i&&await this.jogger.setJoggingMode("off"),r||(r=await this.waitForTcpConfirmation(t,2e3)),y.runInAction(()=>{r?this.selectedTcpId=t:(this.jogger.tcp=o,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??"")})}catch(r){throw i&&await this.jogger.setJoggingMode("off").catch(()=>{}),y.runInAction(()=>{this.jogger.tcp=o,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??""}),r}finally{y.runInAction(()=>{this.tcpChangeInProgress=!1})}}waitForTcpConfirmation(t,o){return new Promise(i=>{const r=setTimeout(()=>{s(),i(!1)},o),s=y.when(()=>this.jogger.motionStream.rapidlyChangingMotionState.tcp===t,()=>{clearTimeout(r),i(!0)})})}setSelectedOrientation(t){this.selectedOrientation=t}setSelectedIncrementId(t){this.selectedIncrementId=t}setCurrentIncrementJog(t){this.incrementJogInProgress=t}setVelocityFromSlider(t,o){o?this.rotationVelocityDegPerSec=t:this.translationVelocityMmPerSec=t}setSelectedCartesianMotionType(t){this.selectedCartesianMotionType=t}lock(t){this.locks.add(t)}unlock(t){this.locks.delete(t)}block(){this.blocked=!0}unblock(){this.blocked=!1,this.jogger.mode==="jogging"&&this.jogger.initializeJoggingWebsocket().catch(t=>{console.error("Failed to initialize jogging:",t)})}async withMotionLock(t){const o=Ht();this.lock(o);try{return await t()}finally{this.unlock(o)}}}const be=T.observer(({store:e,useDegree:t})=>{var l;const{t:o}=V.useTranslation(),i=C.useId(),r=[];function s(a){switch(a){case"coordsys":return o("Jogging.Orientation.coordsys");case"tool":return o("Jogging.Orientation.tool");default:return a}}return e.showCoordSystemSelect&&r.push(n.jsx(Z,{labelId:`jogging-coord-select-${i}`,labelValue:o("Jogging.CoordinateSystem.hlb"),value:e.selectedCoordSystemId,size:"small",variant:"filled",displayEmpty:!0,onChange:a=>e.setSelectedCoordSystemId(a.target.value),children:e.coordSystems.map(a=>n.jsx(B,{value:a.coordinate_system,children:a.name&&e.coordSystemCountByName[a.name]>1?`${a.name} / ${a.coordinate_system}`:a.name||a.coordinate_system},a.coordinate_system))},"coord")),e.showTcpSelect&&r.push(n.jsx(Z,{labelId:`jogging-tcp-select-${i}`,labelValue:"TCP",value:e.selectedTcpId,size:"small",variant:"filled",displayEmpty:e.tcpChangeInProgress,onChange:a=>{e.requestTcpChange(a.target.value).catch(u=>{console.error("Failed to change TCP:",u)})},disabled:e.tcpChangeInProgress,endAdornment:e.tcpChangeInProgress?n.jsx(zt,{position:"end",children:n.jsx(ft,{size:16})}):void 0,children:e.tcps.map(a=>n.jsx(B,{value:a.id,children:a.id},a.id))},"tcp")),e.showOrientationSelect&&r.push(n.jsx(Z,{labelValue:o("Jogging.Cartesian.Orientation.lb"),labelId:`orientation-select-${i}`,value:e.selectedOrientation,onChange:a=>e.setSelectedOrientation(a.target.value),children:Se.map(a=>n.jsx(B,{value:a,children:s(a)},a))},"orientation")),e.showIncrementSelect&&r.push(n.jsxs(Z,{labelValue:o("Jogging.Increment.hlb"),labelId:`jogging-increment-select-${i}`,size:"small",variant:"filled",value:((l=e.activeDiscreteIncrement)==null?void 0:l.id)||"continuous",onChange:a=>e.setSelectedIncrementId(a.target.value),children:[n.jsx(B,{value:"continuous",children:o("Jogging.Increment.Continuous.dd")},"continuous"),e.selectedOrientation==="tool"?null:e.discreteIncrementOptions.map(a=>n.jsx(B,{value:a.id,children:t?`${a.degrees}°`:`${a.mm}mm`},a.id))]},"increment")),n.jsx(L,{component:"div","data-testid":"jogging-options","aria-label":"jogging-options",sx:{display:"grid",gap:"16px",gridTemplateColumns:"1fr 1fr",gridAutoRows:"min-content","& label":{opacity:.7,fontSize:"12px",marginBottom:"4px"}},children:r.map((a,u)=>n.jsx(L,{sx:{gridColumn:r.length%2===1&&u===r.length-1?"span 2":"auto"},children:a},u))})}),ve=q.styled(Yt)(({theme:e})=>{var t;return{"&.MuiToggleButtonGroup-root":{background:(t=e.palette.backgroundPaperElevation)==null?void 0:t[8],borderRadius:"8px",padding:"4px",gap:"4px",button:{border:"none",borderRadius:"4px",flex:"1 1 0px",minWidth:0,"&.MuiToggleButtonGroup-firstButton":{borderRadius:"8px 4px 4px 8px"},"&.MuiToggleButtonGroup-lastButton":{borderRadius:"4px 8px 8px 4px"}}}}}),Mt=W.externalizeComponent(T.observer(e=>{const{store:t}=e,{t:o}=V.useTranslation();function i(r,s){s===e.velocity||!Zt(s)||e.onVelocityChange(s,e.useDegree)}return n.jsxs(v,{direction:"row",gap:2,alignItems:"center","data-testid":"velocity-slider","aria-label":"velocity-slider",children:[t.showVelocityLegend&&n.jsx(_,{sx:{color:z.velocitySliderLegendColor,fontSize:"14px"},children:o("Jogging.Velocity.bt")}),n.jsx(yt,{value:e.velocity,color:"secondary",onChange:i,min:e.min,max:e.max,"aria-labelledby":"input-slider",disabled:e.disabled,sx:{"& .MuiSlider-valueLabelOpen":{zIndex:100,backgroundColor:"transparent",top:"0px"}}}),t.showVelocitySliderLabel&&(e.renderValue?e.renderValue(e.velocity):n.jsx(ct,{value:e.velocity.toString()}))]})}));function ct({value:e,sx:t}){var i;const o=q.useTheme();return n.jsx(v,{direction:"row",justifyContent:"center",alignItems:"center",gap:"5px",sx:{padding:"6px 12px",background:(i=o.palette.backgroundPaperElevation)==null?void 0:i[8],borderRadius:"10px",minWidth:"111px",...t},children:n.jsx(_,{component:"span",sx:{textAlign:"right",fontSize:"14px",opacity:.8,color:o.palette.text.primary,whiteSpace:"nowrap"},children:e})})}const _t=T.observer(({store:e,useDegree:t})=>{const{t:o}=V.useTranslation();function i(r,s){return s?`ω = ${o("Jogging.Cartesian.Rotation.velocityDegPerSec.lb",{amount:r})}`:`v = ${o("Jogging.Cartesian.Translation.velocityMmPerSec.lb",{amount:r})}`}return n.jsx(Mt,{store:e,velocity:e.velocityInDisplayUnits(t),min:e.minVelocityInDisplayUnits(t),max:e.maxVelocityInDisplayUnits(t),onVelocityChange:e.setVelocityFromSlider,useDegree:t,disabled:e.isLocked,renderValue:r=>n.jsx(ct,{value:i(r,t),sx:{minWidth:"111px",span:{transform:"translateY(-1.5px)"}}})})}),Tt=T.observer(({store:e})=>{var r,s,l;const{t}=V.useTranslation(),o=q.useTheme(),i=((l=(s=(r=e.jogger.motionStream.rapidlyChangingMotionState.execute)==null?void 0:r.details)==null?void 0:s.state)==null?void 0:l.kind)??"KIND_UNKNOWN";return n.jsxs(L,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",color:o.palette.text.primary},children:[n.jsx(_,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},children:t("Jogging.StreamStateSection.lb")}),n.jsx(_,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},"data-testid":i,children:t(`Jogging.StreamStateSection.${i}.lb`)})]})}),Ce=T.observer(({store:e,children:t})=>{const{t:o}=V.useTranslation(),i=q.useTheme(),r=C.useRef(0);function s(d,c){(c==="translate"||c==="rotate")&&e.setSelectedCartesianMotionType(c)}async function l(d,c){const f=await e.activate(),x=f.motionStream.rapidlyChangingMotionState.tcp_pose,m=f.motionStream.rapidlyChangingMotionState.joint_position;x&&await e.withMotionLock(async()=>{try{e.setCurrentIncrementJog({axis:d.axis,direction:d.direction}),await e.jogger.runIncrementalCartesianMotion({currentTcpPose:x,currentJoints:m,coordSystemId:e.activeCoordSystemId,velocityInRelevantUnits:e.selectedCartesianMotionType==="translate"?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec,axis:d.axis,direction:d.direction,motion:e.selectedCartesianMotionType==="translate"?{type:"translate",distanceMm:c.mm}:{type:"rotate",distanceRads:M.degreesToRadians(c.degrees)}})}finally{e.setCurrentIncrementJog(null),await e.deactivate()}})}async function a(d){if(e.isLocked)return;const c=++r.current;try{if(await e.activate(),c!==r.current)return;if(e.activeDiscreteIncrement)return await l(d,e.activeDiscreteIncrement);d.motionType==="translate"?await e.jogger.translateTCP({axis:d.axis,direction:d.direction,velocityMmPerSec:e.translationVelocityMmPerSec}):await e.jogger.rotateTCP({axis:d.axis,direction:d.direction,velocityRadsPerSec:e.rotationVelocityRadsPerSec})}catch(f){console.error("Jogging failed:",f)}}async function u(){e.isLocked||e.activeDiscreteIncrement||(r.current++,await e.deactivate())}const g=[{id:"x",icon:n.jsx(de,{}),colors:z.cartesianAxisColors.X},{id:"y",icon:n.jsx(he,{}),colors:z.cartesianAxisColors.Y},{id:"z",icon:n.jsx(pe,{}),colors:z.cartesianAxisColors.Z}];function p(d){return o("General.mm.variable",{amount:d.toFixed(1)})}function h(d){return o("General.degree.variable",{amount:M.radiansToDegrees(d).toFixed(1)})}return n.jsxs(v,{"data-testid":"jogging-cartesian-tab","aria-label":"jogging-cartesian-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[n.jsxs(v,{gap:2,children:[n.jsx(be,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),n.jsx(_t,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),n.jsx(N,{})]}),n.jsx(v,{marginLeft:"auto",marginRight:"auto",gap:"24px",justifyContent:"center",sx:{flexGrow:"1"},children:n.jsxs(v,{alignItems:"center",justifyContent:"center",gap:"24px",sx:{flexGrow:1},children:[n.jsxs(ve,{value:e.selectedCartesianMotionType,onChange:s,exclusive:!0,"aria-label":o("Jogging.Cartesian.MotionType.lb"),sx:{justifyContent:"center"},children:[n.jsx(gt,{value:"translate",children:o("Jogging.Cartesian.Translation.bt")}),n.jsx(gt,{value:"rotate",children:o("Jogging.Cartesian.Rotation.bt")})]}),e.selectedCartesianMotionType==="translate"&&g.map(d=>{var c,f;return n.jsx(rt,{"data-testid":`jogging-cartesian-axis-control-${d.id}`,"aria-label":`jogging-cartesian-axis-control-${d.id}`,colors:d.colors,disabled:e.isLocked,activeJoggingDirection:((c=e.incrementJogInProgress)==null?void 0:c.axis)===d.id?e.incrementJogInProgress.direction:void 0,label:n.jsxs(n.Fragment,{children:[d.icon,n.jsx(_,{sx:{fontSize:"24px",color:((f=d.colors)==null?void 0:f.labelColor)??i.palette.text.primary},children:d.id.toUpperCase()})]}),getDisplayedValue:()=>{var x,m;return p(((m=(x=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:x.position)==null?void 0:m[M.XYZ_TO_VECTOR[d.id]])||0)},startJogging:x=>a({axis:d.id,motionType:"translate",direction:x}),stopJogging:u},d.id)}),e.selectedCartesianMotionType==="rotate"&&g.map(d=>{var c,f;return n.jsx(rt,{"data-testid":`jogging-cartesian-axis-control-${d.id}`,"aria-label":`jogging-cartesian-axis-control-${d.id}`,colors:d.colors,disabled:e.isLocked,activeJoggingDirection:((c=e.incrementJogInProgress)==null?void 0:c.axis)===d.id?e.incrementJogInProgress.direction:void 0,label:n.jsxs(n.Fragment,{children:[n.jsx(xe,{}),n.jsx(_,{sx:{fontSize:"24px",color:((f=d.colors)==null?void 0:f.labelColor)??i.palette.text.primary},children:d.id.toUpperCase()})]}),getDisplayedValue:()=>{var x,m;return h(((m=(x=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:x.orientation)==null?void 0:m[M.XYZ_TO_VECTOR[d.id]])||0)},startJogging:x=>a({axis:d.id,motionType:"rotate",direction:x}),stopJogging:u},d.id)})]})}),n.jsx(wt,{store:e}),n.jsx(N,{}),n.jsx(Tt,{store:e}),t&&n.jsx(N,{}),t]})}),Ie=T.observer(({store:e,children:t})=>{const o=q.useTheme(),i=C.useRef(0);async function r(l){const a=++i.current;try{if(await e.activate(),a!==i.current)return;await e.jogger.rotateJoints({joint:l.joint,direction:l.direction,velocityUnit:e.jointType===D.JointTypeEnum.PrismaticJoint?"mm/s":"rad/s",velocityValue:e.jointType===D.JointTypeEnum.PrismaticJoint?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec})}catch(u){console.error("Jogging failed:",u)}}async function s(){i.current++,await e.jogger.stop(),await e.deactivate()}return n.jsxs(v,{"data-testid":"jogging-joint-tab","aria-label":"jogging-joint-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[n.jsx(_t,{store:e,useDegree:e.jointType===D.JointTypeEnum.RevoluteJoint}),n.jsx(N,{}),n.jsx(v,{justifyContent:"center",alignItems:"stretch",sx:{flexGrow:"1"},children:n.jsx(v,{"data-testid":"jogging-joint-value-controls-wrapper","aria-label":"jogging-joint-value-controls-wrapper",alignItems:"center",gap:"24px",children:e.jogger.motionStream.joints.map(l=>{var u,g,p;const a=(p=(g=(u=e.motionGroupDescription.operation_limits.auto_limits)==null?void 0:u.joints)==null?void 0:g[l.index])==null?void 0:p.position;return n.jsxs(v,{"data-testid":`jogging-joint-value-control-${l.index}`,"aria-label":`jogging-joint-value-control-${l.index}`,direction:"row",alignItems:"center",justifyContent:"center",spacing:1.5,width:"100%",children:[e.showJointsLegend&&n.jsx(_,{color:e.isLocked?o.palette.text.disabled:o.palette.text.secondary,children:`G${l.index+1}`}),n.jsx(St,{disabled:e.isLocked,lowerLimit:a==null?void 0:a.lower_limit,upperLimit:a==null?void 0:a.upper_limit,useDegree:e.jointType===D.JointTypeEnum.RevoluteJoint,getValue:()=>{const h=e.jogger.motionStream.rapidlyChangingMotionState.joint_position[l.index];return h!==void 0?h:void 0},startJogging:h=>r({joint:l.index,direction:h}),stopJogging:s})]},`joint-${l.index}`)})})}),n.jsx(wt,{store:e}),n.jsx(N,{}),n.jsx(Tt,{store:e}),t&&n.jsx(N,{}),t]})}),we=W.externalizeComponent(T.observer(e=>{const t=T.useLocalObservable(()=>({joggingStore:null,loadingError:null}));return C.useEffect(()=>{let o=!1,i;async function r(){y.runInAction(()=>{t.loadingError=null,t.joggingStore=null});try{let s=e.store;if(!s){const l=await tt.open(e.nova,e.motionGroupId,{cellId:e.cellId});if(o){l.dispose();return}try{s=await et.loadFor(l)}catch(a){throw l.dispose(),a}if(i=s,o){s.dispose();return}}y.runInAction(()=>{t.joggingStore=s}),e.onSetup&&e.onSetup(s)}catch(s){if(o)return;y.runInAction(()=>{t.loadingError=s})}}return r(),()=>{o=!0,i==null||i.dispose()}},[e.store,e.nova,e.motionGroupId,e.cellId]),C.useEffect(()=>{const o=t.joggingStore;o&&(e.locked?o.lock("external"):o.unlock("external"))},[t.joggingStore,e.locked]),n.jsx(v,{"data-testid":"jogging-panel","aria-label":"jogging-panel",sx:{maxWidth:"460px",minWidth:"320px",position:"relative",...e.sx},children:t.joggingStore?n.jsx(Me,{store:t.joggingStore,children:e.children}):n.jsx(Ct,{message:"Loading jogging",error:t.loadingError})})})),Me=T.observer(({store:e,children:t})=>{const{t:o}=V.useTranslation();function i(){if(e.currentTab.id==="cartesian")return n.jsx(Ce,{store:e,children:t});if(e.currentTab.id==="joint")return n.jsx(Ie,{store:e,children:t})}return n.jsxs(v,{flexGrow:1,sx:{overflow:"hidden"},children:[n.jsx(Lt,{"data-testid":"jogging-tabs","aria-label":"jogging-tabs",value:e.tabIndex,onChange:e.onTabChange,variant:"fullWidth",children:e.tabs.map(r=>{const s=r.label==="Cartesian"?o("Jogging.Cartesian.bt"):o("Jogging.Joints.bt"),l=r.label==="cartesian"?n.jsx(At,{fontSize:"small",sx:{mr:1}}):n.jsx(Vt,{fontSize:"small",sx:{mr:1}});return n.jsx(Dt,{"data-testid":`jogging-tab-${r.id}`,"aria-label":`jogging-tab-${r.id}`,label:e.showTabIcons?n.jsxs(v,{direction:"row",alignItems:"center",children:[l,s]}):s,id:`jogging-tab-${r.id}`,"aria-controls":`jogging-tab-${r.id}`},r.id)})}),n.jsx(v,{flexGrow:1,position:"relative",sx:{overflowY:"auto",overflowX:"hidden"},children:i()}),e.blocked&&n.jsx(ce,{store:e})]})});function _e(){const e=window.location.href;return e.substring(0,e.indexOf("/",e.indexOf("//")+2))}function Te({baseUrl:e=_e(),...t}){return n.jsxs(te,{"aria-labelledby":"no-motion-group-modal-title",open:!0,fullWidth:!0,sx:{"& .MuiModal-backdrop":{backdropFilter:"blur(10px)"},"& .MuiDialog-paper":{"::before":{content:'""',height:"8px",width:"100%",background:"linear-gradient(90deg, #FF0E65 0%, #47D3FF 100%)"},background:"#101629"}},children:[n.jsx(ie,{id:"no-motion-group-modal-title",children:"No motion group found"}),n.jsxs(oe,{sx:{marginTop:"3rem",marginBottom:"1.5rem",textAlign:"center"},children:[n.jsx(_,{color:"#fff",children:"Found no devices to connect to."}),n.jsx(_,{color:"#fff",children:"Please ensure a motion group has been created."})]}),n.jsx(ee,{children:n.jsxs(v,{width:"100%",maxWidth:"300px",margin:"auto",marginBottom:"2rem",children:[n.jsx(it,{href:`${e}/settings`,variant:"contained",sx:{borderRadius:"8px",width:"100%"},children:"Go to settings app"}),n.jsx(it,{href:`${e}`,variant:"text",sx:{marginTop:"1rem",color:"#fff",textDecoration:"underline",fontSize:"0.75rem"},children:"Back to Homescreen"})]})})]})}const mt=1e-4,Ee={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class K{constructor(t,o,i,r,s,l,a,u,g,p,h="cell"){this.controller=o,this.motionGroup=i,this.initialMotionState=r,this.motionStateSocket=s,this.isVirtual=l,this.tcps=a,this.description=u,this.initialControllerState=g,this.controllerStateSocket=p,this.cellId=h,this.connectedJoggingSocket=null,this.joggingVelocity=10,this.activationState="inactive",this.nova=A.createNovaClient(t),this.rapidlyChangingMotionState=r,this.controllerState=g,p.addEventListener("message",d=>{var f;const c=(f=M.tryParseJson(d.data))==null?void 0:f.result;c&&y.runInAction(()=>{this.controllerState=c})}),s.addEventListener("message",d=>{var f;const c=(f=M.tryParseJson(d.data))==null?void 0:f.result;if(!c)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${d.data}`);at(this.rapidlyChangingMotionState.joint_position,c.joint_position,mt)||y.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=c.joint_position}),lt(this.rapidlyChangingMotionState,c,mt)||y.runInAction(()=>{this.rapidlyChangingMotionState.tcp_pose=c.tcp_pose}),c.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==c.tcp&&y.runInAction(()=>{this.rapidlyChangingMotionState.tcp=c.tcp}),this.rapidlyChangingMotionState.standstill!==c.standstill&&y.runInAction(()=>{this.rapidlyChangingMotionState.standstill=c.standstill})}),y.makeAutoObservable(this)}static async connectMultiple(t,o,i={}){const r=A.createNovaClient(t),s=i.cellId??A.cellIdOf(t);return Promise.all(o.map(l=>K.connect(r,l,{...i,cellId:s})))}static async connect(t,o,i={}){var E,R;const r=A.createNovaClient(t),s=i.cellId??A.cellIdOf(t)??"cell",[l,a]=o.split("@"),u=await r.api.controller.getCurrentRobotControllerState(s,a),g=u==null?void 0:u.motion_groups.find(k=>k.motion_group===o);if(!u||!g)throw new Error(`Controller ${a} or motion group ${o} not found`);const p=r.openReconnectingWebsocket(`/cells/${s}/controllers/${a}/motion-groups/${o}/state-stream`),h=await p.firstMessage(),d=(E=M.tryParseJson(h.data))==null?void 0:E.result;if(!d)throw new Error(`Unable to parse initial motion state message ${h.data}`);console.log(`Connected motion state websocket to motion group ${g.motion_group}. Initial state:
3
3
  `,d);const f=(await r.api.controller.getRobotController(s,u.controller)).configuration.kind==="VirtualController",x=await r.api.motionGroup.getMotionGroupDescription(s,a,g.motion_group),m=Object.entries(x.tcps||{}).map(([k,O])=>({id:k,readable_name:O.name,position:O.pose.position,orientation:O.pose.orientation})),j=r.openReconnectingWebsocket(`/cells/${s}/controllers/${u.controller}/state-stream?response_rate=1000`),I=await j.firstMessage(),w=(R=M.tryParseJson(I.data))==null?void 0:R.result;if(!w)throw new Error(`Unable to parse initial controller state message ${I.data}`);return console.log(`Connected controller state websocket to controller ${u.controller}. Initial state:
4
4
  `,w),new K(r,u,g,d,p,f,m,x,w,j,s)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get modelFromController(){return this.description.motion_group_model}get joggingVelocityRads(){return this.joggingVelocity*Math.PI/180}get joints(){return this.initialMotionState.joint_position.map((t,o)=>({index:o}))}get dhParameters(){if(this.description.dh_parameters!==void 0)return this.description.dh_parameters.map(t=>({...Ee,...t}))}get safetyZones(){return this.description.safety_zones}get mountingPosition(){var t,o,i;return this.description.mounting?[(((t=this.description.mounting.position)==null?void 0:t[0])||0)/1e3,(((o=this.description.mounting.position)==null?void 0:o[1])||0)/1e3,(((i=this.description.mounting.position)==null?void 0:i[2])||0)/1e3]:[0,0,0]}get mountingQuaternion(){var r,s,l,a,u,g;const t=new dt.Vector3(((s=(r=this.description.mounting)==null?void 0:r.orientation)==null?void 0:s[0])||0,((a=(l=this.description.mounting)==null?void 0:l.orientation)==null?void 0:a[1])||0,((g=(u=this.description.mounting)==null?void 0:u.orientation)==null?void 0:g[2])||0),o=t.length(),i=t.normalize();return new dt.Quaternion().setFromAxisAngle(i,o)}get isEstopActive(){return["SAFETY_STATE_ROBOT_EMERGENCY_STOP","SAFETY_STATE_DEVICE_EMERGENCY_STOP"].includes(this.controllerState.safety_state)}get isMoveableSafetyState(){return["SAFETY_STATE_NORMAL","SAFETY_STATE_REDUCED"].includes(this.controllerState.safety_state)}get isMoveableOperationMode(){return["OPERATION_MODE_AUTO","OPERATION_MODE_MANUAL","OPERATION_MODE_MANUAL_T1","OPERATION_MODE_MANUAL_T2"].includes(this.controllerState.operation_mode)}get canBeMoved(){return this.isMoveableSafetyState&&this.isMoveableOperationMode&&this.activationState==="active"}async deactivate(){if(this.activationState!=="active"){console.error("Tried to deactivate while already deactivating");return}y.runInAction(()=>{this.activationState="deactivating"});try{await this.nova.api.controller.setDefaultMode(this.cellId,this.controllerId,"ROBOT_SYSTEM_MODE_MONITOR"),y.runInAction(()=>{this.activationState="inactive"})}catch(t){throw y.runInAction(()=>{this.activationState="active"}),t}}async activate(){if(this.activationState!=="inactive"){console.error("Tried to activate while already activating");return}y.runInAction(()=>{this.activationState="activating"});try{await this.nova.api.controller.setDefaultMode(this.cellId,this.controllerId,"ROBOT_SYSTEM_MODE_CONTROL"),y.runInAction(()=>{this.activationState="active"})}catch(t){throw y.runInAction(()=>{this.activationState="inactive"}),t}}toggleActivation(){this.activationState==="inactive"?this.activate():this.activationState==="active"&&this.deactivate()}dispose(){this.motionStateSocket.close(),this.controllerStateSocket.close(),this.connectedJoggingSocket&&this.connectedJoggingSocket.close()}setJoggingVelocity(t){this.joggingVelocity=t}}exports.AppHeader=ne;exports.ConnectedMotionGroup=K;exports.JoggerConnection=tt;exports.JoggingCartesianAxisControl=rt;exports.JoggingJointValueControl=St;exports.JoggingPanel=we;exports.JoggingStore=et;exports.LoadingCover=Ct;exports.LoadingErrorMessage=It;exports.MotionStreamConnection=Q;exports.NoMotionGroupModal=Te;exports.VelocitySlider=Mt;exports.VelocitySliderLabel=ct;exports.jointValuesEqual=at;exports.poseEqual=bt;exports.tcpMotionEqual=lt;exports.unwrapRotationVector=vt;
@@ -1 +1 @@
1
- "use strict";const o=require("react/jsx-runtime"),j=require("@mui/material/Box"),d=require("@mui/material/Button"),x=require("@mui/material/Stack"),l=require("@mui/material/styles"),m=require("@mui/material/Typography"),q=require("@wandelbots/icons/Rotation"),f=require("@wandelbots/mui"),I=require("./externalizeComponent-Cr89LZ90.cjs"),t=require("./joggingColors-ZDc_2UCp.cjs");function y({axis:e,motion:n,disabled:i}){const r=t.jogAxisColors[e];return o.jsx(j,{"aria-hidden":!0,sx:{opacity:i?.4:1,width:30,height:30,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:1,backgroundColor:l.alpha(r,.15),border:`1px solid ${l.alpha(r,.4)}`},children:o.jsx(m,{variant:"caption",sx:{color:r},children:n==="rotate"?`R${e}`:e.toUpperCase()})})}function R(e){return o.jsx(q.Rotation,{style:e.direction==="-"?{transform:"scaleX(-1)"}:void 0})}const v=I.externalizeComponent(e=>{const{motion:n="translate",disabled:i=!1}=e,{handlersFor:r,label:C,isPressed:b}=t.useJogControls(e);return o.jsx(x,{"data-testid":"jogging-buttons",sx:{gap:"16px",width:280,maxWidth:"100%"},children:t.JOG_AXES.map(a=>o.jsxs(x,{direction:"row",sx:{alignItems:"center",gap:"16px"},children:[o.jsx(y,{axis:a,motion:n,disabled:i}),t.JOG_DIRECTIONS.map(c=>{const s={axis:a,direction:c},u=b(s),g=n==="rotate"?R(s):void 0,h=t.jogAxisColors[a],p={backgroundColor:l.alpha(h,.25),borderColor:l.alpha(h,.4)};return o.jsx(f.SecondaryButton,{size:"large",disabled:i,"aria-label":C(s),"aria-pressed":u,startIcon:c==="-"?g:void 0,endIcon:c==="+"?g:void 0,...r(s),sx:{flex:1,touchAction:"none",userSelect:"none","& svg":{width:24,height:24},[`& .${d.buttonClasses.startIcon}`]:{marginLeft:"-6px"},[`& .${d.buttonClasses.endIcon}`]:{marginRight:"-6px"},...u&&{...p,[`&.${d.buttonClasses.disabled}`]:p}},children:t.jogHandleName(s,n)},c)})]},a))})});exports.JoggingButtons=v;
1
+ "use strict";const o=require("react/jsx-runtime"),j=require("@mui/material/Box"),d=require("@mui/material/Button"),x=require("@mui/material/Stack"),l=require("@mui/material/styles"),m=require("@mui/material/Typography"),q=require("@wandelbots/icons/Rotation"),f=require("@wandelbots/mui"),I=require("./externalizeComponent-BBWF9CMB.cjs"),t=require("./joggingColors-ZDc_2UCp.cjs");function y({axis:e,motion:n,disabled:i}){const r=t.jogAxisColors[e];return o.jsx(j,{"aria-hidden":!0,sx:{opacity:i?.4:1,width:30,height:30,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:1,backgroundColor:l.alpha(r,.15),border:`1px solid ${l.alpha(r,.4)}`},children:o.jsx(m,{variant:"caption",sx:{color:r},children:n==="rotate"?`R${e}`:e.toUpperCase()})})}function R(e){return o.jsx(q.Rotation,{style:e.direction==="-"?{transform:"scaleX(-1)"}:void 0})}const v=I.externalizeComponent(e=>{const{motion:n="translate",disabled:i=!1}=e,{handlersFor:r,label:C,isPressed:b}=t.useJogControls(e);return o.jsx(x,{"data-testid":"jogging-buttons",sx:{gap:"16px",width:280,maxWidth:"100%"},children:t.JOG_AXES.map(a=>o.jsxs(x,{direction:"row",sx:{alignItems:"center",gap:"16px"},children:[o.jsx(y,{axis:a,motion:n,disabled:i}),t.JOG_DIRECTIONS.map(c=>{const s={axis:a,direction:c},u=b(s),g=n==="rotate"?R(s):void 0,h=t.jogAxisColors[a],p={backgroundColor:l.alpha(h,.25),borderColor:l.alpha(h,.4)};return o.jsx(f.SecondaryButton,{size:"large",disabled:i,"aria-label":C(s),"aria-pressed":u,startIcon:c==="-"?g:void 0,endIcon:c==="+"?g:void 0,...r(s),sx:{flex:1,touchAction:"none",userSelect:"none","& svg":{width:24,height:24},[`& .${d.buttonClasses.startIcon}`]:{marginLeft:"-6px"},[`& .${d.buttonClasses.endIcon}`]:{marginRight:"-6px"},...u&&{...p,[`&.${d.buttonClasses.disabled}`]:p}},children:t.jogHandleName(s,n)},c)})]},a))})});exports.JoggingButtons=v;
@@ -6,7 +6,7 @@ import { alpha as d } from "@mui/material/styles";
6
6
  import I from "@mui/material/Typography";
7
7
  import { Rotation as j } from "@wandelbots/icons/Rotation";
8
8
  import { SecondaryButton as y } from "@wandelbots/mui";
9
- import { e as v } from "./externalizeComponent-BbDa5SzK.js";
9
+ import { e as v } from "./externalizeComponent-DBRjUP0q.js";
10
10
  import { u as J, J as S, a as k, j as u, b as R } from "./joggingColors-CuT5u0H8.js";
11
11
  function $({
12
12
  axis: o,
@@ -3,7 +3,7 @@ import T from "@mui/material/Box";
3
3
  import { useThree as Mt, useFrame as At, Canvas as wt } from "@react-three/fiber";
4
4
  import { Fragment as St, useRef as L, useEffect as k, useMemo as D, useState as et } from "react";
5
5
  import { Vector3 as A, Quaternion as v, Matrix4 as ot } from "three";
6
- import { e as Et } from "./externalizeComponent-BbDa5SzK.js";
6
+ import { e as Et } from "./externalizeComponent-DBRjUP0q.js";
7
7
  import { c as vt, i as Rt, J as _, a as F, u as Tt } from "./joggingColors-CuT5u0H8.js";
8
8
  import { alpha as U, useTheme as rt } from "@mui/material/styles";
9
9
  const st = new A(0, 1, 0), I = 0.26, at = 0.1, _t = { x: "X", y: "Y", z: "Z" };
@@ -1 +1 @@
1
- "use strict";const d=require("react/jsx-runtime"),R=require("@mui/material/Box"),z=require("@react-three/fiber"),M=require("react"),g=require("three"),pt=require("./externalizeComponent-Cr89LZ90.cjs"),E=require("./joggingColors-ZDc_2UCp.cjs"),$=require("@mui/material/styles"),Y=new g.Vector3(0,1,0),I=.26,Z=.1,dt={x:"X",y:"Y",z:"Z"};function V(t){var e;return((e=E.cartesianAxisColors[dt[t]].buttonBackgroundColor)==null?void 0:e.default)??"currentColor"}const ft=200;function F(t){const e=t/ft;return{marginPx:30*e,gripPx:30*e,grab:{innerPx:10*e,beyondTipPx:10*e,minTipPx:16*e},labelFontPx:Math.max(10,13*e)}}function xt(t,e,n){return Math.max(1,Math.min(t,e)/2-n)}function yt(t,e){const{gripPx:n,grab:l}=F(t);return{radiusPx:e,gripPx:n,headLength:I,...l}}function gt(t,e){const{gripPx:n,grab:l}=F(t);return{radiusPx:e,gripPx:n,beyondTipPx:l.beyondTipPx,headLength:I}}function _(t,e){return n=>{n?t.current.set(e,n):t.current.delete(e)}}const O=t=>`${t.axis}${t.direction}`,tt=t=>`label:${t}`,et=[0,1],nt=(t,e)=>`half:${O(t)}:${e}`,ot=t=>`halo:${O(t)}`,st=t=>`focus:${O(t)}`,C="polygon(0 0, 0 0, 0 0)";function rt(t,{isPressed:e,hovered:n,disabled:l}){const r=e(t),s=!l&&(r||E.isSameJogHandle(n,t));return{pressed:r,lit:s}}function at(t,{pressed:e,lit:n}){return e?$.alpha(t,.25):n?$.alpha(t,.12):"transparent"}function ct(t,{onHover:e,handlersFor:n}){return{onPointerEnter:()=>e(t),onPointerLeave:()=>e(null),...n(t)}}const q=t=>({cursor:t?"default":"pointer",touchAction:"none",userSelect:"none"}),it=t=>`2px solid ${t.palette.primary.main}`,J={x:new g.Vector3(1,0,0),y:new g.Vector3(0,1,0),z:new g.Vector3(0,0,1)};function mt(t,e,n=new g.Quaternion){return n.copy(t).invert().multiply(e)}const bt=new g.Quaternion().setFromRotationMatrix(new g.Matrix4().makeBasis(new g.Vector3(1,0,0),new g.Vector3(0,0,-1),new g.Vector3(0,1,0))),L=new g.Quaternion,St=new g.Quaternion;function At(t){return t.up.z>.5?St:bt}function Mt(t,e=new g.Quaternion){return t.getWorldQuaternion(L),mt(L,At(t),e)}function Et(t,e,n=new g.Quaternion){return n.copy(t).multiply(e)}const wt=1e-8;function B(t,e){return t?Math.abs(t.dot(e))<1-wt:!0}function jt(t){const{disabled:e,label:n,overlay:l,size:r}=t,s=$.useTheme(),{gripPx:a}=F(r);return E.JOG_AXES.flatMap(u=>E.JOG_DIRECTIONS.map(o=>{const i={axis:u,direction:o},x=rt(i,t),c=ct(i,t);return d.jsxs(M.Fragment,{children:[d.jsx(R,{component:"span","aria-hidden":!0,ref:_(l,ot(i)),sx:{position:"absolute",inset:0,clipPath:C,pointerEvents:"none",background:at(V(u),x)}}),et.map(h=>d.jsx(R,{component:"span","aria-hidden":!0,ref:_(l,nt(i,h)),...c,sx:{position:"absolute",inset:0,clipPath:C,...q(e)}},h)),d.jsx(R,{component:"button",type:"button",ref:_(l,O(i)),disabled:e,"aria-label":n(i),"aria-pressed":x.pressed,...c,sx:{position:"absolute",width:a,height:a,transform:"translate(-50%, -50%)",padding:0,border:"none",borderRadius:"50%",background:"transparent","&:focus-visible":{outline:it(s)},"&[data-band='shown']:focus-visible":{outline:"none"},...q(e)}}),d.jsx(R,{component:"svg","aria-hidden":!0,sx:{position:"absolute",left:0,top:0,width:r,height:r,overflow:"visible",pointerEvents:"none",display:"none",zIndex:100,"button[data-band='shown']:focus-visible + &":{display:"block"}},children:d.jsx("path",{ref:_(l,st(i)),fill:"none",stroke:s.palette.primary.main,strokeWidth:2,strokeLinejoin:"round"})})]},O(i))}))}const T=.8,Q=.45,lt=2.25,ut={x:[new g.Vector3(0,1,0),new g.Vector3(0,0,1)],y:[new g.Vector3(-1,0,0),new g.Vector3(0,0,1)],z:[new g.Vector3(1,0,0),new g.Vector3(0,1,0)]};function H(t){const e=t==="+"?Q:Q+Math.PI,n=e+lt;return{start:e,end:n,head:t==="+"?n:e}}const Ot=new g.Vector3,P=new g.Vector3,Rt=new g.Vector3;function _t(t,e=24){const n=[];for(const l of E.JOG_AXES){const[r,s]=ut[l],a=o=>Ot.copy(r).multiplyScalar(Math.cos(o)*T).addScaledVector(s,Math.sin(o)*T).applyQuaternion(t),u=Math.abs(Rt.copy(J[l]).applyQuaternion(t).z);for(const o of E.JOG_DIRECTIONS){const{start:i,end:x,head:c}=H(o),h=[];for(let A=0;A<=e;A++){const w=a(i+(x-i)*A/e);h.push({x:w.x+0,y:-w.y+0,depth:w.z})}const m=a(c),p={x:m.x+0,y:-m.y+0,depth:m.z},f=o==="+"?1:-1;P.copy(r).multiplyScalar(-Math.sin(c)*f).addScaledVector(s,Math.cos(c)*f).applyQuaternion(t);const y=Math.hypot(P.x,P.y),b=y>1e-9?P.x/y:0,S=y>1e-9?-P.y/y:0;n.push({axis:l,direction:o,points:h,head:{...p,dx:b+0,dy:S+0},openness:u})}}return n}function It(t,e,n){let l={distance:Number.POSITIVE_INFINITY,depth:0};for(let r=1;r<t.length;r++){const s=t[r-1],a=t[r],u=(a.x-s.x)**2+(a.y-s.y)**2,o=u===0?0:Math.min(1,Math.max(0,((e-s.x)*(a.x-s.x)+(n-s.y)*(a.y-s.y))/u)),i=Math.hypot(e-(s.x+o*(a.x-s.x)),n-(s.y+o*(a.y-s.y)));i<l.distance&&(l={distance:i,depth:s.depth+o*(a.depth-s.depth)})}return l}function Tt(t,e){const n=t.length,l=t.map(()=>new Array(n).fill(!1));for(let o=0;o<n;o++)for(let i=o+1;i<n;i++){if(t[o].arc===t[i].arc)continue;let x=0;for(const c of t[o].line){const h=It(t[i].line,c.x,c.y);h.distance<e&&(x+=c.depth-h.depth)}x>0?l[o][i]=!0:x<0&&(l[i][o]=!0)}const r=t.map(({line:o})=>o.reduce((i,x)=>i+x.depth,0)/o.length),s=(o,i)=>r[o]-r[i],a=new Array(n).fill(0),u=new Set(t.keys());for(let o=1;u.size>0;o++){const i=[...u],x=i.filter(h=>!i.some(m=>l[h][m])),c=(x.length>0?x:i).sort(s)[0];a[c]=o,u.delete(c)}return a}const k=8;function D(t,e){const n=[...t];if(e>=0){const r=n[n.length-1],s=n[n.length-2],a=Math.hypot(r.x-s.x,r.y-s.y)||1;return n.push({x:r.x+(r.x-s.x)/a*e,y:r.y+(r.y-s.y)/a*e,depth:r.depth}),n}let l=-e;for(;n.length>2;){const r=n[n.length-1],s=n[n.length-2],a=Math.hypot(r.x-s.x,r.y-s.y);if(a>l){const u=l/a;return n[n.length-1]={x:r.x+(s.x-r.x)*u,y:r.y+(s.y-r.y)*u,depth:r.depth+(s.depth-r.depth)*u},n}l-=a,n.pop()}return n}const X=(t,e)=>D([...t].reverse(),e).reverse();function vt(t,e){const n=e/2,l=[],r=[],s=[];let a={x:0,y:0};for(const[o,i]of t.entries()){const x=t[Math.max(0,o-1)],c=t[Math.min(t.length-1,o+1)],h=c.x-x.x,m=c.y-x.y,p=Math.hypot(h,m);p>1e-9&&(a={x:-m/p,y:h/p}),s.push(a),l.push({x:i.x+a.x*n,y:i.y+a.y*n}),r.push({x:i.x-a.x*n,y:i.y-a.y*n})}const u=(o,i)=>{const x=s[o],c={x:x.y,y:-x.x},h=i?1:-1;return Array.from({length:k-1},(m,p)=>{const f=Math.PI*(p+1)/k,y=Math.cos(f)*h,b=Math.sin(f)*h;return{x:t[o].x+(x.x*y+c.x*b)*n,y:t[o].y+(x.y*y+c.y*b)*n}})};return(o,i)=>[...l.slice(o,i+1),...i===t.length-1?u(i,!0):[],...r.slice(o,i+1).reverse(),...o===0?u(o,!1):[]]}function Gt(t,e){return[{from:0,to:Math.min(t-1,e+1)},{from:Math.max(0,e-1),to:t-1}]}function Pt(t,{radiusPx:e,gripPx:n,beyondTipPx:l,headLength:r}){const s=n/2,a=r/2*e+l-s,u=l-s,o=t.map(p=>{const f=p.points.map(S=>({x:S.x*e,y:S.y*e,depth:S.depth})),y=f[f.length>>1],b=p.direction==="+"?X(D(f,a),u):D(X(f,a),u);return{line:b,middle:b.indexOf(y)}}),i=o.map(({line:p})=>p),x=t.map(p=>2*T*e*p.openness>=n),c=i.flatMap((p,f)=>x[f]?Gt(p.length,o[f].middle).map(({from:y,to:b})=>({arc:f,from:y,to:b,line:p.slice(y,b+1)})):[]),h=Tt(c,n),m=t.map((p,f)=>f).sort((p,f)=>t[p].head.depth-t[f].head.depth);return t.map((p,f)=>{if(!x[f])return null;const y=vt(i[f],n),b=c.flatMap((S,A)=>S.arc===f?[{...S,layer:h[A]}]:[]);return{band:y(0,i[f].length-1),halves:b.map(({from:S,to:A,layer:w})=>({polygon:y(S,A),layer:w})),head:{x:p.head.x*e,y:p.head.y*e},headLayer:c.length+1+m.indexOf(f)}})}function ht(t,e,n,l){const r=M.useRef(null),s=z.useThree(a=>a.invalidate);M.useEffect(()=>{r.current=null,s()},[l,s]),M.useEffect(()=>{let a=requestAnimationFrame(function u(){const o=t.current;o&&B(r.current,o)&&s(),a=requestAnimationFrame(u)});return()=>cancelAnimationFrame(a)},[t,s]),z.useFrame(()=>{const a=t.current;!a||!e.current||B(r.current,a)&&(e.current.quaternion.copy(a),n(a)&&(r.current=a.clone()))})}const U=.03;function Vt({orientation:t,lit:e,disabled:n,size:l,radius:r,overlay:s}){const a=M.useRef(null),u=l/2,o=c=>`${(u+c).toFixed(2)}px`,i=c=>`polygon(${c.map(h=>`${o(h.x)} ${o(h.y)}`).join(", ")})`,x=c=>`M${c.map(h=>`${(u+h.x).toFixed(2)} ${(u+h.y).toFixed(2)}`).join("L")}Z`;return ht(t,a,c=>{let h=!0;const m=_t(c),p=Pt(m,gt(l,r));for(const[f,y]of m.entries()){const b=s.current.get(O(y)),S=s.current.get(ot(y)),A=s.current.get(st(y)),w=et.map(v=>s.current.get(nt(y,v)));if(!b||!S||!A||w.some(v=>!v)){h=!1;continue}const j=p[f];b.style.left=o(y.head.x*r),b.style.top=o(y.head.y*r),b.style.zIndex=j?String(j.headLayer):"0",b.style.pointerEvents=j?"":"none",b.dataset.band=j?"shown":"none",S.style.clipPath=j?i(j.band):C,A.setAttribute("d",j?x(j.band):"");for(const[v,N]of w.entries()){if(!N)continue;const G=j==null?void 0:j.halves[v];N.style.clipPath=G?i(G.polygon):C,N.style.zIndex=G?String(G.layer):"0",N.style.pointerEvents=G?"":"none"}}return h},`${l}:${r}`),d.jsxs("group",{ref:a,children:[d.jsxs("mesh",{children:[d.jsx("sphereGeometry",{args:[.07,16,16]}),d.jsx("meshBasicMaterial",{color:"#c4c8d0"})]}),E.JOG_AXES.map(c=>d.jsx(Ft,{axis:c,color:V(c),lit:(e==null?void 0:e.axis)===c?e.direction:null,disabled:n},c))]})}function Ft({axis:t,color:e,lit:n,disabled:l}){const r=M.useMemo(()=>{const[s,a]=ut[t];return new g.Quaternion().setFromRotationMatrix(new g.Matrix4().makeBasis(s,a,J[t]))},[t]);return d.jsx("group",{quaternion:r,children:E.JOG_DIRECTIONS.map(s=>{const a=n===s,u=a?1:l?.35:.8,o=a?U*1.5:U;return d.jsxs("group",{children:[d.jsxs("mesh",{rotation:[0,0,H(s).start],children:[d.jsx("torusGeometry",{args:[T,o,12,48,lt]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:u})]}),d.jsx(Nt,{direction:s,color:e,opacity:u,lit:a})]},s)})})}function Nt({direction:t,color:e,opacity:n,lit:l}){const{position:r,rotation:s}=M.useMemo(()=>{const{head:a}=H(t),u=t==="+"?1:-1;return{position:new g.Vector3(Math.cos(a)*T,Math.sin(a)*T,0),rotation:new g.Quaternion().setFromUnitVectors(Y,new g.Vector3(-Math.sin(a)*u,Math.cos(a)*u,0))}},[t]);return d.jsxs("mesh",{position:r,quaternion:s,scale:l?1.2:1,children:[d.jsx("coneGeometry",{args:[Z,I,20]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:n})]})}function $t(t){const{disabled:e,label:n,overlay:l,size:r}=t,s=$.useTheme(),{gripPx:a,labelFontPx:u}=F(r);return d.jsxs(d.Fragment,{children:[E.JOG_AXES.map(o=>d.jsx(R,{component:"span","aria-hidden":!0,ref:_(l,tt(o)),sx:{position:"absolute",transform:"translate(-50%, -50%)",pointerEvents:"none",fontSize:u,color:V(o),opacity:e?.4:1},children:o.toUpperCase()},o)),E.JOG_AXES.flatMap(o=>E.JOG_DIRECTIONS.map(i=>{const x={axis:o,direction:i},c=rt(x,t);return d.jsx(R,{component:"button",type:"button",ref:_(l,O(x)),disabled:e,"aria-label":n(x),"aria-pressed":c.pressed,...ct(x,t),sx:{position:"absolute",height:a,transformOrigin:"0 50%",padding:0,borderRadius:`${a/2}px`,border:"none",background:at(V(o),c),"&:focus-visible":{outline:it(s)},...q(e)}},O(x))}))]})}function Ct(t){const e=[];for(const n of E.JOG_AXES)for(const l of E.JOG_DIRECTIONS){const r=J[n].clone().multiplyScalar(l==="+"?1:-1).applyQuaternion(t);e.push({axis:n,direction:l,x:r.x+0,y:-r.y+0,depth:r.z})}return e}function Jt(t,e){const{radiusPx:n,gripPx:l,innerPx:r,beyondTipPx:s,minTipPx:a,headLength:u}=e,o=t.map(c=>{const h=Math.hypot(c.x,c.y)*n;return{tip:h,angle:Math.atan2(c.y,c.x),start:r,end:h+s,depth:c.depth,grabbed:h>=a}});for(const[c,h]of o.entries())for(const m of o.slice(c+1)){if(!h.grabbed||!m.grabbed)continue;const[p,f]=h.tip<=m.tip?[h,m]:[m,h],y=h.angle-m.angle,b=p.tip*Math.abs(Math.sin(y));if(Math.cos(y)<=0||b>=l)continue;const S=f.tip*(1-u);if(p.tip>S){const A=h.depth<m.depth?h:m;A.grabbed=!1}else{const A=(p.tip+S)/2;p.end=Math.min(p.end,A),f.start=Math.max(f.start,A)}}const i=o.map((c,h)=>h);i.sort((c,h)=>o[c].depth-o[h].depth);const x=new Map(i.map((c,h)=>[c,h+1]));return o.map((c,h)=>!c.grabbed||c.end<=c.start?null:{x:Math.cos(c.angle)*c.start,y:Math.sin(c.angle)*c.start,length:c.end-c.start,angle:c.angle,layer:x.get(h)??0})}const W=.035,K=1.28;function zt({orientation:t,lit:e,disabled:n,size:l,radius:r,overlay:s}){const a=M.useRef(null),u=l/2;return ht(t,a,o=>{let i=!0;const x=Ct(o),c=Jt(x,yt(l,r));for(const[h,m]of x.entries()){const p=s.current.get(O(m)),f=c[h];if(p?f?(p.style.left=`${u+f.x}px`,p.style.top=`${u+f.y}px`,p.style.width=`${f.length}px`,p.style.transform=`translateY(-50%) rotate(${f.angle}rad)`,p.style.zIndex=String(f.layer),p.style.pointerEvents=""):p.style.pointerEvents="none":i=!1,m.direction!=="+")continue;const y=s.current.get(tt(m.axis));y?(y.style.left=`${u+m.x*r*K}px`,y.style.top=`${u+m.y*r*K}px`):i=!1}return i},`${l}:${r}`),d.jsxs("group",{ref:a,children:[d.jsxs("mesh",{children:[d.jsx("sphereGeometry",{args:[.07,16,16]}),d.jsx("meshBasicMaterial",{color:"#c4c8d0"})]}),E.JOG_AXES.map(o=>d.jsx(qt,{axis:o,color:V(o),lit:(e==null?void 0:e.axis)===o?e.direction:null,disabled:n},o))]})}function qt({axis:t,color:e,lit:n,disabled:l}){const r=M.useMemo(()=>new g.Quaternion().setFromUnitVectors(Y,J[t]),[t]),s=1-I;return d.jsx("group",{quaternion:r,children:E.JOG_DIRECTIONS.map(a=>{const u=n===a,o=u?1:l?.35:.8,i=u?W*1.5:W;return d.jsxs("group",{rotation:[a==="+"?0:Math.PI,0,0],children:[d.jsxs("mesh",{position:[0,s/2,0],children:[d.jsx("cylinderGeometry",{args:[i,i,s,12]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:o})]}),d.jsxs("mesh",{position:[0,1-I/2,0],scale:u?1.2:1,children:[d.jsx("coneGeometry",{args:[Z,I,20]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:o})]})]},a)})})}const Dt=new g.Quaternion;function Ht(t,e=Dt){const n=M.useRef(e);return n.current=e,M.useMemo(()=>{const l=new g.Quaternion;return{get current(){const r=t.current;if(!r)return null;const s=n.current;return Et(r,typeof s=="function"?s():s,l)}}},[t])}const Lt=3e3;function Bt(t){const[e,n]=M.useState(()=>t.current!==null);return M.useEffect(()=>{if(e)return;let l=requestAnimationFrame(function s(){t.current!==null?n(!0):l=requestAnimationFrame(s)});const r=setTimeout(()=>{t.current===null&&console.warn("JoggingGizmo has no orientation, so it stays disabled. Put a JoggingGizmoOrientation with the same ref into the app's 3D scene.")},Lt);return()=>{cancelAnimationFrame(l),clearTimeout(r)}},[e,t]),e}const Qt=pt.externalizeComponent(({orientation:t,frameQuaternion:e,motion:n="translate",onJogStart:l,onJogStop:r,activeHandle:s,disabled:a=!1,size:u=200})=>{const o=Bt(t),i=a||!o,x=Ht(t,e),{held:c,handlersFor:h,label:m,isPressed:p}=E.useJogControls({motion:n,onJogStart:l,onJogStop:r,activeHandle:s,disabled:i}),[f,y]=M.useState(null);M.useEffect(()=>y(null),[n]);const b=n==="rotate"?Vt:zt,S=n==="rotate"?jt:$t,A=M.useRef(new Map),w=xt(u,u,F(u).marginPx);return d.jsxs(R,{"data-testid":"jogging-gizmo",sx:{position:"relative",width:u,height:u,flexShrink:0,isolation:"isolate"},children:[d.jsx(z.Canvas,{orthographic:!0,flat:!0,frameloop:"demand",camera:{position:[0,0,10],up:[0,1,0],zoom:w,near:.1,far:100},gl:{alpha:!0,antialias:!0},style:{position:"absolute",inset:0,pointerEvents:"none"},children:d.jsx(b,{orientation:x,lit:c??s??f,disabled:i,size:u,radius:w,overlay:A})}),d.jsx(S,{isPressed:p,hovered:f,disabled:i,size:u,onHover:y,handlersFor:h,label:m,overlay:A})]})});exports.JoggingGizmo=Qt;exports.novaAxesSeenBy=Mt;
1
+ "use strict";const d=require("react/jsx-runtime"),R=require("@mui/material/Box"),z=require("@react-three/fiber"),M=require("react"),g=require("three"),pt=require("./externalizeComponent-BBWF9CMB.cjs"),E=require("./joggingColors-ZDc_2UCp.cjs"),$=require("@mui/material/styles"),Y=new g.Vector3(0,1,0),I=.26,Z=.1,dt={x:"X",y:"Y",z:"Z"};function V(t){var e;return((e=E.cartesianAxisColors[dt[t]].buttonBackgroundColor)==null?void 0:e.default)??"currentColor"}const ft=200;function F(t){const e=t/ft;return{marginPx:30*e,gripPx:30*e,grab:{innerPx:10*e,beyondTipPx:10*e,minTipPx:16*e},labelFontPx:Math.max(10,13*e)}}function xt(t,e,n){return Math.max(1,Math.min(t,e)/2-n)}function yt(t,e){const{gripPx:n,grab:l}=F(t);return{radiusPx:e,gripPx:n,headLength:I,...l}}function gt(t,e){const{gripPx:n,grab:l}=F(t);return{radiusPx:e,gripPx:n,beyondTipPx:l.beyondTipPx,headLength:I}}function _(t,e){return n=>{n?t.current.set(e,n):t.current.delete(e)}}const O=t=>`${t.axis}${t.direction}`,tt=t=>`label:${t}`,et=[0,1],nt=(t,e)=>`half:${O(t)}:${e}`,ot=t=>`halo:${O(t)}`,st=t=>`focus:${O(t)}`,C="polygon(0 0, 0 0, 0 0)";function rt(t,{isPressed:e,hovered:n,disabled:l}){const r=e(t),s=!l&&(r||E.isSameJogHandle(n,t));return{pressed:r,lit:s}}function at(t,{pressed:e,lit:n}){return e?$.alpha(t,.25):n?$.alpha(t,.12):"transparent"}function ct(t,{onHover:e,handlersFor:n}){return{onPointerEnter:()=>e(t),onPointerLeave:()=>e(null),...n(t)}}const q=t=>({cursor:t?"default":"pointer",touchAction:"none",userSelect:"none"}),it=t=>`2px solid ${t.palette.primary.main}`,J={x:new g.Vector3(1,0,0),y:new g.Vector3(0,1,0),z:new g.Vector3(0,0,1)};function mt(t,e,n=new g.Quaternion){return n.copy(t).invert().multiply(e)}const bt=new g.Quaternion().setFromRotationMatrix(new g.Matrix4().makeBasis(new g.Vector3(1,0,0),new g.Vector3(0,0,-1),new g.Vector3(0,1,0))),L=new g.Quaternion,St=new g.Quaternion;function At(t){return t.up.z>.5?St:bt}function Mt(t,e=new g.Quaternion){return t.getWorldQuaternion(L),mt(L,At(t),e)}function Et(t,e,n=new g.Quaternion){return n.copy(t).multiply(e)}const wt=1e-8;function B(t,e){return t?Math.abs(t.dot(e))<1-wt:!0}function jt(t){const{disabled:e,label:n,overlay:l,size:r}=t,s=$.useTheme(),{gripPx:a}=F(r);return E.JOG_AXES.flatMap(u=>E.JOG_DIRECTIONS.map(o=>{const i={axis:u,direction:o},x=rt(i,t),c=ct(i,t);return d.jsxs(M.Fragment,{children:[d.jsx(R,{component:"span","aria-hidden":!0,ref:_(l,ot(i)),sx:{position:"absolute",inset:0,clipPath:C,pointerEvents:"none",background:at(V(u),x)}}),et.map(h=>d.jsx(R,{component:"span","aria-hidden":!0,ref:_(l,nt(i,h)),...c,sx:{position:"absolute",inset:0,clipPath:C,...q(e)}},h)),d.jsx(R,{component:"button",type:"button",ref:_(l,O(i)),disabled:e,"aria-label":n(i),"aria-pressed":x.pressed,...c,sx:{position:"absolute",width:a,height:a,transform:"translate(-50%, -50%)",padding:0,border:"none",borderRadius:"50%",background:"transparent","&:focus-visible":{outline:it(s)},"&[data-band='shown']:focus-visible":{outline:"none"},...q(e)}}),d.jsx(R,{component:"svg","aria-hidden":!0,sx:{position:"absolute",left:0,top:0,width:r,height:r,overflow:"visible",pointerEvents:"none",display:"none",zIndex:100,"button[data-band='shown']:focus-visible + &":{display:"block"}},children:d.jsx("path",{ref:_(l,st(i)),fill:"none",stroke:s.palette.primary.main,strokeWidth:2,strokeLinejoin:"round"})})]},O(i))}))}const T=.8,Q=.45,lt=2.25,ut={x:[new g.Vector3(0,1,0),new g.Vector3(0,0,1)],y:[new g.Vector3(-1,0,0),new g.Vector3(0,0,1)],z:[new g.Vector3(1,0,0),new g.Vector3(0,1,0)]};function H(t){const e=t==="+"?Q:Q+Math.PI,n=e+lt;return{start:e,end:n,head:t==="+"?n:e}}const Ot=new g.Vector3,P=new g.Vector3,Rt=new g.Vector3;function _t(t,e=24){const n=[];for(const l of E.JOG_AXES){const[r,s]=ut[l],a=o=>Ot.copy(r).multiplyScalar(Math.cos(o)*T).addScaledVector(s,Math.sin(o)*T).applyQuaternion(t),u=Math.abs(Rt.copy(J[l]).applyQuaternion(t).z);for(const o of E.JOG_DIRECTIONS){const{start:i,end:x,head:c}=H(o),h=[];for(let A=0;A<=e;A++){const w=a(i+(x-i)*A/e);h.push({x:w.x+0,y:-w.y+0,depth:w.z})}const m=a(c),p={x:m.x+0,y:-m.y+0,depth:m.z},f=o==="+"?1:-1;P.copy(r).multiplyScalar(-Math.sin(c)*f).addScaledVector(s,Math.cos(c)*f).applyQuaternion(t);const y=Math.hypot(P.x,P.y),b=y>1e-9?P.x/y:0,S=y>1e-9?-P.y/y:0;n.push({axis:l,direction:o,points:h,head:{...p,dx:b+0,dy:S+0},openness:u})}}return n}function It(t,e,n){let l={distance:Number.POSITIVE_INFINITY,depth:0};for(let r=1;r<t.length;r++){const s=t[r-1],a=t[r],u=(a.x-s.x)**2+(a.y-s.y)**2,o=u===0?0:Math.min(1,Math.max(0,((e-s.x)*(a.x-s.x)+(n-s.y)*(a.y-s.y))/u)),i=Math.hypot(e-(s.x+o*(a.x-s.x)),n-(s.y+o*(a.y-s.y)));i<l.distance&&(l={distance:i,depth:s.depth+o*(a.depth-s.depth)})}return l}function Tt(t,e){const n=t.length,l=t.map(()=>new Array(n).fill(!1));for(let o=0;o<n;o++)for(let i=o+1;i<n;i++){if(t[o].arc===t[i].arc)continue;let x=0;for(const c of t[o].line){const h=It(t[i].line,c.x,c.y);h.distance<e&&(x+=c.depth-h.depth)}x>0?l[o][i]=!0:x<0&&(l[i][o]=!0)}const r=t.map(({line:o})=>o.reduce((i,x)=>i+x.depth,0)/o.length),s=(o,i)=>r[o]-r[i],a=new Array(n).fill(0),u=new Set(t.keys());for(let o=1;u.size>0;o++){const i=[...u],x=i.filter(h=>!i.some(m=>l[h][m])),c=(x.length>0?x:i).sort(s)[0];a[c]=o,u.delete(c)}return a}const k=8;function D(t,e){const n=[...t];if(e>=0){const r=n[n.length-1],s=n[n.length-2],a=Math.hypot(r.x-s.x,r.y-s.y)||1;return n.push({x:r.x+(r.x-s.x)/a*e,y:r.y+(r.y-s.y)/a*e,depth:r.depth}),n}let l=-e;for(;n.length>2;){const r=n[n.length-1],s=n[n.length-2],a=Math.hypot(r.x-s.x,r.y-s.y);if(a>l){const u=l/a;return n[n.length-1]={x:r.x+(s.x-r.x)*u,y:r.y+(s.y-r.y)*u,depth:r.depth+(s.depth-r.depth)*u},n}l-=a,n.pop()}return n}const X=(t,e)=>D([...t].reverse(),e).reverse();function vt(t,e){const n=e/2,l=[],r=[],s=[];let a={x:0,y:0};for(const[o,i]of t.entries()){const x=t[Math.max(0,o-1)],c=t[Math.min(t.length-1,o+1)],h=c.x-x.x,m=c.y-x.y,p=Math.hypot(h,m);p>1e-9&&(a={x:-m/p,y:h/p}),s.push(a),l.push({x:i.x+a.x*n,y:i.y+a.y*n}),r.push({x:i.x-a.x*n,y:i.y-a.y*n})}const u=(o,i)=>{const x=s[o],c={x:x.y,y:-x.x},h=i?1:-1;return Array.from({length:k-1},(m,p)=>{const f=Math.PI*(p+1)/k,y=Math.cos(f)*h,b=Math.sin(f)*h;return{x:t[o].x+(x.x*y+c.x*b)*n,y:t[o].y+(x.y*y+c.y*b)*n}})};return(o,i)=>[...l.slice(o,i+1),...i===t.length-1?u(i,!0):[],...r.slice(o,i+1).reverse(),...o===0?u(o,!1):[]]}function Gt(t,e){return[{from:0,to:Math.min(t-1,e+1)},{from:Math.max(0,e-1),to:t-1}]}function Pt(t,{radiusPx:e,gripPx:n,beyondTipPx:l,headLength:r}){const s=n/2,a=r/2*e+l-s,u=l-s,o=t.map(p=>{const f=p.points.map(S=>({x:S.x*e,y:S.y*e,depth:S.depth})),y=f[f.length>>1],b=p.direction==="+"?X(D(f,a),u):D(X(f,a),u);return{line:b,middle:b.indexOf(y)}}),i=o.map(({line:p})=>p),x=t.map(p=>2*T*e*p.openness>=n),c=i.flatMap((p,f)=>x[f]?Gt(p.length,o[f].middle).map(({from:y,to:b})=>({arc:f,from:y,to:b,line:p.slice(y,b+1)})):[]),h=Tt(c,n),m=t.map((p,f)=>f).sort((p,f)=>t[p].head.depth-t[f].head.depth);return t.map((p,f)=>{if(!x[f])return null;const y=vt(i[f],n),b=c.flatMap((S,A)=>S.arc===f?[{...S,layer:h[A]}]:[]);return{band:y(0,i[f].length-1),halves:b.map(({from:S,to:A,layer:w})=>({polygon:y(S,A),layer:w})),head:{x:p.head.x*e,y:p.head.y*e},headLayer:c.length+1+m.indexOf(f)}})}function ht(t,e,n,l){const r=M.useRef(null),s=z.useThree(a=>a.invalidate);M.useEffect(()=>{r.current=null,s()},[l,s]),M.useEffect(()=>{let a=requestAnimationFrame(function u(){const o=t.current;o&&B(r.current,o)&&s(),a=requestAnimationFrame(u)});return()=>cancelAnimationFrame(a)},[t,s]),z.useFrame(()=>{const a=t.current;!a||!e.current||B(r.current,a)&&(e.current.quaternion.copy(a),n(a)&&(r.current=a.clone()))})}const U=.03;function Vt({orientation:t,lit:e,disabled:n,size:l,radius:r,overlay:s}){const a=M.useRef(null),u=l/2,o=c=>`${(u+c).toFixed(2)}px`,i=c=>`polygon(${c.map(h=>`${o(h.x)} ${o(h.y)}`).join(", ")})`,x=c=>`M${c.map(h=>`${(u+h.x).toFixed(2)} ${(u+h.y).toFixed(2)}`).join("L")}Z`;return ht(t,a,c=>{let h=!0;const m=_t(c),p=Pt(m,gt(l,r));for(const[f,y]of m.entries()){const b=s.current.get(O(y)),S=s.current.get(ot(y)),A=s.current.get(st(y)),w=et.map(v=>s.current.get(nt(y,v)));if(!b||!S||!A||w.some(v=>!v)){h=!1;continue}const j=p[f];b.style.left=o(y.head.x*r),b.style.top=o(y.head.y*r),b.style.zIndex=j?String(j.headLayer):"0",b.style.pointerEvents=j?"":"none",b.dataset.band=j?"shown":"none",S.style.clipPath=j?i(j.band):C,A.setAttribute("d",j?x(j.band):"");for(const[v,N]of w.entries()){if(!N)continue;const G=j==null?void 0:j.halves[v];N.style.clipPath=G?i(G.polygon):C,N.style.zIndex=G?String(G.layer):"0",N.style.pointerEvents=G?"":"none"}}return h},`${l}:${r}`),d.jsxs("group",{ref:a,children:[d.jsxs("mesh",{children:[d.jsx("sphereGeometry",{args:[.07,16,16]}),d.jsx("meshBasicMaterial",{color:"#c4c8d0"})]}),E.JOG_AXES.map(c=>d.jsx(Ft,{axis:c,color:V(c),lit:(e==null?void 0:e.axis)===c?e.direction:null,disabled:n},c))]})}function Ft({axis:t,color:e,lit:n,disabled:l}){const r=M.useMemo(()=>{const[s,a]=ut[t];return new g.Quaternion().setFromRotationMatrix(new g.Matrix4().makeBasis(s,a,J[t]))},[t]);return d.jsx("group",{quaternion:r,children:E.JOG_DIRECTIONS.map(s=>{const a=n===s,u=a?1:l?.35:.8,o=a?U*1.5:U;return d.jsxs("group",{children:[d.jsxs("mesh",{rotation:[0,0,H(s).start],children:[d.jsx("torusGeometry",{args:[T,o,12,48,lt]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:u})]}),d.jsx(Nt,{direction:s,color:e,opacity:u,lit:a})]},s)})})}function Nt({direction:t,color:e,opacity:n,lit:l}){const{position:r,rotation:s}=M.useMemo(()=>{const{head:a}=H(t),u=t==="+"?1:-1;return{position:new g.Vector3(Math.cos(a)*T,Math.sin(a)*T,0),rotation:new g.Quaternion().setFromUnitVectors(Y,new g.Vector3(-Math.sin(a)*u,Math.cos(a)*u,0))}},[t]);return d.jsxs("mesh",{position:r,quaternion:s,scale:l?1.2:1,children:[d.jsx("coneGeometry",{args:[Z,I,20]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:n})]})}function $t(t){const{disabled:e,label:n,overlay:l,size:r}=t,s=$.useTheme(),{gripPx:a,labelFontPx:u}=F(r);return d.jsxs(d.Fragment,{children:[E.JOG_AXES.map(o=>d.jsx(R,{component:"span","aria-hidden":!0,ref:_(l,tt(o)),sx:{position:"absolute",transform:"translate(-50%, -50%)",pointerEvents:"none",fontSize:u,color:V(o),opacity:e?.4:1},children:o.toUpperCase()},o)),E.JOG_AXES.flatMap(o=>E.JOG_DIRECTIONS.map(i=>{const x={axis:o,direction:i},c=rt(x,t);return d.jsx(R,{component:"button",type:"button",ref:_(l,O(x)),disabled:e,"aria-label":n(x),"aria-pressed":c.pressed,...ct(x,t),sx:{position:"absolute",height:a,transformOrigin:"0 50%",padding:0,borderRadius:`${a/2}px`,border:"none",background:at(V(o),c),"&:focus-visible":{outline:it(s)},...q(e)}},O(x))}))]})}function Ct(t){const e=[];for(const n of E.JOG_AXES)for(const l of E.JOG_DIRECTIONS){const r=J[n].clone().multiplyScalar(l==="+"?1:-1).applyQuaternion(t);e.push({axis:n,direction:l,x:r.x+0,y:-r.y+0,depth:r.z})}return e}function Jt(t,e){const{radiusPx:n,gripPx:l,innerPx:r,beyondTipPx:s,minTipPx:a,headLength:u}=e,o=t.map(c=>{const h=Math.hypot(c.x,c.y)*n;return{tip:h,angle:Math.atan2(c.y,c.x),start:r,end:h+s,depth:c.depth,grabbed:h>=a}});for(const[c,h]of o.entries())for(const m of o.slice(c+1)){if(!h.grabbed||!m.grabbed)continue;const[p,f]=h.tip<=m.tip?[h,m]:[m,h],y=h.angle-m.angle,b=p.tip*Math.abs(Math.sin(y));if(Math.cos(y)<=0||b>=l)continue;const S=f.tip*(1-u);if(p.tip>S){const A=h.depth<m.depth?h:m;A.grabbed=!1}else{const A=(p.tip+S)/2;p.end=Math.min(p.end,A),f.start=Math.max(f.start,A)}}const i=o.map((c,h)=>h);i.sort((c,h)=>o[c].depth-o[h].depth);const x=new Map(i.map((c,h)=>[c,h+1]));return o.map((c,h)=>!c.grabbed||c.end<=c.start?null:{x:Math.cos(c.angle)*c.start,y:Math.sin(c.angle)*c.start,length:c.end-c.start,angle:c.angle,layer:x.get(h)??0})}const W=.035,K=1.28;function zt({orientation:t,lit:e,disabled:n,size:l,radius:r,overlay:s}){const a=M.useRef(null),u=l/2;return ht(t,a,o=>{let i=!0;const x=Ct(o),c=Jt(x,yt(l,r));for(const[h,m]of x.entries()){const p=s.current.get(O(m)),f=c[h];if(p?f?(p.style.left=`${u+f.x}px`,p.style.top=`${u+f.y}px`,p.style.width=`${f.length}px`,p.style.transform=`translateY(-50%) rotate(${f.angle}rad)`,p.style.zIndex=String(f.layer),p.style.pointerEvents=""):p.style.pointerEvents="none":i=!1,m.direction!=="+")continue;const y=s.current.get(tt(m.axis));y?(y.style.left=`${u+m.x*r*K}px`,y.style.top=`${u+m.y*r*K}px`):i=!1}return i},`${l}:${r}`),d.jsxs("group",{ref:a,children:[d.jsxs("mesh",{children:[d.jsx("sphereGeometry",{args:[.07,16,16]}),d.jsx("meshBasicMaterial",{color:"#c4c8d0"})]}),E.JOG_AXES.map(o=>d.jsx(qt,{axis:o,color:V(o),lit:(e==null?void 0:e.axis)===o?e.direction:null,disabled:n},o))]})}function qt({axis:t,color:e,lit:n,disabled:l}){const r=M.useMemo(()=>new g.Quaternion().setFromUnitVectors(Y,J[t]),[t]),s=1-I;return d.jsx("group",{quaternion:r,children:E.JOG_DIRECTIONS.map(a=>{const u=n===a,o=u?1:l?.35:.8,i=u?W*1.5:W;return d.jsxs("group",{rotation:[a==="+"?0:Math.PI,0,0],children:[d.jsxs("mesh",{position:[0,s/2,0],children:[d.jsx("cylinderGeometry",{args:[i,i,s,12]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:o})]}),d.jsxs("mesh",{position:[0,1-I/2,0],scale:u?1.2:1,children:[d.jsx("coneGeometry",{args:[Z,I,20]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:o})]})]},a)})})}const Dt=new g.Quaternion;function Ht(t,e=Dt){const n=M.useRef(e);return n.current=e,M.useMemo(()=>{const l=new g.Quaternion;return{get current(){const r=t.current;if(!r)return null;const s=n.current;return Et(r,typeof s=="function"?s():s,l)}}},[t])}const Lt=3e3;function Bt(t){const[e,n]=M.useState(()=>t.current!==null);return M.useEffect(()=>{if(e)return;let l=requestAnimationFrame(function s(){t.current!==null?n(!0):l=requestAnimationFrame(s)});const r=setTimeout(()=>{t.current===null&&console.warn("JoggingGizmo has no orientation, so it stays disabled. Put a JoggingGizmoOrientation with the same ref into the app's 3D scene.")},Lt);return()=>{cancelAnimationFrame(l),clearTimeout(r)}},[e,t]),e}const Qt=pt.externalizeComponent(({orientation:t,frameQuaternion:e,motion:n="translate",onJogStart:l,onJogStop:r,activeHandle:s,disabled:a=!1,size:u=200})=>{const o=Bt(t),i=a||!o,x=Ht(t,e),{held:c,handlersFor:h,label:m,isPressed:p}=E.useJogControls({motion:n,onJogStart:l,onJogStop:r,activeHandle:s,disabled:i}),[f,y]=M.useState(null);M.useEffect(()=>y(null),[n]);const b=n==="rotate"?Vt:zt,S=n==="rotate"?jt:$t,A=M.useRef(new Map),w=xt(u,u,F(u).marginPx);return d.jsxs(R,{"data-testid":"jogging-gizmo",sx:{position:"relative",width:u,height:u,flexShrink:0,isolation:"isolate"},children:[d.jsx(z.Canvas,{orthographic:!0,flat:!0,frameloop:"demand",camera:{position:[0,0,10],up:[0,1,0],zoom:w,near:.1,far:100},gl:{alpha:!0,antialias:!0},style:{position:"absolute",inset:0,pointerEvents:"none"},children:d.jsx(b,{orientation:x,lit:c??s??f,disabled:i,size:u,radius:w,overlay:A})}),d.jsx(S,{isPressed:p,hovered:f,disabled:i,size:u,onHover:y,handlersFor:h,label:m,overlay:A})]})});exports.JoggingGizmo=Qt;exports.novaAxesSeenBy=Mt;
@@ -1 +1 @@
1
- "use strict";const n=require("@react-three/fiber"),o=require("three"),t=require("./JoggingGizmo-B7JRrD75.cjs");function u({target:e}){const r=n.useThree(i=>i.camera);return n.useFrame(()=>{e.current=t.novaAxesSeenBy(r,e.current??new o.Quaternion)}),null}exports.JoggingGizmoOrientation=u;
1
+ "use strict";const n=require("@react-three/fiber"),o=require("three"),t=require("./JoggingGizmo-xvCp3LCB.cjs");function u({target:e}){const r=n.useThree(i=>i.camera);return n.useFrame(()=>{e.current=t.novaAxesSeenBy(r,e.current??new o.Quaternion)}),null}exports.JoggingGizmoOrientation=u;
@@ -1,6 +1,6 @@
1
1
  import { useThree as o, useFrame as m } from "@react-three/fiber";
2
2
  import { Quaternion as t } from "three";
3
- import { n as a } from "./JoggingGizmo-B2e8sWhW.js";
3
+ import { n as a } from "./JoggingGizmo-CR-9mcYX.js";
4
4
  function s({
5
5
  target: r
6
6
  }) {
@@ -1 +1 @@
1
- "use strict";const u=require("react/jsx-runtime"),w=require("@mui/material/Box"),P=require("@mui/material/Stack"),J=require("@mui/material/styles"),z=require("@mui/material/Typography"),h=require("react"),tt=require("./externalizeComponent-Cr89LZ90.cjs"),S=require("./holdSafety-BtoZ5We3.cjs"),I=2*Math.PI;function nt({min:t,max:n,linear:o},f){const s=t!==void 0,c=n!==void 0;if(s&&c&&n>t)return{min:t,max:n};if(o)return null;if(s&&!c)return{min:t,max:t+I};if(c&&!s)return{min:n-I,max:n};const b=Math.round(f/I)*I;return{min:b-Math.PI,max:b+Math.PI}}function G(t,n){return Math.min(1,Math.max(0,(t-n.min)/(n.max-n.min)))}function et(t,n){const o=Math.min(1,Math.max(0,t));return n.min+o*(n.max-n.min)}function ot(t){return t.min>0||t.max<0?null:G(0,t)}function O(t,n,o){return Math.abs(n-t)<=o?null:n>t?"+":"-"}function rt(t,n,o){return o==="+"?t>=n:t<=n}function it(t,n){return t?"mm":n}const L={deg:{shown:t=>t*180/Math.PI,decimals:1,limitDecimals:0,suffix:"°"},rad:{shown:t=>t,decimals:3,limitDecimals:2,suffix:" rad"},mm:{shown:t=>t,decimals:1,limitDecimals:0,suffix:" mm"}};function W(t,n){const o=t.toFixed(n);return Number(o)===0?0 .toFixed(n):o}function v(t,n){return L[n].shown(t)}function st(t,n){const{shown:o,decimals:f,suffix:s}=L[n];return`${W(o(t),f)}${s}`}function K(t,n){const{shown:o,limitDecimals:f,suffix:s}=L[n],c=10**f,b=o(t),d=Math.sign(b)*Math.round(Math.abs(b)*c)/c;return`${d>0?"+":""}${W(d,f)}${s}`}const N=16,U=4;function V({railRef:t,at:n,goalAt:o,held:f,zeroAt:s,limits:c,disabled:b}){const d=J.useTheme(),x=d.palette.primary.main,l=`0 0 0 8px ${J.alpha(x,.16)}`;return u.jsxs(u.Fragment,{children:[u.jsxs(w,{ref:t,sx:{position:"absolute",left:0,right:0,top:"50%",height:U,transform:"translateY(-50%)"},children:[u.jsx(w,{sx:{position:"absolute",inset:0,borderRadius:U/2,backgroundColor:J.alpha(x,.38)}}),n!==null&&o!==null&&u.jsx(w,{sx:{position:"absolute",top:0,bottom:0,borderRadius:U/2,backgroundColor:x},style:{left:`${Math.min(n,o)*100}%`,width:`${Math.abs(o-n)*100}%`,opacity:f?1:.5}}),s!==null&&u.jsx(w,{"aria-hidden":!0,sx:{position:"absolute",top:"50%",width:2,height:12,transform:"translate(-50%, -50%)",borderRadius:1,backgroundColor:"text.secondary"},style:{left:`${s*100}%`}}),n!==null&&u.jsx(w,{sx:{position:"absolute",top:"50%",boxSizing:"border-box",width:N,height:N,transform:"translate(-50%, -50%)",borderRadius:"50%",border:`3px solid ${x}`,backgroundColor:"background.paper",boxShadow:f?l:d.shadows[2],transition:"box-shadow 150ms","&:hover":b?{}:{boxShadow:l}},style:{left:`${n*100}%`}})]}),c&&u.jsx(P,{direction:"row",sx:{position:"absolute",left:0,right:0,top:30,justifyContent:"space-between"},children:[c.min,c.max].map((k,j)=>u.jsx(z,{variant:"caption",color:"text.secondary",sx:{fontSize:10,lineHeight:"14px"},children:k},j))})]})}function ut({value:t,onJogStart:n,onJogStop:o,disabled:f}){const s=h.useRef(null),[c,b]=h.useState(null),d=h.useCallback(e=>{s.current=e,b(e)},[]),x=h.useRef({value:t,onJogStart:n,onJogStop:o});x.current={value:t,onJogStart:n,onJogStop:o};const l=h.useCallback((e,m,g)=>{const y=O(x.current.value,m,g);d({...e,goal:m,direction:y,settledAt:y?null:e.settledAt}),e.direction&&e.direction!==y&&x.current.onJogStop(),y&&y!==e.direction&&x.current.onJogStart(y)},[d]),k=h.useCallback(()=>s.current!==null,[]),j=h.useCallback((e,m,g)=>f||s.current?!1:(l({goal:e,direction:null,settledAt:null,by:g},e,m),!0),[f,l]),M=h.useCallback((e,m)=>{const g=s.current;if(g){if(g.direction===null&&g.settledAt!==null&&Math.abs(e-g.settledAt)<=m){d({...g,goal:e});return}l(g,e,m)}},[l,d]),C=h.useCallback(()=>{const e=s.current;e&&(d(null),e.direction&&x.current.onJogStop())},[d]),D=h.useCallback(()=>{var e;return((e=s.current)==null?void 0:e.by)??null},[]),$=h.useCallback(e=>{const m=s.current;m&&e(m.by)&&C()},[C]);return h.useEffect(()=>{const e=s.current;e!=null&&e.direction&&rt(t,e.goal,e.direction)&&(d({...e,direction:null,settledAt:e.goal}),x.current.onJogStop())},[t,d]),S.useEndHoldWhenUnattended(c!==null,f,C),{hold:c,isHolding:k,heldBy:D,begin:j,moveGoal:M,end:C,endIfHeldBy:$}}function lt(t){return t==="mouse"||t==="pen"?1:4}function at(t){return t==="ArrowRight"||t==="ArrowUp"?"+":t==="ArrowLeft"||t==="ArrowDown"?"-":null}const ct=tt.externalizeComponent(({label:t,name:n,value:o,min:f,max:s,linear:c=!1,angleUnit:b="deg",onJogStart:d,onJogStop:x,disabled:l=!1})=>{const k=J.useTheme(),j=h.useRef(null),{hold:M,isHolding:C,heldBy:D,begin:$,moveGoal:e,end:m,endIfHeldBy:g}=ut({value:o,onJogStart:d,onJogStop:x,disabled:l}),[y,q]=h.useState(null);h.useEffect(()=>{l&&q(null)},[l]);const a=nt({min:f,max:s,linear:c},o),R=it(c,b),B=r=>st(r,R);function E({clientX:r,pointerType:i}){if(!a||!j.current)return null;const p=j.current.getBoundingClientRect();return p.width<=0?null:{goal:et((r-p.left)/p.width,a),deadband:lt(i)/p.width*(a.max-a.min)}}function Y(r){var p,H;if(!S.startsPointerHold(r)||l||C())return;const i=E(r);if(i){try{(H=(p=r.currentTarget).setPointerCapture)==null||H.call(p,r.pointerId)}catch{}$(i.goal,i.deadband,{pointer:r.pointerId})}}function Z(r){const i=E(r);q(l?null:(i==null?void 0:i.goal)??null);const p=D();if(!(!p||!("pointer"in p)||p.pointer!==r.pointerId)){if(S.primaryReleased(r)){m();return}i&&e(i.goal,i.deadband)}}function T(r){g(i=>"pointer"in i&&i.pointer===r.pointerId)}function _(r){const i=at(r.key);if(i&&r.preventDefault(),C()){S.endsHold(r)&&m();return}if(!i||!S.startsKeyHold(r)||l||!a)return;const p=i==="+"?a.max:a.min,H=(a.max-a.min)*1e-4;O(o,p,H)===i&&$(p,H,{key:r.key})}function Q(r){g(i=>"key"in i&&i.key===r.key)}const A=(M==null?void 0:M.goal)??y,X=a&&{min:K(a.min,R),max:K(a.max,R)},F=u.jsxs(P,{direction:"row",sx:{justifyContent:"space-between",gap:1,mb:"-4px"},children:[u.jsxs(z,{variant:"body2",noWrap:!0,children:[t,n&&u.jsx(w,{component:"span",sx:{color:"text.secondary"},children:` - ${n}`})]}),u.jsxs(z,{variant:"body2",sx:{fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},children:[B(o),a&&A!==null&&u.jsx(w,{component:"span",sx:{color:"text.secondary"},children:` / ${B(A)}`})]})]});return a?u.jsxs(P,{"data-testid":"jogging-joint-slider",children:[F,u.jsx(w,{role:"slider",tabIndex:l?-1:0,"aria-label":n?`${t} ${n}`:t,"aria-valuemin":v(a.min,R),"aria-valuemax":v(a.max,R),"aria-valuenow":v(o,R),"aria-valuetext":B(o),"aria-disabled":l||void 0,onPointerDown:Y,onPointerMove:Z,onPointerLeave:()=>q(null),onPointerUp:T,onPointerCancel:T,onLostPointerCapture:T,onKeyDown:_,onKeyUp:Q,onBlur:m,onContextMenu:S.preventContextMenu,sx:{position:"relative",height:44,borderRadius:1,opacity:l?.5:1,cursor:l?"default":"pointer",touchAction:"none",userSelect:"none",outline:"none","&:focus-visible":{outline:`2px solid ${k.palette.primary.main}`,outlineOffset:"2px"}},children:u.jsx(V,{railRef:j,at:G(o,a),goalAt:A===null?null:G(A,a),held:M!==null,zeroAt:ot(a),limits:X??void 0,disabled:l})})]}):u.jsxs(P,{"data-testid":"jogging-joint-slider",children:[F,u.jsx(w,{"aria-hidden":!0,sx:{position:"relative",height:44},children:u.jsx(V,{at:null,goalAt:null,held:!1,zeroAt:null,disabled:!0})})]})});exports.JoggingJointSlider=ct;
1
+ "use strict";const u=require("react/jsx-runtime"),w=require("@mui/material/Box"),P=require("@mui/material/Stack"),J=require("@mui/material/styles"),z=require("@mui/material/Typography"),h=require("react"),tt=require("./externalizeComponent-BBWF9CMB.cjs"),S=require("./holdSafety-BtoZ5We3.cjs"),I=2*Math.PI;function nt({min:t,max:n,linear:o},f){const s=t!==void 0,c=n!==void 0;if(s&&c&&n>t)return{min:t,max:n};if(o)return null;if(s&&!c)return{min:t,max:t+I};if(c&&!s)return{min:n-I,max:n};const b=Math.round(f/I)*I;return{min:b-Math.PI,max:b+Math.PI}}function G(t,n){return Math.min(1,Math.max(0,(t-n.min)/(n.max-n.min)))}function et(t,n){const o=Math.min(1,Math.max(0,t));return n.min+o*(n.max-n.min)}function ot(t){return t.min>0||t.max<0?null:G(0,t)}function O(t,n,o){return Math.abs(n-t)<=o?null:n>t?"+":"-"}function rt(t,n,o){return o==="+"?t>=n:t<=n}function it(t,n){return t?"mm":n}const L={deg:{shown:t=>t*180/Math.PI,decimals:1,limitDecimals:0,suffix:"°"},rad:{shown:t=>t,decimals:3,limitDecimals:2,suffix:" rad"},mm:{shown:t=>t,decimals:1,limitDecimals:0,suffix:" mm"}};function W(t,n){const o=t.toFixed(n);return Number(o)===0?0 .toFixed(n):o}function v(t,n){return L[n].shown(t)}function st(t,n){const{shown:o,decimals:f,suffix:s}=L[n];return`${W(o(t),f)}${s}`}function K(t,n){const{shown:o,limitDecimals:f,suffix:s}=L[n],c=10**f,b=o(t),d=Math.sign(b)*Math.round(Math.abs(b)*c)/c;return`${d>0?"+":""}${W(d,f)}${s}`}const N=16,U=4;function V({railRef:t,at:n,goalAt:o,held:f,zeroAt:s,limits:c,disabled:b}){const d=J.useTheme(),x=d.palette.primary.main,l=`0 0 0 8px ${J.alpha(x,.16)}`;return u.jsxs(u.Fragment,{children:[u.jsxs(w,{ref:t,sx:{position:"absolute",left:0,right:0,top:"50%",height:U,transform:"translateY(-50%)"},children:[u.jsx(w,{sx:{position:"absolute",inset:0,borderRadius:U/2,backgroundColor:J.alpha(x,.38)}}),n!==null&&o!==null&&u.jsx(w,{sx:{position:"absolute",top:0,bottom:0,borderRadius:U/2,backgroundColor:x},style:{left:`${Math.min(n,o)*100}%`,width:`${Math.abs(o-n)*100}%`,opacity:f?1:.5}}),s!==null&&u.jsx(w,{"aria-hidden":!0,sx:{position:"absolute",top:"50%",width:2,height:12,transform:"translate(-50%, -50%)",borderRadius:1,backgroundColor:"text.secondary"},style:{left:`${s*100}%`}}),n!==null&&u.jsx(w,{sx:{position:"absolute",top:"50%",boxSizing:"border-box",width:N,height:N,transform:"translate(-50%, -50%)",borderRadius:"50%",border:`3px solid ${x}`,backgroundColor:"background.paper",boxShadow:f?l:d.shadows[2],transition:"box-shadow 150ms","&:hover":b?{}:{boxShadow:l}},style:{left:`${n*100}%`}})]}),c&&u.jsx(P,{direction:"row",sx:{position:"absolute",left:0,right:0,top:30,justifyContent:"space-between"},children:[c.min,c.max].map((k,j)=>u.jsx(z,{variant:"caption",color:"text.secondary",sx:{fontSize:10,lineHeight:"14px"},children:k},j))})]})}function ut({value:t,onJogStart:n,onJogStop:o,disabled:f}){const s=h.useRef(null),[c,b]=h.useState(null),d=h.useCallback(e=>{s.current=e,b(e)},[]),x=h.useRef({value:t,onJogStart:n,onJogStop:o});x.current={value:t,onJogStart:n,onJogStop:o};const l=h.useCallback((e,m,g)=>{const y=O(x.current.value,m,g);d({...e,goal:m,direction:y,settledAt:y?null:e.settledAt}),e.direction&&e.direction!==y&&x.current.onJogStop(),y&&y!==e.direction&&x.current.onJogStart(y)},[d]),k=h.useCallback(()=>s.current!==null,[]),j=h.useCallback((e,m,g)=>f||s.current?!1:(l({goal:e,direction:null,settledAt:null,by:g},e,m),!0),[f,l]),M=h.useCallback((e,m)=>{const g=s.current;if(g){if(g.direction===null&&g.settledAt!==null&&Math.abs(e-g.settledAt)<=m){d({...g,goal:e});return}l(g,e,m)}},[l,d]),C=h.useCallback(()=>{const e=s.current;e&&(d(null),e.direction&&x.current.onJogStop())},[d]),D=h.useCallback(()=>{var e;return((e=s.current)==null?void 0:e.by)??null},[]),$=h.useCallback(e=>{const m=s.current;m&&e(m.by)&&C()},[C]);return h.useEffect(()=>{const e=s.current;e!=null&&e.direction&&rt(t,e.goal,e.direction)&&(d({...e,direction:null,settledAt:e.goal}),x.current.onJogStop())},[t,d]),S.useEndHoldWhenUnattended(c!==null,f,C),{hold:c,isHolding:k,heldBy:D,begin:j,moveGoal:M,end:C,endIfHeldBy:$}}function lt(t){return t==="mouse"||t==="pen"?1:4}function at(t){return t==="ArrowRight"||t==="ArrowUp"?"+":t==="ArrowLeft"||t==="ArrowDown"?"-":null}const ct=tt.externalizeComponent(({label:t,name:n,value:o,min:f,max:s,linear:c=!1,angleUnit:b="deg",onJogStart:d,onJogStop:x,disabled:l=!1})=>{const k=J.useTheme(),j=h.useRef(null),{hold:M,isHolding:C,heldBy:D,begin:$,moveGoal:e,end:m,endIfHeldBy:g}=ut({value:o,onJogStart:d,onJogStop:x,disabled:l}),[y,q]=h.useState(null);h.useEffect(()=>{l&&q(null)},[l]);const a=nt({min:f,max:s,linear:c},o),R=it(c,b),B=r=>st(r,R);function E({clientX:r,pointerType:i}){if(!a||!j.current)return null;const p=j.current.getBoundingClientRect();return p.width<=0?null:{goal:et((r-p.left)/p.width,a),deadband:lt(i)/p.width*(a.max-a.min)}}function Y(r){var p,H;if(!S.startsPointerHold(r)||l||C())return;const i=E(r);if(i){try{(H=(p=r.currentTarget).setPointerCapture)==null||H.call(p,r.pointerId)}catch{}$(i.goal,i.deadband,{pointer:r.pointerId})}}function Z(r){const i=E(r);q(l?null:(i==null?void 0:i.goal)??null);const p=D();if(!(!p||!("pointer"in p)||p.pointer!==r.pointerId)){if(S.primaryReleased(r)){m();return}i&&e(i.goal,i.deadband)}}function T(r){g(i=>"pointer"in i&&i.pointer===r.pointerId)}function _(r){const i=at(r.key);if(i&&r.preventDefault(),C()){S.endsHold(r)&&m();return}if(!i||!S.startsKeyHold(r)||l||!a)return;const p=i==="+"?a.max:a.min,H=(a.max-a.min)*1e-4;O(o,p,H)===i&&$(p,H,{key:r.key})}function Q(r){g(i=>"key"in i&&i.key===r.key)}const A=(M==null?void 0:M.goal)??y,X=a&&{min:K(a.min,R),max:K(a.max,R)},F=u.jsxs(P,{direction:"row",sx:{justifyContent:"space-between",gap:1,mb:"-4px"},children:[u.jsxs(z,{variant:"body2",noWrap:!0,children:[t,n&&u.jsx(w,{component:"span",sx:{color:"text.secondary"},children:` - ${n}`})]}),u.jsxs(z,{variant:"body2",sx:{fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},children:[B(o),a&&A!==null&&u.jsx(w,{component:"span",sx:{color:"text.secondary"},children:` / ${B(A)}`})]})]});return a?u.jsxs(P,{"data-testid":"jogging-joint-slider",children:[F,u.jsx(w,{role:"slider",tabIndex:l?-1:0,"aria-label":n?`${t} ${n}`:t,"aria-valuemin":v(a.min,R),"aria-valuemax":v(a.max,R),"aria-valuenow":v(o,R),"aria-valuetext":B(o),"aria-disabled":l||void 0,onPointerDown:Y,onPointerMove:Z,onPointerLeave:()=>q(null),onPointerUp:T,onPointerCancel:T,onLostPointerCapture:T,onKeyDown:_,onKeyUp:Q,onBlur:m,onContextMenu:S.preventContextMenu,sx:{position:"relative",height:44,borderRadius:1,opacity:l?.5:1,cursor:l?"default":"pointer",touchAction:"none",userSelect:"none",outline:"none","&:focus-visible":{outline:`2px solid ${k.palette.primary.main}`,outlineOffset:"2px"}},children:u.jsx(V,{railRef:j,at:G(o,a),goalAt:A===null?null:G(A,a),held:M!==null,zeroAt:ot(a),limits:X??void 0,disabled:l})})]}):u.jsxs(P,{"data-testid":"jogging-joint-slider",children:[F,u.jsx(w,{"aria-hidden":!0,sx:{position:"relative",height:44},children:u.jsx(V,{at:null,goalAt:null,held:!1,zeroAt:null,disabled:!0})})]})});exports.JoggingJointSlider=ct;
@@ -4,7 +4,7 @@ import J from "@mui/material/Stack";
4
4
  import { useTheme as Y, alpha as N } from "@mui/material/styles";
5
5
  import G from "@mui/material/Typography";
6
6
  import { useRef as L, useState as Z, useCallback as y, useEffect as _ } from "react";
7
- import { e as it } from "./externalizeComponent-BbDa5SzK.js";
7
+ import { e as it } from "./externalizeComponent-DBRjUP0q.js";
8
8
  import { u as st, p as at, b as lt, a as ut, e as ct, s as dt } from "./holdSafety-Di1GZAWg.js";
9
9
  const k = 2 * Math.PI;
10
10
  function ft({ min: t, max: n, linear: r }, d) {