@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.9fadf2c → 6.4.0-pr.revamp.667.fa67ce5

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 (32) hide show
  1. package/README.md +2 -0
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.js +1 -1
  4. package/dist/RobotHeader/index.cjs +1 -1
  5. package/dist/RobotHeader/index.js +1 -1
  6. package/dist/SafetyBar/index.cjs +1 -1
  7. package/dist/SafetyBar/index.js +1 -1
  8. package/dist/chunks/{Robot-BeTWgowU.cjs → Robot-B3vKEVXP.cjs} +1 -1
  9. package/dist/chunks/{Robot-D4XbngYI.js → Robot-DDD382dk.js} +1 -1
  10. package/dist/chunks/{RobotHeader-BZci9ahT.js → RobotHeader-BvIzk8Fw.js} +1 -1
  11. package/dist/chunks/{RobotHeader-CqK0700U.cjs → RobotHeader-Daft80jq.cjs} +1 -1
  12. package/dist/chunks/{SafetyBar-Bbg-o8h9.cjs → SafetyBar-BVk-SH_0.cjs} +1 -1
  13. package/dist/chunks/{SafetyBar-Cuak4ffd.js → SafetyBar-eYzCHOFD.js} +1 -1
  14. package/dist/chunks/TrajectoryExecutionStore-8yxebRg1.cjs +3 -0
  15. package/dist/chunks/{TrajectoryExecutionStore-DG2Ztg9g.js → TrajectoryExecutionStore-tZgq2ivg.js} +977 -734
  16. package/dist/chunks/converters-BsXgcxCW.cjs +1 -0
  17. package/dist/chunks/{converters-DpNB_WNQ.js → converters-D9KpJ2HD.js} +16 -8
  18. package/dist/components/jogging/JoggingStore.d.ts +29 -3
  19. package/dist/core.cjs +1 -1
  20. package/dist/core.d.ts +3 -1
  21. package/dist/core.js +41 -38
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.js +49 -46
  24. package/dist/lib/ControllerStateStream.d.ts +125 -0
  25. package/dist/lib/controllerStateSource.d.ts +37 -0
  26. package/dist/lib/nats/natsControllerStateSource.d.ts +27 -0
  27. package/dist/nats.cjs +1 -0
  28. package/dist/nats.d.ts +4 -0
  29. package/dist/nats.js +131 -0
  30. package/package.json +11 -1
  31. package/dist/chunks/TrajectoryExecutionStore-BlmjJeEw.cjs +0 -3
  32. package/dist/chunks/converters-C8I_A_tA.cjs +0 -1
package/README.md CHANGED
@@ -68,6 +68,7 @@ Browse the full icon set at https://wandelbotsgmbh.github.io/nova-design-system/
68
68
  - **`.`** (Main) — All components. Requires the peer dependencies of `/core` and `/3d`.
69
69
  - **`/core`** — The parts without 3D (jogging, `SafetyBar`, `AppHeader`, `LoadingCover`, `NoMotionGroupModal`), the NOVA connections and `JoggingStore`, the motion state helpers and `i18n`.
70
70
  - **`/3d`** — The 3D parts (`Robot`, `MotionGroupVisualizer`, `SafetyZonesRenderer`, …). Requires in addition three, three-stdlib, @react-three/fiber and @react-three/drei.
71
+ - **`/nats`** — A robot's live controller state over NOVA's NATS server (`natsControllerStateSource`, `natsUrlOf`), a source for `ControllerStateStream` of `/core` instead of its websocket (`controllerStateWebsocket`). Requires in addition nats.ws; no other entry point loads it.
71
72
  - **`/SafetyBar`** — Only `SafetyBar` (also as the default export).
72
73
  - **`/JoggingGizmo`** — Only `JoggingGizmo` (also as the default export) and `JoggingGizmoOrientation`. Requires in addition three and @react-three/fiber.
73
74
  - **`/JoggingButtons`** — Only `JoggingButtons` (also as the default export). No 3D packages needed.
@@ -94,6 +95,7 @@ import JoggingJointSlider from "@wandelbots/wandelbots-js-react-components/Joggi
94
95
  | `three-stdlib` (only `/3d`) | >=2 |
95
96
  | `@react-three/fiber` (only `/3d`, `/JoggingGizmo`, `/RobotControlPanel`) | ^9 |
96
97
  | `@react-three/drei` (only `/3d`) | ^10 |
98
+ | `nats.ws` (only `/nats`) | ^1.30.3 |
97
99
 
98
100
  These packages are peer dependencies because the app and the library must use the same copy: React, the MUI theme of the app, the MobX stores that the app reads with its own `observer`, and the `<Canvas>` of React Three Fiber.
99
101
 
package/dist/3d.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/Robot-BeTWgowU.cjs"),t=require("./chunks/JoggingGizmo-DGbFLWgT.cjs"),i=require("./chunks/JoggingGizmoOrientation-dzned4f4.cjs"),r=require("./chunks/RobotControlPanel-BXtBHEe9.cjs"),e=require("./chunks/Pose3-DIyg-aZA.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.Pose3=e.Pose3;exports.ValueInterpolator=e.ValueInterpolator;exports.parseRotationToQuaternion=e.parseRotationToQuaternion;exports.quaternionToRotationVector=e.quaternionToRotationVector;exports.useSmoothedMotionState=e.useSmoothedMotionState;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/Robot-B3vKEVXP.cjs"),t=require("./chunks/JoggingGizmo-DGbFLWgT.cjs"),i=require("./chunks/JoggingGizmoOrientation-dzned4f4.cjs"),r=require("./chunks/RobotControlPanel-BXtBHEe9.cjs"),e=require("./chunks/Pose3-DIyg-aZA.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.Pose3=e.Pose3;exports.ValueInterpolator=e.ValueInterpolator;exports.parseRotationToQuaternion=e.parseRotationToQuaternion;exports.quaternionToRotationVector=e.quaternionToRotationVector;exports.useSmoothedMotionState=e.useSmoothedMotionState;
package/dist/3d.js CHANGED
@@ -1,4 +1,4 @@
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 u, b as d, c as m, d as x, e as R, T as l, f as S } from "./chunks/Robot-D4XbngYI.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 u, b as d, c as m, d as x, e as R, T as l, f as S } from "./chunks/Robot-DDD382dk.js";
2
2
  import { J as c } from "./chunks/JoggingGizmo-SuS9MmL7.js";
3
3
  import { J as G } from "./chunks/JoggingGizmoOrientation-x_crT_64.js";
