@wandelbots/wandelbots-js-react-components 5.6.1 → 5.7.0-pr.feat-design-tokens.616.fff06df

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.
@@ -1,7 +1,8 @@
1
1
  import { type AutoReconnectingWebsocket } from "@wandelbots/nova-js";
2
- import type { MotionGroupDescription, MotionGroupState, NovaClient, RobotControllerState } from "@wandelbots/nova-js/v2";
2
+ import type { MotionGroupDescription, MotionGroupState, Nova, RobotControllerState } from "@wandelbots/nova-js/v2";
3
3
  import * as THREE from "three";
4
4
  import type { Vector3Simple } from "./JoggerConnection";
5
+ import { type AnyNovaClient } from "./novaCompat";
5
6
  export type RobotTcpLike = {
6
7
  id: string;
7
8
  readable_name: string;
@@ -11,12 +12,15 @@ export type RobotTcpLike = {
11
12
  export type MotionGroupOption = {
12
13
  selectionId: string;
13
14
  };
15
+ export type ConnectedMotionGroupOptions = {
16
+ /** Cell id on the Nova instance. Defaults to "cell". */
17
+ cellId?: string;
18
+ };
14
19
  /**
15
20
  * Store representing the current state of a connected motion group.
16
21
  * API v2 version, not used yet in the components.
17
22
  */
18
23
  export declare class ConnectedMotionGroup {
19
- readonly nova: NovaClient;
20
24
  readonly controller: RobotControllerState;
21
25
  readonly motionGroup: MotionGroupState;
22
26
  readonly initialMotionState: MotionGroupState;
@@ -26,8 +30,9 @@ export declare class ConnectedMotionGroup {
26
30
  readonly description: MotionGroupDescription;
27
31
  readonly initialControllerState: RobotControllerState;
28
32
  readonly controllerStateSocket: AutoReconnectingWebsocket;
29
- static connectMultiple(nova: NovaClient, motionGroupIds: string[]): Promise<ConnectedMotionGroup[]>;
30
- static connect(nova: NovaClient, motionGroupId: string): Promise<ConnectedMotionGroup>;
33
+ readonly cellId: string;
34
+ static connectMultiple(nova: AnyNovaClient, motionGroupIds: string[], options?: ConnectedMotionGroupOptions): Promise<ConnectedMotionGroup[]>;
35
+ static connect(novaClient: AnyNovaClient, motionGroupId: string, options?: ConnectedMotionGroupOptions): Promise<ConnectedMotionGroup>;
31
36
  connectedJoggingSocket: WebSocket | null;
32
37
  planData: any | null;
33
38
  joggingVelocity: number;
@@ -38,7 +43,9 @@ export declare class ConnectedMotionGroup {
38
43
  * movement controls in the UI should only be enabled in the "active" state
39
44
  */
40
45
  activationState: "inactive" | "activating" | "deactivating" | "active";
41
- constructor(nova: NovaClient, controller: RobotControllerState, motionGroup: MotionGroupState, initialMotionState: MotionGroupState, motionStateSocket: AutoReconnectingWebsocket, isVirtual: boolean, tcps: RobotTcpLike[], description: MotionGroupDescription, initialControllerState: RobotControllerState, controllerStateSocket: AutoReconnectingWebsocket);
46
+ /** Normalized instance-level Nova client (see `asNovaInstance`) */
47
+ readonly nova: Nova;
48
+ constructor(nova: AnyNovaClient, controller: RobotControllerState, motionGroup: MotionGroupState, initialMotionState: MotionGroupState, motionStateSocket: AutoReconnectingWebsocket, isVirtual: boolean, tcps: RobotTcpLike[], description: MotionGroupDescription, initialControllerState: RobotControllerState, controllerStateSocket: AutoReconnectingWebsocket, cellId?: string);
42
49
  get motionGroupId(): string;
43
50
  get controllerId(): string;
44
51
  get modelFromController(): string;
@@ -1,6 +1,7 @@
1
1
  import { type AutoReconnectingWebsocket } from "@wandelbots/nova-js";
2
- import { type NovaClient, type Pose } from "@wandelbots/nova-js/v2";
2
+ import { type Pose } from "@wandelbots/nova-js/v2";
3
3
  import { MotionStreamConnection } from "./MotionStreamConnection";
4
+ import type { AnyNovaClient } from "./novaCompat";
4
5
  export type Vector3Simple = [number, number, number];
5
6
  export type JoggerConnectionOptions = {
6
7
  mode?: JoggerMode;
@@ -13,6 +14,8 @@ export type JoggerConnectionOptions = {
13
14
  onError?: (err: unknown) => void;
14
15
  tcp?: string;
15
16
  orientation?: JoggerOrientation;
17
+ /** Cell id on the Nova instance. Defaults to "cell". */
18
+ cellId?: string;
16
19
  };
17
20
  export type JoggerMode = "jogging" | "trajectory" | "off";
18
21
  export type JoggerOrientation = "coordsys" | "tool";
@@ -49,12 +52,13 @@ export declare class JoggerConnection {
49
52
  * @param options.onError - Error handler for websocket errors
50
53
  * @returns Promise resolving to initialized JoggerConnection instance
51
54
  */
52
- static open(nova: NovaClient, motionGroupId: string, options?: JoggerConnectionOptions): Promise<JoggerConnection>;
55
+ static open(nova: AnyNovaClient, motionGroupId: string, options?: JoggerConnectionOptions): Promise<JoggerConnection>;
53
56
  constructor(motionStream: MotionStreamConnection, options?: JoggerConnectionOptions | undefined);
54
57
  getDefaultTcp(motionStream: MotionStreamConnection): string | undefined;
55
58
  setOptions(options: Partial<JoggerConnectionOptions>): Promise<void>;
56
59
  get motionGroupId(): string;
57
- get nova(): NovaClient;
60
+ get nova(): import("@wandelbots/nova-js/v2").Nova;
61
+ get cellId(): string;
58
62
  get numJoints(): number;
59
63
  stop(): Promise<void>;
60
64
  dispose(): Promise<void[]>;
@@ -1,18 +1,25 @@
1
1
  import { type AutoReconnectingWebsocket } from "@wandelbots/nova-js";
2
- import type { MotionGroupDescription, MotionGroupState, NovaClient, RobotControllerState } from "@wandelbots/nova-js/v2";
2
+ import type { MotionGroupDescription, MotionGroupState, Nova, RobotControllerState } from "@wandelbots/nova-js/v2";
3
+ import { type AnyNovaClient } from "./novaCompat";
3
4
  /**
4
5
  * Store representing the current state of a connected motion group.
5
6
  */
7
+ export type MotionStreamConnectionOptions = {
8
+ /** Cell id on the Nova instance. Defaults to "cell". */
9
+ cellId?: string;
10
+ };
6
11
  export declare class MotionStreamConnection {
7
- readonly nova: NovaClient;
8
12
  readonly controller: RobotControllerState;
9
13
  readonly motionGroup: MotionGroupState;
10
14
  readonly description: MotionGroupDescription;
11
15
  readonly initialMotionState: MotionGroupState;
12
16
  readonly motionStateSocket: AutoReconnectingWebsocket;
13
- static open(nova: NovaClient, motionGroupId: string): Promise<MotionStreamConnection>;
17
+ readonly cellId: string;
18
+ static open(novaClient: AnyNovaClient, motionGroupId: string, options?: MotionStreamConnectionOptions): Promise<MotionStreamConnection>;
14
19
  rapidlyChangingMotionState: MotionGroupState;
15
- constructor(nova: NovaClient, controller: RobotControllerState, motionGroup: MotionGroupState, description: MotionGroupDescription, initialMotionState: MotionGroupState, motionStateSocket: AutoReconnectingWebsocket);
20
+ /** Normalized instance-level Nova client (see `asNovaInstance`) */
21
+ readonly nova: Nova;
22
+ constructor(nova: AnyNovaClient, controller: RobotControllerState, motionGroup: MotionGroupState, description: MotionGroupDescription, initialMotionState: MotionGroupState, motionStateSocket: AutoReconnectingWebsocket, cellId?: string);
16
23
  get motionGroupId(): string;
17
24
  get controllerId(): string;
18
25
  get joints(): {
@@ -0,0 +1,16 @@
1
+ import type { Nova, NovaClient } from "@wandelbots/nova-js/v2";
2
+ /**
3
+ * A Nova-like client. We accept either the current instance-level `Nova`
4
+ * client or, for backwards compatibility, the deprecated cell-scoped
5
+ * `NovaClient`.
6
+ */
7
+ export type AnyNovaClient = Nova | NovaClient;
8
+ /**
9
+ * For backwards compatibility we still accept the deprecated cell-scoped
10
+ * `NovaClient`. This normalizes it to present the same interface as the
11
+ * current instance-level `Nova` client, so the rest of the code can be
12
+ * written against the newer API.
13
+ *
14
+ * Instance-level `Nova` clients are returned unchanged.
15
+ */
16
+ export declare function asNovaInstance(nova: AnyNovaClient): Nova;
@@ -1,2 +1,7 @@
1
- import { type Theme } from "@mui/material/styles";
2
- export declare function createDarkTheme(): Theme;
1
+ /**
2
+ * @deprecated Internal alias retained for backward compatibility. Use
3
+ * {@link createNovaTheme} from `./theming` instead — it accepts variadic
4
+ * `ThemeOptions` overrides matching the upstream
5
+ * `@wandelbots/design-tokens/mui` signature.
6
+ */
7
+ export { createNovaTheme as createDarkTheme } from "./theming";
@@ -1,17 +1,4 @@
1
- type NovaColorPaletteExtension = {
2
- paletteExt?: {
3
- primary?: {
4
- hover?: string;
5
- selected?: string;
6
- focus?: string;
7
- focusVisible?: string;
8
- outlineBorder?: string;
9
- };
10
- secondary?: {
11
- tonal?: string;
12
- };
13
- };
14
- };
1
+ import "@wandelbots/design-tokens/mui";
15
2
  export interface AxisControlComponentColors {
16
3
  color?: string;
17
4
  borderColor?: string;
@@ -24,67 +11,30 @@ export interface AxisControlComponentColors {
24
11
  };
25
12
  labelColor?: string;
26
13
  }
27
- interface NovaComponentsExtension {
28
- componentsExt?: {
29
- JoggingPanel?: {
30
- JoggingCartesian?: {
31
- Axis?: {
32
- X?: AxisControlComponentColors;
33
- Y?: AxisControlComponentColors;
34
- Z?: AxisControlComponentColors;
35
- CustomRotation?: AxisControlComponentColors;
14
+ declare module "@mui/material/styles" {
15
+ interface Theme {
16
+ componentsExt?: {
17
+ JoggingPanel?: {
18
+ JoggingCartesian?: {
19
+ Axis?: {
20
+ X?: AxisControlComponentColors;
21
+ Y?: AxisControlComponentColors;
22
+ Z?: AxisControlComponentColors;
23
+ CustomRotation?: AxisControlComponentColors;
24
+ };
36
25
  };
37
- };
38
- JoggingJoint?: {
39
- Joint?: {
40
- arrowColor?: string;
26
+ JoggingJoint?: {
27
+ Joint?: {
28
+ arrowColor?: string;
29
+ };
30
+ };
31
+ VelocitySlider?: {
32
+ sliderLegendColor?: string;
41
33
  };
42
- };
43
- VelocitySlider?: {
44
- sliderLegendColor?: string;
45
34
  };
46
35
  };
47
- };
48
- }
49
- interface BackgroundPaperElevation {
50
- 0?: string;
51
- 1?: string;
52
- 2?: string;
53
- 3?: string;
54
- 4?: string;
55
- 5?: string;
56
- 6?: string;
57
- 7?: string;
58
- 8?: string;
59
- 9?: string;
60
- 10?: string;
61
- 11?: string;
62
- 12?: string;
63
- 13?: string;
64
- 14?: string;
65
- 15?: string;
66
- 16?: string;
67
- 17?: string;
68
- 18?: string;
69
- 19?: string;
70
- 20?: string;
71
- 21?: string;
72
- 22?: string;
73
- 23?: string;
74
- 24?: string;
75
- }
76
- declare module "@mui/material/styles" {
77
- interface Palette {
78
- tertiary: Palette["primary"];
79
- backgroundPaperElevation?: BackgroundPaperElevation;
80
- }
81
- interface PaletteOptions {
82
- tertiary?: PaletteOptions["primary"];
83
- backgroundPaperElevation?: BackgroundPaperElevation;
84
- }
85
- interface Theme extends NovaComponentsExtension, NovaColorPaletteExtension {
86
36
  }
87
- interface ThemeOptions extends NovaComponentsExtension, NovaColorPaletteExtension {
37
+ interface ThemeOptions {
38
+ componentsExt?: Theme["componentsExt"];
88
39
  }
89
40
  }
90
- export {};
@@ -1,6 +1,23 @@
1
- import { type Theme, type ThemeOptions } from "@mui/material/styles";
1
+ import type { Theme, ThemeOptions } from "@mui/material/styles";
2
+ import "@mui/x-data-grid/themeAugmentation";
2
3
  /**
3
- * Create the default Wandelbots Nova Material UI theme, overriding
4
- * any defaults with the provided theme options.
4
+ * Create the default Wandelbots Nova Material UI theme for use with
5
+ * `@wandelbots/wandelbots-js-react-components`. Layers DataGrid +
6
+ * JoggingPanel-defaults on top of the canonical Nova theme from
7
+ * `@wandelbots/design-tokens`.
8
+ *
9
+ * Pass any number of `ThemeOptions` objects to override defaults. Each is
10
+ * deep-merged in order via MUI's `createTheme`.
11
+ *
12
+ * Light mode is not currently supported. Passing `palette: { mode: "light" }`
13
+ * will throw upstream. Browser-preference autodetection was removed when the
14
+ * upstream theme dropped its light-mode stub. It can be re-introduced once
15
+ * Figma synchronises a real light palette.
5
16
  */
6
- export declare function createNovaMuiTheme(opts: ThemeOptions): Theme;
17
+ export declare function createNovaTheme(...overrides: ThemeOptions[]): Theme;
18
+ /**
19
+ * @deprecated Use {@link createNovaTheme} instead. This name shadows the
20
+ * upstream `createNovaMuiTheme` from `@wandelbots/design-tokens/mui` (which
21
+ * has a different, variadic signature) and is therefore confusing.
22
+ */
23
+ export declare function createNovaMuiTheme(opts?: ThemeOptions): Theme;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wandelbots/wandelbots-js-react-components",
3
- "version": "5.6.1",
3
+ "version": "5.7.0-pr.feat-design-tokens.616.fff06df",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -173,7 +173,8 @@
173
173
  "dependencies": {
174
174
  "@mui/x-charts": "^8.27.0",
175
175
  "@mui/x-data-grid": "^8.27.0",
176
- "@wandelbots/nova-js": "^3.6.0",
176
+ "@wandelbots/design-tokens": "~1.2.2",
177
+ "@wandelbots/nova-js": "3.10.0-pr.295.cb733a7",
177
178
  "axios": "^1.15.0",
178
179
  "dotenv": "^17.2.3",
179
180
  "i18next-browser-languagedetector": "^8.2.0",
@@ -1 +0,0 @@
1
- "use strict";const t=require("react/jsx-runtime"),g=require("three"),V=require("three-stdlib"),d=require("react"),S=require("./externalizeComponent-OO4jcrz5.cjs"),M=require("@react-three/drei"),pe=require("@mui/material/styles"),v=require("@mui/material/Box"),Y=require("@mui/material/Button"),he=require("@mui/material/Card"),Q=require("@mui/material/Divider"),X=require("@mui/material/Typography"),T=require("@react-three/fiber"),me=require("mobx-react-lite"),xe=require("react-i18next"),L=require("./interpolation-C9sLsved.cjs"),R=require("@wandelbots/nova-js/v2"),K=require("react-error-boundary");function ye(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const j=ye(g);function ge(e){switch(e.shape_type){case"convex_hull":return new V.ConvexGeometry(e.vertices.map(r=>new j.Vector3(r[0]/1e3,r[1]/1e3,r[2]/1e3)));case"box":return new j.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new j.SphereGeometry(e.radius/1e3);case"capsule":return new j.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new j.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new j.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new j.BufferGeometry}}function je({name:e,collider:n,children:r}){var f,u;const o=((f=n.pose)==null?void 0:f.position)??[0,0,0],i=((u=n.pose)==null?void 0:u.orientation)??[0,0,0];return n.margin&&console.warn(`${e} margin is not supported`),t.jsx("mesh",{name:e,position:new j.Vector3(o[0],o[1],o[2]).divideScalar(1e3),rotation:new j.Euler(i[0],i[1],i[2],"XYZ"),geometry:ge(n.shape),children:r})}function be({name:e,colliders:n,meshChildrenProvider:r,...o}){return t.jsx("group",{name:e,...o,children:Object.entries(n).map(([i,f])=>t.jsx(je,{name:i,collider:f,children:r(i,f)},i))})}function we({scene:e,meshChildrenProvider:n}){const r=e.colliders;return t.jsx("group",{children:r&&t.jsx(be,{meshChildrenProvider:n,colliders:r})})}function O(){return t.jsx(M.Environment,{frames:1,children:t.jsx(Me,{})})}const Re=[2,0,2,0,2,0,2,0];function Me({positions:e=Re}){return t.jsxs(t.Fragment,{children:[t.jsx(M.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),t.jsx("group",{rotation:[0,.5,0],children:t.jsx("group",{children:e.map((n,r)=>t.jsx(M.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,r*4],scale:[3,1,1]},r))})}),t.jsx(M.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),t.jsx(M.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),t.jsx(M.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),t.jsx(M.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),t.jsx(M.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}const Z={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function ve({safetyZones:e,dhParameters:n,...r}){const o=d.useMemo(()=>S.dhParametersToPlaneSize(n??[]),[n]),i=(u,s)=>{var l,h;if(!((l=s==null?void 0:s.pose)!=null&&l.position)||!((h=s==null?void 0:s.pose)!=null&&h.orientation))return null;const y=new j.Vector3(s.pose.position[0]/1e3,s.pose.position[1]/1e3,s.pose.position[2]/1e3),a=new j.Vector3(s.pose.orientation[0],s.pose.orientation[1],s.pose.orientation[2]);let m;const c=s.shape.shape_type==="plane"?{...Z,side:j.DoubleSide}:{...Z,side:j.FrontSide};switch(s.shape.shape_type){case"plane":m=t.jsx("planeGeometry",{args:[o,o]});break;case"sphere":{const p=(s==null?void 0:s.shape).radius/1e3;m=t.jsx("sphereGeometry",{args:[p]});break}case"capsule":{const p=(s==null?void 0:s.shape).radius/1e3,x=(s==null?void 0:s.shape).cylinder_height/1e3;m=t.jsx("capsuleGeometry",{args:[p,x]});break}case"convex_hull":{const p=(s==null?void 0:s.shape).vertices.map(b=>new j.Vector3(b[0]/1e3,b[1]/1e3,b[2]/1e3)),x=S.verticesToCoplanarity(p);if(x.isCoplanar&&x.normal){const w=new j.Vector3().addVectors(p[0],x.normal.multiplyScalar(1e-4));p.push(w)}try{m=t.jsx("primitive",{object:new V.ConvexGeometry(p),attach:"geometry"})}catch(b){return console.log("Error creating ConvexGeometry:",b),null}break}case"rectangular_capsule":{const p=s.shape,x=p.radius/1e3,b=p.sphere_center_distance_x/1e3,w=p.sphere_center_distance_y/1e3,k=x*2;m=t.jsx("primitive",{object:new V.RoundedBoxGeometry(b,w,k,2,x),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",s.shape.shape_type),m=null}return t.jsxs("mesh",{renderOrder:u,position:y,quaternion:S.orientationToQuaternion(a),children:[m,t.jsx("meshStandardMaterial",{...c,polygonOffsetFactor:-u})]},`safety-zone-${s.shape.shape_type}-${u}`)},f=d.useMemo(()=>Object.values(e??{}).map((u,s)=>i(s,u)),[e,o]);return t.jsx("group",{...r,children:f})}function _e({trajectory:e,...n}){const r=(e==null?void 0:e.map(o=>{if(o.position&&o.position.length>=3){const[i,f,u]=o.position;if(Number.isFinite(i)&&Number.isFinite(f)&&Number.isFinite(u))return new j.Vector3(i/1e3,u/1e3,-f/1e3)}return null}).filter(o=>o!==null))||[];return t.jsx("group",{...n,children:r.length>0&&t.jsx(M.Line,{points:r,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const P=new Map;async function E(e,n){if(P.has(e))return P.get(e);const r=(async()=>{var u;const o=n||"",i=new R.NovaClient({instanceUrl:o}),f=i.api.motionGroupModels;(u=f.axios)!=null&&u.interceptors&&f.axios.interceptors.request.use(s=>{var y;return(y=s.url)!=null&&y.includes("/glb")&&(s.responseType="blob"),s});try{const s=await i.api.motionGroupModels.getMotionGroupGlbModel(e);return URL.createObjectURL(s)}catch(s){throw console.error("Failed to fetch model:",s),s}})();return P.set(e,r),r}function z(e){function n(r){return r.children.length===0?[r]:[r,...r.children.flatMap(o=>n(o))]}return n(e).filter(r=>te(r))}function ee(e){return e.name.endsWith("_FLG")}function te(e){return/_J[0-9]+$/.test(e.name)}function Se(e,n){let r;function o(i){if(ee(i)){if(r)throw Error(`Found multiple flange groups in robot model ${n}; first ${r.name} then ${i.name}. Only one _FLG group is allowed.`);r=i}te(i),i.children.map(o)}if(o(e.scene),!r)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}function re({rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:r,children:o}){const i=d.useRef([]),f=d.useRef(null),{invalidate:u}=T.useThree(),s=d.useRef(e);s.current=e,d.useEffect(()=>{const c=e.joint_position.filter(l=>l!==void 0);return f.current=new L.ValueInterpolator(c,{tension:120,friction:20,threshold:.001}),()=>{var l;(l=f.current)==null||l.destroy()}},[]),T.useFrame((c,l)=>{if(f.current){const h=f.current.update(l);a(),h||u()}});function y(c){c&&(i.current=z(c),a(),u())}function a(){var l;const c=((l=f.current)==null?void 0:l.getCurrentValues())||[];if(r)r(i.current,c);else for(const[h,p]of i.current.entries()){const x=n[h],b=x.theta||0,w=x.reverse_rotation_direction?-1:1;p.rotation.y=w*(c[h]||0)+b}}function m(c){var h;const l=c.joint_position.filter(p=>p!==void 0);(h=f.current)==null||h.setTarget(l),u()}return L.useAutorun(()=>{m(s.current)}),d.useEffect(()=>{m(e)},[e]),t.jsx("group",{ref:y,children:o})}const Te="line",Le="mesh";function ke({rapidlyChangingMotionState:e,dhParameters:n,...r}){const o=new g.Matrix4,i=d.useRef([]),f=d.useRef([]);d.useEffect(()=>{i.current=new Array(n.length).fill(null),f.current=new Array(n.length).fill(null)},[n.length]);function u(a,m){const c=new g.Vector3,l=new g.Quaternion,h=new g.Vector3;o.decompose(c,l,h);const p=c.clone(),x=new g.Matrix4().makeRotationY(a.theta+m*(a.reverse_rotation_direction?-1:1)).multiply(new g.Matrix4().makeTranslation(0,a.d/1e3,0)).multiply(new g.Matrix4().makeTranslation(a.a/1e3,0,0)).multiply(new g.Matrix4().makeRotationX(a.alpha));return o.multiply(x),o.decompose(c,l,h),{a:p,b:c}}function s(a,m,c,l){if(!n)return;const h=n[a];if(!h)return;const{a:p,b:x}=u(h,l);m.geometry.setPositions([p.toArray(),x.toArray()].flat()),c.position.set(x.x,x.y,x.z)}function y(a,m){o.identity();for(let c=0;c<Math.min(a.length,m.length);c++){const l=i.current[c],h=f.current[c];l&&h&&s(c,l,h,m[c])}}return t.jsx(re,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:y,children:t.jsxs("group",{...r,name:"Scene",children:[t.jsxs("mesh",{children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n==null?void 0:n.map((a,m)=>{const{a:c,b:l}=u(a,e.joint_position[m]??0),h=`dhrobot_J0${m}`;return t.jsxs("group",{name:h,children:[t.jsx(M.Line,{ref:p=>{i.current[m]=p},name:Te,points:[c,l],color:"white",lineWidth:5}),t.jsxs("mesh",{ref:p=>{f.current[m]=p},name:Le,position:l,children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${m}`)]},h)})]})})}const Ee=console.warn;function ne(){return d.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Ee(e)}},[]),null}function Ge(e){return e.type==="Mesh"}function Ce({url:e,flangeRef:n,postModelRender:r,...o}){const i=M.useGLTF(e),u=Se(i,"robot.glb").gltf,s=d.useCallback(a=>{a&&r&&r()},[r]);function y(a){try{return Ge(a)?a.geometry?t.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:ee(a)?n:void 0,children:a.children.map(y)},a.uuid)}catch(m){return console.warn("Error rendering node",a.name,m),null}}return t.jsx("group",{...o,dispose:null,ref:s,children:y(u.scene)})}function se({modelURL:e,flangeRef:n,postModelRender:r,...o}){const[i,f]=d.useState(null);return d.useEffect(()=>{let u=!1;return(async()=>{try{const y=typeof e=="string"?e:await e;u||f(a=>a===y?a:y)}catch(y){console.error("Failed to resolve model URL:",y)}})(),()=>{u=!0}},[e]),i?t.jsx(Ce,{url:i,flangeRef:n,postModelRender:r,...o}):null}const oe=(e,n)=>{e.userData.isGhost||(e.traverse(r=>{if(r instanceof j.Mesh){r.material instanceof j.Material&&(r.material.colorWrite=!1);const o=r.clone(),i=r.clone();o.material=new j.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:j.DoubleSide}),o.userData.isGhost=!0,i.material=new j.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:j.DoubleSide}),i.userData.isGhost=!0,r.parent&&(r.parent.add(o),r.parent.add(i))}}),e.userData.isGhost=!0)},ie=e=>{if(!e.userData.isGhost)return;const n=[];e.traverse(r=>{var o;r instanceof j.Mesh&&((o=r.userData)!=null&&o.isGhost?n.push(r):r.material instanceof j.Material&&(r.material.colorWrite=!0))}),n.forEach(r=>{r.parent&&r.parent.remove(r)}),e.userData.isGhost=!1},q=S.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:o=E,flangeRef:i,postModelRender:f,transparentColor:u,instanceUrl:s,...y})=>{const[a,m]=d.useState(null),c=d.useCallback(p=>{m(p)},[]);d.useEffect(()=>{a&&(u?oe(a,u):ie(a))},[a,u]);const l=d.useMemo(()=>{const p=o(n,s);if(!p)throw new Error(`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`);return p},[n,s,o]),h=t.jsx(ke,{rapidlyChangingMotionState:e,dhParameters:r,...y});return t.jsxs(K.ErrorBoundary,{fallback:h,onError:p=>{console.warn(p)},children:[t.jsx(d.Suspense,{fallback:h,children:t.jsx("group",{ref:c,children:t.jsx(re,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsx(se,{modelURL:l,postModelRender:f,flangeRef:i,...y})})})}),t.jsx(ne,{})]})});function ae({connectedMotionGroup:e,getModel:n=E,flangeRef:r,transparentColor:o,postModelRender:i,...f}){return e.dhParameters?t.jsx(q,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:o,postModelRender:i,...f}):null}const Ae=S.externalizeComponent(me.observer(({robotName:e,programState:n,safetyState:r,operationMode:o,driveToHomeEnabled:i=!1,onDriveToHomePress:f,onDriveToHomeRelease:u,connectedMotionGroup:s,robotComponent:y=ae,customContentComponent:a,className:m})=>{var N;const c=pe.useTheme(),{t:l}=xe.useTranslation(),[h,p]=d.useState(!1),x=d.useRef(null),b=d.useRef(null),[w,k]=d.useState(!1),[G,fe]=d.useState({width:400,height:600}),[Oe,de]=d.useState(0);d.useEffect(()=>{const F=()=>{if(b.current){const{offsetWidth:$,offsetHeight:H}=b.current;k($>H),fe({width:$,height:H})}};F();const W=new ResizeObserver(F);return b.current&&W.observe(b.current),()=>{W.disconnect()}},[]);const J=d.useCallback(()=>{de(F=>F+1)},[]),C=d.useCallback(()=>{!i||!f||(p(!0),f())},[i,f]),A=d.useCallback(()=>{!i||!u||(p(!1),u())},[i,u]),B=d.useCallback(()=>{h&&u&&(p(!1),u())},[h,u]),_=w?G.width<350:G.height<200,I=w?G.height<310:G.height<450;return t.jsx(he,{ref:b,className:m,sx:{width:"100%",height:"100%",display:"flex",flexDirection:w?"row":"column",position:"relative",overflow:"hidden",minWidth:{xs:180,sm:220,md:250},minHeight:w?{xs:200,sm:240,md:260}:{xs:150,sm:180,md:220},border:`1px solid ${c.palette.divider}`,borderRadius:"18px",boxShadow:"none",backgroundColor:((N=c.palette.backgroundPaperElevation)==null?void 0:N[8])||"#2A2A3F",backgroundImage:"none"},children:w?t.jsxs(t.Fragment,{children:[t.jsx(v,{sx:{flex:"0 0 50%",position:"relative",height:"100%",minHeight:"100%",maxHeight:"100%",borderRadius:1,m:{xs:1.5,sm:2,md:3},mr:{xs:.75,sm:1,md:1.5},overflow:"hidden",display:_?"none":"block"},children:!_&&t.jsxs(T.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:c.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute",top:0,left:0},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(O,{}),t.jsx(M.Bounds,{fit:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(y,{connectedMotionGroup:s,postModelRender:J})})]})}),t.jsxs(v,{sx:{flex:"1",display:"flex",flexDirection:"column",justifyContent:"flex-start",width:_?"100%":"50%"},children:[t.jsxs(v,{sx:{p:{xs:1.5,sm:2,md:3},pb:{xs:1,sm:1.5,md:2},textAlign:"left"},children:[t.jsx(X,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:o})]}),t.jsxs(v,{sx:{p:{xs:1.5,sm:2,md:3},pt:0,flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[!I&&a&&t.jsxs(v,{children:[t.jsx(a,{}),t.jsx(Q,{sx:{mt:1,mb:0,borderColor:c.palette.divider,opacity:.5}})]}),t.jsx(v,{sx:{mt:!I&&a?"auto":0},children:t.jsx(v,{sx:{display:"flex",justifyContent:"flex-start",mt:{xs:1,sm:1.5,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Y,{ref:x,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:C,onMouseUp:A,onMouseLeave:B,onTouchStart:C,onTouchEnd:A,sx:{textTransform:"none",px:1.5,py:.5},children:l("RobotCard.DriveToHome.bt")})})})]})]})]}):t.jsx(t.Fragment,{children:t.jsxs(v,{sx:{p:3,height:"100%",display:"flex",flexDirection:"column"},children:[t.jsxs(v,{children:[t.jsx(X,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:o})]}),t.jsx(v,{sx:{flex:_?0:1,position:"relative",minHeight:_?0:{xs:120,sm:150,md:200},height:_?0:"auto",borderRadius:1,overflow:"hidden",display:_?"none":"block"},children:!_&&t.jsxs(T.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:c.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute"},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(O,{}),t.jsx(M.Bounds,{fit:!0,clip:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(y,{connectedMotionGroup:s,postModelRender:J})})]})}),t.jsxs(v,{children:[!I&&a&&t.jsxs(t.Fragment,{children:[t.jsx(a,{}),t.jsx(Q,{sx:{mt:1,mb:0,borderColor:c.palette.divider,opacity:.5}})]}),t.jsx(v,{sx:{display:"flex",justifyContent:"flex-start",mt:!I&&a?{xs:1,sm:2,md:5}:{xs:.5,sm:1,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Y,{ref:x,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:C,onMouseUp:A,onMouseLeave:B,onTouchStart:C,onTouchEnd:A,sx:{textTransform:"none",px:1.5,py:.5},children:l("RobotCard.DriveToHome.bt")})})]})]})})})})),Ie=Array(6).fill(2*Math.PI);function ce({rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:r,children:o}){const i=d.useRef([]),f=d.useRef([]),u=d.useRef(null),{invalidate:s}=T.useThree();d.useEffect(()=>{const c=e.joint_position.filter(l=>l!==void 0);return u.current=new L.ValueInterpolator(c,{tension:120,friction:20,threshold:.001}),()=>{var l;(l=u.current)==null||l.destroy()}},[]),T.useFrame((c,l)=>{if(u.current){const h=u.current.update(l);a(),h||s()}});function y(c){c&&(f.current=z(c),a(),s())}function a(){var l;const c=((l=u.current)==null?void 0:l.getCurrentValues())||[];if(r)r(f.current,c);else for(const[h,p]of f.current.entries()){const b=n[h].reverse_rotation_direction?-1:1;p.position.y=b*(c[h]||0)/1e3}}const m=d.useCallback(()=>{const c=e.joint_position.filter(l=>l!==void 0);requestAnimationFrame(()=>{var l;i.current=c,(l=u.current)==null||l.setTarget(c)})},[e]);return d.useEffect(()=>{m()},[e,m]),L.useAutorun(()=>{m()}),t.jsx("group",{ref:y,children:o})}function ue({rapidlyChangingMotionState:e,dhParameters:n,...r}){const o=new g.Matrix4,i=d.useRef(null),f=d.useRef(null);function u(a){const m=new g.Matrix4;for(let p=0;p<n.length;p++){const x=n[p],b=a[p]??0,w=new g.Matrix4().makeRotationY(x.theta).multiply(new g.Matrix4().makeTranslation(x.a/1e3,(x.d+b*(x.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(x.alpha));m.multiply(w)}const c=new g.Vector3,l=new g.Quaternion,h=new g.Vector3;return m.decompose(c,l,h),c}const s=u(e.joint_position);function y(a,m){o.identity();let c=new g.Vector3;for(let x=0;x<n.length;x++){const b=m[x]??0,w=n[x],k=new g.Matrix4().makeRotationY(w.theta).multiply(new g.Matrix4().makeTranslation(w.a/1e3,(w.d+b*(w.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(w.alpha));o.multiply(k)}const l=new g.Vector3,h=new g.Quaternion,p=new g.Vector3;if(o.decompose(l,h,p),c=l,i.current&&i.current.position.set(c.x,c.y,c.z),f.current){const x=f.current.geometry;x!=null&&x.setPositions&&x.setPositions([0,0,0,c.x,c.y,c.z])}}return t.jsx(ce,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:y,children:t.jsxs("group",{...r,name:"Scene",children:[t.jsxs("mesh",{name:"Base",position:[0,0,0],children:[t.jsx("sphereGeometry",{args:[.02,32,32]}),t.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),t.jsx(M.Line,{ref:f,points:[new g.Vector3(0,0,0),s],color:"White",lineWidth:5}),t.jsxs("mesh",{ref:i,name:"TCP",position:s,children:[t.jsx("sphereGeometry",{args:[.025,32,32]}),t.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}const U=S.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:o=E,flangeRef:i,postModelRender:f,transparentColor:u,instanceUrl:s,...y})=>{const[a,m]=d.useState(null),c=d.useCallback(h=>{m(h)},[]);d.useEffect(()=>{a&&(u?oe(a,u):ie(a))},[a,u]);const l=t.jsx(ue,{rapidlyChangingMotionState:e,dhParameters:r,...y});return t.jsxs(K.ErrorBoundary,{fallback:l,onError:h=>{console.warn(h)},children:[t.jsx(d.Suspense,{fallback:l,children:t.jsx("group",{ref:c,children:t.jsx(ce,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsx(se,{modelURL:(()=>{const h=o(n,s);if(!h){const p=new Blob([],{type:"model/gltf-binary"}),x=new File([p],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(x))}return h})(),postModelRender:f,flangeRef:i,...y})})})}),t.jsx(ne,{})]})});function Fe({connectedMotionGroup:e,getModel:n=E,flangeRef:r,transparentColor:o,postModelRender:i,...f}){if(!e.dhParameters)return null;const u=e.modelFromController||"";return u&&n(u)?t.jsx(U,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:u,dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:o,postModelRender:i,...f}):t.jsx(ue,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,...f})}const D={[R.Manufacturer.Abb]:[0,0,0,0,Math.PI/2,0,0],[R.Manufacturer.Fanuc]:[0,0,0,0,-Math.PI/2,0,0],[R.Manufacturer.Yaskawa]:[0,0,0,0,-Math.PI/2,0,0],[R.Manufacturer.Kuka]:[0,-Math.PI/2,Math.PI/2,0,Math.PI/2,0,0],[R.Manufacturer.Universalrobots]:[0,-Math.PI/2,-Math.PI/2,-Math.PI/2,Math.PI/2,-Math.PI/2,0]};function le(e){const[n]=e.split("_");switch(n){case"ABB":return R.Manufacturer.Abb;case"FANUC":return R.Manufacturer.Fanuc;case"YASKAWA":return R.Manufacturer.Yaskawa;case"KUKA":return R.Manufacturer.Kuka;case"UniversalRobots":return R.Manufacturer.Universalrobots;default:return null}}function Pe(e,n){const r=le(e);return r&&r in D?D[r]:n||null}const Ve=S.externalizeComponent(e=>{const{inverseSolver:n,dhParameters:r,...o}=e,[i,f]=d.useState(R.JointTypeEnum.RevoluteJoint);d.useEffect(()=>{r.length&&f(r[0].type??R.JointTypeEnum.RevoluteJoint)},[r]);const u=d.useMemo(()=>n===null&&i===R.JointTypeEnum.RevoluteJoint,[n,i]),s=d.useMemo(()=>n===null&&i===R.JointTypeEnum.PrismaticJoint,[n,i]);return d.useMemo(()=>!!n,[n])||u?t.jsx(q,{dhParameters:r,...o}):s?t.jsx(U,{dhParameters:r,...o}):null});exports.CollisionSceneRenderer=we;exports.LinearAxis=Fe;exports.MANUFACTURER_HOME_CONFIGS=D;exports.MotionGroupVisualizer=Ve;exports.PresetEnvironment=O;exports.Robot=ae;exports.RobotCard=Ae;exports.SafetyZonesRenderer=ve;exports.SupportedLinearAxis=U;exports.SupportedRobot=q;exports.TrajectoryRenderer=_e;exports.defaultAxisConfig=Ie;exports.defaultGetModel=E;exports.extractManufacturer=le;exports.getDefaultHomeConfig=Pe;