@wandelbots/wandelbots-js-react-components 6.3.0 → 6.4.0-pr.chore-playground-tool-steps.664.4537d63

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 (191) hide show
  1. package/README.md +323 -120
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +5 -3
  4. package/dist/3d.js +24 -23
  5. package/dist/CurrentPoseBar/index.cjs +1 -0
  6. package/dist/CurrentPoseBar/index.d.ts +2 -0
  7. package/dist/CurrentPoseBar/index.js +5 -0
  8. package/dist/JoggingButtons/index.cjs +1 -0
  9. package/dist/JoggingButtons/index.d.ts +3 -0
  10. package/dist/JoggingButtons/index.js +5 -0
  11. package/dist/JoggingGizmo/index.cjs +1 -0
  12. package/dist/JoggingGizmo/index.d.ts +4 -0
  13. package/dist/JoggingGizmo/index.js +7 -0
  14. package/dist/JoggingJointSlider/index.cjs +1 -0
  15. package/dist/JoggingJointSlider/index.d.ts +2 -0
  16. package/dist/JoggingJointSlider/index.js +5 -0
  17. package/dist/RobotControlPanel/index.cjs +1 -0
  18. package/dist/RobotControlPanel/index.d.ts +2 -0
  19. package/dist/RobotControlPanel/index.js +5 -0
  20. package/dist/RobotHeader/index.cjs +1 -0
  21. package/dist/RobotHeader/index.d.ts +4 -0
  22. package/dist/RobotHeader/index.js +5 -0
  23. package/dist/SafetyBar/index.cjs +1 -1
  24. package/dist/SafetyBar/index.js +1 -1
  25. package/dist/chunks/CurrentPoseBar-CyHUWmjM.cjs +1 -0
  26. package/dist/chunks/CurrentPoseBar-zTZi68tY.js +505 -0
  27. package/dist/chunks/JoggingButtons-CXaozFVz.js +108 -0
  28. package/dist/chunks/JoggingButtons-CbL-5LMK.cjs +1 -0
  29. package/dist/chunks/JoggingGizmo-DGbFLWgT.cjs +1 -0
  30. package/dist/chunks/JoggingGizmo-SuS9MmL7.js +810 -0
  31. package/dist/chunks/JoggingGizmoOrientation-dzned4f4.cjs +1 -0
  32. package/dist/chunks/JoggingGizmoOrientation-x_crT_64.js +14 -0
  33. package/dist/chunks/JoggingJointSlider-CZ-k6XCa.js +406 -0
  34. package/dist/chunks/JoggingJointSlider-R3_A9Ppj.cjs +1 -0
  35. package/dist/chunks/Robot-D0ZqUCn3.cjs +1 -0
  36. package/dist/chunks/Robot-UoykZeYH.js +1272 -0
  37. package/dist/chunks/RobotControlPanel-BnMfmO41.js +822 -0
  38. package/dist/chunks/RobotControlPanel-BuDGcxPR.cjs +1 -0
  39. package/dist/chunks/RobotHeader-BZci9ahT.js +244 -0
  40. package/dist/chunks/RobotHeader-CqK0700U.cjs +1 -0
  41. package/dist/chunks/SafetyBar-Bbg-o8h9.cjs +1 -0
  42. package/dist/chunks/{SafetyBar-Cy9DiXp9.js → SafetyBar-Cuak4ffd.js} +11 -10
  43. package/dist/chunks/SmallSelect-BdD9uLKK.js +52 -0
  44. package/dist/chunks/SmallSelect-Dcsd7_6_.cjs +1 -0
  45. package/dist/chunks/TrajectoryExecutionStore-DPqfDcfn.js +3398 -0
  46. package/dist/chunks/TrajectoryExecutionStore-DV6mLEx9.cjs +3 -0
  47. package/dist/chunks/converters-C8I_A_tA.cjs +1 -0
  48. package/dist/chunks/converters-DpNB_WNQ.js +39 -0
  49. package/dist/chunks/externalizeComponent-BdxGBLIv.cjs +2 -0
  50. package/dist/chunks/externalizeComponent-_w2d1_pz.js +283 -0
  51. package/dist/chunks/holdSafety-BtoZ5We3.cjs +1 -0
  52. package/dist/chunks/holdSafety-Di1GZAWg.js +37 -0
  53. package/dist/chunks/joggingColors-CuT5u0H8.js +135 -0
  54. package/dist/chunks/joggingColors-ZDc_2UCp.cjs +1 -0
  55. package/dist/chunks/useEveryFrame-G_-ma1nC.js +142 -0
  56. package/dist/chunks/useEveryFrame-dmPPTKtT.cjs +1 -0
  57. package/dist/chunks/useSmoothedMotionState-COMJRcOt.js +214 -0
  58. package/dist/chunks/useSmoothedMotionState-Con0E5Bx.cjs +1 -0
  59. package/dist/components/AppHeader.d.ts +1 -1
  60. package/dist/components/currentPoseBar/CurrentPoseBar.d.ts +48 -0
  61. package/dist/components/currentPoseBar/OrientationFormatPopover.d.ts +19 -0
  62. package/dist/components/currentPoseBar/StreamStatus.d.ts +10 -0
  63. package/dist/components/currentPoseBar/orientation.d.ts +34 -0
  64. package/dist/components/currentPoseBar/poseValues.d.ts +15 -0
  65. package/dist/components/jogging/JoggingButtons.d.ts +16 -0
  66. package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +1 -1
  67. package/dist/components/jogging/JoggingJointTab.d.ts +1 -1
  68. package/dist/components/jogging/JoggingPanel.d.ts +6 -3
  69. package/dist/components/jogging/JoggingStore.d.ts +96 -19
  70. package/dist/components/jogging/gizmo/JoggingGizmo.d.ts +43 -0
  71. package/dist/components/jogging/gizmo/JoggingGizmoOrientation.d.ts +26 -0
  72. package/dist/components/jogging/gizmo/RotationHandles.d.ts +7 -0
  73. package/dist/components/jogging/gizmo/RotationScene.d.ts +6 -0
  74. package/dist/components/jogging/gizmo/TranslationHandles.d.ts +6 -0
  75. package/dist/components/jogging/gizmo/TranslationScene.d.ts +6 -0
  76. package/dist/components/jogging/gizmo/arcGrabAreas.d.ts +58 -0
  77. package/dist/components/jogging/gizmo/arcs.d.ts +54 -0
  78. package/dist/components/jogging/gizmo/arrows.d.ts +63 -0
  79. package/dist/components/jogging/gizmo/gizmoShared.d.ts +125 -0
  80. package/dist/components/jogging/gizmo/gizmoView.d.ts +42 -0
  81. package/dist/components/jogging/gizmo/useGizmoTurn.d.ts +11 -0
  82. package/dist/components/jogging/holdSafety.d.ts +44 -0
  83. package/dist/components/jogging/jogError.d.ts +9 -0
  84. package/dist/components/jogging/jogHandle.d.ts +23 -0
  85. package/dist/components/jogging/joggingColors.d.ts +24 -0
  86. package/dist/components/jogging/joggingVelocity.d.ts +21 -0
  87. package/dist/components/jogging/joint/JoggingJointSlider.d.ts +52 -0
  88. package/dist/components/jogging/joint/JointSliderTrack.d.ts +27 -0
  89. package/dist/components/jogging/joint/jointJog.d.ts +55 -0
  90. package/dist/components/jogging/joint/useJointJogHold.d.ts +48 -0
  91. package/dist/components/jogging/useHold.d.ts +38 -0
  92. package/dist/components/jogging/useJogControls.d.ts +45 -0
  93. package/dist/components/robotControl/CartesianJogTab.d.ts +21 -0
  94. package/dist/components/robotControl/HoldToMoveButton.d.ts +25 -0
  95. package/dist/components/robotControl/JogArea.d.ts +22 -0
  96. package/dist/components/robotControl/JogModeToggle.d.ts +8 -0
  97. package/dist/components/robotControl/JointJogTab.d.ts +11 -0
  98. package/dist/components/robotControl/MoveToTab.d.ts +18 -0
  99. package/dist/components/robotControl/PanelSelect.d.ts +13 -0
  100. package/dist/components/robotControl/PoseField.d.ts +21 -0
  101. package/dist/components/robotControl/RobotControlPanel.d.ts +212 -0
  102. package/dist/components/robotControl/Section.d.ts +5 -0
  103. package/dist/components/robotControl/SmallSelect.d.ts +15 -0
  104. package/dist/components/robotControl/VelocityRow.d.ts +14 -0
  105. package/dist/components/robotControl/atPose.d.ts +8 -0
  106. package/dist/components/robotControl/poseText.d.ts +15 -0
  107. package/dist/components/robotControl/units.d.ts +16 -0
  108. package/dist/components/robotControl/useCopyText.d.ts +12 -0
  109. package/dist/components/robotControl/useEveryFrame.d.ts +6 -0
  110. package/dist/components/robotHeader/ActivationSwitch.d.ts +7 -0
  111. package/dist/components/robotHeader/AppNavigation.d.ts +15 -0
  112. package/dist/components/robotHeader/RobotHeader.d.ts +42 -0
  113. package/dist/components/robots/GenericRobot.d.ts +2 -1
  114. package/dist/components/robots/LinearAxis.d.ts +1 -1
  115. package/dist/components/robots/LinearAxisAnimator.d.ts +11 -2
  116. package/dist/components/robots/Robot.d.ts +1 -1
  117. package/dist/components/robots/robotModelLogic.d.ts +11 -9
  118. package/dist/components/utils/hooks.d.ts +1 -6
  119. package/dist/core.cjs +1 -1
  120. package/dist/core.d.ts +13 -18
  121. package/dist/core.js +37 -51
  122. package/dist/index.cjs +1 -1
  123. package/dist/index.js +58 -71
  124. package/dist/lib/ConnectedMotionGroup.d.ts +5 -7
  125. package/dist/lib/JoggerConnection.d.ts +137 -27
  126. package/dist/lib/MotionStreamConnection.d.ts +15 -6
  127. package/dist/lib/Pose3.d.ts +22 -0
  128. package/dist/lib/PoseTransformer.d.ts +25 -0
  129. package/dist/lib/TrajectoryExecutionStore.d.ts +129 -0
  130. package/dist/lib/connectionLogger.d.ts +9 -0
  131. package/dist/lib/incrementalCartesianMotion.d.ts +40 -0
  132. package/dist/lib/motionStateUpdate.d.ts +27 -0
  133. package/dist/lib/novaConnection.d.ts +23 -0
  134. package/dist/lib/planErrorTranslation.d.ts +8 -0
  135. package/dist/lib/rotation.d.ts +12 -0
  136. package/package.json +31 -66
  137. package/dist/Setup.d.ts +0 -11
  138. package/dist/chunks/MotionGroupVisualizer-DshWR1wY.js +0 -1653
  139. package/dist/chunks/MotionGroupVisualizer-eD7yFEcF.cjs +0 -1
  140. package/dist/chunks/SafetyBar-DPrv_OQA.cjs +0 -1
  141. package/dist/chunks/externalizeComponent-EDymnaGR.js +0 -268
  142. package/dist/chunks/externalizeComponent-OO4jcrz5.cjs +0 -2
  143. package/dist/chunks/theming-DfSy4-Ic.cjs +0 -4
  144. package/dist/chunks/theming-mF9Rt8SS.js +0 -5542
  145. package/dist/chunks/useSmoothedMotionState-DyDgSVYX.js +0 -478
  146. package/dist/chunks/useSmoothedMotionState-VYxEIyfr.cjs +0 -1
  147. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +0 -11
  148. package/dist/components/AdornedTextField.d.ts +0 -7
  149. package/dist/components/CopyableText.d.ts +0 -6
  150. package/dist/components/CycleTimer/CycleTimer.d.ts +0 -3
  151. package/dist/components/CycleTimer/DefaultVariant.d.ts +0 -9
  152. package/dist/components/CycleTimer/SmallVariant.d.ts +0 -10
  153. package/dist/components/CycleTimer/index.d.ts +0 -27
  154. package/dist/components/CycleTimer/types.d.ts +0 -49
  155. package/dist/components/CycleTimer/useAnimations.d.ts +0 -14
  156. package/dist/components/CycleTimer/useTimerLogic.d.ts +0 -24
  157. package/dist/components/CycleTimer/utils.d.ts +0 -21
  158. package/dist/components/CycleTimer.d.ts +0 -3
  159. package/dist/components/DataGrid.d.ts +0 -66
  160. package/dist/components/LogPanel.d.ts +0 -38
  161. package/dist/components/LogStore.d.ts +0 -12
  162. package/dist/components/LogViewer.d.ts +0 -46
  163. package/dist/components/ProgramControl.d.ts +0 -55
  164. package/dist/components/ProgramStateIndicator.d.ts +0 -26
  165. package/dist/components/RobotCard.d.ts +0 -98
  166. package/dist/components/RobotListItem.d.ts +0 -34
  167. package/dist/components/RobotSetupReadinessIndicator.d.ts +0 -37
  168. package/dist/components/SelectableFab.d.ts +0 -7
  169. package/dist/components/TabBar.d.ts +0 -45
  170. package/dist/components/ThemeSelect.d.ts +0 -6
  171. package/dist/components/Timer/Timer.d.ts +0 -3
  172. package/dist/components/Timer/TimerDefaultVariant.d.ts +0 -9
  173. package/dist/components/Timer/TimerSmallVariant.d.ts +0 -10
  174. package/dist/components/Timer/index.d.ts +0 -19
  175. package/dist/components/Timer/types.d.ts +0 -35
  176. package/dist/components/Timer/useTimerAnimations.d.ts +0 -10
  177. package/dist/components/Timer/useTimerLogic.d.ts +0 -19
  178. package/dist/components/Timer/utils.d.ts +0 -17
  179. package/dist/components/Timer.d.ts +0 -3
  180. package/dist/components/TransparentOverlay.d.ts +0 -4
  181. package/dist/components/jogging/JoggingFreedriveTab.d.ts +0 -1
  182. package/dist/components/jogging/PoseCartesianValues.d.ts +0 -9
  183. package/dist/components/jogging/PoseJointValues.d.ts +0 -8
  184. package/dist/components/robots/AxisConfig.d.ts +0 -2
  185. package/dist/components/robots/manufacturerHomePositions.d.ts +0 -20
  186. package/dist/icons/DropdownArrowIcon.d.ts +0 -2
  187. package/dist/icons/index.d.ts +0 -12
  188. package/dist/lib/novaCompat.d.ts +0 -16
  189. package/dist/themes/createDarkTheme.d.ts +0 -7
  190. package/dist/themes/themeTypes.d.ts +0 -40
  191. package/dist/themes/theming.d.ts +0 -24
