@wandelbots/wandelbots-js-react-components 6.4.0-pr.revamp.667.bd2ec84 → 6.4.0-pr.revamp.667.ca77f09

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/README.md +172 -40
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +3 -4
  4. package/dist/3d.js +35 -38
  5. package/dist/CurrentPose/index.cjs +1 -1
  6. package/dist/CurrentPose/index.js +2 -2
  7. package/dist/CurrentPoseBar/index.cjs +1 -1
  8. package/dist/CurrentPoseBar/index.js +1 -1
  9. package/dist/JoggingButtons/index.cjs +1 -1
  10. package/dist/JoggingButtons/index.js +1 -1
  11. package/dist/JoggingGizmo/index.cjs +1 -1
  12. package/dist/JoggingGizmo/index.js +2 -2
  13. package/dist/JoggingJointSlider/index.cjs +1 -1
  14. package/dist/JoggingJointSlider/index.js +1 -1
  15. package/dist/RobotControl/index.cjs +1 -1
  16. package/dist/RobotControl/index.js +2 -2
  17. package/dist/RobotControlPanel/index.cjs +1 -1
  18. package/dist/RobotControlPanel/index.d.ts +1 -1
  19. package/dist/RobotControlPanel/index.js +1 -1
  20. package/dist/RobotHeader/index.cjs +1 -1
  21. package/dist/RobotHeader/index.d.ts +3 -5
  22. package/dist/RobotHeader/index.js +6 -7
  23. package/dist/RobotScene/index.cjs +1 -1
  24. package/dist/RobotScene/index.js +3 -3
  25. package/dist/RobotView/index.cjs +1 -1
  26. package/dist/RobotView/index.js +2 -2
  27. package/dist/SafetyBar/IndicatorWithExplanation.d.ts +12 -1
  28. package/dist/SafetyBar/SafetyBar.d.ts +15 -1
  29. package/dist/SafetyBar/index.cjs +1 -1
  30. package/dist/SafetyBar/index.d.ts +0 -1
  31. package/dist/SafetyBar/index.js +3 -4
  32. package/dist/SafetyBar/robotSafetyOf.d.ts +1 -0
  33. package/dist/chunks/{ConnectedMotionGroup-BifrgwV1.js → ConnectedMotionGroup-DNYakgxy.js} +6 -5
  34. package/dist/chunks/ConnectedMotionGroup-IRTsTxwB.cjs +3 -0
  35. package/dist/chunks/{CurrentPose-CMqO8oqX.cjs → CurrentPose-CAq9e9JY.cjs} +1 -1
  36. package/dist/chunks/{CurrentPose-CdD2ZB7B.js → CurrentPose-CgdINEh2.js} +3 -3
  37. package/dist/chunks/{CurrentPoseBar-CX1xFBtm.js → CurrentPoseBar--HkZBGnN.js} +11 -11
  38. package/dist/chunks/{CurrentPoseBar-BTBAwIO4.cjs → CurrentPoseBar-DoOUfRRs.cjs} +1 -1
  39. package/dist/chunks/{JoggingButtons-aijK-3g6.js → JoggingButtons-BNOnpcTH.js} +1 -1
  40. package/dist/chunks/{JoggingButtons-BOHl7hVq.cjs → JoggingButtons-Boaym2hQ.cjs} +1 -1
  41. package/dist/chunks/{JoggingGizmo-CoKYUtXq.cjs → JoggingGizmo-CNFjpWDv.cjs} +1 -1
  42. package/dist/chunks/{JoggingGizmo-DHvrJouR.js → JoggingGizmo-RDiEVQes.js} +1 -1
  43. package/dist/chunks/{JoggingGizmoOrientation-CIvIAIeO.js → JoggingGizmoOrientation-Dzzz2gEz.js} +1 -1
  44. package/dist/chunks/{JoggingGizmoOrientation-DVcagPRJ.cjs → JoggingGizmoOrientation-laUrgY0N.cjs} +1 -1
  45. package/dist/chunks/{JoggingJointSlider-DQtt4-pa.js → JoggingJointSlider-BY-Tof8G.js} +1 -1
  46. package/dist/chunks/{JoggingJointSlider-CTFYKzsU.cjs → JoggingJointSlider-Dm3vILd3.cjs} +1 -1
  47. package/dist/chunks/{JoggingRefusedError-BIkUM6-g.js → JoggingRefusedError-C4D8_YR_.js} +5 -3
  48. package/dist/chunks/JoggingRefusedError-DqyrfUcc.cjs +1 -0
  49. package/dist/chunks/Pose3-BfBNPRDM.cjs +1 -0
  50. package/dist/chunks/{Pose3-B_fLR-Wv.js → Pose3-DWxfC6Dj.js} +1 -2
  51. package/dist/chunks/{Robot-C-IWfxP9.js → Robot-B-VAYuAr.js} +5 -5
  52. package/dist/chunks/{Robot-Cfhjv9Z8.cjs → Robot-DRf8T9Zf.cjs} +1 -1
  53. package/dist/chunks/RobotActivation-CRVxXvlx.cjs +1 -0
  54. package/dist/chunks/RobotActivation-oR-8Y0iq.js +143 -0
  55. package/dist/chunks/RobotControl-Dbe50ZKM.cjs +1 -0
  56. package/dist/chunks/RobotControl-Ms1F7fFe.js +332 -0
  57. package/dist/chunks/RobotControlPanel-B7NxoHsO.cjs +1 -0
  58. package/dist/chunks/RobotControlPanel-CkQlkq8x.js +1029 -0
  59. package/dist/chunks/RobotHeader-CjOaf9s6.cjs +1 -0
  60. package/dist/chunks/RobotHeader-LSuRTDFB.js +395 -0
  61. package/dist/chunks/RobotScene-Au6zpHH1.cjs +1 -0
  62. package/dist/chunks/RobotScene-C6XEgaVR.js +1284 -0
  63. package/dist/chunks/RobotSessionProvider-CoF_tX0O.cjs +1 -0
  64. package/dist/chunks/RobotSessionProvider-DuHi-dtw.js +30 -0
  65. package/dist/chunks/{RobotView-BGYlAWj-.cjs → RobotView-Cg6JfGiY.cjs} +1 -1
  66. package/dist/chunks/{RobotView-D-v8jCM7.js → RobotView-CrAxNkyG.js} +3 -3
  67. package/dist/chunks/{robotSafetyOf-DuKKma1_.js → SafetyBar-C85BAKsL.js} +244 -215
  68. package/dist/chunks/SafetyBar-D2l81Omq.cjs +1 -0
  69. package/dist/chunks/externalizeComponent-CA_sHzyH.cjs +2 -0
  70. package/dist/chunks/{externalizeComponent-4juwPKL5.js → externalizeComponent-CChY_1bN.js} +34 -8
  71. package/dist/chunks/{useSmoothedMotionState-BSSV8aZN.js → hooks-BWoeBWLV.js} +43 -87
  72. package/dist/chunks/hooks-BXe2bNMo.cjs +1 -0
  73. package/dist/chunks/loadRobotSession-BzY9H3F8.cjs +1 -0
  74. package/dist/chunks/{loadRobotSession-GHHtv5dv.js → loadRobotSession-Ts2MumBB.js} +1065 -679
  75. package/dist/chunks/poseText-BxG4Caa-.js +48 -0
  76. package/dist/chunks/poseText-CwplkbDM.cjs +1 -0
  77. package/dist/chunks/useSmoothedMotionState-CCXmMZ0S.cjs +1 -0
  78. package/dist/chunks/useSmoothedMotionState-CELh-YJa.js +50 -0
  79. package/dist/components/VelocitySlider.d.ts +14 -1
  80. package/dist/components/connectionWarning/ConnectionWarning.d.ts +18 -4
  81. package/dist/components/connectionWarning/connectionWarningOf.d.ts +1 -11
  82. package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +7 -1
  83. package/dist/components/jogging/JoggingCartesianTab.d.ts +6 -0
  84. package/dist/components/jogging/JoggingJointTab.d.ts +5 -0
  85. package/dist/components/jogging/JoggingJointValueControl.d.ts +7 -1
  86. package/dist/components/jogging/JoggingPanel.d.ts +11 -0
  87. package/dist/components/jogging/JoggingRefusedError.d.ts +8 -3
  88. package/dist/components/jogging/JoggingStore.d.ts +206 -17
  89. package/dist/components/jogging/joggingColors.d.ts +6 -0
  90. package/dist/components/robotControl/CartesianJogTab.d.ts +14 -3
  91. package/dist/components/robotControl/JogArea.d.ts +6 -3
  92. package/dist/components/robotControl/JogDisabledReason.d.ts +15 -0
  93. package/dist/components/robotControl/JointJogTab.d.ts +10 -2
  94. package/dist/components/robotControl/MoveToTab.d.ts +24 -3
  95. package/dist/components/robotControl/PoseField.d.ts +3 -1
  96. package/dist/components/robotControl/RobotControl.d.ts +3 -0
  97. package/dist/components/robotControl/RobotControlPanel.d.ts +91 -22
  98. package/dist/components/robotControl/VelocityRow.d.ts +8 -2
  99. package/dist/components/robotControl/atPose.d.ts +6 -0
  100. package/dist/components/robotControl/poseText.d.ts +13 -1
  101. package/dist/components/robotControl/units.d.ts +10 -2
  102. package/dist/components/robotControl/useRobotControlProps.d.ts +7 -4
  103. package/dist/components/robotControl/velocityText.d.ts +18 -0
  104. package/dist/components/robotHeader/ActivationSwitch.d.ts +13 -2
  105. package/dist/components/robotHeader/RobotHeader.d.ts +25 -4
  106. package/dist/components/robotHeader/robotActivationOf.d.ts +1 -8
  107. package/dist/components/robotScene/RobotScene.d.ts +7 -1
  108. package/dist/components/robots/MotionGroupVisualizer.d.ts +6 -4
  109. package/dist/components/robots/SupportedLinearAxis.d.ts +6 -4
  110. package/dist/components/robots/SupportedRobot.d.ts +7 -5
  111. package/dist/components/robots/useFrameSmoothedMotionState.d.ts +25 -0
  112. package/dist/components/utils/useSmoothedMotionState.d.ts +11 -2
  113. package/dist/core.cjs +1 -1
  114. package/dist/core.d.ts +8 -10
  115. package/dist/core.js +60 -69
  116. package/dist/index.cjs +1 -1
  117. package/dist/index.js +100 -113
  118. package/dist/lib/ConnectedMotionGroup.d.ts +11 -0
  119. package/dist/lib/ControllerStateStream.d.ts +9 -9
  120. package/dist/lib/JoggerConnection.d.ts +48 -13
  121. package/dist/lib/MotionStreamConnection.d.ts +3 -2
  122. package/dist/lib/TrajectoryExecutionStore.d.ts +58 -20
  123. package/dist/lib/controllerStateSource.d.ts +6 -5
  124. package/dist/lib/robotSession/RobotActivation.d.ts +52 -21
  125. package/dist/lib/robotSession/RobotSession.d.ts +27 -8
  126. package/dist/lib/robotSession/RobotTargetPose.d.ts +4 -2
  127. package/dist/lib/robotSession/loadRobotSession.d.ts +1 -1
  128. package/dist/lib/robotSession/robotPose.d.ts +0 -6
  129. package/dist/session.cjs +1 -1
  130. package/dist/session.d.ts +6 -6
  131. package/dist/session.js +30 -38
  132. package/package.json +22 -1
  133. package/dist/chunks/ConnectedMotionGroup-CybwJHkh.cjs +0 -3
  134. package/dist/chunks/JoggingRefusedError-BuCGsVsa.cjs +0 -1
  135. package/dist/chunks/Pose3-Ch4xVeXV.cjs +0 -1
  136. package/dist/chunks/RobotActivation-Bb0oNSBN.cjs +0 -1
  137. package/dist/chunks/RobotActivation-C0rrwpQZ.js +0 -115
  138. package/dist/chunks/RobotControl-Cv6Sr1Ni.js +0 -289
  139. package/dist/chunks/RobotControl-DFnOYMAa.cjs +0 -1
  140. package/dist/chunks/RobotControlPanel-B1_9g9D-.js +0 -850
  141. package/dist/chunks/RobotControlPanel-BpTpRBgy.cjs +0 -1
  142. package/dist/chunks/RobotScene-0ZJzXL50.cjs +0 -1
  143. package/dist/chunks/RobotScene-DpFeFpnx.js +0 -1255
  144. package/dist/chunks/RobotSessionProvider--AekyPqD.cjs +0 -1
  145. package/dist/chunks/RobotSessionProvider-TVaKGzqa.js +0 -25
  146. package/dist/chunks/externalizeComponent-Br_U-QAr.cjs +0 -2
  147. package/dist/chunks/loadRobotSession-DYbeNnTI.cjs +0 -1
  148. package/dist/chunks/poseText-BXUaQWnK.cjs +0 -1
  149. package/dist/chunks/poseText-pg4cxE8R.js +0 -41
  150. package/dist/chunks/robotActivationOf-B4oV10Za.cjs +0 -1
  151. package/dist/chunks/robotActivationOf-EzcT9g07.js +0 -368
  152. package/dist/chunks/robotSafetyOf-Dxm6s7Pp.cjs +0 -1
  153. package/dist/chunks/useSmoothedMotionState-B9WO73k0.cjs +0 -1
  154. package/dist/components/robotHeader/robotSafetyOf.d.ts +0 -11
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react/jsx-runtime"),p=require("@mui/material/Box"),W=require("@mui/material/Paper"),y=require("@mui/material/Tooltip"),h=require("@mui/material/Typography"),B=require("@wandelbots/icons/WifiOff"),I=require("mobx-react-lite"),x=require("react"),b=require("react-i18next"),v=require("./externalizeComponent-CA_sHzyH.cjs"),w=require("./RobotSessionProvider-CoF_tX0O.cjs"),u=require("@mui/material/Stack"),q=require("./SafetyBar-D2l81Omq.cjs"),z=require("./SmallSelect-Dcsd7_6_.cjs"),M=require("@mui/material/CircularProgress"),k=require("@mui/material/Switch"),O=require("./RobotActivation-CRVxXvlx.cjs"),E=require("@mui/icons-material/Apps"),C=require("@mui/material/Button"),H=require("@mui/material/ButtonGroup"),P=require("@mui/material/Menu"),F=require("@mui/material/MenuItem"),D=require("@wandelbots/design-tokens"),N=require("@wandelbots/icons/SearchFilled");function L(i){const{connectionQuality:t,lastValidStateMessage:o,lastInvalidStateMessage:n}=i.state;return{quality:t,lastMessageAt:o.receivedAt,lastInvalidMessage:n}}const U=[["day",86400],["hour",3600],["minute",60],["second",1]];function G(i,t,o){const n=Math.max(0,Math.floor((t-i)/1e3)),[s,a]=U.find(([,c])=>n>=c)??["second",1];return new Intl.RelativeTimeFormat(o,{numeric:"auto"}).format(-Math.floor(n/a),s)}function V(i){const[t,o]=x.useState(Date.now);return x.useEffect(()=>{if(!i)return;o(Date.now());const n=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(n)},[i]),t}const Y=v.externalizeComponent(I.observer(function({session:t,...o}){const n=w.useOptionalRobotSessionOf(t),{quality:s,lastMessageAt:a,lastInvalidMessage:c}={...n&&L(n),...o};return s===void 0||a===void 0?null:e.jsx(_,{quality:s,lastMessageAt:a,lastInvalidMessage:c})}));function _({quality:i,lastMessageAt:t,lastInvalidMessage:o}){const{t:n,i18n:s}=b.useTranslation(),a=i==="critical",c=V(a);if(!a)return null;const l=r=>G(r,c,s.language),d=o&&o.receivedAt>t?o:null;return e.jsx(y,{placement:"bottom-end",slotProps:{popper:{sx:{[`& .${y.tooltipClasses.tooltip}`]:{maxWidth:"340px",padding:0,maxHeight:"80vh",overflowY:"auto",borderRadius:"10px",border:1,borderColor:"divider"}}}},title:e.jsxs(W,{elevation:8,sx:{padding:"14px"},children:[e.jsx(h,{fontSize:"14px",children:n("ConnectionWarning.LastUpdate.lb",{time:l(t)})}),d&&e.jsxs(h,{fontSize:"14px",marginTop:"1rem",children:[n("ConnectionWarning.ErrorState.lb",{time:l(d.receivedAt)}),e.jsx("pre",{style:{fontSize:"12px",whiteSpace:"pre-wrap",wordWrap:"break-word",margin:"4px 0 0"},children:String(d.data)})]})]}),children:e.jsx(p,{component:"span",role:"img","aria-label":n("ConnectionWarning.Interrupted.ti"),sx:{display:"inline-flex",cursor:"pointer",color:"error.main"},children:e.jsx(B.WifiOff,{size:20})})})}function Q(i){return{state:i.activation.state,disabled:!i.safety.canBeActive,onToggle:()=>{i.activation.toggle().catch(t=>{i.reportError({kind:"mode",message:t instanceof Error?t.message:String(t),url:t instanceof O.RobotModeChangeError?t.url:void 0,cause:t})})}}}const m=v.externalizeComponent(I.observer(function(t){const o=w.useOptionalRobotSessionOf("session"in t?t.session:void 0),n="session"in t?o&&Q(o):t;return n?e.jsx($,{...n}):null}));function $({state:i,disabled:t=!1,onToggle:o}){const{t:n}=b.useTranslation(),s=x.useId(),a=i==="activating"||i==="deactivating",c={inactive:n("SafetyBar.ActivationToggle.Activate.bt"),activating:n("SafetyBar.ActivationToggle.Activating.bt"),active:n("SafetyBar.ActivationToggle.Activated.bt"),deactivating:n("SafetyBar.ActivationToggle.Deactivating.bt")}[i];return e.jsxs(u,{direction:"row","data-testid":"robot-activation",sx:{gap:"4px",alignItems:"center"},children:[e.jsx(k,{size:"small",checked:i==="active"||i==="deactivating",disabled:a||t,onChange:()=>o(),slotProps:{input:{role:"switch","aria-labelledby":s}}}),e.jsx(h,{id:s,variant:"body2",color:"text.secondary",noWrap:!0,sx:{letterSpacing:"0.17px"},children:c}),a&&e.jsx(M,{size:16})]})}const A={minWidth:0,padding:"4px 10px",color:"text.primary","& svg":{width:"16px",height:"16px"}};function J({appIcon:i,appName:t,apps:o,onAppSelect:n,onSearch:s}){const{t:a}=b.useTranslation(),[c,l]=x.useState(null);function d(r){l(null),r.onClick?r.onClick():r.href&&(window.location.href=r.href),n==null||n(r)}return e.jsxs(u,{direction:"row",sx:{gap:"8px",alignItems:"center"},children:[e.jsxs(H,{variant:"outlined",color:"secondary",sx:r=>({borderRadius:"10px",boxShadow:r.shadows[2],"& .MuiButtonGroup-grouped":{borderColor:r.palette.divider}}),children:[e.jsx(C,{"aria-label":a("RobotHeader.Apps.bt"),"aria-haspopup":"menu","aria-expanded":c!==null,disabled:o.length===0,onClick:r=>l(r.currentTarget),sx:A,children:e.jsx(E,{})}),s&&e.jsx(C,{"aria-label":a("RobotHeader.Search.bt"),onClick:s,sx:A,children:e.jsx(N.SearchFilled,{})})]}),e.jsxs(u,{direction:"row",sx:{gap:"4px",alignItems:"center"},children:[i&&e.jsx(p,{sx:{display:"flex","& svg":{width:"25px",height:"25px"}},children:i}),e.jsx(h,{component:"h1",noWrap:!0,sx:{fontFamily:D.FontFamilyBrand,fontWeight:700,fontSize:"16px",letterSpacing:"0.24px"},children:t})]}),e.jsx(P,{anchorEl:c,open:c!==null,onClose:()=>l(null),sx:{"& .MuiPaper-root":{minWidth:200,mt:1}},children:o.map(r=>e.jsxs(F,{onClick:()=>d(r),children:[r.icon&&e.jsx(p,{sx:{display:"flex",alignItems:"center",mr:2},children:r.icon}),r.name]},r.id))})]})}const K={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},X=v.externalizeComponent(({appIcon:i,appName:t,apps:o=[],onAppSelect:n,onSearch:s,motionGroup:a,session:c,safety:l,activation:d,actions:r,sx:f})=>{const{t:R}=b.useTranslation(),j=x.useId(),g=w.useOptionalRobotSessionOf(c);return e.jsxs(u,{component:"header",direction:"row","data-testid":"robot-header",sx:[T=>{var S;return{alignItems:"center",justifyContent:"space-between",gap:"24px",padding:"8px 24px",minHeight:"52px",boxSizing:"border-box",background:(S=T.palette.backgroundPaperElevation)==null?void 0:S[1]}},...Array.isArray(f)?f:[f]],children:[e.jsx(J,{appIcon:i,appName:t,apps:o,onAppSelect:n,onSearch:s}),e.jsxs(u,{direction:"row",sx:{gap:"20px",alignItems:"center"},children:[a&&e.jsxs(e.Fragment,{children:[e.jsx(p,{component:"span",id:j,sx:K,children:R("RobotHeader.MotionGroup.lb")}),e.jsx(z.SmallSelect,{labelId:j,width:"240px",...a})]}),l?e.jsx(q.SafetyBar,{...l}):g&&e.jsx(q.SafetyBar,{session:g}),d?e.jsx(m,{...d}):g&&e.jsx(m,{session:g})]}),e.jsx(u,{direction:"row",sx:{gap:"24px",alignItems:"center"},children:r})]})});exports.ActivationSwitch=m;exports.ConnectionWarning=Y;exports.RobotHeader=X;
@@ -0,0 +1,395 @@
1
+ import { jsx as e, jsxs as s, Fragment as R } from "react/jsx-runtime";
2
+ import u from "@mui/material/Box";
3
+ import z from "@mui/material/Paper";
4
+ import E, { tooltipClasses as H } from "@mui/material/Tooltip";
5
+ import f from "@mui/material/Typography";
6
+ import { WifiOff as O } from "@wandelbots/icons/WifiOff";
7
+ import { observer as W } from "mobx-react-lite";
8
+ import { useState as T, useEffect as P, useId as M } from "react";
9
+ import { useTranslation as h } from "react-i18next";
10
+ import { e as b } from "./externalizeComponent-CChY_1bN.js";
11
+ import { b as v } from "./RobotSessionProvider-DuHi-dtw.js";
12
+ import p from "@mui/material/Stack";
13
+ import { S as y } from "./SafetyBar-C85BAKsL.js";
14
+ import { S as D } from "./SmallSelect-BdD9uLKK.js";
15
+ import F from "@mui/material/CircularProgress";
16
+ import N from "@mui/material/Switch";
17
+ import { a as U } from "./RobotActivation-oR-8Y0iq.js";
18
+ import G from "@mui/icons-material/Apps";
19
+ import A from "@mui/material/Button";
20
+ import L from "@mui/material/ButtonGroup";
21
+ import V from "@mui/material/Menu";
22
+ import j from "@mui/material/MenuItem";
23
+ import { FontFamilyBrand as q } from "@wandelbots/design-tokens";
24
+ import { SearchFilled as Y } from "@wandelbots/icons/SearchFilled";
25
+ function _(o) {
26
+ const { connectionQuality: t, lastValidStateMessage: i, lastInvalidStateMessage: n } = o.state;
27
+ return {
28
+ quality: t,
29
+ lastMessageAt: i.receivedAt,
30
+ lastInvalidMessage: n
31
+ };
32
+ }
33
+ const Q = [
34
+ ["day", 86400],
35
+ ["hour", 3600],
36
+ ["minute", 60],
37
+ ["second", 1]
38
+ ];
39
+ function $(o, t, i) {
40
+ const n = Math.max(0, Math.floor((t - o) / 1e3)), [c, a] = Q.find(([, l]) => n >= l) ?? [
41
+ "second",
42
+ 1
43
+ ];
44
+ return new Intl.RelativeTimeFormat(i, { numeric: "auto" }).format(
45
+ -Math.floor(n / a),
46
+ c
47
+ );
48
+ }
49
+ function J(o) {
50
+ const [t, i] = T(Date.now);
51
+ return P(() => {
52
+ if (!o) return;
53
+ i(Date.now());
54
+ const n = setInterval(() => i(Date.now()), 1e3);
55
+ return () => clearInterval(n);
56
+ }, [o]), t;
57
+ }
58
+ const Wt = b(
59
+ W(function({
60
+ session: t,
61
+ ...i
62
+ }) {
63
+ const n = v(t), { quality: c, lastMessageAt: a, lastInvalidMessage: l } = {
64
+ ...n && _(n),
65
+ ...i
66
+ };
67
+ return c === void 0 || a === void 0 ? null : /* @__PURE__ */ e(
68
+ K,
69
+ {
70
+ quality: c,
71
+ lastMessageAt: a,
72
+ lastInvalidMessage: l
73
+ }
74
+ );
75
+ })
76
+ );
77
+ function K({
78
+ quality: o,
79
+ lastMessageAt: t,
80
+ lastInvalidMessage: i
81
+ }) {
82
+ const { t: n, i18n: c } = h(), a = o === "critical", l = J(a);
83
+ if (!a) return null;
84
+ const d = (r) => $(r, l, c.language), m = i && i.receivedAt > t ? i : null;
85
+ return /* @__PURE__ */ e(
86
+ E,
87
+ {
88
+ placement: "bottom-end",
89
+ slotProps: {
90
+ popper: {
91
+ sx: {
92
+ [`& .${H.tooltip}`]: {
93
+ maxWidth: "340px",
94
+ padding: 0,
95
+ maxHeight: "80vh",
96
+ overflowY: "auto",
97
+ borderRadius: "10px",
98
+ border: 1,
99
+ borderColor: "divider"
100
+ }
101
+ }
102
+ }
103
+ },
104
+ title: /* @__PURE__ */ s(z, { elevation: 8, sx: { padding: "14px" }, children: [
105
+ /* @__PURE__ */ e(f, { fontSize: "14px", children: n("ConnectionWarning.LastUpdate.lb", {
106
+ time: d(t)
107
+ }) }),
108
+ m && /* @__PURE__ */ s(f, { fontSize: "14px", marginTop: "1rem", children: [
109
+ n("ConnectionWarning.ErrorState.lb", {
110
+ time: d(m.receivedAt)
111
+ }),
112
+ /* @__PURE__ */ e(
113
+ "pre",
114
+ {
115
+ style: {
116
+ fontSize: "12px",
117
+ whiteSpace: "pre-wrap",
118
+ wordWrap: "break-word",
119
+ margin: "4px 0 0"
120
+ },
121
+ children: String(m.data)
122
+ }
123
+ )
124
+ ] })
125
+ ] }),
126
+ children: /* @__PURE__ */ e(
127
+ u,
128
+ {
129
+ component: "span",
130
+ role: "img",
131
+ "aria-label": n("ConnectionWarning.Interrupted.ti"),
132
+ sx: {
133
+ display: "inline-flex",
134
+ cursor: "pointer",
135
+ color: "error.main"
136
+ },
137
+ children: /* @__PURE__ */ e(O, { size: 20 })
138
+ }
139
+ )
140
+ }
141
+ );
142
+ }
143
+ function X(o) {
144
+ return {
145
+ state: o.activation.state,
146
+ disabled: !o.safety.canBeActive,
147
+ onToggle: () => {
148
+ o.activation.toggle().catch((t) => {
149
+ o.reportError({
150
+ kind: "mode",
151
+ message: t instanceof Error ? t.message : String(t),
152
+ url: t instanceof U ? t.url : void 0,
153
+ cause: t
154
+ });
155
+ });
156
+ }
157
+ };
158
+ }
159
+ const C = b(
160
+ W(function(t) {
161
+ const i = v(
162
+ "session" in t ? t.session : void 0
163
+ ), n = "session" in t ? i && X(i) : t;
164
+ return n ? /* @__PURE__ */ e(Z, { ...n }) : null;
165
+ })
166
+ );
167
+ function Z({
168
+ state: o,
169
+ disabled: t = !1,
170
+ onToggle: i
171
+ }) {
172
+ const { t: n } = h(), c = M(), a = o === "activating" || o === "deactivating", l = {
173
+ inactive: n("SafetyBar.ActivationToggle.Activate.bt"),
174
+ activating: n("SafetyBar.ActivationToggle.Activating.bt"),
175
+ active: n("SafetyBar.ActivationToggle.Activated.bt"),
176
+ deactivating: n("SafetyBar.ActivationToggle.Deactivating.bt")
177
+ }[o];
178
+ return /* @__PURE__ */ s(
179
+ p,
180
+ {
181
+ direction: "row",
182
+ "data-testid": "robot-activation",
183
+ sx: { gap: "4px", alignItems: "center" },
184
+ children: [
185
+ /* @__PURE__ */ e(
186
+ N,
187
+ {
188
+ size: "small",
189
+ checked: o === "active" || o === "deactivating",
190
+ disabled: a || t,
191
+ onChange: () => i(),
192
+ slotProps: { input: { role: "switch", "aria-labelledby": c } }
193
+ }
194
+ ),
195
+ /* @__PURE__ */ e(
196
+ f,
197
+ {
198
+ id: c,
199
+ variant: "body2",
200
+ color: "text.secondary",
201
+ noWrap: !0,
202
+ sx: { letterSpacing: "0.17px" },
203
+ children: l
204
+ }
205
+ ),
206
+ a && /* @__PURE__ */ e(F, { size: 16 })
207
+ ]
208
+ }
209
+ );
210
+ }
211
+ const I = {
212
+ minWidth: 0,
213
+ padding: "4px 10px",
214
+ color: "text.primary",
215
+ "& svg": { width: "16px", height: "16px" }
216
+ };
217
+ function tt({
218
+ appIcon: o,
219
+ appName: t,
220
+ apps: i,
221
+ onAppSelect: n,
222
+ onSearch: c
223
+ }) {
224
+ const { t: a } = h(), [l, d] = T(null);
225
+ function m(r) {
226
+ d(null), r.onClick ? r.onClick() : r.href && (window.location.href = r.href), n == null || n(r);
227
+ }
228
+ return /* @__PURE__ */ s(p, { direction: "row", sx: { gap: "8px", alignItems: "center" }, children: [
229
+ /* @__PURE__ */ s(
230
+ L,
231
+ {
232
+ variant: "outlined",
233
+ color: "secondary",
234
+ sx: (r) => ({
235
+ borderRadius: "10px",
236
+ boxShadow: r.shadows[2],
237
+ "& .MuiButtonGroup-grouped": { borderColor: r.palette.divider }
238
+ }),
239
+ children: [
240
+ /* @__PURE__ */ e(
241
+ A,
242
+ {
243
+ "aria-label": a("RobotHeader.Apps.bt"),
244
+ "aria-haspopup": "menu",
245
+ "aria-expanded": l !== null,
246
+ disabled: i.length === 0,
247
+ onClick: (r) => d(r.currentTarget),
248
+ sx: I,
249
+ children: /* @__PURE__ */ e(G, {})
250
+ }
251
+ ),
252
+ c && /* @__PURE__ */ e(
253
+ A,
254
+ {
255
+ "aria-label": a("RobotHeader.Search.bt"),
256
+ onClick: c,
257
+ sx: I,
258
+ children: /* @__PURE__ */ e(Y, {})
259
+ }
260
+ )
261
+ ]
262
+ }
263
+ ),
264
+ /* @__PURE__ */ s(p, { direction: "row", sx: { gap: "4px", alignItems: "center" }, children: [
265
+ o && /* @__PURE__ */ e(
266
+ u,
267
+ {
268
+ sx: {
269
+ display: "flex",
270
+ "& svg": { width: "25px", height: "25px" }
271
+ },
272
+ children: o
273
+ }
274
+ ),
275
+ /* @__PURE__ */ e(
276
+ f,
277
+ {
278
+ component: "h1",
279
+ noWrap: !0,
280
+ sx: {
281
+ fontFamily: q,
282
+ fontWeight: 700,
283
+ fontSize: "16px",
284
+ letterSpacing: "0.24px"
285
+ },
286
+ children: t
287
+ }
288
+ )
289
+ ] }),
290
+ /* @__PURE__ */ e(
291
+ V,
292
+ {
293
+ anchorEl: l,
294
+ open: l !== null,
295
+ onClose: () => d(null),
296
+ sx: { "& .MuiPaper-root": { minWidth: 200, mt: 1 } },
297
+ children: i.map((r) => /* @__PURE__ */ s(j, { onClick: () => m(r), children: [
298
+ r.icon && /* @__PURE__ */ e(u, { sx: { display: "flex", alignItems: "center", mr: 2 }, children: r.icon }),
299
+ r.name
300
+ ] }, r.id))
301
+ }
302
+ )
303
+ ] });
304
+ }
305
+ const nt = {
306
+ position: "absolute",
307
+ width: "1px",
308
+ height: "1px",
309
+ margin: "-1px",
310
+ padding: 0,
311
+ overflow: "hidden",
312
+ clip: "rect(0 0 0 0)",
313
+ whiteSpace: "nowrap",
314
+ border: 0
315
+ }, Tt = b(
316
+ ({
317
+ appIcon: o,
318
+ appName: t,
319
+ apps: i = [],
320
+ onAppSelect: n,
321
+ onSearch: c,
322
+ motionGroup: a,
323
+ session: l,
324
+ safety: d,
325
+ activation: m,
326
+ actions: r,
327
+ sx: x
328
+ }) => {
329
+ const { t: B } = h(), w = M(), g = v(l);
330
+ return /* @__PURE__ */ s(
331
+ p,
332
+ {
333
+ component: "header",
334
+ direction: "row",
335
+ "data-testid": "robot-header",
336
+ sx: [
337
+ (k) => {
338
+ var S;
339
+ return {
340
+ alignItems: "center",
341
+ justifyContent: "space-between",
342
+ gap: "24px",
343
+ padding: "8px 24px",
344
+ minHeight: "52px",
345
+ boxSizing: "border-box",
346
+ background: (S = k.palette.backgroundPaperElevation) == null ? void 0 : S[1]
347
+ };
348
+ },
349
+ ...Array.isArray(x) ? x : [x]
350
+ ],
351
+ children: [
352
+ /* @__PURE__ */ e(
353
+ tt,
354
+ {
355
+ appIcon: o,
356
+ appName: t,
357
+ apps: i,
358
+ onAppSelect: n,
359
+ onSearch: c
360
+ }
361
+ ),
362
+ /* @__PURE__ */ s(p, { direction: "row", sx: { gap: "20px", alignItems: "center" }, children: [
363
+ a && /* @__PURE__ */ s(R, { children: [
364
+ /* @__PURE__ */ e(
365
+ u,
366
+ {
367
+ component: "span",
368
+ id: w,
369
+ sx: nt,
370
+ children: B("RobotHeader.MotionGroup.lb")
371
+ }
372
+ ),
373
+ /* @__PURE__ */ e(
374
+ D,
375
+ {
376
+ labelId: w,
377
+ width: "240px",
378
+ ...a
379
+ }
380
+ )
381
+ ] }),
382
+ d ? /* @__PURE__ */ e(y, { ...d }) : g && /* @__PURE__ */ e(y, { session: g }),
383
+ m ? /* @__PURE__ */ e(C, { ...m }) : g && /* @__PURE__ */ e(C, { session: g })
384
+ ] }),
385
+ /* @__PURE__ */ e(p, { direction: "row", sx: { gap: "24px", alignItems: "center" }, children: r })
386
+ ]
387
+ }
388
+ );
389
+ }
390
+ );
391
+ export {
392
+ C as A,
393
+ Wt as C,
394
+ Tt as R
395
+ };
@@ -0,0 +1 @@
1
+ "use strict";const r=require("react/jsx-runtime"),ye=require("mobx-react-lite"),ge=require("./RobotSessionProvider-CoF_tX0O.cjs"),je=require("@mui/material/styles"),u=require("react"),T=require("@react-three/drei"),R=require("three"),D=require("three-stdlib"),_=require("@wandelbots/nova-js/v2"),E=require("./externalizeComponent-CA_sHzyH.cjs"),X=require("react-error-boundary"),O=require("@react-three/fiber"),L=require("./hooks-BXe2bNMo.cjs"),F=require("./PoseTransformer-2QIzECOZ.cjs"),G=require("./Pose3-BfBNPRDM.cjs"),M=require("mobx");function Re(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const w=Re(R);function Y(){return r.jsx(T.Environment,{frames:1,children:r.jsx(we,{})})}const be=[2,0,2,0,2,0,2,0];function we({positions:e=be}){return r.jsxs(r.Fragment,{children:[r.jsx(T.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),r.jsx("group",{rotation:[0,.5,0],children:r.jsx("group",{children:e.map((n,t)=>r.jsx(T.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,t*4],scale:[3,1,1]},t))})}),r.jsx(T.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),r.jsx(T.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),r.jsx(T.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),r.jsx(T.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),r.jsx(T.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}function ve(e){const n=e.length(),t=new w.Quaternion;if(n>1e-6){const o=e.clone().normalize();t.setFromAxisAngle(o,n)}return t}function Se(e){if(!e||e.length===0)return 5;const o=e.reduce((s,c)=>s+Math.abs(c.a??0)/1e3+Math.abs(c.d??0)/1e3,0)*2;return!Number.isFinite(o)||o<=0?5:o}function Te(e){if(e.length<3)return console.log("Not enough vertices to define a plane"),{isCoplanar:!1};const n=new w.Vector3(e[0].x,e[0].y,e[0].z),t=new w.Vector3(e[1].x,e[1].y,e[1].z),o=new w.Vector3(e[2].x,e[2].y,e[2].z),s=new w.Vector3().subVectors(t,n),c=new w.Vector3().subVectors(o,n),l=new w.Vector3().crossVectors(s,c).normalize();for(let i=3;i<e.length;i++){const m=new w.Vector3(e[i].x,e[i].y,e[i].z),f=new w.Vector3().subVectors(m,n),d=l.dot(f);if(Math.abs(d)>1e-6)return console.log("Vertices are not on the same plane"),{isCoplanar:!1}}return{isCoplanar:!0,normal:l}}const $={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function Z({safetyZones:e,dhParameters:n,...t}){const o=u.useMemo(()=>Se(n??[]),[n]),s=(l,i)=>{var y,g;if(!((y=i==null?void 0:i.pose)!=null&&y.position)||!((g=i==null?void 0:i.pose)!=null&&g.orientation))return null;const m=new w.Vector3(i.pose.position[0]/1e3,i.pose.position[1]/1e3,i.pose.position[2]/1e3),f=new w.Vector3(i.pose.orientation[0],i.pose.orientation[1],i.pose.orientation[2]);let d;const a=i.shape.shape_type==="plane"?{...$,side:w.DoubleSide}:{...$,side:w.FrontSide};switch(i.shape.shape_type){case"plane":d=r.jsx("planeGeometry",{args:[o,o]});break;case"sphere":{const h=(i==null?void 0:i.shape).radius/1e3;d=r.jsx("sphereGeometry",{args:[h]});break}case"capsule":{const h=(i==null?void 0:i.shape).radius/1e3,p=(i==null?void 0:i.shape).cylinder_height/1e3;d=r.jsx("capsuleGeometry",{args:[h,p]});break}case"convex_hull":{const h=(i==null?void 0:i.shape).vertices.map(j=>new w.Vector3(j[0]/1e3,j[1]/1e3,j[2]/1e3)),p=Te(h);if(p.isCoplanar&&p.normal){const x=new w.Vector3().addVectors(h[0],p.normal.multiplyScalar(1e-4));h.push(x)}try{d=r.jsx("primitive",{object:new D.ConvexGeometry(h),attach:"geometry"})}catch(j){return console.log("Error creating ConvexGeometry:",j),null}break}case"rectangular_capsule":{const h=i.shape,p=h.radius/1e3,j=h.sphere_center_distance_x/1e3,x=h.sphere_center_distance_y/1e3,b=p*2;d=r.jsx("primitive",{object:new D.RoundedBoxGeometry(j,x,b,2,p),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",i.shape.shape_type),d=null}return r.jsxs("mesh",{renderOrder:l,position:m,quaternion:ve(f),children:[d,r.jsx("meshStandardMaterial",{...a,polygonOffsetFactor:-l})]},`safety-zone-${i.shape.shape_type}-${l}`)},c=u.useMemo(()=>Object.values(e??{}).map((l,i)=>s(i,l)),[e,o]);return r.jsx("group",{...t,children:c})}const _e=["#ff2060","#20df80","#2080ff"],Me=["#6A6A6A","#9B9B9B","#727272"],Oe="#BBBBBB",Ee=.5;function B(e){if(!e)return[0,0,0,0,0,0,1];const{position:n,quaternion:t}=G.Pose3.fromPose(e);return[n.x/1e3,n.y/1e3,n.z/1e3,t.x,t.y,t.z,t.w]}function K({base:e,tcpOffset:n,rapidlyChangingMotionState:t,orientation:o,rotate:s=!1}){const c=u.useRef(null),l=u.useRef(null),i=O.useThree(f=>f.invalidate),m=o==="tool";return u.useEffect(()=>{const f=new L.ValueInterpolator(B(t.flange_pose),{tension:120,friction:20,threshold:.001});return l.current=f,()=>{f.destroy(),l.current=null}},[]),u.useEffect(()=>M.autorun(()=>{var d;const f=t.flange_pose;f&&((d=l.current)==null||d.setTarget(B(f)),i())}),[t,i]),O.useFrame((f,d)=>{const a=l.current,y=c.current;if(!a||!y)return;const g=a.update(d),[h=0,p=0,j=0,x=0,b=0,v=0,S=1]=a.getCurrentValues();y.position.set(h,p,j),y.quaternion.set(x,b,v,S),g||i()}),r.jsxs(r.Fragment,{children:[r.jsx(U,{transform:e,children:r.jsx(Q,{active:!m,rotate:!1})}),r.jsx("group",{ref:c,children:r.jsx(U,{transform:n,children:r.jsx(Q,{active:m,rotate:s})})})]})}function U({transform:e,children:n}){const t=e==null?void 0:e.position;return r.jsx("group",{position:[((t==null?void 0:t[0])??0)/1e3,((t==null?void 0:t[1])??0)/1e3,((t==null?void 0:t[2])??0)/1e3],quaternion:G.parseRotationToQuaternion((e==null?void 0:e.orientation)??[0,0,0],(e==null?void 0:e.orientation_type)??"ROTATION_VECTOR"),children:n})}function Q({active:e,rotate:n}){return r.jsx(T.PivotControls,{depthTest:!1,scale:.12,disableRotations:!n,disableSliders:!0,disableScaling:!0,autoTransform:!1,opacity:e?1:Ee,axisColors:e?_e:Me,hoveredColor:e?void 0:Oe})}const z=new R.Euler(Math.PI/2,0,0),Ae=console.warn;function ee(){return u.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Ae(e)}},[]),null}const Ie=new R.Vector3(0,1,0),te=/_J([0-9]+)$/,ne="_FLG",V="_REST",I=new Map;async function q(e,n,t){const o=n||"";if(!o)throw new Error(`Cannot download the model "${e}": no NOVA instance. Give defaultGetModel the URL of the instance or a NOVA client, or give the component its instanceUrl or getModel.`);const s=`${Ve(o)} ${e} ${t??""}`,c=I.get(s);if(c)return c;const l=(async()=>{const i=F.createNovaClient(o);try{const m=t?await F.getMotionGroupModelResource(i,e,t,"glb"):await i.api.motionGroupModels.getMotionGroupGlbModel(e,{responseType:"blob"});return URL.createObjectURL(m)}catch(m){throw console.error("Failed to fetch model:",m),m}})();return I.set(s,l),l.catch(()=>{I.get(s)===l&&I.delete(s)}),l}function Ve(e){return typeof e=="string"?e:e.config.instanceUrl}function oe(e){function n(t){return t.children.length===0?[t]:[t,...t.children.flatMap(o=>n(o))]}return n(e).filter(t=>ie(t))}function Le(e,n){return e.clone().multiply(new R.Quaternion().setFromAxisAngle(Ie,-n))}function Ge(e,n,t){const o=C(e);if(o===null)return null;const s=n[o];if(!s||s.type===_.JointTypeEnum.PrismaticJoint)return null;const c=s.theta??0,l=o===0&&t?t.position:e.position,i=o===0&&t?t.quaternion:e.quaternion;return{position:l,frame:Le(i,c),theta:c}}function qe(e,n){var t;return C(e)===0&&((t=n[0])==null?void 0:t.type)===_.JointTypeEnum.PrismaticJoint}function re(e){const n=new R.Quaternion().setFromEuler(z),t=n.clone().invert(),[o=0,s=0,c=0]=(e==null?void 0:e.position)??[],l=new R.Vector3(o,s,c).divideScalar(1e3).applyQuaternion(t),[i=0,m=0,f=0]=(e==null?void 0:e.orientation)??[],d=t.clone().multiply(G.parseRotationToQuaternion([i,m,f],"ROTATION_VECTOR")).multiply(n);return{position:l,quaternion:d}}function Ce(e,n){const t=C(e);if(t===null)return null;const o=n[t];return!o||o.type!==_.JointTypeEnum.PrismaticJoint?null:{position:e.position.clone(),quaternion:e.quaternion.clone()}}function se(e){return e.name.endsWith(ne)}function ie(e){return te.test(e.name)}function C(e){var t;const n=(t=e.name.match(te))==null?void 0:t[1];return n===void 0?null:Number.parseInt(n,10)}function Fe(e,n){let t;function o(s){if(se(s)){if(t)throw Error(`Found multiple flange groups in robot model ${n}; first ${t.name} then ${s.name}. Only one _FLG group is allowed.`);t=s}ie(s),s.children.map(o)}if(o(e.scene),!t)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}const ae=u.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:t,chainOffsetPosition:o,chainOffsetQuaternion:s,onTranslationChanged:c,children:l},i){const m=u.useRef(null),f=u.useRef([]),d=u.useRef(n.joint_position.filter(x=>x!==void 0)),{invalidate:a}=O.useThree(),y=u.useRef(n);y.current=n;function g(x){m.current=x,x&&h()}function h(){m.current&&(f.current=oe(m.current),p(),a())}u.useImperativeHandle(i,()=>({recollectJoints:h}));function p(){const x=d.current;if(c)c(f.current,x);else for(const[b,v]of f.current.entries()){const S=t[b];if((S==null?void 0:S.type)!==_.JointTypeEnum.PrismaticJoint)continue;const A=S.reverse_rotation_direction?-1:1;v.position.y=A*(x[b]||0)/1e3}}function j(x){d.current=x.joint_position.filter(b=>b!==void 0),p(),a()}return L.useAutorun(()=>{j(y.current)}),u.useEffect(()=>{j(n)},[n]),r.jsx("group",{ref:g,position:o,quaternion:s,children:l})});function ce({rapidlyChangingMotionState:e,dhParameters:n,...t}){const o=new R.Matrix4,s=u.useRef(null),c=u.useRef(null);function l(f){const d=new R.Matrix4;for(let h=0;h<n.length;h++){const p=n[h],j=f[h]??0,x=new R.Matrix4().makeRotationY(p.theta).multiply(new R.Matrix4().makeTranslation(p.a/1e3,(p.d+j*(p.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new R.Matrix4().makeRotationX(p.alpha));d.multiply(x)}const a=new R.Vector3,y=new R.Quaternion,g=new R.Vector3;return d.decompose(a,y,g),a}const i=l(e.joint_position);function m(f,d){o.identity();let a=new R.Vector3;for(let p=0;p<n.length;p++){const j=d[p]??0,x=n[p],b=new R.Matrix4().makeRotationY(x.theta).multiply(new R.Matrix4().makeTranslation(x.a/1e3,(x.d+j*(x.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new R.Matrix4().makeRotationX(x.alpha));o.multiply(b)}const y=new R.Vector3,g=new R.Quaternion,h=new R.Vector3;if(o.decompose(y,g,h),a=y,s.current&&s.current.position.set(a.x,a.y,a.z),c.current){const p=c.current.geometry;p!=null&&p.setPositions&&p.setPositions([0,0,0,a.x,a.y,a.z])}}return r.jsx(ae,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:m,children:r.jsxs("group",{...t,name:"Scene",children:[r.jsxs("mesh",{name:"Base",position:[0,0,0],children:[r.jsx("sphereGeometry",{args:[.02,32,32]}),r.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),r.jsx(T.Line,{ref:c,points:[new R.Vector3(0,0,0),i],color:"White",lineWidth:5}),r.jsxs("mesh",{ref:s,name:"TCP",position:i,children:[r.jsx("sphereGeometry",{args:[.025,32,32]}),r.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}function Je(e){return e.type==="Mesh"}function Pe({url:e,flangeRef:n,postModelRender:t,dhParameters:o=[],kinematicChainOffset:s,...c}){const l=T.useGLTF(e),m=Fe(l,"robot.glb").gltf,f=u.useMemo(()=>re(s),[s]);u.useEffect(()=>{t==null||t()},[e,t]);function d(a){try{if(Je(a))return a.geometry?r.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):r.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid);if(qe(a,o))return r.jsx("group",{name:`${a.name}${V}`,position:f.position,quaternion:f.quaternion,children:r.jsx("group",{name:a.name,children:a.children.map(d)})},a.uuid);const y=Ce(a,o);if(y)return r.jsx("group",{name:`${a.name}${V}`,position:y.position,quaternion:y.quaternion,children:r.jsx("group",{name:a.name,children:a.children.map(d)})},a.uuid);const g=Ge(a,o,s?f:void 0);return g?r.jsx("group",{name:`${a.name}${V}`,position:g.position,quaternion:g.frame,children:r.jsx("group",{name:a.name,rotation:[0,g.theta,0],children:a.children.map(d)})},a.uuid):r.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:se(a)?n:void 0,children:a.children.map(d)},a.uuid)}catch(y){return console.warn("Error rendering node",a.name,y),null}}return r.jsx("group",{...c,dispose:null,children:d(m.scene)})}function ue({modelURL:e,flangeRef:n,postModelRender:t,dhParameters:o,kinematicChainOffset:s,...c}){const[l,i]=u.useState(null);return u.useEffect(()=>{let m=!1;return(async()=>{try{const d=typeof e=="string"?e:await e;m||i(a=>a===d?a:d)}catch(d){console.error("Failed to resolve model URL:",d)}})(),()=>{m=!0}},[e]),l?r.jsx(Pe,{url:l,flangeRef:n,postModelRender:t,dhParameters:o,kinematicChainOffset:s,...c}):null}const H=(e,n)=>{const t=[];e.traverse(o=>{o instanceof w.Mesh&&!o.userData.isGhost&&!o.userData.hasGhost&&t.push(o)});for(const o of t){if(!o.parent)continue;const s=o.clone();s.visible=!0,s.material=new w.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:w.DoubleSide}),s.userData.isGhost=!0;const c=o.clone();c.visible=!0,c.material=new w.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:w.DoubleSide}),c.userData.isGhost=!0,o.parent.add(s),o.parent.add(c),o.visible=!1,o.userData.hasGhost=!0}},ke=e=>{var t;const n=[];e.traverse(o=>{o instanceof w.Mesh&&(o.userData.isGhost?n.push(o):o.userData.hasGhost&&(o.visible=!0,o.userData.hasGhost=!1))});for(const o of n)(t=o.parent)==null||t.remove(o),o.material instanceof w.Material&&o.material.dispose()};function le(e){const n=u.useRef(null),t=u.useRef(e);t.current=e,u.useEffect(()=>{const s=n.current;s&&(ke(s),e&&H(s,e))},[e]);const o=u.useCallback(()=>{const s=n.current;s&&t.current&&H(s,t.current)},[]);return{groupRef:n,styleDrawnModel:o}}function J(e){const n=O.useThree(c=>c.invalidate),[t]=u.useState(()=>M.observable({...e})),[o]=u.useState(()=>new L.ValueInterpolator(W(e))),s=u.useRef(null);return O.useFrame((c,l)=>{const i=s.current;if(i===null)return;const m=Math.min(l,(performance.now()-i)/1e3),f=o.update(m);M.runInAction(()=>{t.joint_position=o.getCurrentValues()}),f?s.current=null:n()}),u.useEffect(()=>M.autorun(()=>{o.setTarget(W(e)),Ne(e,t),s.current??(s.current=performance.now()),n()}),[e,t,o,n]),t}function W(e){return e.joint_position.filter(n=>n!==void 0)}function Ne(e,n){M.runInAction(()=>{const t=e,o=n;for(const s of Object.keys(t))s!=="joint_position"&&o[s]!==t[s]&&(o[s]=t[s])})}const P=E.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:t,serialNumber:o,kinematicChainOffset:s,chainOffsetPosition:c,chainOffsetQuaternion:l,getModel:i=q,flangeRef:m,postModelRender:f,transparentColor:d,instanceUrl:a,...y})=>{const g=u.useRef(null),h=le(d),{styleDrawnModel:p}=h,j=u.useCallback(()=>{var v;(v=g.current)==null||v.recollectJoints(),p(),f==null||f()},[f,p]),x=u.useMemo(()=>{const v=i(n,a,o);if(!v){const S=new Blob([],{type:"model/gltf-binary"}),A=new File([S],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(A))}return v},[n,a,o,i]),b=r.jsx(ce,{rapidlyChangingMotionState:e,dhParameters:t,...y});return r.jsxs(X.ErrorBoundary,{fallback:b,onError:v=>{console.warn(v)},children:[r.jsx(u.Suspense,{fallback:b,children:r.jsx("group",{ref:h.groupRef,children:r.jsx(ae,{ref:g,rapidlyChangingMotionState:e,dhParameters:t,chainOffsetPosition:c,chainOffsetQuaternion:l,children:r.jsx(ue,{modelURL:x,postModelRender:j,flangeRef:m,dhParameters:t,kinematicChainOffset:s,...y})})})}),r.jsx(ee,{})]})}),De=E.externalizeComponent(({rapidlyChangingMotionState:e,...n})=>{const t=J(e);return r.jsx(P,{rapidlyChangingMotionState:t,...n})}),pe=u.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:t,chainOffsetPosition:o,chainOffsetQuaternion:s,onRotationChanged:c,children:l},i){const m=u.useRef(null),f=u.useRef([]),d=u.useRef(n.joint_position.filter(x=>x!==void 0)),{invalidate:a}=O.useThree(),y=u.useRef(n);y.current=n;function g(x){m.current=x,x&&h()}function h(){m.current&&(f.current=oe(m.current),p(),a())}u.useImperativeHandle(i,()=>({recollectJoints:h}));function p(){const x=d.current;if(c)c(f.current,x);else for(const[b,v]of f.current.entries()){const S=t[b];if(!S)continue;const A=S.theta||0,xe=S.reverse_rotation_direction?-1:1;v.rotation.y=xe*(x[b]||0)+A}}function j(x){d.current=x.joint_position.filter(b=>b!==void 0),p(),a()}return L.useAutorun(()=>{j(y.current)}),u.useEffect(()=>{j(n)},[n]),r.jsx("group",{ref:g,position:o,quaternion:s,children:l})}),$e="line",Be="mesh";function Ue({rapidlyChangingMotionState:e,dhParameters:n,kinematicChainOffset:t,...o}){const s=new R.Matrix4,c=u.useRef([]),l=u.useRef([]),i=re(t);u.useEffect(()=>{c.current=new Array(n.length).fill(null),l.current=new Array(n.length).fill(null)},[n.length]);function m(a,y){const g=new R.Vector3,h=new R.Quaternion,p=new R.Vector3;s.decompose(g,h,p);const j=g.clone(),x=new R.Matrix4().makeRotationY(a.theta+y*(a.reverse_rotation_direction?-1:1)).multiply(new R.Matrix4().makeTranslation(0,a.d/1e3,0)).multiply(new R.Matrix4().makeTranslation(a.a/1e3,0,0)).multiply(new R.Matrix4().makeRotationX(a.alpha));return s.multiply(x),s.decompose(g,h,p),{a:j,b:g}}function f(a,y,g,h){if(!n)return;const p=n[a];if(!p)return;const{a:j,b:x}=m(p,h);y.geometry.setPositions([j.toArray(),x.toArray()].flat()),g.position.set(x.x,x.y,x.z)}function d(a,y){s.identity();for(let g=0;g<Math.min(a.length,y.length);g++){const h=c.current[g],p=l.current[g];h&&p&&f(g,h,p,y[g])}}return r.jsx(pe,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:d,children:r.jsx("group",{...o,name:"Scene",children:r.jsxs("group",{position:i.position,quaternion:i.quaternion,children:[r.jsxs("mesh",{children:[r.jsx("sphereGeometry",{args:[.01,32,32]}),r.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n==null?void 0:n.map((a,y)=>{const{a:g,b:h}=m(a,e.joint_position[y]??0),p=`dhrobot_J0${y}`;return r.jsxs("group",{name:p,children:[r.jsx(T.Line,{ref:j=>{c.current[y]=j},name:$e,points:[g,h],color:"white",lineWidth:5}),r.jsxs("mesh",{ref:j=>{l.current[y]=j},name:Be,position:h,children:[r.jsx("sphereGeometry",{args:[.01,32,32]}),r.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${y}`)]},p)})]})})})}const k=E.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:t,serialNumber:o,kinematicChainOffset:s,chainOffsetPosition:c,chainOffsetQuaternion:l,getModel:i=q,flangeRef:m,postModelRender:f,transparentColor:d,instanceUrl:a,...y})=>{const g=u.useRef(null),h=le(d),{styleDrawnModel:p}=h,j=u.useCallback(()=>{var v;(v=g.current)==null||v.recollectJoints(),p(),f==null||f()},[f,p]),x=u.useMemo(()=>{const v=i(n,a,o);if(!v)throw new Error(`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`);return v},[n,a,o,i]),b=r.jsx(Ue,{rapidlyChangingMotionState:e,dhParameters:t,kinematicChainOffset:s,...y});return r.jsxs(X.ErrorBoundary,{fallback:b,onError:v=>{console.warn(v)},children:[r.jsx(u.Suspense,{fallback:b,children:r.jsx("group",{ref:h.groupRef,children:r.jsx(pe,{ref:g,rapidlyChangingMotionState:e,dhParameters:t,chainOffsetPosition:c,chainOffsetQuaternion:l,children:r.jsx(ue,{modelURL:x,postModelRender:j,flangeRef:m,dhParameters:t,kinematicChainOffset:s,...y})})})}),r.jsx(ee,{})]})}),Qe=E.externalizeComponent(({rapidlyChangingMotionState:e,...n})=>{const t=J(e);return r.jsx(k,{rapidlyChangingMotionState:t,...n})}),N=E.externalizeComponent(e=>{const{inverseSolver:n,dhParameters:t,...o}=e,[s,c]=u.useState(_.JointTypeEnum.RevoluteJoint);u.useEffect(()=>{t.length&&c(t[0].type??_.JointTypeEnum.RevoluteJoint)},[t]);const l=u.useMemo(()=>n===null&&s===_.JointTypeEnum.RevoluteJoint,[n,s]),i=u.useMemo(()=>n===null&&s===_.JointTypeEnum.PrismaticJoint,[n,s]);return u.useMemo(()=>!!n,[n])||l?r.jsx(k,{dhParameters:t,...o}):i?r.jsx(P,{dhParameters:t,...o}):null}),fe=E.externalizeComponent(e=>{const n=J(e.rapidlyChangingMotionState);return r.jsx(N,{...e,rapidlyChangingMotionState:n})}),He=[-4,1,4],We={timestamp:"",sequence_number:0,motion_group:"",controller:"",joint_limit_reached:{limit_reached:[]},standstill:!0,description_revision:0};function he({robot:e,getModel:n,safetyZones:t,plannedJoints:o,jogAxes:s,robotVisible:c=!0,robotRef:l,onModelDrawn:i,lighting:m=!0,children:f}){const d=je.useTheme(),a=e.nova,y=u.useCallback((j,x,b)=>q(j,a,b),[a]),g=n??y,h=u.useMemo(()=>o?{...We,joint_position:o}:null,[o]);if(!e.dhParameters)return null;const p={instanceUrl:"",getModel:g,inverseSolver:e.inverseSolver,modelFromController:e.modelFromController??"",serialNumber:e.serialNumber,dhParameters:e.dhParameters,kinematicChainOffset:e.kinematicChainOffset};return r.jsxs(r.Fragment,{children:[t&&r.jsx(Z,{safetyZones:t,dhParameters:e.dhParameters}),r.jsx("group",{ref:l,position:e.mountingPosition,quaternion:e.mountingQuaternion,children:r.jsxs("group",{rotation:z,children:[r.jsx("group",{visible:c,children:r.jsx(fe,{...p,rapidlyChangingMotionState:e.rapidlyChangingMotionState,postModelRender:i})}),h&&r.jsx(N,{...p,rapidlyChangingMotionState:h,transparentColor:d.palette.success.main}),m&&r.jsx("directionalLight",{position:He,castShadow:!0,intensity:1})]})}),s&&r.jsx(K,{...s}),m&&r.jsx(Y,{}),f]})}function de(e){var s,c,l,i,m,f;const{description:n,state:t}=e,o=n.mounting;return{nova:e.nova,modelFromController:n.motionGroupModel,dhParameters:n.dhParameters,inverseSolver:n.inverseSolver,serialNumber:n.serialNumber,kinematicChainOffset:n.kinematicChainOffset,rapidlyChangingMotionState:t.rapidlyChangingMotionState,mountingPosition:[(((s=o==null?void 0:o.position)==null?void 0:s[0])??0)/1e3,(((c=o==null?void 0:o.position)==null?void 0:c[1])??0)/1e3,(((l=o==null?void 0:o.position)==null?void 0:l[2])??0)/1e3],mountingQuaternion:G.parseRotationToQuaternion([((i=o==null?void 0:o.orientation)==null?void 0:i[0])??0,((m=o==null?void 0:o.orientation)==null?void 0:m[1])??0,((f=o==null?void 0:o.orientation)==null?void 0:f[2])??0],"ROTATION_VECTOR")}}function me(e){var l;const{description:n,jogging:t}=e,o=u.useMemo(()=>M.computed(()=>{const i=e.trajectory.plannedTrajectory;return i?e.state.isAt({type:"joint",motionGroupId:e.motionGroupId,joints:i.endJoints})?null:i.endJoints:null}),[e]).get(),s=t.selectedOrientation==="tool",c=t.selectedTcpId;return{robot:de(e),safetyZones:n.safetyZones,plannedJoints:o,jogAxes:{base:s?F.resolveCoordinateSystemInWorld(t.selectedCoordSystemId,t.coordSystems):t.jogCoordSystem,tcpOffset:c?(l=n.tcpOffsetsById[c])==null?void 0:l.pose:void 0,rapidlyChangingMotionState:e.state.rapidlyChangingMotionState,orientation:t.selectedOrientation,rotate:t.selectedCartesianMotionType==="rotate"}}}const Xe=ye.observer(function({session:n,robot:t,...o}){const s=me(ge.useRobotSessionOf(n));return r.jsx(he,{...s,...o,robot:t?{...s.robot,...t}:s.robot})});exports.DHLinearAxis=ce;exports.FLANGE_NODE_SUFFIX=ne;exports.JOINT_REST_SUFFIX=V;exports.JoggingAxes=K;exports.MotionGroupVisualizer=fe;exports.MotionGroupVisualizerExact=N;exports.PresetEnvironment=Y;exports.RobotScene=Xe;exports.RobotSceneView=he;exports.SafetyZonesRenderer=Z;exports.SupportedLinearAxis=De;exports.SupportedLinearAxisExact=P;exports.SupportedRobot=Qe;exports.SupportedRobotExact=k;exports.defaultGetModel=q;exports.jointIndexOf=C;exports.robotModelOf=de;exports.useRobotSceneProps=me;