@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.4e5a9e6 → 6.4.0-pr.revamp.667.6038f41
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.
- package/dist/3d.cjs +1 -1
- package/dist/3d.js +5 -5
- package/dist/CurrentPose/index.cjs +1 -1
- package/dist/CurrentPose/index.js +1 -1
- package/dist/CurrentPoseBar/index.cjs +1 -1
- package/dist/CurrentPoseBar/index.js +1 -1
- package/dist/JoggingButtons/index.cjs +1 -1
- package/dist/JoggingButtons/index.js +1 -1
- package/dist/JoggingGizmo/index.cjs +1 -1
- package/dist/JoggingGizmo/index.js +2 -2
- package/dist/JoggingJointSlider/index.cjs +1 -1
- package/dist/JoggingJointSlider/index.js +1 -1
- package/dist/RobotControl/index.cjs +1 -1
- package/dist/RobotControl/index.js +1 -1
- package/dist/RobotControlPanel/index.cjs +1 -1
- package/dist/RobotControlPanel/index.js +1 -1
- package/dist/RobotHeader/index.cjs +1 -1
- package/dist/RobotHeader/index.d.ts +2 -0
- package/dist/RobotHeader/index.js +6 -4
- package/dist/SafetyBar/index.cjs +1 -1
- package/dist/SafetyBar/index.js +1 -1
- package/dist/chunks/{CurrentPose-BIPvpQLG.cjs → CurrentPose-BStpfgEJ.cjs} +1 -1
- package/dist/chunks/{CurrentPose-DYKoKD2D.js → CurrentPose-UJbSKPRp.js} +2 -2
- package/dist/chunks/{CurrentPoseBar-Cb_Pk2jp.js → CurrentPoseBar-BmsPnLVP.js} +1 -1
- package/dist/chunks/{CurrentPoseBar-CAEEifBY.cjs → CurrentPoseBar-ZUhFaVdM.cjs} +1 -1
- package/dist/chunks/{JoggingButtons-DC0jII72.cjs → JoggingButtons-9nBrKbUa.cjs} +1 -1
- package/dist/chunks/{JoggingButtons-DluWqNuO.js → JoggingButtons-I_Y70pg8.js} +1 -1
- package/dist/chunks/{JoggingGizmo-Hy42DAQU.js → JoggingGizmo-DBpDIbzl.js} +1 -1
- package/dist/chunks/{JoggingGizmo-DT7iX5Ka.cjs → JoggingGizmo-DtWw6KWg.cjs} +1 -1
- package/dist/chunks/{JoggingGizmoOrientation-l2slmUE_.cjs → JoggingGizmoOrientation-BwkW76fE.cjs} +1 -1
- package/dist/chunks/{JoggingGizmoOrientation-Bba8HLQJ.js → JoggingGizmoOrientation-DU97IUWq.js} +1 -1
- package/dist/chunks/{JoggingJointSlider-C0lI_9W5.cjs → JoggingJointSlider-DHBB7MwU.cjs} +1 -1
- package/dist/chunks/{JoggingJointSlider-DePZ3JHW.js → JoggingJointSlider-DeMqm9Jh.js} +1 -1
- package/dist/chunks/{RobotControl-C1JzXIAa.js → RobotControl-BDcNKq32.js} +2 -2
- package/dist/chunks/{RobotControl-ku4CNQCb.cjs → RobotControl-DXbcloVq.cjs} +1 -1
- package/dist/chunks/{RobotControlPanel-Cy5LwU1h.js → RobotControlPanel-CzhYCBAm.js} +4 -4
- package/dist/chunks/{RobotControlPanel-B4u3D3yO.cjs → RobotControlPanel-DHQga5uu.cjs} +1 -1
- package/dist/chunks/{externalizeComponent-CSzPVfuG.js → externalizeComponent-CPAVvPKk.js} +8 -2
- package/dist/chunks/externalizeComponent-CkWiNBu0.cjs +2 -0
- package/dist/chunks/{loadRobotSession-cQNeaBOf.cjs → loadRobotSession-68wS5Tn1.cjs} +1 -1
- package/dist/chunks/{loadRobotSession-DVkuHA-V.js → loadRobotSession-C1g2yivF.js} +3 -3
- package/dist/chunks/robotActivationOf-DXC0E2DS.cjs +1 -0
- package/dist/chunks/robotActivationOf-E1GLe_69.js +477 -0
- package/dist/chunks/{robotModelSource-D7VR89r_.cjs → robotModelSource-BCX1Jrrd.cjs} +1 -1
- package/dist/chunks/{robotModelSource-C2Mi0LtR.js → robotModelSource-C57_9QYT.js} +1 -1
- package/dist/chunks/{robotSafetyOf-Cb4qlwd_.cjs → robotSafetyOf-CwfVV9__.cjs} +1 -1
- package/dist/chunks/{robotSafetyOf-Dr5Q4rCp.js → robotSafetyOf-P4RgO2LQ.js} +1 -1
- package/dist/components/connectionWarning/ConnectionWarning.d.ts +21 -0
- package/dist/components/connectionWarning/connectionWarningOf.d.ts +11 -0
- package/dist/components/connectionWarning/timeAgo.d.ts +5 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.js +46 -44
- package/dist/index.cjs +1 -1
- package/dist/index.js +52 -50
- package/package.json +1 -1
- package/dist/chunks/externalizeComponent-Bl23ayrr.cjs +0 -2
- package/dist/chunks/robotActivationOf-DUHukd46.js +0 -371
- package/dist/chunks/robotActivationOf-DeJsI4H5.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),$=require("@mui/material/IconButton"),v=require("@mui/material/Stack"),z=require("@mui/material/Tab"),W=require("@mui/material/Tabs"),F=require("@mui/material/Typography"),D=require("@wandelbots/icons/CloseFilled"),b=require("react"),w=require("react-i18next"),K=require("./externalizeComponent-Bl23ayrr.cjs"),V=require("@mui/material/Divider"),P=require("@mui/material/Tooltip"),Q=require("@wandelbots/icons/Jog"),U=require("@wandelbots/icons/ViewModuleFilled"),Y=require("./JoggingGizmo-DT7iX5Ka.cjs"),Z=require("./JoggingButtons-DC0jII72.cjs"),tt=require("@mui/material/styles"),X=require("@mui/material/ToggleButton"),et=require("@mui/material/ToggleButtonGroup"),T=require("./useEveryFrame-CHxg25f4.cjs"),ot=require("@mui/material/Slider"),nt=require("./JoggingJointSlider-C0lI_9W5.cjs"),rt=require("@wandelbots/icons/Undo"),I=require("@wandelbots/mui"),lt=require("@wandelbots/icons/NorthEastFilled"),st=require("./joggingColors-ZDc_2UCp.cjs"),_=require("@wandelbots/icons/CheckFilled"),at=require("@wandelbots/icons/ContentCopyFilled"),it=require("@wandelbots/icons/EditFilled");function ct({view:t,onViewChange:o,mode:n,controls:s,gizmoOrientation:a,gizmoFrameQuaternion:d}){const{t:l}=w.useTranslation(),r=t==="gizmo"&&a!==void 0,i=l(r?n==="increment"?"RobotControl.JogArea.Hint.ClickHandle.lb":"RobotControl.JogArea.Hint.HoldHandle.lb":n==="increment"?"RobotControl.JogArea.Hint.ClickButton.lb":"RobotControl.JogArea.Hint.HoldButton.lb"),x=l(r?"RobotControl.JogArea.ShowButtons.bt":"RobotControl.JogArea.ShowGizmo.bt");return e.jsxs(v,{"data-testid":"jog-area",sx:{position:"relative",alignItems:"center",gap:"16px"},children:[a&&e.jsx(P,{title:x,placement:"left",children:e.jsx($,{"aria-label":x,onClick:()=>o(r?"buttons":"gizmo"),size:"small",sx:c=>{var g;return{position:"absolute",top:0,right:0,zIndex:1,borderRadius:"8px",border:`1px solid ${c.palette.divider}`,background:(g=c.palette.backgroundPaperElevation)==null?void 0:g[11]}},children:r?e.jsx(U.ViewModuleFilled,{}):e.jsx(Q.Jog,{})})}),r?e.jsx(Y.JoggingGizmo,{...s,orientation:a,frameQuaternion:d,size:180}):e.jsx(Z.JoggingButtons,{...s}),e.jsx(F,{variant:"body2",color:"text.secondary",textAlign:"center",children:i})]})}const ut=tt.styled(et)(({theme:t})=>{var o;return{gap:"4px","& .MuiToggleButton-root":{border:"none",borderRadius:"8px",padding:"6px 16px",textTransform:"none",fontSize:"14px",color:t.palette.text.secondary},"& .MuiToggleButton-root.Mui-selected":{color:t.palette.text.primary,background:(o=t.palette.backgroundPaperElevation)==null?void 0:o[11]}}});function dt({value:t,onChange:o,disabled:n}){const{t:s}=w.useTranslation();return e.jsxs(ut,{exclusive:!0,value:t,disabled:n,"aria-label":s("RobotControl.JogMode.lb"),onChange:(a,d)=>{d!==null&&o(d)},children:[e.jsx(X,{value:"continuous",children:s("RobotControl.JogMode.Continuous.bt")}),e.jsx(X,{value:"increment",children:s("RobotControl.JogMode.Increment.bt")})]})}function J({children:t}){return e.jsx(v,{sx:{padding:"16px 20px",gap:"16px"},children:t})}function xt(t){return t*180/Math.PI}function pt(t){return t*Math.PI/180}function H(t,o){return t==="rotate"?xt(o):o}function gt(t,o){return t==="rotate"?pt(o):o}function bt(t,o){const n=String(Number(H(t,o).toFixed(2)));return t==="rotate"?`${n}°`:`${n} mm`}function ft(t,o){const n=Math.round(H(t,o));return t==="rotate"?`${n}°/s`:`${n} mm/s`}function L({motion:t,velocity:o,onChange:n,disabled:s}){const{t:a}=w.useTranslation(),d=b.useId(),l=r=>H(t,r);return e.jsxs(v,{gap:"4px",children:[e.jsxs(v,{direction:"row",sx:{justifyContent:"space-between"},children:[e.jsx(F,{id:d,variant:"body2",color:"text.secondary",children:a("RobotControl.Velocity.lb")}),e.jsx(F,{variant:"body2",color:"text.primary",sx:{fontVariantNumeric:"tabular-nums"},children:ft(t,o.value)})]}),e.jsx(ot,{"aria-labelledby":d,size:"small",value:Math.round(l(o.value)),min:Math.ceil(l(o.min)),max:Math.floor(l(o.max)),disabled:s,onChange:(r,i)=>{typeof i=="number"&&n(gt(t,i))},sx:r=>{var i;return{height:4,"& .MuiSlider-rail":{opacity:.38},"& .MuiSlider-thumb":{width:16,height:16,border:`3px solid ${r.palette.primary.main}`,backgroundColor:(i=r.palette.backgroundPaperElevation)==null?void 0:i[5]}}}})]})}function ht({motion:t,settings:o,onSettingsChange:n,disabled:s=!1,tcp:a,jogFrame:d,velocity:l,onVelocityChange:r,onJogStart:i,onJogStop:x,increments:c,gizmoOrientation:g,gizmoFrameQuaternion:j}){const{t:h}=w.useTranslation(),u=c?o.mode:"continuous",R=(c==null?void 0:c.steps[t])??[],m=Math.min(o.step[t],R.length-1),C=R[m],M=b.useRef(!1);function S(f,y){if(u==="increment"){c&&C!==void 0&&c.onStep(t,f,y,C);return}M.current=!0,i(t,f,y)}function E(){M.current&&(M.current=!1,x())}return e.jsxs(e.Fragment,{children:[(a||d)&&e.jsxs(e.Fragment,{children:[e.jsx(J,{children:e.jsxs(v,{direction:"row",sx:{gap:"12px"},children:[a&&e.jsx(T.PanelSelect,{label:h("RobotControl.Tcp.lb"),...a,disabled:s}),d&&e.jsx(T.PanelSelect,{label:h("RobotControl.JogFrame.lb"),...d,disabled:s})]})}),e.jsx(V,{sx:{marginX:"20px"}})]}),e.jsxs(J,{children:[c&&e.jsx(dt,{value:u,onChange:f=>n({...o,mode:f}),disabled:s}),e.jsx(L,{motion:t,velocity:l[t],onChange:f=>r(t,f),disabled:s}),u==="increment"&&C!==void 0&&e.jsx(T.InlineSelect,{label:h("RobotControl.StepSize.lb"),value:String(m),options:R.map((f,y)=>({id:String(y),label:bt(t,f)})),onChange:f=>n({...o,step:{...o.step,[t]:Number(f)}}),disabled:s})]}),e.jsx(V,{sx:{marginX:"20px"}}),e.jsx(J,{children:e.jsx(ct,{view:o.view,onViewChange:f=>n({...o,view:f}),mode:u,controls:{motion:t,onJogStart:S,onJogStop:E,activeHandle:u==="increment"?c==null?void 0:c.running:null,disabled:s},gizmoOrientation:g,gizmoFrameQuaternion:j},u)})]})}function Ct({joints:t,disabled:o}){const n=b.useRef(null),[s,a]=b.useState(null);function d(r,i){n.current!==null&&n.current!==r||(n.current=r,a(r),t.onJogStart(r,i))}function l(r){n.current===r&&(n.current=null,a(null),t.onJogStop())}return e.jsxs(e.Fragment,{children:[e.jsx(J,{children:e.jsx(v,{sx:{gap:"8px",paddingX:"4px"},children:t.joints.map((r,i)=>e.jsx(nt.JoggingJointSlider,{label:`J${i+1}`,name:r.name,value:r.value,min:r.min,max:r.max,linear:t.linear,onJogStart:x=>d(i,x),onJogStop:()=>l(i),disabled:o||s!==null&&s!==i},i))})}),e.jsx(V,{sx:{marginX:"20px"}}),e.jsx(J,{children:e.jsx(L,{motion:t.linear?"translate":"rotate",velocity:t.velocity,onChange:t.onVelocityChange,disabled:o})})]})}const jt=.5,vt=.01;function Rt(t,o){return t?Math.hypot(t.position[0]-o.position[0],t.position[1]-o.position[1],t.position[2]-o.position[2])<=jt&&mt(t.orientation,o.orientation)<=vt:!1}function G(t){const o=Math.hypot(...t);if(o<1e-12)return[1,0,0,0];const n=Math.sin(o/2)/o;return[Math.cos(o/2),t[0]*n,t[1]*n,t[2]*n]}function mt(t,o){const n=G(t),s=G(o),a=Math.abs(n[0]*s[0]+n[1]*s[1]+n[2]*s[2]+n[3]*s[3]);return 2*Math.acos(Math.min(1,a))}const Tt="move",Mt=200;function St({state:t,ready:o,atPose:n,disabled:s,onMoveStart:a,onMoveStop:d,stopRef:l}){const{t:r}=w.useTranslation(),[i,x]=b.useState(!1),c=b.useRef(void 0),g=b.useRef(!1),j=b.useRef({onMoveStart:a,onMoveStop:d});j.current={onMoveStart:a,onMoveStop:d};const h=t==="planned",u=h||t==="moving",{handlersFor:R,stop:m}=st.useHold({onStart:()=>{x(!0),c.current=setTimeout(()=>{c.current=void 0,g.current=!0,j.current.onMoveStart()},Mt)},onStop:()=>{x(!1),clearTimeout(c.current),c.current=void 0,g.current&&(g.current=!1,j.current.onMoveStop())},disabled:i?s||!o||!u:s||!o||n||!h,isSame:()=>!0});l&&(l.current=m),b.useEffect(()=>()=>clearTimeout(c.current),[]);const C=r(t==="moving"?"RobotControl.MoveTo.Moving.bt":t==="stopping"?"RobotControl.MoveTo.Stopping.bt":"RobotControl.MoveTo.MoveTo.bt");return e.jsx(P,{title:r(n?"RobotControl.MoveTo.AtPose.lb":"RobotControl.MoveTo.HoldToMove.lb"),placement:"top",children:e.jsx("span",{...R(Tt),style:{display:"block",flexGrow:1,touchAction:"none",userSelect:"none"},children:e.jsx(I.PrimaryButton,{fullWidth:!0,disabled:s||!o||n||!u,loading:t==="planning"||t==="stopping",loadingPosition:"start",startIcon:e.jsx(lt.NorthEastFilled,{}),"aria-pressed":i,children:C})})})}function yt({text:t,editing:o,onEdit:n,onDraftChange:s,onCancel:a,onConfirm:d,canConfirm:l,error:r,disabled:i}){const{t:x}=w.useTranslation(),c=b.useRef(null),{copied:g,copy:j}=T.useCopyText();b.useEffect(()=>{const u=c.current;u&&(o?(u.focus(),u.setSelectionRange(u.value.length,u.value.length)):document.activeElement===u&&(u.blur(),u.scrollLeft=0))},[o]);function h(){return j(t,()=>{var u;return(u=c.current)==null?void 0:u.select()})}return e.jsxs(v,{direction:"row",sx:{gap:"8px",alignItems:"flex-start"},children:[e.jsx(I.AdornedTextField,{label:x("RobotControl.MoveTo.Coordinates.lb"),value:t,inputRef:c,onChange:u=>s(u.target.value),onClick:()=>{!o&&!i&&n()},onKeyDown:u=>{o&&(u.key==="Enter"&&l?d():u.key==="Escape"&&a())},error:!!r,helperText:r??void 0,fullWidth:!0,autoComplete:"off",slotProps:{htmlInput:{readOnly:!o,spellCheck:!1}},sx:{"& input":{fontVariantNumeric:"tabular-nums",cursor:o||i?void 0:"text"}}}),e.jsx(v,{direction:"row",sx:{gap:"8px",height:"56px",alignItems:"center"},children:o?e.jsxs(e.Fragment,{children:[e.jsx(I.RoundedIconButton,{icon:e.jsx(D.CloseFilled,{}),ariaLabel:x("RobotControl.MoveTo.Cancel.bt"),onClick:a}),e.jsx(P,{title:x("RobotControl.MoveTo.ConfirmEdit.lb"),placement:"left",children:e.jsx("span",{children:e.jsx(I.RoundedIconButton,{icon:e.jsx(_.CheckFilled,{}),ariaLabel:x("RobotControl.MoveTo.ConfirmEdit.lb"),onClick:d,disabled:!l,sx:{color:"primary.main"}})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{title:x("RobotControl.MoveTo.Copied.lb"),open:g,disableHoverListener:!0,placement:"left",children:e.jsx(I.RoundedIconButton,{icon:g?e.jsx(_.CheckFilled,{}):e.jsx(at.ContentCopyFilled,{}),ariaLabel:x("RobotControl.MoveTo.Copy.bt"),onClick:()=>void h()})}),e.jsx(I.RoundedIconButton,{icon:e.jsx(it.EditFilled,{}),ariaLabel:x("RobotControl.MoveTo.Edit.bt"),onClick:n,disabled:i})]})})]})}function wt({moveTo:t,tcp:o,velocity:n,onVelocityChange:s,disabled:a}){var B;const{t:d}=w.useTranslation(),[l,r]=b.useState(null),[i,x]=b.useState(null),c=T.useEveryFrame(()=>{const p=t.getCurrentPose();return p?T.poseToText(p):""},l===null&&i===null),g=(l==null?void 0:l.text)??c,j=i!==null,h=i===null?null:T.parsePoseText(i),u=l!==null&&!t.error&&!j,R=T.useEveryFrame(()=>l!==null&&Rt(t.getCurrentPose(),l.pose),u)&&u,m=b.useRef(!1),C=b.useRef(null);function M(){var p;(p=C.current)==null||p.call(C),m.current=!1,r(null),x(null),t.onTargetChange(null)}function S(){h===null||a||(m.current=!1,r({pose:h,text:T.poseToText(h)}),x(null),t.onTargetChange(h))}b.useEffect(()=>{if(u){if(t.state==="moving"){m.current=!0;return}m.current&&R&&t.state!=="stopping"&&M()}},[u,t.state,R]);const E=[o==null?void 0:o.value,(B=t.frame)==null?void 0:B.value].join("\0");b.useEffect(()=>{l&&M()},[E]);const f=b.useRef({target:l,onTargetChange:t.onTargetChange});f.current={target:l,onTargetChange:t.onTargetChange},b.useEffect(()=>()=>{var p;(p=C.current)==null||p.call(C),f.current.target&&f.current.onTargetChange(null)},[]);const y=i!==null?h===null?d("RobotControl.MoveTo.InvalidPose.lb"):null:l?t.error??null:null;return e.jsxs(J,{children:[o&&e.jsx(T.PanelSelect,{label:d("RobotControl.Tcp.lb"),...o,disabled:a}),e.jsx(F,{variant:"body1",color:"text.primary",children:d("RobotControl.MoveTo.TargetPose.lb")}),e.jsxs(v,{sx:{gap:"8px"},children:[t.frame&&e.jsx(T.PanelSelect,{label:d("RobotControl.MoveTo.RelativeTo.lb"),...t.frame,disabled:a}),e.jsx(yt,{text:i??g,editing:j,onEdit:()=>{a||x(g)},onDraftChange:x,onCancel:()=>x(null),onConfirm:S,canConfirm:h!==null&&!a&&t.state!=="planning",error:y,disabled:a})]}),e.jsx(L,{motion:"translate",velocity:n,onChange:s,disabled:a}),e.jsxs(v,{direction:"row",sx:{gap:"12px",alignItems:"center"},children:[l&&!j&&e.jsx(P,{title:d("RobotControl.MoveTo.Reset.lb"),placement:"top",children:e.jsx("span",{children:e.jsx(I.RoundedIconButton,{icon:e.jsx(rt.Undo,{}),ariaLabel:d("RobotControl.MoveTo.Reset.lb"),onClick:M})})}),e.jsx(St,{state:l?t.state:"idle",ready:u,atPose:R,disabled:a,onMoveStart:()=>{l&&t.onMoveStart(l.pose)},onMoveStop:t.onMoveStop,stopRef:C})]})]})}const Et=K.externalizeComponent(({onClose:t,sx:o,joints:n,moveTo:s,jogDisabled:a=!1,cartesian:d=!0,tab:l,onTabChange:r,jogMode:i,onJogModeChange:x,...c})=>{const{t:g}=w.useTranslation(),j=c.disabled??!1,[h,u]=b.useState("translate"),[R,m]=b.useState({mode:"continuous",view:"gizmo",step:{translate:0,rotate:0}}),C=[...d?["translate","rotate"]:[],...n?["joint"]:[],...s?["moveTo"]:[]],M=l??h,S=C.includes(M)?M:C[0],E=qt(R,i,c.increments),f=g("RobotControl.Title.ti");function y(p){u(p),r==null||r(p)}function B(p){var q,A,N;m(p),p.mode!==E.mode&&(x==null||x(p.mode));for(const k of["translate","rotate"]){const O=(q=c.increments)==null?void 0:q.steps[k][p.step[k]];p.step[k]!==E.step[k]&&O!==void 0&&((N=(A=c.increments)==null?void 0:A.onStepChange)==null||N.call(A,k,O))}}return e.jsxs(v,{"data-testid":"robot-control-panel",sx:[p=>{var q;return{minHeight:0,overflow:"hidden",borderRadius:"16px",background:(q=p.palette.backgroundPaperElevation)==null?void 0:q[5]}},...Array.isArray(o)?o:[o]],children:[e.jsxs(v,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between",padding:"20px 20px 8px"},children:[e.jsx(F,{component:"h2",color:"text.primary",sx:{fontSize:"20px"},children:f}),t&&e.jsx($,{"aria-label":g("RobotControl.Close.bt"),onClick:t,size:"small",children:e.jsx(D.CloseFilled,{})})]}),e.jsxs(W,{value:S??!1,onChange:(p,q)=>y(q),"aria-label":f,variant:"scrollable",scrollButtons:!1,sx:{marginX:"20px",borderBottom:1,borderColor:"divider",background:"transparent"},children:[d&&e.jsx(z,{value:"translate",label:g("RobotControl.Tab.Translate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),d&&e.jsx(z,{value:"rotate",label:g("RobotControl.Tab.Rotate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),n&&e.jsx(z,{value:"joint",label:g("RobotControl.Tab.Joint.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),s&&e.jsx(z,{value:"moveTo",label:g("RobotControl.Tab.MoveTo.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}})]}),e.jsx(v,{sx:{flexGrow:1,overflowY:"auto",overflowX:"hidden"},children:S==="joint"&&n?e.jsx(Ct,{joints:n,disabled:j||a}):S==="moveTo"&&s?e.jsx(wt,{moveTo:s,tcp:c.tcp,velocity:c.velocity.translate,onVelocityChange:p=>c.onVelocityChange("translate",p),disabled:j}):S==="translate"||S==="rotate"?e.jsx(ht,{...c,disabled:j||a,motion:S,settings:E,onSettingsChange:B}):null})]})});function qt(t,o,n){const s=a=>{var r;const d=(r=n==null?void 0:n.step)==null?void 0:r[a];if(d===void 0)return t.step[a];const l=n==null?void 0:n.steps[a].findIndex(i=>Math.abs(i-d)<=1e-9*Math.max(1,Math.abs(i)));return l===void 0||l<0?t.step[a]:l};return{...t,mode:o??t.mode,step:{translate:s("translate"),rotate:s("rotate")}}}exports.RobotControlPanel=Et;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),$=require("@mui/material/IconButton"),v=require("@mui/material/Stack"),z=require("@mui/material/Tab"),W=require("@mui/material/Tabs"),F=require("@mui/material/Typography"),D=require("@wandelbots/icons/CloseFilled"),b=require("react"),w=require("react-i18next"),K=require("./externalizeComponent-CkWiNBu0.cjs"),V=require("@mui/material/Divider"),P=require("@mui/material/Tooltip"),Q=require("@wandelbots/icons/Jog"),U=require("@wandelbots/icons/ViewModuleFilled"),Y=require("./JoggingGizmo-DtWw6KWg.cjs"),Z=require("./JoggingButtons-9nBrKbUa.cjs"),tt=require("@mui/material/styles"),X=require("@mui/material/ToggleButton"),et=require("@mui/material/ToggleButtonGroup"),T=require("./useEveryFrame-CHxg25f4.cjs"),ot=require("@mui/material/Slider"),nt=require("./JoggingJointSlider-DHBB7MwU.cjs"),rt=require("@wandelbots/icons/Undo"),I=require("@wandelbots/mui"),lt=require("@wandelbots/icons/NorthEastFilled"),st=require("./joggingColors-ZDc_2UCp.cjs"),_=require("@wandelbots/icons/CheckFilled"),at=require("@wandelbots/icons/ContentCopyFilled"),it=require("@wandelbots/icons/EditFilled");function ct({view:t,onViewChange:o,mode:n,controls:s,gizmoOrientation:a,gizmoFrameQuaternion:d}){const{t:l}=w.useTranslation(),r=t==="gizmo"&&a!==void 0,i=l(r?n==="increment"?"RobotControl.JogArea.Hint.ClickHandle.lb":"RobotControl.JogArea.Hint.HoldHandle.lb":n==="increment"?"RobotControl.JogArea.Hint.ClickButton.lb":"RobotControl.JogArea.Hint.HoldButton.lb"),x=l(r?"RobotControl.JogArea.ShowButtons.bt":"RobotControl.JogArea.ShowGizmo.bt");return e.jsxs(v,{"data-testid":"jog-area",sx:{position:"relative",alignItems:"center",gap:"16px"},children:[a&&e.jsx(P,{title:x,placement:"left",children:e.jsx($,{"aria-label":x,onClick:()=>o(r?"buttons":"gizmo"),size:"small",sx:c=>{var g;return{position:"absolute",top:0,right:0,zIndex:1,borderRadius:"8px",border:`1px solid ${c.palette.divider}`,background:(g=c.palette.backgroundPaperElevation)==null?void 0:g[11]}},children:r?e.jsx(U.ViewModuleFilled,{}):e.jsx(Q.Jog,{})})}),r?e.jsx(Y.JoggingGizmo,{...s,orientation:a,frameQuaternion:d,size:180}):e.jsx(Z.JoggingButtons,{...s}),e.jsx(F,{variant:"body2",color:"text.secondary",textAlign:"center",children:i})]})}const ut=tt.styled(et)(({theme:t})=>{var o;return{gap:"4px","& .MuiToggleButton-root":{border:"none",borderRadius:"8px",padding:"6px 16px",textTransform:"none",fontSize:"14px",color:t.palette.text.secondary},"& .MuiToggleButton-root.Mui-selected":{color:t.palette.text.primary,background:(o=t.palette.backgroundPaperElevation)==null?void 0:o[11]}}});function dt({value:t,onChange:o,disabled:n}){const{t:s}=w.useTranslation();return e.jsxs(ut,{exclusive:!0,value:t,disabled:n,"aria-label":s("RobotControl.JogMode.lb"),onChange:(a,d)=>{d!==null&&o(d)},children:[e.jsx(X,{value:"continuous",children:s("RobotControl.JogMode.Continuous.bt")}),e.jsx(X,{value:"increment",children:s("RobotControl.JogMode.Increment.bt")})]})}function J({children:t}){return e.jsx(v,{sx:{padding:"16px 20px",gap:"16px"},children:t})}function xt(t){return t*180/Math.PI}function pt(t){return t*Math.PI/180}function H(t,o){return t==="rotate"?xt(o):o}function gt(t,o){return t==="rotate"?pt(o):o}function bt(t,o){const n=String(Number(H(t,o).toFixed(2)));return t==="rotate"?`${n}°`:`${n} mm`}function ft(t,o){const n=Math.round(H(t,o));return t==="rotate"?`${n}°/s`:`${n} mm/s`}function L({motion:t,velocity:o,onChange:n,disabled:s}){const{t:a}=w.useTranslation(),d=b.useId(),l=r=>H(t,r);return e.jsxs(v,{gap:"4px",children:[e.jsxs(v,{direction:"row",sx:{justifyContent:"space-between"},children:[e.jsx(F,{id:d,variant:"body2",color:"text.secondary",children:a("RobotControl.Velocity.lb")}),e.jsx(F,{variant:"body2",color:"text.primary",sx:{fontVariantNumeric:"tabular-nums"},children:ft(t,o.value)})]}),e.jsx(ot,{"aria-labelledby":d,size:"small",value:Math.round(l(o.value)),min:Math.ceil(l(o.min)),max:Math.floor(l(o.max)),disabled:s,onChange:(r,i)=>{typeof i=="number"&&n(gt(t,i))},sx:r=>{var i;return{height:4,"& .MuiSlider-rail":{opacity:.38},"& .MuiSlider-thumb":{width:16,height:16,border:`3px solid ${r.palette.primary.main}`,backgroundColor:(i=r.palette.backgroundPaperElevation)==null?void 0:i[5]}}}})]})}function ht({motion:t,settings:o,onSettingsChange:n,disabled:s=!1,tcp:a,jogFrame:d,velocity:l,onVelocityChange:r,onJogStart:i,onJogStop:x,increments:c,gizmoOrientation:g,gizmoFrameQuaternion:j}){const{t:h}=w.useTranslation(),u=c?o.mode:"continuous",R=(c==null?void 0:c.steps[t])??[],m=Math.min(o.step[t],R.length-1),C=R[m],M=b.useRef(!1);function S(f,y){if(u==="increment"){c&&C!==void 0&&c.onStep(t,f,y,C);return}M.current=!0,i(t,f,y)}function E(){M.current&&(M.current=!1,x())}return e.jsxs(e.Fragment,{children:[(a||d)&&e.jsxs(e.Fragment,{children:[e.jsx(J,{children:e.jsxs(v,{direction:"row",sx:{gap:"12px"},children:[a&&e.jsx(T.PanelSelect,{label:h("RobotControl.Tcp.lb"),...a,disabled:s}),d&&e.jsx(T.PanelSelect,{label:h("RobotControl.JogFrame.lb"),...d,disabled:s})]})}),e.jsx(V,{sx:{marginX:"20px"}})]}),e.jsxs(J,{children:[c&&e.jsx(dt,{value:u,onChange:f=>n({...o,mode:f}),disabled:s}),e.jsx(L,{motion:t,velocity:l[t],onChange:f=>r(t,f),disabled:s}),u==="increment"&&C!==void 0&&e.jsx(T.InlineSelect,{label:h("RobotControl.StepSize.lb"),value:String(m),options:R.map((f,y)=>({id:String(y),label:bt(t,f)})),onChange:f=>n({...o,step:{...o.step,[t]:Number(f)}}),disabled:s})]}),e.jsx(V,{sx:{marginX:"20px"}}),e.jsx(J,{children:e.jsx(ct,{view:o.view,onViewChange:f=>n({...o,view:f}),mode:u,controls:{motion:t,onJogStart:S,onJogStop:E,activeHandle:u==="increment"?c==null?void 0:c.running:null,disabled:s},gizmoOrientation:g,gizmoFrameQuaternion:j},u)})]})}function Ct({joints:t,disabled:o}){const n=b.useRef(null),[s,a]=b.useState(null);function d(r,i){n.current!==null&&n.current!==r||(n.current=r,a(r),t.onJogStart(r,i))}function l(r){n.current===r&&(n.current=null,a(null),t.onJogStop())}return e.jsxs(e.Fragment,{children:[e.jsx(J,{children:e.jsx(v,{sx:{gap:"8px",paddingX:"4px"},children:t.joints.map((r,i)=>e.jsx(nt.JoggingJointSlider,{label:`J${i+1}`,name:r.name,value:r.value,min:r.min,max:r.max,linear:t.linear,onJogStart:x=>d(i,x),onJogStop:()=>l(i),disabled:o||s!==null&&s!==i},i))})}),e.jsx(V,{sx:{marginX:"20px"}}),e.jsx(J,{children:e.jsx(L,{motion:t.linear?"translate":"rotate",velocity:t.velocity,onChange:t.onVelocityChange,disabled:o})})]})}const jt=.5,vt=.01;function Rt(t,o){return t?Math.hypot(t.position[0]-o.position[0],t.position[1]-o.position[1],t.position[2]-o.position[2])<=jt&&mt(t.orientation,o.orientation)<=vt:!1}function G(t){const o=Math.hypot(...t);if(o<1e-12)return[1,0,0,0];const n=Math.sin(o/2)/o;return[Math.cos(o/2),t[0]*n,t[1]*n,t[2]*n]}function mt(t,o){const n=G(t),s=G(o),a=Math.abs(n[0]*s[0]+n[1]*s[1]+n[2]*s[2]+n[3]*s[3]);return 2*Math.acos(Math.min(1,a))}const Tt="move",Mt=200;function St({state:t,ready:o,atPose:n,disabled:s,onMoveStart:a,onMoveStop:d,stopRef:l}){const{t:r}=w.useTranslation(),[i,x]=b.useState(!1),c=b.useRef(void 0),g=b.useRef(!1),j=b.useRef({onMoveStart:a,onMoveStop:d});j.current={onMoveStart:a,onMoveStop:d};const h=t==="planned",u=h||t==="moving",{handlersFor:R,stop:m}=st.useHold({onStart:()=>{x(!0),c.current=setTimeout(()=>{c.current=void 0,g.current=!0,j.current.onMoveStart()},Mt)},onStop:()=>{x(!1),clearTimeout(c.current),c.current=void 0,g.current&&(g.current=!1,j.current.onMoveStop())},disabled:i?s||!o||!u:s||!o||n||!h,isSame:()=>!0});l&&(l.current=m),b.useEffect(()=>()=>clearTimeout(c.current),[]);const C=r(t==="moving"?"RobotControl.MoveTo.Moving.bt":t==="stopping"?"RobotControl.MoveTo.Stopping.bt":"RobotControl.MoveTo.MoveTo.bt");return e.jsx(P,{title:r(n?"RobotControl.MoveTo.AtPose.lb":"RobotControl.MoveTo.HoldToMove.lb"),placement:"top",children:e.jsx("span",{...R(Tt),style:{display:"block",flexGrow:1,touchAction:"none",userSelect:"none"},children:e.jsx(I.PrimaryButton,{fullWidth:!0,disabled:s||!o||n||!u,loading:t==="planning"||t==="stopping",loadingPosition:"start",startIcon:e.jsx(lt.NorthEastFilled,{}),"aria-pressed":i,children:C})})})}function yt({text:t,editing:o,onEdit:n,onDraftChange:s,onCancel:a,onConfirm:d,canConfirm:l,error:r,disabled:i}){const{t:x}=w.useTranslation(),c=b.useRef(null),{copied:g,copy:j}=T.useCopyText();b.useEffect(()=>{const u=c.current;u&&(o?(u.focus(),u.setSelectionRange(u.value.length,u.value.length)):document.activeElement===u&&(u.blur(),u.scrollLeft=0))},[o]);function h(){return j(t,()=>{var u;return(u=c.current)==null?void 0:u.select()})}return e.jsxs(v,{direction:"row",sx:{gap:"8px",alignItems:"flex-start"},children:[e.jsx(I.AdornedTextField,{label:x("RobotControl.MoveTo.Coordinates.lb"),value:t,inputRef:c,onChange:u=>s(u.target.value),onClick:()=>{!o&&!i&&n()},onKeyDown:u=>{o&&(u.key==="Enter"&&l?d():u.key==="Escape"&&a())},error:!!r,helperText:r??void 0,fullWidth:!0,autoComplete:"off",slotProps:{htmlInput:{readOnly:!o,spellCheck:!1}},sx:{"& input":{fontVariantNumeric:"tabular-nums",cursor:o||i?void 0:"text"}}}),e.jsx(v,{direction:"row",sx:{gap:"8px",height:"56px",alignItems:"center"},children:o?e.jsxs(e.Fragment,{children:[e.jsx(I.RoundedIconButton,{icon:e.jsx(D.CloseFilled,{}),ariaLabel:x("RobotControl.MoveTo.Cancel.bt"),onClick:a}),e.jsx(P,{title:x("RobotControl.MoveTo.ConfirmEdit.lb"),placement:"left",children:e.jsx("span",{children:e.jsx(I.RoundedIconButton,{icon:e.jsx(_.CheckFilled,{}),ariaLabel:x("RobotControl.MoveTo.ConfirmEdit.lb"),onClick:d,disabled:!l,sx:{color:"primary.main"}})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{title:x("RobotControl.MoveTo.Copied.lb"),open:g,disableHoverListener:!0,placement:"left",children:e.jsx(I.RoundedIconButton,{icon:g?e.jsx(_.CheckFilled,{}):e.jsx(at.ContentCopyFilled,{}),ariaLabel:x("RobotControl.MoveTo.Copy.bt"),onClick:()=>void h()})}),e.jsx(I.RoundedIconButton,{icon:e.jsx(it.EditFilled,{}),ariaLabel:x("RobotControl.MoveTo.Edit.bt"),onClick:n,disabled:i})]})})]})}function wt({moveTo:t,tcp:o,velocity:n,onVelocityChange:s,disabled:a}){var B;const{t:d}=w.useTranslation(),[l,r]=b.useState(null),[i,x]=b.useState(null),c=T.useEveryFrame(()=>{const p=t.getCurrentPose();return p?T.poseToText(p):""},l===null&&i===null),g=(l==null?void 0:l.text)??c,j=i!==null,h=i===null?null:T.parsePoseText(i),u=l!==null&&!t.error&&!j,R=T.useEveryFrame(()=>l!==null&&Rt(t.getCurrentPose(),l.pose),u)&&u,m=b.useRef(!1),C=b.useRef(null);function M(){var p;(p=C.current)==null||p.call(C),m.current=!1,r(null),x(null),t.onTargetChange(null)}function S(){h===null||a||(m.current=!1,r({pose:h,text:T.poseToText(h)}),x(null),t.onTargetChange(h))}b.useEffect(()=>{if(u){if(t.state==="moving"){m.current=!0;return}m.current&&R&&t.state!=="stopping"&&M()}},[u,t.state,R]);const E=[o==null?void 0:o.value,(B=t.frame)==null?void 0:B.value].join("\0");b.useEffect(()=>{l&&M()},[E]);const f=b.useRef({target:l,onTargetChange:t.onTargetChange});f.current={target:l,onTargetChange:t.onTargetChange},b.useEffect(()=>()=>{var p;(p=C.current)==null||p.call(C),f.current.target&&f.current.onTargetChange(null)},[]);const y=i!==null?h===null?d("RobotControl.MoveTo.InvalidPose.lb"):null:l?t.error??null:null;return e.jsxs(J,{children:[o&&e.jsx(T.PanelSelect,{label:d("RobotControl.Tcp.lb"),...o,disabled:a}),e.jsx(F,{variant:"body1",color:"text.primary",children:d("RobotControl.MoveTo.TargetPose.lb")}),e.jsxs(v,{sx:{gap:"8px"},children:[t.frame&&e.jsx(T.PanelSelect,{label:d("RobotControl.MoveTo.RelativeTo.lb"),...t.frame,disabled:a}),e.jsx(yt,{text:i??g,editing:j,onEdit:()=>{a||x(g)},onDraftChange:x,onCancel:()=>x(null),onConfirm:S,canConfirm:h!==null&&!a&&t.state!=="planning",error:y,disabled:a})]}),e.jsx(L,{motion:"translate",velocity:n,onChange:s,disabled:a}),e.jsxs(v,{direction:"row",sx:{gap:"12px",alignItems:"center"},children:[l&&!j&&e.jsx(P,{title:d("RobotControl.MoveTo.Reset.lb"),placement:"top",children:e.jsx("span",{children:e.jsx(I.RoundedIconButton,{icon:e.jsx(rt.Undo,{}),ariaLabel:d("RobotControl.MoveTo.Reset.lb"),onClick:M})})}),e.jsx(St,{state:l?t.state:"idle",ready:u,atPose:R,disabled:a,onMoveStart:()=>{l&&t.onMoveStart(l.pose)},onMoveStop:t.onMoveStop,stopRef:C})]})]})}const Et=K.externalizeComponent(({onClose:t,sx:o,joints:n,moveTo:s,jogDisabled:a=!1,cartesian:d=!0,tab:l,onTabChange:r,jogMode:i,onJogModeChange:x,...c})=>{const{t:g}=w.useTranslation(),j=c.disabled??!1,[h,u]=b.useState("translate"),[R,m]=b.useState({mode:"continuous",view:"gizmo",step:{translate:0,rotate:0}}),C=[...d?["translate","rotate"]:[],...n?["joint"]:[],...s?["moveTo"]:[]],M=l??h,S=C.includes(M)?M:C[0],E=qt(R,i,c.increments),f=g("RobotControl.Title.ti");function y(p){u(p),r==null||r(p)}function B(p){var q,A,N;m(p),p.mode!==E.mode&&(x==null||x(p.mode));for(const k of["translate","rotate"]){const O=(q=c.increments)==null?void 0:q.steps[k][p.step[k]];p.step[k]!==E.step[k]&&O!==void 0&&((N=(A=c.increments)==null?void 0:A.onStepChange)==null||N.call(A,k,O))}}return e.jsxs(v,{"data-testid":"robot-control-panel",sx:[p=>{var q;return{minHeight:0,overflow:"hidden",borderRadius:"16px",background:(q=p.palette.backgroundPaperElevation)==null?void 0:q[5]}},...Array.isArray(o)?o:[o]],children:[e.jsxs(v,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between",padding:"20px 20px 8px"},children:[e.jsx(F,{component:"h2",color:"text.primary",sx:{fontSize:"20px"},children:f}),t&&e.jsx($,{"aria-label":g("RobotControl.Close.bt"),onClick:t,size:"small",children:e.jsx(D.CloseFilled,{})})]}),e.jsxs(W,{value:S??!1,onChange:(p,q)=>y(q),"aria-label":f,variant:"scrollable",scrollButtons:!1,sx:{marginX:"20px",borderBottom:1,borderColor:"divider",background:"transparent"},children:[d&&e.jsx(z,{value:"translate",label:g("RobotControl.Tab.Translate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),d&&e.jsx(z,{value:"rotate",label:g("RobotControl.Tab.Rotate.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),n&&e.jsx(z,{value:"joint",label:g("RobotControl.Tab.Joint.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}}),s&&e.jsx(z,{value:"moveTo",label:g("RobotControl.Tab.MoveTo.bt"),sx:{minWidth:0,paddingX:"12px",textTransform:"none"}})]}),e.jsx(v,{sx:{flexGrow:1,overflowY:"auto",overflowX:"hidden"},children:S==="joint"&&n?e.jsx(Ct,{joints:n,disabled:j||a}):S==="moveTo"&&s?e.jsx(wt,{moveTo:s,tcp:c.tcp,velocity:c.velocity.translate,onVelocityChange:p=>c.onVelocityChange("translate",p),disabled:j}):S==="translate"||S==="rotate"?e.jsx(ht,{...c,disabled:j||a,motion:S,settings:E,onSettingsChange:B}):null})]})});function qt(t,o,n){const s=a=>{var r;const d=(r=n==null?void 0:n.step)==null?void 0:r[a];if(d===void 0)return t.step[a];const l=n==null?void 0:n.steps[a].findIndex(i=>Math.abs(i-d)<=1e-9*Math.max(1,Math.abs(i)));return l===void 0||l<0?t.step[a]:l};return{...t,mode:o??t.mode,step:{translate:s("translate"),rotate:s("rotate")}}}exports.RobotControlPanel=Et;
|
|
@@ -128,7 +128,10 @@ Bei einem physischen Roboter bedeutet dies im Allgemeinen, dass ein Freigabescha
|
|
|
128
128
|
"RobotHeader.Apps.bt": "Apps",
|
|
129
129
|
"RobotHeader.Search.bt": "Suchen",
|
|
130
130
|
"RobotHeader.MotionGroup.lb": "Bewegungsgruppe",
|
|
131
|
-
"Jogging.MoveRelativeTo.SelectedTcp.dd": "Ausgewählter TCP"
|
|
131
|
+
"Jogging.MoveRelativeTo.SelectedTcp.dd": "Ausgewählter TCP",
|
|
132
|
+
"ConnectionWarning.Interrupted.ti": "Verbindung unterbrochen",
|
|
133
|
+
"ConnectionWarning.LastUpdate.lb": "Kommunikation mit der Robotersteuerung nicht möglich. Die letzte Bewegungsmeldung kam {{time}}.",
|
|
134
|
+
"ConnectionWarning.ErrorState.lb": "Fehlermeldung {{time}}:"
|
|
132
135
|
}, b = {
|
|
133
136
|
"Jogging.Cartesian.Translation.velocityMmPerSec.lb": "{{amount}} mm/s",
|
|
134
137
|
"Jogging.Cartesian.Rotation.velocityDegPerSec.lb": "{{amount}}°/s",
|
|
@@ -254,7 +257,10 @@ Bei einem physischen Roboter bedeutet dies im Allgemeinen, dass ein Freigabescha
|
|
|
254
257
|
"RobotHeader.Apps.bt": "Apps",
|
|
255
258
|
"RobotHeader.Search.bt": "Search",
|
|
256
259
|
"RobotHeader.MotionGroup.lb": "Motion group",
|
|
257
|
-
"Jogging.MoveRelativeTo.SelectedTcp.dd": "Selected TCP"
|
|
260
|
+
"Jogging.MoveRelativeTo.SelectedTcp.dd": "Selected TCP",
|
|
261
|
+
"ConnectionWarning.Interrupted.ti": "Connection interrupted",
|
|
262
|
+
"ConnectionWarning.LastUpdate.lb": "Communication with the robot controller interrupted. The last motion update was received {{time}}.",
|
|
263
|
+
"ConnectionWarning.ErrorState.lb": "Error message from {{time}}:"
|
|
258
264
|
}, o = l.createInstance();
|
|
259
265
|
o.use(g).init({
|
|
260
266
|
supportedLngs: ["en", "de"],
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),i=require("react"),a=require("react-i18next"),l=require("i18next"),g=require("i18next-browser-languagedetector"),s={"Jogging.Cartesian.Translation.velocityMmPerSec.lb":"{{amount}} mm/s","Jogging.Cartesian.Rotation.velocityDegPerSec.lb":"{{amount}}°/s","Jogging.Velocity.lb":"Geschwindigkeit","General.degree.variable":"{{amount}}°","General.mm.variable":"{{amount}} mm","Jogging.Blocked.ti":"Verbindung blockiert","Jogging.Blocked.lb":"Ein anderer Client kontrolliert das Jogging.","Jogging.Blocked.Reenable.bt":"Neu verbinden","Jogging.Cartesian.MotionType.lb":"Bewegungstyp","Jogging.Cartesian.Translation.bt":"Translation","Jogging.Cartesian.Rotation.bt":"Rotation","Jogging.Joints.JointValues.lb":"Gelenkwerte","Jogging.Increment.Continuous.dd":"Fortlaufend","Jogging.Cartesian.Orientation.lb":"Orientierung","Jogging.JointLimitsReached.lb":"Gelenkgrenzen für Gelenk {{jointNumbers}} erreicht","Jogging.Orientation.coordsys":"Roboterbasis","Jogging.Orientation.tool":"Werkzeug","Jogging.StreamStateSection.lb":"Status Stream:","Jogging.StreamStateSection.RUNNING.lb":"In Bewegung","Jogging.StreamStateSection.PAUSED_BY_USER.lb":"Pausiert (Nutzer)","Jogging.StreamStateSection.PAUSED_NEAR_COLLISION.lb":"Pausiert (Kollisionsnähe)","Jogging.StreamStateSection.PAUSED_NEAR_JOINT_LIMIT.lb":"Pausiert (nahe Gelenkgrenze)","Jogging.StreamStateSection.PAUSED_NEAR_SINGULARITY.lb":"Pausiert (nahe Singularität)","Jogging.StreamStateSection.PAUSED_ON_IO.lb":"Pausiert (I/O-Ereignis)","Jogging.StreamStateSection.END_OF_TRAJECTORY.lb":"Trajektorie beendet","Jogging.StreamStateSection.WAIT_FOR_IO.lb":"Warte auf I/O","Jogging.StreamStateSection.KIND_UNKNOWN.lb":"Bereit","Jogging.StreamStateSection.Error.Collision.lb":"Bewegung kann nicht geplant werden: sie würde zu einer Kollision führen","Jogging.StreamStateSection.Error.JointLimit.lb":"Bewegung kann nicht geplant werden: eine Gelenkgrenze würde überschritten","Jogging.StreamStateSection.Error.NoSolutionInConfiguration.lb":"Bewegung kann in der aktuellen Roboterkonfiguration nicht geplant werden","Jogging.StreamStateSection.Error.OutOfWorkspace.lb":"Bewegung kann nicht geplant werden: das Ziel liegt außerhalb des Arbeitsraums","Jogging.StreamStateSection.Error.PlanningFailed.lb":"Die angeforderte Bewegung konnte nicht geplant werden","Jogging.StreamStateSection.Error.Singularity.lb":"Bewegung kann nicht geplant werden: der Pfad führt durch eine Singularität. Versuche eine andere Achse oder bewege die Gelenke direkt","Jogging.TargetPose.Error.Collision.lb":"Die Bewegung zur aktuellen Pose würde eine Kollision verursachen. Bitte ändere die Posen-Koordinaten.","Jogging.TargetPose.Error.NotReachable.lb":"Die aktuelle Pose ist nicht erreichbar. Bitte ändere die Posen-Koordinaten.","Jogging.TargetPose.Error.PlanningFailed.lb":"Die Bewegung zu dieser Pose konnte nicht geplant werden. Bitte ändere die Posen-Koordinaten.","Jogging.TargetPose.Error.Singularity.lb":"Die aktuelle Pose würde eine Singularität erzeugen. Bitte ändere die Posen-Koordinaten.","SafetyBar.ActivationToggle.Activate.bt":"Aktivieren","SafetyBar.ActivationToggle.Activated.bt":"Aktiviert","SafetyBar.ActivationToggle.Activating.bt":"Wird aktiviert…","SafetyBar.ActivationToggle.Deactivating.bt":"Wird deaktiviert…","SafetyBar.ControllerType.Physical.lb":"Physisch","SafetyBar.ControllerType.Virtual.lb":"Virtuell","SafetyBar.MotionGroup.Physical.Explanation.lb":"<code>{{motionGroupId}}</code> ist ein physische Robotersteuerung. Für die Bewegung dieses Roboters sind <strong>Sicherheitsmaßnahmen</strong> aktiv.","SafetyBar.MotionGroup.Virtual.Explanation.lb":"<1>{{motionGroupId}}</1> ist eine virtuelle Robotersteuerung ohne physisches Gegenstück. Der Roboter kann ohne Sicherheitsmaßnahmen bewegt werden.","SafetyBar.OperationMode.Auto.Explanation.lb":"Automatischer Betriebsmodus der Robotersteuerung aktiv. Automatisierte Bewegung ohne manuelle Bestätigung freigegeben.","SafetyBar.OperationMode.Automatic.ti":"Automatisch","SafetyBar.OperationMode.Error.Explanation.lb":"Fehler beim Abrufen des Betriebsmodus. Originalhandbediengerät des Roboters verwenden, um Fehler zu lösen.","SafetyBar.OperationMode.Error.lb":"Fehler","SafetyBar.OperationMode.Manual.Explanation.lb":`Die Robotersteuerung befindet sich im manuellen Betriebsmodus.
|
|
2
|
+
Bei einem physischen Roboter bedeutet dies im Allgemeinen, dass ein Freigabeschalter gedrückt werden muss, damit sich der Roboter erfolgreich bewegen kann.`,"SafetyBar.OperationMode.Manual.lb":"Manuell","SafetyBar.OperationMode.ti":"Betriebsmodus","SafetyBar.SafetyState.Error.Explanation.lb":"Die Robotersteuerung ist in einen unerwarteten Sicherheitszustand eingetreten.","SafetyBar.SafetyState.Error.lb":"Fehler","SafetyBar.SafetyState.Estop.lb":"NOT-AUS","SafetyBar.SafetyState.ManualActionRequired.Explanation.lb":"Die Robotersteuerung ist in einen Sicherheitszustand eingetreten, der manuelle Maßnahmen zur Behebung erfordert.","SafetyBar.SafetyState.ManualActionRequired.lb":"Aktion erforderlich","SafetyBar.SafetyState.Normal.Explanation.lb":"Die Robotersteuerung befindet sich in einem sicheren Zustand. Roboterbewegungen sind möglich.","SafetyBar.SafetyState.Normal.lb":"Sicher","SafetyBar.SafetyState.Stop.Explanation.lb":"Die Robotersteuerung ist in einen Stoppzustand übergegangen. Bis der Stoppzustand aufgelöst ist, ist keine Bewegung mehr möglich.","SafetyBar.SafetyState.Stop.lb":"Stopp","SafetyBar.SafetyState.ti":"Sicherheitszustand","SafetyBar.StopState.Estop.Explanation.lb":"NOT-AUS aktiviert. NOT-AUS freischalten, um Roboter zu bewegen.","Jogging.Increment.hlb":"Schrittgröße","Jogging.CoordinateSystem.hlb":"Koordinatensystem","Jogging.Cartesian.bt":"Kartesisch","Jogging.Joints.bt":"Gelenke","Jogging.Velocity.bt":"Geschwindigkeit","Jogging.Handle.lb":"{{handle}} verfahren","RobotControl.Title.ti":"Robotersteuerung","RobotControl.Close.bt":"Schließen","RobotControl.Tab.Translate.bt":"Verschieben","RobotControl.Tab.Rotate.bt":"Drehen","RobotControl.Tcp.lb":"TCP","RobotControl.JogFrame.lb":"Bewegen relativ zu","RobotControl.JogMode.lb":"Verfahrmodus","RobotControl.JogMode.Continuous.bt":"Fortlaufend","RobotControl.JogMode.Increment.bt":"Schrittweise","RobotControl.Velocity.lb":"Geschwindigkeit","RobotControl.StepSize.lb":"Schrittgröße","RobotControl.JogArea.ShowGizmo.bt":"Gizmo-Steuerung","RobotControl.JogArea.ShowButtons.bt":"Tasten-Steuerung","RobotControl.JogArea.Hint.HoldHandle.lb":"Griff halten zum Verfahren · Loslassen zum Stoppen","RobotControl.JogArea.Hint.HoldButton.lb":"Taste halten zum Verfahren · Loslassen zum Stoppen","RobotControl.JogArea.Hint.ClickHandle.lb":"Griff klicken für einen Schritt","RobotControl.JogArea.Hint.ClickButton.lb":"Taste klicken für einen Schritt","RobotControl.Tab.Joint.bt":"Gelenk","RobotControl.Tab.MoveTo.bt":"Bewegen zu","RobotControl.MoveTo.TargetPose.lb":"Zielpose","RobotControl.MoveTo.RelativeTo.lb":"Relativ zu","RobotControl.MoveTo.Coordinates.lb":"Koordinaten XYZ (mm) · Rotationsvektor (rad)","RobotControl.MoveTo.Copy.bt":"Kopieren","RobotControl.MoveTo.Copied.lb":"Pose kopiert","RobotControl.MoveTo.Edit.bt":"Pose bearbeiten","RobotControl.MoveTo.Cancel.bt":"Abbrechen","RobotControl.MoveTo.ConfirmEdit.lb":"Bearbeitete Pose übernehmen","RobotControl.MoveTo.InvalidPose.lb":"Bitte gültige Posen-Koordinaten eingeben.","RobotControl.MoveTo.Reset.lb":"Pose auf vorherige Position zurücksetzen","RobotControl.MoveTo.MoveTo.bt":"Hierhin bewegen","RobotControl.MoveTo.Moving.bt":"Bewegung aktiv…","RobotControl.MoveTo.Stopping.bt":"Anhalten","RobotControl.MoveTo.HoldToMove.lb":"Zum Bewegen gedrückt halten","RobotControl.MoveTo.AtPose.lb":"Der Roboter befindet sich bereits in dieser Pose","CurrentPose.Title.lb":"Aktuelle Position","CurrentPose.RelativeTo.lb":"Relativ zu","CurrentPose.Copy.bt":"Kopieren","CurrentPose.Copied.lb":"Pose kopiert","CurrentPose.OrientationFormat.ti":"Orientierungsformat","CurrentPose.Format.lb":"Format","CurrentPose.Format.RotationVector.lb":"Rotationsvektor","CurrentPose.Format.EulerAngles.lb":"Euler-Winkel","CurrentPose.Format.Quaternion.lb":"Quaternion","CurrentPose.AngleUnit.lb":"Winkeleinheit","CurrentPose.AngleUnit.Radians.lb":"Radiant","CurrentPose.AngleUnit.Degrees.lb":"Grad","CurrentPose.EulerConvention.lb":"Euler-Konvention","CurrentPose.EulerConvention.Intrinsic.hlb":"Intrinsische Rotationen","CurrentPose.EulerConvention.Extrinsic.hlb":"Extrinsische Rotationen","CurrentPose.EulerConvention.Intrinsic.lb":"Intrinsisch {{axes}}","CurrentPose.EulerConvention.Extrinsic.lb":"Extrinsisch {{axes}}","RobotHeader.Apps.bt":"Apps","RobotHeader.Search.bt":"Suchen","RobotHeader.MotionGroup.lb":"Bewegungsgruppe","Jogging.MoveRelativeTo.SelectedTcp.dd":"Ausgewählter TCP","ConnectionWarning.Interrupted.ti":"Verbindung unterbrochen","ConnectionWarning.LastUpdate.lb":"Kommunikation mit der Robotersteuerung nicht möglich. Die letzte Bewegungsmeldung kam {{time}}.","ConnectionWarning.ErrorState.lb":"Fehlermeldung {{time}}:"},b={"Jogging.Cartesian.Translation.velocityMmPerSec.lb":"{{amount}} mm/s","Jogging.Cartesian.Rotation.velocityDegPerSec.lb":"{{amount}}°/s","Jogging.Velocity.lb":"Velocity","General.degree.variable":"{{amount}}°","General.mm.variable":"{{amount}} mm","Jogging.Blocked.ti":"Connection blocked","Jogging.Blocked.lb":"Another client is currently controlling the jogging.","Jogging.Blocked.Reenable.bt":"Reconnect","Jogging.Cartesian.MotionType.lb":"Motion type","Jogging.Cartesian.Translation.bt":"Translation","Jogging.Cartesian.Rotation.bt":"Rotation","Jogging.Joints.JointValues.lb":"Joint values","Jogging.Increment.Continuous.dd":"Continuous","Jogging.Cartesian.Orientation.lb":"Orientation","Jogging.Activating.lb":"Activating jogging","Jogging.JointLimitsReached.lb":"Joint limit reached for joint {{jointNumbers}}","Jogging.Orientation.coordsys":"Robot base","Jogging.Orientation.tool":"Tool","Jogging.StreamStateSection.lb":"State stream:","Jogging.StreamStateSection.RUNNING.lb":"Running","Jogging.StreamStateSection.PAUSED_BY_USER.lb":"Paused (by user)","Jogging.StreamStateSection.PAUSED_NEAR_COLLISION.lb":"Paused (collision proximity)","Jogging.StreamStateSection.PAUSED_NEAR_JOINT_LIMIT.lb":"Paused (near joint limit)","Jogging.StreamStateSection.PAUSED_NEAR_SINGULARITY.lb":"Paused (near singularity)","Jogging.StreamStateSection.PAUSED_ON_IO.lb":"Paused (I/O event)","Jogging.StreamStateSection.END_OF_TRAJECTORY.lb":"End of trajectory","Jogging.StreamStateSection.WAIT_FOR_IO.lb":"Waiting for I/O","Jogging.StreamStateSection.KIND_UNKNOWN.lb":"Ready","Jogging.StreamStateSection.Error.Collision.lb":"Cannot plan this motion: it would cause a collision","Jogging.StreamStateSection.Error.JointLimit.lb":"Cannot plan this motion: a joint limit would be exceeded","Jogging.StreamStateSection.Error.NoSolutionInConfiguration.lb":"Cannot plan this motion in the current robot configuration","Jogging.StreamStateSection.Error.OutOfWorkspace.lb":"Cannot plan this motion: the target is outside the robot's workspace","Jogging.StreamStateSection.Error.PlanningFailed.lb":"The requested motion could not be planned","Jogging.StreamStateSection.Error.Singularity.lb":"Cannot plan this motion: the path passes through a singularity. Try a different axis or jog the joints directly","Jogging.TargetPose.Error.Collision.lb":"Moving to the current pose would cause a collision. Please change the pose coordinates.","Jogging.TargetPose.Error.NotReachable.lb":"The current pose is not reachable. Please change the pose coordinates.","Jogging.TargetPose.Error.PlanningFailed.lb":"Planning a motion to this pose failed. Please change the pose coordinates.","Jogging.TargetPose.Error.Singularity.lb":"The current pose would create a singularity. Please change the pose coordinates.","SafetyBar.ActivationToggle.Activate.bt":"Activate","SafetyBar.ActivationToggle.Activated.bt":"Activated","SafetyBar.ActivationToggle.Activating.bt":"Activating","SafetyBar.ActivationToggle.Deactivating.bt":"Deactivating","SafetyBar.ControllerType.Physical.lb":"Physical","SafetyBar.ControllerType.Virtual.lb":"Virtual","SafetyBar.MotionGroup.Physical.Explanation.lb":"<code>{{motionGroupId}}</code> is a physical robot controller. <strong>Safety precautions</strong> are active for the movement of this robot.","SafetyBar.MotionGroup.Virtual.Explanation.lb":"<1>{{motionGroupId}}</1> is a virtual robot controller with no physical counterpart. It can be freely manipulated without safety precautions.","SafetyBar.OperationMode.Auto.Explanation.lb":"Automatic operation mode active. Automated movement without manual confirmation enabled.","SafetyBar.OperationMode.Automatic.ti":"Automatic","SafetyBar.OperationMode.Error.Explanation.lb":"Failed to get operation mode. Use the original control panel to resolve the error.","SafetyBar.OperationMode.Error.lb":"Error","SafetyBar.OperationMode.Manual.Explanation.lb":"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.","SafetyBar.OperationMode.Manual.lb":"Manual","SafetyBar.OperationMode.ti":"Operation mode","SafetyBar.SafetyState.Error.Explanation.lb":"The robot controller has entered an unexpected safety state.","SafetyBar.SafetyState.Error.lb":"Error","SafetyBar.SafetyState.Estop.lb":"E-Stop","SafetyBar.SafetyState.ManualActionRequired.Explanation.lb":"The robot controller has entered a safety state requiring manual action to resolve.","SafetyBar.SafetyState.ManualActionRequired.lb":"Action required","SafetyBar.SafetyState.Normal.Explanation.lb":"The robot controller is in a safe state. Robot movement is enabled.","SafetyBar.SafetyState.Normal.lb":"Safe","SafetyBar.SafetyState.Stop.Explanation.lb":"The robot controller has entered a stop state. Movement is no longer possible until the stop state is resolved.","SafetyBar.SafetyState.Stop.lb":"Stop","SafetyBar.SafetyState.ti":"Safety state","SafetyBar.StopState.Estop.Explanation.lb":"An emergency stop of the robot controller has been triggered. Movement of the robot is no longer possible until the estop is released.","Jogging.Increment.hlb":"Increment","Jogging.CoordinateSystem.hlb":"Coordinate system","Jogging.Cartesian.bt":"Cartesian","Jogging.Joints.bt":"Joints","Jogging.Velocity.bt":"Velocity","Jogging.Handle.lb":"Jog {{handle}}","RobotControl.Title.ti":"Robot control","RobotControl.Close.bt":"Close","RobotControl.Tab.Translate.bt":"Translate","RobotControl.Tab.Rotate.bt":"Rotate","RobotControl.Tcp.lb":"TCP","RobotControl.JogFrame.lb":"Move relative to","RobotControl.JogMode.lb":"Jog mode","RobotControl.JogMode.Continuous.bt":"Continuous","RobotControl.JogMode.Increment.bt":"Increment","RobotControl.Velocity.lb":"Velocity","RobotControl.StepSize.lb":"Step size","RobotControl.JogArea.ShowGizmo.bt":"Gizmo controls","RobotControl.JogArea.ShowButtons.bt":"Button controls","RobotControl.JogArea.Hint.HoldHandle.lb":"Hold a handle to jog · Release to stop","RobotControl.JogArea.Hint.HoldButton.lb":"Hold a button to jog · Release to stop","RobotControl.JogArea.Hint.ClickHandle.lb":"Click a handle to jog one step","RobotControl.JogArea.Hint.ClickButton.lb":"Click a button to jog one step","RobotControl.Tab.Joint.bt":"Joint","RobotControl.Tab.MoveTo.bt":"Move to","RobotControl.MoveTo.TargetPose.lb":"Target pose","RobotControl.MoveTo.RelativeTo.lb":"Relative to","RobotControl.MoveTo.Coordinates.lb":"Coordinates XYZ (mm) · Rotation vector (rad)","RobotControl.MoveTo.Copy.bt":"Copy","RobotControl.MoveTo.Copied.lb":"Pose copied","RobotControl.MoveTo.Edit.bt":"Edit pose","RobotControl.MoveTo.Cancel.bt":"Cancel","RobotControl.MoveTo.ConfirmEdit.lb":"Save pose edit","RobotControl.MoveTo.InvalidPose.lb":"Please enter valid pose coordinates.","RobotControl.MoveTo.Reset.lb":"Reset pose to previous one","RobotControl.MoveTo.MoveTo.bt":"Move to","RobotControl.MoveTo.Moving.bt":"Moving…","RobotControl.MoveTo.Stopping.bt":"Stopping…","RobotControl.MoveTo.HoldToMove.lb":"Click and hold to move","RobotControl.MoveTo.AtPose.lb":"Robot is already at this pose","CurrentPose.Title.lb":"Current position","CurrentPose.RelativeTo.lb":"Relative to","CurrentPose.Copy.bt":"Copy","CurrentPose.Copied.lb":"Pose copied","CurrentPose.OrientationFormat.ti":"Orientation format","CurrentPose.Format.lb":"Format","CurrentPose.Format.RotationVector.lb":"Rotation vector","CurrentPose.Format.EulerAngles.lb":"Euler angles","CurrentPose.Format.Quaternion.lb":"Quaternion","CurrentPose.AngleUnit.lb":"Angle unit","CurrentPose.AngleUnit.Radians.lb":"Radians","CurrentPose.AngleUnit.Degrees.lb":"Degrees","CurrentPose.EulerConvention.lb":"Euler convention","CurrentPose.EulerConvention.Intrinsic.hlb":"Intrinsic rotations","CurrentPose.EulerConvention.Extrinsic.hlb":"Extrinsic rotations","CurrentPose.EulerConvention.Intrinsic.lb":"Intrinsic {{axes}}","CurrentPose.EulerConvention.Extrinsic.lb":"Extrinsic {{axes}}","RobotHeader.Apps.bt":"Apps","RobotHeader.Search.bt":"Search","RobotHeader.MotionGroup.lb":"Motion group","Jogging.MoveRelativeTo.SelectedTcp.dd":"Selected TCP","ConnectionWarning.Interrupted.ti":"Connection interrupted","ConnectionWarning.LastUpdate.lb":"Communication with the robot controller interrupted. The last motion update was received {{time}}.","ConnectionWarning.ErrorState.lb":"Error message from {{time}}:"},o=l.createInstance();o.use(g).init({supportedLngs:["en","de"],resources:{en:{translations:b},de:{translations:s}},ns:["translations"],defaultNS:"translations",detection:{order:["navigator","htmlTag"]}});function u(e){const n=i.memo(e);return(r=>t.jsx(c,{children:t.jsx(n,{...r})}))}const c=({children:e})=>t.jsx(a.I18nextProvider,{i18n:o,children:e});exports.externalizeComponent=u;exports.i18n=o;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";const c=require("react/jsx-runtime"),je=require("@mui/material/AppBar"),Dt=require("@mui/material/Backdrop"),G=require("@mui/material/Box"),be=require("@mui/material/Menu"),W=require("@mui/material/MenuItem"),xe=require("@mui/material/Toolbar"),T=require("@mui/material/Typography"),ve=require("@wandelbots/design-tokens"),_e=require("@wandelbots/icons/ExpandMoreFilled"),Ie=require("@wandelbots/mui"),M=require("mobx-react-lite"),I=require("react"),tt=require("./externalizeComponent-Bl23ayrr.cjs"),Ee=require("@mui/icons-material/OpenWith"),Ce=require("@mui/icons-material/Share"),x=require("@mui/material/Stack"),Te=require("@mui/material/Tab"),we=require("@mui/material/Tabs"),m=require("mobx"),F=require("react-i18next"),Lt=require("@mui/material/CircularProgress"),Me=require("@mui/material/utils"),$t=require("lodash-es"),Oe=require("./robotSafetyOf-Cb4qlwd_.cjs"),ke=require("@mui/material/Alert"),Re=require("@mui/material/AlertTitle"),dt=require("@mui/material/Button"),B=require("@mui/material/styles"),H=require("@mui/material/Divider"),It=require("@mui/material/ToggleButton"),_=require("@wandelbots/nova-js"),at=require("@mui/material/IconButton"),w=require("./useSmoothedMotionState-Con0E5Bx.cjs"),Y=require("./joggingColors-ZDc_2UCp.cjs"),Vt=require("lodash-es/isEqual.js"),Ae=require("@mui/material/InputAdornment"),Pe=require("@mui/material/FormControl"),Je=require("@mui/material/InputLabel"),De=require("@mui/material/Select"),Le=require("@mui/material/ToggleButtonGroup"),Nt=require("@mui/material/Slider"),$e=require("lodash-es/isNumber.js"),N=require("@wandelbots/nova-js/v2"),Ve=require("@mui/icons-material/ChevronLeft"),Ne=require("@mui/icons-material/ChevronRight"),Fe=require("lodash-es/throttle.js"),Ge=require("@mui/material/Dialog"),Be=require("@mui/material/DialogActions"),qe=require("@mui/material/DialogContent"),Ue=require("@mui/material/DialogTitle"),U=require("three"),Ft=require("./converters-BsXgcxCW.cjs"),Gt=require("axios"),Z=require("lodash-es/keyBy.js"),ze=require("lodash-es/uniqueId.js"),L=require("./Pose3-Ch4xVeXV.cjs"),Et=require("./robotActivationOf-DeJsI4H5.cjs"),z=require("./useEveryFrame-CHxg25f4.cjs");function Bt(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const b=Bt(I),Ct=Bt(U),We=tt.externalizeComponent(M.observer(o=>{const{appIcon:t,appName:e,apps:i=[],onAppSelect:n,disabled:r=!1,sx:s}=o,[a,g]=I.useState(null),u=!!a,d=l=>{g(l.currentTarget)},p=()=>{g(null)},h=l=>{p(),l.onClick?l.onClick():l.href&&(window.location.href=l.href),n==null||n(l)};return c.jsxs(c.Fragment,{children:[c.jsx(je,{position:"static",sx:{boxShadow:"none",backgroundImage:"none","& .MuiAppBar-root":{backgroundImage:"none",backgroundColor:"transparent"},...s},children:c.jsxs(xe,{sx:{minHeight:"62px !important"},children:[c.jsx(G,{sx:{mr:1,display:"flex",alignItems:"center"},children:t}),c.jsxs(G,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[c.jsx(T,{component:"h1",variant:"subtitle1",children:e}),i.length>0&&c.jsx(Ie.RoundedIconButton,{icon:c.jsx(_e.ExpandMoreFilled,{size:20}),ariaLabel:"switch app","aria-controls":"app-menu","aria-haspopup":"true",onClick:d,disabled:r,sx:{ml:1}})]})]})}),c.jsx(Dt,{open:u,onClick:p,sx:{backdropFilter:"blur(4px)",backgroundColor:ve.ZeroGravityComponentsBackdropFill,zIndex:l=>l.zIndex.modal-1}}),c.jsx(be,{id:"app-menu",anchorEl:a,open:u,onClose:p,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{zIndex:l=>l.zIndex.modal,"& .MuiPaper-root":{minWidth:200,mt:1}},children:i.map(l=>c.jsxs(W,{onClick:()=>h(l),children:[c.jsx(G,{sx:{display:"flex",alignItems:"center"},children:l.icon}),c.jsx(T,{variant:"body1",sx:{ml:2},children:l.name})]},l.id))})]})})),He=({title:o,titleId:t,...e},i)=>b.createElement("svg",{width:21,height:21,viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):null,b.createElement("g",{id:"JogMinus"},b.createElement("path",{id:"Minus",d:"M0 13V8H21V13H0Z",fill:"white"}))),Ye=I.forwardRef(He),Ke=({title:o,titleId:t,...e},i)=>b.createElement("svg",{width:21,height:21,viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):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"})))),Qe=I.forwardRef(Ke),gt=tt.externalizeComponent(M.observer(({colors:o,label:t,getDisplayedValue:e,startJogging:i,stopJogging:n,disabled:r,activeJoggingDirection:s,...a})=>{var O,k,R,E,A,V,q;w.useAnimationFrame(()=>{const D=e(),$=h.current;$&&($.textContent=D)});const g=B.useTheme(),[u,d]=I.useState(null);I.useEffect(()=>{r&&C()},[r]);const p=s||u,h=I.useRef(null);o||(o={color:"#fff",backgroundColor:"#000",borderColor:"#000",buttonBackgroundColor:{disabled:"#000",default:"#000",hovered:"#000",pressed:"#000"},labelColor:"#000"});const l=p?(O=o.buttonBackgroundColor)==null?void 0:O.pressed:o.borderColor,f={width:"55px",color:o.color,path:{fill:o.color},alignContent:"center",fontSize:"37px",svg:{pointerEvents:"none"}},y={...f,backgroundColor:(k=o.buttonBackgroundColor)==null?void 0:k.default,":hover":{backgroundColor:(R=o.buttonBackgroundColor)==null?void 0:R.hovered},":active":{backgroundColor:(E=o.buttonBackgroundColor)==null?void 0:E.pressed,color:o.backgroundColor,path:{fill:o.backgroundColor}},":disabled":{backgroundColor:(A=o.buttonBackgroundColor)==null?void 0:A.disabled,"svg path":{fill:g.palette.action.disabled}}},j={...f,backgroundColor:(V=o.buttonBackgroundColor)==null?void 0:V.pressed,color:o.backgroundColor,path:{fill:o.backgroundColor},":disabled":{backgroundColor:(q=o.buttonBackgroundColor)==null?void 0:q.pressed,"svg path":{fill:g.palette.action.disabled}}};function v(D,$){r||D.button===0&&(d($),i($))}function C(){d(null),n()}return c.jsxs(x,{height:"64px",direction:"row",justifyContent:"center",...a,children:[c.jsx(at,{disabled:r,disableRipple:!0,onPointerDown:D=>v(D,"-"),onPointerUp:C,onPointerOut:C,size:"large",sx:{...p==="-"?j:y,borderRadius:"16px 0px 0px 16px",borderLeft:`2px solid ${l??"#fff"}`,borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:c.jsx(Ye,{})}),c.jsxs(x,{spacing:"6px",sx:{width:"150px",backgroundColor:o.backgroundColor,alignItems:"center",justifyContent:"center",opacity:"0.9",borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:[c.jsx(x,{height:"22px",direction:"row",alignItems:"center",justifyItems:"center",spacing:1,sx:{userSelect:"none",color:o.color,".MuiTypography-root":{fontWeight:700,...r?{color:g.palette.action.disabled}:{}},...r?{"svg path":{fill:g.palette.action.disabled}}:{}},children:t}),c.jsx(T,{height:"22px",sx:{fontSize:"15px",color:r?g.palette.action.disabled:o.color,fontWeight:700,fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center"},ref:h,children:e()})]}),c.jsx(at,{disableRipple:!0,disabled:r,onPointerDown:D=>v(D,"+"),onPointerUp:C,onPointerOut:C,size:"large",sx:{...p==="+"?j:y,borderRadius:"0px 16px 16px 0px",borderRight:`2px solid ${l??"#fff"}`,borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:c.jsx(Qe,{})})]})})),qt=tt.externalizeComponent(M.observer(({startJogging:o,stopJogging:t,lowerLimit:e,upperLimit:i,useDegree:n,getValue:r,disabled:s,...a})=>{var E,A,V,q,D,$,nt;const{t:g}=F.useTranslation(),[u,d]=I.useState(),p=B.useTheme(),h={background:(E=p.palette.backgroundPaperElevation)==null?void 0:E[4],color:(A=p.palette.backgroundPaperElevation)==null?void 0:A[11]},l=M.useLocalObservable(()=>({activeJoggingDir:null,startJogging(S){this.activeJoggingDir=S,o(S)},stopJogging(){this.activeJoggingDir=null,t()}})),f=Fe(()=>{const S=n?y(r()):r();(S===void 0||u===void 0||Math.abs(u-S)>1e-9)&&d(S)},50);w.useAnimationFrame(f);function y(S){if(S!==void 0)return _.radiansToDegrees(S)}function j(S){S.button===0&&l.startJogging("-")}function v(S){S.button===0&&l.startJogging("+")}function C(S){l.stopJogging()}function O(S){l.stopJogging()}function k(S,P=1){if(S===void 0||Number.isNaN(S))return"";const J=g("General.degree.variable",{amount:S.toFixed(P)});return S>0&&P===0?`+${J}`:J}function R(S,P=1){if(S===void 0||Number.isNaN(S))return"";const J=g("General.mm.variable",{amount:S.toFixed(P)});return S>0&&P===0?`+${J}`:J}return c.jsxs(x,{height:"64px",width:"100%",maxWidth:"260px",direction:"row",...a,sx:{"& .MuiIconButton-root":{width:"52px",color:p.palette.text.primary,alignContent:"center",backgroundColor:(V=p.palette.backgroundPaperElevation)==null?void 0:V[11],"& svg":{width:"42px",height:"42px"},"&.Mui-disabled":{backgroundColor:(q=p.palette.backgroundPaperElevation)==null?void 0:q[11],color:p.palette.action.disabled,opacity:1},"&:hover":{backgroundColor:(D=p.palette.backgroundPaperElevation)==null?void 0:D[9]},"&:active":{...h}}},children:[c.jsx(at,{onPointerDown:j,onPointerUp:C,onPointerOut:O,disabled:s,disableRipple:!0,sx:{borderRadius:"16px 0px 0px 16px",...l.activeJoggingDir==="-"?h:{}},children:c.jsx(Ve,{sx:{pointerEvents:"none",color:Y.jointArrowColor}})}),c.jsxs(x,{flexGrow:1,alignItems:"center",justifyContent:"center",sx:{borderStyle:"solid",borderLeftWidth:0,borderRightWidth:0,border:"none",backgroundColor:($=p.palette.backgroundPaperElevation)==null?void 0:$[11],paddingLeft:"20px",paddingRight:"20px",zIndex:1},children:[c.jsx(T,{sx:{fontSize:"15px",fontWeight:700,position:"relative",top:"5px",fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center",color:s?p.palette.action.disabled:p.palette.text.primary},children:n?k(u):R(u)}),c.jsx(Nt,{disabled:!0,"aria-label":"Joint position",min:n?y(e):e,max:n?y(i):i,value:u||0,track:!1,sx:{"& .MuiSlider-mark":{display:"none"},"& .MuiSlider-thumb":{width:"5px",height:"12px",borderRadius:"2px",color:s?p.palette.action.disabled:p.palette.text.primary},"& .MuiSlider-markLabel":{top:"20px",fontSize:"12px",color:s?p.palette.action.disabled:p.palette.text.secondary},"& .MuiSlider-rail":{backgroundColor:(nt=p.palette.backgroundPaperElevation)==null?void 0:nt[5],opacity:1}},marks:e!==void 0&&i!==void 0&&[{value:n?y(e):e,label:n?k(y(e),0):R(e)},{value:n?y(i):i,label:n?k(y(i),0):R(i)}]})]}),c.jsx(at,{onPointerDown:v,onPointerUp:C,onPointerOut:O,disabled:s,disableRipple:!0,sx:{borderRadius:"0px 16px 16px 0px",...l.activeJoggingDir==="+"?h:{}},children:c.jsx(Ne,{sx:{pointerEvents:"none",color:Y.jointArrowColor}})})]})}));function Ze({currentTcpPose:o,axis:t,direction:e,motion:i,useToolCoordinateSystem:n,coordinateSystemRotation:r}){const s=e==="-"?-1:1;if(i.type==="translate"){if(!o.position)throw new Error("Current pose has no position, cannot perform translation");const p=i.distanceMm*s,h=new U.Vector3;if(h[t]=p,n){if(!o.orientation)throw new Error("Current pose has no orientation, cannot translate relative to tool");h.applyQuaternion(L.parseRotationToQuaternion(o.orientation,"ROTATION_VECTOR"))}else r&&h.applyQuaternion(r);const l=[...o.position];return l[0]=(l[0]??0)+h.x,l[1]=(l[1]??0)+h.y,l[2]=(l[2]??0)+h.z,{position:l,orientation:o.orientation}}if(!o.orientation)throw new Error("Current pose has no orientation, cannot perform rotation");const a=L.parseRotationToQuaternion(o.orientation,"ROTATION_VECTOR"),g=new U.Vector3;g[t]=1,!n&&r&&g.applyQuaternion(r);const u=new U.Quaternion().setFromAxisAngle(g,i.distanceRads*s),d=n?a.multiply(u):u.multiply(a);return{position:o.position,orientation:[...L.quaternionToRotationVector(d)]}}function et(o,t,e){return t.length!==o.length?!1:Ut(o,t,e)}function ft(o,t,e){return t.length!==o.length?!0:Ut(o,t,e)}function Ut(o,t,e){for(let i=0;i<t.length;i++)if(Math.abs((t[i]??0)-(o[i]??0))>e)return!1;return!0}function zt(o,t,e){if(o===void 0&&t||o&&t===void 0||(o==null?void 0:o.orientation)===void 0||(t==null?void 0:t.orientation)===void 0||(o==null?void 0:o.position)===void 0||(t==null?void 0:t.position)===void 0)return!1;if(o===void 0||t===void 0)return!0;let i=0;return i+=Math.abs(o.orientation[0]-t.orientation[0]),i+=Math.abs(o.orientation[1]-t.orientation[1]),i+=Math.abs(o.orientation[2]-t.orientation[2]),i+=Math.abs(o.position[0]-t.position[0]),i+=Math.abs(o.position[1]-t.position[1]),i+=Math.abs(o.position[2]-t.position[2]),i<=e}function yt(o,t,e){return o.coordinate_system===t.coordinate_system&&o.tcp===t.tcp&&zt(o.tcp_pose,t.tcp_pose,e)}function St(o,t){const e=new U.Vector3(t[0],t[1],t[2]),i=new U.Vector3(o[0],o[1],o[2]),n=e.length(),r=e.normalize();let s=i.length(),a=i.normalize();a.dot(r)<0&&(s=-s,a=a.multiplyScalar(-1));let g=s-n;return g-=2*Math.PI*Math.floor((g+Math.PI)/(2*Math.PI)),s=n+g,[...a.multiplyScalar(s)]}const Xe=2e-4;function jt(o){const{joint_position:t,tcp_pose:e,tcp:i,coordinate_system:n}=o;return{joint_position:t,tcp_pose:e,tcp:i,coordinate_system:n}}function bt(o,t){return o.tcp===t.tcp&&o.coordinate_system===t.coordinate_system&&o.tcp_pose===void 0==(t.tcp_pose===void 0)&&et(o.joint_position,t.joint_position,Xe)}const Tt=1e-4;class ot{constructor(t,e,i,n,r,s,a="cell",g={}){this.controller=e,this.motionGroup=i,this.description=n,this.initialMotionState=r,this.motionStateSocket=s,this.cellId=a,this.nova=w.createNovaClient(t),this.logger=g.logger??console,this.rapidlyChangingMotionState=r,s.addEventListener("message",u=>{var l;const d=(l=_.tryParseJson(u.data))==null?void 0:l.result;if(!d)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${u.data}`);yt(this.rapidlyChangingMotionState,d,Tt)||m.runInAction(()=>{var f,y,j;this.rapidlyChangingMotionState.tcp_pose==null?this.rapidlyChangingMotionState.tcp_pose=d.tcp_pose:(f=d.tcp_pose)!=null&&f.orientation&&((y=d.tcp_pose)!=null&&y.position)&&((j=this.rapidlyChangingMotionState.tcp_pose)!=null&&j.orientation)?this.rapidlyChangingMotionState.tcp_pose={position:d.tcp_pose.position,orientation:St(d.tcp_pose.orientation,this.rapidlyChangingMotionState.tcp_pose.orientation)}:this.logger.debug("Received incomplete tcp_pose, ignoring",{tcpPose:d.tcp_pose})}),ft(this.rapidlyChangingMotionState.joint_position,d.joint_position,Tt)||m.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=d.joint_position}),d.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==d.tcp&&m.runInAction(()=>{this.rapidlyChangingMotionState.tcp=d.tcp}),this.rapidlyChangingMotionState.standstill!==d.standstill&&m.runInAction(()=>{this.rapidlyChangingMotionState.standstill=d.standstill});const p=this.rapidlyChangingMotionState.joint_limit_reached.limit_reached,h=d.joint_limit_reached.limit_reached;p.some((f,y)=>f!==h[y])&&m.runInAction(()=>{this.rapidlyChangingMotionState.joint_limit_reached=d.joint_limit_reached}),this.rapidlyChangingMotionState.execute!==d.execute&&m.runInAction(()=>{this.rapidlyChangingMotionState.execute=d.execute})}),m.makeAutoObservable(this,{logger:!1,readoutState:m.computed({equals:bt,keepAlive:!0})})}static async open(t,e,i={}){var y;const n=w.createNovaClient(t),r=i.cellId??w.cellIdOf(t)??"cell",[s,a]=e.split("@"),g=await n.api.controller.getCurrentRobotControllerState(r,a),u=g==null?void 0:g.motion_groups.find(j=>j.motion_group===e);if(!g||!u)throw new Error(`Controller ${a} or motion group ${e} not found`);const d=n.openReconnectingWebsocket(`/cells/${r}/controllers/${a}/motion-groups/${e}/state-stream`),p=await d.firstMessage(),h=(y=_.tryParseJson(p.data))==null?void 0:y.result;if(!h)throw new Error(`Unable to parse initial motion state message ${p.data}`);const l=i.logger??console;l.info("Connected motion state websocket to motion group",{motionGroup:u.motion_group,initialMotionState:h});const f=await n.api.motionGroup.getMotionGroupDescription(r,a,u.motion_group);return new ot(n,g,u,f,h,d,r,{logger:l})}get readoutState(){return jt(this.rapidlyChangingMotionState)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get joints(){return this.initialMotionState.joint_position.map((t,e)=>({index:e}))}dispose(){this.motionStateSocket.close()}}const wt="Movement request rejected. Another client is currently executing a 'Jogging' motion!",to=500,eo=5e3;function oo(o){var e;return(((e=o.times)==null?void 0:e[o.times.length-1])??0)*2e3+eo}class it{constructor(t,e={}){this.motionStream=t,this.options=e,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=(e==null?void 0:e.tcp)||t.motionGroup.tcp||this.getDefaultTcp(t),this.coordinateSystem=e==null?void 0:e.coordinateSystem,this.orientation=(e==null?void 0:e.orientation)||this.DEFAULT_ORIENTATION,this.timeout=(e==null?void 0:e.timeout)||this.DEFAULT_INIT_TIMEOUT,this.mode=(e==null?void 0:e.mode)||this.DEFAULT_MODE,this.onError=e==null?void 0:e.onError,this.logger=(e==null?void 0:e.logger)??console}static async open(t,e,i={}){const n=await ot.open(t,e,{cellId:i.cellId,logger:i.logger}),r=new it(n,i);r.ownsMotionStream=!0;try{await r.setJoggingMode(r.mode)}catch(s){throw r.dispose(),s}return r}getDefaultTcp(t){var i,n;const e=(n=(i=t.description.dh_parameters)==null?void 0:i[0])==null?void 0:n.type;return t.joints.length<6&&(e===N.JointTypeEnum.RevoluteJoint||e===N.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 e,i;(e=this.endJoggingInit)==null||e.call(this),(i=this.endIncrementalMotion)==null||i.call(this);const t=[this.joggingSocket,this.trajectorySocket].filter(n=>n!==null);return t.forEach(n=>{n.dispose()}),this.joggingSocket=null,this.trajectorySocket=null,Promise.all(t.map(n=>n.closed()))}async setJoggingMode(t,e=!0){if(!(this.mode===t&&e)&&(this.closeJoggingSockets(),this.mode=t,this.mode==="jogging"))return this.initializeJoggingWebsocket()}async initializeJoggingWebsocket(){return new Promise((t,e)=>{const i=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`);this.joggingSocket=i;let n=!1;const r=setTimeout(()=>{s(new Error(`Jogging initialization timeout after ${this.timeout} ms`))},this.timeout),s=u=>{n||(n=!0,clearTimeout(r),i.removeEventListener("close",g),this.endJoggingInit===a&&(this.endJoggingInit=void 0),u?e(u):t())},a=()=>s(),g=()=>{i.disposed&&s()};this.endJoggingInit=a,i.addEventListener("close",g),i.addEventListener("message",u=>{var p,h,l;const d=_.tryParseJson(u.data);if(((p=d==null?void 0:d.result)==null?void 0:p.kind)==="INITIALIZE_RECEIVED"){s();return}if(((h=d==null?void 0:d.result)==null?void 0:h.kind)==="MOTION_ERROR")if(this.onBlocked&&((l=d==null?void 0:d.result)!=null&&l.message.includes(wt))){s(),i.dispose(),this.onBlocked();return}else this.onError?(s(),this.onError(u.data)):s(new Error(u.data))}),i.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:t,direction:e,velocityValue:i,velocityUnit:n}){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]=e==="-"?-i:i,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:r})}async translateTCP({axis:t,direction:e,velocityMmPerSec:i}){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,e==="-"?-i:i),rotation:[0,0,0],use_tool_coordinate_system:this.orientation==="tool"})}async rotateTCP({axis:t,direction:e,velocityRadsPerSec:i}){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,e==="-"?-i:i),use_tool_coordinate_system:this.orientation==="tool"})}get coordinateSystemRotation(){if(!(this.orientation==="tool"||!this.coordinateSystem))return L.Pose3.fromCoordinateSystem(this.coordinateSystem).quaternion}velocityAlongAxis(t,e){const i=new U.Vector3;i[t]=e;const n=this.coordinateSystemRotation;return n&&i.applyQuaternion(n),[i.x,i.y,i.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 e=await this.planIncrementalCartesianMotion(t);e&&await this.executeTrajectory(e)}finally{this.incrementalMotionInFlight=!1}}}async planIncrementalCartesianMotion({currentTcpPose:t,currentJoints:e,velocityInRelevantUnits:i,axis:n,direction:r,motion:s}){var y,j,v;const a=[],g=Ze({currentTcpPose:t,axis:n,direction:r,motion:s,useToolCoordinateSystem:this.orientation==="tool",coordinateSystemRotation:this.coordinateSystemRotation});a.push({limits_override:s.type==="translate"?{tcp_velocity_limit:i}:{tcp_orientation_velocity_limit:i},path:{path_definition_name:"PathLine",target_pose:{position:g.position,orientation:g.orientation}}});const u=this.motionStream.description;if(u.cycle_time===void 0){this.logger.warn("Current motion group has no cycle time, cannot plan jogging motion");return}const d=this.motionStream.rapidlyChangingMotionState.tcp,p=d?(j=(y=u.tcps)==null?void 0:y[d])==null?void 0:j.pose:void 0,h={motion_group_model:((v=this.options)==null?void 0:v.motionGroupModel)??u.motion_group_model,cycle_time:u.cycle_time,mounting:u.mounting,tcp_offset:p,global:u.operation_limits.auto_limits},l=await this.nova.api.trajectoryPlanning.planTrajectory(this.cellId,{motion_group_setup:h,start_joint_position:e,motion_commands:a}),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 e=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);this.trajectorySocket=e;const i=new AbortController;let n,r;try{await new Promise((s,a)=>{let g=!1;const u=()=>{g||(g=!0,s())},d=h=>{if(!g){if(g=!0,this.onError){this.onError(h),s();return}a(h instanceof Error?h:new Error(`Failed to execute trajectory: ${JSON.stringify(h)}`))}};r=u,this.endIncrementalMotion=u;const p=oo(t);n=setTimeout(()=>{d(new Error(`Jogging motion did not complete within ${p}ms`))},p),e.addEventListener("message",h=>{var f,y;const l=(f=_.tryParseJson(h.data))==null?void 0:f.result;if(!(l!=null&&l.kind)){d(new Error(`Failed to execute trajectory: Received invalid message ${h.data}`));return}if(this.onBlocked&&((y=l.message)!=null&&y.includes(wt))){this.onBlocked(),u();return}if(l.kind==="INITIALIZE_RECEIVED"){if(l.add_trajectory_error||l.message){d(l);return}e.sendJson({message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"})}else if(l.kind==="START_RECEIVED"){if(l.message){d(l);return}this.waitForMotionToFinish(i.signal).then(u,d)}else l.kind==="PAUSE_RECEIVED"||(l.kind==="MOTION_ERROR"&&l.message?d(l):d(new Error(`Failed to execute trajectory, cannot handle message type "${l.kind}"`)))}),e.sendJson({message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.motionGroupId,data:t,tcp:this.tcp}})})}finally{clearTimeout(n),i.abort(),this.endIncrementalMotion===r&&(this.endIncrementalMotion=void 0),e.dispose(),this.trajectorySocket===e&&(this.trajectorySocket=null)}}async waitForMotionToFinish(t){const e=()=>this.motionStream.rapidlyChangingMotionState.standstill;await m.when(()=>!e(),{timeout:to,signal:t}).catch(()=>{}),await m.when(e,{signal:t})}}const Wt=o=>{const t=o.softTimeout||3e3,[e,i]=I.useState(!1);return I.useEffect(()=>{const n=setTimeout(()=>{i(!0)},t);return()=>clearTimeout(n)}),c.jsx(x,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:"text.primary"},children:o.error?c.jsx(Ht,{loadingMessage:o.message,error:o.error}):c.jsxs(c.Fragment,{children:[c.jsx(Lt,{sx:{mb:3}}),!!o.message&&c.jsx(T,{variant:"body1",children:o.message}),c.jsx(T,{variant:"body2",sx:{visibility:e?"visible":"hidden",mt:2,color:"text.secondary"},children:"This is taking longer than expected..."})]})})},Ht=o=>{const t=Oe.makeErrorMessage(o.error),e=o.error instanceof Error?o.error.stack:null;return c.jsxs(x,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",p:2,overflow:"auto",color:"error.main"},children:[c.jsx(T,{variant:"body1",children:(o.loadingMessage?`Error while ${$t.lowerFirst(Me.capitalize(o.loadingMessage))} - `:"")+t}),e&&c.jsx(G,{component:"pre",sx:{typography:"body2",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",mt:2,pb:6},children:e})]})},io=M.observer(({store:o})=>{const{t}=F.useTranslation();return c.jsx(Dt,{"data-testid":"jogging-blocked","aria-label":"jogging-blocked",open:!0,sx:{position:"absolute",zIndex:e=>e.zIndex.drawer+1,color:"#fff",background:"rgba(15, 15, 15, 0.88)",justifyContent:"flex-start",alignItems:"flex-start"},children:c.jsxs(x,{sx:{m:2,width:"100%"},children:[c.jsxs(ke,{severity:"error",sx:{mb:2},children:[c.jsx(Re,{children:t("Jogging.Blocked.ti")}),t("Jogging.Blocked.lb")]}),c.jsx(dt,{variant:"contained",color:"secondary",onClick:()=>o.unblock(),children:t("Jogging.Blocked.Reenable.bt")})]})})}),no=({title:o,titleId:t,...e},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):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"})),ro=I.forwardRef(no),so=({title:o,titleId:t,...e},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):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"})),ao=I.forwardRef(so),co=({title:o,titleId:t,...e},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:10,height:19,fill:"none",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):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"})),lo=I.forwardRef(co),go=({title:o,titleId:t,...e},i)=>b.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):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"})),uo=I.forwardRef(go),Yt=M.observer(({store:o})=>{const{t}=F.useTranslation(),[e,i]=I.useState(o.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached),n=I.useRef(e);w.useAnimationFrame(()=>{const s=o.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;Vt(n.current,s)||(n.current=s,i(s))});const r=[];for(const[s,a]of e.entries())a&&r.push(s);return c.jsx(G,{sx:{display:"flex",flexDirection:"row",justifyContent:"center"},children:c.jsx(T,{"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(s=>s+1).join(", ")})})})}),ho=B.styled(Pe)(({theme:o})=>({"&.MuiFormControl-root":{".MuiSelect-select":{paddingTop:"20px",paddingLeft:"12px"},label:{pointerEvents:"none",fontSize:"16px"},".MuiInputLabel-root":{"&.Mui-focused":{color:o.palette.text.primary}}}}));function rt({labelValue:o,...t}){return c.jsxs(ho,{fullWidth:!0,variant:"filled",children:[c.jsx(Je,{id:t.labelId,children:o}),c.jsx(De,{...t})]})}function Mt(o){const t=o.lastIndexOf("On");return t>0?o.slice(0,t):o}function Kt(o,t){const e=o[t];if(e)return e;const i=Mt(t),n=o[i];if(n)return n;const r=Object.keys(o).filter(a=>Mt(a)===i);if(r.length!==1)return;const s=r[0];return s?o[s]:void 0}const po={coordinate_system:"world",name:"world",reference_coordinate_system:"",position:[0,0,0],orientation:[0,0,0],orientation_type:"ROTATION_VECTOR"};function Qt(o){const t=Z(o.map(n=>({...n,coordinate_system:n.coordinate_system||"world"})),"coordinate_system");t.world??(t.world=po);const e={},i=n=>{const r=e[n];if(r)return r;const s=Kt(t,n);if(!s)throw new Error(`Unknown coordinate system ${n}. Known coordinate systems are: ${Object.keys(t).join(", ")}`);const a=s.reference_coordinate_system||"world";let g;if(a==="world")g=s;else{const u=i(a),d=L.Pose3.fromCoordinateSystem(u).multiply(L.Pose3.fromCoordinateSystem(s));g={...s,position:[d.position.x,d.position.y,d.position.z],orientation:[d.orientation.x,d.orientation.y,d.orientation.z],orientation_type:"ROTATION_VECTOR",reference_coordinate_system:u.reference_coordinate_system}}return e[n]=g,g};return Object.fromEntries(Object.keys(t).map(n=>[n,i(n)]))}function ut(o,t){const e=Kt(o,t||"world");if(!e)throw new Error(`Unknown coordinate system ${t}. Known coordinate systems are: ${Object.keys(o).join(", ")}`);return e}function Zt(o,t){return ut(Qt(t),o)}function X(o,t,e){if(o.coordinateSystemId===t)return o;const i=Qt(e),n=ut(i,o.coordinateSystemId||"world"),r=ut(i,t);if(n.coordinate_system===r.coordinate_system)return{...o,coordinateSystemId:r.coordinate_system};const s=L.Pose3.fromCoordinateSystem(r).inverse().multiply(L.Pose3.fromCoordinateSystem(n).multiply(L.Pose3.fromPose(o.pose)));return{...o,pose:{position:[s.position.x,s.position.y,s.position.z],orientation:[s.orientation.x,s.orientation.y,s.orientation.z]},coordinateSystemId:r.coordinate_system}}function Xt(o,t,e){const i=L.Pose3.fromPose(o).multiply(L.Pose3.fromRobotTcp(t).inverse()).multiply(L.Pose3.fromRobotTcp(e)),{position:n,orientation:r}=i;return{position:[n.x,n.y,n.z],orientation:[r.x,r.y,r.z]}}function Ot(o,t){const e=o==null?void 0:o[t];if(!e)throw new Error(`Unknown TCP ${t}. Known TCPs are: ${Object.keys(o??{}).join(", ")}`);return{position:e.pose.position??[0,0,0],orientation:e.pose.orientation??[0,0,0],orientation_type:"ROTATION_VECTOR"}}function ht({inputPose:o,selectedTcpId:t,selectedCoordinateSystemId:e,tcpOffsetsById:i,coordinateSystems:n}){const r=t&&t!==o.tcpId?{...o,pose:Xt(o.pose,Ot(i,o.tcpId),Ot(i,t)),tcpId:t}:o;return e?X(r,e,n):r}function te(o){var t,e,i,n,r;if(typeof o=="string"){const s=_.tryParseJson(o);return s?te(s):o}if(o&&typeof o=="object"){const s=o;return((t=s.error_feedback)==null?void 0:t.error_feedback_name)||((e=s.add_trajectory_error)==null?void 0:e.message)||s.message||((n=(i=s.result)==null?void 0:i.add_trajectory_error)==null?void 0:n.message)||((r=s.result)==null?void 0:r.message)||"Jogging motion failed"}return"Jogging motion failed"}const mo=[{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 fo(o){var t;return((t=mo.find(({pattern:e})=>e.test(o)))==null?void 0:t.translationKey)??null}const yo=5,So=250;function jo(o){var i,n,r,s;const t=[(n=(i=o==null?void 0:o.manual_t1_limits)==null?void 0:i.tcp)==null?void 0:n.velocity,(s=(r=o==null?void 0:o.manual_limits)==null?void 0:r.tcp)==null?void 0:s.velocity].filter(a=>typeof a=="number"&&Number.isFinite(a)&&a>0);return Math.min(So,...t)/10}const pt=[{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}],bo=[{id:"continuous"},...pt],xo=["coordsys","tool"],kt="joggingToolStore",vo=()=>typeof localStorage>"u"?void 0:localStorage;class K{constructor(t,e,i,n,r,s={}){var g,u,d;this.jogger=t,this.coordSystems=e,this.motionGroupDescription=i,this.tcps=n,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=yo,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=N.JointTypeEnum.RevoluteJoint,this.storage=s.storage??vo();for(const p of e)if(p.coordinate_system===""){p.coordinate_system="world";break}this.selectedCoordSystemId=((g=e[0])==null?void 0:g.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=jo(i==null?void 0:i.operation_limits),this.jointType=((d=(u=i==null?void 0:i.dh_parameters)==null?void 0:u[0])==null?void 0:d.type)??N.JointTypeEnum.RevoluteJoint,m.makeAutoObservable(this,{storage:!1},{autoBind:!0}),this.jogger.onBlocked=()=>{this.block()};const a=this.jogger.onError;this.jogger.onError=p=>{this.setLastJogError(te(p)),a==null||a(p)},this.loadFromLocalStorage(),this.disposers.push(m.autorun(()=>this.saveToLocalStorage())),this.disposers.push(m.autorun(()=>{const p=this.jogger.motionStream.rapidlyChangingMotionState.tcp;p&&p!==this.selectedTcpId&&m.runInAction(()=>{this.selectedTcpId=p,this.tcpChangeInProgress=!1})}))}static async loadFor(t,e={}){const{nova:i,cellId:n}=t,[r,s]=await Promise.all([i.api.controller.listCoordinateSystems(n,t.motionStream.controllerId,"ROTATION_VECTOR"),i.api.motionGroup.getMotionGroupDescription(n,t.motionStream.controllerId,t.motionGroupId)]),a=await i.api.motionGroupModels.getMotionGroupKinematicModel(s.motion_group_model);return K.create(t,{coordinateSystems:r||[],description:s,kinematicModel:a},e)}static create(t,e,i={}){const{coordinateSystems:n,description:r,kinematicModel:s}=e,a=Object.entries(r.tcps||{}).map(([g,u])=>({id:g,readable_name:u.name,position:u.pose.position,orientation:u.pose.orientation}));return new K(t,n,r,a,s.inverse_solver,i)}dispose(){for(const t of this.disposers)t();this.jogger.dispose()}get coordSystemCountByName(){return $t.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 i;const t=(i=this.storage)==null?void 0:i.getItem(kt),e=t?_.tryParseJson(t):void 0;e&&(this.tabsById[e.selectedTabId]&&(this.selectedTabId=e.selectedTabId),this.coordSystemsById[e.selectedCoordSystemId]&&(this.selectedCoordSystemId=e.selectedCoordSystemId),this.coordSystemsById[e.jogCoordSystemId]&&(this.jogCoordSystemId=e.jogCoordSystemId),this.incrementOptionsById[e.selectedIncrementId]&&(this.selectedIncrementId=e.selectedIncrementId),["translate","rotate"].includes(e.selectedCartesianMotionType)&&(this.selectedCartesianMotionType=e.selectedCartesianMotionType),["coordsys","tool"].includes(e.selectedOrientation)&&(this.selectedOrientation=e.selectedOrientation))}saveToLocalStorage(){var t;(t=this.storage)==null||t.setItem(kt,JSON.stringify(this.localStorageSave))}get isLocked(){return this.locks.size>0}get lastJogErrorTranslationKey(){return this.lastJogError?fo(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 bo}get discreteIncrementOptions(){return pt}get incrementOptionsById(){return Z(this.incrementOptions,t=>t.id)}get tabsById(){return Z(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 Z(this.coordSystems,t=>t.coordinate_system)}get activeCoordSystemId(){return this.selectedOrientation==="tool"?"tool":this.selectedCoordSystemId}get jogCoordSystem(){return Zt(this.jogCoordSystemId,this.coordSystems)}get tcpPoseInSelectedCoordSystem(){const{tcp_pose:t,coordinate_system:e}=this.jogger.motionStream.readoutState;return!(t!=null&&t.position)||!t.orientation?t:X({pose:{position:t.position,orientation:t.orientation},coordinateSystemId:e||"world"},this.selectedCoordSystemId,this.coordSystems).pose}get tcpsById(){return Z(this.tcps,t=>t.id)}tcpPoseIn(t,e){const{tcp_pose:i,tcp:n,coordinate_system:r}=this.jogger.motionStream.readoutState,s=this.tcpsById[n||this.selectedTcpId],a=this.tcpsById[t];if(!(!(i!=null&&i.position)||!i.orientation)&&!(!s||!a))try{return X({pose:Xt(i,s,a),coordinateSystemId:r||"world"},e,this.coordSystems).pose}catch{return}}get activeDiscreteIncrement(){return pt.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,e){const i=this.tabs[e]||this.tabs[0];this.selectedTabId=i.id}setSelectedCoordSystemId(t){this.selectedCoordSystemId=t}setSelectedTcpId(t){this.requestTcpChange(t).catch(e=>{console.error("Failed to change TCP:",e)})}async requestTcpChange(t){if(t===this.selectedTcpId)return;this.tcpChangeInProgress=!0;const e=this.jogger.tcp,i=this.jogger.mode!=="jogging";try{this.jogger.tcp=t,i?await this.jogger.setJoggingMode("jogging"):await this.jogger.setJoggingMode("jogging",!1);let n=await this.waitForTcpConfirmation(t,1e3);i&&await this.jogger.setJoggingMode("off"),n||(n=await this.waitForTcpConfirmation(t,2e3)),m.runInAction(()=>{n?this.selectedTcpId=t:(this.jogger.tcp=e,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??"")})}catch(n){throw i&&await this.jogger.setJoggingMode("off").catch(()=>{}),m.runInAction(()=>{this.jogger.tcp=e,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??""}),n}finally{m.runInAction(()=>{this.tcpChangeInProgress=!1})}}waitForTcpConfirmation(t,e){return new Promise(i=>{const n=setTimeout(()=>{r(),i(!1)},e),r=m.when(()=>this.jogger.motionStream.rapidlyChangingMotionState.tcp===t,()=>{clearTimeout(n),i(!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,e){!Number.isFinite(t)||t<this.minVelocityInDisplayUnits(e)||t>this.maxVelocityInDisplayUnits(e)||(e?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 e=ze();this.lock(e);try{return await t()}finally{this.unlock(e)}}}const _o=M.observer(({store:o,useDegree:t})=>{var s;const{t:e}=F.useTranslation(),i=I.useId(),n=[];function r(a){switch(a){case"coordsys":return e("Jogging.Orientation.coordsys");case"tool":return e("Jogging.Orientation.tool");default:return a}}return o.showCoordSystemSelect&&n.push(c.jsx(rt,{labelId:`jogging-coord-select-${i}`,labelValue:e("Jogging.CoordinateSystem.hlb"),value:o.selectedCoordSystemId,size:"small",variant:"filled",displayEmpty:!0,onChange:a=>o.setSelectedCoordSystemId(a.target.value),children:o.coordSystems.map(a=>c.jsx(W,{value:a.coordinate_system,children:a.name&&o.coordSystemCountByName[a.name]>1?`${a.name} / ${a.coordinate_system}`:a.name||a.coordinate_system},a.coordinate_system))},"coord")),o.showTcpSelect&&n.push(c.jsx(rt,{labelId:`jogging-tcp-select-${i}`,labelValue:"TCP",value:o.selectedTcpId,size:"small",variant:"filled",displayEmpty:o.tcpChangeInProgress,onChange:a=>{o.requestTcpChange(a.target.value).catch(g=>{console.error("Failed to change TCP:",g)})},disabled:o.tcpChangeInProgress,endAdornment:o.tcpChangeInProgress?c.jsx(Ae,{position:"end",children:c.jsx(Lt,{size:16})}):void 0,children:o.tcps.map(a=>c.jsx(W,{value:a.id,children:a.id},a.id))},"tcp")),o.showOrientationSelect&&n.push(c.jsx(rt,{labelValue:e("Jogging.Cartesian.Orientation.lb"),labelId:`orientation-select-${i}`,value:o.selectedOrientation,onChange:a=>o.setSelectedOrientation(a.target.value),children:xo.map(a=>c.jsx(W,{value:a,children:r(a)},a))},"orientation")),o.showIncrementSelect&&n.push(c.jsxs(rt,{labelValue:e("Jogging.Increment.hlb"),labelId:`jogging-increment-select-${i}`,size:"small",variant:"filled",value:((s=o.activeDiscreteIncrement)==null?void 0:s.id)||"continuous",onChange:a=>o.setSelectedIncrementId(a.target.value),children:[c.jsx(W,{value:"continuous",children:e("Jogging.Increment.Continuous.dd")},"continuous"),o.discreteIncrementOptions.map(a=>c.jsx(W,{value:a.id,children:t?`${a.degrees}°`:`${a.mm}mm`},a.id))]},"increment")),c.jsx(G,{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:n.map((a,g)=>c.jsx(G,{sx:{gridColumn:n.length%2===1&&g===n.length-1?"span 2":"auto"},children:a},g))})}),Io=B.styled(Le)(({theme:o})=>{var t;return{"&.MuiToggleButtonGroup-root":{background:(t=o.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"}}}}}),ee=tt.externalizeComponent(M.observer(o=>{const{store:t}=o,{t:e}=F.useTranslation();function i(n,r){r===o.velocity||!$e(r)||o.onVelocityChange(r,o.useDegree)}return c.jsxs(x,{direction:"row",gap:2,alignItems:"center","data-testid":"velocity-slider","aria-label":"velocity-slider",children:[t.showVelocityLegend&&c.jsx(T,{sx:{color:Y.velocitySliderLegendColor,fontSize:"14px"},children:e("Jogging.Velocity.bt")}),c.jsx(Nt,{value:o.velocity,color:"secondary",onChange:i,min:o.min,max:o.max,"aria-labelledby":"input-slider",disabled:o.disabled,sx:{"& .MuiSlider-valueLabelOpen":{zIndex:100,backgroundColor:"transparent",top:"0px"}}}),t.showVelocitySliderLabel&&(o.renderValue?o.renderValue(o.velocity):c.jsx(xt,{value:o.velocity.toString()}))]})}));function xt({value:o,sx:t}){var i;const e=B.useTheme();return c.jsx(x,{direction:"row",justifyContent:"center",alignItems:"center",gap:"5px",sx:{padding:"6px 12px",background:(i=e.palette.backgroundPaperElevation)==null?void 0:i[8],borderRadius:"10px",minWidth:"111px",...t},children:c.jsx(T,{component:"span",sx:{textAlign:"right",fontSize:"14px",opacity:.8,color:e.palette.text.primary,whiteSpace:"nowrap"},children:o})})}const oe=M.observer(({store:o,useDegree:t})=>{const{t:e}=F.useTranslation();function i(n,r){return r?`ω = ${e("Jogging.Cartesian.Rotation.velocityDegPerSec.lb",{amount:n})}`:`v = ${e("Jogging.Cartesian.Translation.velocityMmPerSec.lb",{amount:n})}`}return c.jsx(ee,{store:o,velocity:o.velocityInDisplayUnits(t),min:o.minVelocityInDisplayUnits(t),max:o.maxVelocityInDisplayUnits(t),onVelocityChange:o.setVelocityFromSlider,useDegree:t,disabled:o.isLocked,renderValue:n=>c.jsx(xt,{value:i(n,t),sx:{minWidth:"111px",span:{transform:"translateY(-1.5px)"}}})})}),ie=M.observer(({store:o})=>{var s,a,g;const{t}=F.useTranslation(),e=B.useTheme(),i=((g=(a=(s=o.jogger.motionStream.rapidlyChangingMotionState.execute)==null?void 0:s.details)==null?void 0:a.state)==null?void 0:g.kind)??"KIND_UNKNOWN",n=o.lastJogError,r=o.lastJogErrorTranslationKey;return c.jsxs(G,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",color:e.palette.text.primary},children:[c.jsx(T,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},children:t("Jogging.StreamStateSection.lb")}),c.jsx(T,{variant:"body2",color:n?"error":void 0,sx:{fontSize:"0.75rem",lineHeight:1.2,textAlign:"right"},"data-testid":n?"JOG_ERROR":i,children:n?r?t(r):n:t(`Jogging.StreamStateSection.${i}.lb`)})]})}),Eo=M.observer(({store:o,children:t})=>{const{t:e}=F.useTranslation(),i=B.useTheme(),n=I.useRef(0);function r(h,l){(l==="translate"||l==="rotate")&&o.setSelectedCartesianMotionType(l)}async function s(h,l){const f=await o.activate(),y=f.motionStream.rapidlyChangingMotionState.tcp_pose,j=f.motionStream.rapidlyChangingMotionState.joint_position;y&&await o.withMotionLock(async()=>{try{o.setCurrentIncrementJog({axis:h.axis,direction:h.direction}),await o.jogger.runIncrementalCartesianMotion({currentTcpPose:y,currentJoints:j,coordSystemId:o.activeCoordSystemId,velocityInRelevantUnits:o.selectedCartesianMotionType==="translate"?o.translationVelocityMmPerSec:o.rotationVelocityRadsPerSec,axis:h.axis,direction:h.direction,motion:o.selectedCartesianMotionType==="translate"?{type:"translate",distanceMm:l.mm}:{type:"rotate",distanceRads:_.degreesToRadians(l.degrees)}})}finally{o.setCurrentIncrementJog(null),await o.deactivate()}})}async function a(h){if(o.isLocked)return;const l=++n.current;try{if(await o.activate(),l!==n.current)return;if(o.activeDiscreteIncrement)return await s(h,o.activeDiscreteIncrement);h.motionType==="translate"?await o.jogger.translateTCP({axis:h.axis,direction:h.direction,velocityMmPerSec:o.translationVelocityMmPerSec}):await o.jogger.rotateTCP({axis:h.axis,direction:h.direction,velocityRadsPerSec:o.rotationVelocityRadsPerSec})}catch(f){console.error("Jogging failed:",f)}}async function g(){o.isLocked||o.activeDiscreteIncrement||(n.current++,await o.deactivate())}const u=[{id:"x",icon:c.jsx(ro,{}),colors:Y.cartesianAxisColors.X},{id:"y",icon:c.jsx(ao,{}),colors:Y.cartesianAxisColors.Y},{id:"z",icon:c.jsx(lo,{}),colors:Y.cartesianAxisColors.Z}];function d(h){return e("General.mm.variable",{amount:h.toFixed(1)})}function p(h){return e("General.degree.variable",{amount:_.radiansToDegrees(h).toFixed(1)})}return c.jsxs(x,{"data-testid":"jogging-cartesian-tab","aria-label":"jogging-cartesian-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[c.jsxs(x,{gap:2,children:[c.jsx(_o,{store:o,useDegree:o.selectedCartesianMotionType==="rotate"}),c.jsx(oe,{store:o,useDegree:o.selectedCartesianMotionType==="rotate"}),c.jsx(H,{})]}),c.jsx(x,{marginLeft:"auto",marginRight:"auto",gap:"24px",justifyContent:"center",sx:{flexGrow:"1"},children:c.jsxs(x,{alignItems:"center",justifyContent:"center",gap:"24px",sx:{flexGrow:1},children:[c.jsxs(Io,{value:o.selectedCartesianMotionType,onChange:r,exclusive:!0,"aria-label":e("Jogging.Cartesian.MotionType.lb"),sx:{justifyContent:"center"},children:[c.jsx(It,{value:"translate",children:e("Jogging.Cartesian.Translation.bt")}),c.jsx(It,{value:"rotate",children:e("Jogging.Cartesian.Rotation.bt")})]}),o.selectedCartesianMotionType==="translate"&&u.map(h=>{var l,f;return c.jsx(gt,{"data-testid":`jogging-cartesian-axis-control-${h.id}`,"aria-label":`jogging-cartesian-axis-control-${h.id}`,colors:h.colors,disabled:o.isLocked,activeJoggingDirection:((l=o.incrementJogInProgress)==null?void 0:l.axis)===h.id?o.incrementJogInProgress.direction:void 0,label:c.jsxs(c.Fragment,{children:[h.icon,c.jsx(T,{sx:{fontSize:"24px",color:((f=h.colors)==null?void 0:f.labelColor)??i.palette.text.primary},children:h.id.toUpperCase()})]}),getDisplayedValue:()=>{var y,j;return d(((j=(y=o.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:y.position)==null?void 0:j[_.XYZ_TO_VECTOR[h.id]])||0)},startJogging:y=>a({axis:h.id,motionType:"translate",direction:y}),stopJogging:g},h.id)}),o.selectedCartesianMotionType==="rotate"&&u.map(h=>{var l,f;return c.jsx(gt,{"data-testid":`jogging-cartesian-axis-control-${h.id}`,"aria-label":`jogging-cartesian-axis-control-${h.id}`,colors:h.colors,disabled:o.isLocked,activeJoggingDirection:((l=o.incrementJogInProgress)==null?void 0:l.axis)===h.id?o.incrementJogInProgress.direction:void 0,label:c.jsxs(c.Fragment,{children:[c.jsx(uo,{}),c.jsx(T,{sx:{fontSize:"24px",color:((f=h.colors)==null?void 0:f.labelColor)??i.palette.text.primary},children:h.id.toUpperCase()})]}),getDisplayedValue:()=>{var y,j;return p(((j=(y=o.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:y.orientation)==null?void 0:j[_.XYZ_TO_VECTOR[h.id]])||0)},startJogging:y=>a({axis:h.id,motionType:"rotate",direction:y}),stopJogging:g},h.id)})]})}),c.jsx(Yt,{store:o}),c.jsx(H,{}),c.jsx(ie,{store:o}),t&&c.jsx(H,{}),t]})}),Co=M.observer(({store:o,children:t})=>{const e=B.useTheme(),i=I.useRef(0);async function n(s){const a=++i.current;try{if(await o.activate(),a!==i.current)return;await o.jogger.rotateJoints({joint:s.joint,direction:s.direction,velocityUnit:o.jointType===N.JointTypeEnum.PrismaticJoint?"mm/s":"rad/s",velocityValue:o.jointType===N.JointTypeEnum.PrismaticJoint?o.translationVelocityMmPerSec:o.rotationVelocityRadsPerSec})}catch(g){console.error("Jogging failed:",g)}}async function r(){i.current++,await o.jogger.stop(),await o.deactivate()}return c.jsxs(x,{"data-testid":"jogging-joint-tab","aria-label":"jogging-joint-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[c.jsx(oe,{store:o,useDegree:o.jointType===N.JointTypeEnum.RevoluteJoint}),c.jsx(H,{}),c.jsx(x,{justifyContent:"center",alignItems:"stretch",sx:{flexGrow:"1"},children:c.jsx(x,{"data-testid":"jogging-joint-value-controls-wrapper","aria-label":"jogging-joint-value-controls-wrapper",alignItems:"center",gap:"24px",children:o.jogger.motionStream.joints.map(s=>{var g,u,d;const a=(d=(u=(g=o.motionGroupDescription.operation_limits.auto_limits)==null?void 0:g.joints)==null?void 0:u[s.index])==null?void 0:d.position;return c.jsxs(x,{"data-testid":`jogging-joint-value-control-${s.index}`,"aria-label":`jogging-joint-value-control-${s.index}`,direction:"row",alignItems:"center",justifyContent:"center",spacing:1.5,width:"100%",children:[o.showJointsLegend&&c.jsx(T,{color:o.isLocked?e.palette.text.disabled:e.palette.text.secondary,children:`G${s.index+1}`}),c.jsx(qt,{disabled:o.isLocked,lowerLimit:a==null?void 0:a.lower_limit,upperLimit:a==null?void 0:a.upper_limit,useDegree:o.jointType===N.JointTypeEnum.RevoluteJoint,getValue:()=>{const p=o.jogger.motionStream.rapidlyChangingMotionState.joint_position[s.index];return p!==void 0?p:void 0},startJogging:p=>n({joint:s.index,direction:p}),stopJogging:r})]},`joint-${s.index}`)})})}),c.jsx(Yt,{store:o}),c.jsx(H,{}),c.jsx(ie,{store:o}),t&&c.jsx(H,{}),t]})}),To=tt.externalizeComponent(M.observer(o=>{const t=M.useLocalObservable(()=>({joggingStore:null,loadingError:null}));return I.useEffect(()=>{let e=!1,i;async function n(){m.runInAction(()=>{t.loadingError=null,t.joggingStore=null});try{let r=o.store;if(!r){const s=await it.open(o.nova,o.motionGroupId,{cellId:o.cellId});if(e){s.dispose();return}try{r=await K.loadFor(s)}catch(a){throw s.dispose(),a}if(i=r,e){r.dispose();return}}m.runInAction(()=>{t.joggingStore=r}),o.onSetup&&o.onSetup(r)}catch(r){if(e)return;m.runInAction(()=>{t.loadingError=r})}}return n(),()=>{e=!0,i==null||i.dispose()}},[o.store,o.nova,o.motionGroupId,o.cellId]),I.useEffect(()=>{const e=t.joggingStore;e&&(o.locked?e.lock("external"):e.unlock("external"))},[t.joggingStore,o.locked]),c.jsx(x,{"data-testid":"jogging-panel","aria-label":"jogging-panel",sx:{maxWidth:"460px",minWidth:"320px",position:"relative",...o.sx},children:t.joggingStore?c.jsx(wo,{store:t.joggingStore,children:o.children}):c.jsx(Wt,{message:"Loading jogging",error:t.loadingError})})})),wo=M.observer(({store:o,children:t})=>{const{t:e}=F.useTranslation();function i(){if(o.currentTab.id==="cartesian")return c.jsx(Eo,{store:o,children:t});if(o.currentTab.id==="joint")return c.jsx(Co,{store:o,children:t})}return c.jsxs(x,{flexGrow:1,sx:{overflow:"hidden"},children:[c.jsx(we,{"data-testid":"jogging-tabs","aria-label":"jogging-tabs",value:o.tabIndex,onChange:o.onTabChange,variant:"fullWidth",children:o.tabs.map(n=>{const r=n.label==="Cartesian"?e("Jogging.Cartesian.bt"):e("Jogging.Joints.bt"),s=n.label==="cartesian"?c.jsx(Ee,{fontSize:"small",sx:{mr:1}}):c.jsx(Ce,{fontSize:"small",sx:{mr:1}});return c.jsx(Te,{"data-testid":`jogging-tab-${n.id}`,"aria-label":`jogging-tab-${n.id}`,label:o.showTabIcons?c.jsxs(x,{direction:"row",alignItems:"center",children:[s,r]}):r,id:`jogging-tab-${n.id}`,"aria-controls":`jogging-tab-${n.id}`},n.id)})}),c.jsx(x,{flexGrow:1,position:"relative",sx:{overflowY:"auto",overflowX:"hidden"},children:i()}),o.blocked&&c.jsx(io,{store:o})]})});function Mo(){const o=window.location.href;return o.substring(0,o.indexOf("/",o.indexOf("//")+2))}function Oo({baseUrl:o=Mo(),...t}){return c.jsxs(Ge,{"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:[c.jsx(Ue,{id:"no-motion-group-modal-title",children:"No motion group found"}),c.jsxs(qe,{sx:{marginTop:"3rem",marginBottom:"1.5rem",textAlign:"center"},children:[c.jsx(T,{color:"#fff",children:"Found no devices to connect to."}),c.jsx(T,{color:"#fff",children:"Please ensure a motion group has been created."})]}),c.jsx(Be,{children:c.jsxs(x,{width:"100%",maxWidth:"300px",margin:"auto",marginBottom:"2rem",children:[c.jsx(dt,{href:`${o}/settings`,variant:"contained",sx:{borderRadius:"8px",width:"100%"},children:"Go to settings app"}),c.jsx(dt,{href:`${o}`,variant:"text",sx:{marginTop:"1rem",color:"#fff",textDecoration:"underline",fontSize:"0.75rem"},children:"Back to Homescreen"})]})})]})}const Rt=1e-4,ko={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class ct{constructor(t,e,i,n,r,s,a,g,u,d,p="cell"){this.controller=e,this.motionGroup=i,this.initialMotionState=n,this.motionStateSocket=r,this.isVirtual=s,this.tcps=a,this.description=g,this.initialControllerState=u,this.controllerStateSocket=d,this.cellId=p,this.connectedJoggingSocket=null,this.joggingVelocity=10,this.activationState="inactive",this.nova=w.createNovaClient(t),this.rapidlyChangingMotionState=n,this.controllerState=u,d.addEventListener("message",h=>{var f;const l=(f=_.tryParseJson(h.data))==null?void 0:f.result;l&&m.runInAction(()=>{this.controllerState=l})}),r.addEventListener("message",h=>{var f;const l=(f=_.tryParseJson(h.data))==null?void 0:f.result;if(!l)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${h.data}`);ft(this.rapidlyChangingMotionState.joint_position,l.joint_position,Rt)||m.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=l.joint_position}),yt(this.rapidlyChangingMotionState,l,Rt)||m.runInAction(()=>{this.rapidlyChangingMotionState.tcp_pose=l.tcp_pose}),l.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==l.tcp&&m.runInAction(()=>{this.rapidlyChangingMotionState.tcp=l.tcp}),this.rapidlyChangingMotionState.standstill!==l.standstill&&m.runInAction(()=>{this.rapidlyChangingMotionState.standstill=l.standstill})}),m.makeAutoObservable(this)}static async connectMultiple(t,e,i={}){const n=w.createNovaClient(t),r=i.cellId??w.cellIdOf(t);return Promise.all(e.map(s=>ct.connect(n,s,{...i,cellId:r})))}static async connect(t,e,i={}){var k,R;const n=w.createNovaClient(t),r=i.cellId??w.cellIdOf(t)??"cell",[s,a]=e.split("@"),g=await n.api.controller.getCurrentRobotControllerState(r,a),u=g==null?void 0:g.motion_groups.find(E=>E.motion_group===e);if(!g||!u)throw new Error(`Controller ${a} or motion group ${e} not found`);const d=n.openReconnectingWebsocket(`/cells/${r}/controllers/${a}/motion-groups/${e}/state-stream`),p=await d.firstMessage(),h=(k=_.tryParseJson(p.data))==null?void 0:k.result;if(!h)throw new Error(`Unable to parse initial motion state message ${p.data}`);console.log(`Connected motion state websocket to motion group ${u.motion_group}. Initial state:
|
|
1
|
+
"use strict";const c=require("react/jsx-runtime"),je=require("@mui/material/AppBar"),Dt=require("@mui/material/Backdrop"),G=require("@mui/material/Box"),be=require("@mui/material/Menu"),W=require("@mui/material/MenuItem"),xe=require("@mui/material/Toolbar"),T=require("@mui/material/Typography"),ve=require("@wandelbots/design-tokens"),_e=require("@wandelbots/icons/ExpandMoreFilled"),Ie=require("@wandelbots/mui"),M=require("mobx-react-lite"),I=require("react"),tt=require("./externalizeComponent-CkWiNBu0.cjs"),Ee=require("@mui/icons-material/OpenWith"),Ce=require("@mui/icons-material/Share"),x=require("@mui/material/Stack"),Te=require("@mui/material/Tab"),we=require("@mui/material/Tabs"),m=require("mobx"),F=require("react-i18next"),Lt=require("@mui/material/CircularProgress"),Me=require("@mui/material/utils"),$t=require("lodash-es"),Oe=require("./robotSafetyOf-CwfVV9__.cjs"),ke=require("@mui/material/Alert"),Re=require("@mui/material/AlertTitle"),dt=require("@mui/material/Button"),B=require("@mui/material/styles"),H=require("@mui/material/Divider"),It=require("@mui/material/ToggleButton"),_=require("@wandelbots/nova-js"),at=require("@mui/material/IconButton"),w=require("./useSmoothedMotionState-Con0E5Bx.cjs"),Y=require("./joggingColors-ZDc_2UCp.cjs"),Vt=require("lodash-es/isEqual.js"),Ae=require("@mui/material/InputAdornment"),Pe=require("@mui/material/FormControl"),Je=require("@mui/material/InputLabel"),De=require("@mui/material/Select"),Le=require("@mui/material/ToggleButtonGroup"),Nt=require("@mui/material/Slider"),$e=require("lodash-es/isNumber.js"),N=require("@wandelbots/nova-js/v2"),Ve=require("@mui/icons-material/ChevronLeft"),Ne=require("@mui/icons-material/ChevronRight"),Fe=require("lodash-es/throttle.js"),Ge=require("@mui/material/Dialog"),Be=require("@mui/material/DialogActions"),qe=require("@mui/material/DialogContent"),Ue=require("@mui/material/DialogTitle"),U=require("three"),Ft=require("./converters-BsXgcxCW.cjs"),Gt=require("axios"),Z=require("lodash-es/keyBy.js"),ze=require("lodash-es/uniqueId.js"),L=require("./Pose3-Ch4xVeXV.cjs"),Et=require("./robotActivationOf-DXC0E2DS.cjs"),z=require("./useEveryFrame-CHxg25f4.cjs");function Bt(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const b=Bt(I),Ct=Bt(U),We=tt.externalizeComponent(M.observer(o=>{const{appIcon:t,appName:e,apps:i=[],onAppSelect:n,disabled:r=!1,sx:s}=o,[a,g]=I.useState(null),u=!!a,d=l=>{g(l.currentTarget)},p=()=>{g(null)},h=l=>{p(),l.onClick?l.onClick():l.href&&(window.location.href=l.href),n==null||n(l)};return c.jsxs(c.Fragment,{children:[c.jsx(je,{position:"static",sx:{boxShadow:"none",backgroundImage:"none","& .MuiAppBar-root":{backgroundImage:"none",backgroundColor:"transparent"},...s},children:c.jsxs(xe,{sx:{minHeight:"62px !important"},children:[c.jsx(G,{sx:{mr:1,display:"flex",alignItems:"center"},children:t}),c.jsxs(G,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:[c.jsx(T,{component:"h1",variant:"subtitle1",children:e}),i.length>0&&c.jsx(Ie.RoundedIconButton,{icon:c.jsx(_e.ExpandMoreFilled,{size:20}),ariaLabel:"switch app","aria-controls":"app-menu","aria-haspopup":"true",onClick:d,disabled:r,sx:{ml:1}})]})]})}),c.jsx(Dt,{open:u,onClick:p,sx:{backdropFilter:"blur(4px)",backgroundColor:ve.ZeroGravityComponentsBackdropFill,zIndex:l=>l.zIndex.modal-1}}),c.jsx(be,{id:"app-menu",anchorEl:a,open:u,onClose:p,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{zIndex:l=>l.zIndex.modal,"& .MuiPaper-root":{minWidth:200,mt:1}},children:i.map(l=>c.jsxs(W,{onClick:()=>h(l),children:[c.jsx(G,{sx:{display:"flex",alignItems:"center"},children:l.icon}),c.jsx(T,{variant:"body1",sx:{ml:2},children:l.name})]},l.id))})]})})),He=({title:o,titleId:t,...e},i)=>b.createElement("svg",{width:21,height:21,viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):null,b.createElement("g",{id:"JogMinus"},b.createElement("path",{id:"Minus",d:"M0 13V8H21V13H0Z",fill:"white"}))),Ye=I.forwardRef(He),Ke=({title:o,titleId:t,...e},i)=>b.createElement("svg",{width:21,height:21,viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):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"})))),Qe=I.forwardRef(Ke),gt=tt.externalizeComponent(M.observer(({colors:o,label:t,getDisplayedValue:e,startJogging:i,stopJogging:n,disabled:r,activeJoggingDirection:s,...a})=>{var O,k,R,E,A,V,q;w.useAnimationFrame(()=>{const D=e(),$=h.current;$&&($.textContent=D)});const g=B.useTheme(),[u,d]=I.useState(null);I.useEffect(()=>{r&&C()},[r]);const p=s||u,h=I.useRef(null);o||(o={color:"#fff",backgroundColor:"#000",borderColor:"#000",buttonBackgroundColor:{disabled:"#000",default:"#000",hovered:"#000",pressed:"#000"},labelColor:"#000"});const l=p?(O=o.buttonBackgroundColor)==null?void 0:O.pressed:o.borderColor,f={width:"55px",color:o.color,path:{fill:o.color},alignContent:"center",fontSize:"37px",svg:{pointerEvents:"none"}},y={...f,backgroundColor:(k=o.buttonBackgroundColor)==null?void 0:k.default,":hover":{backgroundColor:(R=o.buttonBackgroundColor)==null?void 0:R.hovered},":active":{backgroundColor:(E=o.buttonBackgroundColor)==null?void 0:E.pressed,color:o.backgroundColor,path:{fill:o.backgroundColor}},":disabled":{backgroundColor:(A=o.buttonBackgroundColor)==null?void 0:A.disabled,"svg path":{fill:g.palette.action.disabled}}},j={...f,backgroundColor:(V=o.buttonBackgroundColor)==null?void 0:V.pressed,color:o.backgroundColor,path:{fill:o.backgroundColor},":disabled":{backgroundColor:(q=o.buttonBackgroundColor)==null?void 0:q.pressed,"svg path":{fill:g.palette.action.disabled}}};function v(D,$){r||D.button===0&&(d($),i($))}function C(){d(null),n()}return c.jsxs(x,{height:"64px",direction:"row",justifyContent:"center",...a,children:[c.jsx(at,{disabled:r,disableRipple:!0,onPointerDown:D=>v(D,"-"),onPointerUp:C,onPointerOut:C,size:"large",sx:{...p==="-"?j:y,borderRadius:"16px 0px 0px 16px",borderLeft:`2px solid ${l??"#fff"}`,borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:c.jsx(Ye,{})}),c.jsxs(x,{spacing:"6px",sx:{width:"150px",backgroundColor:o.backgroundColor,alignItems:"center",justifyContent:"center",opacity:"0.9",borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:[c.jsx(x,{height:"22px",direction:"row",alignItems:"center",justifyItems:"center",spacing:1,sx:{userSelect:"none",color:o.color,".MuiTypography-root":{fontWeight:700,...r?{color:g.palette.action.disabled}:{}},...r?{"svg path":{fill:g.palette.action.disabled}}:{}},children:t}),c.jsx(T,{height:"22px",sx:{fontSize:"15px",color:r?g.palette.action.disabled:o.color,fontWeight:700,fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center"},ref:h,children:e()})]}),c.jsx(at,{disableRipple:!0,disabled:r,onPointerDown:D=>v(D,"+"),onPointerUp:C,onPointerOut:C,size:"large",sx:{...p==="+"?j:y,borderRadius:"0px 16px 16px 0px",borderRight:`2px solid ${l??"#fff"}`,borderBottom:`2px solid ${l??"#fff"}`,borderTop:`2px solid ${l??"#fff"}`},children:c.jsx(Qe,{})})]})})),qt=tt.externalizeComponent(M.observer(({startJogging:o,stopJogging:t,lowerLimit:e,upperLimit:i,useDegree:n,getValue:r,disabled:s,...a})=>{var E,A,V,q,D,$,nt;const{t:g}=F.useTranslation(),[u,d]=I.useState(),p=B.useTheme(),h={background:(E=p.palette.backgroundPaperElevation)==null?void 0:E[4],color:(A=p.palette.backgroundPaperElevation)==null?void 0:A[11]},l=M.useLocalObservable(()=>({activeJoggingDir:null,startJogging(S){this.activeJoggingDir=S,o(S)},stopJogging(){this.activeJoggingDir=null,t()}})),f=Fe(()=>{const S=n?y(r()):r();(S===void 0||u===void 0||Math.abs(u-S)>1e-9)&&d(S)},50);w.useAnimationFrame(f);function y(S){if(S!==void 0)return _.radiansToDegrees(S)}function j(S){S.button===0&&l.startJogging("-")}function v(S){S.button===0&&l.startJogging("+")}function C(S){l.stopJogging()}function O(S){l.stopJogging()}function k(S,P=1){if(S===void 0||Number.isNaN(S))return"";const J=g("General.degree.variable",{amount:S.toFixed(P)});return S>0&&P===0?`+${J}`:J}function R(S,P=1){if(S===void 0||Number.isNaN(S))return"";const J=g("General.mm.variable",{amount:S.toFixed(P)});return S>0&&P===0?`+${J}`:J}return c.jsxs(x,{height:"64px",width:"100%",maxWidth:"260px",direction:"row",...a,sx:{"& .MuiIconButton-root":{width:"52px",color:p.palette.text.primary,alignContent:"center",backgroundColor:(V=p.palette.backgroundPaperElevation)==null?void 0:V[11],"& svg":{width:"42px",height:"42px"},"&.Mui-disabled":{backgroundColor:(q=p.palette.backgroundPaperElevation)==null?void 0:q[11],color:p.palette.action.disabled,opacity:1},"&:hover":{backgroundColor:(D=p.palette.backgroundPaperElevation)==null?void 0:D[9]},"&:active":{...h}}},children:[c.jsx(at,{onPointerDown:j,onPointerUp:C,onPointerOut:O,disabled:s,disableRipple:!0,sx:{borderRadius:"16px 0px 0px 16px",...l.activeJoggingDir==="-"?h:{}},children:c.jsx(Ve,{sx:{pointerEvents:"none",color:Y.jointArrowColor}})}),c.jsxs(x,{flexGrow:1,alignItems:"center",justifyContent:"center",sx:{borderStyle:"solid",borderLeftWidth:0,borderRightWidth:0,border:"none",backgroundColor:($=p.palette.backgroundPaperElevation)==null?void 0:$[11],paddingLeft:"20px",paddingRight:"20px",zIndex:1},children:[c.jsx(T,{sx:{fontSize:"15px",fontWeight:700,position:"relative",top:"5px",fontVariantNumeric:"tabular-nums",minWidth:"80px",textAlign:"center",color:s?p.palette.action.disabled:p.palette.text.primary},children:n?k(u):R(u)}),c.jsx(Nt,{disabled:!0,"aria-label":"Joint position",min:n?y(e):e,max:n?y(i):i,value:u||0,track:!1,sx:{"& .MuiSlider-mark":{display:"none"},"& .MuiSlider-thumb":{width:"5px",height:"12px",borderRadius:"2px",color:s?p.palette.action.disabled:p.palette.text.primary},"& .MuiSlider-markLabel":{top:"20px",fontSize:"12px",color:s?p.palette.action.disabled:p.palette.text.secondary},"& .MuiSlider-rail":{backgroundColor:(nt=p.palette.backgroundPaperElevation)==null?void 0:nt[5],opacity:1}},marks:e!==void 0&&i!==void 0&&[{value:n?y(e):e,label:n?k(y(e),0):R(e)},{value:n?y(i):i,label:n?k(y(i),0):R(i)}]})]}),c.jsx(at,{onPointerDown:v,onPointerUp:C,onPointerOut:O,disabled:s,disableRipple:!0,sx:{borderRadius:"0px 16px 16px 0px",...l.activeJoggingDir==="+"?h:{}},children:c.jsx(Ne,{sx:{pointerEvents:"none",color:Y.jointArrowColor}})})]})}));function Ze({currentTcpPose:o,axis:t,direction:e,motion:i,useToolCoordinateSystem:n,coordinateSystemRotation:r}){const s=e==="-"?-1:1;if(i.type==="translate"){if(!o.position)throw new Error("Current pose has no position, cannot perform translation");const p=i.distanceMm*s,h=new U.Vector3;if(h[t]=p,n){if(!o.orientation)throw new Error("Current pose has no orientation, cannot translate relative to tool");h.applyQuaternion(L.parseRotationToQuaternion(o.orientation,"ROTATION_VECTOR"))}else r&&h.applyQuaternion(r);const l=[...o.position];return l[0]=(l[0]??0)+h.x,l[1]=(l[1]??0)+h.y,l[2]=(l[2]??0)+h.z,{position:l,orientation:o.orientation}}if(!o.orientation)throw new Error("Current pose has no orientation, cannot perform rotation");const a=L.parseRotationToQuaternion(o.orientation,"ROTATION_VECTOR"),g=new U.Vector3;g[t]=1,!n&&r&&g.applyQuaternion(r);const u=new U.Quaternion().setFromAxisAngle(g,i.distanceRads*s),d=n?a.multiply(u):u.multiply(a);return{position:o.position,orientation:[...L.quaternionToRotationVector(d)]}}function et(o,t,e){return t.length!==o.length?!1:Ut(o,t,e)}function ft(o,t,e){return t.length!==o.length?!0:Ut(o,t,e)}function Ut(o,t,e){for(let i=0;i<t.length;i++)if(Math.abs((t[i]??0)-(o[i]??0))>e)return!1;return!0}function zt(o,t,e){if(o===void 0&&t||o&&t===void 0||(o==null?void 0:o.orientation)===void 0||(t==null?void 0:t.orientation)===void 0||(o==null?void 0:o.position)===void 0||(t==null?void 0:t.position)===void 0)return!1;if(o===void 0||t===void 0)return!0;let i=0;return i+=Math.abs(o.orientation[0]-t.orientation[0]),i+=Math.abs(o.orientation[1]-t.orientation[1]),i+=Math.abs(o.orientation[2]-t.orientation[2]),i+=Math.abs(o.position[0]-t.position[0]),i+=Math.abs(o.position[1]-t.position[1]),i+=Math.abs(o.position[2]-t.position[2]),i<=e}function yt(o,t,e){return o.coordinate_system===t.coordinate_system&&o.tcp===t.tcp&&zt(o.tcp_pose,t.tcp_pose,e)}function St(o,t){const e=new U.Vector3(t[0],t[1],t[2]),i=new U.Vector3(o[0],o[1],o[2]),n=e.length(),r=e.normalize();let s=i.length(),a=i.normalize();a.dot(r)<0&&(s=-s,a=a.multiplyScalar(-1));let g=s-n;return g-=2*Math.PI*Math.floor((g+Math.PI)/(2*Math.PI)),s=n+g,[...a.multiplyScalar(s)]}const Xe=2e-4;function jt(o){const{joint_position:t,tcp_pose:e,tcp:i,coordinate_system:n}=o;return{joint_position:t,tcp_pose:e,tcp:i,coordinate_system:n}}function bt(o,t){return o.tcp===t.tcp&&o.coordinate_system===t.coordinate_system&&o.tcp_pose===void 0==(t.tcp_pose===void 0)&&et(o.joint_position,t.joint_position,Xe)}const Tt=1e-4;class ot{constructor(t,e,i,n,r,s,a="cell",g={}){this.controller=e,this.motionGroup=i,this.description=n,this.initialMotionState=r,this.motionStateSocket=s,this.cellId=a,this.nova=w.createNovaClient(t),this.logger=g.logger??console,this.rapidlyChangingMotionState=r,s.addEventListener("message",u=>{var l;const d=(l=_.tryParseJson(u.data))==null?void 0:l.result;if(!d)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${u.data}`);yt(this.rapidlyChangingMotionState,d,Tt)||m.runInAction(()=>{var f,y,j;this.rapidlyChangingMotionState.tcp_pose==null?this.rapidlyChangingMotionState.tcp_pose=d.tcp_pose:(f=d.tcp_pose)!=null&&f.orientation&&((y=d.tcp_pose)!=null&&y.position)&&((j=this.rapidlyChangingMotionState.tcp_pose)!=null&&j.orientation)?this.rapidlyChangingMotionState.tcp_pose={position:d.tcp_pose.position,orientation:St(d.tcp_pose.orientation,this.rapidlyChangingMotionState.tcp_pose.orientation)}:this.logger.debug("Received incomplete tcp_pose, ignoring",{tcpPose:d.tcp_pose})}),ft(this.rapidlyChangingMotionState.joint_position,d.joint_position,Tt)||m.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=d.joint_position}),d.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==d.tcp&&m.runInAction(()=>{this.rapidlyChangingMotionState.tcp=d.tcp}),this.rapidlyChangingMotionState.standstill!==d.standstill&&m.runInAction(()=>{this.rapidlyChangingMotionState.standstill=d.standstill});const p=this.rapidlyChangingMotionState.joint_limit_reached.limit_reached,h=d.joint_limit_reached.limit_reached;p.some((f,y)=>f!==h[y])&&m.runInAction(()=>{this.rapidlyChangingMotionState.joint_limit_reached=d.joint_limit_reached}),this.rapidlyChangingMotionState.execute!==d.execute&&m.runInAction(()=>{this.rapidlyChangingMotionState.execute=d.execute})}),m.makeAutoObservable(this,{logger:!1,readoutState:m.computed({equals:bt,keepAlive:!0})})}static async open(t,e,i={}){var y;const n=w.createNovaClient(t),r=i.cellId??w.cellIdOf(t)??"cell",[s,a]=e.split("@"),g=await n.api.controller.getCurrentRobotControllerState(r,a),u=g==null?void 0:g.motion_groups.find(j=>j.motion_group===e);if(!g||!u)throw new Error(`Controller ${a} or motion group ${e} not found`);const d=n.openReconnectingWebsocket(`/cells/${r}/controllers/${a}/motion-groups/${e}/state-stream`),p=await d.firstMessage(),h=(y=_.tryParseJson(p.data))==null?void 0:y.result;if(!h)throw new Error(`Unable to parse initial motion state message ${p.data}`);const l=i.logger??console;l.info("Connected motion state websocket to motion group",{motionGroup:u.motion_group,initialMotionState:h});const f=await n.api.motionGroup.getMotionGroupDescription(r,a,u.motion_group);return new ot(n,g,u,f,h,d,r,{logger:l})}get readoutState(){return jt(this.rapidlyChangingMotionState)}get motionGroupId(){return this.motionGroup.motion_group}get controllerId(){return this.controller.controller}get joints(){return this.initialMotionState.joint_position.map((t,e)=>({index:e}))}dispose(){this.motionStateSocket.close()}}const wt="Movement request rejected. Another client is currently executing a 'Jogging' motion!",to=500,eo=5e3;function oo(o){var e;return(((e=o.times)==null?void 0:e[o.times.length-1])??0)*2e3+eo}class it{constructor(t,e={}){this.motionStream=t,this.options=e,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=(e==null?void 0:e.tcp)||t.motionGroup.tcp||this.getDefaultTcp(t),this.coordinateSystem=e==null?void 0:e.coordinateSystem,this.orientation=(e==null?void 0:e.orientation)||this.DEFAULT_ORIENTATION,this.timeout=(e==null?void 0:e.timeout)||this.DEFAULT_INIT_TIMEOUT,this.mode=(e==null?void 0:e.mode)||this.DEFAULT_MODE,this.onError=e==null?void 0:e.onError,this.logger=(e==null?void 0:e.logger)??console}static async open(t,e,i={}){const n=await ot.open(t,e,{cellId:i.cellId,logger:i.logger}),r=new it(n,i);r.ownsMotionStream=!0;try{await r.setJoggingMode(r.mode)}catch(s){throw r.dispose(),s}return r}getDefaultTcp(t){var i,n;const e=(n=(i=t.description.dh_parameters)==null?void 0:i[0])==null?void 0:n.type;return t.joints.length<6&&(e===N.JointTypeEnum.RevoluteJoint||e===N.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 e,i;(e=this.endJoggingInit)==null||e.call(this),(i=this.endIncrementalMotion)==null||i.call(this);const t=[this.joggingSocket,this.trajectorySocket].filter(n=>n!==null);return t.forEach(n=>{n.dispose()}),this.joggingSocket=null,this.trajectorySocket=null,Promise.all(t.map(n=>n.closed()))}async setJoggingMode(t,e=!0){if(!(this.mode===t&&e)&&(this.closeJoggingSockets(),this.mode=t,this.mode==="jogging"))return this.initializeJoggingWebsocket()}async initializeJoggingWebsocket(){return new Promise((t,e)=>{const i=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`);this.joggingSocket=i;let n=!1;const r=setTimeout(()=>{s(new Error(`Jogging initialization timeout after ${this.timeout} ms`))},this.timeout),s=u=>{n||(n=!0,clearTimeout(r),i.removeEventListener("close",g),this.endJoggingInit===a&&(this.endJoggingInit=void 0),u?e(u):t())},a=()=>s(),g=()=>{i.disposed&&s()};this.endJoggingInit=a,i.addEventListener("close",g),i.addEventListener("message",u=>{var p,h,l;const d=_.tryParseJson(u.data);if(((p=d==null?void 0:d.result)==null?void 0:p.kind)==="INITIALIZE_RECEIVED"){s();return}if(((h=d==null?void 0:d.result)==null?void 0:h.kind)==="MOTION_ERROR")if(this.onBlocked&&((l=d==null?void 0:d.result)!=null&&l.message.includes(wt))){s(),i.dispose(),this.onBlocked();return}else this.onError?(s(),this.onError(u.data)):s(new Error(u.data))}),i.sendJson({message_type:"InitializeJoggingRequest",motion_group:this.motionGroupId,...this.tcp?{tcp:this.tcp}:{}})})}async rotateJoints({joint:t,direction:e,velocityValue:i,velocityUnit:n}){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]=e==="-"?-i:i,this.joggingSocket.sendJson({message_type:"JointVelocityRequest",velocity:r})}async translateTCP({axis:t,direction:e,velocityMmPerSec:i}){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,e==="-"?-i:i),rotation:[0,0,0],use_tool_coordinate_system:this.orientation==="tool"})}async rotateTCP({axis:t,direction:e,velocityRadsPerSec:i}){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,e==="-"?-i:i),use_tool_coordinate_system:this.orientation==="tool"})}get coordinateSystemRotation(){if(!(this.orientation==="tool"||!this.coordinateSystem))return L.Pose3.fromCoordinateSystem(this.coordinateSystem).quaternion}velocityAlongAxis(t,e){const i=new U.Vector3;i[t]=e;const n=this.coordinateSystemRotation;return n&&i.applyQuaternion(n),[i.x,i.y,i.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 e=await this.planIncrementalCartesianMotion(t);e&&await this.executeTrajectory(e)}finally{this.incrementalMotionInFlight=!1}}}async planIncrementalCartesianMotion({currentTcpPose:t,currentJoints:e,velocityInRelevantUnits:i,axis:n,direction:r,motion:s}){var y,j,v;const a=[],g=Ze({currentTcpPose:t,axis:n,direction:r,motion:s,useToolCoordinateSystem:this.orientation==="tool",coordinateSystemRotation:this.coordinateSystemRotation});a.push({limits_override:s.type==="translate"?{tcp_velocity_limit:i}:{tcp_orientation_velocity_limit:i},path:{path_definition_name:"PathLine",target_pose:{position:g.position,orientation:g.orientation}}});const u=this.motionStream.description;if(u.cycle_time===void 0){this.logger.warn("Current motion group has no cycle time, cannot plan jogging motion");return}const d=this.motionStream.rapidlyChangingMotionState.tcp,p=d?(j=(y=u.tcps)==null?void 0:y[d])==null?void 0:j.pose:void 0,h={motion_group_model:((v=this.options)==null?void 0:v.motionGroupModel)??u.motion_group_model,cycle_time:u.cycle_time,mounting:u.mounting,tcp_offset:p,global:u.operation_limits.auto_limits},l=await this.nova.api.trajectoryPlanning.planTrajectory(this.cellId,{motion_group_setup:h,start_joint_position:e,motion_commands:a}),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 e=this.nova.openReconnectingWebsocket(`/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`);this.trajectorySocket=e;const i=new AbortController;let n,r;try{await new Promise((s,a)=>{let g=!1;const u=()=>{g||(g=!0,s())},d=h=>{if(!g){if(g=!0,this.onError){this.onError(h),s();return}a(h instanceof Error?h:new Error(`Failed to execute trajectory: ${JSON.stringify(h)}`))}};r=u,this.endIncrementalMotion=u;const p=oo(t);n=setTimeout(()=>{d(new Error(`Jogging motion did not complete within ${p}ms`))},p),e.addEventListener("message",h=>{var f,y;const l=(f=_.tryParseJson(h.data))==null?void 0:f.result;if(!(l!=null&&l.kind)){d(new Error(`Failed to execute trajectory: Received invalid message ${h.data}`));return}if(this.onBlocked&&((y=l.message)!=null&&y.includes(wt))){this.onBlocked(),u();return}if(l.kind==="INITIALIZE_RECEIVED"){if(l.add_trajectory_error||l.message){d(l);return}e.sendJson({message_type:"StartMovementRequest",direction:"DIRECTION_FORWARD"})}else if(l.kind==="START_RECEIVED"){if(l.message){d(l);return}this.waitForMotionToFinish(i.signal).then(u,d)}else l.kind==="PAUSE_RECEIVED"||(l.kind==="MOTION_ERROR"&&l.message?d(l):d(new Error(`Failed to execute trajectory, cannot handle message type "${l.kind}"`)))}),e.sendJson({message_type:"InitializeMovementRequest",trajectory:{message_type:"TrajectoryData",motion_group:this.motionGroupId,data:t,tcp:this.tcp}})})}finally{clearTimeout(n),i.abort(),this.endIncrementalMotion===r&&(this.endIncrementalMotion=void 0),e.dispose(),this.trajectorySocket===e&&(this.trajectorySocket=null)}}async waitForMotionToFinish(t){const e=()=>this.motionStream.rapidlyChangingMotionState.standstill;await m.when(()=>!e(),{timeout:to,signal:t}).catch(()=>{}),await m.when(e,{signal:t})}}const Wt=o=>{const t=o.softTimeout||3e3,[e,i]=I.useState(!1);return I.useEffect(()=>{const n=setTimeout(()=>{i(!0)},t);return()=>clearTimeout(n)}),c.jsx(x,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",sx:{color:"text.primary"},children:o.error?c.jsx(Ht,{loadingMessage:o.message,error:o.error}):c.jsxs(c.Fragment,{children:[c.jsx(Lt,{sx:{mb:3}}),!!o.message&&c.jsx(T,{variant:"body1",children:o.message}),c.jsx(T,{variant:"body2",sx:{visibility:e?"visible":"hidden",mt:2,color:"text.secondary"},children:"This is taking longer than expected..."})]})})},Ht=o=>{const t=Oe.makeErrorMessage(o.error),e=o.error instanceof Error?o.error.stack:null;return c.jsxs(x,{sx:{maxHeight:"100%",maxWidth:"min(100%, 800px)",p:2,overflow:"auto",color:"error.main"},children:[c.jsx(T,{variant:"body1",children:(o.loadingMessage?`Error while ${$t.lowerFirst(Me.capitalize(o.loadingMessage))} - `:"")+t}),e&&c.jsx(G,{component:"pre",sx:{typography:"body2",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",mt:2,pb:6},children:e})]})},io=M.observer(({store:o})=>{const{t}=F.useTranslation();return c.jsx(Dt,{"data-testid":"jogging-blocked","aria-label":"jogging-blocked",open:!0,sx:{position:"absolute",zIndex:e=>e.zIndex.drawer+1,color:"#fff",background:"rgba(15, 15, 15, 0.88)",justifyContent:"flex-start",alignItems:"flex-start"},children:c.jsxs(x,{sx:{m:2,width:"100%"},children:[c.jsxs(ke,{severity:"error",sx:{mb:2},children:[c.jsx(Re,{children:t("Jogging.Blocked.ti")}),t("Jogging.Blocked.lb")]}),c.jsx(dt,{variant:"contained",color:"secondary",onClick:()=>o.unblock(),children:t("Jogging.Blocked.Reenable.bt")})]})})}),no=({title:o,titleId:t,...e},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):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"})),ro=I.forwardRef(no),so=({title:o,titleId:t,...e},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:19,height:10,fill:"none",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):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"})),ao=I.forwardRef(so),co=({title:o,titleId:t,...e},i)=>b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:10,height:19,fill:"none",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):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"})),lo=I.forwardRef(co),go=({title:o,titleId:t,...e},i)=>b.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:i,"aria-labelledby":t,...e},o?b.createElement("title",{id:t},o):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"})),uo=I.forwardRef(go),Yt=M.observer(({store:o})=>{const{t}=F.useTranslation(),[e,i]=I.useState(o.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached),n=I.useRef(e);w.useAnimationFrame(()=>{const s=o.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;Vt(n.current,s)||(n.current=s,i(s))});const r=[];for(const[s,a]of e.entries())a&&r.push(s);return c.jsx(G,{sx:{display:"flex",flexDirection:"row",justifyContent:"center"},children:c.jsx(T,{"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(s=>s+1).join(", ")})})})}),ho=B.styled(Pe)(({theme:o})=>({"&.MuiFormControl-root":{".MuiSelect-select":{paddingTop:"20px",paddingLeft:"12px"},label:{pointerEvents:"none",fontSize:"16px"},".MuiInputLabel-root":{"&.Mui-focused":{color:o.palette.text.primary}}}}));function rt({labelValue:o,...t}){return c.jsxs(ho,{fullWidth:!0,variant:"filled",children:[c.jsx(Je,{id:t.labelId,children:o}),c.jsx(De,{...t})]})}function Mt(o){const t=o.lastIndexOf("On");return t>0?o.slice(0,t):o}function Kt(o,t){const e=o[t];if(e)return e;const i=Mt(t),n=o[i];if(n)return n;const r=Object.keys(o).filter(a=>Mt(a)===i);if(r.length!==1)return;const s=r[0];return s?o[s]:void 0}const po={coordinate_system:"world",name:"world",reference_coordinate_system:"",position:[0,0,0],orientation:[0,0,0],orientation_type:"ROTATION_VECTOR"};function Qt(o){const t=Z(o.map(n=>({...n,coordinate_system:n.coordinate_system||"world"})),"coordinate_system");t.world??(t.world=po);const e={},i=n=>{const r=e[n];if(r)return r;const s=Kt(t,n);if(!s)throw new Error(`Unknown coordinate system ${n}. Known coordinate systems are: ${Object.keys(t).join(", ")}`);const a=s.reference_coordinate_system||"world";let g;if(a==="world")g=s;else{const u=i(a),d=L.Pose3.fromCoordinateSystem(u).multiply(L.Pose3.fromCoordinateSystem(s));g={...s,position:[d.position.x,d.position.y,d.position.z],orientation:[d.orientation.x,d.orientation.y,d.orientation.z],orientation_type:"ROTATION_VECTOR",reference_coordinate_system:u.reference_coordinate_system}}return e[n]=g,g};return Object.fromEntries(Object.keys(t).map(n=>[n,i(n)]))}function ut(o,t){const e=Kt(o,t||"world");if(!e)throw new Error(`Unknown coordinate system ${t}. Known coordinate systems are: ${Object.keys(o).join(", ")}`);return e}function Zt(o,t){return ut(Qt(t),o)}function X(o,t,e){if(o.coordinateSystemId===t)return o;const i=Qt(e),n=ut(i,o.coordinateSystemId||"world"),r=ut(i,t);if(n.coordinate_system===r.coordinate_system)return{...o,coordinateSystemId:r.coordinate_system};const s=L.Pose3.fromCoordinateSystem(r).inverse().multiply(L.Pose3.fromCoordinateSystem(n).multiply(L.Pose3.fromPose(o.pose)));return{...o,pose:{position:[s.position.x,s.position.y,s.position.z],orientation:[s.orientation.x,s.orientation.y,s.orientation.z]},coordinateSystemId:r.coordinate_system}}function Xt(o,t,e){const i=L.Pose3.fromPose(o).multiply(L.Pose3.fromRobotTcp(t).inverse()).multiply(L.Pose3.fromRobotTcp(e)),{position:n,orientation:r}=i;return{position:[n.x,n.y,n.z],orientation:[r.x,r.y,r.z]}}function Ot(o,t){const e=o==null?void 0:o[t];if(!e)throw new Error(`Unknown TCP ${t}. Known TCPs are: ${Object.keys(o??{}).join(", ")}`);return{position:e.pose.position??[0,0,0],orientation:e.pose.orientation??[0,0,0],orientation_type:"ROTATION_VECTOR"}}function ht({inputPose:o,selectedTcpId:t,selectedCoordinateSystemId:e,tcpOffsetsById:i,coordinateSystems:n}){const r=t&&t!==o.tcpId?{...o,pose:Xt(o.pose,Ot(i,o.tcpId),Ot(i,t)),tcpId:t}:o;return e?X(r,e,n):r}function te(o){var t,e,i,n,r;if(typeof o=="string"){const s=_.tryParseJson(o);return s?te(s):o}if(o&&typeof o=="object"){const s=o;return((t=s.error_feedback)==null?void 0:t.error_feedback_name)||((e=s.add_trajectory_error)==null?void 0:e.message)||s.message||((n=(i=s.result)==null?void 0:i.add_trajectory_error)==null?void 0:n.message)||((r=s.result)==null?void 0:r.message)||"Jogging motion failed"}return"Jogging motion failed"}const mo=[{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 fo(o){var t;return((t=mo.find(({pattern:e})=>e.test(o)))==null?void 0:t.translationKey)??null}const yo=5,So=250;function jo(o){var i,n,r,s;const t=[(n=(i=o==null?void 0:o.manual_t1_limits)==null?void 0:i.tcp)==null?void 0:n.velocity,(s=(r=o==null?void 0:o.manual_limits)==null?void 0:r.tcp)==null?void 0:s.velocity].filter(a=>typeof a=="number"&&Number.isFinite(a)&&a>0);return Math.min(So,...t)/10}const pt=[{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}],bo=[{id:"continuous"},...pt],xo=["coordsys","tool"],kt="joggingToolStore",vo=()=>typeof localStorage>"u"?void 0:localStorage;class K{constructor(t,e,i,n,r,s={}){var g,u,d;this.jogger=t,this.coordSystems=e,this.motionGroupDescription=i,this.tcps=n,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=yo,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=N.JointTypeEnum.RevoluteJoint,this.storage=s.storage??vo();for(const p of e)if(p.coordinate_system===""){p.coordinate_system="world";break}this.selectedCoordSystemId=((g=e[0])==null?void 0:g.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=jo(i==null?void 0:i.operation_limits),this.jointType=((d=(u=i==null?void 0:i.dh_parameters)==null?void 0:u[0])==null?void 0:d.type)??N.JointTypeEnum.RevoluteJoint,m.makeAutoObservable(this,{storage:!1},{autoBind:!0}),this.jogger.onBlocked=()=>{this.block()};const a=this.jogger.onError;this.jogger.onError=p=>{this.setLastJogError(te(p)),a==null||a(p)},this.loadFromLocalStorage(),this.disposers.push(m.autorun(()=>this.saveToLocalStorage())),this.disposers.push(m.autorun(()=>{const p=this.jogger.motionStream.rapidlyChangingMotionState.tcp;p&&p!==this.selectedTcpId&&m.runInAction(()=>{this.selectedTcpId=p,this.tcpChangeInProgress=!1})}))}static async loadFor(t,e={}){const{nova:i,cellId:n}=t,[r,s]=await Promise.all([i.api.controller.listCoordinateSystems(n,t.motionStream.controllerId,"ROTATION_VECTOR"),i.api.motionGroup.getMotionGroupDescription(n,t.motionStream.controllerId,t.motionGroupId)]),a=await i.api.motionGroupModels.getMotionGroupKinematicModel(s.motion_group_model);return K.create(t,{coordinateSystems:r||[],description:s,kinematicModel:a},e)}static create(t,e,i={}){const{coordinateSystems:n,description:r,kinematicModel:s}=e,a=Object.entries(r.tcps||{}).map(([g,u])=>({id:g,readable_name:u.name,position:u.pose.position,orientation:u.pose.orientation}));return new K(t,n,r,a,s.inverse_solver,i)}dispose(){for(const t of this.disposers)t();this.jogger.dispose()}get coordSystemCountByName(){return $t.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 i;const t=(i=this.storage)==null?void 0:i.getItem(kt),e=t?_.tryParseJson(t):void 0;e&&(this.tabsById[e.selectedTabId]&&(this.selectedTabId=e.selectedTabId),this.coordSystemsById[e.selectedCoordSystemId]&&(this.selectedCoordSystemId=e.selectedCoordSystemId),this.coordSystemsById[e.jogCoordSystemId]&&(this.jogCoordSystemId=e.jogCoordSystemId),this.incrementOptionsById[e.selectedIncrementId]&&(this.selectedIncrementId=e.selectedIncrementId),["translate","rotate"].includes(e.selectedCartesianMotionType)&&(this.selectedCartesianMotionType=e.selectedCartesianMotionType),["coordsys","tool"].includes(e.selectedOrientation)&&(this.selectedOrientation=e.selectedOrientation))}saveToLocalStorage(){var t;(t=this.storage)==null||t.setItem(kt,JSON.stringify(this.localStorageSave))}get isLocked(){return this.locks.size>0}get lastJogErrorTranslationKey(){return this.lastJogError?fo(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 bo}get discreteIncrementOptions(){return pt}get incrementOptionsById(){return Z(this.incrementOptions,t=>t.id)}get tabsById(){return Z(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 Z(this.coordSystems,t=>t.coordinate_system)}get activeCoordSystemId(){return this.selectedOrientation==="tool"?"tool":this.selectedCoordSystemId}get jogCoordSystem(){return Zt(this.jogCoordSystemId,this.coordSystems)}get tcpPoseInSelectedCoordSystem(){const{tcp_pose:t,coordinate_system:e}=this.jogger.motionStream.readoutState;return!(t!=null&&t.position)||!t.orientation?t:X({pose:{position:t.position,orientation:t.orientation},coordinateSystemId:e||"world"},this.selectedCoordSystemId,this.coordSystems).pose}get tcpsById(){return Z(this.tcps,t=>t.id)}tcpPoseIn(t,e){const{tcp_pose:i,tcp:n,coordinate_system:r}=this.jogger.motionStream.readoutState,s=this.tcpsById[n||this.selectedTcpId],a=this.tcpsById[t];if(!(!(i!=null&&i.position)||!i.orientation)&&!(!s||!a))try{return X({pose:Xt(i,s,a),coordinateSystemId:r||"world"},e,this.coordSystems).pose}catch{return}}get activeDiscreteIncrement(){return pt.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,e){const i=this.tabs[e]||this.tabs[0];this.selectedTabId=i.id}setSelectedCoordSystemId(t){this.selectedCoordSystemId=t}setSelectedTcpId(t){this.requestTcpChange(t).catch(e=>{console.error("Failed to change TCP:",e)})}async requestTcpChange(t){if(t===this.selectedTcpId)return;this.tcpChangeInProgress=!0;const e=this.jogger.tcp,i=this.jogger.mode!=="jogging";try{this.jogger.tcp=t,i?await this.jogger.setJoggingMode("jogging"):await this.jogger.setJoggingMode("jogging",!1);let n=await this.waitForTcpConfirmation(t,1e3);i&&await this.jogger.setJoggingMode("off"),n||(n=await this.waitForTcpConfirmation(t,2e3)),m.runInAction(()=>{n?this.selectedTcpId=t:(this.jogger.tcp=e,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??"")})}catch(n){throw i&&await this.jogger.setJoggingMode("off").catch(()=>{}),m.runInAction(()=>{this.jogger.tcp=e,this.selectedTcpId=this.jogger.motionStream.rapidlyChangingMotionState.tcp??""}),n}finally{m.runInAction(()=>{this.tcpChangeInProgress=!1})}}waitForTcpConfirmation(t,e){return new Promise(i=>{const n=setTimeout(()=>{r(),i(!1)},e),r=m.when(()=>this.jogger.motionStream.rapidlyChangingMotionState.tcp===t,()=>{clearTimeout(n),i(!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,e){!Number.isFinite(t)||t<this.minVelocityInDisplayUnits(e)||t>this.maxVelocityInDisplayUnits(e)||(e?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 e=ze();this.lock(e);try{return await t()}finally{this.unlock(e)}}}const _o=M.observer(({store:o,useDegree:t})=>{var s;const{t:e}=F.useTranslation(),i=I.useId(),n=[];function r(a){switch(a){case"coordsys":return e("Jogging.Orientation.coordsys");case"tool":return e("Jogging.Orientation.tool");default:return a}}return o.showCoordSystemSelect&&n.push(c.jsx(rt,{labelId:`jogging-coord-select-${i}`,labelValue:e("Jogging.CoordinateSystem.hlb"),value:o.selectedCoordSystemId,size:"small",variant:"filled",displayEmpty:!0,onChange:a=>o.setSelectedCoordSystemId(a.target.value),children:o.coordSystems.map(a=>c.jsx(W,{value:a.coordinate_system,children:a.name&&o.coordSystemCountByName[a.name]>1?`${a.name} / ${a.coordinate_system}`:a.name||a.coordinate_system},a.coordinate_system))},"coord")),o.showTcpSelect&&n.push(c.jsx(rt,{labelId:`jogging-tcp-select-${i}`,labelValue:"TCP",value:o.selectedTcpId,size:"small",variant:"filled",displayEmpty:o.tcpChangeInProgress,onChange:a=>{o.requestTcpChange(a.target.value).catch(g=>{console.error("Failed to change TCP:",g)})},disabled:o.tcpChangeInProgress,endAdornment:o.tcpChangeInProgress?c.jsx(Ae,{position:"end",children:c.jsx(Lt,{size:16})}):void 0,children:o.tcps.map(a=>c.jsx(W,{value:a.id,children:a.id},a.id))},"tcp")),o.showOrientationSelect&&n.push(c.jsx(rt,{labelValue:e("Jogging.Cartesian.Orientation.lb"),labelId:`orientation-select-${i}`,value:o.selectedOrientation,onChange:a=>o.setSelectedOrientation(a.target.value),children:xo.map(a=>c.jsx(W,{value:a,children:r(a)},a))},"orientation")),o.showIncrementSelect&&n.push(c.jsxs(rt,{labelValue:e("Jogging.Increment.hlb"),labelId:`jogging-increment-select-${i}`,size:"small",variant:"filled",value:((s=o.activeDiscreteIncrement)==null?void 0:s.id)||"continuous",onChange:a=>o.setSelectedIncrementId(a.target.value),children:[c.jsx(W,{value:"continuous",children:e("Jogging.Increment.Continuous.dd")},"continuous"),o.discreteIncrementOptions.map(a=>c.jsx(W,{value:a.id,children:t?`${a.degrees}°`:`${a.mm}mm`},a.id))]},"increment")),c.jsx(G,{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:n.map((a,g)=>c.jsx(G,{sx:{gridColumn:n.length%2===1&&g===n.length-1?"span 2":"auto"},children:a},g))})}),Io=B.styled(Le)(({theme:o})=>{var t;return{"&.MuiToggleButtonGroup-root":{background:(t=o.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"}}}}}),ee=tt.externalizeComponent(M.observer(o=>{const{store:t}=o,{t:e}=F.useTranslation();function i(n,r){r===o.velocity||!$e(r)||o.onVelocityChange(r,o.useDegree)}return c.jsxs(x,{direction:"row",gap:2,alignItems:"center","data-testid":"velocity-slider","aria-label":"velocity-slider",children:[t.showVelocityLegend&&c.jsx(T,{sx:{color:Y.velocitySliderLegendColor,fontSize:"14px"},children:e("Jogging.Velocity.bt")}),c.jsx(Nt,{value:o.velocity,color:"secondary",onChange:i,min:o.min,max:o.max,"aria-labelledby":"input-slider",disabled:o.disabled,sx:{"& .MuiSlider-valueLabelOpen":{zIndex:100,backgroundColor:"transparent",top:"0px"}}}),t.showVelocitySliderLabel&&(o.renderValue?o.renderValue(o.velocity):c.jsx(xt,{value:o.velocity.toString()}))]})}));function xt({value:o,sx:t}){var i;const e=B.useTheme();return c.jsx(x,{direction:"row",justifyContent:"center",alignItems:"center",gap:"5px",sx:{padding:"6px 12px",background:(i=e.palette.backgroundPaperElevation)==null?void 0:i[8],borderRadius:"10px",minWidth:"111px",...t},children:c.jsx(T,{component:"span",sx:{textAlign:"right",fontSize:"14px",opacity:.8,color:e.palette.text.primary,whiteSpace:"nowrap"},children:o})})}const oe=M.observer(({store:o,useDegree:t})=>{const{t:e}=F.useTranslation();function i(n,r){return r?`ω = ${e("Jogging.Cartesian.Rotation.velocityDegPerSec.lb",{amount:n})}`:`v = ${e("Jogging.Cartesian.Translation.velocityMmPerSec.lb",{amount:n})}`}return c.jsx(ee,{store:o,velocity:o.velocityInDisplayUnits(t),min:o.minVelocityInDisplayUnits(t),max:o.maxVelocityInDisplayUnits(t),onVelocityChange:o.setVelocityFromSlider,useDegree:t,disabled:o.isLocked,renderValue:n=>c.jsx(xt,{value:i(n,t),sx:{minWidth:"111px",span:{transform:"translateY(-1.5px)"}}})})}),ie=M.observer(({store:o})=>{var s,a,g;const{t}=F.useTranslation(),e=B.useTheme(),i=((g=(a=(s=o.jogger.motionStream.rapidlyChangingMotionState.execute)==null?void 0:s.details)==null?void 0:a.state)==null?void 0:g.kind)??"KIND_UNKNOWN",n=o.lastJogError,r=o.lastJogErrorTranslationKey;return c.jsxs(G,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",color:e.palette.text.primary},children:[c.jsx(T,{variant:"body2",sx:{fontSize:"0.75rem",lineHeight:1.2},children:t("Jogging.StreamStateSection.lb")}),c.jsx(T,{variant:"body2",color:n?"error":void 0,sx:{fontSize:"0.75rem",lineHeight:1.2,textAlign:"right"},"data-testid":n?"JOG_ERROR":i,children:n?r?t(r):n:t(`Jogging.StreamStateSection.${i}.lb`)})]})}),Eo=M.observer(({store:o,children:t})=>{const{t:e}=F.useTranslation(),i=B.useTheme(),n=I.useRef(0);function r(h,l){(l==="translate"||l==="rotate")&&o.setSelectedCartesianMotionType(l)}async function s(h,l){const f=await o.activate(),y=f.motionStream.rapidlyChangingMotionState.tcp_pose,j=f.motionStream.rapidlyChangingMotionState.joint_position;y&&await o.withMotionLock(async()=>{try{o.setCurrentIncrementJog({axis:h.axis,direction:h.direction}),await o.jogger.runIncrementalCartesianMotion({currentTcpPose:y,currentJoints:j,coordSystemId:o.activeCoordSystemId,velocityInRelevantUnits:o.selectedCartesianMotionType==="translate"?o.translationVelocityMmPerSec:o.rotationVelocityRadsPerSec,axis:h.axis,direction:h.direction,motion:o.selectedCartesianMotionType==="translate"?{type:"translate",distanceMm:l.mm}:{type:"rotate",distanceRads:_.degreesToRadians(l.degrees)}})}finally{o.setCurrentIncrementJog(null),await o.deactivate()}})}async function a(h){if(o.isLocked)return;const l=++n.current;try{if(await o.activate(),l!==n.current)return;if(o.activeDiscreteIncrement)return await s(h,o.activeDiscreteIncrement);h.motionType==="translate"?await o.jogger.translateTCP({axis:h.axis,direction:h.direction,velocityMmPerSec:o.translationVelocityMmPerSec}):await o.jogger.rotateTCP({axis:h.axis,direction:h.direction,velocityRadsPerSec:o.rotationVelocityRadsPerSec})}catch(f){console.error("Jogging failed:",f)}}async function g(){o.isLocked||o.activeDiscreteIncrement||(n.current++,await o.deactivate())}const u=[{id:"x",icon:c.jsx(ro,{}),colors:Y.cartesianAxisColors.X},{id:"y",icon:c.jsx(ao,{}),colors:Y.cartesianAxisColors.Y},{id:"z",icon:c.jsx(lo,{}),colors:Y.cartesianAxisColors.Z}];function d(h){return e("General.mm.variable",{amount:h.toFixed(1)})}function p(h){return e("General.degree.variable",{amount:_.radiansToDegrees(h).toFixed(1)})}return c.jsxs(x,{"data-testid":"jogging-cartesian-tab","aria-label":"jogging-cartesian-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[c.jsxs(x,{gap:2,children:[c.jsx(_o,{store:o,useDegree:o.selectedCartesianMotionType==="rotate"}),c.jsx(oe,{store:o,useDegree:o.selectedCartesianMotionType==="rotate"}),c.jsx(H,{})]}),c.jsx(x,{marginLeft:"auto",marginRight:"auto",gap:"24px",justifyContent:"center",sx:{flexGrow:"1"},children:c.jsxs(x,{alignItems:"center",justifyContent:"center",gap:"24px",sx:{flexGrow:1},children:[c.jsxs(Io,{value:o.selectedCartesianMotionType,onChange:r,exclusive:!0,"aria-label":e("Jogging.Cartesian.MotionType.lb"),sx:{justifyContent:"center"},children:[c.jsx(It,{value:"translate",children:e("Jogging.Cartesian.Translation.bt")}),c.jsx(It,{value:"rotate",children:e("Jogging.Cartesian.Rotation.bt")})]}),o.selectedCartesianMotionType==="translate"&&u.map(h=>{var l,f;return c.jsx(gt,{"data-testid":`jogging-cartesian-axis-control-${h.id}`,"aria-label":`jogging-cartesian-axis-control-${h.id}`,colors:h.colors,disabled:o.isLocked,activeJoggingDirection:((l=o.incrementJogInProgress)==null?void 0:l.axis)===h.id?o.incrementJogInProgress.direction:void 0,label:c.jsxs(c.Fragment,{children:[h.icon,c.jsx(T,{sx:{fontSize:"24px",color:((f=h.colors)==null?void 0:f.labelColor)??i.palette.text.primary},children:h.id.toUpperCase()})]}),getDisplayedValue:()=>{var y,j;return d(((j=(y=o.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:y.position)==null?void 0:j[_.XYZ_TO_VECTOR[h.id]])||0)},startJogging:y=>a({axis:h.id,motionType:"translate",direction:y}),stopJogging:g},h.id)}),o.selectedCartesianMotionType==="rotate"&&u.map(h=>{var l,f;return c.jsx(gt,{"data-testid":`jogging-cartesian-axis-control-${h.id}`,"aria-label":`jogging-cartesian-axis-control-${h.id}`,colors:h.colors,disabled:o.isLocked,activeJoggingDirection:((l=o.incrementJogInProgress)==null?void 0:l.axis)===h.id?o.incrementJogInProgress.direction:void 0,label:c.jsxs(c.Fragment,{children:[c.jsx(uo,{}),c.jsx(T,{sx:{fontSize:"24px",color:((f=h.colors)==null?void 0:f.labelColor)??i.palette.text.primary},children:h.id.toUpperCase()})]}),getDisplayedValue:()=>{var y,j;return p(((j=(y=o.jogger.motionStream.rapidlyChangingMotionState.tcp_pose)==null?void 0:y.orientation)==null?void 0:j[_.XYZ_TO_VECTOR[h.id]])||0)},startJogging:y=>a({axis:h.id,motionType:"rotate",direction:y}),stopJogging:g},h.id)})]})}),c.jsx(Yt,{store:o}),c.jsx(H,{}),c.jsx(ie,{store:o}),t&&c.jsx(H,{}),t]})}),Co=M.observer(({store:o,children:t})=>{const e=B.useTheme(),i=I.useRef(0);async function n(s){const a=++i.current;try{if(await o.activate(),a!==i.current)return;await o.jogger.rotateJoints({joint:s.joint,direction:s.direction,velocityUnit:o.jointType===N.JointTypeEnum.PrismaticJoint?"mm/s":"rad/s",velocityValue:o.jointType===N.JointTypeEnum.PrismaticJoint?o.translationVelocityMmPerSec:o.rotationVelocityRadsPerSec})}catch(g){console.error("Jogging failed:",g)}}async function r(){i.current++,await o.jogger.stop(),await o.deactivate()}return c.jsxs(x,{"data-testid":"jogging-joint-tab","aria-label":"jogging-joint-tab",flexGrow:1,gap:2,sx:{padding:"18px 24px"},children:[c.jsx(oe,{store:o,useDegree:o.jointType===N.JointTypeEnum.RevoluteJoint}),c.jsx(H,{}),c.jsx(x,{justifyContent:"center",alignItems:"stretch",sx:{flexGrow:"1"},children:c.jsx(x,{"data-testid":"jogging-joint-value-controls-wrapper","aria-label":"jogging-joint-value-controls-wrapper",alignItems:"center",gap:"24px",children:o.jogger.motionStream.joints.map(s=>{var g,u,d;const a=(d=(u=(g=o.motionGroupDescription.operation_limits.auto_limits)==null?void 0:g.joints)==null?void 0:u[s.index])==null?void 0:d.position;return c.jsxs(x,{"data-testid":`jogging-joint-value-control-${s.index}`,"aria-label":`jogging-joint-value-control-${s.index}`,direction:"row",alignItems:"center",justifyContent:"center",spacing:1.5,width:"100%",children:[o.showJointsLegend&&c.jsx(T,{color:o.isLocked?e.palette.text.disabled:e.palette.text.secondary,children:`G${s.index+1}`}),c.jsx(qt,{disabled:o.isLocked,lowerLimit:a==null?void 0:a.lower_limit,upperLimit:a==null?void 0:a.upper_limit,useDegree:o.jointType===N.JointTypeEnum.RevoluteJoint,getValue:()=>{const p=o.jogger.motionStream.rapidlyChangingMotionState.joint_position[s.index];return p!==void 0?p:void 0},startJogging:p=>n({joint:s.index,direction:p}),stopJogging:r})]},`joint-${s.index}`)})})}),c.jsx(Yt,{store:o}),c.jsx(H,{}),c.jsx(ie,{store:o}),t&&c.jsx(H,{}),t]})}),To=tt.externalizeComponent(M.observer(o=>{const t=M.useLocalObservable(()=>({joggingStore:null,loadingError:null}));return I.useEffect(()=>{let e=!1,i;async function n(){m.runInAction(()=>{t.loadingError=null,t.joggingStore=null});try{let r=o.store;if(!r){const s=await it.open(o.nova,o.motionGroupId,{cellId:o.cellId});if(e){s.dispose();return}try{r=await K.loadFor(s)}catch(a){throw s.dispose(),a}if(i=r,e){r.dispose();return}}m.runInAction(()=>{t.joggingStore=r}),o.onSetup&&o.onSetup(r)}catch(r){if(e)return;m.runInAction(()=>{t.loadingError=r})}}return n(),()=>{e=!0,i==null||i.dispose()}},[o.store,o.nova,o.motionGroupId,o.cellId]),I.useEffect(()=>{const e=t.joggingStore;e&&(o.locked?e.lock("external"):e.unlock("external"))},[t.joggingStore,o.locked]),c.jsx(x,{"data-testid":"jogging-panel","aria-label":"jogging-panel",sx:{maxWidth:"460px",minWidth:"320px",position:"relative",...o.sx},children:t.joggingStore?c.jsx(wo,{store:t.joggingStore,children:o.children}):c.jsx(Wt,{message:"Loading jogging",error:t.loadingError})})})),wo=M.observer(({store:o,children:t})=>{const{t:e}=F.useTranslation();function i(){if(o.currentTab.id==="cartesian")return c.jsx(Eo,{store:o,children:t});if(o.currentTab.id==="joint")return c.jsx(Co,{store:o,children:t})}return c.jsxs(x,{flexGrow:1,sx:{overflow:"hidden"},children:[c.jsx(we,{"data-testid":"jogging-tabs","aria-label":"jogging-tabs",value:o.tabIndex,onChange:o.onTabChange,variant:"fullWidth",children:o.tabs.map(n=>{const r=n.label==="Cartesian"?e("Jogging.Cartesian.bt"):e("Jogging.Joints.bt"),s=n.label==="cartesian"?c.jsx(Ee,{fontSize:"small",sx:{mr:1}}):c.jsx(Ce,{fontSize:"small",sx:{mr:1}});return c.jsx(Te,{"data-testid":`jogging-tab-${n.id}`,"aria-label":`jogging-tab-${n.id}`,label:o.showTabIcons?c.jsxs(x,{direction:"row",alignItems:"center",children:[s,r]}):r,id:`jogging-tab-${n.id}`,"aria-controls":`jogging-tab-${n.id}`},n.id)})}),c.jsx(x,{flexGrow:1,position:"relative",sx:{overflowY:"auto",overflowX:"hidden"},children:i()}),o.blocked&&c.jsx(io,{store:o})]})});function Mo(){const o=window.location.href;return o.substring(0,o.indexOf("/",o.indexOf("//")+2))}function Oo({baseUrl:o=Mo(),...t}){return c.jsxs(Ge,{"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:[c.jsx(Ue,{id:"no-motion-group-modal-title",children:"No motion group found"}),c.jsxs(qe,{sx:{marginTop:"3rem",marginBottom:"1.5rem",textAlign:"center"},children:[c.jsx(T,{color:"#fff",children:"Found no devices to connect to."}),c.jsx(T,{color:"#fff",children:"Please ensure a motion group has been created."})]}),c.jsx(Be,{children:c.jsxs(x,{width:"100%",maxWidth:"300px",margin:"auto",marginBottom:"2rem",children:[c.jsx(dt,{href:`${o}/settings`,variant:"contained",sx:{borderRadius:"8px",width:"100%"},children:"Go to settings app"}),c.jsx(dt,{href:`${o}`,variant:"text",sx:{marginTop:"1rem",color:"#fff",textDecoration:"underline",fontSize:"0.75rem"},children:"Back to Homescreen"})]})})]})}const Rt=1e-4,ko={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class ct{constructor(t,e,i,n,r,s,a,g,u,d,p="cell"){this.controller=e,this.motionGroup=i,this.initialMotionState=n,this.motionStateSocket=r,this.isVirtual=s,this.tcps=a,this.description=g,this.initialControllerState=u,this.controllerStateSocket=d,this.cellId=p,this.connectedJoggingSocket=null,this.joggingVelocity=10,this.activationState="inactive",this.nova=w.createNovaClient(t),this.rapidlyChangingMotionState=n,this.controllerState=u,d.addEventListener("message",h=>{var f;const l=(f=_.tryParseJson(h.data))==null?void 0:f.result;l&&m.runInAction(()=>{this.controllerState=l})}),r.addEventListener("message",h=>{var f;const l=(f=_.tryParseJson(h.data))==null?void 0:f.result;if(!l)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${h.data}`);ft(this.rapidlyChangingMotionState.joint_position,l.joint_position,Rt)||m.runInAction(()=>{this.rapidlyChangingMotionState.joint_position=l.joint_position}),yt(this.rapidlyChangingMotionState,l,Rt)||m.runInAction(()=>{this.rapidlyChangingMotionState.tcp_pose=l.tcp_pose}),l.tcp!==void 0&&this.rapidlyChangingMotionState.tcp!==l.tcp&&m.runInAction(()=>{this.rapidlyChangingMotionState.tcp=l.tcp}),this.rapidlyChangingMotionState.standstill!==l.standstill&&m.runInAction(()=>{this.rapidlyChangingMotionState.standstill=l.standstill})}),m.makeAutoObservable(this)}static async connectMultiple(t,e,i={}){const n=w.createNovaClient(t),r=i.cellId??w.cellIdOf(t);return Promise.all(e.map(s=>ct.connect(n,s,{...i,cellId:r})))}static async connect(t,e,i={}){var k,R;const n=w.createNovaClient(t),r=i.cellId??w.cellIdOf(t)??"cell",[s,a]=e.split("@"),g=await n.api.controller.getCurrentRobotControllerState(r,a),u=g==null?void 0:g.motion_groups.find(E=>E.motion_group===e);if(!g||!u)throw new Error(`Controller ${a} or motion group ${e} not found`);const d=n.openReconnectingWebsocket(`/cells/${r}/controllers/${a}/motion-groups/${e}/state-stream`),p=await d.firstMessage(),h=(k=_.tryParseJson(p.data))==null?void 0:k.result;if(!h)throw new Error(`Unable to parse initial motion state message ${p.data}`);console.log(`Connected motion state websocket to motion group ${u.motion_group}. Initial state:
|
|
2
2
|
`,h);const f=(await n.api.controller.getRobotController(r,g.controller)).configuration.kind==="VirtualController",y=await n.api.motionGroup.getMotionGroupDescription(r,a,u.motion_group),j=Object.entries(y.tcps||{}).map(([E,A])=>({id:E,readable_name:A.name,position:A.pose.position,orientation:A.pose.orientation})),v=n.openReconnectingWebsocket(`/cells/${r}/controllers/${g.controller}/state-stream?response_rate=1000`),C=await v.firstMessage(),O=(R=_.tryParseJson(C.data))==null?void 0:R.result;if(!O)throw new Error(`Unable to parse initial controller state message ${C.data}`);return console.log(`Connected controller state websocket to controller ${g.controller}. Initial state:
|
|
3
3
|
`,O),new ct(n,g,u,h,d,f,j,y,O,v,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,e)=>({index:e}))}get dhParameters(){if(this.description.dh_parameters!==void 0)return this.description.dh_parameters.map(t=>({...ko,...t}))}get safetyZones(){return this.description.safety_zones}get mountingPosition(){var t,e,i;return this.description.mounting?[(((t=this.description.mounting.position)==null?void 0:t[0])||0)/1e3,(((e=this.description.mounting.position)==null?void 0:e[1])||0)/1e3,(((i=this.description.mounting.position)==null?void 0:i[2])||0)/1e3]:[0,0,0]}get mountingQuaternion(){var n,r,s,a,g,u;const t=new Ct.Vector3(((r=(n=this.description.mounting)==null?void 0:n.orientation)==null?void 0:r[0])||0,((a=(s=this.description.mounting)==null?void 0:s.orientation)==null?void 0:a[1])||0,((u=(g=this.description.mounting)==null?void 0:g.orientation)==null?void 0:u[2])||0),e=t.length(),i=t.normalize();return new Ct.Quaternion().setFromAxisAngle(i,e)}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}m.runInAction(()=>{this.activationState="deactivating"});try{await this.nova.api.controller.setDefaultMode(this.cellId,this.controllerId,"ROBOT_SYSTEM_MODE_MONITOR"),m.runInAction(()=>{this.activationState="inactive"})}catch(t){throw m.runInAction(()=>{this.activationState="active"}),t}}async activate(){if(this.activationState!=="inactive"){console.error("Tried to activate while already activating");return}m.runInAction(()=>{this.activationState="activating"});try{await this.nova.api.controller.setDefaultMode(this.cellId,this.controllerId,"ROBOT_SYSTEM_MODE_CONTROL"),m.runInAction(()=>{this.activationState="active"})}catch(t){throw m.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 vt=1e-4,Ro=new Set(["timestamp","sequence_number","joint_position","joint_torque","joint_current","flange_pose","tcp_pose","flange_velocity","tcp_velocity"]),Ao=1,At=o=>Array.isArray(o)&&o.length===3&&o.every(t=>typeof t=="number");class ne{constructor(t,e,i,n={}){this.source=t,this.motionGroupId=e,this.lastMessageReceivedAt=Date.now(),this.lastInvalidStateMessage=null,this.connectionQuality="good";const r=i.motion_groups.find(s=>s.motion_group===e);if(!r)throw new Error(`Motion group ${e} not found in initial controller state`);this.isVirtual=n.isVirtual??!1,this.onError=n.onError,this.reconnectsOnFocus=(n.reconnectOnFocus??!0)&&typeof window<"u",this.rapidlyChangingMotionState=r,this.lastValidStateMessage={receivedAt:Date.now(),data:i},m.makeAutoObservable(this,{source:!1,lastMessageReceivedAt:!1,connectionQualityInterval:!1,isVirtual:!1,onError:!1,reconnectsOnFocus:!1,readoutState:m.computed({equals:bt,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 jt(this.rapidlyChangingMotionState)}async nextMotionState(){var i,n;const t=await this.source.nextMessage(),e=(n=(i=this.source.parse(t.data))==null?void 0:i.motion_groups)==null?void 0:n.find(r=>r.motion_group===this.motionGroupId);if(!e)throw new Error(`Failed to get motion state for ${this.motionGroupId}: ${t.data}`);return e}setLastInvalidStateMessage(t){this.lastInvalidStateMessage={receivedAt:Date.now(),data:t}}setLastValidStateMessage(t){this.lastValidStateMessage={receivedAt:Date.now(),data:t}}updateRapidlyChangingMotionState(t,e){const i=this.rapidlyChangingMotionState,n=t;for(const r of Object.keys(n))e!=null&&e.has(r)||Vt(i[r],n[r])||(i[r]=n[r]);for(const r of Object.keys(i))e!=null&&e.has(r)||r in n||delete i[r]}setConnectionQuality(t){this.connectionQuality=t}handleWindowFocus(){this.source.reconnect()}updateConnectionQuality(){const t=Date.now()-this.lastMessageReceivedAt,e=this.isVirtual?3e3:1e3,i=this.isVirtual?6e3:3e3;if(t>i){this.source.readyState===Ao&&this.source.reconnect(),this.setConnectionQuality("critical");return}if(t>e){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 u,d;const e=this.source.parse(t.data);if(!(e!=null&&e.motion_groups)){(u=this.onError)==null||u.call(this,{message:_.makeErrorMessage(t.data),url:this.source.url}),this.setLastInvalidStateMessage(t.data);return}this.lastMessageReceivedAt=Date.now();const i=this.lastValidStateMessage.data;(i.safety_state!==e.safety_state||i.operation_mode!==e.operation_mode||i.mode!==e.mode)&&this.setLastValidStateMessage(e);const n=e.motion_groups.find(p=>p.motion_group===this.motionGroupId);if(!n){(d=this.onError)==null||d.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=!et(this.rapidlyChangingMotionState.joint_position,n.joint_position,vt),s=this.rapidlyChangingMotionState.tcp!==n.tcp;if(!r&&!s){this.updateRapidlyChangingMotionState(n,Ro);return}const a=this.rapidlyChangingMotionState.flange_pose,g=n.flange_pose;if((g==null?void 0:g.orientation)==null||!At(g.orientation)){const p=g==null?void 0:g.orientation;throw new Error(`Invalid newFlangePose.orientation: expected [number, number, number] (got ${p==null?"null":p.length})`)}if((a==null?void 0:a.orientation)==null||!At(a.orientation)){const p=a==null?void 0:a.orientation;throw new Error(`Invalid oldFlangePose.orientation: expected [number, number, number] (got ${p==null?"null":p.length})`)}g.orientation=St(g.orientation,a.orientation),this.updateRapidlyChangingMotionState(n)}}function Po(o){return{get url(){return o.url},get readyState(){return o.readyState},addEventListener:(t,e)=>o.addEventListener(t,e),removeEventListener:(t,e)=>o.removeEventListener(t,e),firstMessage:()=>o.firstMessage(),nextMessage:()=>o.nextMessage(),reconnect:()=>o.reconnect(),close:()=>o.close(),parse:t=>{var e;return(e=Ft.tryParseJson(t))==null?void 0:e.result}}}function re(o,{controllerId:t,cellId:e,responseRateMs:i}){const n=w.createNovaClient(o),r=e??w.cellIdOf(o)??"cell",s=i===void 0?"":`?response_rate=${i}`;return Po(n.openReconnectingWebsocket(`/cells/${r}/controllers/${t}/state-stream${s}`))}const Jo=["FeedbackOutOfWorkspace","FeedbackJointLimitExceeded","FeedbackAxisRangeExceeded","FeedbackNoSolutionInCurrentConfiguration"];function se(o){return o==="FeedbackSingularity"?"Jogging.TargetPose.Error.Singularity.lb":o==="FeedbackCollision"?"Jogging.TargetPose.Error.Collision.lb":Jo.includes(o)?"Jogging.TargetPose.Error.NotReachable.lb":"Jogging.TargetPose.Error.PlanningFailed.lb"}function ae(o){const t=o.api.opts.axiosInstance;if(!t)throw new Error("Nova API client has no configured HTTP transport");return t}function mt(o,t){const e=o.api.opts.baseOptions??{},i={...e,...t};return(e.headers||t.headers)&&(i.headers={...e.headers,...t.headers}),(e.params||t.params)&&(i.params={...e.params,...t.params}),i}async function Do(o,t,e,i){var r;if(!e)return t;const n=`/experimental/motion-group-models/${encodeURIComponent(t)}/description`;i==null||i(`${n}?serial_number=${encodeURIComponent(e)}`);try{return(await ae(o).get(n,mt(o,{params:{serial_number:e}}))).data.name}catch(s){if(!Gt.isAxiosError(s)||((r=s.response)==null?void 0:r.status)!==404)throw s;return t}}async function Lo(o,t,e,i,n){var u;const r=ae(o),s=`/motion-group-models/${encodeURIComponent(t)}/${i}`,a={};if(e){const d=`/experimental${s}`;n==null||n(`${d}?serial_number=${encodeURIComponent(e)}`);try{return(await r.get(d,mt(o,{...a,params:{serial_number:e}}))).data}catch(p){if(!Gt.isAxiosError(p)||((u=p.response)==null?void 0:u.status)!==404)throw p}}return n==null||n(s),(await r.get(s,mt(o,a))).data}const ce=["motionGroupDescription","controllerConfiguration","kinematicModel","motionGroupModel","coordinateSystems","controllerState","motionStateStream","controllerStateStream"];class _t extends Error{constructor(t,e,i){super(i),this.stepId=t,this.cause=e,this.name="RobotLoadStepError"}}function st(o){return o instanceof _t}class le{constructor(t=null,e=null){this.motionGroupId=null,this.controllerId=null,this.steps=[],this.retryAttempt=0,this.fatalError=null,this.currentStepStartedAt=null,this.motionGroupId=t,this.controllerId=e,this.steps=ce.map(i=>({id:i,status:"pending",url:null,error:null})),m.makeAutoObservable(this,{},{autoBind:!0})}beginRetry(t){for(const e of this.steps)e.status="pending",e.url=null,e.error=null;this.retryAttempt=t,this.fatalError=null,this.currentStepStartedAt=null}stepById(t){return this.steps.find(e=>e.id===t)}startStep(t,e){const i=this.stepById(t);i&&(i.status="running",i.url=e,i.error=null,this.currentStepStartedAt=Date.now())}updateStepUrl(t,e){const i=this.stepById(t);i&&(i.url=e)}succeedStep(t){const e=this.stepById(t);e&&(e.status="succeeded",this.currentStepStartedAt=null)}failStep(t,e){const i=this.stepById(t);i&&(i.status="failed",i.error=e,this.currentStepStartedAt=null)}failWith(t){this.fatalError=t,this.currentStepStartedAt=null}get totalCount(){return this.steps.length}get succeededCount(){return this.steps.filter(t=>t.status==="succeeded").length}get runningStep(){return this.steps.find(t=>t.status==="running")}get failedStep(){return this.steps.find(t=>t.status==="failed")}get isFailed(){return this.fatalError!==null||this.failedStep!==void 0}get isComplete(){return this.steps.length>0&&this.steps.every(t=>t.status==="succeeded")}}const $o=1e4;async function Pt(o,t,e){let i;o.catch(()=>{});try{return await Promise.race([o,new Promise((n,r)=>{i=setTimeout(()=>r(new Error(e)),t)})])}finally{clearTimeout(i)}}async function Vo({nova:o,cellId:t,controllerId:e,motionGroupId:i,progress:n,createStateSource:r,isStale:s=()=>!1,socketTimeoutMs:a=$o}){let g,u,d=!1;function p(){g==null||g.dispose(),u==null||u.close()}async function h(l,f,y){n.startStep(l,f);try{const j=await y();return n.succeedStep(l),j}catch(j){throw n.failStep(l,j),new _t(l,j,_.makeErrorMessage(j))}}try{if(s())return null;const l=`/cells/${t}/controllers/${e}/motion-groups/${i}`,f=`/cells/${t}/controllers/${e}`,y=await h("motionGroupDescription",`${l}/description`,()=>o.api.motionGroup.getMotionGroupDescription(t,e,i));if(s())return null;const{configuration:j}=await h("controllerConfiguration",f,()=>o.api.controller.getRobotController(t,e));if(s())return null;const v={model:y.motion_group_model,serialNumber:y.serial_number},C=v.serialNumber?`?serial_number=${encodeURIComponent(v.serialNumber)}`:"",O=await h("kinematicModel",`/experimental/motion-group-models/${encodeURIComponent(v.model)}/kinematic${C}`,()=>Lo(o,v.model,v.serialNumber,"kinematic",S=>n.updateStepUrl("kinematicModel",S)));if(s())return null;const k=await h("motionGroupModel",`/experimental/motion-group-models/${encodeURIComponent(v.model)}/description${C}`,()=>Do(o,v.model,v.serialNumber,S=>n.updateStepUrl("motionGroupModel",S)));if(s())return null;const R=await h("coordinateSystems",`${f}/coordinate-systems?orientation_type=ROTATION_VECTOR`,async()=>await o.api.controller.listCoordinateSystems(t,e,"ROTATION_VECTOR")??[]);if(s())return null;const{controllerState:E,motionGroupState:A}=await h("controllerState",`${f}/state`,async()=>{const S=await o.api.controller.getCurrentRobotControllerState(t,e),P=S==null?void 0:S.motion_groups.find(J=>J.motion_group===i);if(!S||!P)throw new Error(`Controller ${e} or motion group ${i} not found`);return{controllerState:S,motionGroupState:P}});if(s())return null;const V=`${l}/state-stream`,{socket:q,initialMotionState:D}=await h("motionStateStream",V,async()=>{var Q;const S=o.openReconnectingWebsocket(V);g=S;const P=await Pt(S.firstMessage(),a,`No motion state received from ${V} within ${a/1e3}s`),J=(Q=Ft.tryParseJson(P.data))==null?void 0:Q.result;if(!J)throw new Error(`Unable to parse initial motion state message ${P.data}`);return{socket:S,initialMotionState:J}});if(s())return null;const{source:$,initialControllerState:nt}=await h("controllerStateStream",`${f}/state`,async()=>{var Q;const S=r({cellId:t,controllerId:e});u=S,n.updateStepUrl("controllerStateStream",S.url);const P=await Pt(S.firstMessage(),a,`No controller state received from ${S.url} within ${a/1e3}s`),J=S.parse(P.data);if(!J)throw new Error(`Unable to parse initial controller state message ${P.data}`);if(!((Q=J.motion_groups)!=null&&Q.some(Se=>Se.motion_group===i)))throw new Error(`Controller state from ${S.url} does not list motion group ${i} yet`);return{source:S,initialControllerState:J}});return s()?null:(d=!0,{motionGroupDescription:y,controllerConfiguration:j,kinematicModel:O,motionGroupModelName:k,coordinateSystems:R,controllerState:E,motionGroupState:A,initialMotionState:D,motionStateSocket:q,stateSource:$,initialControllerState:nt,dispose:p})}finally{d||p()}}class de{constructor(t){this.options=t,this.plannedTrajectory=null,this.trajectoryState="idle",this.lastError=null,this.disposers=[],this.logger=t.logger??console,m.makeAutoObservable(this,{socket:!1,disposers:!1,logger:!1,options:!1},{autoBind:!0}),this.socket=this.openSocket(),this.disposers.push(m.reaction(()=>this.executionState,e=>{e==="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,e;return(e=(t=this.motionStream.rapidlyChangingMotionState.execute)==null?void 0:t.details)==null?void 0:e.state.kind}async planTrajectory(t){var v,C,O,k,R;if((C=(v=this.options).isLocked)!=null&&C.call(v))throw this.reset(),new Error("Cannot plan trajectory: the robot is locked");await this.ensureMovementOwnership();const e=this.motionStream.rapidlyChangingMotionState.joint_position??[],{cycle_time:i,mounting:n,motion_group_model:r,tcps:s}=this.motionStream.description,a=this.joggingStore.selectedTcpId,g=a?(O=s==null?void 0:s[a])==null?void 0:O.pose:void 0,u={motion_group_model:((k=this.jogger.options)==null?void 0:k.motionGroupModel)??r,cycle_time:i??0,mounting:n,...g&&{tcp_offset:g}};let d;if(t.type==="cartesian"){let E=t.pose;const A=t.coordinateSystemId||"world";if(A!=="world")try{E=X({pose:{position:E.position??[0,0,0],orientation:E.orientation??[0,0,0]},coordinateSystemId:A},"world",this.joggingStore.coordSystems).pose}catch{return this.reset(),{ok:!1,errorFeedbackName:"FeedbackUnknown"}}d={limits_override:{tcp_velocity_limit:this.joggingStore.translationVelocityMmPerSec},path:{target_pose:E,path_definition_name:"PathCartesianPTP"}}}else d={limits_override:{joint_velocity_limits:Array(e.length).fill(this.joggingStore.rotationVelocityRadsPerSec)},path:{target_joint_position:t.joints,path_definition_name:"PathJointPTP"}};m.runInAction(()=>{this.lastError=null,this.trajectoryState="planning"});let p;try{p=await this.jogger.nova.api.trajectoryPlanning.planTrajectory(this.jogger.cellId,{motion_group_setup:u,start_joint_position:e,motion_commands:[d]})}catch(E){throw this.reset(),E}const h=p.response;if("error_feedback"in h){const E=((R=h.error_feedback)==null?void 0:R.error_feedback_name)??"FeedbackUnknown";return this.reset(),{ok:!1,errorFeedbackName:E}}const l=h.joint_positions,f=l[0],y=l[l.length-1];if(!f||!y)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:a||void 0,data:h}};return this.socket.sendJson(j),m.runInAction(()=>{this.plannedTrajectory={startJoints:f,endJoints:y}}),{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(),m.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 m.when(()=>this.motionStream.rapidlyChangingMotionState.standstill)}handleMessage(t){var i,n;const e=(i=_.tryParseJson(t.data))==null?void 0:i.result;if(e)switch(e.kind){case"INITIALIZE_RECEIVED":e.add_trajectory_error||e.message?(this.lastError=((n=e.add_trajectory_error)==null?void 0:n.message)??e.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=e.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()}}const No={a:0,d:0,alpha:0,theta:0,reverse_rotation_direction:!1};class ge{constructor(t,e,i,n,r){this.motionGroupDescription=t,this.controllerConfiguration=e,this.kinematicModel=i,this.resolvedMotionGroupModel=n,this.coordinateSystems=r,this.dhParameters=(t.dh_parameters??[]).map(s=>({...No,...s}))}get isVirtual(){return this.controllerConfiguration.kind==="VirtualController"}get motionGroupModel(){return this.motionGroupDescription.motion_group_model}get serialNumber(){return this.motionGroupDescription.serial_number}get inverseSolver(){return this.kinematicModel.inverse_solver}get jointType(){var t,e;return((e=(t=this.motionGroupDescription.dh_parameters)==null?void 0:t[0])==null?void 0:e.type)??N.JointTypeEnum.RevoluteJoint}get jointLimits(){var t;return((t=this.motionGroupDescription.operation_limits.auto_limits)==null?void 0:t.joints)??[]}get safetyZones(){return this.motionGroupDescription.safety_zones}get safetyLinkColliders(){return this.motionGroupDescription.safety_link_colliders}get safetyToolColliders(){return this.motionGroupDescription.safety_tool_colliders}get kinematicChainOffset(){return this.kinematicModel.kinematic_chain_offset??this.motionGroupDescription.kinematic_chain_offset??null}get flangeOffset(){return this.kinematicModel.flange_offset??this.motionGroupDescription.flange_offset??null}get mounting(){return this.motionGroupDescription.mounting??null}get tcps(){return Object.entries(this.motionGroupDescription.tcps??{}).map(([t,e])=>({id:t,name:e.name}))}get tcpOffsetsById(){return this.motionGroupDescription.tcps??{}}}const Jt=o=>Array.isArray(o)&&o.length===3&&o.every(t=>typeof t=="number"),Fo=.001,Go=.5,Bo=.01,lt=(o,t,e)=>!!(o&&t&&et([...o],[...t],e));class ue{constructor(t,e,i){this.stream=t,this.description=e,this.jogging=i,m.makeAutoObservable(this,{stream:!1,description:!1,jogging:!1},{autoBind:!0})}get controllerState(){return this.stream.controllerState}get rapidlyChangingMotionState(){return this.stream.rapidlyChangingMotionState}get readoutState(){return this.stream.readoutState}get jointPose(){return this.stream.readoutState.joint_position}get connectionQuality(){return this.stream.connectionQuality}get lastValidStateMessage(){return this.stream.lastValidStateMessage}get lastInvalidStateMessage(){return this.stream.lastInvalidStateMessage}get measuredTcpPoseReference(){return this.tcpPoseReferenceOf(this.rapidlyChangingMotionState)}get displayedTcpPoseReference(){return this.inSelectedFrame(this.measuredTcpPoseReference)}get displayedTcpPose(){return this.inSelectedFrame(this.tcpPoseReferenceOf(this.readoutState)).pose}isAt(t){if(t.type==="joint")return lt(t.joints,this.rapidlyChangingMotionState.joint_position,Fo);try{const e=ht({inputPose:this.measuredTcpPoseReference,selectedTcpId:t.tcpPose.tcpId,selectedCoordinateSystemId:t.tcpPose.coordSystemId,tcpOffsetsById:this.description.tcpOffsetsById,coordinateSystems:this.jogging.coordSystems});return lt(t.tcpPose.pose.position,e.pose.position,Go)&<(t.tcpPose.pose.orientation,e.pose.orientation,Bo)}catch{return!1}}nextMotionState(){return this.stream.nextMotionState()}async waitUntilStopped(){let t=await this.stream.nextMotionState(),e=await this.stream.nextMotionState();for(;!et(t.joint_position,e.joint_position,vt);)t=e,e=await this.stream.nextMotionState()}tcpPoseReferenceOf(t){var n,r;const e=(n=t.tcp_pose)==null?void 0:n.position,i=(r=t.tcp_pose)==null?void 0:r.orientation;if(!e||!Jt(e))throw new Error(`Invalid current TCP pose position for motion group ${this.stream.motionGroupId}`);if(!i||!Jt(i))throw new Error(`Invalid current TCP pose orientation for motion group ${this.stream.motionGroupId}`);return{pose:{position:e,orientation:i},tcpId:t.tcp??"",coordinateSystemId:t.coordinate_system??"world"}}inSelectedFrame(t){return ht({inputPose:t,selectedTcpId:this.jogging.selectedTcpId,selectedCoordinateSystemId:this.jogging.selectedCoordSystemId,tcpOffsetsById:this.description.tcpOffsetsById,coordinateSystems:this.jogging.coordSystems})}}const qo=["SAFETY_STATE_ROBOT_EMERGENCY_STOP","SAFETY_STATE_DEVICE_EMERGENCY_STOP"],Uo=["SAFETY_STATE_NORMAL","SAFETY_STATE_REDUCED"],zo=["SAFETY_STATE_STOP","SAFETY_STATE_STOP_0","SAFETY_STATE_STOP_1","SAFETY_STATE_STOP_2"],Wo=["OPERATION_MODE_AUTO","OPERATION_MODE_MANUAL","OPERATION_MODE_MANUAL_T1","OPERATION_MODE_MANUAL_T2"];class he{constructor(t,e){this.state=t,this.activationState=e,m.makeAutoObservable(this,{state:!1,activationState:!1},{autoBind:!0})}get safetyState(){return this.state.controllerState.safety_state}get operationMode(){return this.state.controllerState.operation_mode}get isEstopActive(){return qo.includes(this.safetyState)}get isMoveableSafetyState(){return Uo.includes(this.safetyState)}get isMoveableOperationMode(){return Wo.includes(this.operationMode)}get isActivatableSafetyState(){return this.isMoveableSafetyState||zo.includes(this.safetyState)}get activationBlockedReason(){return this.isEstopActive?`an emergency stop is active (${this.safetyState})`:this.isActivatableSafetyState?this.isMoveableOperationMode?null:`the operation mode is ${this.operationMode}`:`the safety state is ${this.safetyState}`}get canBeActive(){return this.activationBlockedReason===null}get notMoveableReason(){return this.state.connectionQuality==="critical"?{code:"disconnected"}:this.isMoveableSafetyState?this.isMoveableOperationMode?this.activationState()==="inactive"?{code:"deactivated"}:null:{code:"operation_mode",value:this.operationMode}:{code:"safety_state",value:this.safetyState}}get canBeMoved(){return this.isMoveableSafetyState&&this.isMoveableOperationMode&&this.activationState()==="active"&&this.state.connectionQuality!=="critical"}}function pe(o){return o.type==="joint"?{type:"joint",joints:o.joints}:{type:"cartesian",pose:o.tcpPose.pose,coordinateSystemId:o.tcpPose.coordSystemId}}class me{constructor(t,e){this.robot=t,this.logger=e,this.editing=!1,this.draft="",this.confirming=!1,this.staged=null,this.moveStarted=!1,this.disposers=[],m.makeAutoObservable(this,{robot:!1,logger:!1,disposers:!1,onBeforePlan:!1},{autoBind:!0}),this.disposers.push(m.reaction(()=>this.robot.jogging.selectedTabId,()=>{(this.editing||this.staged)&&this.resetToLive()})),this.disposers.push(m.reaction(()=>({trajectoryState:this.robot.trajectory.trajectoryState,executionState:this.robot.trajectory.executionState,isRobotAtStagedPose:this.isRobotAtStagedPose}),({trajectoryState:i,executionState:n,isRobotAtStagedPose:r})=>{if(!this.stagedPose)return;if(i==="moving"){this.moveStarted=!0;return}(n==="END_OF_TRAJECTORY"||this.moveStarted&&r&&i!=="stopping")&&this.resetToLive()}))}dispose(){for(const t of this.disposers)t()}get phase(){return this.editing?"editing":this.staged?this.staged.errorKey?"error":"staged":"view"}get isJointTab(){return this.robot.jogging.selectedTabId==="joint"}get liveDisplayString(){return this.isJointTab?z.jointsToText(this.robot.state.jointPose):z.poseToText(this.robot.state.displayedTcpPose)}get displayString(){var t;return((t=this.staged)==null?void 0:t.displayString)??this.liveDisplayString}get parsedDraft(){const{state:t,motionGroupId:e}=this.robot;if(this.isJointTab){const r=z.parseJointsText(this.draft,t.jointPose.length);return r?{type:"joint",motionGroupId:e,joints:r}:null}const i=z.parsePoseText(this.draft);if(!i)return null;const n=t.displayedTcpPoseReference;return{type:"cartesian",motionGroupId:e,tcpPose:{pose:{position:i.position,orientation:i.orientation},coordSystemId:n.coordinateSystemId,tcpId:n.tcpId}}}get draftValid(){return this.parsedDraft!==null}beginEdit(){this.draft=this.displayString,this.editing=!0}setDraft(t){this.draft=t}cancelEdit(){this.editing=!1,this.draft=""}async confirmEdit(){var i;const t=this.parsedDraft;if(!t||this.confirming||this.robot.notMoveableReason())return;const e=t.type==="joint"?z.jointsToText(t.joints):z.poseToText(t.tcpPose.pose);this.confirming=!0;try{await((i=this.onBeforePlan)==null?void 0:i.call(this));const n=await this.robot.trajectory.planTrajectory(pe(t));m.runInAction(()=>{this.staged={pose:t,displayString:e,errorKey:n.ok?null:se(n.errorFeedbackName)},this.editing=!1,this.draft=""})}catch(n){this.logger.warn("Failed to plan trajectory to typed pose",n),m.runInAction(()=>{this.staged={pose:t,displayString:e,errorKey:"Jogging.TargetPose.Error.PlanningFailed.lb"},this.editing=!1,this.draft=""})}finally{m.runInAction(()=>{this.confirming=!1})}}async resetToLive(){const t=this.staged!==null&&!this.staged.errorKey;this.staged=null,this.moveStarted=!1,this.editing=!1,this.draft="",t&&await this.robot.trajectory.stopAndReset()}clear(){this.editing=!1,this.staged=null}get stagedPose(){return!this.staged||this.staged.errorKey?null:this.staged.pose}get isRobotAtStagedPose(){return this.stagedPose?this.robot.state.isAt(this.stagedPose):!1}}const Ho={getItem:()=>null,setItem:()=>{}};class fe{constructor(t,e,i,n={}){const r=n.logger??console;this.onError=n.onError??(()=>{}),this.nova=t,this.motionGroupId=e.motionGroupId,this.controllerId=e.controllerId,this.cellId=e.cellId,this.stateSource=i.stateSource,this.motionStateSocket=i.motionStateSocket;const s=new ot(t,i.controllerState,i.motionGroupState,i.motionGroupDescription,i.initialMotionState,i.motionStateSocket,e.cellId,{logger:r}),a=new it(s,{cellId:e.cellId,motionGroupModel:i.motionGroupModelName,logger:r,onError:u=>this.onError({kind:"jog",message:_.makeErrorMessage(u),url:a.motionStream.motionStateSocket.url,cause:u})});this.jogging=K.create(a,{coordinateSystems:i.coordinateSystems,description:i.motionGroupDescription,kinematicModel:i.kinematicModel},{storage:n.storage??Ho}),this.description=new ge(i.motionGroupDescription,i.controllerConfiguration,i.kinematicModel,i.motionGroupModelName,this.jogging.coordSystems);const g=new ne(i.stateSource,e.motionGroupId,i.initialControllerState,{isVirtual:this.description.isVirtual,onError:u=>this.onError({kind:"stream",...u})});this.state=new ue(g,this.description,this.jogging),this.activation=new Et.RobotActivation(t,e,this.state,()=>this.safety,r),this.safety=new he(this.state,()=>this.activation.state),this.trajectory=new de({joggingStore:this.jogging,isLocked:n.isLocked,ensureMovementOwnership:()=>this.ensureMovementOwnership("trajectory"),logger:r}),this.targetPose=new me({motionGroupId:e.motionGroupId,state:this.state,jogging:this.jogging,trajectory:this.trajectory,notMoveableReason:()=>{var u;return this.safety.notMoveableReason??((u=n.isLocked)!=null&&u.call(n)?{code:"locked"}:null)}},r),this.jogging.onBeforeActivate=async()=>{this.targetPose.staged&&await this.targetPose.resetToLive()},n.autoActivateVirtual&&this.description.isVirtual&&this.activation.state==="inactive"&&this.activation.activate().catch(u=>{this.onError({kind:"mode",message:_.makeErrorMessage(u),url:u instanceof Et.RobotModeChangeError?u.url:void 0,cause:u})})}reportError(t){this.onError(t)}get movementOwner(){return this.jogging.jogger.mode}async ensureMovementOwnership(t){this.movementOwner!==t&&(await this.jogging.deactivate(),await this.jogging.jogger.setJoggingMode(t))}dispose(){this.activation.dispose(),this.targetPose.dispose(),this.state.stream.dispose(),this.trajectory.dispose(),this.stateSource.close(),this.jogging.dispose(),this.motionStateSocket.dispose()}}const Yo=[1e3,2e3],Ko=o=>new Promise(t=>setTimeout(t,o));class ye{constructor(t,e,i,n){this.nova=t,this.motionGroupId=e,this.ids=i,this.options=n,this.state="loading",this.session=null,this.error=null,this.attempt=0,this.disposed=!1,this.progress=new le(e,i.controllerId),m.makeAutoObservable(this,{nova:!1,ids:!1,options:!1,attempt:!1,disposed:!1,readyPromise:!1,settle:!1,progress:!1},{autoBind:!0}),this.start()}get ready(){return this.readyPromise}retry(){this.disposed||this.state!=="failed"||this.start()}dispose(){var t;this.disposed||(this.disposed=!0,this.attempt++,(t=this.session)==null||t.dispose(),this.session=null,this.settle.reject(new Error("The robot session load was disposed")))}start(){this.attempt++;const t=this.attempt;this.readyPromise=new Promise((e,i)=>{this.settle={resolve:e,reject:i}}),this.readyPromise.catch(()=>{}),m.runInAction(()=>{this.state="loading",this.error=null}),this.run(t)}isStale(t){return this.disposed||t!==this.attempt}async run(t){var a,g;const{cellId:e,controllerId:i}=this.ids,n=this.options.retryDelaysMs??Yo,r=this.options.logger??console,s=this.options.stateSource??(u=>re(this.nova,u));for(let u=0;;u++)try{const d=await Vo({nova:this.nova,cellId:e,controllerId:i,motionGroupId:this.motionGroupId,progress:this.progress,createStateSource:s,isStale:()=>this.isStale(t),socketTimeoutMs:this.options.socketTimeoutMs});if(!d)return;if(this.isStale(t)){d.dispose();return}let p;try{p=new fe(this.nova,{cellId:e,controllerId:i,motionGroupId:this.motionGroupId},d,this.options)}catch(h){throw d.dispose(),h}if(this.isStale(t)){p.dispose();return}m.runInAction(()=>{this.session=p,this.state="ready"}),this.settle.resolve(p);return}catch(d){if(this.isStale(t))return;const p=st(d)?n[u]:void 0;if(p===void 0){m.runInAction(()=>{st(d)?this.progress.failStep(d.stepId,d.cause):this.progress.failWith(d),this.state="failed",this.error=d}),(g=(a=this.options).onEvent)==null||g.call(a,{type:"loadFailed",motionGroupId:this.motionGroupId,step:st(d)?d.stepId:"unknown",message:_.makeErrorMessage(d),attempts:u+1}),this.settle.reject(d);return}if(r.warn(`Retrying load of robot "${this.motionGroupId}" after: ${_.makeErrorMessage(d)}`),m.runInAction(()=>{this.progress.beginRetry(u+1)}),await Ko(p),this.isStale(t))return}}}function Qo(o,t,e={}){return Zo(w.createNovaClient(o),t,{...e,cellId:e.cellId??w.cellIdOf(o)})}function Zo(o,t,e={}){const i=e.cellId??"cell",n=e.controllerId??t.split("@")[1]??"";return new ye(o,t,{cellId:i,controllerId:n},e)}exports.AppHeader=We;exports.ConnectedMotionGroup=ct;exports.ControllerStateStream=ne;exports.JoggerConnection=it;exports.JoggingCartesianAxisControl=gt;exports.JoggingJointValueControl=qt;exports.JoggingPanel=To;exports.JoggingStore=K;exports.LoadingCover=Wt;exports.LoadingErrorMessage=Ht;exports.MOTION_DELTA_THRESHOLD=vt;exports.MotionStreamConnection=ot;exports.NoMotionGroupModal=Oo;exports.ROBOT_LOAD_STEP_IDS=ce;exports.RobotDescription=ge;exports.RobotLiveState=ue;exports.RobotLoadProgress=le;exports.RobotLoadStepError=_t;exports.RobotSafety=he;exports.RobotSession=fe;exports.RobotSessionLoad=ye;exports.RobotTargetPose=me;exports.TrajectoryExecutionStore=de;exports.VelocitySlider=ee;exports.VelocitySliderLabel=xt;exports.controllerStateWebsocket=re;exports.deriveSelectedTcpPose=ht;exports.isRobotLoadStepError=st;exports.jointValuesEqual=et;exports.jointValuesUnchanged=ft;exports.loadRobotSession=Qo;exports.planErrorTranslationKey=se;exports.poseEqual=zt;exports.readoutOf=jt;exports.readoutsEqual=bt;exports.resolveCoordinateSystemInWorld=Zt;exports.tcpMotionEqual=yt;exports.trajectoryTargetOf=pe;exports.transformPoseToCoordinateSystem=X;exports.unwrapRotationVector=St;
|