@wandelbots/wandelbots-js-react-components 6.3.0-pr.ci-nova-dev-instance.642.2e11f62 → 6.3.0-pr.feat-RB-4575-v7-cleanup.644.0feb6ca

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 (89) hide show
  1. package/README.md +24 -0
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +0 -3
  4. package/dist/3d.js +16 -21
  5. package/dist/SafetyBar/index.cjs +1 -1
  6. package/dist/SafetyBar/index.js +1 -1
  7. package/dist/chunks/ConnectedMotionGroup-BewSDQvD.cjs +4 -0
  8. package/dist/chunks/ConnectedMotionGroup-D6-4wBkk.js +2654 -0
  9. package/dist/chunks/Robot-CKQKy_Dr.cjs +1 -0
  10. package/dist/chunks/Robot-THGqCJEj.js +1265 -0
  11. package/dist/chunks/{SafetyBar-Cy9DiXp9.js → SafetyBar-C2-H1ifP.js} +1 -1
  12. package/dist/chunks/{SafetyBar-DPrv_OQA.cjs → SafetyBar-Cq_WsuK2.cjs} +1 -1
  13. package/dist/chunks/externalizeComponent-Bue3-Wra.cjs +2 -0
  14. package/dist/chunks/{externalizeComponent-EDymnaGR.js → externalizeComponent-C0cVcPE2.js} +29 -107
  15. package/dist/chunks/useSmoothedMotionState-COMJRcOt.js +214 -0
  16. package/dist/chunks/useSmoothedMotionState-Con0E5Bx.cjs +1 -0
  17. package/dist/components/AppHeader.d.ts +1 -1
  18. package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +1 -1
  19. package/dist/components/jogging/JoggingJointTab.d.ts +1 -1
  20. package/dist/components/jogging/JoggingPanel.d.ts +6 -3
  21. package/dist/components/jogging/JoggingStore.d.ts +5 -1
  22. package/dist/components/jogging/joggingColors.d.ts +18 -0
  23. package/dist/components/robots/GenericRobot.d.ts +2 -1
  24. package/dist/components/robots/LinearAxis.d.ts +1 -1
  25. package/dist/components/robots/LinearAxisAnimator.d.ts +11 -2
  26. package/dist/components/robots/Robot.d.ts +1 -1
  27. package/dist/components/robots/robotModelLogic.d.ts +12 -1
  28. package/dist/components/utils/hooks.d.ts +1 -6
  29. package/dist/core.cjs +1 -1
  30. package/dist/core.d.ts +3 -18
  31. package/dist/core.js +27 -54
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.js +39 -71
  34. package/dist/lib/ConnectedMotionGroup.d.ts +5 -7
  35. package/dist/lib/JoggerConnection.d.ts +29 -5
  36. package/dist/lib/MotionStreamConnection.d.ts +4 -6
  37. package/dist/lib/novaConnection.d.ts +23 -0
  38. package/package.json +30 -46
  39. package/dist/Setup.d.ts +0 -11
  40. package/dist/chunks/MotionGroupVisualizer-DshWR1wY.js +0 -1653
  41. package/dist/chunks/MotionGroupVisualizer-eD7yFEcF.cjs +0 -1
  42. package/dist/chunks/externalizeComponent-OO4jcrz5.cjs +0 -2
  43. package/dist/chunks/theming-DfSy4-Ic.cjs +0 -4
  44. package/dist/chunks/theming-mF9Rt8SS.js +0 -5542
  45. package/dist/chunks/useSmoothedMotionState-DyDgSVYX.js +0 -478
  46. package/dist/chunks/useSmoothedMotionState-VYxEIyfr.cjs +0 -1
  47. package/dist/components/AdornedTextField.d.ts +0 -7
  48. package/dist/components/CopyableText.d.ts +0 -6
  49. package/dist/components/CycleTimer/CycleTimer.d.ts +0 -3
  50. package/dist/components/CycleTimer/DefaultVariant.d.ts +0 -9
  51. package/dist/components/CycleTimer/SmallVariant.d.ts +0 -10
  52. package/dist/components/CycleTimer/index.d.ts +0 -27
  53. package/dist/components/CycleTimer/types.d.ts +0 -49
  54. package/dist/components/CycleTimer/useAnimations.d.ts +0 -14
  55. package/dist/components/CycleTimer/useTimerLogic.d.ts +0 -24
  56. package/dist/components/CycleTimer/utils.d.ts +0 -21
  57. package/dist/components/CycleTimer.d.ts +0 -3
  58. package/dist/components/DataGrid.d.ts +0 -66
  59. package/dist/components/LogPanel.d.ts +0 -38
  60. package/dist/components/LogStore.d.ts +0 -12
  61. package/dist/components/LogViewer.d.ts +0 -46
  62. package/dist/components/ProgramControl.d.ts +0 -55
  63. package/dist/components/ProgramStateIndicator.d.ts +0 -26
  64. package/dist/components/RobotCard.d.ts +0 -98
  65. package/dist/components/RobotListItem.d.ts +0 -34
  66. package/dist/components/RobotSetupReadinessIndicator.d.ts +0 -37
  67. package/dist/components/SelectableFab.d.ts +0 -7
  68. package/dist/components/TabBar.d.ts +0 -45
  69. package/dist/components/ThemeSelect.d.ts +0 -6
  70. package/dist/components/Timer/Timer.d.ts +0 -3
  71. package/dist/components/Timer/TimerDefaultVariant.d.ts +0 -9
  72. package/dist/components/Timer/TimerSmallVariant.d.ts +0 -10
  73. package/dist/components/Timer/index.d.ts +0 -19
  74. package/dist/components/Timer/types.d.ts +0 -35
  75. package/dist/components/Timer/useTimerAnimations.d.ts +0 -10
  76. package/dist/components/Timer/useTimerLogic.d.ts +0 -19
  77. package/dist/components/Timer/utils.d.ts +0 -17
  78. package/dist/components/Timer.d.ts +0 -3
  79. package/dist/components/TransparentOverlay.d.ts +0 -4
  80. package/dist/components/jogging/PoseCartesianValues.d.ts +0 -9
  81. package/dist/components/jogging/PoseJointValues.d.ts +0 -8
  82. package/dist/components/robots/AxisConfig.d.ts +0 -2
  83. package/dist/components/robots/manufacturerHomePositions.d.ts +0 -20
  84. package/dist/icons/DropdownArrowIcon.d.ts +0 -2
  85. package/dist/icons/index.d.ts +0 -12
  86. package/dist/lib/novaCompat.d.ts +0 -16
  87. package/dist/themes/createDarkTheme.d.ts +0 -7
  88. package/dist/themes/themeTypes.d.ts +0 -40
  89. package/dist/themes/theming.d.ts +0 -24