4
4
  import { R as b } from "./chunks/RobotControlPanel-BiLexAWI.js";
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/RobotHeader-CqK0700U.cjs");exports.RobotHeader=e.RobotHeader;exports.default=e.RobotHeader;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/RobotHeader-Daft80jq.cjs");exports.RobotHeader=e.RobotHeader;exports.default=e.RobotHeader;
@@ -1,4 +1,4 @@
1
- import { R as o, R as r } from "../chunks/RobotHeader-BZci9ahT.js";
1
+ import { R as o, R as r } from "../chunks/RobotHeader-BvIzk8Fw.js";
2
2
  export {
3
3
  o as RobotHeader,
4
4
  r as default
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../chunks/SafetyBar-Bbg-o8h9.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-BVk-SH_0.cjs");exports.SafetyBar=e.SafetyBar;exports.default=e.SafetyBar;
@@ -1,4 +1,4 @@
1
- import { S as f, S as r } from "../chunks/SafetyBar-Cuak4ffd.js";
1
+ import { S as f, S as r } from "../chunks/SafetyBar-eYzCHOFD.js";
2
2
  export {
3
3
  f as SafetyBar,
4
4
  r as default
@@ -1 +1 @@
1
- "use strict";const o=require("react/jsx-runtime"),w=require("three"),C=require("three-stdlib"),S=require("@react-three/drei"),m=require("react"),A=require("./converters-C8I_A_tA.cjs"),O=require("@wandelbots/nova-js/v2"),T=require("./externalizeComponent-BdxGBLIv.cjs"),L=require("./Pose3-DIyg-aZA.cjs"),D=require("react-error-boundary"),$=require("@react-three/fiber");function re(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const R=re(w);function ie(e){switch(e.shape_type){case"convex_hull":return new C.ConvexGeometry(e.vertices.map(t=>new R.Vector3(t[0]/1e3,t[1]/1e3,t[2]/1e3)));case"box":return new R.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new R.SphereGeometry(e.radius/1e3);case"capsule":return new R.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new R.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new R.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new R.BufferGeometry}}function se({name:e,collider:n,children:t}){var c,l;const r=((c=n.pose)==null?void 0:c.position)??[0,0,0],i=((l=n.pose)==null?void 0:l.orientation)??[0,0,0];return n.margin&&console.warn(`${e} margin is not supported`),o.jsx("mesh",{name:e,position:new R.Vector3(r[0],r[1],r[2]).divideScalar(1e3),rotation:new R.Euler(i[0],i[1],i[2],"XYZ"),geometry:ie(n.shape),children:t})}function ae({name:e,colliders:n,meshChildrenProvider:t,...r}){return o.jsx("group",{name:e,...r,children:Object.entries(n).map(([i,c])=>o.jsx(se,{name:i,collider:c,children:t(i,c)},i))})}function ce({scene:e,meshChildrenProvider:n}){const t=e.colliders;return o.jsx("group",{children:t&&o.jsx(ae,{meshChildrenProvider:n,colliders:t})})}function le(e){const n=(e==null?void 0:e.position)??[],t=(e==null?void 0:e.orientation)??[],r=new w.Vector3(t[0]??0,t[1]??0,t[2]??0),i=r.length(),c=i>0?new w.Quaternion().setFromAxisAngle(r.normalize(),i):new w.Quaternion;return new w.Matrix4().compose(new w.Vector3(n[0]??0,n[1]??0,n[2]??0).divideScalar(1e3),c,new w.Vector3(1,1,1))}function ue(e,n=null,t=[]){const r=le(n);return e.map((i,c)=>{const l=r.clone(),s=(i.reverse_rotation_direction?-1:1)*(t[c]??0),a=i.type==="PRISMATIC_JOINT",f=(i.theta??0)+(a?0:s),p=(i.d??0)+(a?s:0);return r.multiply(new w.Matrix4().makeRotationZ(f)).multiply(new w.Matrix4().makeTranslation((i.a??0)/1e3,0,p/1e3)).multiply(new w.Matrix4().makeRotationX(i.alpha??0)),l})}const P="#ff4b4b",q="#2fa8ff",fe="#8a8d9e",pe=96,me=.15,he=new R.Vector3(0,1,0),de=.2,xe=2;function ge(e){const{lower_limit:n,upper_limit:t}=e??{};return typeof n!="number"||typeof t!="number"||!Number.isFinite(n)||!Number.isFinite(t)||!(n<t)?null:{lower_limit:n,upper_limit:t}}function k({base:e,direction:n,size:t,color:r,opacity:i}){const c=new R.Quaternion().setFromUnitVectors(he,n.clone().normalize()),l=e.clone().addScaledVector(n.clone().normalize(),t/2);return o.jsxs("mesh",{position:l,quaternion:c,renderOrder:10,children:[o.jsx("coneGeometry",{args:[t*.35,t,16]}),o.jsx("meshBasicMaterial",{color:r,depthTest:!1,transparent:!0,opacity:i})]})}function V({points:e,color:n,width:t,opacity:r}){return o.jsx(S.Line,{points:e,color:n,lineWidth:t,depthTest:!1,transparent:!0,opacity:r,renderOrder:10})}function J(e,n){const t=[...e];let r=n;for(;t.length>1;){const i=t[t.length-1],c=t[t.length-2],l=i.distanceTo(c);if(l>r)return t[t.length-1]=i.clone().lerp(c,r/l),t;r-=l,t.pop()}return t}function ye(e,n,t,r){const i=t*e,c=t*n,l=Math.abs(c-i),s=Math.max(2,Math.ceil(l/(2*Math.PI)*pe));return Array.from({length:s+1},(a,f)=>{const p=i+(c-i)*f/s,u=l*f/s/(2*Math.PI),y=r*(1+me*u);return new R.Vector3(Math.cos(p)*y,Math.sin(p)*y,0)})}function je(e,n,t,r){const i=e.theta??0,c=e.d??0,l=e.type==="PRISMATIC_JOINT",s=e.reverse_rotation_direction?-1:1,{lower_limit:a,upper_limit:f}=n;return m.useMemo(()=>{const p=new R.Matrix4().makeRotationZ(i).multiply(new R.Matrix4().makeTranslation(0,0,l?c/1e3:0)),u=(M,_,v)=>new R.Vector3(M,_,v).applyMatrix4(p),y=new R.Vector3().applyMatrix4(p),j=u(0,0,t),d=(l?[u(t*.25,0,s*a/1e3),u(t*.25,0,s*f/1e3)]:ye(a,f,s,t*.6)).map(M=>l?M:M.applyMatrix4(p)),h=u(l?t*.25:t*.6,0,0),b=d.slice(1).reduce((M,_,v)=>M+_.distanceTo(d[v]),0),x=Math.min(r,b/3),g=J(J(d,x).reverse(),x).reverse();return{axisPoints:[y,j],axisTip:j,origin:y,restPoints:[y,h],range:d,limitPoints:g,rangeStart:g[0],rangeEnd:g[g.length-1]}},[i,c,l,s,t,a,f,r])}function we({frame:e,dh:n,limit:t,size:r,emphasis:i}){const c=i==="highlighted"?xe:1,l=i==="dimmed"?de:1,s=r*.2*(i==="highlighted"?1.4:1),a=2*c,{axisPoints:f,axisTip:p,origin:u,restPoints:y,range:j,limitPoints:d,rangeStart:h,rangeEnd:b}=je(n,t,r,s),{position:x,quaternion:g}=m.useMemo(()=>{const M=new R.Vector3,_=new R.Quaternion;return e.decompose(M,_,new R.Vector3),{position:M,quaternion:_}},[e]);return o.jsxs("group",{position:x,quaternion:g,children:[o.jsx(V,{points:f,color:q,width:a,opacity:l}),o.jsx(k,{base:p,direction:p.clone().sub(u),size:s,color:q,opacity:l}),o.jsx(V,{points:y,color:fe,width:1.5*c,opacity:l}),o.jsx(V,{points:d,color:P,width:a,opacity:l}),o.jsx(k,{base:h,direction:j[0].clone().sub(h),size:h.distanceTo(j[0]),color:P,opacity:l}),o.jsx(k,{base:b,direction:j[j.length-1].clone().sub(b),size:b.distanceTo(j[j.length-1]),color:P,opacity:l})]})}function Re({dhParameters:e,chainOffset:n=null,limits:t,jointPositions:r,size:i=.15,highlightedJoint:c=null}){const l=m.useMemo(()=>ue(e,n,r),[e,n,r]);return o.jsx("group",{children:l.map((s,a)=>{const f=ge(t[a]);return f?o.jsx(we,{frame:s,dh:e[a],limit:f,size:i,emphasis:c===null?"normal":c===a?"highlighted":"dimmed"},a):null})})}function be(){return o.jsx(S.Environment,{frames:1,children:o.jsx(Se,{})})}const Me=[2,0,2,0,2,0,2,0];function Se({positions:e=Me}){return o.jsxs(o.Fragment,{children:[o.jsx(S.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),o.jsx("group",{rotation:[0,.5,0],children:o.jsx("group",{children:e.map((n,t)=>o.jsx(S.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,t*4],scale:[3,1,1]},t))})}),o.jsx(S.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),o.jsx(S.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),o.jsx(S.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),o.jsx(S.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),o.jsx(S.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}const N={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function _e({safetyZones:e,dhParameters:n,...t}){const r=m.useMemo(()=>A.dhParametersToPlaneSize(n??[]),[n]),i=(l,s)=>{var y,j;if(!((y=s==null?void 0:s.pose)!=null&&y.position)||!((j=s==null?void 0:s.pose)!=null&&j.orientation))return null;const a=new R.Vector3(s.pose.position[0]/1e3,s.pose.position[1]/1e3,s.pose.position[2]/1e3),f=new R.Vector3(s.pose.orientation[0],s.pose.orientation[1],s.pose.orientation[2]);let p;const u=s.shape.shape_type==="plane"?{...N,side:R.DoubleSide}:{...N,side:R.FrontSide};switch(s.shape.shape_type){case"plane":p=o.jsx("planeGeometry",{args:[r,r]});break;case"sphere":{const d=(s==null?void 0:s.shape).radius/1e3;p=o.jsx("sphereGeometry",{args:[d]});break}case"capsule":{const d=(s==null?void 0:s.shape).radius/1e3,h=(s==null?void 0:s.shape).cylinder_height/1e3;p=o.jsx("capsuleGeometry",{args:[d,h]});break}case"convex_hull":{const d=(s==null?void 0:s.shape).vertices.map(b=>new R.Vector3(b[0]/1e3,b[1]/1e3,b[2]/1e3)),h=A.verticesToCoplanarity(d);if(h.isCoplanar&&h.normal){const x=new R.Vector3().addVectors(d[0],h.normal.multiplyScalar(1e-4));d.push(x)}try{p=o.jsx("primitive",{object:new C.ConvexGeometry(d),attach:"geometry"})}catch(b){return console.log("Error creating ConvexGeometry:",b),null}break}case"rectangular_capsule":{const d=s.shape,h=d.radius/1e3,b=d.sphere_center_distance_x/1e3,x=d.sphere_center_distance_y/1e3,g=h*2;p=o.jsx("primitive",{object:new C.RoundedBoxGeometry(b,x,g,2,h),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",s.shape.shape_type),p=null}return o.jsxs("mesh",{renderOrder:l,position:a,quaternion:A.orientationToQuaternion(f),children:[p,o.jsx("meshStandardMaterial",{...u,polygonOffsetFactor:-l})]},`safety-zone-${s.shape.shape_type}-${l}`)},c=m.useMemo(()=>Object.values(e??{}).map((l,s)=>i(s,l)),[e,r]);return o.jsx("group",{...t,children:c})}function ve({trajectory:e,...n}){const t=(e==null?void 0:e.map(r=>{if(r.position&&r.position.length>=3){const[i,c,l]=r.position;if(Number.isFinite(i)&&Number.isFinite(c)&&Number.isFinite(l))return new R.Vector3(i/1e3,l/1e3,-c/1e3)}return null}).filter(r=>r!==null))||[];return o.jsx("group",{...n,children:t.length>0&&o.jsx(S.Line,{points:t,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const G=new Map;async function E(e,n){const t=n||"";if(!t)throw new Error(`Cannot download the model "${e}": no NOVA instance. Give defaultGetModel the URL of the instance or a NOVA client, or give the component its instanceUrl or getModel.`);const r=`${Te(t)} ${e}`,i=G.get(r);if(i)return i;const c=(async()=>{const l=L.createNovaClient(t);try{const s=await l.api.motionGroupModels.getMotionGroupGlbModel(e,{responseType:"blob"});return URL.createObjectURL(s)}catch(s){throw console.error("Failed to fetch model:",s),s}})();return G.set(r,c),c.catch(()=>{G.get(r)===c&&G.delete(r)}),c}function Te(e){return typeof e=="string"?e:e.config.instanceUrl}function Q(e){function n(t){return t.children.length===0?[t]:[t,...t.children.flatMap(r=>n(r))]}return n(e).filter(t=>W(t))}function U(e){return e.name.endsWith("_FLG")}function W(e){return/_J[0-9]+$/.test(e.name)}function Le(e,n){let t;function r(i){if(U(i)){if(t)throw Error(`Found multiple flange groups in robot model ${n}; first ${t.name} then ${i.name}. Only one _FLG group is allowed.`);t=i}W(i),i.children.map(r)}if(r(e.scene),!t)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}const H=m.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,onTranslationChanged:c,children:l},s){const a=m.useRef(null),f=m.useRef([]),p=m.useRef(n.joint_position.filter(x=>x!==void 0)),{invalidate:u}=$.useThree(),y=m.useRef(n);y.current=n;function j(x){a.current=x,x&&d()}function d(){a.current&&(f.current=Q(a.current),h(),u())}m.useImperativeHandle(s,()=>({recollectJoints:d}));function h(){const x=p.current;if(c)c(f.current,x);else for(const[g,M]of f.current.entries()){const v=t[g].reverse_rotation_direction?-1:1;M.position.y=v*(x[g]||0)/1e3}}function b(x){p.current=x.joint_position.filter(g=>g!==void 0),h(),u()}return L.useAutorun(()=>{b(y.current)}),o.jsx("group",{ref:j,position:r,quaternion:i,children:l})});function B({rapidlyChangingMotionState:e,dhParameters:n,...t}){const r=new w.Matrix4,i=m.useRef(null),c=m.useRef(null);function l(f){const p=new w.Matrix4;for(let d=0;d<n.length;d++){const h=n[d],b=f[d]??0,x=new w.Matrix4().makeRotationY(h.theta).multiply(new w.Matrix4().makeTranslation(h.a/1e3,(h.d+b*(h.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new w.Matrix4().makeRotationX(h.alpha));p.multiply(x)}const u=new w.Vector3,y=new w.Quaternion,j=new w.Vector3;return p.decompose(u,y,j),u}const s=l(e.joint_position);function a(f,p){r.identity();let u=new w.Vector3;for(let h=0;h<n.length;h++){const b=p[h]??0,x=n[h],g=new w.Matrix4().makeRotationY(x.theta).multiply(new w.Matrix4().makeTranslation(x.a/1e3,(x.d+b*(x.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new w.Matrix4().makeRotationX(x.alpha));r.multiply(g)}const y=new w.Vector3,j=new w.Quaternion,d=new w.Vector3;if(r.decompose(y,j,d),u=y,i.current&&i.current.position.set(u.x,u.y,u.z),c.current){const h=c.current.geometry;h!=null&&h.setPositions&&h.setPositions([0,0,0,u.x,u.y,u.z])}}return o.jsx(H,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:a,children:o.jsxs("group",{...t,name:"Scene",children:[o.jsxs("mesh",{name:"Base",position:[0,0,0],children:[o.jsx("sphereGeometry",{args:[.02,32,32]}),o.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),o.jsx(S.Line,{ref:c,points:[new w.Vector3(0,0,0),s],color:"White",lineWidth:5}),o.jsxs("mesh",{ref:i,name:"TCP",position:s,children:[o.jsx("sphereGeometry",{args:[.025,32,32]}),o.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}const Ee=console.warn;function X(){return m.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Ee(e)}},[]),null}function Oe(e){return e.type==="Mesh"}function Ge({url:e,flangeRef:n,postModelRender:t,...r}){const i=S.useGLTF(e),l=Le(i,"robot.glb").gltf;m.useEffect(()=>{t==null||t()},[e,t]);function s(a){try{return Oe(a)?a.geometry?o.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):o.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid):o.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:U(a)?n:void 0,children:a.children.map(s)},a.uuid)}catch(f){return console.warn("Error rendering node",a.name,f),null}}return o.jsx("group",{...r,dispose:null,children:s(l.scene)})}function Y({modelURL:e,flangeRef:n,postModelRender:t,...r}){const[i,c]=m.useState(null);return m.useEffect(()=>{let l=!1;return(async()=>{try{const a=typeof e=="string"?e:await e;l||c(f=>f===a?f:a)}catch(a){console.error("Failed to resolve model URL:",a)}})(),()=>{l=!0}},[e]),i?o.jsx(Ge,{url:i,flangeRef:n,postModelRender:t,...r}):null}const Z=(e,n)=>{e.userData.isGhost||(e.traverse(t=>{if(t instanceof R.Mesh){t.material instanceof R.Material&&(t.material.colorWrite=!1);const r=t.clone(),i=t.clone();r.material=new R.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:R.DoubleSide}),r.userData.isGhost=!0,i.material=new R.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:R.DoubleSide}),i.userData.isGhost=!0,t.parent&&(t.parent.add(r),t.parent.add(i))}}),e.userData.isGhost=!0)},K=e=>{if(!e.userData.isGhost)return;const n=[];e.traverse(t=>{var r;t instanceof R.Mesh&&((r=t.userData)!=null&&r.isGhost?n.push(t):t.material instanceof R.Material&&(t.material.colorWrite=!0))}),n.forEach(t=>{t.parent&&t.parent.remove(t)}),e.userData.isGhost=!1},I=T.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,getModel:c=E,flangeRef:l,postModelRender:s,transparentColor:a,instanceUrl:f,...p})=>{const[u,y]=m.useState(null),j=m.useRef(null),d=m.useCallback(g=>{y(g)},[]),h=m.useCallback(()=>{var g;(g=j.current)==null||g.recollectJoints(),s==null||s()},[s]);m.useEffect(()=>{u&&(a?Z(u,a):K(u))},[u,a]);const b=m.useMemo(()=>{const g=c(n,f);if(!g){const M=new Blob([],{type:"model/gltf-binary"}),_=new File([M],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(_))}return g},[n,f,c]),x=o.jsx(B,{rapidlyChangingMotionState:e,dhParameters:t,...p});return o.jsxs(D.ErrorBoundary,{fallback:x,onError:g=>{console.warn(g)},children:[o.jsx(m.Suspense,{fallback:x,children:o.jsx("group",{ref:d,children:o.jsx(H,{ref:j,rapidlyChangingMotionState:e,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,children:o.jsx(Y,{modelURL:b,postModelRender:h,flangeRef:l,...p})})})}),o.jsx(X,{})]})}),z=T.externalizeComponent(({rapidlyChangingMotionState:e,...n})=>{const t=L.useSmoothedMotionState(e);return o.jsx(I,{rapidlyChangingMotionState:t,...n})});function Ae({connectedMotionGroup:e,getModel:n,flangeRef:t,transparentColor:r,postModelRender:i,...c}){const l=m.useCallback(y=>E(y,e.nova),[e]),s=n??l;if(!e.dhParameters)return null;const a=e.mountingPosition,f=e.mountingQuaternion,p=e.modelFromController||"";return p?o.jsx(z,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:p,dhParameters:e.dhParameters,getModel:s,flangeRef:t,transparentColor:r,postModelRender:i,chainOffsetPosition:a,chainOffsetQuaternion:f,...c}):o.jsx(B,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,chainOffsetPosition:a,chainOffsetQuaternion:f,...c})}const ee=m.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,onRotationChanged:c,children:l},s){const a=m.useRef(null),f=m.useRef([]),p=m.useRef(n.joint_position.filter(x=>x!==void 0)),{invalidate:u}=$.useThree(),y=m.useRef(n);y.current=n;function j(x){a.current=x,x&&d()}function d(){a.current&&(f.current=Q(a.current),h(),u())}m.useImperativeHandle(s,()=>({recollectJoints:d}));function h(){const x=p.current;if(c)c(f.current,x);else for(const[g,M]of f.current.entries()){const _=t[g],v=_.theta||0,oe=_.reverse_rotation_direction?-1:1;M.rotation.y=oe*(x[g]||0)+v}}function b(x){p.current=x.joint_position.filter(g=>g!==void 0),h(),u()}return L.useAutorun(()=>{b(y.current)}),m.useEffect(()=>{b(n)},[n]),o.jsx("group",{ref:j,position:r,quaternion:i,children:l})}),Pe="line",ke="mesh";function Ve({rapidlyChangingMotionState:e,dhParameters:n,...t}){const r=new w.Matrix4,i=m.useRef([]),c=m.useRef([]);m.useEffect(()=>{i.current=new Array(n.length).fill(null),c.current=new Array(n.length).fill(null)},[n.length]);function l(f,p){const u=new w.Vector3,y=new w.Quaternion,j=new w.Vector3;r.decompose(u,y,j);const d=u.clone(),h=new w.Matrix4().makeRotationY(f.theta+p*(f.reverse_rotation_direction?-1:1)).multiply(new w.Matrix4().makeTranslation(0,f.d/1e3,0)).multiply(new w.Matrix4().makeTranslation(f.a/1e3,0,0)).multiply(new w.Matrix4().makeRotationX(f.alpha));return r.multiply(h),r.decompose(u,y,j),{a:d,b:u}}function s(f,p,u,y){if(!n)return;const j=n[f];if(!j)return;const{a:d,b:h}=l(j,y);p.geometry.setPositions([d.toArray(),h.toArray()].flat()),u.position.set(h.x,h.y,h.z)}function a(f,p){r.identity();for(let u=0;u<Math.min(f.length,p.length);u++){const y=i.current[u],j=c.current[u];y&&j&&s(u,y,j,p[u])}}return o.jsx(ee,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:a,children:o.jsxs("group",{...t,name:"Scene",children:[o.jsxs("mesh",{children:[o.jsx("sphereGeometry",{args:[.01,32,32]}),o.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n==null?void 0:n.map((f,p)=>{const{a:u,b:y}=l(f,e.joint_position[p]??0),j=`dhrobot_J0${p}`;return o.jsxs("group",{name:j,children:[o.jsx(S.Line,{ref:d=>{i.current[p]=d},name:Pe,points:[u,y],color:"white",lineWidth:5}),o.jsxs("mesh",{ref:d=>{c.current[p]=d},name:ke,position:y,children:[o.jsx("sphereGeometry",{args:[.01,32,32]}),o.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${p}`)]},j)})]})})}const F=T.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,getModel:c=E,flangeRef:l,postModelRender:s,transparentColor:a,instanceUrl:f,...p})=>{const[u,y]=m.useState(null),j=m.useRef(null),d=m.useCallback(g=>{y(g)},[]),h=m.useCallback(()=>{var g;(g=j.current)==null||g.recollectJoints(),s==null||s()},[s]);m.useEffect(()=>{u&&(a?Z(u,a):K(u))},[u,a]);const b=m.useMemo(()=>{const g=c(n,f);if(!g)throw new Error(`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`);return g},[n,f,c]),x=o.jsx(Ve,{rapidlyChangingMotionState:e,dhParameters:t,...p});return o.jsxs(D.ErrorBoundary,{fallback:x,onError:g=>{console.warn(g)},children:[o.jsx(m.Suspense,{fallback:x,children:o.jsx("group",{ref:d,children:o.jsx(ee,{ref:j,rapidlyChangingMotionState:e,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,children:o.jsx(Y,{modelURL:b,postModelRender:h,flangeRef:l,...p})})})}),o.jsx(X,{})]})}),te=T.externalizeComponent(({rapidlyChangingMotionState:e,...n})=>{const t=L.useSmoothedMotionState(e);return o.jsx(F,{rapidlyChangingMotionState:t,...n})}),ne=T.externalizeComponent(e=>{const{inverseSolver:n,dhParameters:t,...r}=e,[i,c]=m.useState(O.JointTypeEnum.RevoluteJoint);m.useEffect(()=>{t.length&&c(t[0].type??O.JointTypeEnum.RevoluteJoint)},[t]);const l=m.useMemo(()=>n===null&&i===O.JointTypeEnum.RevoluteJoint,[n,i]),s=m.useMemo(()=>n===null&&i===O.JointTypeEnum.PrismaticJoint,[n,i]);return m.useMemo(()=>!!n,[n])||l?o.jsx(F,{dhParameters:t,...r}):s?o.jsx(I,{dhParameters:t,...r}):null}),Ce=T.externalizeComponent(e=>{const n=L.useSmoothedMotionState(e.rapidlyChangingMotionState);return o.jsx(ne,{...e,rapidlyChangingMotionState:n})});function Ie({connectedMotionGroup:e,getModel:n,flangeRef:t,transparentColor:r,postModelRender:i,...c}){const l=m.useCallback(f=>E(f,e.nova),[e]);if(!e.dhParameters)return null;const s=e.mountingPosition,a=e.mountingQuaternion;return o.jsx(te,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:n??l,flangeRef:t,transparentColor:r,postModelRender:i,chainOffsetPosition:s,chainOffsetQuaternion:a,...c})}exports.CollisionSceneRenderer=ce;exports.JointLimitGizmo=Re;exports.LinearAxis=Ae;exports.MotionGroupVisualizer=Ce;exports.MotionGroupVisualizerExact=ne;exports.PresetEnvironment=be;exports.Robot=Ie;exports.SafetyZonesRenderer=_e;exports.SupportedLinearAxis=z;exports.SupportedLinearAxisExact=I;exports.SupportedRobot=te;exports.SupportedRobotExact=F;exports.TrajectoryRenderer=ve;exports.defaultGetModel=E;
1
+ "use strict";const o=require("react/jsx-runtime"),w=require("three"),C=require("three-stdlib"),S=require("@react-three/drei"),m=require("react"),A=require("./converters-BsXgcxCW.cjs"),O=require("@wandelbots/nova-js/v2"),T=require("./externalizeComponent-BdxGBLIv.cjs"),L=require("./Pose3-DIyg-aZA.cjs"),D=require("react-error-boundary"),$=require("@react-three/fiber");function re(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const R=re(w);function ie(e){switch(e.shape_type){case"convex_hull":return new C.ConvexGeometry(e.vertices.map(t=>new R.Vector3(t[0]/1e3,t[1]/1e3,t[2]/1e3)));case"box":return new R.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new R.SphereGeometry(e.radius/1e3);case"capsule":return new R.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new R.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new R.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new R.BufferGeometry}}function se({name:e,collider:n,children:t}){var c,l;const r=((c=n.pose)==null?void 0:c.position)??[0,0,0],i=((l=n.pose)==null?void 0:l.orientation)??[0,0,0];return n.margin&&console.warn(`${e} margin is not supported`),o.jsx("mesh",{name:e,position:new R.Vector3(r[0],r[1],r[2]).divideScalar(1e3),rotation:new R.Euler(i[0],i[1],i[2],"XYZ"),geometry:ie(n.shape),children:t})}function ae({name:e,colliders:n,meshChildrenProvider:t,...r}){return o.jsx("group",{name:e,...r,children:Object.entries(n).map(([i,c])=>o.jsx(se,{name:i,collider:c,children:t(i,c)},i))})}function ce({scene:e,meshChildrenProvider:n}){const t=e.colliders;return o.jsx("group",{children:t&&o.jsx(ae,{meshChildrenProvider:n,colliders:t})})}function le(e){const n=(e==null?void 0:e.position)??[],t=(e==null?void 0:e.orientation)??[],r=new w.Vector3(t[0]??0,t[1]??0,t[2]??0),i=r.length(),c=i>0?new w.Quaternion().setFromAxisAngle(r.normalize(),i):new w.Quaternion;return new w.Matrix4().compose(new w.Vector3(n[0]??0,n[1]??0,n[2]??0).divideScalar(1e3),c,new w.Vector3(1,1,1))}function ue(e,n=null,t=[]){const r=le(n);return e.map((i,c)=>{const l=r.clone(),s=(i.reverse_rotation_direction?-1:1)*(t[c]??0),a=i.type==="PRISMATIC_JOINT",f=(i.theta??0)+(a?0:s),p=(i.d??0)+(a?s:0);return r.multiply(new w.Matrix4().makeRotationZ(f)).multiply(new w.Matrix4().makeTranslation((i.a??0)/1e3,0,p/1e3)).multiply(new w.Matrix4().makeRotationX(i.alpha??0)),l})}const P="#ff4b4b",q="#2fa8ff",fe="#8a8d9e",pe=96,me=.15,he=new R.Vector3(0,1,0),de=.2,xe=2;function ge(e){const{lower_limit:n,upper_limit:t}=e??{};return typeof n!="number"||typeof t!="number"||!Number.isFinite(n)||!Number.isFinite(t)||!(n<t)?null:{lower_limit:n,upper_limit:t}}function k({base:e,direction:n,size:t,color:r,opacity:i}){const c=new R.Quaternion().setFromUnitVectors(he,n.clone().normalize()),l=e.clone().addScaledVector(n.clone().normalize(),t/2);return o.jsxs("mesh",{position:l,quaternion:c,renderOrder:10,children:[o.jsx("coneGeometry",{args:[t*.35,t,16]}),o.jsx("meshBasicMaterial",{color:r,depthTest:!1,transparent:!0,opacity:i})]})}function V({points:e,color:n,width:t,opacity:r}){return o.jsx(S.Line,{points:e,color:n,lineWidth:t,depthTest:!1,transparent:!0,opacity:r,renderOrder:10})}function J(e,n){const t=[...e];let r=n;for(;t.length>1;){const i=t[t.length-1],c=t[t.length-2],l=i.distanceTo(c);if(l>r)return t[t.length-1]=i.clone().lerp(c,r/l),t;r-=l,t.pop()}return t}function ye(e,n,t,r){const i=t*e,c=t*n,l=Math.abs(c-i),s=Math.max(2,Math.ceil(l/(2*Math.PI)*pe));return Array.from({length:s+1},(a,f)=>{const p=i+(c-i)*f/s,u=l*f/s/(2*Math.PI),y=r*(1+me*u);return new R.Vector3(Math.cos(p)*y,Math.sin(p)*y,0)})}function je(e,n,t,r){const i=e.theta??0,c=e.d??0,l=e.type==="PRISMATIC_JOINT",s=e.reverse_rotation_direction?-1:1,{lower_limit:a,upper_limit:f}=n;return m.useMemo(()=>{const p=new R.Matrix4().makeRotationZ(i).multiply(new R.Matrix4().makeTranslation(0,0,l?c/1e3:0)),u=(M,_,v)=>new R.Vector3(M,_,v).applyMatrix4(p),y=new R.Vector3().applyMatrix4(p),j=u(0,0,t),d=(l?[u(t*.25,0,s*a/1e3),u(t*.25,0,s*f/1e3)]:ye(a,f,s,t*.6)).map(M=>l?M:M.applyMatrix4(p)),h=u(l?t*.25:t*.6,0,0),b=d.slice(1).reduce((M,_,v)=>M+_.distanceTo(d[v]),0),x=Math.min(r,b/3),g=J(J(d,x).reverse(),x).reverse();return{axisPoints:[y,j],axisTip:j,origin:y,restPoints:[y,h],range:d,limitPoints:g,rangeStart:g[0],rangeEnd:g[g.length-1]}},[i,c,l,s,t,a,f,r])}function we({frame:e,dh:n,limit:t,size:r,emphasis:i}){const c=i==="highlighted"?xe:1,l=i==="dimmed"?de:1,s=r*.2*(i==="highlighted"?1.4:1),a=2*c,{axisPoints:f,axisTip:p,origin:u,restPoints:y,range:j,limitPoints:d,rangeStart:h,rangeEnd:b}=je(n,t,r,s),{position:x,quaternion:g}=m.useMemo(()=>{const M=new R.Vector3,_=new R.Quaternion;return e.decompose(M,_,new R.Vector3),{position:M,quaternion:_}},[e]);return o.jsxs("group",{position:x,quaternion:g,children:[o.jsx(V,{points:f,color:q,width:a,opacity:l}),o.jsx(k,{base:p,direction:p.clone().sub(u),size:s,color:q,opacity:l}),o.jsx(V,{points:y,color:fe,width:1.5*c,opacity:l}),o.jsx(V,{points:d,color:P,width:a,opacity:l}),o.jsx(k,{base:h,direction:j[0].clone().sub(h),size:h.distanceTo(j[0]),color:P,opacity:l}),o.jsx(k,{base:b,direction:j[j.length-1].clone().sub(b),size:b.distanceTo(j[j.length-1]),color:P,opacity:l})]})}function Re({dhParameters:e,chainOffset:n=null,limits:t,jointPositions:r,size:i=.15,highlightedJoint:c=null}){const l=m.useMemo(()=>ue(e,n,r),[e,n,r]);return o.jsx("group",{children:l.map((s,a)=>{const f=ge(t[a]);return f?o.jsx(we,{frame:s,dh:e[a],limit:f,size:i,emphasis:c===null?"normal":c===a?"highlighted":"dimmed"},a):null})})}function be(){return o.jsx(S.Environment,{frames:1,children:o.jsx(Se,{})})}const Me=[2,0,2,0,2,0,2,0];function Se({positions:e=Me}){return o.jsxs(o.Fragment,{children:[o.jsx(S.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),o.jsx("group",{rotation:[0,.5,0],children:o.jsx("group",{children:e.map((n,t)=>o.jsx(S.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,t*4],scale:[3,1,1]},t))})}),o.jsx(S.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),o.jsx(S.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),o.jsx(S.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),o.jsx(S.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),o.jsx(S.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}const N={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function _e({safetyZones:e,dhParameters:n,...t}){const r=m.useMemo(()=>A.dhParametersToPlaneSize(n??[]),[n]),i=(l,s)=>{var y,j;if(!((y=s==null?void 0:s.pose)!=null&&y.position)||!((j=s==null?void 0:s.pose)!=null&&j.orientation))return null;const a=new R.Vector3(s.pose.position[0]/1e3,s.pose.position[1]/1e3,s.pose.position[2]/1e3),f=new R.Vector3(s.pose.orientation[0],s.pose.orientation[1],s.pose.orientation[2]);let p;const u=s.shape.shape_type==="plane"?{...N,side:R.DoubleSide}:{...N,side:R.FrontSide};switch(s.shape.shape_type){case"plane":p=o.jsx("planeGeometry",{args:[r,r]});break;case"sphere":{const d=(s==null?void 0:s.shape).radius/1e3;p=o.jsx("sphereGeometry",{args:[d]});break}case"capsule":{const d=(s==null?void 0:s.shape).radius/1e3,h=(s==null?void 0:s.shape).cylinder_height/1e3;p=o.jsx("capsuleGeometry",{args:[d,h]});break}case"convex_hull":{const d=(s==null?void 0:s.shape).vertices.map(b=>new R.Vector3(b[0]/1e3,b[1]/1e3,b[2]/1e3)),h=A.verticesToCoplanarity(d);if(h.isCoplanar&&h.normal){const x=new R.Vector3().addVectors(d[0],h.normal.multiplyScalar(1e-4));d.push(x)}try{p=o.jsx("primitive",{object:new C.ConvexGeometry(d),attach:"geometry"})}catch(b){return console.log("Error creating ConvexGeometry:",b),null}break}case"rectangular_capsule":{const d=s.shape,h=d.radius/1e3,b=d.sphere_center_distance_x/1e3,x=d.sphere_center_distance_y/1e3,g=h*2;p=o.jsx("primitive",{object:new C.RoundedBoxGeometry(b,x,g,2,h),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",s.shape.shape_type),p=null}return o.jsxs("mesh",{renderOrder:l,position:a,quaternion:A.orientationToQuaternion(f),children:[p,o.jsx("meshStandardMaterial",{...u,polygonOffsetFactor:-l})]},`safety-zone-${s.shape.shape_type}-${l}`)},c=m.useMemo(()=>Object.values(e??{}).map((l,s)=>i(s,l)),[e,r]);return o.jsx("group",{...t,children:c})}function ve({trajectory:e,...n}){const t=(e==null?void 0:e.map(r=>{if(r.position&&r.position.length>=3){const[i,c,l]=r.position;if(Number.isFinite(i)&&Number.isFinite(c)&&Number.isFinite(l))return new R.Vector3(i/1e3,l/1e3,-c/1e3)}return null}).filter(r=>r!==null))||[];return o.jsx("group",{...n,children:t.length>0&&o.jsx(S.Line,{points:t,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const G=new Map;async function E(e,n){const t=n||"";if(!t)throw new Error(`Cannot download the model "${e}": no NOVA instance. Give defaultGetModel the URL of the instance or a NOVA client, or give the component its instanceUrl or getModel.`);const r=`${Te(t)} ${e}`,i=G.get(r);if(i)return i;const c=(async()=>{const l=L.createNovaClient(t);try{const s=await l.api.motionGroupModels.getMotionGroupGlbModel(e,{responseType:"blob"});return URL.createObjectURL(s)}catch(s){throw console.error("Failed to fetch model:",s),s}})();return G.set(r,c),c.catch(()=>{G.get(r)===c&&G.delete(r)}),c}function Te(e){return typeof e=="string"?e:e.config.instanceUrl}function Q(e){function n(t){return t.children.length===0?[t]:[t,...t.children.flatMap(r=>n(r))]}return n(e).filter(t=>W(t))}function U(e){return e.name.endsWith("_FLG")}function W(e){return/_J[0-9]+$/.test(e.name)}function Le(e,n){let t;function r(i){if(U(i)){if(t)throw Error(`Found multiple flange groups in robot model ${n}; first ${t.name} then ${i.name}. Only one _FLG group is allowed.`);t=i}W(i),i.children.map(r)}if(r(e.scene),!t)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}const H=m.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,onTranslationChanged:c,children:l},s){const a=m.useRef(null),f=m.useRef([]),p=m.useRef(n.joint_position.filter(x=>x!==void 0)),{invalidate:u}=$.useThree(),y=m.useRef(n);y.current=n;function j(x){a.current=x,x&&d()}function d(){a.current&&(f.current=Q(a.current),h(),u())}m.useImperativeHandle(s,()=>({recollectJoints:d}));function h(){const x=p.current;if(c)c(f.current,x);else for(const[g,M]of f.current.entries()){const v=t[g].reverse_rotation_direction?-1:1;M.position.y=v*(x[g]||0)/1e3}}function b(x){p.current=x.joint_position.filter(g=>g!==void 0),h(),u()}return L.useAutorun(()=>{b(y.current)}),o.jsx("group",{ref:j,position:r,quaternion:i,children:l})});function B({rapidlyChangingMotionState:e,dhParameters:n,...t}){const r=new w.Matrix4,i=m.useRef(null),c=m.useRef(null);function l(f){const p=new w.Matrix4;for(let d=0;d<n.length;d++){const h=n[d],b=f[d]??0,x=new w.Matrix4().makeRotationY(h.theta).multiply(new w.Matrix4().makeTranslation(h.a/1e3,(h.d+b*(h.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new w.Matrix4().makeRotationX(h.alpha));p.multiply(x)}const u=new w.Vector3,y=new w.Quaternion,j=new w.Vector3;return p.decompose(u,y,j),u}const s=l(e.joint_position);function a(f,p){r.identity();let u=new w.Vector3;for(let h=0;h<n.length;h++){const b=p[h]??0,x=n[h],g=new w.Matrix4().makeRotationY(x.theta).multiply(new w.Matrix4().makeTranslation(x.a/1e3,(x.d+b*(x.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new w.Matrix4().makeRotationX(x.alpha));r.multiply(g)}const y=new w.Vector3,j=new w.Quaternion,d=new w.Vector3;if(r.decompose(y,j,d),u=y,i.current&&i.current.position.set(u.x,u.y,u.z),c.current){const h=c.current.geometry;h!=null&&h.setPositions&&h.setPositions([0,0,0,u.x,u.y,u.z])}}return o.jsx(H,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:a,children:o.jsxs("group",{...t,name:"Scene",children:[o.jsxs("mesh",{name:"Base",position:[0,0,0],children:[o.jsx("sphereGeometry",{args:[.02,32,32]}),o.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),o.jsx(S.Line,{ref:c,points:[new w.Vector3(0,0,0),s],color:"White",lineWidth:5}),o.jsxs("mesh",{ref:i,name:"TCP",position:s,children:[o.jsx("sphereGeometry",{args:[.025,32,32]}),o.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}const Ee=console.warn;function X(){return m.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Ee(e)}},[]),null}function Oe(e){return e.type==="Mesh"}function Ge({url:e,flangeRef:n,postModelRender:t,...r}){const i=S.useGLTF(e),l=Le(i,"robot.glb").gltf;m.useEffect(()=>{t==null||t()},[e,t]);function s(a){try{return Oe(a)?a.geometry?o.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):o.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid):o.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:U(a)?n:void 0,children:a.children.map(s)},a.uuid)}catch(f){return console.warn("Error rendering node",a.name,f),null}}return o.jsx("group",{...r,dispose:null,children:s(l.scene)})}function Y({modelURL:e,flangeRef:n,postModelRender:t,...r}){const[i,c]=m.useState(null);return m.useEffect(()=>{let l=!1;return(async()=>{try{const a=typeof e=="string"?e:await e;l||c(f=>f===a?f:a)}catch(a){console.error("Failed to resolve model URL:",a)}})(),()=>{l=!0}},[e]),i?o.jsx(Ge,{url:i,flangeRef:n,postModelRender:t,...r}):null}const Z=(e,n)=>{e.userData.isGhost||(e.traverse(t=>{if(t instanceof R.Mesh){t.material instanceof R.Material&&(t.material.colorWrite=!1);const r=t.clone(),i=t.clone();r.material=new R.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:R.DoubleSide}),r.userData.isGhost=!0,i.material=new R.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:R.DoubleSide}),i.userData.isGhost=!0,t.parent&&(t.parent.add(r),t.parent.add(i))}}),e.userData.isGhost=!0)},K=e=>{if(!e.userData.isGhost)return;const n=[];e.traverse(t=>{var r;t instanceof R.Mesh&&((r=t.userData)!=null&&r.isGhost?n.push(t):t.material instanceof R.Material&&(t.material.colorWrite=!0))}),n.forEach(t=>{t.parent&&t.parent.remove(t)}),e.userData.isGhost=!1},I=T.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,getModel:c=E,flangeRef:l,postModelRender:s,transparentColor:a,instanceUrl:f,...p})=>{const[u,y]=m.useState(null),j=m.useRef(null),d=m.useCallback(g=>{y(g)},[]),h=m.useCallback(()=>{var g;(g=j.current)==null||g.recollectJoints(),s==null||s()},[s]);m.useEffect(()=>{u&&(a?Z(u,a):K(u))},[u,a]);const b=m.useMemo(()=>{const g=c(n,f);if(!g){const M=new Blob([],{type:"model/gltf-binary"}),_=new File([M],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(_))}return g},[n,f,c]),x=o.jsx(B,{rapidlyChangingMotionState:e,dhParameters:t,...p});return o.jsxs(D.ErrorBoundary,{fallback:x,onError:g=>{console.warn(g)},children:[o.jsx(m.Suspense,{fallback:x,children:o.jsx("group",{ref:d,children:o.jsx(H,{ref:j,rapidlyChangingMotionState:e,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,children:o.jsx(Y,{modelURL:b,postModelRender:h,flangeRef:l,...p})})})}),o.jsx(X,{})]})}),z=T.externalizeComponent(({rapidlyChangingMotionState:e,...n})=>{const t=L.useSmoothedMotionState(e);return o.jsx(I,{rapidlyChangingMotionState:t,...n})});function Ae({connectedMotionGroup:e,getModel:n,flangeRef:t,transparentColor:r,postModelRender:i,...c}){const l=m.useCallback(y=>E(y,e.nova),[e]),s=n??l;if(!e.dhParameters)return null;const a=e.mountingPosition,f=e.mountingQuaternion,p=e.modelFromController||"";return p?o.jsx(z,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:p,dhParameters:e.dhParameters,getModel:s,flangeRef:t,transparentColor:r,postModelRender:i,chainOffsetPosition:a,chainOffsetQuaternion:f,...c}):o.jsx(B,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,chainOffsetPosition:a,chainOffsetQuaternion:f,...c})}const ee=m.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,onRotationChanged:c,children:l},s){const a=m.useRef(null),f=m.useRef([]),p=m.useRef(n.joint_position.filter(x=>x!==void 0)),{invalidate:u}=$.useThree(),y=m.useRef(n);y.current=n;function j(x){a.current=x,x&&d()}function d(){a.current&&(f.current=Q(a.current),h(),u())}m.useImperativeHandle(s,()=>({recollectJoints:d}));function h(){const x=p.current;if(c)c(f.current,x);else for(const[g,M]of f.current.entries()){const _=t[g],v=_.theta||0,oe=_.reverse_rotation_direction?-1:1;M.rotation.y=oe*(x[g]||0)+v}}function b(x){p.current=x.joint_position.filter(g=>g!==void 0),h(),u()}return L.useAutorun(()=>{b(y.current)}),m.useEffect(()=>{b(n)},[n]),o.jsx("group",{ref:j,position:r,quaternion:i,children:l})}),Pe="line",ke="mesh";function Ve({rapidlyChangingMotionState:e,dhParameters:n,...t}){const r=new w.Matrix4,i=m.useRef([]),c=m.useRef([]);m.useEffect(()=>{i.current=new Array(n.length).fill(null),c.current=new Array(n.length).fill(null)},[n.length]);function l(f,p){const u=new w.Vector3,y=new w.Quaternion,j=new w.Vector3;r.decompose(u,y,j);const d=u.clone(),h=new w.Matrix4().makeRotationY(f.theta+p*(f.reverse_rotation_direction?-1:1)).multiply(new w.Matrix4().makeTranslation(0,f.d/1e3,0)).multiply(new w.Matrix4().makeTranslation(f.a/1e3,0,0)).multiply(new w.Matrix4().makeRotationX(f.alpha));return r.multiply(h),r.decompose(u,y,j),{a:d,b:u}}function s(f,p,u,y){if(!n)return;const j=n[f];if(!j)return;const{a:d,b:h}=l(j,y);p.geometry.setPositions([d.toArray(),h.toArray()].flat()),u.position.set(h.x,h.y,h.z)}function a(f,p){r.identity();for(let u=0;u<Math.min(f.length,p.length);u++){const y=i.current[u],j=c.current[u];y&&j&&s(u,y,j,p[u])}}return o.jsx(ee,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:a,children:o.jsxs("group",{...t,name:"Scene",children:[o.jsxs("mesh",{children:[o.jsx("sphereGeometry",{args:[.01,32,32]}),o.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n==null?void 0:n.map((f,p)=>{const{a:u,b:y}=l(f,e.joint_position[p]??0),j=`dhrobot_J0${p}`;return o.jsxs("group",{name:j,children:[o.jsx(S.Line,{ref:d=>{i.current[p]=d},name:Pe,points:[u,y],color:"white",lineWidth:5}),o.jsxs("mesh",{ref:d=>{c.current[p]=d},name:ke,position:y,children:[o.jsx("sphereGeometry",{args:[.01,32,32]}),o.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${p}`)]},j)})]})})}const F=T.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,getModel:c=E,flangeRef:l,postModelRender:s,transparentColor:a,instanceUrl:f,...p})=>{const[u,y]=m.useState(null),j=m.useRef(null),d=m.useCallback(g=>{y(g)},[]),h=m.useCallback(()=>{var g;(g=j.current)==null||g.recollectJoints(),s==null||s()},[s]);m.useEffect(()=>{u&&(a?Z(u,a):K(u))},[u,a]);const b=m.useMemo(()=>{const g=c(n,f);if(!g)throw new Error(`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`);return g},[n,f,c]),x=o.jsx(Ve,{rapidlyChangingMotionState:e,dhParameters:t,...p});return o.jsxs(D.ErrorBoundary,{fallback:x,onError:g=>{console.warn(g)},children:[o.jsx(m.Suspense,{fallback:x,children:o.jsx("group",{ref:d,children:o.jsx(ee,{ref:j,rapidlyChangingMotionState:e,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,children:o.jsx(Y,{modelURL:b,postModelRender:h,flangeRef:l,...p})})})}),o.jsx(X,{})]})}),te=T.externalizeComponent(({rapidlyChangingMotionState:e,...n})=>{const t=L.useSmoothedMotionState(e);return o.jsx(F,{rapidlyChangingMotionState:t,...n})}),ne=T.externalizeComponent(e=>{const{inverseSolver:n,dhParameters:t,...r}=e,[i,c]=m.useState(O.JointTypeEnum.RevoluteJoint);m.useEffect(()=>{t.length&&c(t[0].type??O.JointTypeEnum.RevoluteJoint)},[t]);const l=m.useMemo(()=>n===null&&i===O.JointTypeEnum.RevoluteJoint,[n,i]),s=m.useMemo(()=>n===null&&i===O.JointTypeEnum.PrismaticJoint,[n,i]);return m.useMemo(()=>!!n,[n])||l?o.jsx(F,{dhParameters:t,...r}):s?o.jsx(I,{dhParameters:t,...r}):null}),Ce=T.externalizeComponent(e=>{const n=L.useSmoothedMotionState(e.rapidlyChangingMotionState);return o.jsx(ne,{...e,rapidlyChangingMotionState:n})});function Ie({connectedMotionGroup:e,getModel:n,flangeRef:t,transparentColor:r,postModelRender:i,...c}){const l=m.useCallback(f=>E(f,e.nova),[e]);if(!e.dhParameters)return null;const s=e.mountingPosition,a=e.mountingQuaternion;return o.jsx(te,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:n??l,flangeRef:t,transparentColor:r,postModelRender:i,chainOffsetPosition:s,chainOffsetQuaternion:a,...c})}exports.CollisionSceneRenderer=ce;exports.JointLimitGizmo=Re;exports.LinearAxis=Ae;exports.MotionGroupVisualizer=Ce;exports.MotionGroupVisualizerExact=ne;exports.PresetEnvironment=be;exports.Robot=Ie;exports.SafetyZonesRenderer=_e;exports.SupportedLinearAxis=z;exports.SupportedLinearAxisExact=I;exports.SupportedRobot=te;exports.SupportedRobotExact=F;exports.TrajectoryRenderer=ve;exports.defaultGetModel=E;
@@ -4,7 +4,7 @@ import { Matrix4 as b, Vector3 as x, Quaternion as k } from "three";
4
4
  import { ConvexGeometry as H, RoundedBoxGeometry as mt } from "three-stdlib";
5
5
  import { Line as V, Environment as ht, Lightformer as G, useGLTF as dt } from "@react-three/drei";
6
6
  import gt, { useMemo as L, forwardRef as Q, useRef as S, useImperativeHandle as B, useEffect as P, useState as C, useCallback as A, Suspense as X } from "react";
7
- import { d as yt, v as wt, o as Rt } from "./converters-DpNB_WNQ.js";
7
+ import { d as yt, v as wt, o as Rt } from "./converters-D9KpJ2HD.js";
8
8
  import { JointTypeEnum as I } from "@wandelbots/nova-js/v2";
9
9
  import { e as E } from "./externalizeComponent-_w2d1_pz.js";
10
10
  import { c as _t, b as Y, a as j } from "./Pose3-pocKPrHN.js";
@@ -4,7 +4,7 @@ import s from "@mui/material/Stack";
4
4
  import { useId as v, useState as A } from "react";
5
5
  import { useTranslation as h } from "react-i18next";
6
6
  import { e as B } from "./externalizeComponent-_w2d1_pz.js";
7
- import { S as C } from "./SafetyBar-Cuak4ffd.js";
7
+ import { S as C } from "./SafetyBar-eYzCHOFD.js";
8
8
  import { S as k } from "./SmallSelect-BdD9uLKK.js";
9
9
  import T from "@mui/material/CircularProgress";
10
10
  import R from "@mui/material/Switch";
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),u=require("@mui/material/Box"),l=require("@mui/material/Stack"),g=require("react"),h=require("react-i18next"),y=require("./externalizeComponent-BdxGBLIv.cjs"),S=require("./SafetyBar-Bbg-o8h9.cjs"),q=require("./SmallSelect-Dcsd7_6_.cjs"),I=require("@mui/material/CircularProgress"),A=require("@mui/material/Switch"),v=require("@mui/material/Typography"),B=require("@mui/icons-material/Apps"),m=require("@mui/material/Button"),C=require("@mui/material/ButtonGroup"),T=require("@mui/material/Menu"),k=require("@mui/material/MenuItem"),R=require("@wandelbots/design-tokens"),H=require("@wandelbots/icons/SearchFilled");function z({state:i,disabled:d=!1,onToggle:s}){const{t:n}=h.useTranslation(),a=g.useId(),r=i==="activating"||i==="deactivating",o={inactive:n("SafetyBar.ActivationToggle.Activate.bt"),activating:n("SafetyBar.ActivationToggle.Activating.bt"),active:n("SafetyBar.ActivationToggle.Activated.bt"),deactivating:n("SafetyBar.ActivationToggle.Deactivating.bt")}[i];return e.jsxs(l,{direction:"row","data-testid":"robot-activation",sx:{gap:"4px",alignItems:"center"},children:[e.jsx(A,{size:"small",checked:i==="active"||i==="deactivating",disabled:r||d,onChange:()=>s(),slotProps:{input:{role:"switch","aria-labelledby":a}}}),e.jsx(v,{id:a,variant:"body2",color:"text.secondary",noWrap:!0,sx:{letterSpacing:"0.17px"},children:o}),r&&e.jsx(I,{size:16})]})}const j={minWidth:0,padding:"4px 10px",color:"text.primary","& svg":{width:"16px",height:"16px"}};function F({appIcon:i,appName:d,apps:s,onAppSelect:n,onSearch:a}){const{t:r}=h.useTranslation(),[o,c]=g.useState(null);function x(t){c(null),t.onClick?t.onClick():t.href&&(window.location.href=t.href),n==null||n(t)}return e.jsxs(l,{direction:"row",sx:{gap:"8px",alignItems:"center"},children:[e.jsxs(C,{variant:"outlined",color:"secondary",sx:t=>({borderRadius:"10px",boxShadow:t.shadows[2],"& .MuiButtonGroup-grouped":{borderColor:t.palette.divider}}),children:[e.jsx(m,{"aria-label":r("RobotHeader.Apps.bt"),"aria-haspopup":"menu","aria-expanded":o!==null,disabled:s.length===0,onClick:t=>c(t.currentTarget),sx:j,children:e.jsx(B,{})}),a&&e.jsx(m,{"aria-label":r("RobotHeader.Search.bt"),onClick:a,sx:j,children:e.jsx(H.SearchFilled,{})})]}),e.jsxs(l,{direction:"row",sx:{gap:"4px",alignItems:"center"},children:[i&&e.jsx(u,{sx:{display:"flex","& svg":{width:"25px",height:"25px"}},children:i}),e.jsx(v,{component:"h1",noWrap:!0,sx:{fontFamily:R.FontFamilyBrand,fontWeight:700,fontSize:"16px",letterSpacing:"0.24px"},children:d})]}),e.jsx(T,{anchorEl:o,open:o!==null,onClose:()=>c(null),sx:{"& .MuiPaper-root":{minWidth:200,mt:1}},children:s.map(t=>e.jsxs(k,{onClick:()=>x(t),children:[t.icon&&e.jsx(u,{sx:{display:"flex",alignItems:"center",mr:2},children:t.icon}),t.name]},t.id))})]})}const M={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},P=y.externalizeComponent(({appIcon:i,appName:d,apps:s=[],onAppSelect:n,onSearch:a,motionGroup:r,safety:o,activation:c,actions:x,sx:t})=>{const{t:f}=h.useTranslation(),p=g.useId();return e.jsxs(l,{component:"header",direction:"row","data-testid":"robot-header",sx:[w=>{var b;return{alignItems:"center",justifyContent:"space-between",gap:"24px",padding:"8px 24px",minHeight:"52px",boxSizing:"border-box",background:(b=w.palette.backgroundPaperElevation)==null?void 0:b[1]}},...Array.isArray(t)?t:[t]],children:[e.jsx(F,{appIcon:i,appName:d,apps:s,onAppSelect:n,onSearch:a}),e.jsxs(l,{direction:"row",sx:{gap:"20px",alignItems:"center"},children:[r&&e.jsxs(e.Fragment,{children:[e.jsx(u,{component:"span",id:p,sx:M,children:f("RobotHeader.MotionGroup.lb")}),e.jsx(q.SmallSelect,{labelId:p,width:"240px",...r})]}),o&&e.jsx(S.SafetyBar,{...o}),c&&e.jsx(z,{...c})]}),e.jsx(l,{direction:"row",sx:{gap:"24px",alignItems:"center"},children:x})]})});exports.RobotHeader=P;
1
+ "use strict";const e=require("react/jsx-runtime"),u=require("@mui/material/Box"),l=require("@mui/material/Stack"),g=require("react"),h=require("react-i18next"),y=require("./externalizeComponent-BdxGBLIv.cjs"),S=require("./SafetyBar-BVk-SH_0.cjs"),q=require("./SmallSelect-Dcsd7_6_.cjs"),I=require("@mui/material/CircularProgress"),A=require("@mui/material/Switch"),v=require("@mui/material/Typography"),B=require("@mui/icons-material/Apps"),m=require("@mui/material/Button"),C=require("@mui/material/ButtonGroup"),T=require("@mui/material/Menu"),k=require("@mui/material/MenuItem"),R=require("@wandelbots/design-tokens"),H=require("@wandelbots/icons/SearchFilled");function z({state:i,disabled:d=!1,onToggle:s}){const{t:n}=h.useTranslation(),a=g.useId(),r=i==="activating"||i==="deactivating",o={inactive:n("SafetyBar.ActivationToggle.Activate.bt"),activating:n("SafetyBar.ActivationToggle.Activating.bt"),active:n("SafetyBar.ActivationToggle.Activated.bt"),deactivating:n("SafetyBar.ActivationToggle.Deactivating.bt")}[i];return e.jsxs(l,{direction:"row","data-testid":"robot-activation",sx:{gap:"4px",alignItems:"center"},children:[e.jsx(A,{size:"small",checked:i==="active"||i==="deactivating",disabled:r||d,onChange:()=>s(),slotProps:{input:{role:"switch","aria-labelledby":a}}}),e.jsx(v,{id:a,variant:"body2",color:"text.secondary",noWrap:!0,sx:{letterSpacing:"0.17px"},children:o}),r&&e.jsx(I,{size:16})]})}const j={minWidth:0,padding:"4px 10px",color:"text.primary","& svg":{width:"16px",height:"16px"}};function F({appIcon:i,appName:d,apps:s,onAppSelect:n,onSearch:a}){const{t:r}=h.useTranslation(),[o,c]=g.useState(null);function x(t){c(null),t.onClick?t.onClick():t.href&&(window.location.href=t.href),n==null||n(t)}return e.jsxs(l,{direction:"row",sx:{gap:"8px",alignItems:"center"},children:[e.jsxs(C,{variant:"outlined",color:"secondary",sx:t=>({borderRadius:"10px",boxShadow:t.shadows[2],"& .MuiButtonGroup-grouped":{borderColor:t.palette.divider}}),children:[e.jsx(m,{"aria-label":r("RobotHeader.Apps.bt"),"aria-haspopup":"menu","aria-expanded":o!==null,disabled:s.length===0,onClick:t=>c(t.currentTarget),sx:j,children:e.jsx(B,{})}),a&&e.jsx(m,{"aria-label":r("RobotHeader.Search.bt"),onClick:a,sx:j,children:e.jsx(H.SearchFilled,{})})]}),e.jsxs(l,{direction:"row",sx:{gap:"4px",alignItems:"center"},children:[i&&e.jsx(u,{sx:{display:"flex","& svg":{width:"25px",height:"25px"}},children:i}),e.jsx(v,{component:"h1",noWrap:!0,sx:{fontFamily:R.FontFamilyBrand,fontWeight:700,fontSize:"16px",letterSpacing:"0.24px"},children:d})]}),e.jsx(T,{anchorEl:o,open:o!==null,onClose:()=>c(null),sx:{"& .MuiPaper-root":{minWidth:200,mt:1}},children:s.map(t=>e.jsxs(k,{onClick:()=>x(t),children:[t.icon&&e.jsx(u,{sx:{display:"flex",alignItems:"center",mr:2},children:t.icon}),t.name]},t.id))})]})}const M={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},P=y.externalizeComponent(({appIcon:i,appName:d,apps:s=[],onAppSelect:n,onSearch:a,motionGroup:r,safety:o,activation:c,actions:x,sx:t})=>{const{t:f}=h.useTranslation(),p=g.useId();return e.jsxs(l,{component:"header",direction:"row","data-testid":"robot-header",sx:[w=>{var b;return{alignItems:"center",justifyContent:"space-between",gap:"24px",padding:"8px 24px",minHeight:"52px",boxSizing:"border-box",background:(b=w.palette.backgroundPaperElevation)==null?void 0:b[1]}},...Array.isArray(t)?t:[t]],children:[e.jsx(F,{appIcon:i,appName:d,apps:s,onAppSelect:n,onSearch:a}),e.jsxs(l,{direction:"row",sx:{gap:"20px",alignItems:"center"},children:[r&&e.jsxs(e.Fragment,{children:[e.jsx(u,{component:"span",id:p,sx:M,children:f("RobotHeader.MotionGroup.lb")}),e.jsx(q.SmallSelect,{labelId:p,width:"240px",...r})]}),o&&e.jsx(S.SafetyBar,{...o}),c&&e.jsx(z,{...c})]}),e.jsx(l,{direction:"row",sx:{gap:"24px",alignItems:"center"},children:x})]})});exports.RobotHeader=P;
@@ -1 +1 @@
1
- "use strict";const r=require("react/jsx-runtime"),m=require("@mui/material/Divider"),E=require("@mui/material/Stack"),f=require("mobx-react-lite"),w=require("./externalizeComponent-BdxGBLIv.cjs"),y=require("@mui/material/styles"),c=require("react"),d=require("react-i18next"),A=require("@mui/material/Popover"),g=require("@mui/material/SvgIcon"),h=require("@mui/material/Typography"),T=require("axios"),M=require("./converters-C8I_A_tA.cjs");function _(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:()=>e[a]})}}return t.default=e,Object.freeze(t)}const l=_(c);function R(e,t){throw new Error(`${t} ${JSON.stringify(e)}`)}function O(e){var t,a,n,o;return e instanceof T.AxiosError&&e.code==="ERR_NETWORK"?"Failed to connect to the server. Please check your internet connection.":e instanceof T.AxiosError&&e.response?`${(t=e.response)==null?void 0:t.status} ${(a=e.response)==null?void 0:a.statusText} from ${(n=e.response)==null?void 0:n.config.url}: ${JSON.stringify((o=e.response)==null?void 0:o.data)}`:e instanceof Error?e.message:`Unexpected error: ${M.tryStringifyJson(e)||e}`}const j=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M5.248 21c-.334 0-.619-.116-.853-.35a1.153 1.153 0 0 1-.351-.848c0-.333.117-.616.351-.85.234-.233.519-.35.853-.35H7.24L4.558 9.87a2.881 2.881 0 0 1-1.126-1.042A2.77 2.77 0 0 1 3 7.317c0-.793.28-1.467.838-2.023a2.774 2.774 0 0 1 2.033-.834 2.71 2.71 0 0 1 1.728.585c.494.389.832.887 1.014 1.493h3.58V5.239c0-.22.076-.406.226-.555a.76.76 0 0 1 .558-.224c.136 0 .263.035.381.104.118.07.209.167.273.292v.14l1.835-1.702a.979.979 0 0 1 .52-.279.881.881 0 0 1 .58.091l4.01 1.85a.74.74 0 0 1 .36.364.537.537 0 0 1-.002.474.592.592 0 0 1-.366.323.657.657 0 0 1-.477-.039l-3.858-1.774L13.76 6.59v1.454l2.473 2.233 3.858-1.774a.648.648 0 0 1 .485-.03.571.571 0 0 1 .358.314.513.513 0 0 1 .01.482.79.79 0 0 1-.367.357l-4.011 1.882a.881.881 0 0 1-.58.09.979.979 0 0 1-.52-.278L13.63 9.638v.14a.92.92 0 0 1-.273.275.665.665 0 0 1-.381.12.76.76 0 0 1-.558-.224.752.752 0 0 1-.225-.555V8.096h-3.58a2.82 2.82 0 0 1-.215.54 2.552 2.552 0 0 1-.323.479l5.139 9.488h2.673c.335 0 .62.116.854.35.234.233.35.516.35.849 0 .332-.116.615-.35.849a1.167 1.167 0 0 1-.854.349H5.248Zm.623-12.385c.362 0 .67-.126.924-.378a1.25 1.25 0 0 0 .38-.92 1.25 1.25 0 0 0-.38-.92 1.261 1.261 0 0 0-.924-.379 1.26 1.26 0 0 0-.925.379 1.25 1.25 0 0 0-.38.92c0 .36.127.667.38.92.254.252.562.378.925.378Z"})),B=c.forwardRef(j),F=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"m13.37 9.12 1.69 1.69 2.99-2.99-3.73-3.73-.95-.95-7.66 7.66-.95.95 3.99 3.99v3.44h7.55v-3.55l-4.72-4.72 1.79-1.79Zm-.91-2.99.91-.91 2.6 2.6-.91.91-2.6-2.6Zm-2.25 10.24h3.74l-1.34-1.34-.04-.04h-2.5l-3.25-3.25 4.59-4.59.92.92L9.5 10.9l5.33 5.33v1.48H10.2v-1.35l.01.01ZM2 2v4.99h1.41V3.4h3.58V2H2ZM22.21 2h-4.98v1.41h3.59v3.58h1.4V2h-.01ZM20.81 20.65h-3.58v1.4h4.98v-4.99h-1.4v3.59ZM3.4 17.06H2v4.98h4.99v-1.4H3.4v-3.58Z"})),Z=c.forwardRef(F),p=f.observer(({id:e,icon:t,color:a,title:n,name:o,label:s,explanation:i,literalValue:u,anchorOrigin:v,transformOrigin:x})=>{const S=f.useLocalObservable(()=>({anchorEl:null,get isPopoverOpen(){return!!S.anchorEl},openPopover(b){S.anchorEl=b.currentTarget},closePopover(){S.anchorEl=null}}));return r.jsxs(r.Fragment,{children:[r.jsxs(E,{"aria-owns":S.isPopoverOpen?e:void 0,"aria-haspopup":"true",onMouseEnter:S.openPopover,onMouseLeave:S.closePopover,direction:"row",spacing:1,sx:{cursor:"pointer"},children:[r.jsx(g,{component:t,sx:{color:a}}),s&&r.jsx("div",{style:{color:a},children:s})]}),r.jsx(A,{id:e,sx:{pointerEvents:"none"},open:S.isPopoverOpen,anchorEl:S.anchorEl,anchorOrigin:v??{vertical:"bottom",horizontal:"left"},transformOrigin:x??{vertical:"top",horizontal:"left"},onClose:S.closePopover,disableRestoreFocus:!0,children:r.jsxs(E,{gap:"1rem",padding:2,maxWidth:"450px",sx:{wordWrap:"break-word"},children:[r.jsxs("div",{children:[n&&r.jsx(h,{component:"span",fontSize:"14px",children:`${n}: `}),r.jsx(h,{component:"span",color:a,fontWeight:"bold",fontSize:"14px",children:o})]}),r.jsx(h,{fontSize:"14px",children:i}),u&&r.jsx(h,{fontSize:"12px",children:u})]})})]})}),C=f.observer(({isVirtual:e,motionGroupId:t,anchorOrigin:a,transformOrigin:n,compact:o})=>{const s=y.useTheme(),i=c.useId(),{t:u}=d.useTranslation();return e?r.jsx(p,{id:`motion-group-virtual-${i}`,icon:Z,color:s.palette.tertiary.main,name:u("SafetyBar.ControllerType.Virtual.lb"),label:o?null:u("SafetyBar.ControllerType.Virtual.lb"),explanation:r.jsxs(d.Trans,{i18nKey:"SafetyBar.MotionGroup.Virtual.Explanation.lb",values:{motionGroupId:t},children:["Motion group ",r.jsx("code",{children:t})," refers to a virtual robot with no physical counterpart. It can be freely manipulated without special safety precautions."]}),anchorOrigin:a,transformOrigin:n}):r.jsx(p,{id:`motion-group-physical-${i}`,icon:B,color:s.palette.primary.main,name:u("SafetyBar.ControllerType.Physical.lb"),label:o?null:u("SafetyBar.ControllerType.Physical.lb"),explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.MotionGroup.Physical.Explanation.lb",values:{motionGroupId:t},components:{code:r.jsx("code",{}),strong:r.jsx("strong",{})}}),anchorOrigin:a,transformOrigin:n})}),P=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.306 2.768c0-.424.344-.768.768-.768h.406C19.53 2 22 4.551 22 7.699c0 3.237-2.51 5.587-5.31 5.703-.84 1.595-2.478 2.677-4.36 2.677a4.845 4.845 0 0 1-3.146-1.163c-.6 1.783 0 3.922 1.79 4.99 1.929 1.149 4.395.467 5.508-1.524l.212-.378a.75.75 0 1 1 1.308.732l-.231.414c-1.524 2.725-4.9 3.66-7.54 2.085-2.716-1.618-3.432-5.037-2.129-7.599a5.22 5.22 0 0 1-.73-2.677c0-2.192 1.335-4.063 3.212-4.793-1.195-1.427-3.29-1.96-5.08-.892-1.928 1.15-2.589 3.696-1.475 5.687l.231.413a.75.75 0 0 1-1.308.732l-.212-.377c-1.524-2.726-.62-6.211 2.02-7.785 2.716-1.619 5.943-.55 7.44 1.897l.13-.001c2.739 0 4.96 2.292 4.96 5.12 0 .284-.023.563-.066.834 1.795-.354 3.288-1.96 3.288-4.095 0-2.3-1.805-4.163-4.032-4.163h-.406a.768.768 0 0 1-.768-.768Zm.496 8.191c0 .286-.033.564-.094.831a3.62 3.62 0 0 1-.672 1.415 3.425 3.425 0 0 1-2.706 1.338 3.402 3.402 0 0 1-2.384-.98 3.598 3.598 0 0 1-.852-1.306 3.677 3.677 0 0 1-.235-1.298c0-1.623 1.046-2.994 2.48-3.435a3.37 3.37 0 0 1 1.522-.107c1.665.264 2.94 1.75 2.94 3.542Z"})),$=c.forwardRef(P),N=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M19.763 16.432 13.516 5.864c-.674-1.152-2.358-1.152-3.049 0l-6.23 10.568C3.563 17.567 4.405 19 5.753 19H18.23c1.364 0 2.206-1.432 1.532-2.568ZM12 8.498c.539 0 .96.428.96.938v.066l-.32 4.708a.639.639 0 0 1-.64.592.639.639 0 0 1-.64-.592l-.32-4.708A.953.953 0 0 1 12 8.498Zm0 8.79c-.556 0-1.01-.444-1.01-.987 0-.544.454-.988 1.01-.988s1.01.444 1.01.988c0 .542-.454.987-1.01.987Z",fill:"#fff",fillOpacity:.56})),Y=c.forwardRef(N),V=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M12.953 5.09a1.497 1.497 0 0 0-1.653-.518l-1.35.43a1.504 1.504 0 0 0-1.726-.376L2.858 6.97c-.736.321-1.06 1.155-.726 1.862.334.707 1.202 1.02 1.937.698l4.27-1.865 1.466 1.973v.402c0 .873-.627 1.63-1.512 1.827l-2.56.567c-1.329.295-2.27 1.431-2.27 2.74v.107c0 .26.22.469.489.469h11.117c1.329 0 2.618.435 3.656 1.233l1.665 1.28A1 1 0 0 0 22 17.47V11.062c0-.312-.108-.616-.308-.863l-3.415-4.218a1.5 1.5 0 0 0-1.618-.471l-.378.12-.866-.475a1.516 1.516 0 0 0-1.188-.114l-1.06.338-.214-.289Z"})),q=c.forwardRef(V),L=f.observer(({operationMode:e,anchorOrigin:t,transformOrigin:a,compact:n})=>{const{t:o}=d.useTranslation(),s=y.useTheme(),i=c.useId();switch(e){case"OPERATION_MODE_AUTO":return r.jsx(p,{id:`operation-mode-auto-${i}`,icon:$,title:o("SafetyBar.OperationMode.ti"),name:o("SafetyBar.OperationMode.Automatic.ti"),label:n?null:o("SafetyBar.OperationMode.Automatic.ti"),color:s.palette.text.secondary,explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.OperationMode.Auto.Explanation.lb",children:"The robot controller is in automatic operation mode. Automated movement without manual confirmation is possible in this mode."}),anchorOrigin:t,transformOrigin:a});case"OPERATION_MODE_MANUAL":case"OPERATION_MODE_MANUAL_T1":case"OPERATION_MODE_MANUAL_T2":return r.jsx(p,{id:`operation-mode-manual-${i}`,icon:q,color:s.palette.warning.main,title:o("SafetyBar.OperationMode.ti"),name:o("SafetyBar.OperationMode.Manual.lb"),label:n?null:o("SafetyBar.OperationMode.Manual.lb"),explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.OperationMode.Manual.Explanation.lb",children:"The robot controller is in manual operation mode. On a physical robot, this generally indicates that an enabling switch must be held for the robot to move successfully."}),literalValue:e,anchorOrigin:t,transformOrigin:a});default:return r.jsx(p,{id:`operation-mode-error-${i}`,icon:Y,color:s.palette.warning.main,title:o("SafetyBar.OperationMode.ti"),name:o("SafetyBar.OperationMode.Error.lb"),label:n?null:o("SafetyBar.OperationMode.Error.lb"),explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.OperationMode.Error.Explanation.lb",children:"The robot controller has entered an unexpected operation mode. Motion group movement may not be possible."}),literalValue:e,anchorOrigin:t,transformOrigin:a})}}),I=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M19.763 16.432 13.516 5.864c-.674-1.152-2.358-1.152-3.049 0l-6.23 10.568C3.563 17.567 4.405 19 5.753 19H18.23c1.364 0 2.206-1.432 1.532-2.568ZM12 8.498c.539 0 .96.428.96.938v.066l-.32 4.708a.639.639 0 0 1-.64.592.639.639 0 0 1-.64-.592l-.32-4.708A.953.953 0 0 1 12 8.498Zm0 8.79c-.556 0-1.01-.444-1.01-.987 0-.544.454-.988 1.01-.988s1.01.444 1.01.988c0 .542-.454.987-1.01.987Z"})),K=c.forwardRef(I),D=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M10.24 10.636 12 13.764l1.76-3.128h-3.52Z"}),l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.364 12a6.364 6.364 0 1 1-12.728 0 6.364 6.364 0 0 1 12.728 0ZM7.909 9.273 12 16.546l4.09-7.273H7.91Z"}),l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-1.364 0a8.636 8.636 0 1 1-17.273 0 8.636 8.636 0 0 1 17.273 0Z"})),H=c.forwardRef(D),U=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M9.057 15.115c-1.681 0-3.111-.59-4.29-1.768C3.59 12.17 3 10.74 3 9.057c0-.29.021-.582.064-.876a4.1 4.1 0 0 1 .214-.844.78.78 0 0 1 .273-.36c.115-.077.244-.133.389-.168a.857.857 0 0 1 .437.008c.146.04.28.12.4.24l2.806 2.787 2.26-2.261-2.775-2.786a.903.903 0 0 1-.241-.405.875.875 0 0 1-.008-.442 1.13 1.13 0 0 1 .174-.389.82.82 0 0 1 .355-.273c.268-.107.548-.182.838-.224.29-.043.581-.064.871-.064 1.682 0 3.112.59 4.29 1.768 1.179 1.178 1.768 2.608 1.768 4.29 0 .444-.042.858-.126 1.241-.084.384-.21.755-.377 1.113l5.726 5.692A2.2 2.2 0 0 1 21 18.721a2.2 2.2 0 0 1-.662 1.617A2.2 2.2 0 0 1 18.72 21a2.173 2.173 0 0 1-1.617-.679l-5.692-5.709c-.372.161-.75.285-1.133.372-.383.087-.79.13-1.222.13Z",fill:"#fff",fillOpacity:.56})),z=c.forwardRef(U),k=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"m10.6 13.8-2.15-2.15a.948.948 0 0 0-.7-.275.948.948 0 0 0-.7.275.948.948 0 0 0-.275.7c0 .283.092.517.275.7L9.9 15.9c.2.2.433.3.7.3.267 0 .5-.1.7-.3l5.65-5.65a.948.948 0 0 0 .275-.7.948.948 0 0 0-.275-.7.948.948 0 0 0-.7-.275.948.948 0 0 0-.7.275L10.6 13.8ZM12 22a9.738 9.738 0 0 1-3.9-.788 10.099 10.099 0 0 1-3.175-2.137c-.9-.9-1.612-1.958-2.137-3.175A9.738 9.738 0 0 1 2 12c0-1.383.263-2.683.788-3.9a10.099 10.099 0 0 1 2.137-3.175c.9-.9 1.958-1.612 3.175-2.137A9.738 9.738 0 0 1 12 2c1.383 0 2.683.263 3.9.788a10.098 10.098 0 0 1 3.175 2.137c.9.9 1.613 1.958 2.137 3.175A9.738 9.738 0 0 1 22 12a9.738 9.738 0 0 1-.788 3.9 10.098 10.098 0 0 1-2.137 3.175c-.9.9-1.958 1.613-3.175 2.137A9.738 9.738 0 0 1 12 22Zm0-2c2.233 0 4.125-.775 5.675-2.325C19.225 16.125 20 14.233 20 12c0-2.233-.775-4.125-2.325-5.675C16.125 4.775 14.233 4 12 4c-2.233 0-4.125.775-5.675 2.325C4.775 7.875 4 9.767 4 12c0 2.233.775 4.125 2.325 5.675C7.875 19.225 9.767 20 12 20Z"})),W=c.forwardRef(k),G=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M9 16h6c.283 0 .52-.096.713-.287A.968.968 0 0 0 16 15V9a.967.967 0 0 0-.287-.713A.968.968 0 0 0 15 8H9a.968.968 0 0 0-.713.287A.968.968 0 0 0 8 9v6c0 .283.096.52.287.713.192.191.43.287.713.287Zm3 6a9.738 9.738 0 0 1-3.9-.788 10.099 10.099 0 0 1-3.175-2.137c-.9-.9-1.612-1.958-2.137-3.175A9.738 9.738 0 0 1 2 12c0-1.383.263-2.683.788-3.9a10.099 10.099 0 0 1 2.137-3.175c.9-.9 1.958-1.612 3.175-2.137A9.738 9.738 0 0 1 12 2c1.383 0 2.683.263 3.9.788a10.098 10.098 0 0 1 3.175 2.137c.9.9 1.613 1.958 2.137 3.175A9.738 9.738 0 0 1 22 12a9.738 9.738 0 0 1-.788 3.9 10.098 10.098 0 0 1-2.137 3.175c-.9.9-1.958 1.613-3.175 2.137A9.738 9.738 0 0 1 12 22Zm0-2c2.233 0 4.125-.775 5.675-2.325C19.225 16.125 20 14.233 20 12c0-2.233-.775-4.125-2.325-5.675C16.125 4.775 14.233 4 12 4c-2.233 0-4.125.775-5.675 2.325C4.775 7.875 4 9.767 4 12c0 2.233.775 4.125 2.325 5.675C7.875 19.225 9.767 20 12 20Z"})),J=c.forwardRef(G),Q=f.observer(({safetyState:e,anchorOrigin:t,transformOrigin:a,compact:n})=>{const{t:o}=d.useTranslation(),s=y.useTheme(),i=c.useId();switch(e){case"SAFETY_STATE_NORMAL":return r.jsx(p,{id:`safety-state-normal-${i}`,title:o("SafetyBar.SafetyState.ti"),name:o("SafetyBar.SafetyState.Normal.lb"),label:n?null:o("SafetyBar.SafetyState.Normal.lb"),icon:W,color:s.palette.text.secondary,explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.SafetyState.Normal.Explanation.lb",children:"The robot controller is in a normal safety state. Movement is not prevented by this state."}),anchorOrigin:t,transformOrigin:a});case"SAFETY_STATE_DEVICE_EMERGENCY_STOP":case"SAFETY_STATE_ROBOT_EMERGENCY_STOP":return r.jsx(p,{id:`safety-state-estop-${i}`,title:o("SafetyBar.SafetyState.ti"),name:o("SafetyBar.SafetyState.Estop.lb"),label:n?null:o("SafetyBar.SafetyState.Estop.lb"),icon:H,color:s.palette.error.main,explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.StopState.Estop.Explanation.lb",children:"An emergency stop of the robot controller has been triggered. Movement of the robot is no longer possible until the estop is released."}),literalValue:e,anchorOrigin:t,transformOrigin:a});case"SAFETY_STATE_STOP_0":case"SAFETY_STATE_STOP_1":case"SAFETY_STATE_STOP_2":case"SAFETY_STATE_PROTECTIVE_STOP":case"SAFETY_STATE_STOP":return r.jsx(p,{id:`safety-state-stop-${i}`,icon:J,title:o("SafetyBar.SafetyState.ti"),name:o("SafetyBar.SafetyState.Stop.lb"),label:n?null:o("SafetyBar.SafetyState.Stop.lb"),color:s.palette.warning.main,explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.SafetyState.Stop.Explanation.lb",children:"The robot controller has entered a stop state. Movement is no longer possible until the stop state is resolved."}),literalValue:e,anchorOrigin:t,transformOrigin:a});case"SAFETY_STATE_REDUCED":case"SAFETY_STATE_MASTERING":case"SAFETY_STATE_CONFIRM_SAFETY":case"SAFETY_STATE_OPERATOR_SAFETY":case"SAFETY_STATE_RECOVERY":case"SAFETY_STATE_VIOLATION":return r.jsx(p,{id:`safety-state-manual-action-required-${i}`,icon:z,color:s.palette.warning.main,title:o("SafetyBar.SafetyState.ti"),name:o("SafetyBar.SafetyState.ManualActionRequired.lb"),label:n?null:o("SafetyBar.SafetyState.ManualActionRequired.lb"),explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.SafetyState.ManualActionRequired.Explanation.lb",children:"The robot controller has entered a safety state requiring manual action to resolve."}),literalValue:e,anchorOrigin:t,transformOrigin:a});case"SAFETY_STATE_UNKNOWN":case"SAFETY_STATE_FAULT":return r.jsx(p,{id:`safety-state-error-${i}`,icon:K,color:s.palette.error.main,title:o("SafetyBar.SafetyState.ti"),name:o("SafetyBar.SafetyState.Error.lb"),label:n?null:o("SafetyBar.SafetyState.Error.lb"),explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.SafetyState.Error.Explanation.lb",children:"The robot controller has entered an unexpected safety state."}),literalValue:e,anchorOrigin:t,transformOrigin:a});default:R(e,`Unknown safety state ${e}`)}}),X=w.externalizeComponent(f.observer(({isVirtual:e,motionGroupId:t,operationMode:a,safetyState:n,anchorOrigin:o,transformOrigin:s,compact:i=!0})=>{const u=i?1:2;return r.jsxs(E,{direction:"row",gap:u,alignItems:"center",sx:{height:"24px"},children:[r.jsx(Q,{safetyState:n,anchorOrigin:o,transformOrigin:s,compact:i}),r.jsx(m,{orientation:"vertical",flexItem:!0}),r.jsx(L,{operationMode:a,anchorOrigin:o,transformOrigin:s,compact:i}),r.jsx(m,{orientation:"vertical",flexItem:!0}),r.jsx(C,{isVirtual:e,motionGroupId:t,anchorOrigin:o,transformOrigin:s,compact:i})]})}));exports.SafetyBar=X;exports.makeErrorMessage=O;
1
+ "use strict";const r=require("react/jsx-runtime"),m=require("@mui/material/Divider"),E=require("@mui/material/Stack"),f=require("mobx-react-lite"),w=require("./externalizeComponent-BdxGBLIv.cjs"),y=require("@mui/material/styles"),c=require("react"),d=require("react-i18next"),A=require("@mui/material/Popover"),g=require("@mui/material/SvgIcon"),h=require("@mui/material/Typography"),T=require("axios"),M=require("./converters-BsXgcxCW.cjs");function _(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:()=>e[a]})}}return t.default=e,Object.freeze(t)}const l=_(c);function R(e,t){throw new Error(`${t} ${JSON.stringify(e)}`)}function O(e){var t,a,n,o;return e instanceof T.AxiosError&&e.code==="ERR_NETWORK"?"Failed to connect to the server. Please check your internet connection.":e instanceof T.AxiosError&&e.response?`${(t=e.response)==null?void 0:t.status} ${(a=e.response)==null?void 0:a.statusText} from ${(n=e.response)==null?void 0:n.config.url}: ${JSON.stringify((o=e.response)==null?void 0:o.data)}`:e instanceof Error?e.message:`Unexpected error: ${M.tryStringifyJson(e)||e}`}const j=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M5.248 21c-.334 0-.619-.116-.853-.35a1.153 1.153 0 0 1-.351-.848c0-.333.117-.616.351-.85.234-.233.519-.35.853-.35H7.24L4.558 9.87a2.881 2.881 0 0 1-1.126-1.042A2.77 2.77 0 0 1 3 7.317c0-.793.28-1.467.838-2.023a2.774 2.774 0 0 1 2.033-.834 2.71 2.71 0 0 1 1.728.585c.494.389.832.887 1.014 1.493h3.58V5.239c0-.22.076-.406.226-.555a.76.76 0 0 1 .558-.224c.136 0 .263.035.381.104.118.07.209.167.273.292v.14l1.835-1.702a.979.979 0 0 1 .52-.279.881.881 0 0 1 .58.091l4.01 1.85a.74.74 0 0 1 .36.364.537.537 0 0 1-.002.474.592.592 0 0 1-.366.323.657.657 0 0 1-.477-.039l-3.858-1.774L13.76 6.59v1.454l2.473 2.233 3.858-1.774a.648.648 0 0 1 .485-.03.571.571 0 0 1 .358.314.513.513 0 0 1 .01.482.79.79 0 0 1-.367.357l-4.011 1.882a.881.881 0 0 1-.58.09.979.979 0 0 1-.52-.278L13.63 9.638v.14a.92.92 0 0 1-.273.275.665.665 0 0 1-.381.12.76.76 0 0 1-.558-.224.752.752 0 0 1-.225-.555V8.096h-3.58a2.82 2.82 0 0 1-.215.54 2.552 2.552 0 0 1-.323.479l5.139 9.488h2.673c.335 0 .62.116.854.35.234.233.35.516.35.849 0 .332-.116.615-.35.849a1.167 1.167 0 0 1-.854.349H5.248Zm.623-12.385c.362 0 .67-.126.924-.378a1.25 1.25 0 0 0 .38-.92 1.25 1.25 0 0 0-.38-.92 1.261 1.261 0 0 0-.924-.379 1.26 1.26 0 0 0-.925.379 1.25 1.25 0 0 0-.38.92c0 .36.127.667.38.92.254.252.562.378.925.378Z"})),B=c.forwardRef(j),F=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"m13.37 9.12 1.69 1.69 2.99-2.99-3.73-3.73-.95-.95-7.66 7.66-.95.95 3.99 3.99v3.44h7.55v-3.55l-4.72-4.72 1.79-1.79Zm-.91-2.99.91-.91 2.6 2.6-.91.91-2.6-2.6Zm-2.25 10.24h3.74l-1.34-1.34-.04-.04h-2.5l-3.25-3.25 4.59-4.59.92.92L9.5 10.9l5.33 5.33v1.48H10.2v-1.35l.01.01ZM2 2v4.99h1.41V3.4h3.58V2H2ZM22.21 2h-4.98v1.41h3.59v3.58h1.4V2h-.01ZM20.81 20.65h-3.58v1.4h4.98v-4.99h-1.4v3.59ZM3.4 17.06H2v4.98h4.99v-1.4H3.4v-3.58Z"})),Z=c.forwardRef(F),p=f.observer(({id:e,icon:t,color:a,title:n,name:o,label:s,explanation:i,literalValue:u,anchorOrigin:v,transformOrigin:x})=>{const S=f.useLocalObservable(()=>({anchorEl:null,get isPopoverOpen(){return!!S.anchorEl},openPopover(b){S.anchorEl=b.currentTarget},closePopover(){S.anchorEl=null}}));return r.jsxs(r.Fragment,{children:[r.jsxs(E,{"aria-owns":S.isPopoverOpen?e:void 0,"aria-haspopup":"true",onMouseEnter:S.openPopover,onMouseLeave:S.closePopover,direction:"row",spacing:1,sx:{cursor:"pointer"},children:[r.jsx(g,{component:t,sx:{color:a}}),s&&r.jsx("div",{style:{color:a},children:s})]}),r.jsx(A,{id:e,sx:{pointerEvents:"none"},open:S.isPopoverOpen,anchorEl:S.anchorEl,anchorOrigin:v??{vertical:"bottom",horizontal:"left"},transformOrigin:x??{vertical:"top",horizontal:"left"},onClose:S.closePopover,disableRestoreFocus:!0,children:r.jsxs(E,{gap:"1rem",padding:2,maxWidth:"450px",sx:{wordWrap:"break-word"},children:[r.jsxs("div",{children:[n&&r.jsx(h,{component:"span",fontSize:"14px",children:`${n}: `}),r.jsx(h,{component:"span",color:a,fontWeight:"bold",fontSize:"14px",children:o})]}),r.jsx(h,{fontSize:"14px",children:i}),u&&r.jsx(h,{fontSize:"12px",children:u})]})})]})}),C=f.observer(({isVirtual:e,motionGroupId:t,anchorOrigin:a,transformOrigin:n,compact:o})=>{const s=y.useTheme(),i=c.useId(),{t:u}=d.useTranslation();return e?r.jsx(p,{id:`motion-group-virtual-${i}`,icon:Z,color:s.palette.tertiary.main,name:u("SafetyBar.ControllerType.Virtual.lb"),label:o?null:u("SafetyBar.ControllerType.Virtual.lb"),explanation:r.jsxs(d.Trans,{i18nKey:"SafetyBar.MotionGroup.Virtual.Explanation.lb",values:{motionGroupId:t},children:["Motion group ",r.jsx("code",{children:t})," refers to a virtual robot with no physical counterpart. It can be freely manipulated without special safety precautions."]}),anchorOrigin:a,transformOrigin:n}):r.jsx(p,{id:`motion-group-physical-${i}`,icon:B,color:s.palette.primary.main,name:u("SafetyBar.ControllerType.Physical.lb"),label:o?null:u("SafetyBar.ControllerType.Physical.lb"),explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.MotionGroup.Physical.Explanation.lb",values:{motionGroupId:t},components:{code:r.jsx("code",{}),strong:r.jsx("strong",{})}}),anchorOrigin:a,transformOrigin:n})}),P=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.306 2.768c0-.424.344-.768.768-.768h.406C19.53 2 22 4.551 22 7.699c0 3.237-2.51 5.587-5.31 5.703-.84 1.595-2.478 2.677-4.36 2.677a4.845 4.845 0 0 1-3.146-1.163c-.6 1.783 0 3.922 1.79 4.99 1.929 1.149 4.395.467 5.508-1.524l.212-.378a.75.75 0 1 1 1.308.732l-.231.414c-1.524 2.725-4.9 3.66-7.54 2.085-2.716-1.618-3.432-5.037-2.129-7.599a5.22 5.22 0 0 1-.73-2.677c0-2.192 1.335-4.063 3.212-4.793-1.195-1.427-3.29-1.96-5.08-.892-1.928 1.15-2.589 3.696-1.475 5.687l.231.413a.75.75 0 0 1-1.308.732l-.212-.377c-1.524-2.726-.62-6.211 2.02-7.785 2.716-1.619 5.943-.55 7.44 1.897l.13-.001c2.739 0 4.96 2.292 4.96 5.12 0 .284-.023.563-.066.834 1.795-.354 3.288-1.96 3.288-4.095 0-2.3-1.805-4.163-4.032-4.163h-.406a.768.768 0 0 1-.768-.768Zm.496 8.191c0 .286-.033.564-.094.831a3.62 3.62 0 0 1-.672 1.415 3.425 3.425 0 0 1-2.706 1.338 3.402 3.402 0 0 1-2.384-.98 3.598 3.598 0 0 1-.852-1.306 3.677 3.677 0 0 1-.235-1.298c0-1.623 1.046-2.994 2.48-3.435a3.37 3.37 0 0 1 1.522-.107c1.665.264 2.94 1.75 2.94 3.542Z"})),$=c.forwardRef(P),N=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M19.763 16.432 13.516 5.864c-.674-1.152-2.358-1.152-3.049 0l-6.23 10.568C3.563 17.567 4.405 19 5.753 19H18.23c1.364 0 2.206-1.432 1.532-2.568ZM12 8.498c.539 0 .96.428.96.938v.066l-.32 4.708a.639.639 0 0 1-.64.592.639.639 0 0 1-.64-.592l-.32-4.708A.953.953 0 0 1 12 8.498Zm0 8.79c-.556 0-1.01-.444-1.01-.987 0-.544.454-.988 1.01-.988s1.01.444 1.01.988c0 .542-.454.987-1.01.987Z",fill:"#fff",fillOpacity:.56})),Y=c.forwardRef(N),V=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M12.953 5.09a1.497 1.497 0 0 0-1.653-.518l-1.35.43a1.504 1.504 0 0 0-1.726-.376L2.858 6.97c-.736.321-1.06 1.155-.726 1.862.334.707 1.202 1.02 1.937.698l4.27-1.865 1.466 1.973v.402c0 .873-.627 1.63-1.512 1.827l-2.56.567c-1.329.295-2.27 1.431-2.27 2.74v.107c0 .26.22.469.489.469h11.117c1.329 0 2.618.435 3.656 1.233l1.665 1.28A1 1 0 0 0 22 17.47V11.062c0-.312-.108-.616-.308-.863l-3.415-4.218a1.5 1.5 0 0 0-1.618-.471l-.378.12-.866-.475a1.516 1.516 0 0 0-1.188-.114l-1.06.338-.214-.289Z"})),q=c.forwardRef(V),L=f.observer(({operationMode:e,anchorOrigin:t,transformOrigin:a,compact:n})=>{const{t:o}=d.useTranslation(),s=y.useTheme(),i=c.useId();switch(e){case"OPERATION_MODE_AUTO":return r.jsx(p,{id:`operation-mode-auto-${i}`,icon:$,title:o("SafetyBar.OperationMode.ti"),name:o("SafetyBar.OperationMode.Automatic.ti"),label:n?null:o("SafetyBar.OperationMode.Automatic.ti"),color:s.palette.text.secondary,explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.OperationMode.Auto.Explanation.lb",children:"The robot controller is in automatic operation mode. Automated movement without manual confirmation is possible in this mode."}),anchorOrigin:t,transformOrigin:a});case"OPERATION_MODE_MANUAL":case"OPERATION_MODE_MANUAL_T1":case"OPERATION_MODE_MANUAL_T2":return r.jsx(p,{id:`operation-mode-manual-${i}`,icon:q,color:s.palette.warning.main,title:o("SafetyBar.OperationMode.ti"),name:o("SafetyBar.OperationMode.Manual.lb"),label:n?null:o("SafetyBar.OperationMode.Manual.lb"),explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.OperationMode.Manual.Explanation.lb",children:"The robot controller is in manual operation mode. On a physical robot, this generally indicates that an enabling switch must be held for the robot to move successfully."}),literalValue:e,anchorOrigin:t,transformOrigin:a});default:return r.jsx(p,{id:`operation-mode-error-${i}`,icon:Y,color:s.palette.warning.main,title:o("SafetyBar.OperationMode.ti"),name:o("SafetyBar.OperationMode.Error.lb"),label:n?null:o("SafetyBar.OperationMode.Error.lb"),explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.OperationMode.Error.Explanation.lb",children:"The robot controller has entered an unexpected operation mode. Motion group movement may not be possible."}),literalValue:e,anchorOrigin:t,transformOrigin:a})}}),I=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M19.763 16.432 13.516 5.864c-.674-1.152-2.358-1.152-3.049 0l-6.23 10.568C3.563 17.567 4.405 19 5.753 19H18.23c1.364 0 2.206-1.432 1.532-2.568ZM12 8.498c.539 0 .96.428.96.938v.066l-.32 4.708a.639.639 0 0 1-.64.592.639.639 0 0 1-.64-.592l-.32-4.708A.953.953 0 0 1 12 8.498Zm0 8.79c-.556 0-1.01-.444-1.01-.987 0-.544.454-.988 1.01-.988s1.01.444 1.01.988c0 .542-.454.987-1.01.987Z"})),K=c.forwardRef(I),D=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M10.24 10.636 12 13.764l1.76-3.128h-3.52Z"}),l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.364 12a6.364 6.364 0 1 1-12.728 0 6.364 6.364 0 0 1 12.728 0ZM7.909 9.273 12 16.546l4.09-7.273H7.91Z"}),l.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-1.364 0a8.636 8.636 0 1 1-17.273 0 8.636 8.636 0 0 1 17.273 0Z"})),H=c.forwardRef(D),U=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M9.057 15.115c-1.681 0-3.111-.59-4.29-1.768C3.59 12.17 3 10.74 3 9.057c0-.29.021-.582.064-.876a4.1 4.1 0 0 1 .214-.844.78.78 0 0 1 .273-.36c.115-.077.244-.133.389-.168a.857.857 0 0 1 .437.008c.146.04.28.12.4.24l2.806 2.787 2.26-2.261-2.775-2.786a.903.903 0 0 1-.241-.405.875.875 0 0 1-.008-.442 1.13 1.13 0 0 1 .174-.389.82.82 0 0 1 .355-.273c.268-.107.548-.182.838-.224.29-.043.581-.064.871-.064 1.682 0 3.112.59 4.29 1.768 1.179 1.178 1.768 2.608 1.768 4.29 0 .444-.042.858-.126 1.241-.084.384-.21.755-.377 1.113l5.726 5.692A2.2 2.2 0 0 1 21 18.721a2.2 2.2 0 0 1-.662 1.617A2.2 2.2 0 0 1 18.72 21a2.173 2.173 0 0 1-1.617-.679l-5.692-5.709c-.372.161-.75.285-1.133.372-.383.087-.79.13-1.222.13Z",fill:"#fff",fillOpacity:.56})),z=c.forwardRef(U),k=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"m10.6 13.8-2.15-2.15a.948.948 0 0 0-.7-.275.948.948 0 0 0-.7.275.948.948 0 0 0-.275.7c0 .283.092.517.275.7L9.9 15.9c.2.2.433.3.7.3.267 0 .5-.1.7-.3l5.65-5.65a.948.948 0 0 0 .275-.7.948.948 0 0 0-.275-.7.948.948 0 0 0-.7-.275.948.948 0 0 0-.7.275L10.6 13.8ZM12 22a9.738 9.738 0 0 1-3.9-.788 10.099 10.099 0 0 1-3.175-2.137c-.9-.9-1.612-1.958-2.137-3.175A9.738 9.738 0 0 1 2 12c0-1.383.263-2.683.788-3.9a10.099 10.099 0 0 1 2.137-3.175c.9-.9 1.958-1.612 3.175-2.137A9.738 9.738 0 0 1 12 2c1.383 0 2.683.263 3.9.788a10.098 10.098 0 0 1 3.175 2.137c.9.9 1.613 1.958 2.137 3.175A9.738 9.738 0 0 1 22 12a9.738 9.738 0 0 1-.788 3.9 10.098 10.098 0 0 1-2.137 3.175c-.9.9-1.958 1.613-3.175 2.137A9.738 9.738 0 0 1 12 22Zm0-2c2.233 0 4.125-.775 5.675-2.325C19.225 16.125 20 14.233 20 12c0-2.233-.775-4.125-2.325-5.675C16.125 4.775 14.233 4 12 4c-2.233 0-4.125.775-5.675 2.325C4.775 7.875 4 9.767 4 12c0 2.233.775 4.125 2.325 5.675C7.875 19.225 9.767 20 12 20Z"})),W=c.forwardRef(k),G=({title:e,titleId:t,...a},n)=>l.createElement("svg",{width:24,height:24,xmlns:"http://www.w3.org/2000/svg",ref:n,"aria-labelledby":t,...a},e?l.createElement("title",{id:t},e):null,l.createElement("path",{d:"M9 16h6c.283 0 .52-.096.713-.287A.968.968 0 0 0 16 15V9a.967.967 0 0 0-.287-.713A.968.968 0 0 0 15 8H9a.968.968 0 0 0-.713.287A.968.968 0 0 0 8 9v6c0 .283.096.52.287.713.192.191.43.287.713.287Zm3 6a9.738 9.738 0 0 1-3.9-.788 10.099 10.099 0 0 1-3.175-2.137c-.9-.9-1.612-1.958-2.137-3.175A9.738 9.738 0 0 1 2 12c0-1.383.263-2.683.788-3.9a10.099 10.099 0 0 1 2.137-3.175c.9-.9 1.958-1.612 3.175-2.137A9.738 9.738 0 0 1 12 2c1.383 0 2.683.263 3.9.788a10.098 10.098 0 0 1 3.175 2.137c.9.9 1.613 1.958 2.137 3.175A9.738 9.738 0 0 1 22 12a9.738 9.738 0 0 1-.788 3.9 10.098 10.098 0 0 1-2.137 3.175c-.9.9-1.958 1.613-3.175 2.137A9.738 9.738 0 0 1 12 22Zm0-2c2.233 0 4.125-.775 5.675-2.325C19.225 16.125 20 14.233 20 12c0-2.233-.775-4.125-2.325-5.675C16.125 4.775 14.233 4 12 4c-2.233 0-4.125.775-5.675 2.325C4.775 7.875 4 9.767 4 12c0 2.233.775 4.125 2.325 5.675C7.875 19.225 9.767 20 12 20Z"})),J=c.forwardRef(G),Q=f.observer(({safetyState:e,anchorOrigin:t,transformOrigin:a,compact:n})=>{const{t:o}=d.useTranslation(),s=y.useTheme(),i=c.useId();switch(e){case"SAFETY_STATE_NORMAL":return r.jsx(p,{id:`safety-state-normal-${i}`,title:o("SafetyBar.SafetyState.ti"),name:o("SafetyBar.SafetyState.Normal.lb"),label:n?null:o("SafetyBar.SafetyState.Normal.lb"),icon:W,color:s.palette.text.secondary,explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.SafetyState.Normal.Explanation.lb",children:"The robot controller is in a normal safety state. Movement is not prevented by this state."}),anchorOrigin:t,transformOrigin:a});case"SAFETY_STATE_DEVICE_EMERGENCY_STOP":case"SAFETY_STATE_ROBOT_EMERGENCY_STOP":return r.jsx(p,{id:`safety-state-estop-${i}`,title:o("SafetyBar.SafetyState.ti"),name:o("SafetyBar.SafetyState.Estop.lb"),label:n?null:o("SafetyBar.SafetyState.Estop.lb"),icon:H,color:s.palette.error.main,explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.StopState.Estop.Explanation.lb",children:"An emergency stop of the robot controller has been triggered. Movement of the robot is no longer possible until the estop is released."}),literalValue:e,anchorOrigin:t,transformOrigin:a});case"SAFETY_STATE_STOP_0":case"SAFETY_STATE_STOP_1":case"SAFETY_STATE_STOP_2":case"SAFETY_STATE_PROTECTIVE_STOP":case"SAFETY_STATE_STOP":return r.jsx(p,{id:`safety-state-stop-${i}`,icon:J,title:o("SafetyBar.SafetyState.ti"),name:o("SafetyBar.SafetyState.Stop.lb"),label:n?null:o("SafetyBar.SafetyState.Stop.lb"),color:s.palette.warning.main,explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.SafetyState.Stop.Explanation.lb",children:"The robot controller has entered a stop state. Movement is no longer possible until the stop state is resolved."}),literalValue:e,anchorOrigin:t,transformOrigin:a});case"SAFETY_STATE_REDUCED":case"SAFETY_STATE_MASTERING":case"SAFETY_STATE_CONFIRM_SAFETY":case"SAFETY_STATE_OPERATOR_SAFETY":case"SAFETY_STATE_RECOVERY":case"SAFETY_STATE_VIOLATION":return r.jsx(p,{id:`safety-state-manual-action-required-${i}`,icon:z,color:s.palette.warning.main,title:o("SafetyBar.SafetyState.ti"),name:o("SafetyBar.SafetyState.ManualActionRequired.lb"),label:n?null:o("SafetyBar.SafetyState.ManualActionRequired.lb"),explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.SafetyState.ManualActionRequired.Explanation.lb",children:"The robot controller has entered a safety state requiring manual action to resolve."}),literalValue:e,anchorOrigin:t,transformOrigin:a});case"SAFETY_STATE_UNKNOWN":case"SAFETY_STATE_FAULT":return r.jsx(p,{id:`safety-state-error-${i}`,icon:K,color:s.palette.error.main,title:o("SafetyBar.SafetyState.ti"),name:o("SafetyBar.SafetyState.Error.lb"),label:n?null:o("SafetyBar.SafetyState.Error.lb"),explanation:r.jsx(d.Trans,{i18nKey:"SafetyBar.SafetyState.Error.Explanation.lb",children:"The robot controller has entered an unexpected safety state."}),literalValue:e,anchorOrigin:t,transformOrigin:a});default:R(e,`Unknown safety state ${e}`)}}),X=w.externalizeComponent(f.observer(({isVirtual:e,motionGroupId:t,operationMode:a,safetyState:n,anchorOrigin:o,transformOrigin:s,compact:i=!0})=>{const u=i?1:2;return r.jsxs(E,{direction:"row",gap:u,alignItems:"center",sx:{height:"24px"},children:[r.jsx(Q,{safetyState:n,anchorOrigin:o,transformOrigin:s,compact:i}),r.jsx(m,{orientation:"vertical",flexItem:!0}),r.jsx(L,{operationMode:a,anchorOrigin:o,transformOrigin:s,compact:i}),r.jsx(m,{orientation:"vertical",flexItem:!0}),r.jsx(C,{isVirtual:e,motionGroupId:t,anchorOrigin:o,transformOrigin:s,compact:i})]})}));exports.SafetyBar=X;exports.makeErrorMessage=O;
@@ -11,7 +11,7 @@ import O from "@mui/material/Popover";
11
11
  import B from "@mui/material/SvgIcon";
