@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,505 @@
1
+ import { jsxs as d, jsx as o, Fragment as z } from "react/jsx-runtime";
2
+ import J from "@mui/material/Divider";
3
+ import W from "@mui/material/IconButton";
4
+ import C from "@mui/material/Stack";
5
+ import H from "@mui/material/Tooltip";
6
+ import R from "@mui/material/Typography";
7
+ import { ContentCopyFilled as tn } from "@wandelbots/icons/ContentCopyFilled";
8
+ import { Settings as on } from "@wandelbots/icons/Settings";
9
+ import { memo as rn, useId as K, useRef as $, useState as j, useCallback as T } from "react";
10
+ import { useTranslation as U } from "react-i18next";
11
+ import { e as an } from "./externalizeComponent-_w2d1_pz.js";
12
+ import { P as B, u as sn, a as ln, p as cn } from "./useEveryFrame-G_-ma1nC.js";
13
+ import { S as un } from "./SmallSelect-BdD9uLKK.js";
14
+ import pn from "@mui/material/ListSubheader";
15
+ import dn from "@mui/material/MenuItem";
16
+ import hn from "@mui/material/Popover";
17
+ import { AdornedSelect as mn } from "@wandelbots/mui";
18
+ import gn from "@mui/material/Box";
19
+ const G = [
20
+ // Tait–Bryan angles: three different axes
21
+ "XYZ",
22
+ "XZY",
23
+ "YXZ",
24
+ "YZX",
25
+ "ZXY",
26
+ "ZYX",
27
+ // Proper Euler angles: the first axis again at the end
28
+ "XYX",
29
+ "XZX",
30
+ "YXY",
31
+ "YZY",
32
+ "ZXZ",
33
+ "ZYZ"
34
+ ], xn = [
35
+ ...G.map((n) => `EULER_ANGLES_INTRINSIC_${n}`),
36
+ ...G.map((n) => `EULER_ANGLES_EXTRINSIC_${n}`)
37
+ ];
38
+ function y(n) {
39
+ const e = n.slice(n.lastIndexOf("_") + 1);
40
+ return {
41
+ intrinsic: n.includes("_INTRINSIC_"),
42
+ axes: [...e]
43
+ };
44
+ }
45
+ function Q([n, e, t]) {
46
+ const r = Math.hypot(n, e, t);
47
+ if (r < 1e-12) return [0, 0, 0, 1];
48
+ const c = Math.sin(r / 2) / r;
49
+ return [n * c, e * c, t * c, Math.cos(r / 2)];
50
+ }
51
+ const X = { X: 0, Y: 1, Z: 2 };
52
+ function Cn(n) {
53
+ return n > Math.PI ? n - 2 * Math.PI : n < -Math.PI ? n + 2 * Math.PI : n;
54
+ }
55
+ function bn(n, e) {
56
+ const { intrinsic: t, axes: r } = y(e), c = t ? [...r].reverse() : r, i = X[c[0]], s = X[c[1]], p = c[0] === c[2], a = p ? 3 - i - s : X[c[2]], h = (i - s) * (s - a) * (a - i) / 2, F = Math.hypot(...n) || 1, [M, A, v, b] = n.map((en) => en / F), I = [M, A, v], S = I[i] ?? 0, E = I[s] ?? 0, f = (I[a] ?? 0) * h, [O, g, _, w] = p ? [b, S, E, f] : [b - E, S + f, E + b, f - S];
57
+ let x = 2 * Math.atan2(Math.hypot(_, w), Math.hypot(O, g));
58
+ const N = Math.atan2(g, O), P = Math.atan2(w, _);
59
+ let l, u;
60
+ const m = 1e-7;
61
+ return Math.abs(x) <= m ? (l = 2 * N, u = 0) : Math.abs(x - Math.PI) <= m ? (l = -2 * P, u = 0) : (l = N - P, u = N + P), p || (u *= h, x -= Math.PI / 2), (t ? [u, x, l] : [l, x, u]).map(Cn);
62
+ }
63
+ function Z({ children: n }) {
64
+ return /* @__PURE__ */ o(pn, { children: n });
65
+ }
66
+ Z.muiSkipListHighlight = !0;
67
+ function fn({
68
+ value: n,
69
+ onChange: e
70
+ }) {
71
+ const { t } = U(), r = K(), c = (s) => {
72
+ const { intrinsic: p, axes: a } = y(s);
73
+ return t(
74
+ p ? "CurrentPose.EulerConvention.Intrinsic.lb" : "CurrentPose.EulerConvention.Extrinsic.lb",
75
+ { axes: a.join("") }
76
+ );
77
+ }, i = (s) => xn.filter(
78
+ (p) => y(p).intrinsic === s
79
+ ).map((p) => /* @__PURE__ */ o(dn, { value: p, children: y(p).axes.join("") }, p));
80
+ return /* @__PURE__ */ d(
81
+ mn,
82
+ {
83
+ label: t("CurrentPose.EulerConvention.lb"),
84
+ labelId: r,
85
+ value: n,
86
+ renderValue: (s) => c(s),
87
+ onChange: (s) => e(s.target.value),
88
+ children: [
89
+ /* @__PURE__ */ o(Z, { children: t("CurrentPose.EulerConvention.Intrinsic.hlb") }),
90
+ i(!0),
91
+ /* @__PURE__ */ o(Z, { children: t("CurrentPose.EulerConvention.Extrinsic.hlb") }),
92
+ i(!1)
93
+ ]
94
+ }
95
+ );
96
+ }
97
+ const vn = rn(
98
+ In,
99
+ (n, e) => n.anchor === e.anchor && n.open === e.open && n.onClose === e.onClose && n.onChange === e.onChange && n.format.type === e.format.type && n.format.angleUnit === e.format.angleUnit && n.format.eulerConvention === e.format.eulerConvention
100
+ );
101
+ function In({
102
+ anchor: n,
103
+ open: e,
104
+ onClose: t,
105
+ format: r,
106
+ onChange: c
107
+ }) {
108
+ const { t: i } = U(), s = i("CurrentPose.OrientationFormat.ti"), p = (a) => c({ ...r, ...a });
109
+ return /* @__PURE__ */ d(
110
+ hn,
111
+ {
112
+ open: e,
113
+ anchorEl: n,
114
+ onClose: t,
115
+ anchorOrigin: { vertical: "top", horizontal: "left" },
116
+ transformOrigin: { vertical: "bottom", horizontal: "left" },
117
+ slotProps: {
118
+ paper: {
119
+ role: "dialog",
120
+ "aria-label": s,
121
+ sx: (a) => {
122
+ var h;
123
+ return {
124
+ width: "264px",
125
+ padding: "16px",
126
+ display: "flex",
127
+ flexDirection: "column",
128
+ gap: "16px",
129
+ borderRadius: "10px",
130
+ border: `1px solid ${a.palette.divider}`,
131
+ background: (h = a.palette.backgroundPaperElevation) == null ? void 0 : h[2],
132
+ backgroundImage: "none",
133
+ boxShadow: a.shadows[16]
134
+ };
135
+ }
136
+ }
137
+ },
138
+ children: [
139
+ /* @__PURE__ */ o(R, { variant: "subtitle2", color: "text.primary", children: s }),
140
+ /* @__PURE__ */ o(J, {}),
141
+ /* @__PURE__ */ d(C, { sx: { gap: "8px" }, children: [
142
+ /* @__PURE__ */ o(
143
+ B,
144
+ {
145
+ label: i("CurrentPose.Format.lb"),
146
+ options: [
147
+ {
148
+ id: "rotationVector",
149
+ label: i("CurrentPose.Format.RotationVector.lb")
150
+ },
151
+ {
152
+ id: "eulerAngles",
153
+ label: i("CurrentPose.Format.EulerAngles.lb")
154
+ },
155
+ { id: "quaternion", label: i("CurrentPose.Format.Quaternion.lb") }
156
+ ],
157
+ value: r.type,
158
+ onChange: (a) => p({ type: a }),
159
+ disabled: !1
160
+ }
161
+ ),
162
+ r.type !== "quaternion" && /* @__PURE__ */ o(
163
+ B,
164
+ {
165
+ label: i("CurrentPose.AngleUnit.lb"),
166
+ options: [
167
+ { id: "rad", label: i("CurrentPose.AngleUnit.Radians.lb") },
168
+ { id: "deg", label: i("CurrentPose.AngleUnit.Degrees.lb") }
169
+ ],
170
+ value: r.angleUnit,
171
+ onChange: (a) => p({ angleUnit: a }),
172
+ disabled: !1
173
+ }
174
+ ),
175
+ r.type === "eulerAngles" && /* @__PURE__ */ o(
176
+ fn,
177
+ {
178
+ value: r.eulerConvention,
179
+ onChange: (a) => p({ eulerConvention: a })
180
+ }
181
+ )
182
+ ] })
183
+ ]
184
+ }
185
+ );
186
+ }
187
+ const Sn = {
188
+ type: "rotationVector",
189
+ angleUnit: "rad",
190
+ eulerConvention: "EULER_ANGLES_EXTRINSIC_XYZ"
191
+ };
192
+ function L(n, e) {
193
+ const t = n.toFixed(e);
194
+ return Number(t) === 0 ? 0 .toFixed(e) : t;
195
+ }
196
+ function V(n, e) {
197
+ return e === "deg" ? `${L(n * 180 / Math.PI, 1)}°` : `${L(n, 3)} rad`;
198
+ }
199
+ function En(n) {
200
+ switch (n.type) {
201
+ case "quaternion":
202
+ return ["Qx", "Qy", "Qz", "Qw"];
203
+ case "eulerAngles":
204
+ return y(n.eulerConvention).axes.map(
205
+ (e) => `R${e.toLowerCase()}`
206
+ );
207
+ default:
208
+ return ["Rx", "Ry", "Rz"];
209
+ }
210
+ }
211
+ function Nn(n, e) {
212
+ switch (e.type) {
213
+ case "quaternion":
214
+ return Q(n).map((t) => L(t, 3));
215
+ case "eulerAngles":
216
+ return bn(
217
+ Q(n),
218
+ e.eulerConvention
219
+ ).map((t) => V(t, e.angleUnit));
220
+ default:
221
+ return n.map((t) => V(t, e.angleUnit));
222
+ }
223
+ }
224
+ function Pn(n, e) {
225
+ const t = ["x", "y", "z"].map((i, s) => ({
226
+ label: i.toUpperCase(),
227
+ value: n ? L(n.position[s] ?? 0, 1) : "–",
228
+ kind: i
229
+ })), r = n ? Nn(n.orientation, e) : null, c = En(e).map((i, s) => ({
230
+ label: i,
231
+ value: (r == null ? void 0 : r[s]) ?? "–",
232
+ kind: "orientation"
233
+ }));
234
+ return [...t, ...c];
235
+ }
236
+ const yn = {
237
+ KIND_UNKNOWN: "success.main",
238
+ RUNNING: "info.main",
239
+ PAUSED_NEAR_COLLISION: "warning.main",
240
+ PAUSED_NEAR_JOINT_LIMIT: "warning.main",
241
+ PAUSED_NEAR_SINGULARITY: "warning.main"
242
+ };
243
+ function Rn({
244
+ state: n,
245
+ error: e
246
+ }) {
247
+ const { t } = U(), r = n ?? "KIND_UNKNOWN", c = e || t(`Jogging.StreamStateSection.${r}.lb`), i = e ? "error.main" : yn[r] ?? "text.secondary";
248
+ return (
249
+ // A long error is cut off: the whole of it on hover
250
+ /* @__PURE__ */ o(H, { title: e ? c : "", placement: "top-end", children: /* @__PURE__ */ d(
251
+ C,
252
+ {
253
+ direction: "row",
254
+ "data-testid": e ? "JOG_ERROR" : r,
255
+ sx: { gap: "5px", alignItems: "center", minWidth: 0 },
256
+ children: [
257
+ /* @__PURE__ */ o(
258
+ gn,
259
+ {
260
+ sx: {
261
+ width: "6px",
262
+ height: "6px",
263
+ borderRadius: "50%",
264
+ flexShrink: 0,
265
+ bgcolor: i
266
+ }
267
+ }
268
+ ),
269
+ /* @__PURE__ */ o(
270
+ R,
271
+ {
272
+ variant: "caption",
273
+ noWrap: !0,
274
+ sx: { color: i, letterSpacing: "0.17px" },
275
+ children: c
276
+ }
277
+ )
278
+ ]
279
+ }
280
+ ) })
281
+ );
282
+ }
283
+ const k = { letterSpacing: "0.17px" }, An = {
284
+ x: "error.main",
285
+ y: "success.main",
286
+ z: "info.main",
287
+ orientation: "grey.600"
288
+ };
289
+ function nn({ children: n, id: e }) {
290
+ return /* @__PURE__ */ o(
291
+ R,
292
+ {
293
+ id: e,
294
+ variant: "caption",
295
+ color: "text.secondary",
296
+ noWrap: !0,
297
+ sx: k,
298
+ children: n
299
+ }
300
+ );
301
+ }
302
+ function q({
303
+ label: n,
304
+ ...e
305
+ }) {
306
+ const t = K();
307
+ return /* @__PURE__ */ d(C, { direction: "row", sx: { gap: "8px", alignItems: "center" }, children: [
308
+ /* @__PURE__ */ o(nn, { id: t, children: n }),
309
+ /* @__PURE__ */ o(un, { labelId: t, width: "172px", ...e })
310
+ ] });
311
+ }
312
+ const Y = () => /* @__PURE__ */ o(J, { orientation: "vertical", flexItem: !1, sx: { height: "16px" } }), Gn = an(
313
+ ({
314
+ getCurrentPose: n,
315
+ tcp: e,
316
+ frame: t,
317
+ state: r,
318
+ error: c,
319
+ orientationFormat: i,
320
+ onOrientationFormatChange: s,
321
+ sx: p
322
+ }) => {
323
+ const { t: a } = U(), h = $(null), [F, M] = j(Sn), A = i ?? F, [v, b] = j(null), { copied: I, copy: S } = sn(), E = ln(() => JSON.stringify(n()), !0), f = JSON.parse(E), O = Pn(f, A), g = $({ tcp: e, frame: t, onOrientationFormatChange: s });
324
+ g.current = { tcp: e, frame: t, onOrientationFormatChange: s };
325
+ const _ = T(
326
+ (l) => {
327
+ var u;
328
+ return (u = g.current.tcp) == null ? void 0 : u.onChange(l);
329
+ },
330
+ []
331
+ ), w = T(
332
+ (l) => {
333
+ var u;
334
+ return (u = g.current.frame) == null ? void 0 : u.onChange(l);
335
+ },
336
+ []
337
+ ), x = T((l) => {
338
+ var u, m;
339
+ M(l), (m = (u = g.current).onOrientationFormatChange) == null || m.call(u, l);
340
+ }, []), N = T(() => b(null), []);
341
+ function P() {
342
+ const l = n();
343
+ l && S(cn(l));
344
+ }
345
+ return /* @__PURE__ */ d(
346
+ C,
347
+ {
348
+ ref: h,
349
+ direction: "row",
350
+ "data-testid": "current-pose-bar",
351
+ sx: [
352
+ (l) => {
353
+ var u;
354
+ return {
355
+ alignItems: "center",
356
+ justifyContent: "space-between",
357
+ gap: "12px",
358
+ padding: "8px 16px",
359
+ minHeight: "54px",
360
+ boxSizing: "border-box",
361
+ borderRadius: "10px",
362
+ border: `1px solid ${l.palette.divider}`,
363
+ background: (u = l.palette.backgroundPaperElevation) == null ? void 0 : u[2],
364
+ boxShadow: l.shadows[16]
365
+ };
366
+ },
367
+ ...Array.isArray(p) ? p : [p]
368
+ ],
369
+ children: [
370
+ /* @__PURE__ */ d(
371
+ C,
372
+ {
373
+ direction: "row",
374
+ sx: { gap: "12px", alignItems: "center", minWidth: 0 },
375
+ children: [
376
+ /* @__PURE__ */ o(nn, { children: a("CurrentPose.Title.lb") }),
377
+ /* @__PURE__ */ o(
378
+ W,
379
+ {
380
+ "aria-label": a("CurrentPose.OrientationFormat.ti"),
381
+ "aria-haspopup": "dialog",
382
+ "aria-expanded": v !== null,
383
+ onClick: () => b(h.current),
384
+ sx: { padding: "3px", margin: "-3px", color: "text.secondary" },
385
+ children: /* @__PURE__ */ o(on, {})
386
+ }
387
+ ),
388
+ e && /* @__PURE__ */ d(z, { children: [
389
+ /* @__PURE__ */ o(Y, {}),
390
+ /* @__PURE__ */ o(
391
+ q,
392
+ {
393
+ label: a("RobotControl.Tcp.lb"),
394
+ options: e.options,
395
+ value: e.value,
396
+ onChange: _
397
+ }
398
+ )
399
+ ] }),
400
+ t && /* @__PURE__ */ d(z, { children: [
401
+ /* @__PURE__ */ o(Y, {}),
402
+ /* @__PURE__ */ o(
403
+ q,
404
+ {
405
+ label: a("CurrentPose.RelativeTo.lb"),
406
+ options: t.options,
407
+ value: t.value,
408
+ onChange: w
409
+ }
410
+ )
411
+ ] }),
412
+ /* @__PURE__ */ o(Y, {}),
413
+ /* @__PURE__ */ o(
414
+ C,
415
+ {
416
+ direction: "row",
417
+ "data-testid": "current-pose-values",
418
+ sx: {
419
+ gap: "12px",
420
+ alignItems: "center",
421
+ minWidth: 0,
422
+ overflow: "hidden"
423
+ },
424
+ children: O.map(({ label: l, value: u, kind: m }, D) => /* @__PURE__ */ d(
425
+ C,
426
+ {
427
+ direction: "row",
428
+ sx: { gap: m === "orientation" ? "1px" : "2px" },
429
+ children: [
430
+ /* @__PURE__ */ o(
431
+ R,
432
+ {
433
+ variant: "caption",
434
+ sx: { ...k, color: An[m] },
435
+ children: l
436
+ }
437
+ ),
438
+ /* @__PURE__ */ o(
439
+ R,
440
+ {
441
+ variant: "caption",
442
+ noWrap: !0,
443
+ sx: {
444
+ ...k,
445
+ color: "text.secondary",
446
+ // Digits of one width: the values don't jump while jogging
447
+ fontVariantNumeric: "tabular-nums"
448
+ },
449
+ children: u
450
+ }
451
+ )
452
+ ]
453
+ },
454
+ D
455
+ ))
456
+ }
457
+ ),
458
+ /* @__PURE__ */ o(
459
+ H,
460
+ {
461
+ title: a("CurrentPose.Copied.lb"),
462
+ open: I,
463
+ disableHoverListener: !0,
464
+ placement: "top",
465
+ children: /* @__PURE__ */ o("span", { children: /* @__PURE__ */ o(
466
+ W,
467
+ {
468
+ "aria-label": a("CurrentPose.Copy.bt"),
469
+ onClick: P,
470
+ disabled: !f,
471
+ sx: {
472
+ width: "30px",
473
+ height: "30px",
474
+ padding: "5px",
475
+ borderRadius: "10px",
476
+ color: "text.secondary",
477
+ "& svg": { width: "20px", height: "20px" }
478
+ },
479
+ children: /* @__PURE__ */ o(tn, {})
480
+ }
481
+ ) })
482
+ }
483
+ )
484
+ ]
485
+ }
486
+ ),
487
+ /* @__PURE__ */ o(Rn, { state: r, error: c }),
488
+ /* @__PURE__ */ o(
489
+ vn,
490
+ {
491
+ anchor: v,
492
+ open: v !== null,
493
+ onClose: N,
494
+ format: A,
495
+ onChange: x
496
+ }
497
+ )
498
+ ]
499
+ }
500
+ );
501
+ }
502
+ );
503
+ export {
504
+ Gn as C
505
+ };
@@ -0,0 +1,108 @@
1
+ import { jsx as t, jsxs as b } from "react/jsx-runtime";
2
+ import C from "@mui/material/Box";
3
+ import { buttonClasses as l } from "@mui/material/Button";
4
+ import h from "@mui/material/Stack";
5
+ import { alpha as d } from "@mui/material/styles";
6
+ import I from "@mui/material/Typography";
7
+ import { Rotation as j } from "@wandelbots/icons/Rotation";
8
+ import { SecondaryButton as y } from "@wandelbots/mui";
9
+ import { e as v } from "./externalizeComponent-_w2d1_pz.js";
10
+ import { u as J, J as S, a as k, j as u, b as R } from "./joggingColors-CuT5u0H8.js";
11
+ function $({
12
+ axis: o,
13
+ motion: r,
14
+ disabled: s
15
+ }) {
16
+ const e = u[o];
17
+ return /* @__PURE__ */ t(
18
+ C,
19
+ {
20
+ "aria-hidden": !0,
21
+ sx: {
22
+ opacity: s ? 0.4 : 1,
23
+ width: 30,
24
+ height: 30,
25
+ flexShrink: 0,
26
+ display: "flex",
27
+ alignItems: "center",
28
+ justifyContent: "center",
29
+ borderRadius: 1,
30
+ backgroundColor: d(e, 0.15),
31
+ border: `1px solid ${d(e, 0.4)}`
32
+ },
33
+ children: /* @__PURE__ */ t(I, { variant: "caption", sx: { color: e }, children: r === "rotate" ? `R${o}` : o.toUpperCase() })
34
+ }
35
+ );
36
+ }
37
+ function w(o) {
38
+ return /* @__PURE__ */ t(
39
+ j,
40
+ {
41
+ style: o.direction === "-" ? { transform: "scaleX(-1)" } : void 0
42
+ }
43
+ );
44
+ }
45
+ const _ = v(
46
+ (o) => {
47
+ const { motion: r = "translate", disabled: s = !1 } = o, { handlersFor: e, label: f, isPressed: x } = J(o);
48
+ return /* @__PURE__ */ t(
49
+ h,
50
+ {
51
+ "data-testid": "jogging-buttons",
52
+ sx: { gap: "16px", width: 280, maxWidth: "100%" },
53
+ children: S.map((a) => /* @__PURE__ */ b(
54
+ h,
55
+ {
56
+ direction: "row",
57
+ sx: { alignItems: "center", gap: "16px" },
58
+ children: [
59
+ /* @__PURE__ */ t($, { axis: a, motion: r, disabled: s }),
60
+ k.map((i) => {
61
+ const n = { axis: a, direction: i }, c = x(n), m = r === "rotate" ? w(n) : void 0, p = u[a], g = {
62
+ backgroundColor: d(p, 0.25),
63
+ borderColor: d(p, 0.4)
64
+ };
65
+ return /* @__PURE__ */ t(
66
+ y,
67
+ {
68
+ size: "large",
69
+ disabled: s,
70
+ "aria-label": f(n),
71
+ "aria-pressed": c,
72
+ startIcon: i === "-" ? m : void 0,
73
+ endIcon: i === "+" ? m : void 0,
74
+ ...e(n),
75
+ sx: {
76
+ flex: 1,
77
+ // A held button must not scroll the page or select text
78
+ touchAction: "none",
79
+ userSelect: "none",
80
+ // The turn icon as the design has it: 24 px, in the 18 px
81
+ // wide slot of its icon, so the label stays where it is
82
+ "& svg": { width: 24, height: 24 },
83
+ [`& .${l.startIcon}`]: { marginLeft: "-6px" },
84
+ [`& .${l.endIcon}`]: { marginRight: "-6px" },
85
+ // Pressed also while disabled: an app disables the
86
+ // buttons while a step runs, and shows that step with
87
+ // activeHandle
88
+ ...c && {
89
+ ...g,
90
+ [`&.${l.disabled}`]: g
91
+ }
92
+ },
93
+ children: R(n, r)
94
+ },
95
+ i
96
+ );
97
+ })
98
+ ]
99
+ },
100
+ a
101
+ ))
102
+ }
103
+ );
104
+ }
105
+ );
106
+ export {
107
+ _ as J
108
+ };
@@ -0,0 +1 @@
1
+ "use strict";const o=require("react/jsx-runtime"),j=require("@mui/material/Box"),d=require("@mui/material/Button"),x=require("@mui/material/Stack"),l=require("@mui/material/styles"),m=require("@mui/material/Typography"),q=require("@wandelbots/icons/Rotation"),f=require("@wandelbots/mui"),I=require("./externalizeComponent-BdxGBLIv.cjs"),t=require("./joggingColors-ZDc_2UCp.cjs");function y({axis:e,motion:n,disabled:i}){const r=t.jogAxisColors[e];return o.jsx(j,{"aria-hidden":!0,sx:{opacity:i?.4:1,width:30,height:30,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:1,backgroundColor:l.alpha(r,.15),border:`1px solid ${l.alpha(r,.4)}`},children:o.jsx(m,{variant:"caption",sx:{color:r},children:n==="rotate"?`R${e}`:e.toUpperCase()})})}function R(e){return o.jsx(q.Rotation,{style:e.direction==="-"?{transform:"scaleX(-1)"}:void 0})}const v=I.externalizeComponent(e=>{const{motion:n="translate",disabled:i=!1}=e,{handlersFor:r,label:C,isPressed:b}=t.useJogControls(e);return o.jsx(x,{"data-testid":"jogging-buttons",sx:{gap:"16px",width:280,maxWidth:"100%"},children:t.JOG_AXES.map(a=>o.jsxs(x,{direction:"row",sx:{alignItems:"center",gap:"16px"},children:[o.jsx(y,{axis:a,motion:n,disabled:i}),t.JOG_DIRECTIONS.map(c=>{const s={axis:a,direction:c},u=b(s),g=n==="rotate"?R(s):void 0,h=t.jogAxisColors[a],p={backgroundColor:l.alpha(h,.25),borderColor:l.alpha(h,.4)};return o.jsx(f.SecondaryButton,{size:"large",disabled:i,"aria-label":C(s),"aria-pressed":u,startIcon:c==="-"?g:void 0,endIcon:c==="+"?g:void 0,...r(s),sx:{flex:1,touchAction:"none",userSelect:"none","& svg":{width:24,height:24},[`& .${d.buttonClasses.startIcon}`]:{marginLeft:"-6px"},[`& .${d.buttonClasses.endIcon}`]:{marginRight:"-6px"},...u&&{...p,[`&.${d.buttonClasses.disabled}`]:p}},children:t.jogHandleName(s,n)},c)})]},a))})});exports.JoggingButtons=v;
@@ -0,0 +1 @@
1
+ "use strict";const d=require("react/jsx-runtime"),R=require("@mui/material/Box"),z=require("@react-three/fiber"),M=require("react"),g=require("three"),pt=require("./externalizeComponent-BdxGBLIv.cjs"),E=require("./joggingColors-ZDc_2UCp.cjs"),$=require("@mui/material/styles"),Y=new g.Vector3(0,1,0),I=.26,Z=.1,dt={x:"X",y:"Y",z:"Z"};function V(t){var e;return((e=E.cartesianAxisColors[dt[t]].buttonBackgroundColor)==null?void 0:e.default)??"currentColor"}const ft=200;function F(t){const e=t/ft;return{marginPx:30*e,gripPx:30*e,grab:{innerPx:10*e,beyondTipPx:10*e,minTipPx:16*e},labelFontPx:Math.max(10,13*e)}}function xt(t,e,n){return Math.max(1,Math.min(t,e)/2-n)}function yt(t,e){const{gripPx:n,grab:l}=F(t);return{radiusPx:e,gripPx:n,headLength:I,...l}}function gt(t,e){const{gripPx:n,grab:l}=F(t);return{radiusPx:e,gripPx:n,beyondTipPx:l.beyondTipPx,headLength:I}}function _(t,e){return n=>{n?t.current.set(e,n):t.current.delete(e)}}const O=t=>`${t.axis}${t.direction}`,tt=t=>`label:${t}`,et=[0,1],nt=(t,e)=>`half:${O(t)}:${e}`,ot=t=>`halo:${O(t)}`,st=t=>`focus:${O(t)}`,C="polygon(0 0, 0 0, 0 0)";function rt(t,{isPressed:e,hovered:n,disabled:l}){const r=e(t),s=!l&&(r||E.isSameJogHandle(n,t));return{pressed:r,lit:s}}function at(t,{pressed:e,lit:n}){return e?$.alpha(t,.25):n?$.alpha(t,.12):"transparent"}function ct(t,{onHover:e,handlersFor:n}){return{onPointerEnter:()=>e(t),onPointerLeave:()=>e(null),...n(t)}}const q=t=>({cursor:t?"default":"pointer",touchAction:"none",userSelect:"none"}),it=t=>`2px solid ${t.palette.primary.main}`,J={x:new g.Vector3(1,0,0),y:new g.Vector3(0,1,0),z:new g.Vector3(0,0,1)};function mt(t,e,n=new g.Quaternion){return n.copy(t).invert().multiply(e)}const bt=new g.Quaternion().setFromRotationMatrix(new g.Matrix4().makeBasis(new g.Vector3(1,0,0),new g.Vector3(0,0,-1),new g.Vector3(0,1,0))),L=new g.Quaternion,St=new g.Quaternion;function At(t){return t.up.z>.5?St:bt}function Mt(t,e=new g.Quaternion){return t.getWorldQuaternion(L),mt(L,At(t),e)}function Et(t,e,n=new g.Quaternion){return n.copy(t).multiply(e)}const wt=1e-8;function B(t,e){return t?Math.abs(t.dot(e))<1-wt:!0}function jt(t){const{disabled:e,label:n,overlay:l,size:r}=t,s=$.useTheme(),{gripPx:a}=F(r);return E.JOG_AXES.flatMap(u=>E.JOG_DIRECTIONS.map(o=>{const i={axis:u,direction:o},x=rt(i,t),c=ct(i,t);return d.jsxs(M.Fragment,{children:[d.jsx(R,{component:"span","aria-hidden":!0,ref:_(l,ot(i)),sx:{position:"absolute",inset:0,clipPath:C,pointerEvents:"none",background:at(V(u),x)}}),et.map(h=>d.jsx(R,{component:"span","aria-hidden":!0,ref:_(l,nt(i,h)),...c,sx:{position:"absolute",inset:0,clipPath:C,...q(e)}},h)),d.jsx(R,{component:"button",type:"button",ref:_(l,O(i)),disabled:e,"aria-label":n(i),"aria-pressed":x.pressed,...c,sx:{position:"absolute",width:a,height:a,transform:"translate(-50%, -50%)",padding:0,border:"none",borderRadius:"50%",background:"transparent","&:focus-visible":{outline:it(s)},"&[data-band='shown']:focus-visible":{outline:"none"},...q(e)}}),d.jsx(R,{component:"svg","aria-hidden":!0,sx:{position:"absolute",left:0,top:0,width:r,height:r,overflow:"visible",pointerEvents:"none",display:"none",zIndex:100,"button[data-band='shown']:focus-visible + &":{display:"block"}},children:d.jsx("path",{ref:_(l,st(i)),fill:"none",stroke:s.palette.primary.main,strokeWidth:2,strokeLinejoin:"round"})})]},O(i))}))}const T=.8,Q=.45,lt=2.25,ut={x:[new g.Vector3(0,1,0),new g.Vector3(0,0,1)],y:[new g.Vector3(-1,0,0),new g.Vector3(0,0,1)],z:[new g.Vector3(1,0,0),new g.Vector3(0,1,0)]};function H(t){const e=t==="+"?Q:Q+Math.PI,n=e+lt;return{start:e,end:n,head:t==="+"?n:e}}const Ot=new g.Vector3,P=new g.Vector3,Rt=new g.Vector3;function _t(t,e=24){const n=[];for(const l of E.JOG_AXES){const[r,s]=ut[l],a=o=>Ot.copy(r).multiplyScalar(Math.cos(o)*T).addScaledVector(s,Math.sin(o)*T).applyQuaternion(t),u=Math.abs(Rt.copy(J[l]).applyQuaternion(t).z);for(const o of E.JOG_DIRECTIONS){const{start:i,end:x,head:c}=H(o),h=[];for(let A=0;A<=e;A++){const w=a(i+(x-i)*A/e);h.push({x:w.x+0,y:-w.y+0,depth:w.z})}const m=a(c),p={x:m.x+0,y:-m.y+0,depth:m.z},f=o==="+"?1:-1;P.copy(r).multiplyScalar(-Math.sin(c)*f).addScaledVector(s,Math.cos(c)*f).applyQuaternion(t);const y=Math.hypot(P.x,P.y),b=y>1e-9?P.x/y:0,S=y>1e-9?-P.y/y:0;n.push({axis:l,direction:o,points:h,head:{...p,dx:b+0,dy:S+0},openness:u})}}return n}function It(t,e,n){let l={distance:Number.POSITIVE_INFINITY,depth:0};for(let r=1;r<t.length;r++){const s=t[r-1],a=t[r],u=(a.x-s.x)**2+(a.y-s.y)**2,o=u===0?0:Math.min(1,Math.max(0,((e-s.x)*(a.x-s.x)+(n-s.y)*(a.y-s.y))/u)),i=Math.hypot(e-(s.x+o*(a.x-s.x)),n-(s.y+o*(a.y-s.y)));i<l.distance&&(l={distance:i,depth:s.depth+o*(a.depth-s.depth)})}return l}function Tt(t,e){const n=t.length,l=t.map(()=>new Array(n).fill(!1));for(let o=0;o<n;o++)for(let i=o+1;i<n;i++){if(t[o].arc===t[i].arc)continue;let x=0;for(const c of t[o].line){const h=It(t[i].line,c.x,c.y);h.distance<e&&(x+=c.depth-h.depth)}x>0?l[o][i]=!0:x<0&&(l[i][o]=!0)}const r=t.map(({line:o})=>o.reduce((i,x)=>i+x.depth,0)/o.length),s=(o,i)=>r[o]-r[i],a=new Array(n).fill(0),u=new Set(t.keys());for(let o=1;u.size>0;o++){const i=[...u],x=i.filter(h=>!i.some(m=>l[h][m])),c=(x.length>0?x:i).sort(s)[0];a[c]=o,u.delete(c)}return a}const k=8;function D(t,e){const n=[...t];if(e>=0){const r=n[n.length-1],s=n[n.length-2],a=Math.hypot(r.x-s.x,r.y-s.y)||1;return n.push({x:r.x+(r.x-s.x)/a*e,y:r.y+(r.y-s.y)/a*e,depth:r.depth}),n}let l=-e;for(;n.length>2;){const r=n[n.length-1],s=n[n.length-2],a=Math.hypot(r.x-s.x,r.y-s.y);if(a>l){const u=l/a;return n[n.length-1]={x:r.x+(s.x-r.x)*u,y:r.y+(s.y-r.y)*u,depth:r.depth+(s.depth-r.depth)*u},n}l-=a,n.pop()}return n}const X=(t,e)=>D([...t].reverse(),e).reverse();function vt(t,e){const n=e/2,l=[],r=[],s=[];let a={x:0,y:0};for(const[o,i]of t.entries()){const x=t[Math.max(0,o-1)],c=t[Math.min(t.length-1,o+1)],h=c.x-x.x,m=c.y-x.y,p=Math.hypot(h,m);p>1e-9&&(a={x:-m/p,y:h/p}),s.push(a),l.push({x:i.x+a.x*n,y:i.y+a.y*n}),r.push({x:i.x-a.x*n,y:i.y-a.y*n})}const u=(o,i)=>{const x=s[o],c={x:x.y,y:-x.x},h=i?1:-1;return Array.from({length:k-1},(m,p)=>{const f=Math.PI*(p+1)/k,y=Math.cos(f)*h,b=Math.sin(f)*h;return{x:t[o].x+(x.x*y+c.x*b)*n,y:t[o].y+(x.y*y+c.y*b)*n}})};return(o,i)=>[...l.slice(o,i+1),...i===t.length-1?u(i,!0):[],...r.slice(o,i+1).reverse(),...o===0?u(o,!1):[]]}function Gt(t,e){return[{from:0,to:Math.min(t-1,e+1)},{from:Math.max(0,e-1),to:t-1}]}function Pt(t,{radiusPx:e,gripPx:n,beyondTipPx:l,headLength:r}){const s=n/2,a=r/2*e+l-s,u=l-s,o=t.map(p=>{const f=p.points.map(S=>({x:S.x*e,y:S.y*e,depth:S.depth})),y=f[f.length>>1],b=p.direction==="+"?X(D(f,a),u):D(X(f,a),u);return{line:b,middle:b.indexOf(y)}}),i=o.map(({line:p})=>p),x=t.map(p=>2*T*e*p.openness>=n),c=i.flatMap((p,f)=>x[f]?Gt(p.length,o[f].middle).map(({from:y,to:b})=>({arc:f,from:y,to:b,line:p.slice(y,b+1)})):[]),h=Tt(c,n),m=t.map((p,f)=>f).sort((p,f)=>t[p].head.depth-t[f].head.depth);return t.map((p,f)=>{if(!x[f])return null;const y=vt(i[f],n),b=c.flatMap((S,A)=>S.arc===f?[{...S,layer:h[A]}]:[]);return{band:y(0,i[f].length-1),halves:b.map(({from:S,to:A,layer:w})=>({polygon:y(S,A),layer:w})),head:{x:p.head.x*e,y:p.head.y*e},headLayer:c.length+1+m.indexOf(f)}})}function ht(t,e,n,l){const r=M.useRef(null),s=z.useThree(a=>a.invalidate);M.useEffect(()=>{r.current=null,s()},[l,s]),M.useEffect(()=>{let a=requestAnimationFrame(function u(){const o=t.current;o&&B(r.current,o)&&s(),a=requestAnimationFrame(u)});return()=>cancelAnimationFrame(a)},[t,s]),z.useFrame(()=>{const a=t.current;!a||!e.current||B(r.current,a)&&(e.current.quaternion.copy(a),n(a)&&(r.current=a.clone()))})}const U=.03;function Vt({orientation:t,lit:e,disabled:n,size:l,radius:r,overlay:s}){const a=M.useRef(null),u=l/2,o=c=>`${(u+c).toFixed(2)}px`,i=c=>`polygon(${c.map(h=>`${o(h.x)} ${o(h.y)}`).join(", ")})`,x=c=>`M${c.map(h=>`${(u+h.x).toFixed(2)} ${(u+h.y).toFixed(2)}`).join("L")}Z`;return ht(t,a,c=>{let h=!0;const m=_t(c),p=Pt(m,gt(l,r));for(const[f,y]of m.entries()){const b=s.current.get(O(y)),S=s.current.get(ot(y)),A=s.current.get(st(y)),w=et.map(v=>s.current.get(nt(y,v)));if(!b||!S||!A||w.some(v=>!v)){h=!1;continue}const j=p[f];b.style.left=o(y.head.x*r),b.style.top=o(y.head.y*r),b.style.zIndex=j?String(j.headLayer):"0",b.style.pointerEvents=j?"":"none",b.dataset.band=j?"shown":"none",S.style.clipPath=j?i(j.band):C,A.setAttribute("d",j?x(j.band):"");for(const[v,N]of w.entries()){if(!N)continue;const G=j==null?void 0:j.halves[v];N.style.clipPath=G?i(G.polygon):C,N.style.zIndex=G?String(G.layer):"0",N.style.pointerEvents=G?"":"none"}}return h},`${l}:${r}`),d.jsxs("group",{ref:a,children:[d.jsxs("mesh",{children:[d.jsx("sphereGeometry",{args:[.07,16,16]}),d.jsx("meshBasicMaterial",{color:"#c4c8d0"})]}),E.JOG_AXES.map(c=>d.jsx(Ft,{axis:c,color:V(c),lit:(e==null?void 0:e.axis)===c?e.direction:null,disabled:n},c))]})}function Ft({axis:t,color:e,lit:n,disabled:l}){const r=M.useMemo(()=>{const[s,a]=ut[t];return new g.Quaternion().setFromRotationMatrix(new g.Matrix4().makeBasis(s,a,J[t]))},[t]);return d.jsx("group",{quaternion:r,children:E.JOG_DIRECTIONS.map(s=>{const a=n===s,u=a?1:l?.35:.8,o=a?U*1.5:U;return d.jsxs("group",{children:[d.jsxs("mesh",{rotation:[0,0,H(s).start],children:[d.jsx("torusGeometry",{args:[T,o,12,48,lt]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:u})]}),d.jsx(Nt,{direction:s,color:e,opacity:u,lit:a})]},s)})})}function Nt({direction:t,color:e,opacity:n,lit:l}){const{position:r,rotation:s}=M.useMemo(()=>{const{head:a}=H(t),u=t==="+"?1:-1;return{position:new g.Vector3(Math.cos(a)*T,Math.sin(a)*T,0),rotation:new g.Quaternion().setFromUnitVectors(Y,new g.Vector3(-Math.sin(a)*u,Math.cos(a)*u,0))}},[t]);return d.jsxs("mesh",{position:r,quaternion:s,scale:l?1.2:1,children:[d.jsx("coneGeometry",{args:[Z,I,20]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:n})]})}function $t(t){const{disabled:e,label:n,overlay:l,size:r}=t,s=$.useTheme(),{gripPx:a,labelFontPx:u}=F(r);return d.jsxs(d.Fragment,{children:[E.JOG_AXES.map(o=>d.jsx(R,{component:"span","aria-hidden":!0,ref:_(l,tt(o)),sx:{position:"absolute",transform:"translate(-50%, -50%)",pointerEvents:"none",fontSize:u,color:V(o),opacity:e?.4:1},children:o.toUpperCase()},o)),E.JOG_AXES.flatMap(o=>E.JOG_DIRECTIONS.map(i=>{const x={axis:o,direction:i},c=rt(x,t);return d.jsx(R,{component:"button",type:"button",ref:_(l,O(x)),disabled:e,"aria-label":n(x),"aria-pressed":c.pressed,...ct(x,t),sx:{position:"absolute",height:a,transformOrigin:"0 50%",padding:0,borderRadius:`${a/2}px`,border:"none",background:at(V(o),c),"&:focus-visible":{outline:it(s)},...q(e)}},O(x))}))]})}function Ct(t){const e=[];for(const n of E.JOG_AXES)for(const l of E.JOG_DIRECTIONS){const r=J[n].clone().multiplyScalar(l==="+"?1:-1).applyQuaternion(t);e.push({axis:n,direction:l,x:r.x+0,y:-r.y+0,depth:r.z})}return e}function Jt(t,e){const{radiusPx:n,gripPx:l,innerPx:r,beyondTipPx:s,minTipPx:a,headLength:u}=e,o=t.map(c=>{const h=Math.hypot(c.x,c.y)*n;return{tip:h,angle:Math.atan2(c.y,c.x),start:r,end:h+s,depth:c.depth,grabbed:h>=a}});for(const[c,h]of o.entries())for(const m of o.slice(c+1)){if(!h.grabbed||!m.grabbed)continue;const[p,f]=h.tip<=m.tip?[h,m]:[m,h],y=h.angle-m.angle,b=p.tip*Math.abs(Math.sin(y));if(Math.cos(y)<=0||b>=l)continue;const S=f.tip*(1-u);if(p.tip>S){const A=h.depth<m.depth?h:m;A.grabbed=!1}else{const A=(p.tip+S)/2;p.end=Math.min(p.end,A),f.start=Math.max(f.start,A)}}const i=o.map((c,h)=>h);i.sort((c,h)=>o[c].depth-o[h].depth);const x=new Map(i.map((c,h)=>[c,h+1]));return o.map((c,h)=>!c.grabbed||c.end<=c.start?null:{x:Math.cos(c.angle)*c.start,y:Math.sin(c.angle)*c.start,length:c.end-c.start,angle:c.angle,layer:x.get(h)??0})}const W=.035,K=1.28;function zt({orientation:t,lit:e,disabled:n,size:l,radius:r,overlay:s}){const a=M.useRef(null),u=l/2;return ht(t,a,o=>{let i=!0;const x=Ct(o),c=Jt(x,yt(l,r));for(const[h,m]of x.entries()){const p=s.current.get(O(m)),f=c[h];if(p?f?(p.style.left=`${u+f.x}px`,p.style.top=`${u+f.y}px`,p.style.width=`${f.length}px`,p.style.transform=`translateY(-50%) rotate(${f.angle}rad)`,p.style.zIndex=String(f.layer),p.style.pointerEvents=""):p.style.pointerEvents="none":i=!1,m.direction!=="+")continue;const y=s.current.get(tt(m.axis));y?(y.style.left=`${u+m.x*r*K}px`,y.style.top=`${u+m.y*r*K}px`):i=!1}return i},`${l}:${r}`),d.jsxs("group",{ref:a,children:[d.jsxs("mesh",{children:[d.jsx("sphereGeometry",{args:[.07,16,16]}),d.jsx("meshBasicMaterial",{color:"#c4c8d0"})]}),E.JOG_AXES.map(o=>d.jsx(qt,{axis:o,color:V(o),lit:(e==null?void 0:e.axis)===o?e.direction:null,disabled:n},o))]})}function qt({axis:t,color:e,lit:n,disabled:l}){const r=M.useMemo(()=>new g.Quaternion().setFromUnitVectors(Y,J[t]),[t]),s=1-I;return d.jsx("group",{quaternion:r,children:E.JOG_DIRECTIONS.map(a=>{const u=n===a,o=u?1:l?.35:.8,i=u?W*1.5:W;return d.jsxs("group",{rotation:[a==="+"?0:Math.PI,0,0],children:[d.jsxs("mesh",{position:[0,s/2,0],children:[d.jsx("cylinderGeometry",{args:[i,i,s,12]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:o})]}),d.jsxs("mesh",{position:[0,1-I/2,0],scale:u?1.2:1,children:[d.jsx("coneGeometry",{args:[Z,I,20]}),d.jsx("meshBasicMaterial",{color:e,transparent:!0,opacity:o})]})]},a)})})}const Dt=new g.Quaternion;function Ht(t,e=Dt){const n=M.useRef(e);return n.current=e,M.useMemo(()=>{const l=new g.Quaternion;return{get current(){const r=t.current;if(!r)return null;const s=n.current;return Et(r,typeof s=="function"?s():s,l)}}},[t])}const Lt=3e3;function Bt(t){const[e,n]=M.useState(()=>t.current!==null);return M.useEffect(()=>{if(e)return;let l=requestAnimationFrame(function s(){t.current!==null?n(!0):l=requestAnimationFrame(s)});const r=setTimeout(()=>{t.current===null&&console.warn("JoggingGizmo has no orientation, so it stays disabled. Put a JoggingGizmoOrientation with the same ref into the app's 3D scene.")},Lt);return()=>{cancelAnimationFrame(l),clearTimeout(r)}},[e,t]),e}const Qt=pt.externalizeComponent(({orientation:t,frameQuaternion:e,motion:n="translate",onJogStart:l,onJogStop:r,activeHandle:s,disabled:a=!1,size:u=200})=>{const o=Bt(t),i=a||!o,x=Ht(t,e),{held:c,handlersFor:h,label:m,isPressed:p}=E.useJogControls({motion:n,onJogStart:l,onJogStop:r,activeHandle:s,disabled:i}),[f,y]=M.useState(null);M.useEffect(()=>y(null),[n]);const b=n==="rotate"?Vt:zt,S=n==="rotate"?jt:$t,A=M.useRef(new Map),w=xt(u,u,F(u).marginPx);return d.jsxs(R,{"data-testid":"jogging-gizmo",sx:{position:"relative",width:u,height:u,flexShrink:0,isolation:"isolate"},children:[d.jsx(z.Canvas,{orthographic:!0,flat:!0,frameloop:"demand",camera:{position:[0,0,10],up:[0,1,0],zoom:w,near:.1,far:100},gl:{alpha:!0,antialias:!0},style:{position:"absolute",inset:0,pointerEvents:"none"},children:d.jsx(b,{orientation:x,lit:c??s??f,disabled:i,size:u,radius:w,overlay:A})}),d.jsx(S,{isPressed:p,hovered:f,disabled:i,size:u,onHover:y,handlersFor:h,label:m,overlay:A})]})});exports.JoggingGizmo=Qt;exports.novaAxesSeenBy=Mt;