package/README.md CHANGED
@@ -258,6 +258,30 @@ WANDELAPI_BASE_URL=http://<instance-ip>
258
258
  CELL_ID=cell
259
259
  ```
260
260
 
261
+ ### e2e Tests
262
+
263
+ The e2e tests run against a real NOVA instance. There are two kinds:
264
+
265
+ - The vitest tests in `e2e/` test the NOVA connections of the library (motion state, jogging), without a browser.
266
+ - The Playwright tests in `e2e/playground/` test the playground app in Chromium. First they add a virtual robot with 2 safety zones and a stored collision setup to the cell. Then they open each page of the playground, jog the robot, check the values, the 3D view and the safety bar, and take screenshots. At the end, they remove the robot and the collision setup again.
267
+
268
+ Both kinds use the same instance values:
269
+
270
+ - `NOVA_INSTANCE_URL`, and `NOVA_ACCESS_TOKEN` for a cloud instance, or
271
+ - `WANDELAPI_BASE_URL` in `.env.local`, which `pnpm td` writes for a test instance (see above).
272
+
273
+ Without an instance, the tests fail. To run them on your computer:
274
+
275
+ ```bash
276
+ pnpm exec playwright install chromium # once, for the Playwright tests
277
+ pnpm run test:e2e # vitest
278
+ pnpm run test:playground # builds the playground, then runs Playwright
279
+ ```
280
+
281
+ The built playground (`playground/dist`) contains the URL and the access token of the instance, so `test:playground` builds it again each time. Never publish or upload it. The results and the screenshots of the Playwright tests are in `e2e-results/`.
282
+
283
+ For each pull request, the workflow `e2e` creates a NOVA cloud instance with the newest released NOVA version, runs both kinds of tests, and deletes the instance again. The results are in the artifact `e2e-results` of the run: the output and the reports of the tests, the screenshots of the playground (`screenshots/`), and the state of the instance after the tests. The summary of the job lists the tests and the screenshots.
284
+
261
285
  ### Local Testing
262
286
 
263
287
  Build and test the package locally:
package/dist/3d.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/MotionGroupVisualizer-eD7yFEcF.cjs"),o=require("./chunks/useSmoothedMotionState-VYxEIyfr.cjs");exports.CollisionSceneRenderer=e.CollisionSceneRenderer;exports.JointLimitGizmo=e.JointLimitGizmo;exports.LinearAxis=e.LinearAxis;exports.MANUFACTURER_HOME_CONFIGS=e.MANUFACTURER_HOME_CONFIGS;exports.MotionGroupVisualizer=e.MotionGroupVisualizer;exports.MotionGroupVisualizerExact=e.MotionGroupVisualizerExact;exports.PresetEnvironment=e.PresetEnvironment;exports.Robot=e.Robot;exports.RobotCard=e.RobotCard;exports.SafetyZonesRenderer=e.SafetyZonesRenderer;exports.SupportedLinearAxis=e.SupportedLinearAxis;exports.SupportedLinearAxisExact=e.SupportedLinearAxisExact;exports.SupportedRobot=e.SupportedRobot;exports.SupportedRobotExact=e.SupportedRobotExact;exports.TrajectoryRenderer=e.TrajectoryRenderer;exports.defaultAxisConfig=e.defaultAxisConfig;exports.defaultGetModel=e.defaultGetModel;exports.extractManufacturer=e.extractManufacturer;exports.getDefaultHomeConfig=e.getDefaultHomeConfig;exports.ValueInterpolator=o.ValueInterpolator;exports.useSmoothedMotionState=o.useSmoothedMotionState;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/Robot-CKQKy_Dr.cjs"),o=require("./chunks/useSmoothedMotionState-Con0E5Bx.cjs");exports.CollisionSceneRenderer=e.CollisionSceneRenderer;exports.JointLimitGizmo=e.JointLimitGizmo;exports.LinearAxis=e.LinearAxis;exports.MotionGroupVisualizer=e.MotionGroupVisualizer;exports.MotionGroupVisualizerExact=e.MotionGroupVisualizerExact;exports.PresetEnvironment=e.PresetEnvironment;exports.Robot=e.Robot;exports.SafetyZonesRenderer=e.SafetyZonesRenderer;exports.SupportedLinearAxis=e.SupportedLinearAxis;exports.SupportedLinearAxisExact=e.SupportedLinearAxisExact;exports.SupportedRobot=e.SupportedRobot;exports.SupportedRobotExact=e.SupportedRobotExact;exports.TrajectoryRenderer=e.TrajectoryRenderer;exports.defaultGetModel=e.defaultGetModel;exports.ValueInterpolator=o.ValueInterpolator;exports.useSmoothedMotionState=o.useSmoothedMotionState;
package/dist/3d.d.ts CHANGED
@@ -3,10 +3,7 @@ export { JointLimitGizmo, type GizmoChainOffset, type GizmoDhParameter, type Giz
3
3
  export * from "./components/3d-viewport/PresetEnvironment";
4
4
  export * from "./components/3d-viewport/SafetyZonesRenderer";
5
5
  export * from "./components/3d-viewport/TrajectoryRenderer";
6
- export * from "./components/RobotCard";
7
- export * from "./components/robots/AxisConfig";
8
6
  export * from "./components/robots/LinearAxis";
9
- export { extractManufacturer, getDefaultHomeConfig, MANUFACTURER_HOME_CONFIGS, } from "./components/robots/manufacturerHomePositions";
10
7
  export * from "./components/robots/MotionGroupVisualizer";
11
8
  export * from "./components/robots/Robot";
12
9
  export { defaultGetModel } from "./components/robots/robotModelLogic";
package/dist/3d.js CHANGED
@@ -1,25 +1,20 @@
1
- import { C as o, J as t, L as r, M as s, a as i, b as n, P as u, R as d, c as p, S as f, d as l, e as x, f as R, g as S, T as c, h as M, i as m, j as C, k as A } from "./chunks/MotionGroupVisualizer-DshWR1wY.js";
2
- import { V as b, g } from "./chunks/useSmoothedMotionState-DyDgSVYX.js";
1
+ import { C as a, J as t, L as r, M as s, a as i, P as n, R as p, S as d, b as u, c as S, d as l, e as x, T as R, f as c } from "./chunks/Robot-THGqCJEj.js";
2
+ import { V as f, a as L } from "./chunks/useSmoothedMotionState-COMJRcOt.js";
3
3
  export {
4
- o as CollisionSceneRenderer,
4
+ a as CollisionSceneRenderer,
5
5
  t as JointLimitGizmo,
6
6
  r as LinearAxis,
7
- s as MANUFACTURER_HOME_CONFIGS,
8
- i as MotionGroupVisualizer,
9
- n as MotionGroupVisualizerExact,
10
- u as PresetEnvironment,
11
- d as Robot,
12
- p as RobotCard,
13
- f as SafetyZonesRenderer,
14
- l as SupportedLinearAxis,
15
- x as SupportedLinearAxisExact,
16
- R as SupportedRobot,
17
- S as SupportedRobotExact,
18
- c as TrajectoryRenderer,
19
- b as ValueInterpolator,
20
- M as defaultAxisConfig,
21
- m as defaultGetModel,
22
- C as extractManufacturer,
23
- A as getDefaultHomeConfig,
24
- g as useSmoothedMotionState
7
+ s as MotionGroupVisualizer,
8
+ i as MotionGroupVisualizerExact,
9
+ n as PresetEnvironment,
10
+ p as Robot,
11
+ d as SafetyZonesRenderer,
12
+ u as SupportedLinearAxis,
13
+ S as SupportedLinearAxisExact,
14
+ l as SupportedRobot,
15
+ x as SupportedRobotExact,
16
+ R as TrajectoryRenderer,
17
+ f as ValueInterpolator,
18
+ c as defaultGetModel,
19
+ L as useSmoothedMotionState
25
20
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/SafetyBar-DPrv_OQA.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-Cq_WsuK2.cjs");exports.SafetyBar=e.SafetyBar;exports.default=e.SafetyBar;
@@ -1,4 +1,4 @@
1
- import { S as f, S as r } from "../chunks/SafetyBar-Cy9DiXp9.js";
1
+ import { S as f, S as r } from "../chunks/SafetyBar-C2-H1ifP.js";
2
2
  export {
3
3
  f as SafetyBar,
4
4
  r as default
@@ -0,0 +1,4 @@
1
+ "use strict";const i=require("react/jsx-runtime"),Jt=require("@mui/material/AppBar"),xt=require("@mui/material/Backdrop"),L=require("@mui/material/Box"),Rt=require("@mui/material/Menu"),$=require("@mui/material/MenuItem"),Ot=require("@mui/material/Toolbar"),_=require("@mui/material/Typography"),Pt=require("@wandelbots/design-tokens"),At=require("@wandelbots/icons/ExpandMoreFilled"),Vt=require("@wandelbots/mui"),T=require("mobx-react-lite"),C=require("react"),W=require("./externalizeComponent-Bue3-Wra.cjs"),Dt=require("@mui/icons-material/OpenWith"),Lt=require("@mui/icons-material/Share"),v=require("@mui/material/Stack"),qt=require("@mui/material/Tab"),Bt=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"),yt=require("@mui/material/CircularProgress"),Ft=require("@mui/material/utils"),bt=require("lodash-es"),$t=require("./SafetyBar-Cq_WsuK2.cjs"),Nt=require("@mui/material/Alert"),zt=require("@mui/material/AlertTitle"),it=require("@mui/material/Button"),q=require("@mui/material/styles"),N=require("@mui/material/Divider"),dt=require("@mui/material/ToggleButton"),X=require("@mui/material/IconButton"),Gt=require("lodash-es/isEqual.js"),Ut=require("@mui/material/InputAdornment"),Wt=require("@mui/material/FormControl"),Ht=require("@mui/material/InputLabel"),Yt=require("@mui/material/Select"),Y=require("lodash-es/keyBy.js"),Zt=require("lodash-es/uniqueId.js"),Xt=require("@mui/material/ToggleButtonGroup"),jt=require("@mui/material/Slider"),Kt=require("lodash-es/isNumber.js"),Qt=require("@mui/icons-material/ChevronLeft"),te=require("@mui/icons-material/ChevronRight"),ee=require("lodash-es/throttle.js"),oe=require("@mui/material/Dialog"),ne=require("@mui/material/DialogActions"),ie=require("@mui/material/DialogContent"),re=require("@mui/material/DialogTitle"),rt=require("three");function St(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const S=St(C),ut=St(rt),ae=W.externalizeComponent(T.observer(e=>{const{appIcon:t,appName:o,apps:n=[],onAppSelect:r,disabled:a=!1,sx:l}=e,[s,u]=C.useState(null),g=!!s,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 i.jsxs(i.Fragment,{children:[i.jsx(Jt,{position:"static",sx:{boxShadow:"none",backgroundImage:"none","& .MuiAppBar-root":{backgroundImage:"none",backgroundColor:"transparent"},...l},children:i.jsxs(Ot,{sx:{minHeight:"62px !important"},children:[i.jsx(L,{sx:{mr:1,display:"flex",alignItems:"center"},children:t}),i.jsxs(L,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[i.jsx(_,{component:"h1",variant:"subtitle1",children:o}),n.length>0&&i.jsx(Vt.RoundedIconButton,{icon:i.jsx(At.ExpandMoreFilled,{size:20}),ariaLabel:"switch app","aria-controls":"app-menu","aria-haspopup":"true",onClick:p,disabled:a,sx:{ml:1}})]})]})}),i.jsx(xt,{open:g,onClick:h,sx:{backdropFilter:"blur(4px)",backgroundColor:Pt.ZeroGravityComponentsBackdropFill,zIndex:c=>c.zIndex.modal-1}}),i.jsx(Rt,{id:"app-menu",anchorEl:s,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:n.map(c=>i.jsxs($,{onClick:()=>d(c),children:[i.jsx(L,{sx:{display:"flex",alignItems:"center"},children:c.icon}),i.jsx(_,{variant:"body1",sx:{ml:2},children:c.name})]},c.id))})]})})),se=({title:e,titleId:t,...o},n)=>S.createElement("svg",{width:21,height:21,viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...o},e?S.createElement("title",{id:t},e):null,S.createElement("g",{id:"JogMinus"},S.createElement("path",{id:"Minus",d:"M0 13V8H21V13H0Z",fill:"white"}))),le=C.forwardRef(se),ce=({title:e,titleId:t,...o},n)=>S.createElement("svg",{width:21,height:21,viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...o},e?S.createElement("title",{id:t},e):null,S.createElement("g",{id:"JogPlus"},S.createElement("g",{id:"Plus"},S.createElement("path",{d:"M0 13V8H8V13H0Z",fill:"white"}),S.createElement("path",{d:"M8 0L13 2.18557e-07L13 21H8L8 0Z",fill:"white"}),S.createElement("path",{d:"M13 13V8H21V13H13Z",fill:"white"})))),ge=C.forwardRef(ce),at=W.externalizeComponent(T.observer(({colors:e,label:t,getDisplayedValue:o,startJogging:n,stopJogging:r,disabled:a,activeJoggingDirection:l,...s})=>{var w,E,R,k,O,B,F;A.useAnimationFrame(()=>{const J=o(),P=d.current;P&&(P.textContent=J)});const u=q.useTheme(),[g,p]=C.useState(null);C.useEffect(()=>{a&&I()},[a]);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:(B=e.buttonBackgroundColor)==null?void 0:B.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor},":disabled":{backgroundColor:(F=e.buttonBackgroundColor)==null?void 0:F.pressed,"svg path":{fill:u.palette.action.disabled}}};function b(J,P){a||J.button===0&&(p(P),n(P))}function I(){p(null),r()}return i.jsxs(v,{height:"64px",direction:"row",justifyContent:"center",...s,children:[i.jsx(X,{disabled:a,disableRipple:!0,onPointerDown:J=>b(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:i.jsx(le,{})}),i.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:[i.jsx(v,{height:"22px",direction:"row",alignItems:"center",justifyItems:"center",spacing:1,sx:{userSelect:"none",color:e.color,".MuiTypography-root":{fontWeight:700,...a?{color:u.palette.action.disabled}:{}},...a?{"svg path":{fill:u.palette.action.disabled}}:{}},children:t}),i.jsx(_,{height:"22px",sx:{fontSize:"15px",color:a?u.palette.action.disabled:e.color,fontWeight:700,fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center"},ref:d,children:o()})]}),i.jsx(X,{disableRipple:!0,disabled:a,onPointerDown:J=>b(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:i.jsx(ge,{})})]})})),U="rgba(255, 255, 255, 1)",nt={X:{backgroundColor:"rgba(215, 66, 56, 1)",borderColor:"rgba(215, 66, 56, 1)",buttonBackgroundColor:{default:"rgba(241, 77, 66, 1)",pressed:"rgba(138, 41, 35, 1)",hovered:"rgba(241, 77, 66, 1)",disabled:"rgba(241, 77, 66, 1)"},color:"rgba(255, 198, 198, 1)",labelColor:U},Y:{backgroundColor:"rgba(20, 151, 108, 1)",borderColor:"rgba(20, 151, 108, 1)",buttonBackgroundColor:{default:"rgba(28, 188, 135, 1)",pressed:"rgba(11, 89, 63, 1)",disabled:"rgba(28, 188, 135, 1)",hovered:"rgba(28, 188, 135, 1)"},color:"rgba(215, 255, 242, 1)",labelColor:U},Z:{backgroundColor:"rgba(1, 87, 155, 1)",borderColor:"rgba(1, 87, 155, 1)",buttonBackgroundColor:{default:"rgba(2, 136, 209, 1)",pressed:"rgba(2, 64, 114, 1)",disabled:"rgba(2, 136, 209, 1)",hovered:"rgba(2, 136, 209, 1)"},color:"rgba(210, 239, 255, 1)",labelColor:U}},ht=U,de=U,vt=W.externalizeComponent(T.observer(({startJogging:e,stopJogging:t,lowerLimit:o,upperLimit:n,useDegree:r,getValue:a,disabled:l,...s})=>{var k,O,B,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(j){this.activeJoggingDir=j,e(j)},stopJogging(){this.activeJoggingDir=null,t()}})),f=ee(()=>{const j=r?x(a()):a();(j===void 0||g===void 0||Math.abs(g-j)>1e-9)&&p(j)},50);A.useAnimationFrame(f);function x(j){if(j!==void 0)return M.radiansToDegrees(j)}function m(j){j.button===0&&c.startJogging("-")}function b(j){j.button===0&&c.startJogging("+")}function I(j){c.stopJogging()}function w(j){c.stopJogging()}function E(j,z=1){if(j===void 0||Number.isNaN(j))return"";const G=u("General.degree.variable",{amount:j.toFixed(z)});return j>0&&z===0?`+${G}`:G}function R(j,z=1){if(j===void 0||Number.isNaN(j))return"";const G=u("General.mm.variable",{amount:j.toFixed(z)});return j>0&&z===0?`+${G}`:G}return i.jsxs(v,{height:"64px",width:"100%",maxWidth:"260px",direction:"row",...s,sx:{"& .MuiIconButton-root":{width:"52px",color:h.palette.text.primary,alignContent:"center",backgroundColor:(B=h.palette.backgroundPaperElevation)==null?void 0:B[11],"& svg":{width:"42px",height:"42px"},"&.Mui-disabled":{backgroundColor:(F=h.palette.backgroundPaperElevation)==null?void 0:F[11],color:h.palette.action.disabled,opacity:1},"&:hover":{backgroundColor:(J=h.palette.backgroundPaperElevation)==null?void 0:J[9]},"&:active":{...d}}},children:[i.jsx(X,{onPointerDown:m,onPointerUp:I,onPointerOut:w,disabled:l,disableRipple:!0,sx:{borderRadius:"16px 0px 0px 16px",...c.activeJoggingDir==="-"?d:{}},children:i.jsx(Qt,{sx:{pointerEvents:"none",color:ht}})}),i.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:[i.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)}),i.jsx(jt,{disabled:!0,"aria-label":"Joint position",min:r?x(o):o,max:r?x(n):n,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&&n!==void 0&&[{value:r?x(o):o,label:r?E(x(o),0):R(o)},{value:r?x(n):n,label:r?E(x(n),0):R(n)}]})]}),i.jsx(X,{onPointerDown:b,onPointerUp:I,onPointerOut:w,disabled:l,disableRipple:!0,sx:{borderRadius:"0px 16px 16px 0px",...c.activeJoggingDir==="+"?d:{}},children:i.jsx(te,{sx:{pointerEvents:"none",color:ht}})})]})}));function lt(e,t,o){if(t.length!==e.length)return!0;for(let n=0;n<t.length;n++)if(Math.abs(t[n]-e[n])>o)return!1;return!0}function Ct(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 n=0;return n+=Math.abs(e.orientation[0]-t.orientation[0]),n+=Math.abs(e.orientation[1]-t.orientation[1]),n+=Math.abs(e.orientation[2]-t.orientation[2]),n+=Math.abs(e.position[0]-t.position[0]),n+=Math.abs(e.position[1]-t.position[1]),n+=Math.abs(e.position[2]-t.position[2]),n<=o}function ct(e,t,o){return e.coordinate_system===t.coordinate_system&&e.tcp===t.tcp&&Ct(e.tcp_pose,t.tcp_pose,o)}function It(e,t){const o=new rt.Vector3(t[0],t[1],t[2]),n=new rt.Vector3(e[0],e[1],e[2]),r=o.length(),a=o.normalize();let l=n.length(),s=n.normalize();s.dot(a)<0&&(l=-l,s=s.multiplyScalar(-1));let u=l-r;return u-=2*Math.PI*Math.floor((u+Math.PI)/(2*Math.PI)),l=r+u,[...s.multiplyScalar(l)]}const mt=1e-4;class Q{constructor(t,o,n,r,a,l,s="cell"){this.controller=o,this.motionGroup=n,this.description=r,this.initialMotionState=a,this.motionStateSocket=l,this.cellId=s,this.nova=A.createNovaClient(t),this.rapidlyChangingMotionState=a,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}`);lt(this.rapidlyChangingMotionState.joint_position,g.joint_position,mt)||y.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=g.joint_position}),ct(this.rapidlyChangingMotionState,g,mt)||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:It(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,n={}){var f;const r=A.createNovaClient(t),a=n.cellId??A.cellIdOf(t)??"cell",[l,s]=o.split("@"),u=await r.api.controller.getCurrentRobotControllerState(a,s),g=u==null?void 0:u.motion_groups.find(x=>x.motion_group===o);if(!u||!g)throw new Error(`Controller ${s} or motion group ${o} not found`);const p=r.openReconnectingWebsocket(`/cells/${a}/controllers/${s}/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
+ `,d);const c=await r.api.motionGroup.getMotionGroupDescription(a,s,g.motion_group);return new Q(r,u,g,c,d,p,a)}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 pt="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,n={}){const r=await Q.open(t,o,{cellId:n.cellId}),a=new tt(r,n);a.ownsMotionStream=!0;try{await a.setJoggingMode(a.mode)}catch(l){throw a.dispose(),l}return a}getDefaultTcp(t){var n,r;const o=(r=(n=t.description.dh_parameters)==null?void 0:n[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(n=>n!==null);return t.forEach(n=>{n.dispose()}),this.joggingSocket=null,this.trajectorySocket=null,Promise.all(t.map(n=>n.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 n=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`);this.joggingSocket=n;let r=!1;const a=setTimeout(()=>{l(new Error(`Jogging initialization timeout after ${this.timeout} ms`))},this.timeout),l=g=>{r||(r=!0,clearTimeout(a),n.removeEventListener("close",u),this.endJoggingInit===s&&(this.endJoggingInit=void 0),g?o(g):t())},s=()=>l(),u=()=>{n.disposed&&l()};this.endJoggingInit=s,n.addEventListener("close",u),n.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(pt))){l(),n.dispose(),this.onBlocked();return}else this.onError?(l(),this.onError(g.data)):l(new Error(g.data))}),n.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:t,direction:o,velocityValue:n,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 a=new Array(this.numJoints).fill(0);a[t]=o==="-"?-n:n,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:a})}async translateTCP({axis:t,direction:o,velocityMmPerSec:n}){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],a=[0,0,0];a[M.XYZ_TO_VECTOR[t]]=o==="-"?-n:n,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:a,rotation:r,use_tool_coordinate_system:this.orientation==="tool"})}async rotateTCP({axis:t,direction:o,velocityRadsPerSec:n}){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],a=[0,0,0];r[M.XYZ_TO_VECTOR[t]]=o==="-"?-n:n,this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:a,rotation:r,use_tool_coordinate_system:this.orientation==="tool"})}async runIncrementalCartesianMotion({currentTcpPose:t,currentJoints:o,velocityInRelevantUnits:n,axis:r,direction:a,motion:l}){const s=[];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*(a==="-"?-1:1),s.push({limits_override:{tcp_velocity_limit:n},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]),b=m.length(),I=m.clone().normalize(),w=l.distanceRads*(a==="-"?-1:1),E=new ot.Vector3(0,0,0);E[r]=1;const R=Math.cos(.5*w)*Math.cos(.5*b),k=Math.sin(.5*w)*Math.sin(.5*b),O=Math.sin(.5*w)*Math.cos(.5*b),B=Math.cos(.5*w)*Math.sin(.5*b),F=E.dot(I),J=E.clone().cross(I),P=2*Math.acos(R-k*F),H=P/Math.sin(.5*P),j=new ot.Vector3().addScaledVector(J,k).addScaledVector(E,O).addScaledVector(I,B).multiplyScalar(H);s.push({limits_override:{tcp_orientation_velocity_limit:n},path:{path_definition_name:"PathLine",target_pose:{position:t.position,orientation:[...j]}}})}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:s}),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 b;if(!m||m.add_trajectory_error||m.message)if(this.onError)this.onError(m);else throw new Error(((b=m==null?void 0:m.add_trajectory_error)==null?void 0:b.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 b=M.tryParseJson(m.data);if(!((I=b==null?void 0:b.result)!=null&&I.kind))throw new Error(`Failed to execute trajectory: Received invalid message ${m.data}`);if(this.onBlocked&&((w=b.result.message)!=null&&w.includes(pt))){this.onBlocked();return}if(b.result.kind==="INITIALIZE_RECEIVED")d(b.result);else if(b.result.kind==="START_RECEIVED")x(b);else if(b.result.kind!=="PAUSE_RECEIVED")if(b.result.kind==="MOTION_ERROR"&&b.result.message)if(this.onError){this.onError(b);return}else throw new Error(b.result.message);else throw new Error(`Failed to execute trajectory, cannot handle message type "${b.result.kind}"`)}),this.trajectorySocket.sendJson({message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.motionGroupId,data:h,tcp:this.tcp}})}}const wt=e=>{const t=e.softTimeout||3e3,[o,n]=C.useState(!1);return C.useEffect(()=>{const r=setTimeout(()=>{n(!0)},t);return()=>clearTimeout(r)}),i.jsx(v,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:"text.primary"},children:e.error?i.jsx(Mt,{loadingMessage:e.message,error:e.error}):i.jsxs(i.Fragment,{children:[i.jsx(yt,{sx:{mb:3}}),!!e.message&&i.jsx(_,{variant:"body1",children:e.message}),i.jsx(_,{variant:"body2",sx:{visibility:o?"visible":"hidden",mt:2,color:"text.secondary"},children:"This is taking longer than expected..."})]})})},Mt=e=>{const t=$t.makeErrorMessage(e.error),o=e.error instanceof Error?e.error.stack:null;return i.jsxs(v,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",p:2,overflow:"auto",color:"error.main"},children:[i.jsx(_,{variant:"body1",children:(e.loadingMessage?`Error while ${bt.lowerFirst(Ft.capitalize(e.loadingMessage))} - `:"")+t}),o&&i.jsx(L,{component:"pre",sx:{typography:"body2",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",mt:2,pb:6},children:o})]})},ue=T.observer(({store:e})=>{const{t}=V.useTranslation();return i.jsx(xt,{"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:i.jsxs(v,{sx:{m:2,width:"100%"},children:[i.jsxs(Nt,{severity:"error",sx:{mb:2},children:[i.jsx(zt,{children:t("Jogging.Blocked.ti")}),t("Jogging.Blocked.lb")]}),i.jsx(it,{variant:"contained",color:"secondary",onClick:()=>e.unblock(),children:t("Jogging.Blocked.Reenable.bt")})]})})}),he=({title:e,titleId:t,...o},n)=>S.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:n,"aria-labelledby":t,...o},e?S.createElement("title",{id:t},e):null,S.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"})),me=C.forwardRef(he),pe=({title:e,titleId:t,...o},n)=>S.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:n,"aria-labelledby":t,...o},e?S.createElement("title",{id:t},e):null,S.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"})),fe=C.forwardRef(pe),xe=({title:e,titleId:t,...o},n)=>S.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:10,height:19,fill:"none",ref:n,"aria-labelledby":t,...o},e?S.createElement("title",{id:t},e):null,S.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"})),ye=C.forwardRef(xe),be=({title:e,titleId:t,...o},n)=>S.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...o},e?S.createElement("title",{id:t},e):null,S.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"})),je=C.forwardRef(be),_t=T.observer(({store:e})=>{const{t}=V.useTranslation(),[o,n]=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;Gt(r.current,l)||(r.current=l,n(l))});const a=[];for(const[l,s]of o.entries())s&&a.push(l);return i.jsx(L,{sx:{display:"flex",flexDirection:"row",justifyContent:"center"},children:i.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:a.length?"visible":"hidden"},children:t("Jogging.JointLimitsReached.lb",{jointNumbers:a.map(l=>l+1).join(", ")})})})}),Se=q.styled(Wt)(({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 i.jsxs(Se,{fullWidth:!0,variant:"filled",children:[i.jsx(Ht,{id:t.labelId,children:e}),i.jsx(Yt,{...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}],ve=[{id:"continuous"},...st],Ce=["coordsys","tool"];class et{constructor(t,o,n,r,a){var l,s,u;this.jogger=t,this.coordSystems=o,this.motionGroupDescription=n,this.tcps=r,this.inverseSolverValue=a,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=a,this.jointType=((u=(s=n==null?void 0:n.dh_parameters)==null?void 0:s[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:n}=t,[r,a]=await Promise.all([o.api.controller.listCoordinateSystems(n,t.motionStream.controllerId,"ROTATION_VECTOR"),o.api.motionGroup.getMotionGroupDescription(n,t.motionStream.controllerId,t.motionGroupId)]),l=await o.api.motionGroupModels.getMotionGroupKinematicModel(a.motion_group_model),s=Object.entries(a.tcps||{}).map(([u,g])=>({id:u,readable_name:g.name,position:g.pose.position,orientation:g.pose.orientation}));return new et(t,r||[],a,s,l.inverse_solver)}dispose(){for(const t of this.disposers)t();this.jogger.dispose()}get coordSystemCountByName(){return bt.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 ve}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 n=this.tabs[o]||this.tabs[0];this.selectedTabId=n.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,n=this.jogger.mode!=="jogging";try{this.jogger.tcp=t,n?await this.jogger.setJoggingMode("jogging"):await this.jogger.setJoggingMode("jogging",!1);let r=await this.waitForTcpConfirmation(t,1e3);n&&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 n&&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(n=>{const r=setTimeout(()=>{a(),n(!1)},o),a=y.when(()=>this.jogger.motionStream.rapidlyChangingMotionState.tcp===t,()=>{clearTimeout(r),n(!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=Zt();this.lock(o);try{return await t()}finally{this.unlock(o)}}}const Ie=T.observer(({store:e,useDegree:t})=>{var l;const{t:o}=V.useTranslation(),n=C.useId(),r=[];function a(s){switch(s){case"coordsys":return o("Jogging.Orientation.coordsys");case"tool":return o("Jogging.Orientation.tool");default:return s}}return e.showCoordSystemSelect&&r.push(i.jsx(Z,{labelId:`jogging-coord-select-${n}`,labelValue:o("Jogging.CoordinateSystem.hlb"),value:e.selectedCoordSystemId,size:"small",variant:"filled",displayEmpty:!0,onChange:s=>e.setSelectedCoordSystemId(s.target.value),children:e.coordSystems.map(s=>i.jsx($,{value:s.coordinate_system,children:s.name&&e.coordSystemCountByName[s.name]>1?`${s.name} / ${s.coordinate_system}`:s.name||s.coordinate_system},s.coordinate_system))},"coord")),e.showTcpSelect&&r.push(i.jsx(Z,{labelId:`jogging-tcp-select-${n}`,labelValue:"TCP",value:e.selectedTcpId,size:"small",variant:"filled",displayEmpty:e.tcpChangeInProgress,onChange:s=>{e.requestTcpChange(s.target.value).catch(u=>{console.error("Failed to change TCP:",u)})},disabled:e.tcpChangeInProgress,endAdornment:e.tcpChangeInProgress?i.jsx(Ut,{position:"end",children:i.jsx(yt,{size:16})}):void 0,children:e.tcps.map(s=>i.jsx($,{value:s.id,children:s.id},s.id))},"tcp")),e.showOrientationSelect&&r.push(i.jsx(Z,{labelValue:o("Jogging.Cartesian.Orientation.lb"),labelId:`orientation-select-${n}`,value:e.selectedOrientation,onChange:s=>e.setSelectedOrientation(s.target.value),children:Ce.map(s=>i.jsx($,{value:s,children:a(s)},s))},"orientation")),e.showIncrementSelect&&r.push(i.jsxs(Z,{labelValue:o("Jogging.Increment.hlb"),labelId:`jogging-increment-select-${n}`,size:"small",variant:"filled",value:((l=e.activeDiscreteIncrement)==null?void 0:l.id)||"continuous",onChange:s=>e.setSelectedIncrementId(s.target.value),children:[i.jsx($,{value:"continuous",children:o("Jogging.Increment.Continuous.dd")},"continuous"),e.selectedOrientation==="tool"?null:e.discreteIncrementOptions.map(s=>i.jsx($,{value:s.id,children:t?`${s.degrees}°`:`${s.mm}mm`},s.id))]},"increment")),i.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((s,u)=>i.jsx(L,{sx:{gridColumn:r.length%2===1&&u===r.length-1?"span 2":"auto"},children:s},u))})}),we=q.styled(Xt)(({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"}}}}}),Tt=W.externalizeComponent(T.observer(e=>{const{store:t}=e,{t:o}=V.useTranslation();function n(r,a){a===e.velocity||!Kt(a)||e.onVelocityChange(a,e.useDegree)}return i.jsxs(v,{direction:"row",gap:2,alignItems:"center","data-testid":"velocity-slider","aria-label":"velocity-slider",children:[t.showVelocityLegend&&i.jsx(_,{sx:{color:de,fontSize:"14px"},children:o("Jogging.Velocity.bt")}),i.jsx(jt,{value:e.velocity,color:"secondary",onChange:n,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):i.jsx(gt,{value:e.velocity.toString()}))]})}));function gt({value:e,sx:t}){var n;const o=q.useTheme();return i.jsx(v,{direction:"row",justifyContent:"center",alignItems:"center",gap:"5px",sx:{padding:"6px 12px",background:(n=o.palette.backgroundPaperElevation)==null?void 0:n[8],borderRadius:"10px",minWidth:"111px",...t},children:i.jsx(_,{component:"span",sx:{textAlign:"right",fontSize:"14px",opacity:.8,color:o.palette.text.primary,whiteSpace:"nowrap"},children:e})})}const Et=T.observer(({store:e,useDegree:t})=>{const{t:o}=V.useTranslation();function n(r,a){return a?`ω = ${o("Jogging.Cartesian.Rotation.velocityDegPerSec.lb",{amount:r})}`:`v = ${o("Jogging.Cartesian.Translation.velocityMmPerSec.lb",{amount:r})}`}return i.jsx(Tt,{store:e,velocity:e.velocityInDisplayUnits(t),min:e.minVelocityInDisplayUnits(t),max:e.maxVelocityInDisplayUnits(t),onVelocityChange:e.setVelocityFromSlider,useDegree:t,disabled:e.isLocked,renderValue:r=>i.jsx(gt,{value:n(r,t),sx:{minWidth:"111px",span:{transform:"translateY(-1.5px)"}}})})}),kt=T.observer(({store:e})=>{var r,a,l;const{t}=V.useTranslation(),o=q.useTheme(),n=((l=(a=(r=e.jogger.motionStream.rapidlyChangingMotionState.execute)==null?void 0:r.details)==null?void 0:a.state)==null?void 0:l.kind)??"KIND_UNKNOWN";return i.jsxs(L,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",color:o.palette.text.primary},children:[i.jsx(_,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},children:t("Jogging.StreamStateSection.lb")}),i.jsx(_,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},"data-testid":n,children:t(`Jogging.StreamStateSection.${n}.lb`)})]})}),Me=T.observer(({store:e,children:t})=>{const{t:o}=V.useTranslation(),n=q.useTheme(),r=C.useRef(0);function a(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 s(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:i.jsx(me,{}),colors:nt.X},{id:"y",icon:i.jsx(fe,{}),colors:nt.Y},{id:"z",icon:i.jsx(ye,{}),colors:nt.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 i.jsxs(v,{"data-testid":"jogging-cartesian-tab","aria-label":"jogging-cartesian-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[i.jsxs(v,{gap:2,children:[i.jsx(Ie,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),i.jsx(Et,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),i.jsx(N,{})]}),i.jsx(v,{marginLeft:"auto",marginRight:"auto",gap:"24px",justifyContent:"center",sx:{flexGrow:"1"},children:i.jsxs(v,{alignItems:"center",justifyContent:"center",gap:"24px",sx:{flexGrow:1},children:[i.jsxs(we,{value:e.selectedCartesianMotionType,onChange:a,exclusive:!0,"aria-label":o("Jogging.Cartesian.MotionType.lb"),sx:{justifyContent:"center"},children:[i.jsx(dt,{value:"translate",children:o("Jogging.Cartesian.Translation.bt")}),i.jsx(dt,{value:"rotate",children:o("Jogging.Cartesian.Rotation.bt")})]}),e.selectedCartesianMotionType==="translate"&&g.map(d=>{var c,f;return i.jsx(at,{"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:i.jsxs(i.Fragment,{children:[d.icon,i.jsx(_,{sx:{fontSize:"24px",color:((f=d.colors)==null?void 0:f.labelColor)??n.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=>s({axis:d.id,motionType:"translate",direction:x}),stopJogging:u},d.id)}),e.selectedCartesianMotionType==="rotate"&&g.map(d=>{var c,f;return i.jsx(at,{"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:i.jsxs(i.Fragment,{children:[i.jsx(je,{}),i.jsx(_,{sx:{fontSize:"24px",color:((f=d.colors)==null?void 0:f.labelColor)??n.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=>s({axis:d.id,motionType:"rotate",direction:x}),stopJogging:u},d.id)})]})}),i.jsx(_t,{store:e}),i.jsx(N,{}),i.jsx(kt,{store:e}),t&&i.jsx(N,{}),t]})}),_e=T.observer(({store:e,children:t})=>{const o=q.useTheme(),n=C.useRef(0);async function r(l){const s=++n.current;try{if(await e.activate(),s!==n.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 a(){n.current++,await e.jogger.stop(),await e.deactivate()}return i.jsxs(v,{"data-testid":"jogging-joint-tab","aria-label":"jogging-joint-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[i.jsx(Et,{store:e,useDegree:e.jointType===D.JointTypeEnum.RevoluteJoint}),i.jsx(N,{}),i.jsx(v,{justifyContent:"center",alignItems:"stretch",sx:{flexGrow:"1"},children:i.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 s=(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 i.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&&i.jsx(_,{color:e.isLocked?o.palette.text.disabled:o.palette.text.secondary,children:`G${l.index+1}`}),i.jsx(vt,{disabled:e.isLocked,lowerLimit:s==null?void 0:s.lower_limit,upperLimit:s==null?void 0:s.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:a})]},`joint-${l.index}`)})})}),i.jsx(_t,{store:e}),i.jsx(N,{}),i.jsx(kt,{store:e}),t&&i.jsx(N,{}),t]})}),Te=W.externalizeComponent(T.observer(e=>{const t=T.useLocalObservable(()=>({joggingStore:null,loadingError:null}));return C.useEffect(()=>{let o=!1,n;async function r(){y.runInAction(()=>{t.loadingError=null,t.joggingStore=null});try{let a=e.store;if(!a){const l=await tt.open(e.nova,e.motionGroupId,{cellId:e.cellId});if(o){l.dispose();return}try{a=await et.loadFor(l)}catch(s){throw l.dispose(),s}if(n=a,o){a.dispose();return}}y.runInAction(()=>{t.joggingStore=a}),e.onSetup&&e.onSetup(a)}catch(a){if(o)return;y.runInAction(()=>{t.loadingError=a})}}return r(),()=>{o=!0,n==null||n.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]),i.jsx(v,{"data-testid":"jogging-panel","aria-label":"jogging-panel",sx:{maxWidth:"460px",minWidth:"320px",position:"relative",...e.sx},children:t.joggingStore?i.jsx(Ee,{store:t.joggingStore,children:e.children}):i.jsx(wt,{message:"Loading jogging",error:t.loadingError})})})),Ee=T.observer(({store:e,children:t})=>{const{t:o}=V.useTranslation();function n(){if(e.currentTab.id==="cartesian")return i.jsx(Me,{store:e,children:t});if(e.currentTab.id==="joint")return i.jsx(_e,{store:e,children:t})}return i.jsxs(v,{flexGrow:1,sx:{overflow:"hidden"},children:[i.jsx(Bt,{"data-testid":"jogging-tabs","aria-label":"jogging-tabs",value:e.tabIndex,onChange:e.onTabChange,variant:"fullWidth",children:e.tabs.map(r=>{const a=r.label==="Cartesian"?o("Jogging.Cartesian.bt"):o("Jogging.Joints.bt"),l=r.label==="cartesian"?i.jsx(Dt,{fontSize:"small",sx:{mr:1}}):i.jsx(Lt,{fontSize:"small",sx:{mr:1}});return i.jsx(qt,{"data-testid":`jogging-tab-${r.id}`,"aria-label":`jogging-tab-${r.id}`,label:e.showTabIcons?i.jsxs(v,{direction:"row",alignItems:"center",children:[l,a]}):a,id:`jogging-tab-${r.id}`,"aria-controls":`jogging-tab-${r.id}`},r.id)})}),i.jsx(v,{flexGrow:1,position:"relative",sx:{overflowY:"auto",overflowX:"hidden"},children:n()}),e.blocked&&i.jsx(ue,{store:e})]})});function ke(){const e=window.location.href;return e.substring(0,e.indexOf("/",e.indexOf("//")+2))}function Je({baseUrl:e=ke(),...t}){return i.jsxs(oe,{"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:[i.jsx(re,{id:"no-motion-group-modal-title",children:"No motion group found"}),i.jsxs(ie,{sx:{marginTop:"3rem",marginBottom:"1.5rem",textAlign:"center"},children:[i.jsx(_,{color:"#fff",children:"Found no devices to connect to."}),i.jsx(_,{color:"#fff",children:"Please ensure a motion group has been created."})]}),i.jsx(ne,{children:i.jsxs(v,{width:"100%",maxWidth:"300px",margin:"auto",marginBottom:"2rem",children:[i.jsx(it,{href:`${e}/settings`,variant:"contained",sx:{borderRadius:"8px",width:"100%"},children:"Go to settings app"}),i.jsx(it,{href:`${e}`,variant:"text",sx:{marginTop:"1rem",color:"#fff",textDecoration:"underline",fontSize:"0.75rem"},children:"Back to Homescreen"})]})})]})}const ft=1e-4,Re={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class K{constructor(t,o,n,r,a,l,s,u,g,p,h="cell"){this.controller=o,this.motionGroup=n,this.initialMotionState=r,this.motionStateSocket=a,this.isVirtual=l,this.tcps=s,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})}),a.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}`);lt(this.rapidlyChangingMotionState.joint_position,c.joint_position,ft)||y.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=c.joint_position}),ct(this.rapidlyChangingMotionState,c,ft)||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,n={}){const r=A.createNovaClient(t),a=n.cellId??A.cellIdOf(t);return Promise.all(o.map(l=>K.connect(r,l,{...n,cellId:a})))}static async connect(t,o,n={}){var E,R;const r=A.createNovaClient(t),a=n.cellId??A.cellIdOf(t)??"cell",[l,s]=o.split("@"),u=await r.api.controller.getCurrentRobotControllerState(a,s),g=u==null?void 0:u.motion_groups.find(k=>k.motion_group===o);if(!u||!g)throw new Error(`Controller ${s} or motion group ${o} not found`);const p=r.openReconnectingWebsocket(`/cells/${a}/controllers/${s}/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
+ `,d);const f=(await r.api.controller.getRobotController(a,u.controller)).configuration.kind==="VirtualController",x=await r.api.motionGroup.getMotionGroupDescription(a,s,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})),b=r.openReconnectingWebsocket(`/cells/${a}/controllers/${u.controller}/state-stream?response_rate=1000`),I=await b.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
+ `,w),new K(r,u,g,d,p,f,m,x,w,b,a)}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=>({...Re,...t}))}get safetyZones(){return this.description.safety_zones}get mountingPosition(){var t,o,n;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,(((n=this.description.mounting.position)==null?void 0:n[2])||0)/1e3]:[0,0,0]}get mountingQuaternion(){var r,a,l,s,u,g;const t=new ut.Vector3(((a=(r=this.description.mounting)==null?void 0:r.orientation)==null?void 0:a[0])||0,((s=(l=this.description.mounting)==null?void 0:l.orientation)==null?void 0:s[1])||0,((g=(u=this.description.mounting)==null?void 0:u.orientation)==null?void 0:g[2])||0),o=t.length(),n=t.normalize();return new ut.Quaternion().setFromAxisAngle(n,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=ae;exports.ConnectedMotionGroup=K;exports.JoggerConnection=tt;exports.JoggingCartesianAxisControl=at;exports.JoggingJointValueControl=vt;exports.JoggingPanel=Te;exports.JoggingStore=et;exports.LoadingCover=wt;exports.LoadingErrorMessage=Mt;exports.MotionStreamConnection=Q;exports.NoMotionGroupModal=Je;exports.VelocitySlider=Tt;exports.VelocitySliderLabel=gt;exports.jointValuesEqual=lt;exports.poseEqual=Ct;exports.tcpMotionEqual=ct;exports.unwrapRotationVector=It;