12
12
  import E from "@mui/material/Typography";
13
13
  import { AxiosError as w } from "axios";
14
- import { t as F } from "./converters-DpNB_WNQ.js";
14
+ import { a as F } from "./converters-D9KpJ2HD.js";
15
15
  function Z(e, t) {
16
16
  throw new Error(`${t} ${JSON.stringify(e)}`);
17
17
  }
@@ -0,0 +1,3 @@
1
+ "use strict";const s=require("react/jsx-runtime"),Ut=require("@mui/material/AppBar"),It=require("@mui/material/Backdrop"),D=require("@mui/material/Box"),Gt=require("@mui/material/Menu"),F=require("@mui/material/MenuItem"),Wt=require("@mui/material/Toolbar"),w=require("@mui/material/Typography"),Ht=require("@wandelbots/design-tokens"),Kt=require("@wandelbots/icons/ExpandMoreFilled"),Yt=require("@wandelbots/mui"),E=require("mobx-react-lite"),C=require("react"),Q=require("./externalizeComponent-BdxGBLIv.cjs"),Qt=require("@mui/icons-material/OpenWith"),Zt=require("@mui/icons-material/Share"),v=require("@mui/material/Stack"),Xt=require("@mui/material/Tab"),te=require("@mui/material/Tabs"),y=require("mobx"),P=require("react-i18next"),_=require("@wandelbots/nova-js"),V=require("@wandelbots/nova-js/v2"),$=require("three"),x=require("./Pose3-DIyg-aZA.cjs"),_t=require("@mui/material/CircularProgress"),ee=require("@mui/material/utils"),wt=require("lodash-es"),oe=require("./SafetyBar-BVk-SH_0.cjs"),ne=require("@mui/material/Alert"),ie=require("@mui/material/AlertTitle"),nt=require("@mui/material/Button"),N=require("@mui/material/styles"),q=require("@mui/material/Divider"),pt=require("@mui/material/ToggleButton"),X=require("@mui/material/IconButton"),B=require("./joggingColors-ZDc_2UCp.cjs"),Et=require("lodash-es/isEqual.js"),re=require("@mui/material/InputAdornment"),se=require("@mui/material/FormControl"),ae=require("@mui/material/InputLabel"),ce=require("@mui/material/Select"),H=require("lodash-es/keyBy.js"),le=require("lodash-es/uniqueId.js"),de=require("@mui/material/ToggleButtonGroup"),Mt=require("@mui/material/Slider"),ge=require("lodash-es/isNumber.js"),ue=require("@mui/icons-material/ChevronLeft"),he=require("@mui/icons-material/ChevronRight"),me=require("lodash-es/throttle.js"),pe=require("@mui/material/Dialog"),fe=require("@mui/material/DialogActions"),ye=require("@mui/material/DialogContent"),Se=require("@mui/material/DialogTitle"),xe=require("./converters-BsXgcxCW.cjs");function Tt(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 b=Tt(C),ft=Tt($),je=Q.externalizeComponent(E.observer(e=>{const{appIcon:t,appName:o,apps:n=[],onAppSelect:i,disabled:r=!1,sx:a}=e,[c,d]=C.useState(null),h=!!c,u=l=>{d(l.currentTarget)},m=()=>{d(null)},g=l=>{m(),l.onClick?l.onClick():l.href&&(window.location.href=l.href),i==null||i(l)};return s.jsxs(s.Fragment,{children:[s.jsx(Ut,{position:"static",sx:{boxShadow:"none",backgroundImage:"none","& .MuiAppBar-root":{backgroundImage:"none",backgroundColor:"transparent"},...a},children:s.jsxs(Wt,{sx:{minHeight:"62px !important"},children:[s.jsx(D,{sx:{mr:1,display:"flex",alignItems:"center"},children:t}),s.jsxs(D,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[s.jsx(w,{component:"h1",variant:"subtitle1",children:o}),n.length>0&&s.jsx(Yt.RoundedIconButton,{icon:s.jsx(Kt.ExpandMoreFilled,{size:20}),ariaLabel:"switch app","aria-controls":"app-menu","aria-haspopup":"true",onClick:u,disabled:r,sx:{ml:1}})]})]})}),s.jsx(It,{open:h,onClick:m,sx:{backdropFilter:"blur(4px)",backgroundColor:Ht.ZeroGravityComponentsBackdropFill,zIndex:l=>l.zIndex.modal-1}}),s.jsx(Gt,{id:"app-menu",anchorEl:c,open:h,onClose:m,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{zIndex:l=>l.zIndex.modal,"& .MuiPaper-root":{minWidth:200,mt:1}},children:n.map(l=>s.jsxs(F,{onClick:()=>g(l),children:[s.jsx(D,{sx:{display:"flex",alignItems:"center"},children:l.icon}),s.jsx(w,{variant:"body1",sx:{ml:2},children:l.name})]},l.id))})]})})),be=({title:e,titleId:t,...o},n)=>b.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?b.createElement("title",{id:t},e):null,b.createElement("g",{id:"JogMinus"},b.createElement("path",{id:"Minus",d:"M0 13V8H21V13H0Z",fill:"white"}))),ve=C.forwardRef(be),Ce=({title:e,titleId:t,...o},n)=>b.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?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"})))),Ie=C.forwardRef(Ce),it=Q.externalizeComponent(E.observer(({colors:e,label:t,getDisplayedValue:o,startJogging:n,stopJogging:i,disabled:r,activeJoggingDirection:a,...c})=>{var k,O,J,I,R,z,U;x.useAnimationFrame(()=>{const A=o(),L=g.current;L&&(L.textContent=A)});const d=N.useTheme(),[h,u]=C.useState(null);C.useEffect(()=>{r&&M()},[r]);const m=a||h,g=C.useRef(null);e||(e={color:"#fff",backgroundColor:"#000",borderColor:"#000",buttonBackgroundColor:{disabled:"#000",default:"#000",hovered:"#000",pressed:"#000"},labelColor:"#000"});const l=m?(k=e.buttonBackgroundColor)==null?void 0:k.pressed:e.borderColor,f={width:"55px",color:e.color,path:{fill:e.color},alignContent:"center",fontSize:"37px",svg:{pointerEvents:"none"}},p={...f,backgroundColor:(O=e.buttonBackgroundColor)==null?void 0:O.default,":hover":{backgroundColor:(J=e.buttonBackgroundColor)==null?void 0:J.hovered},":active":{backgroundColor:(I=e.buttonBackgroundColor)==null?void 0:I.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor}},":disabled":{backgroundColor:(R=e.buttonBackgroundColor)==null?void 0:R.disabled,"svg path":{fill:d.palette.action.disabled}}},j={...f,backgroundColor:(z=e.buttonBackgroundColor)==null?void 0:z.pressed,color:e.backgroundColor,path:{fill:e.backgroundColor},":disabled":{backgroundColor:(U=e.buttonBackgroundColor)==null?void 0:U.pressed,"svg path":{fill:d.palette.action.disabled}}};function T(A,L){r||A.button===0&&(u(L),n(L))}function M(){u(null),i()}return s.jsxs(v,{height:"64px",direction:"row",justifyContent:"center",...c,children:[s.jsx(X,{disabled:r,disableRipple:!0,onPointerDown:A=>T(A,"-"),onPointerUp:M,onPointerOut:M,size:"large",sx:{...m==="-"?j:p,borderRadius:"16px 0px 0px 16px",borderLeft:`2px solid ${l??"#fff"}`,borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:s.jsx(ve,{})}),s.jsxs(v,{spacing:"6px",sx:{width:"150px",backgroundColor:e.backgroundColor,alignItems:"center",justifyContent:"center",opacity:"0.9",borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:[s.jsx(v,{height:"22px",direction:"row",alignItems:"center",justifyItems:"center",spacing:1,sx:{userSelect:"none",color:e.color,".MuiTypography-root":{fontWeight:700,...r?{color:d.palette.action.disabled}:{}},...r?{"svg path":{fill:d.palette.action.disabled}}:{}},children:t}),s.jsx(w,{height:"22px",sx:{fontSize:"15px",color:r?d.palette.action.disabled:e.color,fontWeight:700,fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center"},ref:g,children:o()})]}),s.jsx(X,{disableRipple:!0,disabled:r,onPointerDown:A=>T(A,"+"),onPointerUp:M,onPointerOut:M,size:"large",sx:{...m==="+"?j:p,borderRadius:"0px 16px 16px 0px",borderRight:`2px solid ${l??"#fff"}`,borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:s.jsx(Ie,{})})]})})),kt=Q.externalizeComponent(E.observer(({startJogging:e,stopJogging:t,lowerLimit:o,upperLimit:n,useDegree:i,getValue:r,disabled:a,...c})=>{var I,R,z,U,A,L,mt;const{t:d}=P.useTranslation(),[h,u]=C.useState(),m=N.useTheme(),g={background:(I=m.palette.backgroundPaperElevation)==null?void 0:I[4],color:(R=m.palette.backgroundPaperElevation)==null?void 0:R[11]},l=E.useLocalObservable(()=>({activeJoggingDir:null,startJogging(S){this.activeJoggingDir=S,e(S)},stopJogging(){this.activeJoggingDir=null,t()}})),f=me(()=>{const S=i?p(r()):r();(S===void 0||h===void 0||Math.abs(h-S)>1e-9)&&u(S)},50);x.useAnimationFrame(f);function p(S){if(S!==void 0)return _.radiansToDegrees(S)}function j(S){S.button===0&&l.startJogging("-")}function T(S){S.button===0&&l.startJogging("+")}function M(S){l.stopJogging()}function k(S){l.stopJogging()}function O(S,G=1){if(S===void 0||Number.isNaN(S))return"";const W=d("General.degree.variable",{amount:S.toFixed(G)});return S>0&&G===0?`+${W}`:W}function J(S,G=1){if(S===void 0||Number.isNaN(S))return"";const W=d("General.mm.variable",{amount:S.toFixed(G)});return S>0&&G===0?`+${W}`:W}return s.jsxs(v,{height:"64px",width:"100%",maxWidth:"260px",direction:"row",...c,sx:{"& .MuiIconButton-root":{width:"52px",color:m.palette.text.primary,alignContent:"center",backgroundColor:(z=m.palette.backgroundPaperElevation)==null?void 0:z[11],"& svg":{width:"42px",height:"42px"},"&.Mui-disabled":{backgroundColor:(U=m.palette.backgroundPaperElevation)==null?void 0:U[11],color:m.palette.action.disabled,opacity:1},"&:hover":{backgroundColor:(A=m.palette.backgroundPaperElevation)==null?void 0:A[9]},"&:active":{...g}}},children:[s.jsx(X,{onPointerDown:j,onPointerUp:M,onPointerOut:k,disabled:a,disableRipple:!0,sx:{borderRadius:"16px 0px 0px 16px",...l.activeJoggingDir==="-"?g:{}},children:s.jsx(ue,{sx:{pointerEvents:"none",color:B.jointArrowColor}})}),s.jsxs(v,{flexGrow:1,alignItems:"center",justifyContent:"center",sx:{borderStyle:"solid",borderLeftWidth:0,borderRightWidth:0,border:"none",backgroundColor:(L=m.palette.backgroundPaperElevation)==null?void 0:L[11],paddingLeft:"20px",paddingRight:"20px",zIndex:1},children:[s.jsx(w,{sx:{fontSize:"15px",fontWeight:700,position:"relative",top:"5px",fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center",color:a?m.palette.action.disabled:m.palette.text.primary},children:i?O(h):J(h)}),s.jsx(Mt,{disabled:!0,"aria-label":"Joint position",min:i?p(o):o,max:i?p(n):n,value:h||0,track:!1,sx:{"& .MuiSlider-mark":{display:"none"},"& .MuiSlider-thumb":{width:"5px",height:"12px",borderRadius:"2px",color:a?m.palette.action.disabled:m.palette.text.primary},"& .MuiSlider-markLabel":{top:"20px",fontSize:"12px",color:a?m.palette.action.disabled:m.palette.text.secondary},"& .MuiSlider-rail":{backgroundColor:(mt=m.palette.backgroundPaperElevation)==null?void 0:mt[5],opacity:1}},marks:o!==void 0&&n!==void 0&&[{value:i?p(o):o,label:i?O(p(o),0):J(o)},{value:i?p(n):n,label:i?O(p(n),0):J(n)}]})]}),s.jsx(X,{onPointerDown:T,onPointerUp:M,onPointerOut:k,disabled:a,disableRipple:!0,sx:{borderRadius:"0px 16px 16px 0px",...l.activeJoggingDir==="+"?g:{}},children:s.jsx(he,{sx:{pointerEvents:"none",color:B.jointArrowColor}})})]})}));function _e({currentTcpPose:e,axis:t,direction:o,motion:n,useToolCoordinateSystem:i,coordinateSystemRotation:r}){const a=o==="-"?-1:1;if(n.type==="translate"){if(!e.position)throw new Error("Current pose has no position, cannot perform translation");const m=n.distanceMm*a,g=new $.Vector3;if(g[t]=m,i){if(!e.orientation)throw new Error("Current pose has no orientation, cannot translate relative to tool");g.applyQuaternion(x.parseRotationToQuaternion(e.orientation,"ROTATION_VECTOR"))}else r&&g.applyQuaternion(r);const l=[...e.position];return l[0]=(l[0]??0)+g.x,l[1]=(l[1]??0)+g.y,l[2]=(l[2]??0)+g.z,{position:l,orientation:e.orientation}}if(!e.orientation)throw new Error("Current pose has no orientation, cannot perform rotation");const c=x.parseRotationToQuaternion(e.orientation,"ROTATION_VECTOR"),d=new $.Vector3;d[t]=1,!i&&r&&d.applyQuaternion(r);const h=new $.Quaternion().setFromAxisAngle(d,n.distanceRads*a),u=i?c.multiply(h):h.multiply(c);return{position:e.position,orientation:[...x.quaternionToRotationVector(u)]}}function at(e,t,o){return t.length!==e.length?!1:Ot(e,t,o)}function ct(e,t,o){return t.length!==e.length?!0:Ot(e,t,o)}function Ot(e,t,o){for(let n=0;n<t.length;n++)if(Math.abs((t[n]??0)-(e[n]??0))>o)return!1;return!0}function Jt(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 lt(e,t,o){return e.coordinate_system===t.coordinate_system&&e.tcp===t.tcp&&Jt(e.tcp_pose,t.tcp_pose,o)}function dt(e,t){const o=new $.Vector3(t[0],t[1],t[2]),n=new $.Vector3(e[0],e[1],e[2]),i=o.length(),r=o.normalize();let a=n.length(),c=n.normalize();c.dot(r)<0&&(a=-a,c=c.multiplyScalar(-1));let d=a-i;return d-=2*Math.PI*Math.floor((d+Math.PI)/(2*Math.PI)),a=i+d,[...c.multiplyScalar(a)]}const we=2e-4;function gt(e){const{joint_position:t,tcp_pose:o,tcp:n,coordinate_system:i}=e;return{joint_position:t,tcp_pose:o,tcp:n,coordinate_system:i}}function ut(e,t){return e.tcp===t.tcp&&e.coordinate_system===t.coordinate_system&&e.tcp_pose===void 0==(t.tcp_pose===void 0)&&at(e.joint_position,t.joint_position,we)}const yt=1e-4;class et{constructor(t,o,n,i,r,a,c="cell",d={}){this.controller=o,this.motionGroup=n,this.description=i,this.initialMotionState=r,this.motionStateSocket=a,this.cellId=c,this.nova=x.createNovaClient(t),this.logger=d.logger??console,this.rapidlyChangingMotionState=r,a.addEventListener("message",h=>{var l;const u=(l=_.tryParseJson(h.data))==null?void 0:l.result;if(!u)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${h.data}`);lt(this.rapidlyChangingMotionState,u,yt)||y.runInAction(()=>{var f,p,j;this.rapidlyChangingMotionState.tcp_pose==null?this.rapidlyChangingMotionState.tcp_pose=u.tcp_pose:(f=u.tcp_pose)!=null&&f.orientation&&((p=u.tcp_pose)!=null&&p.position)&&((j=this.rapidlyChangingMotionState.tcp_pose)!=null&&j.orientation)?this.rapidlyChangingMotionState.tcp_pose={position:u.tcp_pose.position,orientation:dt(u.tcp_pose.orientation,this.rapidlyChangingMotionState.tcp_pose.orientation)}:this.logger.debug("Received incomplete tcp_pose, ignoring",{tcpPose:u.tcp_pose})}),ct(this.rapidlyChangingMotionState.joint_position,u.joint_position,yt)||y.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=u.joint_position}),u.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==u.tcp&&y.runInAction(()=>{this.rapidlyChangingMotionState.tcp=u.tcp}),this.rapidlyChangingMotionState.standstill!==u.standstill&&y.runInAction(()=>{this.rapidlyChangingMotionState.standstill=u.standstill});const m=this.rapidlyChangingMotionState.joint_limit_reached.limit_reached,g=u.joint_limit_reached.limit_reached;m.some((f,p)=>f!==g[p])&&y.runInAction(()=>{this.rapidlyChangingMotionState.joint_limit_reached=u.joint_limit_reached}),this.rapidlyChangingMotionState.execute!==u.execute&&y.runInAction(()=>{this.rapidlyChangingMotionState.execute=u.execute})}),y.makeAutoObservable(this,{logger:!1,readoutState:y.computed({equals:ut,keepAlive:!0})})}static async open(t,o,n={}){var p;const i=x.createNovaClient(t),r=n.cellId??x.cellIdOf(t)??"cell",[a,c]=o.split("@"),d=await i.api.controller.getCurrentRobotControllerState(r,c),h=d==null?void 0:d.motion_groups.find(j=>j.motion_group===o);if(!d||!h)throw new Error(`Controller ${c} or motion group ${o} not found`);const u=i.openReconnectingWebsocket(`/cells/${r}/controllers/${c}/motion-groups/${o}/state-stream`),m=await u.firstMessage(),g=(p=_.tryParseJson(m.data))==null?void 0:p.result;if(!g)throw new Error(`Unable to parse initial motion state message ${m.data}`);const l=n.logger??console;l.info("Connected motion state websocket to motion group",{motionGroup:h.motion_group,initialMotionState:g});const f=await i.api.motionGroup.getMotionGroupDescription(r,c,h.motion_group);return new et(i,d,h,f,g,u,r,{logger:l})}get readoutState(){return gt(this.rapidlyChangingMotionState)}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 St="Movement request rejected. Another client is currently executing a 'Jogging' motion!",Ee=500,Me=5e3;function Te(e){var o;return(((o=e.times)==null?void 0:o[e.times.length-1])??0)*2e3+Me}class ot{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.incrementalMotionInFlight=!1,this.ownsMotionStream=!1,this.tcp=(o==null?void 0:o.tcp)||t.motionGroup.tcp||this.getDefaultTcp(t),this.coordinateSystem=o==null?void 0:o.coordinateSystem,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,this.logger=(o==null?void 0:o.logger)??console}static async open(t,o,n={}){const i=await et.open(t,o,{cellId:n.cellId,logger:n.logger}),r=new ot(i,n);r.ownsMotionStream=!0;try{await r.setJoggingMode(r.mode)}catch(a){throw r.dispose(),a}return r}getDefaultTcp(t){var n,i;const o=(i=(n=t.description.dh_parameters)==null?void 0:n[0])==null?void 0:i.type;return t.joints.length<6&&(o===V.JointTypeEnum.RevoluteJoint||o===V.JointTypeEnum.PrismaticJoint)?this.NO_TCP:this.DEFAULT_TCP}async setOptions(t){return t.tcp&&(this.tcp=t.tcp),t.orientation&&(this.orientation=t.orientation),"coordinateSystem"in t&&(this.coordinateSystem=t.coordinateSystem),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,n;(o=this.endJoggingInit)==null||o.call(this),(n=this.endIncrementalMotion)==null||n.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 n=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`);this.joggingSocket=n;let i=!1;const r=setTimeout(()=>{a(new Error(`Jogging initialization timeout after ${this.timeout} ms`))},this.timeout),a=h=>{i||(i=!0,clearTimeout(r),n.removeEventListener("close",d),this.endJoggingInit===c&&(this.endJoggingInit=void 0),h?o(h):t())},c=()=>a(),d=()=>{n.disposed&&a()};this.endJoggingInit=c,n.addEventListener("close",d),n.addEventListener("message",h=>{var m,g,l;const u=_.tryParseJson(h.data);if(((m=u==null?void 0:u.result)==null?void 0:m.kind)==="INITIALIZE_RECEIVED"){a();return}if(((g=u==null?void 0:u.result)==null?void 0:g.kind)==="MOTION_ERROR")if(this.onBlocked&&((l=u==null?void 0:u.result)!=null&&l.message.includes(St))){a(),n.dispose(),this.onBlocked();return}else this.onError?(a(),this.onError(h.data)):a(new Error(h.data))}),n.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:t,direction:o,velocityValue:n,velocityUnit:i}){if(!this.joggingSocket||this.mode!=="jogging")throw new Error("Joint jogging websocket not connected; create one by setting jogging mode to 'jogging'");const r=new Array(this.numJoints).fill(0);r[t]=o==="-"?-n:n,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:r})}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'");this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:this.velocityAlongAxis(t,o==="-"?-n:n),rotation:[0,0,0],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'");this.joggingSocket.sendJson({message_type:"TcpVelocityRequest",translation:[0,0,0],rotation:this.velocityAlongAxis(t,o==="-"?-n:n),use_tool_coordinate_system:this.orientation==="tool"})}get coordinateSystemRotation(){if(!(this.orientation==="tool"||!this.coordinateSystem))return x.Pose3.fromCoordinateSystem(this.coordinateSystem).quaternion}velocityAlongAxis(t,o){const n=new $.Vector3;n[t]=o;const i=this.coordinateSystemRotation;return i&&n.applyQuaternion(i),[n.x,n.y,n.z]}async runIncrementalCartesianMotion(t){if(this.mode!=="trajectory")throw new Error("Set jogging mode to 'trajectory' to run incremental cartesian motions");if(!this.incrementalMotionInFlight){this.incrementalMotionInFlight=!0;try{const o=await this.planIncrementalCartesianMotion(t);o&&await this.executeTrajectory(o)}finally{this.incrementalMotionInFlight=!1}}}async planIncrementalCartesianMotion({currentTcpPose:t,currentJoints:o,velocityInRelevantUnits:n,axis:i,direction:r,motion:a}){var p,j,T;const c=[],d=_e({currentTcpPose:t,axis:i,direction:r,motion:a,useToolCoordinateSystem:this.orientation==="tool",coordinateSystemRotation:this.coordinateSystemRotation});c.push({limits_override:a.type==="translate"?{tcp_velocity_limit:n}:{tcp_orientation_velocity_limit:n},path:{path_definition_name:"PathLine",target_pose:{position:d.position,orientation:d.orientation}}});const h=this.motionStream.description;if(h.cycle_time===void 0){this.logger.warn("Current motion group has no cycle time, cannot plan jogging motion");return}const u=this.motionStream.rapidlyChangingMotionState.tcp,m=u?(j=(p=h.tcps)==null?void 0:p[u])==null?void 0:j.pose:void 0,g={motion_group_model:((T=this.options)==null?void 0:T.motionGroupModel)??h.motion_group_model,cycle_time:h.cycle_time,mounting:h.mounting,tcp_offset:m,global:h.operation_limits.auto_limits},l=await this.nova.api.trajectoryPlanning.planTrajectory(this.cellId,{motion_group_setup:g,start_joint_position:o,motion_commands:c}),f=l.response;if(!f)throw new Error(`Failed to plan jogging increment motion ${JSON.stringify(l)}`);if("error_feedback"in f){if(this.onError){this.onError(f);return}throw new Error(`Failed to plan jogging increment motion: ${JSON.stringify(f.error_feedback)}`)}return f}async executeTrajectory(t){const o=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);this.trajectorySocket=o;const n=new AbortController;let i,r;try{await new Promise((a,c)=>{let d=!1;const h=()=>{d||(d=!0,a())},u=g=>{if(!d){if(d=!0,this.onError){this.onError(g),a();return}c(g instanceof Error?g:new Error(`Failed to execute trajectory: ${JSON.stringify(g)}`))}};r=h,this.endIncrementalMotion=h;const m=Te(t);i=setTimeout(()=>{u(new Error(`Jogging motion did not complete within ${m}ms`))},m),o.addEventListener("message",g=>{var f,p;const l=(f=_.tryParseJson(g.data))==null?void 0:f.result;if(!(l!=null&&l.kind)){u(new Error(`Failed to execute trajectory: Received invalid message ${g.data}`));return}if(this.onBlocked&&((p=l.message)!=null&&p.includes(St))){this.onBlocked(),h();return}if(l.kind==="INITIALIZE_RECEIVED"){if(l.add_trajectory_error||l.message){u(l);return}o.sendJson({message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"})}else if(l.kind==="START_RECEIVED"){if(l.message){u(l);return}this.waitForMotionToFinish(n.signal).then(h,u)}else l.kind==="PAUSE_RECEIVED"||(l.kind==="MOTION_ERROR"&&l.message?u(l):u(new Error(`Failed to execute trajectory, cannot handle message type "${l.kind}"`)))}),o.sendJson({message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.motionGroupId,data:t,tcp:this.tcp}})})}finally{clearTimeout(i),n.abort(),this.endIncrementalMotion===r&&(this.endIncrementalMotion=void 0),o.dispose(),this.trajectorySocket===o&&(this.trajectorySocket=null)}}async waitForMotionToFinish(t){const o=()=>this.motionStream.rapidlyChangingMotionState.standstill;await y.when(()=>!o(),{timeout:Ee,signal:t}).catch(()=>{}),await y.when(o,{signal:t})}}const Rt=e=>{const t=e.softTimeout||3e3,[o,n]=C.useState(!1);return C.useEffect(()=>{const i=setTimeout(()=>{n(!0)},t);return()=>clearTimeout(i)}),s.jsx(v,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:"text.primary"},children:e.error?s.jsx(At,{loadingMessage:e.message,error:e.error}):s.jsxs(s.Fragment,{children:[s.jsx(_t,{sx:{mb:3}}),!!e.message&&s.jsx(w,{variant:"body1",children:e.message}),s.jsx(w,{variant:"body2",sx:{visibility:o?"visible":"hidden",mt:2,color:"text.secondary"},children:"This is taking longer than expected..."})]})})},At=e=>{const t=oe.makeErrorMessage(e.error),o=e.error instanceof Error?e.error.stack:null;return s.jsxs(v,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",p:2,overflow:"auto",color:"error.main"},children:[s.jsx(w,{variant:"body1",children:(e.loadingMessage?`Error while ${wt.lowerFirst(ee.capitalize(e.loadingMessage))} - `:"")+t}),o&&s.jsx(D,{component:"pre",sx:{typography:"body2",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",mt:2,pb:6},children:o})]})},ke=E.observer(({store:e})=>{const{t}=P.useTranslation();return s.jsx(It,{"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:s.jsxs(v,{sx:{m:2,width:"100%"},children:[s.jsxs(ne,{severity:"error",sx:{mb:2},children:[s.jsx(ie,{children:t("Jogging.Blocked.ti")}),t("Jogging.Blocked.lb")]}),s.jsx(nt,{variant:"contained",color:"secondary",onClick:()=>e.unblock(),children:t("Jogging.Blocked.Reenable.bt")})]})})}),Oe=({title:e,titleId:t,...o},n)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:n,"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"})),Je=C.forwardRef(Oe),Re=({title:e,titleId:t,...o},n)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:n,"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"})),Ae=C.forwardRef(Re),Pe=({title:e,titleId:t,...o},n)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:10,height:19,fill:"none",ref:n,"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"})),Le=C.forwardRef(Pe),Ve=({title:e,titleId:t,...o},n)=>b.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?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"})),De=C.forwardRef(Ve),Pt=E.observer(({store:e})=>{const{t}=P.useTranslation(),[o,n]=C.useState(e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached),i=C.useRef(o);x.useAnimationFrame(()=>{const a=e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;Et(i.current,a)||(i.current=a,n(a))});const r=[];for(const[a,c]of o.entries())c&&r.push(a);return s.jsx(D,{sx:{display:"flex",flexDirection:"row",justifyContent:"center"},children:s.jsx(w,{"data-testid":"jogging-joint-limit-detector","aria-label":"jogging-joint-limit-detector",color:"error",variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2,visibility:r.length?"visible":"hidden"},children:t("Jogging.JointLimitsReached.lb",{jointNumbers:r.map(a=>a+1).join(", ")})})})}),Ne=N.styled(se)(({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 s.jsxs(Ne,{fullWidth:!0,variant:"filled",children:[s.jsx(ae,{id:t.labelId,children:e}),s.jsx(ce,{...t})]})}function xt(e){const t=e.lastIndexOf("On");return t>0?e.slice(0,t):e}function Lt(e,t){const o=e[t];if(o)return o;const n=xt(t),i=e[n];if(i)return i;const r=Object.keys(e).filter(c=>xt(c)===n);if(r.length!==1)return;const a=r[0];return a?e[a]:void 0}const $e={coordinate_system:"world",name:"world",reference_coordinate_system:"",position:[0,0,0],orientation:[0,0,0],orientation_type:"ROTATION_VECTOR"};function Vt(e){const t=H(e.map(i=>({...i,coordinate_system:i.coordinate_system||"world"})),"coordinate_system");t.world??(t.world=$e);const o={},n=i=>{const r=o[i];if(r)return r;const a=Lt(t,i);if(!a)throw new Error(`Unknown coordinate system ${i}. Known coordinate systems are: ${Object.keys(t).join(", ")}`);const c=a.reference_coordinate_system||"world";let d;if(c==="world")d=a;else{const h=n(c),u=x.Pose3.fromCoordinateSystem(h).multiply(x.Pose3.fromCoordinateSystem(a));d={...a,position:[u.position.x,u.position.y,u.position.z],orientation:[u.orientation.x,u.orientation.y,u.orientation.z],orientation_type:"ROTATION_VECTOR",reference_coordinate_system:h.reference_coordinate_system}}return o[i]=d,d};return Object.fromEntries(Object.keys(t).map(i=>[i,n(i)]))}function rt(e,t){const o=Lt(e,t||"world");if(!o)throw new Error(`Unknown coordinate system ${t}. Known coordinate systems are: ${Object.keys(e).join(", ")}`);return o}function Dt(e,t){return rt(Vt(t),e)}function K(e,t,o){if(e.coordinateSystemId===t)return e;const n=Vt(o),i=rt(n,e.coordinateSystemId||"world"),r=rt(n,t);if(i.coordinate_system===r.coordinate_system)return{...e,coordinateSystemId:r.coordinate_system};const a=x.Pose3.fromCoordinateSystem(r).inverse().multiply(x.Pose3.fromCoordinateSystem(i).multiply(x.Pose3.fromPose(e.pose)));return{...e,pose:{position:[a.position.x,a.position.y,a.position.z],orientation:[a.orientation.x,a.orientation.y,a.orientation.z]},coordinateSystemId:r.coordinate_system}}function Nt(e,t,o){const n=x.Pose3.fromPose(e).multiply(x.Pose3.fromRobotTcp(t).inverse()).multiply(x.Pose3.fromRobotTcp(o)),{position:i,orientation:r}=n;return{position:[i.x,i.y,i.z],orientation:[r.x,r.y,r.z]}}function jt(e,t){const o=e==null?void 0:e[t];if(!o)throw new Error(`Unknown TCP ${t}. Known TCPs are: ${Object.keys(e??{}).join(", ")}`);return{position:o.pose.position??[0,0,0],orientation:o.pose.orientation??[0,0,0],orientation_type:"ROTATION_VECTOR"}}function Fe({inputPose:e,selectedTcpId:t,selectedCoordinateSystemId:o,tcpOffsetsById:n,coordinateSystems:i}){const r=t&&t!==e.tcpId?{...e,pose:Nt(e.pose,jt(n,e.tcpId),jt(n,t)),tcpId:t}:e;return o?K(r,o,i):r}function $t(e){var t,o,n,i,r;if(typeof e=="string"){const a=_.tryParseJson(e);return a?$t(a):e}if(e&&typeof e=="object"){const a=e;return((t=a.error_feedback)==null?void 0:t.error_feedback_name)||((o=a.add_trajectory_error)==null?void 0:o.message)||a.message||((i=(n=a.result)==null?void 0:n.add_trajectory_error)==null?void 0:i.message)||((r=a.result)==null?void 0:r.message)||"Jogging motion failed"}return"Jogging motion failed"}const qe=[{pattern:/^FeedbackSingularity$/,translationKey:"Jogging.StreamStateSection.Error.Singularity.lb"},{pattern:/^FeedbackJointLimitExceeded$/,translationKey:"Jogging.StreamStateSection.Error.JointLimit.lb"},{pattern:/^FeedbackOutOfWorkspace$/,translationKey:"Jogging.StreamStateSection.Error.OutOfWorkspace.lb"},{pattern:/^FeedbackCollision$/,translationKey:"Jogging.StreamStateSection.Error.Collision.lb"},{pattern:/^FeedbackNoSolutionInCurrentConfiguration$/,translationKey:"Jogging.StreamStateSection.Error.NoSolutionInConfiguration.lb"},{pattern:/^Feedback\w+$/,translationKey:"Jogging.StreamStateSection.Error.PlanningFailed.lb"}];function Be(e){var t;return((t=qe.find(({pattern:o})=>o.test(e)))==null?void 0:t.translationKey)??null}const ze=5,Ue=250;function Ge(e){var n,i,r,a;const t=[(i=(n=e==null?void 0:e.manual_t1_limits)==null?void 0:n.tcp)==null?void 0:i.velocity,(a=(r=e==null?void 0:e.manual_limits)==null?void 0:r.tcp)==null?void 0:a.velocity].filter(c=>typeof c=="number"&&Number.isFinite(c)&&c>0);return Math.min(Ue,...t)/10}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}],We=[{id:"continuous"},...st],He=["coordsys","tool"],bt="joggingToolStore",Ke=()=>typeof localStorage>"u"?void 0:localStorage;class Y{constructor(t,o,n,i,r,a={}){var d,h,u;this.jogger=t,this.coordSystems=o,this.motionGroupDescription=n,this.tcps=i,this.inverseSolverValue=r,this.selectedTabId="cartesian",this.locks=new Set,this.blocked=!1,this.selectedCoordSystemId="world",this.jogCoordSystemId="world",this.selectedTcpId="",this.tcpChangeInProgress=!1,this.selectedOrientation="coordsys",this.selectedIncrementId="continuous",this.selectedCartesianMotionType="translate",this.incrementJogInProgress=null,this.lastJogError=null,this.onBeforeActivate=null,this.rotationVelocityDegPerSec=ze,this.minTranslationVelocityMmPerSec=1,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=V.JointTypeEnum.RevoluteJoint,this.storage=a.storage??Ke();for(const m of o)if(m.coordinate_system===""){m.coordinate_system="world";break}this.selectedCoordSystemId=((d=o[0])==null?void 0:d.coordinate_system)||"world",this.jogCoordSystemId=this.selectedCoordSystemId,this.selectedTcpId=t.motionStream.rapidlyChangingMotionState.tcp??"",this.tcpChangeInProgress=this.tcps.length>0&&!this.selectedTcpId,this.inverseSolver=r,this.translationVelocityMmPerSec=Ge(n==null?void 0:n.operation_limits),this.jointType=((u=(h=n==null?void 0:n.dh_parameters)==null?void 0:h[0])==null?void 0:u.type)??V.JointTypeEnum.RevoluteJoint,y.makeAutoObservable(this,{storage:!1},{autoBind:!0}),this.jogger.onBlocked=()=>{this.block()};const c=this.jogger.onError;this.jogger.onError=m=>{this.setLastJogError($t(m)),c==null||c(m)},this.loadFromLocalStorage(),this.disposers.push(y.autorun(()=>this.saveToLocalStorage())),this.disposers.push(y.autorun(()=>{const m=this.jogger.motionStream.rapidlyChangingMotionState.tcp;m&&m!==this.selectedTcpId&&y.runInAction(()=>{this.selectedTcpId=m,this.tcpChangeInProgress=!1})}))}static async loadFor(t,o={}){const{nova:n,cellId:i}=t,[r,a]=await Promise.all([n.api.controller.listCoordinateSystems(i,t.motionStream.controllerId,"ROTATION_VECTOR"),n.api.motionGroup.getMotionGroupDescription(i,t.motionStream.controllerId,t.motionGroupId)]),c=await n.api.motionGroupModels.getMotionGroupKinematicModel(a.motion_group_model);return Y.create(t,{coordinateSystems:r||[],description:a,kinematicModel:c},o)}static create(t,o,n={}){const{coordinateSystems:i,description:r,kinematicModel:a}=o,c=Object.entries(r.tcps||{}).map(([d,h])=>({id:d,readable_name:h.name,position:h.pose.position,orientation:h.pose.orientation}));return new Y(t,i,r,c,a.inverse_solver,n)}dispose(){for(const t of this.disposers)t();this.jogger.dispose()}get coordSystemCountByName(){return wt.countBy(this.coordSystems,t=>t.name)}async deactivate(){this.jogger.mode==="jogging"&&await this.jogger.setJoggingMode("off")}async activate(){var t;return this.lastJogError=null,await((t=this.onBeforeActivate)==null?void 0:t.call(this)),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.jogger.coordinateSystem=this.jogCoordSystem,this.activeDiscreteIncrement?await this.jogger.setJoggingMode("trajectory"):await this.jogger.setJoggingMode("jogging")):await this.jogger.setJoggingMode("jogging"),this.jogger}loadFromLocalStorage(){var n;const t=(n=this.storage)==null?void 0:n.getItem(bt),o=t?_.tryParseJson(t):void 0;o&&(this.tabsById[o.selectedTabId]&&(this.selectedTabId=o.selectedTabId),this.coordSystemsById[o.selectedCoordSystemId]&&(this.selectedCoordSystemId=o.selectedCoordSystemId),this.coordSystemsById[o.jogCoordSystemId]&&(this.jogCoordSystemId=o.jogCoordSystemId),this.incrementOptionsById[o.selectedIncrementId]&&(this.selectedIncrementId=o.selectedIncrementId),["translate","rotate"].includes(o.selectedCartesianMotionType)&&(this.selectedCartesianMotionType=o.selectedCartesianMotionType),["coordsys","tool"].includes(o.selectedOrientation)&&(this.selectedOrientation=o.selectedOrientation))}saveToLocalStorage(){var t;(t=this.storage)==null||t.setItem(bt,JSON.stringify(this.localStorageSave))}get isLocked(){return this.locks.size>0}get lastJogErrorTranslationKey(){return this.lastJogError?Be(this.lastJogError):null}get localStorageSave(){return{selectedTabId:this.selectedTabId,selectedCoordSystemId:this.selectedCoordSystemId,jogCoordSystemId:this.jogCoordSystemId,selectedOrientation:this.selectedOrientation,selectedIncrementId:this.selectedIncrementId,selectedCartesianMotionType:this.selectedCartesianMotionType}}get canJogCartesian(){return this.inverseSolver!==null}get tabs(){const t=[{id:"joint",label:"Joints"}];return this.canJogCartesian&&t.unshift({id:"cartesian",label:"Cartesian"}),t}get incrementOptions(){return We}get discreteIncrementOptions(){return st}get incrementOptionsById(){return H(this.incrementOptions,t=>t.id)}get tabsById(){return H(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 H(this.coordSystems,t=>t.coordinate_system)}get activeCoordSystemId(){return this.selectedOrientation==="tool"?"tool":this.selectedCoordSystemId}get jogCoordSystem(){return Dt(this.jogCoordSystemId,this.coordSystems)}get tcpPoseInSelectedCoordSystem(){const{tcp_pose:t,coordinate_system:o}=this.jogger.motionStream.readoutState;return!(t!=null&&t.position)||!t.orientation?t:K({pose:{position:t.position,orientation:t.orientation},coordinateSystemId:o||"world"},this.selectedCoordSystemId,this.coordSystems).pose}get tcpsById(){return H(this.tcps,t=>t.id)}tcpPoseIn(t,o){const{tcp_pose:n,tcp:i,coordinate_system:r}=this.jogger.motionStream.readoutState,a=this.tcpsById[i||this.selectedTcpId],c=this.tcpsById[t];if(!(!(n!=null&&n.position)||!n.orientation)&&!(!a||!c))try{return K({pose:Nt(n,a,c),coordinateSystemId:r||"world"},o,this.coordSystems).pose}catch{return}}get activeDiscreteIncrement(){return 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 i=await this.waitForTcpConfirmation(t,1e3);n&&await this.jogger.setJoggingMode("off"),i||(i=await this.waitForTcpConfirmation(t,2e3)),y.runInAction(()=>{i?this.selectedTcpId=t:(this.jogger.tcp=o,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??"")})}catch(i){throw n&&await this.jogger.setJoggingMode("off").catch(()=>{}),y.runInAction(()=>{this.jogger.tcp=o,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??""}),i}finally{y.runInAction(()=>{this.tcpChangeInProgress=!1})}}waitForTcpConfirmation(t,o){return new Promise(n=>{const i=setTimeout(()=>{r(),n(!1)},o),r=y.when(()=>this.jogger.motionStream.rapidlyChangingMotionState.tcp===t,()=>{clearTimeout(i),n(!0)})})}setSelectedOrientation(t){this.selectedOrientation=t}setMoveRelativeToSelectedTcp(){this.selectedOrientation="tool"}setMoveRelativeToCoordSystem(t){this.selectedOrientation="coordsys",this.jogCoordSystemId=t}setSelectedIncrementId(t){this.selectedIncrementId=t}setCurrentIncrementJog(t){this.incrementJogInProgress=t}setLastJogError(t){this.lastJogError=t}setVelocityFromSlider(t,o){!Number.isFinite(t)||t<this.minVelocityInDisplayUnits(o)||t>this.maxVelocityInDisplayUnits(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=le();this.lock(o);try{return await t()}finally{this.unlock(o)}}}const Ye=E.observer(({store:e,useDegree:t})=>{var a;const{t:o}=P.useTranslation(),n=C.useId(),i=[];function r(c){switch(c){case"coordsys":return o("Jogging.Orientation.coordsys");case"tool":return o("Jogging.Orientation.tool");default:return c}}return e.showCoordSystemSelect&&i.push(s.jsx(Z,{labelId:`jogging-coord-select-${n}`,labelValue:o("Jogging.CoordinateSystem.hlb"),value:e.selectedCoordSystemId,size:"small",variant:"filled",displayEmpty:!0,onChange:c=>e.setSelectedCoordSystemId(c.target.value),children:e.coordSystems.map(c=>s.jsx(F,{value:c.coordinate_system,children:c.name&&e.coordSystemCountByName[c.name]>1?`${c.name} / ${c.coordinate_system}`:c.name||c.coordinate_system},c.coordinate_system))},"coord")),e.showTcpSelect&&i.push(s.jsx(Z,{labelId:`jogging-tcp-select-${n}`,labelValue:"TCP",value:e.selectedTcpId,size:"small",variant:"filled",displayEmpty:e.tcpChangeInProgress,onChange:c=>{e.requestTcpChange(c.target.value).catch(d=>{console.error("Failed to change TCP:",d)})},disabled:e.tcpChangeInProgress,endAdornment:e.tcpChangeInProgress?s.jsx(re,{position:"end",children:s.jsx(_t,{size:16})}):void 0,children:e.tcps.map(c=>s.jsx(F,{value:c.id,children:c.id},c.id))},"tcp")),e.showOrientationSelect&&i.push(s.jsx(Z,{labelValue:o("Jogging.Cartesian.Orientation.lb"),labelId:`orientation-select-${n}`,value:e.selectedOrientation,onChange:c=>e.setSelectedOrientation(c.target.value),children:He.map(c=>s.jsx(F,{value:c,children:r(c)},c))},"orientation")),e.showIncrementSelect&&i.push(s.jsxs(Z,{labelValue:o("Jogging.Increment.hlb"),labelId:`jogging-increment-select-${n}`,size:"small",variant:"filled",value:((a=e.activeDiscreteIncrement)==null?void 0:a.id)||"continuous",onChange:c=>e.setSelectedIncrementId(c.target.value),children:[s.jsx(F,{value:"continuous",children:o("Jogging.Increment.Continuous.dd")},"continuous"),e.discreteIncrementOptions.map(c=>s.jsx(F,{value:c.id,children:t?`${c.degrees}°`:`${c.mm}mm`},c.id))]},"increment")),s.jsx(D,{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:i.map((c,d)=>s.jsx(D,{sx:{gridColumn:i.length%2===1&&d===i.length-1?"span 2":"auto"},children:c},d))})}),Qe=N.styled(de)(({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"}}}}}),Ft=Q.externalizeComponent(E.observer(e=>{const{store:t}=e,{t:o}=P.useTranslation();function n(i,r){r===e.velocity||!ge(r)||e.onVelocityChange(r,e.useDegree)}return s.jsxs(v,{direction:"row",gap:2,alignItems:"center","data-testid":"velocity-slider","aria-label":"velocity-slider",children:[t.showVelocityLegend&&s.jsx(w,{sx:{color:B.velocitySliderLegendColor,fontSize:"14px"},children:o("Jogging.Velocity.bt")}),s.jsx(Mt,{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):s.jsx(ht,{value:e.velocity.toString()}))]})}));function ht({value:e,sx:t}){var n;const o=N.useTheme();return s.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:s.jsx(w,{component:"span",sx:{textAlign:"right",fontSize:"14px",opacity:.8,color:o.palette.text.primary,whiteSpace:"nowrap"},children:e})})}const qt=E.observer(({store:e,useDegree:t})=>{const{t:o}=P.useTranslation();function n(i,r){return r?`ω = ${o("Jogging.Cartesian.Rotation.velocityDegPerSec.lb",{amount:i})}`:`v = ${o("Jogging.Cartesian.Translation.velocityMmPerSec.lb",{amount:i})}`}return s.jsx(Ft,{store:e,velocity:e.velocityInDisplayUnits(t),min:e.minVelocityInDisplayUnits(t),max:e.maxVelocityInDisplayUnits(t),onVelocityChange:e.setVelocityFromSlider,useDegree:t,disabled:e.isLocked,renderValue:i=>s.jsx(ht,{value:n(i,t),sx:{minWidth:"111px",span:{transform:"translateY(-1.5px)"}}})})}),Bt=E.observer(({store:e})=>{var a,c,d;const{t}=P.useTranslation(),o=N.useTheme(),n=((d=(c=(a=e.jogger.motionStream.rapidlyChangingMotionState.execute)==null?void 0:a.details)==null?void 0:c.state)==null?void 0:d.kind)??"KIND_UNKNOWN",i=e.lastJogError,r=e.lastJogErrorTranslationKey;return s.jsxs(D,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",color:o.palette.text.primary},children:[s.jsx(w,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},children:t("Jogging.StreamStateSection.lb")}),s.jsx(w,{variant:"body2",color:i?"error":void 0,sx:{fontSize:"0.75rem",lineHeight:1.2,textAlign:"right"},"data-testid":i?"JOG_ERROR":n,children:i?r?t(r):i:t(`Jogging.StreamStateSection.${n}.lb`)})]})}),Ze=E.observer(({store:e,children:t})=>{const{t:o}=P.useTranslation(),n=N.useTheme(),i=C.useRef(0);function r(g,l){(l==="translate"||l==="rotate")&&e.setSelectedCartesianMotionType(l)}async function a(g,l){const f=await e.activate(),p=f.motionStream.rapidlyChangingMotionState.tcp_pose,j=f.motionStream.rapidlyChangingMotionState.joint_position;p&&await e.withMotionLock(async()=>{try{e.setCurrentIncrementJog({axis:g.axis,direction:g.direction}),await e.jogger.runIncrementalCartesianMotion({currentTcpPose:p,currentJoints:j,coordSystemId:e.activeCoordSystemId,velocityInRelevantUnits:e.selectedCartesianMotionType==="translate"?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec,axis:g.axis,direction:g.direction,motion:e.selectedCartesianMotionType==="translate"?{type:"translate",distanceMm:l.mm}:{type:"rotate",distanceRads:_.degreesToRadians(l.degrees)}})}finally{e.setCurrentIncrementJog(null),await e.deactivate()}})}async function c(g){if(e.isLocked)return;const l=++i.current;try{if(await e.activate(),l!==i.current)return;if(e.activeDiscreteIncrement)return await a(g,e.activeDiscreteIncrement);g.motionType==="translate"?await e.jogger.translateTCP({axis:g.axis,direction:g.direction,velocityMmPerSec:e.translationVelocityMmPerSec}):await e.jogger.rotateTCP({axis:g.axis,direction:g.direction,velocityRadsPerSec:e.rotationVelocityRadsPerSec})}catch(f){console.error("Jogging failed:",f)}}async function d(){e.isLocked||e.activeDiscreteIncrement||(i.current++,await e.deactivate())}const h=[{id:"x",icon:s.jsx(Je,{}),colors:B.cartesianAxisColors.X},{id:"y",icon:s.jsx(Ae,{}),colors:B.cartesianAxisColors.Y},{id:"z",icon:s.jsx(Le,{}),colors:B.cartesianAxisColors.Z}];function u(g){return o("General.mm.variable",{amount:g.toFixed(1)})}function m(g){return o("General.degree.variable",{amount:_.radiansToDegrees(g).toFixed(1)})}return s.jsxs(v,{"data-testid":"jogging-cartesian-tab","aria-label":"jogging-cartesian-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[s.jsxs(v,{gap:2,children:[s.jsx(Ye,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),s.jsx(qt,{store:e,useDegree:e.selectedCartesianMotionType==="rotate"}),s.jsx(q,{})]}),s.jsx(v,{marginLeft:"auto",marginRight:"auto",gap:"24px",justifyContent:"center",sx:{flexGrow:"1"},children:s.jsxs(v,{alignItems:"center",justifyContent:"center",gap:"24px",sx:{flexGrow:1},children:[s.jsxs(Qe,{value:e.selectedCartesianMotionType,onChange:r,exclusive:!0,"aria-label":o("Jogging.Cartesian.MotionType.lb"),sx:{justifyContent:"center"},children:[s.jsx(pt,{value:"translate",children:o("Jogging.Cartesian.Translation.bt")}),s.jsx(pt,{value:"rotate",children:o("Jogging.Cartesian.Rotation.bt")})]}),e.selectedCartesianMotionType==="translate"&&h.map(g=>{var l,f;return s.jsx(it,{"data-testid":`jogging-cartesian-axis-control-${g.id}`,"aria-label":`jogging-cartesian-axis-control-${g.id}`,colors:g.colors,disabled:e.isLocked,activeJoggingDirection:((l=e.incrementJogInProgress)==null?void 0:l.axis)===g.id?e.incrementJogInProgress.direction:void 0,label:s.jsxs(s.Fragment,{children:[g.icon,s.jsx(w,{sx:{fontSize:"24px",color:((f=g.colors)==null?void 0:f.labelColor)??n.palette.text.primary},children:g.id.toUpperCase()})]}),getDisplayedValue:()=>{var p,j;return u(((j=(p=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:p.position)==null?void 0:j[_.XYZ_TO_VECTOR[g.id]])||0)},startJogging:p=>c({axis:g.id,motionType:"translate",direction:p}),stopJogging:d},g.id)}),e.selectedCartesianMotionType==="rotate"&&h.map(g=>{var l,f;return s.jsx(it,{"data-testid":`jogging-cartesian-axis-control-${g.id}`,"aria-label":`jogging-cartesian-axis-control-${g.id}`,colors:g.colors,disabled:e.isLocked,activeJoggingDirection:((l=e.incrementJogInProgress)==null?void 0:l.axis)===g.id?e.incrementJogInProgress.direction:void 0,label:s.jsxs(s.Fragment,{children:[s.jsx(De,{}),s.jsx(w,{sx:{fontSize:"24px",color:((f=g.colors)==null?void 0:f.labelColor)??n.palette.text.primary},children:g.id.toUpperCase()})]}),getDisplayedValue:()=>{var p,j;return m(((j=(p=e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:p.orientation)==null?void 0:j[_.XYZ_TO_VECTOR[g.id]])||0)},startJogging:p=>c({axis:g.id,motionType:"rotate",direction:p}),stopJogging:d},g.id)})]})}),s.jsx(Pt,{store:e}),s.jsx(q,{}),s.jsx(Bt,{store:e}),t&&s.jsx(q,{}),t]})}),Xe=E.observer(({store:e,children:t})=>{const o=N.useTheme(),n=C.useRef(0);async function i(a){const c=++n.current;try{if(await e.activate(),c!==n.current)return;await e.jogger.rotateJoints({joint:a.joint,direction:a.direction,velocityUnit:e.jointType===V.JointTypeEnum.PrismaticJoint?"mm/s":"rad/s",velocityValue:e.jointType===V.JointTypeEnum.PrismaticJoint?e.translationVelocityMmPerSec:e.rotationVelocityRadsPerSec})}catch(d){console.error("Jogging failed:",d)}}async function r(){n.current++,await e.jogger.stop(),await e.deactivate()}return s.jsxs(v,{"data-testid":"jogging-joint-tab","aria-label":"jogging-joint-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[s.jsx(qt,{store:e,useDegree:e.jointType===V.JointTypeEnum.RevoluteJoint}),s.jsx(q,{}),s.jsx(v,{justifyContent:"center",alignItems:"stretch",sx:{flexGrow:"1"},children:s.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(a=>{var d,h,u;const c=(u=(h=(d=e.motionGroupDescription.operation_limits.auto_limits)==null?void 0:d.joints)==null?void 0:h[a.index])==null?void 0:u.position;return s.jsxs(v,{"data-testid":`jogging-joint-value-control-${a.index}`,"aria-label":`jogging-joint-value-control-${a.index}`,direction:"row",alignItems:"center",justifyContent:"center",spacing:1.5,width:"100%",children:[e.showJointsLegend&&s.jsx(w,{color:e.isLocked?o.palette.text.disabled:o.palette.text.secondary,children:`G${a.index+1}`}),s.jsx(kt,{disabled:e.isLocked,lowerLimit:c==null?void 0:c.lower_limit,upperLimit:c==null?void 0:c.upper_limit,useDegree:e.jointType===V.JointTypeEnum.RevoluteJoint,getValue:()=>{const m=e.jogger.motionStream.rapidlyChangingMotionState.joint_position[a.index];return m!==void 0?m:void 0},startJogging:m=>i({joint:a.index,direction:m}),stopJogging:r})]},`joint-${a.index}`)})})}),s.jsx(Pt,{store:e}),s.jsx(q,{}),s.jsx(Bt,{store:e}),t&&s.jsx(q,{}),t]})}),to=Q.externalizeComponent(E.observer(e=>{const t=E.useLocalObservable(()=>({joggingStore:null,loadingError:null}));return C.useEffect(()=>{let o=!1,n;async function i(){y.runInAction(()=>{t.loadingError=null,t.joggingStore=null});try{let r=e.store;if(!r){const a=await ot.open(e.nova,e.motionGroupId,{cellId:e.cellId});if(o){a.dispose();return}try{r=await Y.loadFor(a)}catch(c){throw a.dispose(),c}if(n=r,o){r.dispose();return}}y.runInAction(()=>{t.joggingStore=r}),e.onSetup&&e.onSetup(r)}catch(r){if(o)return;y.runInAction(()=>{t.loadingError=r})}}return i(),()=>{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]),s.jsx(v,{"data-testid":"jogging-panel","aria-label":"jogging-panel",sx:{maxWidth:"460px",minWidth:"320px",position:"relative",...e.sx},children:t.joggingStore?s.jsx(eo,{store:t.joggingStore,children:e.children}):s.jsx(Rt,{message:"Loading jogging",error:t.loadingError})})})),eo=E.observer(({store:e,children:t})=>{const{t:o}=P.useTranslation();function n(){if(e.currentTab.id==="cartesian")return s.jsx(Ze,{store:e,children:t});if(e.currentTab.id==="joint")return s.jsx(Xe,{store:e,children:t})}return s.jsxs(v,{flexGrow:1,sx:{overflow:"hidden"},children:[s.jsx(te,{"data-testid":"jogging-tabs","aria-label":"jogging-tabs",value:e.tabIndex,onChange:e.onTabChange,variant:"fullWidth",children:e.tabs.map(i=>{const r=i.label==="Cartesian"?o("Jogging.Cartesian.bt"):o("Jogging.Joints.bt"),a=i.label==="cartesian"?s.jsx(Qt,{fontSize:"small",sx:{mr:1}}):s.jsx(Zt,{fontSize:"small",sx:{mr:1}});return s.jsx(Xt,{"data-testid":`jogging-tab-${i.id}`,"aria-label":`jogging-tab-${i.id}`,label:e.showTabIcons?s.jsxs(v,{direction:"row",alignItems:"center",children:[a,r]}):r,id:`jogging-tab-${i.id}`,"aria-controls":`jogging-tab-${i.id}`},i.id)})}),s.jsx(v,{flexGrow:1,position:"relative",sx:{overflowY:"auto",overflowX:"hidden"},children:n()}),e.blocked&&s.jsx(ke,{store:e})]})});function oo(){const e=window.location.href;return e.substring(0,e.indexOf("/",e.indexOf("//")+2))}function no({baseUrl:e=oo(),...t}){return s.jsxs(pe,{"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:[s.jsx(Se,{id:"no-motion-group-modal-title",children:"No motion group found"}),s.jsxs(ye,{sx:{marginTop:"3rem",marginBottom:"1.5rem",textAlign:"center"},children:[s.jsx(w,{color:"#fff",children:"Found no devices to connect to."}),s.jsx(w,{color:"#fff",children:"Please ensure a motion group has been created."})]}),s.jsx(fe,{children:s.jsxs(v,{width:"100%",maxWidth:"300px",margin:"auto",marginBottom:"2rem",children:[s.jsx(nt,{href:`${e}/settings`,variant:"contained",sx:{borderRadius:"8px",width:"100%"},children:"Go to settings app"}),s.jsx(nt,{href:`${e}`,variant:"text",sx:{marginTop:"1rem",color:"#fff",textDecoration:"underline",fontSize:"0.75rem"},children:"Back to Homescreen"})]})})]})}const vt=1e-4,io={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class tt{constructor(t,o,n,i,r,a,c,d,h,u,m="cell"){this.controller=o,this.motionGroup=n,this.initialMotionState=i,this.motionStateSocket=r,this.isVirtual=a,this.tcps=c,this.description=d,this.initialControllerState=h,this.controllerStateSocket=u,this.cellId=m,this.connectedJoggingSocket=null,this.joggingVelocity=10,this.activationState="inactive",this.nova=x.createNovaClient(t),this.rapidlyChangingMotionState=i,this.controllerState=h,u.addEventListener("message",g=>{var f;const l=(f=_.tryParseJson(g.data))==null?void 0:f.result;l&&y.runInAction(()=>{this.controllerState=l})}),r.addEventListener("message",g=>{var f;const l=(f=_.tryParseJson(g.data))==null?void 0:f.result;if(!l)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${g.data}`);ct(this.rapidlyChangingMotionState.joint_position,l.joint_position,vt)||y.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=l.joint_position}),lt(this.rapidlyChangingMotionState,l,vt)||y.runInAction(()=>{this.rapidlyChangingMotionState.tcp_pose=l.tcp_pose}),l.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==l.tcp&&y.runInAction(()=>{this.rapidlyChangingMotionState.tcp=l.tcp}),this.rapidlyChangingMotionState.standstill!==l.standstill&&y.runInAction(()=>{this.rapidlyChangingMotionState.standstill=l.standstill})}),y.makeAutoObservable(this)}static async connectMultiple(t,o,n={}){const i=x.createNovaClient(t),r=n.cellId??x.cellIdOf(t);return Promise.all(o.map(a=>tt.connect(i,a,{...n,cellId:r})))}static async connect(t,o,n={}){var O,J;const i=x.createNovaClient(t),r=n.cellId??x.cellIdOf(t)??"cell",[a,c]=o.split("@"),d=await i.api.controller.getCurrentRobotControllerState(r,c),h=d==null?void 0:d.motion_groups.find(I=>I.motion_group===o);if(!d||!h)throw new Error(`Controller ${c} or motion group ${o} not found`);const u=i.openReconnectingWebsocket(`/cells/${r}/controllers/${c}/motion-groups/${o}/state-stream`),m=await u.firstMessage(),g=(O=_.tryParseJson(m.data))==null?void 0:O.result;if(!g)throw new Error(`Unable to parse initial motion state message ${m.data}`);console.log(`Connected motion state websocket to motion group ${h.motion_group}. Initial state:
2
+ `,g);const f=(await i.api.controller.getRobotController(r,d.controller)).configuration.kind==="VirtualController",p=await i.api.motionGroup.getMotionGroupDescription(r,c,h.motion_group),j=Object.entries(p.tcps||{}).map(([I,R])=>({id:I,readable_name:R.name,position:R.pose.position,orientation:R.pose.orientation})),T=i.openReconnectingWebsocket(`/cells/${r}/controllers/${d.controller}/state-stream?response_rate=1000`),M=await T.firstMessage(),k=(J=_.tryParseJson(M.data))==null?void 0:J.result;if(!k)throw new Error(`Unable to parse initial controller state message ${M.data}`);return console.log(`Connected controller state websocket to controller ${d.controller}. Initial state:
3
+ `,k),new tt(i,d,h,g,u,f,j,p,k,T,r)}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=>({...io,...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 i,r,a,c,d,h;const t=new ft.Vector3(((r=(i=this.description.mounting)==null?void 0:i.orientation)==null?void 0:r[0])||0,((c=(a=this.description.mounting)==null?void 0:a.orientation)==null?void 0:c[1])||0,((h=(d=this.description.mounting)==null?void 0:d.orientation)==null?void 0:h[2])||0),o=t.length(),n=t.normalize();return new ft.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}}const zt=1e-4,ro=new Set(["timestamp","sequence_number","joint_position","joint_torque","joint_current","flange_pose","tcp_pose","flange_velocity","tcp_velocity"]),so=1,Ct=e=>Array.isArray(e)&&e.length===3&&e.every(t=>typeof t=="number");class ao{constructor(t,o,n,i={}){this.source=t,this.motionGroupId=o,this.lastMessageReceivedAt=Date.now(),this.lastInvalidStateMessage=null,this.connectionQuality="good";const r=n.motion_groups.find(a=>a.motion_group===o);if(!r)throw new Error(`Motion group ${o} not found in initial controller state`);this.isVirtual=i.isVirtual??!1,this.onError=i.onError,this.reconnectsOnFocus=(i.reconnectOnFocus??!0)&&typeof window<"u",this.rapidlyChangingMotionState=r,this.lastValidStateMessage={receivedAt:Date.now(),data:n},y.makeAutoObservable(this,{source:!1,lastMessageReceivedAt:!1,connectionQualityInterval:!1,isVirtual:!1,onError:!1,reconnectsOnFocus:!1,readoutState:y.computed({equals:ut,keepAlive:!0})},{autoBind:!0}),this.source.addEventListener("message",this.handleMessage),this.connectionQualityInterval=setInterval(this.updateConnectionQuality,500),this.reconnectsOnFocus&&window.addEventListener("focus",this.handleWindowFocus)}get controllerState(){return this.lastValidStateMessage.data}get readoutState(){return gt(this.rapidlyChangingMotionState)}async nextMotionState(){var n,i;const t=await this.source.nextMessage(),o=(i=(n=this.source.parse(t.data))==null?void 0:n.motion_groups)==null?void 0:i.find(r=>r.motion_group===this.motionGroupId);if(!o)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${t.data}`);return o}setLastInvalidStateMessage(t){this.lastInvalidStateMessage={receivedAt:Date.now(),data:t}}setLastValidStateMessage(t){this.lastValidStateMessage={receivedAt:Date.now(),data:t}}updateRapidlyChangingMotionState(t,o){const n=this.rapidlyChangingMotionState,i=t;for(const r of Object.keys(i))o!=null&&o.has(r)||Et(n[r],i[r])||(n[r]=i[r]);for(const r of Object.keys(n))o!=null&&o.has(r)||r in i||delete n[r]}setConnectionQuality(t){this.connectionQuality=t}handleWindowFocus(){this.source.reconnect()}updateConnectionQuality(){const t=Date.now()-this.lastMessageReceivedAt,o=this.isVirtual?3e3:1e3,n=this.isVirtual?6e3:3e3;if(t>n){this.source.readyState===so&&this.source.reconnect(),this.setConnectionQuality("critical");return}if(t>o){this.setConnectionQuality("struggling");return}this.setConnectionQuality("good")}dispose(){this.source.removeEventListener("message",this.handleMessage),clearInterval(this.connectionQualityInterval),this.reconnectsOnFocus&&window.removeEventListener("focus",this.handleWindowFocus)}handleMessage(t){var h,u;const o=this.source.parse(t.data);if(!(o!=null&&o.motion_groups)){(h=this.onError)==null||h.call(this,{message:_.makeErrorMessage(t.data),url:this.source.url}),this.setLastInvalidStateMessage(t.data);return}this.lastMessageReceivedAt=Date.now();const n=this.lastValidStateMessage.data;(n.safety_state!==o.safety_state||n.operation_mode!==o.operation_mode||n.mode!==o.mode)&&this.setLastValidStateMessage(o);const i=o.motion_groups.find(m=>m.motion_group===this.motionGroupId);if(!i){(u=this.onError)==null||u.call(this,{message:`Motion group ${this.motionGroupId} not found in controller state: ${JSON.stringify(t.data)}`,url:this.source.url}),this.setLastInvalidStateMessage(t.data);return}const r=!at(this.rapidlyChangingMotionState.joint_position,i.joint_position,zt),a=this.rapidlyChangingMotionState.tcp!==i.tcp;if(!r&&!a){this.updateRapidlyChangingMotionState(i,ro);return}const c=this.rapidlyChangingMotionState.flange_pose,d=i.flange_pose;if((d==null?void 0:d.orientation)==null||!Ct(d.orientation)){const m=d==null?void 0:d.orientation;throw new Error(`Invalid newFlangePose.orientation: expected [number, number, number] (got ${m==null?"null":m.length})`)}if((c==null?void 0:c.orientation)==null||!Ct(c.orientation)){const m=c==null?void 0:c.orientation;throw new Error(`Invalid oldFlangePose.orientation: expected [number, number, number] (got ${m==null?"null":m.length})`)}d.orientation=dt(d.orientation,c.orientation),this.updateRapidlyChangingMotionState(i)}}function co(e){return{get url(){return e.url},get readyState(){return e.readyState},addEventListener:(t,o)=>e.addEventListener(t,o),removeEventListener:(t,o)=>e.removeEventListener(t,o),firstMessage:()=>e.firstMessage(),nextMessage:()=>e.nextMessage(),reconnect:()=>e.reconnect(),close:()=>e.close(),parse:t=>{var o;return(o=xe.tryParseJson(t))==null?void 0:o.result}}}function lo(e,{controllerId:t,cellId:o,responseRateMs:n}){const i=x.createNovaClient(e),r=o??x.cellIdOf(e)??"cell",a=n===void 0?"":`?response_rate=${n}`;return co(i.openReconnectingWebsocket(`/cells/${r}/controllers/${t}/state-stream${a}`))}const go=["FeedbackOutOfWorkspace","FeedbackJointLimitExceeded","FeedbackAxisRangeExceeded","FeedbackNoSolutionInCurrentConfiguration"];function uo(e){return e==="FeedbackSingularity"?"Jogging.TargetPose.Error.Singularity.lb":e==="FeedbackCollision"?"Jogging.TargetPose.Error.Collision.lb":go.includes(e)?"Jogging.TargetPose.Error.NotReachable.lb":"Jogging.TargetPose.Error.PlanningFailed.lb"}class ho{constructor(t){this.options=t,this.plannedTrajectory=null,this.trajectoryState="idle",this.lastError=null,this.disposers=[],this.logger=t.logger??console,y.makeAutoObservable(this,{socket:!1,disposers:!1,logger:!1,options:!1},{autoBind:!0}),this.socket=this.openSocket(),this.disposers.push(y.reaction(()=>this.executionState,o=>{o==="END_OF_TRAJECTORY"&&this.reset()}))}get joggingStore(){return this.options.joggingStore}get jogger(){return this.options.joggingStore.jogger}get motionStream(){return this.options.joggingStore.jogger.motionStream}get executionState(){var t,o;return(o=(t=this.motionStream.rapidlyChangingMotionState.execute)==null?void 0:t.details)==null?void 0:o.state.kind}async planTrajectory(t){var T,M,k,O,J;if((M=(T=this.options).isLocked)!=null&&M.call(T))throw this.reset(),new Error("Cannot plan trajectory: the robot is locked");await this.ensureMovementOwnership();const o=this.motionStream.rapidlyChangingMotionState.joint_position??[],{cycle_time:n,mounting:i,motion_group_model:r,tcps:a}=this.motionStream.description,c=this.joggingStore.selectedTcpId,d=c?(k=a==null?void 0:a[c])==null?void 0:k.pose:void 0,h={motion_group_model:((O=this.jogger.options)==null?void 0:O.motionGroupModel)??r,cycle_time:n??0,mounting:i,...d&&{tcp_offset:d}};let u;if(t.type==="cartesian"){let I=t.pose;const R=t.coordinateSystemId||"world";if(R!=="world")try{I=K({pose:{position:I.position??[0,0,0],orientation:I.orientation??[0,0,0]},coordinateSystemId:R},"world",this.joggingStore.coordSystems).pose}catch{return this.reset(),{ok:!1,errorFeedbackName:"FeedbackUnknown"}}u={limits_override:{tcp_velocity_limit:this.joggingStore.translationVelocityMmPerSec},path:{target_pose:I,path_definition_name:"PathCartesianPTP"}}}else u={limits_override:{joint_velocity_limits:Array(o.length).fill(this.joggingStore.rotationVelocityRadsPerSec)},path:{target_joint_position:t.joints,path_definition_name:"PathJointPTP"}};y.runInAction(()=>{this.lastError=null,this.trajectoryState="planning"});let m;try{m=await this.jogger.nova.api.trajectoryPlanning.planTrajectory(this.jogger.cellId,{motion_group_setup:h,start_joint_position:o,motion_commands:[u]})}catch(I){throw this.reset(),I}const g=m.response;if("error_feedback"in g){const I=((J=g.error_feedback)==null?void 0:J.error_feedback_name)??"FeedbackUnknown";return this.reset(),{ok:!1,errorFeedbackName:I}}const l=g.joint_positions,f=l[0],p=l[l.length-1];if(!f||!p)throw this.reset(),new Error("Trajectory returned invalid joint positions");const j={message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.jogger.motionGroupId,tcp:c||void 0,data:g}};return this.socket.sendJson(j),y.runInAction(()=>{this.plannedTrajectory={startJoints:f,endJoints:p}}),{ok:!0}}start(){if(!this.plannedTrajectory)throw new Error("Cannot start trajectory: no planned trajectory exists");if(this.trajectoryState!=="planned")throw new Error(`Cannot start trajectory: expected state "planned", got "${this.trajectoryState}"`);if(this.executionState==="RUNNING")throw new Error("Cannot start trajectory: robot is already running");const t={message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"};this.socket.sendJson(t)}async pause(){if(this.trajectoryState!=="moving")throw new Error(`Cannot pause trajectory: expected state "moving", got "${this.trajectoryState}"`);if(this.executionState==="PAUSED_BY_USER")throw new Error("Cannot pause trajectory: robot is already paused");const t={message_type:"PauseMovementRequest"};this.socket.sendJson(t),await this.waitUntilStopped(),y.runInAction(()=>{this.trajectoryState=this.plannedTrajectory?"planned":"idle"})}async stopAndReset(){try{if(this.executionState==="RUNNING"||this.trajectoryState==="moving"){const t={message_type:"PauseMovementRequest"};this.socket.sendJson(t),await this.waitUntilStopped()}}catch(t){this.logger.warn("Failed to stop trajectory execution cleanly",t)}finally{this.reset(),this.closeSocket(),this.socket=this.openSocket()}}reset(){this.plannedTrajectory=null,this.trajectoryState="idle"}clearError(){this.lastError=null}dispose(){for(const t of this.disposers)t();this.closeSocket()}async ensureMovementOwnership(){if(this.options.ensureMovementOwnership){await this.options.ensureMovementOwnership();return}this.jogger.mode!=="trajectory"&&(await this.joggingStore.deactivate(),await this.jogger.setJoggingMode("trajectory"))}async waitUntilStopped(){await y.when(()=>this.motionStream.rapidlyChangingMotionState.standstill)}handleMessage(t){var n,i;const o=(n=_.tryParseJson(t.data))==null?void 0:n.result;if(o)switch(o.kind){case"INITIALIZE_RECEIVED":o.add_trajectory_error||o.message?(this.lastError=((i=o.add_trajectory_error)==null?void 0:i.message)??o.message??"NOVA refused the trajectory",this.reset()):this.trajectoryState="planned";break;case"START_RECEIVED":this.trajectoryState="moving";break;case"PAUSE_RECEIVED":this.trajectoryState==="moving"&&(this.trajectoryState="stopping");break;case"MOTION_ERROR":this.lastError=o.message,this.reset();break}}openSocket(){const t=this.jogger.nova.openReconnectingWebsocket(`/cells/${this.jogger.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);return t.addEventListener("message",this.handleMessage),t}closeSocket(){this.socket.removeEventListener("message",this.handleMessage),this.socket.dispose()}}exports.AppHeader=je;exports.ConnectedMotionGroup=tt;exports.ControllerStateStream=ao;exports.JoggerConnection=ot;exports.JoggingCartesianAxisControl=it;exports.JoggingJointValueControl=kt;exports.JoggingPanel=to;exports.JoggingStore=Y;exports.LoadingCover=Rt;exports.LoadingErrorMessage=At;exports.MOTION_DELTA_THRESHOLD=zt;exports.MotionStreamConnection=et;exports.NoMotionGroupModal=no;exports.TrajectoryExecutionStore=ho;exports.VelocitySlider=Ft;exports.VelocitySliderLabel=ht;exports.controllerStateWebsocket=lo;exports.deriveSelectedTcpPose=Fe;exports.jointValuesEqual=at;exports.jointValuesUnchanged=ct;exports.planErrorTranslationKey=uo;exports.poseEqual=Jt;exports.readoutOf=gt;exports.readoutsEqual=ut;exports.resolveCoordinateSystemInWorld=Dt;exports.tcpMotionEqual=lt;exports.transformPoseToCoordinateSystem=K;exports.unwrapRotationVector=dt;