@@ -0,0 +1 @@
1
+ "use strict";const n=require("@react-three/fiber"),o=require("three"),t=require("./JoggingGizmo-DGbFLWgT.cjs");function u({target:e}){const r=n.useThree(i=>i.camera);return n.useFrame(()=>{e.current=t.novaAxesSeenBy(r,e.current??new o.Quaternion)}),null}exports.JoggingGizmoOrientation=u;
@@ -0,0 +1,14 @@
1
+ import { useThree as o, useFrame as m } from "@react-three/fiber";
2
+ import { Quaternion as t } from "three";
3
+ import { n as a } from "./JoggingGizmo-SuS9MmL7.js";
4
+ function s({
5
+ target: r
6
+ }) {
7
+ const e = o((n) => n.camera);
8
+ return m(() => {
9
+ r.current = a(e, r.current ?? new t());
10
+ }), null;
11
+ }
12
+ export {
13
+ s as J
14
+ };
@@ -0,0 +1,406 @@
1
+ import { jsxs as S, Fragment as et, jsx as x } from "react/jsx-runtime";
2
+ import b from "@mui/material/Box";
3
+ import J from "@mui/material/Stack";
4
+ import { useTheme as Y, alpha as N } from "@mui/material/styles";
5
+ import G from "@mui/material/Typography";
6
+ import { useRef as L, useState as Z, useCallback as y, useEffect as _ } from "react";
7
+ import { e as it } from "./externalizeComponent-_w2d1_pz.js";
8
+ import { u as st, p as at, b as lt, a as ut, e as ct, s as dt } from "./holdSafety-Di1GZAWg.js";
9
+ const k = 2 * Math.PI;
10
+ function ft({ min: t, max: n, linear: r }, d) {
11
+ const s = t !== void 0, u = n !== void 0;
12
+ if (s && u && n > t) return { min: t, max: n };
13
+ if (r) return null;
14
+ if (s && !u) return { min: t, max: t + k };
15
+ if (u && !s) return { min: n - k, max: n };
16
+ const g = Math.round(d / k) * k;
17
+ return { min: g - Math.PI, max: g + Math.PI };
18
+ }
19
+ function z(t, n) {
20
+ return Math.min(1, Math.max(0, (t - n.min) / (n.max - n.min)));
21
+ }
22
+ function mt(t, n) {
23
+ const r = Math.min(1, Math.max(0, t));
24
+ return n.min + r * (n.max - n.min);
25
+ }
26
+ function ht(t) {
27
+ return t.min > 0 || t.max < 0 ? null : z(0, t);
28
+ }
29
+ function q(t, n, r) {
30
+ return Math.abs(n - t) <= r ? null : n > t ? "+" : "-";
31
+ }
32
+ function pt(t, n, r) {
33
+ return r === "+" ? t >= n : t <= n;
34
+ }
35
+ function xt(t, n) {
36
+ return t ? "mm" : n;
37
+ }
38
+ const E = {
39
+ deg: {
40
+ shown: (t) => t * 180 / Math.PI,
41
+ decimals: 1,
42
+ limitDecimals: 0,
43
+ suffix: "°"
44
+ },
45
+ rad: { shown: (t) => t, decimals: 3, limitDecimals: 2, suffix: " rad" },
46
+ mm: { shown: (t) => t, decimals: 1, limitDecimals: 0, suffix: " mm" }
47
+ };
48
+ function Q(t, n) {
49
+ const r = t.toFixed(n);
50
+ return Number(r) === 0 ? 0 .toFixed(n) : r;
51
+ }
52
+ function T(t, n) {
53
+ return E[n].shown(t);
54
+ }
55
+ function gt(t, n) {
56
+ const { shown: r, decimals: d, suffix: s } = E[n];
57
+ return `${Q(r(t), d)}${s}`;
58
+ }
59
+ function V(t, n) {
60
+ const { shown: r, limitDecimals: d, suffix: s } = E[n], u = 10 ** d, g = r(t), c = Math.sign(g) * Math.round(Math.abs(g) * u) / u;
61
+ return `${c > 0 ? "+" : ""}${Q(c, d)}${s}`;
62
+ }
63
+ const O = 16, U = 4;
64
+ function W({
65
+ railRef: t,
66
+ at: n,
67
+ goalAt: r,
68
+ held: d,
69
+ zeroAt: s,
70
+ limits: u,
71
+ disabled: g
72
+ }) {
73
+ const c = Y(), f = c.palette.primary.main, a = `0 0 0 8px ${N(f, 0.16)}`;
74
+ return /* @__PURE__ */ S(et, { children: [
75
+ /* @__PURE__ */ S(
76
+ b,
77
+ {
78
+ ref: t,
79
+ sx: {
80
+ position: "absolute",
81
+ left: 0,
82
+ right: 0,
83
+ top: "50%",
84
+ height: U,
85
+ transform: "translateY(-50%)"
86
+ },
87
+ children: [
88
+ /* @__PURE__ */ x(
89
+ b,
90
+ {
91
+ sx: {
92
+ position: "absolute",
93
+ inset: 0,
94
+ borderRadius: U / 2,
95
+ backgroundColor: N(f, 0.38)
96
+ }
97
+ }
98
+ ),
99
+ n !== null && r !== null && // The stretch the joint would travel: lighter while only hovered
100
+ /* @__PURE__ */ x(
101
+ b,
102
+ {
103
+ sx: {
104
+ position: "absolute",
105
+ top: 0,
106
+ bottom: 0,
107
+ borderRadius: U / 2,
108
+ backgroundColor: f
109
+ },
110
+ style: {
111
+ left: `${Math.min(n, r) * 100}%`,
112
+ width: `${Math.abs(r - n) * 100}%`,
113
+ opacity: d ? 1 : 0.5
114
+ }
115
+ }
116
+ ),
117
+ s !== null && // The joint's zero
118
+ /* @__PURE__ */ x(
119
+ b,
120
+ {
121
+ "aria-hidden": !0,
122
+ sx: {
123
+ position: "absolute",
124
+ top: "50%",
125
+ width: 2,
126
+ height: 12,
127
+ transform: "translate(-50%, -50%)",
128
+ borderRadius: 1,
129
+ backgroundColor: "text.secondary"
130
+ },
131
+ style: { left: `${s * 100}%` }
132
+ }
133
+ ),
134
+ n !== null && /* @__PURE__ */ x(
135
+ b,
136
+ {
137
+ sx: {
138
+ position: "absolute",
139
+ top: "50%",
140
+ boxSizing: "border-box",
141
+ width: O,
142
+ height: O,
143
+ transform: "translate(-50%, -50%)",
144
+ borderRadius: "50%",
145
+ border: `3px solid ${f}`,
146
+ backgroundColor: "background.paper",
147
+ boxShadow: d ? a : c.shadows[2],
148
+ transition: "box-shadow 150ms",
149
+ "&:hover": g ? {} : { boxShadow: a }
150
+ },
151
+ style: { left: `${n * 100}%` }
152
+ }
153
+ )
154
+ ]
155
+ }
156
+ ),
157
+ u && /* @__PURE__ */ x(
158
+ J,
159
+ {
160
+ direction: "row",
161
+ sx: {
162
+ position: "absolute",
163
+ left: 0,
164
+ right: 0,
165
+ top: 30,
166
+ justifyContent: "space-between"
167
+ },
168
+ children: [u.min, u.max].map((I, M) => /* @__PURE__ */ x(
169
+ G,
170
+ {
171
+ variant: "caption",
172
+ color: "text.secondary",
173
+ sx: { fontSize: 10, lineHeight: "14px" },
174
+ children: I
175
+ },
176
+ M
177
+ ))
178
+ }
179
+ )
180
+ ] });
181
+ }
182
+ function bt({
183
+ value: t,
184
+ onJogStart: n,
185
+ onJogStop: r,
186
+ disabled: d
187
+ }) {
188
+ const s = L(null), [u, g] = Z(null), c = y((o) => {
189
+ s.current = o, g(o);
190
+ }, []), f = L({ value: t, onJogStart: n, onJogStop: r });
191
+ f.current = { value: t, onJogStart: n, onJogStop: r };
192
+ const a = y(
193
+ (o, m, p) => {
194
+ const w = q(f.current.value, m, p);
195
+ c({
196
+ ...o,
197
+ goal: m,
198
+ direction: w,
199
+ settledAt: w ? null : o.settledAt
200
+ }), o.direction && o.direction !== w && f.current.onJogStop(), w && w !== o.direction && f.current.onJogStart(w);
201
+ },
202
+ [c]
203
+ ), I = y(() => s.current !== null, []), M = y(
204
+ (o, m, p) => d || s.current ? !1 : (a({ goal: o, direction: null, settledAt: null, by: p }, o, m), !0),
205
+ [d, a]
206
+ ), $ = y(
207
+ (o, m) => {
208
+ const p = s.current;
209
+ if (p) {
210
+ if (p.direction === null && p.settledAt !== null && Math.abs(o - p.settledAt) <= m) {
211
+ c({ ...p, goal: o });
212
+ return;
213
+ }
214
+ a(p, o, m);
215
+ }
216
+ },
217
+ [a, c]
218
+ ), H = y(() => {
219
+ const o = s.current;
220
+ o && (c(null), o.direction && f.current.onJogStop());
221
+ }, [c]), j = y(() => {
222
+ var o;
223
+ return ((o = s.current) == null ? void 0 : o.by) ?? null;
224
+ }, []), R = y(
225
+ (o) => {
226
+ const m = s.current;
227
+ m && o(m.by) && H();
228
+ },
229
+ [H]
230
+ );
231
+ return _(() => {
232
+ const o = s.current;
233
+ o != null && o.direction && pt(t, o.goal, o.direction) && (c({ ...o, direction: null, settledAt: o.goal }), f.current.onJogStop());
234
+ }, [t, c]), st(u !== null, d, H), { hold: u, isHolding: I, heldBy: j, begin: M, moveGoal: $, end: H, endIfHeldBy: R };
235
+ }
236
+ function wt(t) {
237
+ return t === "mouse" || t === "pen" ? 1 : 4;
238
+ }
239
+ function yt(t) {
240
+ return t === "ArrowRight" || t === "ArrowUp" ? "+" : t === "ArrowLeft" || t === "ArrowDown" ? "-" : null;
241
+ }
242
+ const Ct = it(
243
+ ({
244
+ label: t,
245
+ name: n,
246
+ value: r,
247
+ min: d,
248
+ max: s,
249
+ linear: u = !1,
250
+ angleUnit: g = "deg",
251
+ onJogStart: c,
252
+ onJogStop: f,
253
+ disabled: a = !1
254
+ }) => {
255
+ const I = Y(), M = L(null), { hold: $, isHolding: H, heldBy: j, begin: R, moveGoal: o, end: m, endIfHeldBy: p } = bt({ value: r, onJogStart: c, onJogStop: f, disabled: a }), [w, D] = Z(null);
256
+ _(() => {
257
+ a && D(null);
258
+ }, [a]);
259
+ const l = ft({ min: d, max: s, linear: u }, r), A = xt(u, g), B = (e) => gt(e, A);
260
+ function F({ clientX: e, pointerType: i }) {
261
+ if (!l || !M.current) return null;
262
+ const h = M.current.getBoundingClientRect();
263
+ return h.width <= 0 ? null : {
264
+ goal: mt((e - h.left) / h.width, l),
265
+ deadband: wt(i) / h.width * (l.max - l.min)
266
+ };
267
+ }
268
+ function X(e) {
269
+ var h, P;
270
+ if (!lt(e) || a || H()) return;
271
+ const i = F(e);
272
+ if (i) {
273
+ try {
274
+ (P = (h = e.currentTarget).setPointerCapture) == null || P.call(h, e.pointerId);
275
+ } catch {
276
+ }
277
+ R(i.goal, i.deadband, { pointer: e.pointerId });
278
+ }
279
+ }
280
+ function tt(e) {
281
+ const i = F(e);
282
+ D(a ? null : (i == null ? void 0 : i.goal) ?? null);
283
+ const h = j();
284
+ if (!(!h || !("pointer" in h) || h.pointer !== e.pointerId)) {
285
+ if (ut(e)) {
286
+ m();
287
+ return;
288
+ }
289
+ i && o(i.goal, i.deadband);
290
+ }
291
+ }
292
+ function v(e) {
293
+ p((i) => "pointer" in i && i.pointer === e.pointerId);
294
+ }
295
+ function nt(e) {
296
+ const i = yt(e.key);
297
+ if (i && e.preventDefault(), H()) {
298
+ ct(e) && m();
299
+ return;
300
+ }
301
+ if (!i || !dt(e) || a || !l) return;
302
+ const h = i === "+" ? l.max : l.min, P = (l.max - l.min) * 1e-4;
303
+ q(r, h, P) === i && R(h, P, { key: e.key });
304
+ }
305
+ function ot(e) {
306
+ p((i) => "key" in i && i.key === e.key);
307
+ }
308
+ const C = ($ == null ? void 0 : $.goal) ?? w, rt = l && {
309
+ min: V(l.min, A),
310
+ max: V(l.max, A)
311
+ }, K = /* @__PURE__ */ S(
312
+ J,
313
+ {
314
+ direction: "row",
315
+ sx: { justifyContent: "space-between", gap: 1, mb: "-4px" },
316
+ children: [
317
+ /* @__PURE__ */ S(G, { variant: "body2", noWrap: !0, children: [
318
+ t,
319
+ n && /* @__PURE__ */ x(b, { component: "span", sx: { color: "text.secondary" }, children: ` - ${n}` })
320
+ ] }),
321
+ /* @__PURE__ */ S(
322
+ G,
323
+ {
324
+ variant: "body2",
325
+ sx: { fontVariantNumeric: "tabular-nums", whiteSpace: "nowrap" },
326
+ children: [
327
+ B(r),
328
+ l && C !== null && /* @__PURE__ */ x(b, { component: "span", sx: { color: "text.secondary" }, children: ` / ${B(C)}` })
329
+ ]
330
+ }
331
+ )
332
+ ]
333
+ }
334
+ );
335
+ return l ? /* @__PURE__ */ S(J, { "data-testid": "jogging-joint-slider", children: [
336
+ K,
337
+ /* @__PURE__ */ x(
338
+ b,
339
+ {
340
+ role: "slider",
341
+ tabIndex: a ? -1 : 0,
342
+ "aria-label": n ? `${t} ${n}` : t,
343
+ "aria-valuemin": T(l.min, A),
344
+ "aria-valuemax": T(l.max, A),
345
+ "aria-valuenow": T(r, A),
346
+ "aria-valuetext": B(r),
347
+ "aria-disabled": a || void 0,
348
+ onPointerDown: X,
349
+ onPointerMove: tt,
350
+ onPointerLeave: () => D(null),
351
+ onPointerUp: v,
352
+ onPointerCancel: v,
353
+ onLostPointerCapture: v,
354
+ onKeyDown: nt,
355
+ onKeyUp: ot,
356
+ onBlur: m,
357
+ onContextMenu: at,
358
+ sx: {
359
+ position: "relative",
360
+ height: 44,
361
+ borderRadius: 1,
362
+ opacity: a ? 0.5 : 1,
363
+ cursor: a ? "default" : "pointer",
364
+ // A press must stay a press: no scrolling or text selection
365
+ touchAction: "none",
366
+ userSelect: "none",
367
+ outline: "none",
368
+ // The design system's focus mark, as on its buttons: the slider
369
+ // an arrow key jogs must be plain to see
370
+ "&:focus-visible": {
371
+ outline: `2px solid ${I.palette.primary.main}`,
372
+ outlineOffset: "2px"
373
+ }
374
+ },
375
+ children: /* @__PURE__ */ x(
376
+ W,
377
+ {
378
+ railRef: M,
379
+ at: z(r, l),
380
+ goalAt: C === null ? null : z(C, l),
381
+ held: $ !== null,
382
+ zeroAt: ht(l),
383
+ limits: rt ?? void 0,
384
+ disabled: a
385
+ }
386
+ )
387
+ }
388
+ )
389
+ ] }) : /* @__PURE__ */ S(J, { "data-testid": "jogging-joint-slider", children: [
390
+ K,
391
+ /* @__PURE__ */ x(b, { "aria-hidden": !0, sx: { position: "relative", height: 44 }, children: /* @__PURE__ */ x(
392
+ W,
393
+ {
394
+ at: null,
395
+ goalAt: null,
396
+ held: !1,
397
+ zeroAt: null,
398
+ disabled: !0
399
+ }
400
+ ) })
401
+ ] });
402
+ }
403
+ );
404
+ export {
405
+ Ct as J
406
+ };
@@ -0,0 +1 @@
1
+ "use strict";const u=require("react/jsx-runtime"),w=require("@mui/material/Box"),P=require("@mui/material/Stack"),J=require("@mui/material/styles"),z=require("@mui/material/Typography"),h=require("react"),tt=require("./externalizeComponent-BdxGBLIv.cjs"),S=require("./holdSafety-BtoZ5We3.cjs"),I=2*Math.PI;function nt({min:t,max:n,linear:o},f){const s=t!==void 0,c=n!==void 0;if(s&&c&&n>t)return{min:t,max:n};if(o)return null;if(s&&!c)return{min:t,max:t+I};if(c&&!s)return{min:n-I,max:n};const b=Math.round(f/I)*I;return{min:b-Math.PI,max:b+Math.PI}}function G(t,n){return Math.min(1,Math.max(0,(t-n.min)/(n.max-n.min)))}function et(t,n){const o=Math.min(1,Math.max(0,t));return n.min+o*(n.max-n.min)}function ot(t){return t.min>0||t.max<0?null:G(0,t)}function O(t,n,o){return Math.abs(n-t)<=o?null:n>t?"+":"-"}function rt(t,n,o){return o==="+"?t>=n:t<=n}function it(t,n){return t?"mm":n}const L={deg:{shown:t=>t*180/Math.PI,decimals:1,limitDecimals:0,suffix:"°"},rad:{shown:t=>t,decimals:3,limitDecimals:2,suffix:" rad"},mm:{shown:t=>t,decimals:1,limitDecimals:0,suffix:" mm"}};function W(t,n){const o=t.toFixed(n);return Number(o)===0?0 .toFixed(n):o}function v(t,n){return L[n].shown(t)}function st(t,n){const{shown:o,decimals:f,suffix:s}=L[n];return`${W(o(t),f)}${s}`}function K(t,n){const{shown:o,limitDecimals:f,suffix:s}=L[n],c=10**f,b=o(t),d=Math.sign(b)*Math.round(Math.abs(b)*c)/c;return`${d>0?"+":""}${W(d,f)}${s}`}const N=16,U=4;function V({railRef:t,at:n,goalAt:o,held:f,zeroAt:s,limits:c,disabled:b}){const d=J.useTheme(),x=d.palette.primary.main,l=`0 0 0 8px ${J.alpha(x,.16)}`;return u.jsxs(u.Fragment,{children:[u.jsxs(w,{ref:t,sx:{position:"absolute",left:0,right:0,top:"50%",height:U,transform:"translateY(-50%)"},children:[u.jsx(w,{sx:{position:"absolute",inset:0,borderRadius:U/2,backgroundColor:J.alpha(x,.38)}}),n!==null&&o!==null&&u.jsx(w,{sx:{position:"absolute",top:0,bottom:0,borderRadius:U/2,backgroundColor:x},style:{left:`${Math.min(n,o)*100}%`,width:`${Math.abs(o-n)*100}%`,opacity:f?1:.5}}),s!==null&&u.jsx(w,{"aria-hidden":!0,sx:{position:"absolute",top:"50%",width:2,height:12,transform:"translate(-50%, -50%)",borderRadius:1,backgroundColor:"text.secondary"},style:{left:`${s*100}%`}}),n!==null&&u.jsx(w,{sx:{position:"absolute",top:"50%",boxSizing:"border-box",width:N,height:N,transform:"translate(-50%, -50%)",borderRadius:"50%",border:`3px solid ${x}`,backgroundColor:"background.paper",boxShadow:f?l:d.shadows[2],transition:"box-shadow 150ms","&:hover":b?{}:{boxShadow:l}},style:{left:`${n*100}%`}})]}),c&&u.jsx(P,{direction:"row",sx:{position:"absolute",left:0,right:0,top:30,justifyContent:"space-between"},children:[c.min,c.max].map((k,j)=>u.jsx(z,{variant:"caption",color:"text.secondary",sx:{fontSize:10,lineHeight:"14px"},children:k},j))})]})}function ut({value:t,onJogStart:n,onJogStop:o,disabled:f}){const s=h.useRef(null),[c,b]=h.useState(null),d=h.useCallback(e=>{s.current=e,b(e)},[]),x=h.useRef({value:t,onJogStart:n,onJogStop:o});x.current={value:t,onJogStart:n,onJogStop:o};const l=h.useCallback((e,m,g)=>{const y=O(x.current.value,m,g);d({...e,goal:m,direction:y,settledAt:y?null:e.settledAt}),e.direction&&e.direction!==y&&x.current.onJogStop(),y&&y!==e.direction&&x.current.onJogStart(y)},[d]),k=h.useCallback(()=>s.current!==null,[]),j=h.useCallback((e,m,g)=>f||s.current?!1:(l({goal:e,direction:null,settledAt:null,by:g},e,m),!0),[f,l]),M=h.useCallback((e,m)=>{const g=s.current;if(g){if(g.direction===null&&g.settledAt!==null&&Math.abs(e-g.settledAt)<=m){d({...g,goal:e});return}l(g,e,m)}},[l,d]),C=h.useCallback(()=>{const e=s.current;e&&(d(null),e.direction&&x.current.onJogStop())},[d]),D=h.useCallback(()=>{var e;return((e=s.current)==null?void 0:e.by)??null},[]),$=h.useCallback(e=>{const m=s.current;m&&e(m.by)&&C()},[C]);return h.useEffect(()=>{const e=s.current;e!=null&&e.direction&&rt(t,e.goal,e.direction)&&(d({...e,direction:null,settledAt:e.goal}),x.current.onJogStop())},[t,d]),S.useEndHoldWhenUnattended(c!==null,f,C),{hold:c,isHolding:k,heldBy:D,begin:j,moveGoal:M,end:C,endIfHeldBy:$}}function lt(t){return t==="mouse"||t==="pen"?1:4}function at(t){return t==="ArrowRight"||t==="ArrowUp"?"+":t==="ArrowLeft"||t==="ArrowDown"?"-":null}const ct=tt.externalizeComponent(({label:t,name:n,value:o,min:f,max:s,linear:c=!1,angleUnit:b="deg",onJogStart:d,onJogStop:x,disabled:l=!1})=>{const k=J.useTheme(),j=h.useRef(null),{hold:M,isHolding:C,heldBy:D,begin:$,moveGoal:e,end:m,endIfHeldBy:g}=ut({value:o,onJogStart:d,onJogStop:x,disabled:l}),[y,q]=h.useState(null);h.useEffect(()=>{l&&q(null)},[l]);const a=nt({min:f,max:s,linear:c},o),R=it(c,b),B=r=>st(r,R);function E({clientX:r,pointerType:i}){if(!a||!j.current)return null;const p=j.current.getBoundingClientRect();return p.width<=0?null:{goal:et((r-p.left)/p.width,a),deadband:lt(i)/p.width*(a.max-a.min)}}function Y(r){var p,H;if(!S.startsPointerHold(r)||l||C())return;const i=E(r);if(i){try{(H=(p=r.currentTarget).setPointerCapture)==null||H.call(p,r.pointerId)}catch{}$(i.goal,i.deadband,{pointer:r.pointerId})}}function Z(r){const i=E(r);q(l?null:(i==null?void 0:i.goal)??null);const p=D();if(!(!p||!("pointer"in p)||p.pointer!==r.pointerId)){if(S.primaryReleased(r)){m();return}i&&e(i.goal,i.deadband)}}function T(r){g(i=>"pointer"in i&&i.pointer===r.pointerId)}function _(r){const i=at(r.key);if(i&&r.preventDefault(),C()){S.endsHold(r)&&m();return}if(!i||!S.startsKeyHold(r)||l||!a)return;const p=i==="+"?a.max:a.min,H=(a.max-a.min)*1e-4;O(o,p,H)===i&&$(p,H,{key:r.key})}function Q(r){g(i=>"key"in i&&i.key===r.key)}const A=(M==null?void 0:M.goal)??y,X=a&&{min:K(a.min,R),max:K(a.max,R)},F=u.jsxs(P,{direction:"row",sx:{justifyContent:"space-between",gap:1,mb:"-4px"},children:[u.jsxs(z,{variant:"body2",noWrap:!0,children:[t,n&&u.jsx(w,{component:"span",sx:{color:"text.secondary"},children:` - ${n}`})]}),u.jsxs(z,{variant:"body2",sx:{fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},children:[B(o),a&&A!==null&&u.jsx(w,{component:"span",sx:{color:"text.secondary"},children:` / ${B(A)}`})]})]});return a?u.jsxs(P,{"data-testid":"jogging-joint-slider",children:[F,u.jsx(w,{role:"slider",tabIndex:l?-1:0,"aria-label":n?`${t} ${n}`:t,"aria-valuemin":v(a.min,R),"aria-valuemax":v(a.max,R),"aria-valuenow":v(o,R),"aria-valuetext":B(o),"aria-disabled":l||void 0,onPointerDown:Y,onPointerMove:Z,onPointerLeave:()=>q(null),onPointerUp:T,onPointerCancel:T,onLostPointerCapture:T,onKeyDown:_,onKeyUp:Q,onBlur:m,onContextMenu:S.preventContextMenu,sx:{position:"relative",height:44,borderRadius:1,opacity:l?.5:1,cursor:l?"default":"pointer",touchAction:"none",userSelect:"none",outline:"none","&:focus-visible":{outline:`2px solid ${k.palette.primary.main}`,outlineOffset:"2px"}},children:u.jsx(V,{railRef:j,at:G(o,a),goalAt:A===null?null:G(A,a),held:M!==null,zeroAt:ot(a),limits:X??void 0,disabled:l})})]}):u.jsxs(P,{"data-testid":"jogging-joint-slider",children:[F,u.jsx(w,{"aria-hidden":!0,sx:{position:"relative",height:44},children:u.jsx(V,{at:null,goalAt:null,held:!1,zeroAt:null,disabled:!0})})]})});exports.JoggingJointSlider=ct;
@@ -0,0 +1 @@
1
+ "use strict";const o=require("react/jsx-runtime"),w=require("three"),C=require("three-stdlib"),S=require("@react-three/drei"),m=require("react"),A=require("./converters-C8I_A_tA.cjs"),O=require("@wandelbots/nova-js/v2"),T=require("./externalizeComponent-BdxGBLIv.cjs"),L=require("./useSmoothedMotionState-Con0E5Bx.cjs"),D=require("react-error-boundary"),$=require("@react-three/fiber");function re(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const R=re(w);function ie(e){switch(e.shape_type){case"convex_hull":return new C.ConvexGeometry(e.vertices.map(t=>new R.Vector3(t[0]/1e3,t[1]/1e3,t[2]/1e3)));case"box":return new R.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new R.SphereGeometry(e.radius/1e3);case"capsule":return new R.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new R.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new R.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new R.BufferGeometry}}function se({name:e,collider:n,children:t}){var c,l;const r=((c=n.pose)==null?void 0:c.position)??[0,0,0],i=((l=n.pose)==null?void 0:l.orientation)??[0,0,0];return n.margin&&console.warn(`${e} margin is not supported`),o.jsx("mesh",{name:e,position:new R.Vector3(r[0],r[1],r[2]).divideScalar(1e3),rotation:new R.Euler(i[0],i[1],i[2],"XYZ"),geometry:ie(n.shape),children:t})}function ae({name:e,colliders:n,meshChildrenProvider:t,...r}){return o.jsx("group",{name:e,...r,children:Object.entries(n).map(([i,c])=>o.jsx(se,{name:i,collider:c,children:t(i,c)},i))})}function ce({scene:e,meshChildrenProvider:n}){const t=e.colliders;return o.jsx("group",{children:t&&o.jsx(ae,{meshChildrenProvider:n,colliders:t})})}function le(e){const n=(e==null?void 0:e.position)??[],t=(e==null?void 0:e.orientation)??[],r=new w.Vector3(t[0]??0,t[1]??0,t[2]??0),i=r.length(),c=i>0?new w.Quaternion().setFromAxisAngle(r.normalize(),i):new w.Quaternion;return new w.Matrix4().compose(new w.Vector3(n[0]??0,n[1]??0,n[2]??0).divideScalar(1e3),c,new w.Vector3(1,1,1))}function ue(e,n=null,t=[]){const r=le(n);return e.map((i,c)=>{const l=r.clone(),s=(i.reverse_rotation_direction?-1:1)*(t[c]??0),a=i.type==="PRISMATIC_JOINT",f=(i.theta??0)+(a?0:s),p=(i.d??0)+(a?s:0);return r.multiply(new w.Matrix4().makeRotationZ(f)).multiply(new w.Matrix4().makeTranslation((i.a??0)/1e3,0,p/1e3)).multiply(new w.Matrix4().makeRotationX(i.alpha??0)),l})}const P="#ff4b4b",q="#2fa8ff",fe="#8a8d9e",pe=96,me=.15,he=new R.Vector3(0,1,0),de=.2,xe=2;function ge(e){const{lower_limit:n,upper_limit:t}=e??{};return typeof n!="number"||typeof t!="number"||!Number.isFinite(n)||!Number.isFinite(t)||!(n<t)?null:{lower_limit:n,upper_limit:t}}function k({base:e,direction:n,size:t,color:r,opacity:i}){const c=new R.Quaternion().setFromUnitVectors(he,n.clone().normalize()),l=e.clone().addScaledVector(n.clone().normalize(),t/2);return o.jsxs("mesh",{position:l,quaternion:c,renderOrder:10,children:[o.jsx("coneGeometry",{args:[t*.35,t,16]}),o.jsx("meshBasicMaterial",{color:r,depthTest:!1,transparent:!0,opacity:i})]})}function V({points:e,color:n,width:t,opacity:r}){return o.jsx(S.Line,{points:e,color:n,lineWidth:t,depthTest:!1,transparent:!0,opacity:r,renderOrder:10})}function J(e,n){const t=[...e];let r=n;for(;t.length>1;){const i=t[t.length-1],c=t[t.length-2],l=i.distanceTo(c);if(l>r)return t[t.length-1]=i.clone().lerp(c,r/l),t;r-=l,t.pop()}return t}function ye(e,n,t,r){const i=t*e,c=t*n,l=Math.abs(c-i),s=Math.max(2,Math.ceil(l/(2*Math.PI)*pe));return Array.from({length:s+1},(a,f)=>{const p=i+(c-i)*f/s,u=l*f/s/(2*Math.PI),y=r*(1+me*u);return new R.Vector3(Math.cos(p)*y,Math.sin(p)*y,0)})}function je(e,n,t,r){const i=e.theta??0,c=e.d??0,l=e.type==="PRISMATIC_JOINT",s=e.reverse_rotation_direction?-1:1,{lower_limit:a,upper_limit:f}=n;return m.useMemo(()=>{const p=new R.Matrix4().makeRotationZ(i).multiply(new R.Matrix4().makeTranslation(0,0,l?c/1e3:0)),u=(M,_,v)=>new R.Vector3(M,_,v).applyMatrix4(p),y=new R.Vector3().applyMatrix4(p),j=u(0,0,t),d=(l?[u(t*.25,0,s*a/1e3),u(t*.25,0,s*f/1e3)]:ye(a,f,s,t*.6)).map(M=>l?M:M.applyMatrix4(p)),h=u(l?t*.25:t*.6,0,0),b=d.slice(1).reduce((M,_,v)=>M+_.distanceTo(d[v]),0),x=Math.min(r,b/3),g=J(J(d,x).reverse(),x).reverse();return{axisPoints:[y,j],axisTip:j,origin:y,restPoints:[y,h],range:d,limitPoints:g,rangeStart:g[0],rangeEnd:g[g.length-1]}},[i,c,l,s,t,a,f,r])}function we({frame:e,dh:n,limit:t,size:r,emphasis:i}){const c=i==="highlighted"?xe:1,l=i==="dimmed"?de:1,s=r*.2*(i==="highlighted"?1.4:1),a=2*c,{axisPoints:f,axisTip:p,origin:u,restPoints:y,range:j,limitPoints:d,rangeStart:h,rangeEnd:b}=je(n,t,r,s),{position:x,quaternion:g}=m.useMemo(()=>{const M=new R.Vector3,_=new R.Quaternion;return e.decompose(M,_,new R.Vector3),{position:M,quaternion:_}},[e]);return o.jsxs("group",{position:x,quaternion:g,children:[o.jsx(V,{points:f,color:q,width:a,opacity:l}),o.jsx(k,{base:p,direction:p.clone().sub(u),size:s,color:q,opacity:l}),o.jsx(V,{points:y,color:fe,width:1.5*c,opacity:l}),o.jsx(V,{points:d,color:P,width:a,opacity:l}),o.jsx(k,{base:h,direction:j[0].clone().sub(h),size:h.distanceTo(j[0]),color:P,opacity:l}),o.jsx(k,{base:b,direction:j[j.length-1].clone().sub(b),size:b.distanceTo(j[j.length-1]),color:P,opacity:l})]})}function Re({dhParameters:e,chainOffset:n=null,limits:t,jointPositions:r,size:i=.15,highlightedJoint:c=null}){const l=m.useMemo(()=>ue(e,n,r),[e,n,r]);return o.jsx("group",{children:l.map((s,a)=>{const f=ge(t[a]);return f?o.jsx(we,{frame:s,dh:e[a],limit:f,size:i,emphasis:c===null?"normal":c===a?"highlighted":"dimmed"},a):null})})}function be(){return o.jsx(S.Environment,{frames:1,children:o.jsx(Se,{})})}const Me=[2,0,2,0,2,0,2,0];function Se({positions:e=Me}){return o.jsxs(o.Fragment,{children:[o.jsx(S.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),o.jsx("group",{rotation:[0,.5,0],children:o.jsx("group",{children:e.map((n,t)=>o.jsx(S.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,t*4],scale:[3,1,1]},t))})}),o.jsx(S.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),o.jsx(S.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),o.jsx(S.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),o.jsx(S.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),o.jsx(S.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}const N={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function _e({safetyZones:e,dhParameters:n,...t}){const r=m.useMemo(()=>A.dhParametersToPlaneSize(n??[]),[n]),i=(l,s)=>{var y,j;if(!((y=s==null?void 0:s.pose)!=null&&y.position)||!((j=s==null?void 0:s.pose)!=null&&j.orientation))return null;const a=new R.Vector3(s.pose.position[0]/1e3,s.pose.position[1]/1e3,s.pose.position[2]/1e3),f=new R.Vector3(s.pose.orientation[0],s.pose.orientation[1],s.pose.orientation[2]);let p;const u=s.shape.shape_type==="plane"?{...N,side:R.DoubleSide}:{...N,side:R.FrontSide};switch(s.shape.shape_type){case"plane":p=o.jsx("planeGeometry",{args:[r,r]});break;case"sphere":{const d=(s==null?void 0:s.shape).radius/1e3;p=o.jsx("sphereGeometry",{args:[d]});break}case"capsule":{const d=(s==null?void 0:s.shape).radius/1e3,h=(s==null?void 0:s.shape).cylinder_height/1e3;p=o.jsx("capsuleGeometry",{args:[d,h]});break}case"convex_hull":{const d=(s==null?void 0:s.shape).vertices.map(b=>new R.Vector3(b[0]/1e3,b[1]/1e3,b[2]/1e3)),h=A.verticesToCoplanarity(d);if(h.isCoplanar&&h.normal){const x=new R.Vector3().addVectors(d[0],h.normal.multiplyScalar(1e-4));d.push(x)}try{p=o.jsx("primitive",{object:new C.ConvexGeometry(d),attach:"geometry"})}catch(b){return console.log("Error creating ConvexGeometry:",b),null}break}case"rectangular_capsule":{const d=s.shape,h=d.radius/1e3,b=d.sphere_center_distance_x/1e3,x=d.sphere_center_distance_y/1e3,g=h*2;p=o.jsx("primitive",{object:new C.RoundedBoxGeometry(b,x,g,2,h),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",s.shape.shape_type),p=null}return o.jsxs("mesh",{renderOrder:l,position:a,quaternion:A.orientationToQuaternion(f),children:[p,o.jsx("meshStandardMaterial",{...u,polygonOffsetFactor:-l})]},`safety-zone-${s.shape.shape_type}-${l}`)},c=m.useMemo(()=>Object.values(e??{}).map((l,s)=>i(s,l)),[e,r]);return o.jsx("group",{...t,children:c})}function ve({trajectory:e,...n}){const t=(e==null?void 0:e.map(r=>{if(r.position&&r.position.length>=3){const[i,c,l]=r.position;if(Number.isFinite(i)&&Number.isFinite(c)&&Number.isFinite(l))return new R.Vector3(i/1e3,l/1e3,-c/1e3)}return null}).filter(r=>r!==null))||[];return o.jsx("group",{...n,children:t.length>0&&o.jsx(S.Line,{points:t,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const G=new Map;async function E(e,n){const t=n||"";if(!t)throw new Error(`Cannot download the model "${e}": no NOVA instance. Give defaultGetModel the URL of the instance or a NOVA client, or give the component its instanceUrl or getModel.`);const r=`${Te(t)} ${e}`,i=G.get(r);if(i)return i;const c=(async()=>{const l=L.createNovaClient(t);try{const s=await l.api.motionGroupModels.getMotionGroupGlbModel(e,{responseType:"blob"});return URL.createObjectURL(s)}catch(s){throw console.error("Failed to fetch model:",s),s}})();return G.set(r,c),c.catch(()=>{G.get(r)===c&&G.delete(r)}),c}function Te(e){return typeof e=="string"?e:e.config.instanceUrl}function Q(e){function n(t){return t.children.length===0?[t]:[t,...t.children.flatMap(r=>n(r))]}return n(e).filter(t=>W(t))}function U(e){return e.name.endsWith("_FLG")}function W(e){return/_J[0-9]+$/.test(e.name)}function Le(e,n){let t;function r(i){if(U(i)){if(t)throw Error(`Found multiple flange groups in robot model ${n}; first ${t.name} then ${i.name}. Only one _FLG group is allowed.`);t=i}W(i),i.children.map(r)}if(r(e.scene),!t)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}const H=m.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,onTranslationChanged:c,children:l},s){const a=m.useRef(null),f=m.useRef([]),p=m.useRef(n.joint_position.filter(x=>x!==void 0)),{invalidate:u}=$.useThree(),y=m.useRef(n);y.current=n;function j(x){a.current=x,x&&d()}function d(){a.current&&(f.current=Q(a.current),h(),u())}m.useImperativeHandle(s,()=>({recollectJoints:d}));function h(){const x=p.current;if(c)c(f.current,x);else for(const[g,M]of f.current.entries()){const v=t[g].reverse_rotation_direction?-1:1;M.position.y=v*(x[g]||0)/1e3}}function b(x){p.current=x.joint_position.filter(g=>g!==void 0),h(),u()}return L.useAutorun(()=>{b(y.current)}),o.jsx("group",{ref:j,position:r,quaternion:i,children:l})});function B({rapidlyChangingMotionState:e,dhParameters:n,...t}){const r=new w.Matrix4,i=m.useRef(null),c=m.useRef(null);function l(f){const p=new w.Matrix4;for(let d=0;d<n.length;d++){const h=n[d],b=f[d]??0,x=new w.Matrix4().makeRotationY(h.theta).multiply(new w.Matrix4().makeTranslation(h.a/1e3,(h.d+b*(h.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new w.Matrix4().makeRotationX(h.alpha));p.multiply(x)}const u=new w.Vector3,y=new w.Quaternion,j=new w.Vector3;return p.decompose(u,y,j),u}const s=l(e.joint_position);function a(f,p){r.identity();let u=new w.Vector3;for(let h=0;h<n.length;h++){const b=p[h]??0,x=n[h],g=new w.Matrix4().makeRotationY(x.theta).multiply(new w.Matrix4().makeTranslation(x.a/1e3,(x.d+b*(x.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new w.Matrix4().makeRotationX(x.alpha));r.multiply(g)}const y=new w.Vector3,j=new w.Quaternion,d=new w.Vector3;if(r.decompose(y,j,d),u=y,i.current&&i.current.position.set(u.x,u.y,u.z),c.current){const h=c.current.geometry;h!=null&&h.setPositions&&h.setPositions([0,0,0,u.x,u.y,u.z])}}return o.jsx(H,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:a,children:o.jsxs("group",{...t,name:"Scene",children:[o.jsxs("mesh",{name:"Base",position:[0,0,0],children:[o.jsx("sphereGeometry",{args:[.02,32,32]}),o.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),o.jsx(S.Line,{ref:c,points:[new w.Vector3(0,0,0),s],color:"White",lineWidth:5}),o.jsxs("mesh",{ref:i,name:"TCP",position:s,children:[o.jsx("sphereGeometry",{args:[.025,32,32]}),o.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}const Ee=console.warn;function X(){return m.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Ee(e)}},[]),null}function Oe(e){return e.type==="Mesh"}function Ge({url:e,flangeRef:n,postModelRender:t,...r}){const i=S.useGLTF(e),l=Le(i,"robot.glb").gltf;m.useEffect(()=>{t==null||t()},[e,t]);function s(a){try{return Oe(a)?a.geometry?o.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):o.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid):o.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:U(a)?n:void 0,children:a.children.map(s)},a.uuid)}catch(f){return console.warn("Error rendering node",a.name,f),null}}return o.jsx("group",{...r,dispose:null,children:s(l.scene)})}function Y({modelURL:e,flangeRef:n,postModelRender:t,...r}){const[i,c]=m.useState(null);return m.useEffect(()=>{let l=!1;return(async()=>{try{const a=typeof e=="string"?e:await e;l||c(f=>f===a?f:a)}catch(a){console.error("Failed to resolve model URL:",a)}})(),()=>{l=!0}},[e]),i?o.jsx(Ge,{url:i,flangeRef:n,postModelRender:t,...r}):null}const Z=(e,n)=>{e.userData.isGhost||(e.traverse(t=>{if(t instanceof R.Mesh){t.material instanceof R.Material&&(t.material.colorWrite=!1);const r=t.clone(),i=t.clone();r.material=new R.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:R.DoubleSide}),r.userData.isGhost=!0,i.material=new R.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:R.DoubleSide}),i.userData.isGhost=!0,t.parent&&(t.parent.add(r),t.parent.add(i))}}),e.userData.isGhost=!0)},K=e=>{if(!e.userData.isGhost)return;const n=[];e.traverse(t=>{var r;t instanceof R.Mesh&&((r=t.userData)!=null&&r.isGhost?n.push(t):t.material instanceof R.Material&&(t.material.colorWrite=!0))}),n.forEach(t=>{t.parent&&t.parent.remove(t)}),e.userData.isGhost=!1},I=T.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,getModel:c=E,flangeRef:l,postModelRender:s,transparentColor:a,instanceUrl:f,...p})=>{const[u,y]=m.useState(null),j=m.useRef(null),d=m.useCallback(g=>{y(g)},[]),h=m.useCallback(()=>{var g;(g=j.current)==null||g.recollectJoints(),s==null||s()},[s]);m.useEffect(()=>{u&&(a?Z(u,a):K(u))},[u,a]);const b=m.useMemo(()=>{const g=c(n,f);if(!g){const M=new Blob([],{type:"model/gltf-binary"}),_=new File([M],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(_))}return g},[n,f,c]),x=o.jsx(B,{rapidlyChangingMotionState:e,dhParameters:t,...p});return o.jsxs(D.ErrorBoundary,{fallback:x,onError:g=>{console.warn(g)},children:[o.jsx(m.Suspense,{fallback:x,children:o.jsx("group",{ref:d,children:o.jsx(H,{ref:j,rapidlyChangingMotionState:e,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,children:o.jsx(Y,{modelURL:b,postModelRender:h,flangeRef:l,...p})})})}),o.jsx(X,{})]})}),z=T.externalizeComponent(({rapidlyChangingMotionState:e,...n})=>{const t=L.useSmoothedMotionState(e);return o.jsx(I,{rapidlyChangingMotionState:t,...n})});function Ae({connectedMotionGroup:e,getModel:n,flangeRef:t,transparentColor:r,postModelRender:i,...c}){const l=m.useCallback(y=>E(y,e.nova),[e]),s=n??l;if(!e.dhParameters)return null;const a=e.mountingPosition,f=e.mountingQuaternion,p=e.modelFromController||"";return p?o.jsx(z,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:p,dhParameters:e.dhParameters,getModel:s,flangeRef:t,transparentColor:r,postModelRender:i,chainOffsetPosition:a,chainOffsetQuaternion:f,...c}):o.jsx(B,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,chainOffsetPosition:a,chainOffsetQuaternion:f,...c})}const ee=m.forwardRef(function({rapidlyChangingMotionState:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,onRotationChanged:c,children:l},s){const a=m.useRef(null),f=m.useRef([]),p=m.useRef(n.joint_position.filter(x=>x!==void 0)),{invalidate:u}=$.useThree(),y=m.useRef(n);y.current=n;function j(x){a.current=x,x&&d()}function d(){a.current&&(f.current=Q(a.current),h(),u())}m.useImperativeHandle(s,()=>({recollectJoints:d}));function h(){const x=p.current;if(c)c(f.current,x);else for(const[g,M]of f.current.entries()){const _=t[g],v=_.theta||0,oe=_.reverse_rotation_direction?-1:1;M.rotation.y=oe*(x[g]||0)+v}}function b(x){p.current=x.joint_position.filter(g=>g!==void 0),h(),u()}return L.useAutorun(()=>{b(y.current)}),m.useEffect(()=>{b(n)},[n]),o.jsx("group",{ref:j,position:r,quaternion:i,children:l})}),Pe="line",ke="mesh";function Ve({rapidlyChangingMotionState:e,dhParameters:n,...t}){const r=new w.Matrix4,i=m.useRef([]),c=m.useRef([]);m.useEffect(()=>{i.current=new Array(n.length).fill(null),c.current=new Array(n.length).fill(null)},[n.length]);function l(f,p){const u=new w.Vector3,y=new w.Quaternion,j=new w.Vector3;r.decompose(u,y,j);const d=u.clone(),h=new w.Matrix4().makeRotationY(f.theta+p*(f.reverse_rotation_direction?-1:1)).multiply(new w.Matrix4().makeTranslation(0,f.d/1e3,0)).multiply(new w.Matrix4().makeTranslation(f.a/1e3,0,0)).multiply(new w.Matrix4().makeRotationX(f.alpha));return r.multiply(h),r.decompose(u,y,j),{a:d,b:u}}function s(f,p,u,y){if(!n)return;const j=n[f];if(!j)return;const{a:d,b:h}=l(j,y);p.geometry.setPositions([d.toArray(),h.toArray()].flat()),u.position.set(h.x,h.y,h.z)}function a(f,p){r.identity();for(let u=0;u<Math.min(f.length,p.length);u++){const y=i.current[u],j=c.current[u];y&&j&&s(u,y,j,p[u])}}return o.jsx(ee,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:a,children:o.jsxs("group",{...t,name:"Scene",children:[o.jsxs("mesh",{children:[o.jsx("sphereGeometry",{args:[.01,32,32]}),o.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n==null?void 0:n.map((f,p)=>{const{a:u,b:y}=l(f,e.joint_position[p]??0),j=`dhrobot_J0${p}`;return o.jsxs("group",{name:j,children:[o.jsx(S.Line,{ref:d=>{i.current[p]=d},name:Pe,points:[u,y],color:"white",lineWidth:5}),o.jsxs("mesh",{ref:d=>{c.current[p]=d},name:ke,position:y,children:[o.jsx("sphereGeometry",{args:[.01,32,32]}),o.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${p}`)]},j)})]})})}const F=T.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,getModel:c=E,flangeRef:l,postModelRender:s,transparentColor:a,instanceUrl:f,...p})=>{const[u,y]=m.useState(null),j=m.useRef(null),d=m.useCallback(g=>{y(g)},[]),h=m.useCallback(()=>{var g;(g=j.current)==null||g.recollectJoints(),s==null||s()},[s]);m.useEffect(()=>{u&&(a?Z(u,a):K(u))},[u,a]);const b=m.useMemo(()=>{const g=c(n,f);if(!g)throw new Error(`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`);return g},[n,f,c]),x=o.jsx(Ve,{rapidlyChangingMotionState:e,dhParameters:t,...p});return o.jsxs(D.ErrorBoundary,{fallback:x,onError:g=>{console.warn(g)},children:[o.jsx(m.Suspense,{fallback:x,children:o.jsx("group",{ref:d,children:o.jsx(ee,{ref:j,rapidlyChangingMotionState:e,dhParameters:t,chainOffsetPosition:r,chainOffsetQuaternion:i,children:o.jsx(Y,{modelURL:b,postModelRender:h,flangeRef:l,...p})})})}),o.jsx(X,{})]})}),te=T.externalizeComponent(({rapidlyChangingMotionState:e,...n})=>{const t=L.useSmoothedMotionState(e);return o.jsx(F,{rapidlyChangingMotionState:t,...n})}),ne=T.externalizeComponent(e=>{const{inverseSolver:n,dhParameters:t,...r}=e,[i,c]=m.useState(O.JointTypeEnum.RevoluteJoint);m.useEffect(()=>{t.length&&c(t[0].type??O.JointTypeEnum.RevoluteJoint)},[t]);const l=m.useMemo(()=>n===null&&i===O.JointTypeEnum.RevoluteJoint,[n,i]),s=m.useMemo(()=>n===null&&i===O.JointTypeEnum.PrismaticJoint,[n,i]);return m.useMemo(()=>!!n,[n])||l?o.jsx(F,{dhParameters:t,...r}):s?o.jsx(I,{dhParameters:t,...r}):null}),Ce=T.externalizeComponent(e=>{const n=L.useSmoothedMotionState(e.rapidlyChangingMotionState);return o.jsx(ne,{...e,rapidlyChangingMotionState:n})});function Ie({connectedMotionGroup:e,getModel:n,flangeRef:t,transparentColor:r,postModelRender:i,...c}){const l=m.useCallback(f=>E(f,e.nova),[e]);if(!e.dhParameters)return null;const s=e.mountingPosition,a=e.mountingQuaternion;return o.jsx(te,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:n??l,flangeRef:t,transparentColor:r,postModelRender:i,chainOffsetPosition:s,chainOffsetQuaternion:a,...c})}exports.CollisionSceneRenderer=ce;exports.JointLimitGizmo=Re;exports.LinearAxis=Ae;exports.MotionGroupVisualizer=Ce;exports.MotionGroupVisualizerExact=ne;exports.PresetEnvironment=be;exports.Robot=Ie;exports.SafetyZonesRenderer=_e;exports.SupportedLinearAxis=z;exports.SupportedLinearAxisExact=I;exports.SupportedRobot=te;exports.SupportedRobotExact=F;exports.TrajectoryRenderer=ve;exports.defaultGetModel=E;