@wandelbots/wandelbots-js-react-components
Version:
React UI toolkit for building applications on top of the Wandelbots platform
1,399 lines (1,397 loc) • 764 kB
JavaScript
var xf = Object.defineProperty;
var vf = (e, t, n) => t in e ? xf(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var U = (e, t, n) => vf(e, typeof t != "symbol" ? t + "" : t, n);
import { a as ws, b as wf, A as Sf, j as b, e as Ve } from "./index-CAib4NKw.js";
import { SvgIcon as ju, AppBar as Cf, Toolbar as Tf, Box as J, Typography as Q, IconButton as bn, alpha as cl, Backdrop as Lu, Menu as Ef, MenuItem as Un, useTheme as je, Fade as dn, Divider as Kt, Slider as _f, Stack as be, Alert as Mf, AlertTitle as If, Button as Qn, styled as qs, InputLabel as Af, Select as kf, FormControl as Of, ToggleButtonGroup as Rf, ToggleButton as ul, Tabs as Nu, Tab as zu, Tooltip as Pf, Paper as Df, Dialog as $f, DialogTitle as jf, DialogContent as Lf, DialogActions as Nf, Chip as zf, Popover as Ff, Fab as Gf, Badge as Bf, createTheme as Vf, rgbToHex as Uf } from "@mui/material";
import { observer as de, useLocalObservable as Yi } from "mobx-react-lite";
import * as k from "react";
import qi, { useState as $e, useRef as ge, useCallback as le, useEffect as xe, useMemo as yi, forwardRef as Re, useId as Ki } from "react";
import { useTranslation as Le, Trans as pt } from "react-i18next";
import x from "prop-types";
import { S as Wf, C as Hf, g as Yf, h as qf, i as Kf, j as Jf, T as Xf, k as Zf, l as Qf, A as dl, J as ep, K as tp, B as np, m as rp, n as ip, o as op, p as sp, q as ap, r as lp, f as Fu, e as Ks, d as cp } from "./index-CxasuX80.js";
import { useGridApiRef as up, DataGrid as dp, Toolbar as hp, FilterPanelTrigger as fp, ToolbarButton as Go, QuickFilter as pp, QuickFilterTrigger as gp, QuickFilterControl as mp, QuickFilterClear as yp } from "@mui/x-data-grid";
import { countBy as bp, isString as xp } from "lodash-es";
import { runInAction as ze, makeAutoObservable as Js, when as Bo, autorun as vp, makeObservable as wp, action as hl, observable as Sp } from "mobx";
import { tryParseJson as kt, XYZ_TO_VECTOR as Sr, radiansToDegrees as bi, degreesToRadians as Cp } from "@wandelbots/nova-js";
import { L as Tp, b as Ep } from "./LoadingCover-Dr9hDTku.js";
import { DescriptionOutlined as _p, ContentCopy as Mp, ExpandLess as Ip, ExpandMore as Ap } from "@mui/icons-material";
import kp from "@emotion/styled";
import { ThemeContext as Op } from "@emotion/react";
import { Gauge as Rp } from "@mui/x-charts";
import * as fl from "three";
import { Vector3 as pl } from "three";
function Pp(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var Ss = function(e, t) {
return Ss = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
n.__proto__ = r;
} || function(n, r) {
for (var i in r) r.hasOwnProperty(i) && (n[i] = r[i]);
}, Ss(e, t);
};
function Gu(e, t) {
Ss(e, t);
function n() {
this.constructor = e;
}
e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
}
function Dp(e) {
var t = typeof Symbol == "function" && e[Symbol.iterator], n = 0;
return t ? t.call(e) : {
next: function() {
return e && n >= e.length && (e = void 0), { value: e && e[n++], done: !e };
}
};
}
function $p(e, t) {
var n = typeof Symbol == "function" && e[Symbol.iterator];
if (!n) return e;
var r = n.call(e), i, o = [], s;
try {
for (; (t === void 0 || t-- > 0) && !(i = r.next()).done; ) o.push(i.value);
} catch (a) {
s = { error: a };
} finally {
try {
i && !i.done && (n = r.return) && n.call(r);
} finally {
if (s) throw s.error;
}
}
return o;
}
function jp() {
for (var e = [], t = 0; t < arguments.length; t++)
e = e.concat($p(arguments[t]));
return e;
}
var Bu = (
/** @class */
/* @__PURE__ */ (function() {
function e(t, n) {
this.target = n, this.type = t;
}
return e;
})()
), Lp = (
/** @class */
(function(e) {
Gu(t, e);
function t(n, r) {
var i = e.call(this, "error", r) || this;
return i.message = n.message, i.error = n, i;
}
return t;
})(Bu)
), Np = (
/** @class */
(function(e) {
Gu(t, e);
function t(n, r, i) {
n === void 0 && (n = 1e3), r === void 0 && (r = "");
var o = e.call(this, "close", i) || this;
return o.wasClean = !0, o.code = n, o.reason = r, o;
}
return t;
})(Bu)
);
/*!
* Reconnecting WebSocket
* by Pedro Ladaria <pedro.ladaria@gmail.com>
* https://github.com/pladaria/reconnecting-websocket
* License MIT
*/
var zp = function() {
if (typeof WebSocket < "u")
return WebSocket;
}, Fp = function(e) {
return typeof e < "u" && !!e && e.CLOSING === 2;
}, an = {
maxReconnectionDelay: 1e4,
minReconnectionDelay: 1e3 + Math.random() * 4e3,
minUptime: 5e3,
reconnectionDelayGrowFactor: 1.3,
connectionTimeout: 4e3,
maxRetries: 1 / 0,
maxEnqueuedMessages: 1 / 0
}, Gp = (
/** @class */
(function() {
function e(t, n, r) {
var i = this;
r === void 0 && (r = {}), this._listeners = {
error: [],
message: [],
open: [],
close: []
}, this._retryCount = -1, this._shouldReconnect = !0, this._connectLock = !1, this._binaryType = "blob", this._closeCalled = !1, this._messageQueue = [], this.onclose = null, this.onerror = null, this.onmessage = null, this.onopen = null, this._handleOpen = function(o) {
i._debug("open event");
var s = i._options.minUptime, a = s === void 0 ? an.minUptime : s;
clearTimeout(i._connectTimeout), i._uptimeTimeout = setTimeout(function() {
return i._acceptOpen();
}, a), i._ws.binaryType = i._binaryType, i._messageQueue.forEach(function(l) {
return i._ws.send(l);
}), i._messageQueue = [], i.onopen && i.onopen(o), i._listeners.open.forEach(function(l) {
return i._callEventListener(o, l);
});
}, this._handleMessage = function(o) {
i._debug("message event"), i.onmessage && i.onmessage(o), i._listeners.message.forEach(function(s) {
return i._callEventListener(o, s);
});
}, this._handleError = function(o) {
i._debug("error event", o.message), i._disconnect(void 0, o.message === "TIMEOUT" ? "timeout" : void 0), i.onerror && i.onerror(o), i._debug("exec error listeners"), i._listeners.error.forEach(function(s) {
return i._callEventListener(o, s);
}), i._connect();
}, this._handleClose = function(o) {
i._debug("close event"), i._clearTimeouts(), i._shouldReconnect && i._connect(), i.onclose && i.onclose(o), i._listeners.close.forEach(function(s) {
return i._callEventListener(o, s);
});
}, this._url = t, this._protocols = n, this._options = r, this._options.startClosed && (this._shouldReconnect = !1), this._connect();
}
return Object.defineProperty(e, "CONNECTING", {
get: function() {
return 0;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e, "OPEN", {
get: function() {
return 1;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e, "CLOSING", {
get: function() {
return 2;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e, "CLOSED", {
get: function() {
return 3;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "CONNECTING", {
get: function() {
return e.CONNECTING;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "OPEN", {
get: function() {
return e.OPEN;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "CLOSING", {
get: function() {
return e.CLOSING;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "CLOSED", {
get: function() {
return e.CLOSED;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "binaryType", {
get: function() {
return this._ws ? this._ws.binaryType : this._binaryType;
},
set: function(t) {
this._binaryType = t, this._ws && (this._ws.binaryType = t);
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "retryCount", {
/**
* Returns the number or connection retries
*/
get: function() {
return Math.max(this._retryCount, 0);
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "bufferedAmount", {
/**
* The number of bytes of data that have been queued using calls to send() but not yet
* transmitted to the network. This value resets to zero once all queued data has been sent.
* This value does not reset to zero when the connection is closed; if you keep calling send(),
* this will continue to climb. Read only
*/
get: function() {
var t = this._messageQueue.reduce(function(n, r) {
return typeof r == "string" ? n += r.length : r instanceof Blob ? n += r.size : n += r.byteLength, n;
}, 0);
return t + (this._ws ? this._ws.bufferedAmount : 0);
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "extensions", {
/**
* The extensions selected by the server. This is currently only the empty string or a list of
* extensions as negotiated by the connection
*/
get: function() {
return this._ws ? this._ws.extensions : "";
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "protocol", {
/**
* A string indicating the name of the sub-protocol the server selected;
* this will be one of the strings specified in the protocols parameter when creating the
* WebSocket object
*/
get: function() {
return this._ws ? this._ws.protocol : "";
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "readyState", {
/**
* The current state of the connection; this is one of the Ready state constants
*/
get: function() {
return this._ws ? this._ws.readyState : this._options.startClosed ? e.CLOSED : e.CONNECTING;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(e.prototype, "url", {
/**
* The URL as resolved by the constructor
*/
get: function() {
return this._ws ? this._ws.url : "";
},
enumerable: !0,
configurable: !0
}), e.prototype.close = function(t, n) {
if (t === void 0 && (t = 1e3), this._closeCalled = !0, this._shouldReconnect = !1, this._clearTimeouts(), !this._ws) {
this._debug("close enqueued: no ws instance");
return;
}
if (this._ws.readyState === this.CLOSED) {
this._debug("close: already closed");
return;
}
this._ws.close(t, n);
}, e.prototype.reconnect = function(t, n) {
this._shouldReconnect = !0, this._closeCalled = !1, this._retryCount = -1, !this._ws || this._ws.readyState === this.CLOSED ? this._connect() : (this._disconnect(t, n), this._connect());
}, e.prototype.send = function(t) {
if (this._ws && this._ws.readyState === this.OPEN)
this._debug("send", t), this._ws.send(t);
else {
var n = this._options.maxEnqueuedMessages, r = n === void 0 ? an.maxEnqueuedMessages : n;
this._messageQueue.length < r && (this._debug("enqueue", t), this._messageQueue.push(t));
}
}, e.prototype.addEventListener = function(t, n) {
this._listeners[t] && this._listeners[t].push(n);
}, e.prototype.dispatchEvent = function(t) {
var n, r, i = this._listeners[t.type];
if (i)
try {
for (var o = Dp(i), s = o.next(); !s.done; s = o.next()) {
var a = s.value;
this._callEventListener(t, a);
}
} catch (l) {
n = { error: l };
} finally {
try {
s && !s.done && (r = o.return) && r.call(o);
} finally {
if (n) throw n.error;
}
}
return !0;
}, e.prototype.removeEventListener = function(t, n) {
this._listeners[t] && (this._listeners[t] = this._listeners[t].filter(function(r) {
return r !== n;
}));
}, e.prototype._debug = function() {
for (var t = [], n = 0; n < arguments.length; n++)
t[n] = arguments[n];
this._options.debug && console.log.apply(console, jp(["RWS>"], t));
}, e.prototype._getNextDelay = function() {
var t = this._options, n = t.reconnectionDelayGrowFactor, r = n === void 0 ? an.reconnectionDelayGrowFactor : n, i = t.minReconnectionDelay, o = i === void 0 ? an.minReconnectionDelay : i, s = t.maxReconnectionDelay, a = s === void 0 ? an.maxReconnectionDelay : s, l = 0;
return this._retryCount > 0 && (l = o * Math.pow(r, this._retryCount - 1), l > a && (l = a)), this._debug("next delay", l), l;
}, e.prototype._wait = function() {
var t = this;
return new Promise(function(n) {
setTimeout(n, t._getNextDelay());
});
}, e.prototype._getNextUrl = function(t) {
if (typeof t == "string")
return Promise.resolve(t);
if (typeof t == "function") {
var n = t();
if (typeof n == "string")
return Promise.resolve(n);
if (n.then)
return n;
}
throw Error("Invalid URL");
}, e.prototype._connect = function() {
var t = this;
if (!(this._connectLock || !this._shouldReconnect)) {
this._connectLock = !0;
var n = this._options, r = n.maxRetries, i = r === void 0 ? an.maxRetries : r, o = n.connectionTimeout, s = o === void 0 ? an.connectionTimeout : o, a = n.WebSocket, l = a === void 0 ? zp() : a;
if (this._retryCount >= i) {
this._debug("max retries reached", this._retryCount, ">=", i);
return;
}
if (this._retryCount++, this._debug("connect", this._retryCount), this._removeListeners(), !Fp(l))
throw Error("No valid WebSocket class provided");
this._wait().then(function() {
return t._getNextUrl(t._url);
}).then(function(c) {
t._closeCalled || (t._debug("connect", { url: c, protocols: t._protocols }), t._ws = t._protocols ? new l(c, t._protocols) : new l(c), t._ws.binaryType = t._binaryType, t._connectLock = !1, t._addListeners(), t._connectTimeout = setTimeout(function() {
return t._handleTimeout();
}, s));
});
}
}, e.prototype._handleTimeout = function() {
this._debug("timeout event"), this._handleError(new Lp(Error("TIMEOUT"), this));
}, e.prototype._disconnect = function(t, n) {
if (t === void 0 && (t = 1e3), this._clearTimeouts(), !!this._ws) {
this._removeListeners();
try {
this._ws.close(t, n), this._handleClose(new Np(t, n, this));
} catch {
}
}
}, e.prototype._acceptOpen = function() {
this._debug("accept open"), this._retryCount = 0;
}, e.prototype._callEventListener = function(t, n) {
"handleEvent" in n ? n.handleEvent(t) : n(t);
}, e.prototype._removeListeners = function() {
this._ws && (this._debug("removeListeners"), this._ws.removeEventListener("open", this._handleOpen), this._ws.removeEventListener("close", this._handleClose), this._ws.removeEventListener("message", this._handleMessage), this._ws.removeEventListener("error", this._handleError));
}, e.prototype._addListeners = function() {
this._ws && (this._debug("addListeners"), this._ws.addEventListener("open", this._handleOpen), this._ws.addEventListener("close", this._handleClose), this._ws.addEventListener("message", this._handleMessage), this._ws.addEventListener("error", this._handleError));
}, e.prototype._clearTimeouts = function() {
clearTimeout(this._connectTimeout), clearTimeout(this._uptimeTimeout);
}, e;
})()
), Bp = class extends Gp {
constructor(e, t = {}) {
console.log("Opening websocket to", e), super(() => this.targetUrl || e, void 0, { startClosed: !0 }), this.opts = t, this.disposed = !1, Object.defineProperty(this, "url", { get() {
return this.targetUrl;
} }), this.targetUrl = e, this.addEventListener("open", () => {
console.log(`Websocket to ${this.url} opened`);
}), this.addEventListener("message", (r) => {
this.receivedFirstMessage || (this.receivedFirstMessage = r);
}), this.addEventListener("close", () => {
console.log(`Websocket to ${this.url} closed`);
});
const n = this.reconnect;
this.reconnect = () => {
this.opts.mock ? this.opts.mock.handleWebsocketConnection(this) : n.apply(this);
}, this.reconnect();
}
changeUrl(e) {
this.receivedFirstMessage = void 0, this.targetUrl = e, this.reconnect();
}
sendJson(e) {
this.opts.mock ? this.opts.mock.handleWebsocketMessage(this, JSON.stringify(e)) : this.send(JSON.stringify(e));
}
/**
* Permanently close this websocket and indicate that
* this object should not be used again.
**/
dispose() {
this.close(), this.disposed = !0, this.opts.onDispose && this.opts.onDispose();
}
/**
* Returns a promise that resolves once the websocket
* is in the OPEN state. */
async opened() {
return new Promise((e, t) => {
this.readyState === WebSocket.OPEN ? e() : (this.addEventListener("open", () => e()), this.addEventListener("error", t));
});
}
/**
* Returns a promise that resolves once the websocket
* is in the CLOSED state. */
async closed() {
return new Promise((e, t) => {
this.readyState === WebSocket.CLOSED ? e() : (this.addEventListener("close", () => e()), this.addEventListener("error", t));
});
}
/**
* Returns a promise that resolves when the first message
* is received from the websocket. Resolves immediately if
* the first message has already been received.
*/
async firstMessage() {
return this.receivedFirstMessage ? this.receivedFirstMessage : new Promise((e, t) => {
const n = (i) => {
this.receivedFirstMessage = i, this.removeEventListener("message", n), this.removeEventListener("error", r), e(i);
}, r = (i) => {
this.removeEventListener("message", n), this.removeEventListener("error", r), t(i);
};
this.addEventListener("message", n), this.addEventListener("error", r);
});
}
/**
* Returns a promise that resolves when the next message
* is received from the websocket.
*/
async nextMessage() {
return new Promise((e, t) => {
const n = (i) => {
this.removeEventListener("message", n), this.removeEventListener("error", r), e(i);
}, r = (i) => {
this.removeEventListener("message", n), this.removeEventListener("error", r), t(i);
};
this.addEventListener("message", n), this.addEventListener("error", r);
});
}
}, Vp = class {
constructor() {
this.available = typeof window < "u" && !!window.localStorage;
}
getJSON(e) {
if (!this.available) return null;
const t = window.localStorage.getItem(e);
if (t === null) return null;
try {
return JSON.parse(t);
} catch {
return null;
}
}
setJSON(e, t) {
if (!this.available) return null;
window.localStorage.setItem(e, JSON.stringify(t));
}
delete(e) {
if (!this.available) return null;
window.localStorage.removeItem(e);
}
setString(e, t) {
if (!this.available) return null;
window.localStorage.setItem(e, t);
}
getString(e) {
return this.available ? window.localStorage.getItem(e) : null;
}
};
const Vo = new Vp(), Yn = "wandelbots.io", Uo = {
dev: {
domain: `https://auth.portal.dev.${Yn}`,
clientId: "fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha"
},
stg: {
domain: `https://auth.portal.stg.${Yn}`,
clientId: "joVDeD9e786WzFNSGCqoVq7HNkWt5j6s"
},
prod: {
domain: `https://auth.portal.${Yn}`,
clientId: "J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2"
}
}, Up = (e) => {
if (e.endsWith(`dev.${Yn}`)) return Uo.dev;
if (e.endsWith(`stg.${Yn}`)) return Uo.stg;
if (e.endsWith(Yn)) return Uo.prod;
throw new Error("Unsupported instance URL. Cannot determine Auth0 configuration.");
}, Wp = async (e) => {
if (typeof window > "u") throw new Error("Access token must be set to use NovaClient when not in a browser environment.");
const t = Up(e);
if (new URL(e).origin === window.location.origin)
throw window.location.reload(), new Error("Failed to reload page to get auth details, please refresh manually");
const { Auth0Client: n } = await import("./auth0-spa-js.production.esm-9WdmjTxR.js"), r = new n({
domain: t.domain,
clientId: t.clientId ?? "",
useRefreshTokens: !1,
authorizationParams: {
audience: "nova-api",
redirect_uri: window.location.origin
}
});
if (window.location.search.includes("code=") && window.location.search.includes("state=")) {
const { appState: i } = await r.handleRedirectCallback();
window.history.replaceState({}, document.title, (i == null ? void 0 : i.returnTo) || window.location.pathname);
} else await r.loginWithRedirect();
return await r.getTokenSilently();
};
function Hp(e) {
var t = [];
if (e.length === 0)
return "";
if (typeof e[0] != "string")
throw new TypeError("Url must be a string. Received " + e[0]);
if (e[0].match(/^[^/:]+:\/*$/) && e.length > 1) {
var n = e.shift();
e[0] = n + e[0];
}
e[0].match(/^file:\/\/\//) ? e[0] = e[0].replace(/^([^/:]+):\/*/, "$1:///") : e[0] = e[0].replace(/^([^/:]+):\/*/, "$1://");
for (var r = 0; r < e.length; r++) {
var i = e[r];
if (typeof i != "string")
throw new TypeError("Url must be a string. Received " + i);
i !== "" && (r > 0 && (i = i.replace(/^[\/]+/, "")), r < e.length - 1 ? i = i.replace(/[\/]+$/, "") : i = i.replace(/[\/]+$/, "/"), t.push(i));
}
var o = t.join("/");
o = o.replace(/\/(\?|&|#[^!])/g, "$1");
var s = o.split("?");
return o = s.shift() + (s.length > 0 ? "?" : "") + s.join("&"), o;
}
function Wo() {
var e;
return typeof arguments[0] == "object" ? e = arguments[0] : e = [].slice.call(arguments), Hp(e);
}
var Ze = {}, gl;
function Yp() {
if (gl) return Ze;
gl = 1, Object.defineProperty(Ze, "__esModule", { value: !0 }), Ze.PathError = Ze.TokenData = void 0, Ze.parse = c, Ze.compile = u, Ze.match = f, Ze.pathToRegexp = g, Ze.stringify = C;
const e = "/", t = (T) => T, n = /^[$_\p{ID_Start}]$/u, r = /^[$\u200c\u200d\p{ID_Continue}]$/u, i = {
// Groups.
"{": "{",
"}": "}",
// Reserved.
"(": "(",
")": ")",
"[": "[",
"]": "]",
"+": "+",
"?": "?",
"!": "!"
};
function o(T) {
return T.replace(/[{}()\[\]+?!:*\\]/g, "\\$&");
}
function s(T) {
return T.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
}
class a {
constructor(A, R) {
this.tokens = A, this.originalPath = R;
}
}
Ze.TokenData = a;
class l extends TypeError {
constructor(A, R) {
let D = A;
R && (D += `: ${R}`), D += "; visit https://git.new/pathToRegexpError for info", super(D), this.originalPath = R;
}
}
Ze.PathError = l;
function c(T, A = {}) {
const { encodePath: R = t } = A, D = [...T], O = [];
let y = 0, I = 0;
function M() {
let j = "";
if (n.test(D[y]))
do
j += D[y++];
while (r.test(D[y]));
else if (D[y] === '"') {
let V = y;
for (; y++ < D.length; ) {
if (D[y] === '"') {
y++, V = 0;
break;
}
D[y] === "\\" && y++, j += D[y];
}
if (V)
throw new l(`Unterminated quote at index ${V}`, T);
}
if (!j)
throw new l(`Missing parameter name at index ${y}`, T);
return j;
}
for (; y < D.length; ) {
const j = D[y], V = i[j];
V ? O.push({ type: V, index: y++, value: j }) : j === "\\" ? O.push({ type: "escape", index: y++, value: D[y++] }) : j === ":" ? O.push({ type: "param", index: y++, value: M() }) : j === "*" ? O.push({ type: "wildcard", index: y++, value: M() }) : O.push({ type: "char", index: y++, value: j });
}
O.push({ type: "end", index: y, value: "" });
function N(j) {
const V = [];
for (; ; ) {
const z = O[I++];
if (z.type === j)
break;
if (z.type === "char" || z.type === "escape") {
let q = z.value, ce = O[I];
for (; ce.type === "char" || ce.type === "escape"; )
q += ce.value, ce = O[++I];
V.push({
type: "text",
value: R(q)
});
continue;
}
if (z.type === "param" || z.type === "wildcard") {
V.push({
type: z.type,
name: z.value
});
continue;
}
if (z.type === "{") {
V.push({
type: "group",
tokens: N("}")
});
continue;
}
throw new l(`Unexpected ${z.type} at index ${z.index}, expected ${j}`, T);
}
return V;
}
return new a(N("end"), T);
}
function u(T, A = {}) {
const { encode: R = encodeURIComponent, delimiter: D = e } = A, O = typeof T == "object" ? T : c(T, A), y = d(O.tokens, D, R);
return function(M = {}) {
const [N, ...j] = y(M);
if (j.length)
throw new TypeError(`Missing parameters: ${j.join(", ")}`);
return N;
};
}
function d(T, A, R) {
const D = T.map((O) => h(O, A, R));
return (O) => {
const y = [""];
for (const I of D) {
const [M, ...N] = I(O);
y[0] += M, y.push(...N);
}
return y;
};
}
function h(T, A, R) {
if (T.type === "text")
return () => [T.value];
if (T.type === "group") {
const O = d(T.tokens, A, R);
return (y) => {
const [I, ...M] = O(y);
return M.length ? [""] : [I];
};
}
const D = R || t;
return T.type === "wildcard" && R !== !1 ? (O) => {
const y = O[T.name];
if (y == null)
return ["", T.name];
if (!Array.isArray(y) || y.length === 0)
throw new TypeError(`Expected "${T.name}" to be a non-empty array`);
return [
y.map((I, M) => {
if (typeof I != "string")
throw new TypeError(`Expected "${T.name}/${M}" to be a string`);
return D(I);
}).join(A)
];
} : (O) => {
const y = O[T.name];
if (y == null)
return ["", T.name];
if (typeof y != "string")
throw new TypeError(`Expected "${T.name}" to be a string`);
return [D(y)];
};
}
function f(T, A = {}) {
const { decode: R = decodeURIComponent, delimiter: D = e } = A, { regexp: O, keys: y } = g(T, A), I = y.map((M) => R === !1 ? t : M.type === "param" ? R : (N) => N.split(D).map(R));
return function(N) {
const j = O.exec(N);
if (!j)
return !1;
const V = j[0], z = /* @__PURE__ */ Object.create(null);
for (let q = 1; q < j.length; q++) {
if (j[q] === void 0)
continue;
const ce = y[q - 1], Z = I[q - 1];
z[ce.name] = Z(j[q]);
}
return { path: V, params: z };
};
}
function g(T, A = {}) {
const { delimiter: R = e, end: D = !0, sensitive: O = !1, trailing: y = !0 } = A, I = [], M = O ? "" : "i", N = [];
for (const z of p(T, [])) {
const q = typeof z == "object" ? z : c(z, A);
for (const ce of m(q.tokens, 0, []))
N.push(v(ce, R, I, q.originalPath));
}
let j = `^(?:${N.join("|")})`;
return y && (j += `(?:${s(R)}$)?`), j += D ? "$" : `(?=${s(R)}|$)`, { regexp: new RegExp(j, M), keys: I };
}
function p(T, A) {
if (Array.isArray(T))
for (const R of T)
p(R, A);
else
A.push(T);
return A;
}
function* m(T, A, R) {
if (A === T.length)
return yield R;
const D = T[A];
if (D.type === "group")
for (const O of m(D.tokens, 0, R.slice()))
yield* m(T, A + 1, O);
else
R.push(D);
yield* m(T, A + 1, R);
}
function v(T, A, R, D) {
let O = "", y = "", I = !0;
for (const M of T) {
if (M.type === "text") {
O += s(M.value), y += M.value, I || (I = M.value.includes(A));
continue;
}
if (M.type === "param" || M.type === "wildcard") {
if (!I && !y)
throw new l(`Missing text before "${M.name}" ${M.type}`, D);
M.type === "param" ? O += `(${E(A, I ? "" : y)}+)` : O += "([\\s\\S]+)", R.push(M), y = "", I = !1;
continue;
}
}
return O;
}
function E(T, A) {
return A.length < 2 ? T.length < 2 ? `[^${s(T + A)}]` : `(?:(?!${s(T)})[^${s(A)}])` : T.length < 2 ? `(?:(?!${s(A)})[^${s(T)}])` : `(?:(?!${s(A)}|${s(T)})[\\s\\S])`;
}
function S(T) {
let A = "", R = 0;
function D(O) {
return _(O) && w(T[R]) ? O : JSON.stringify(O);
}
for (; R < T.length; ) {
const O = T[R++];
if (O.type === "text") {
A += o(O.value);
continue;
}
if (O.type === "group") {
A += `{${S(O.tokens)}}`;
continue;
}
if (O.type === "param") {
A += `:${D(O.name)}`;
continue;
}
if (O.type === "wildcard") {
A += `*${D(O.name)}`;
continue;
}
throw new TypeError(`Unknown token type: ${O.type}`);
}
return A;
}
function C(T) {
return S(T.tokens);
}
function _(T) {
const [A, ...R] = T;
return n.test(A) && R.every((D) => r.test(D));
}
function w(T) {
return T && T.type === "text" ? !r.test(T.value[0]) : !0;
}
return Ze;
}
var qp = Yp(), Kp = class {
constructor(e, t) {
this.cellId = e, this.opts = t, this.system = this.withUnwrappedResponsesOnly(Wf), this.cell = this.withUnwrappedResponsesOnly(Hf), this.motionGroup = this.withCellId(Yf), this.motionGroupModels = this.withCellId(qf), this.controller = this.withCellId(Kf), this.controllerIOs = this.withCellId(Jf), this.trajectoryPlanning = this.withCellId(Xf), this.trajectoryExecution = this.withCellId(Zf), this.trajectoryCaching = this.withCellId(Qf), this.application = this.withCellId(dl), this.applicationGlobal = this.withUnwrappedResponsesOnly(dl), this.jogging = this.withCellId(ep), this.kinematics = this.withCellId(tp), this.busInputsOutputs = this.withCellId(np), this.virtualController = this.withCellId(rp), this.virtualControllerBehavior = this.withCellId(ip), this.virtualControllerIOs = this.withCellId(op), this.storeObject = this.withCellId(sp), this.storeCollisionComponents = this.withCellId(ap), this.storeCollisionSetups = this.withCellId(lp);
}
/**
* Some TypeScript sorcery which alters the API class methods so you don't
* have to pass the cell id to every single one, and de-encapsulates the
* response data
*/
withCellId(e) {
const t = new e({
...this.opts,
isJsonMime: (n) => n === "application/json"
}, this.opts.basePath ?? "", this.opts.axiosInstance ?? ws.create());
for (const n of Reflect.ownKeys(Reflect.getPrototypeOf(t))) if (n !== "constructor" && typeof t[n] == "function") {
const r = t[n];
t[n] = (...i) => r.apply(t, [this.cellId, ...i]).then((o) => o.data);
}
return t;
}
/**
* As withCellId, but only does the response unwrapping
*/
withUnwrappedResponsesOnly(e) {
const t = new e({
...this.opts,
isJsonMime: (n) => n === "application/json"
}, this.opts.basePath ?? "", this.opts.axiosInstance ?? ws.create());
for (const n of Reflect.ownKeys(Reflect.getPrototypeOf(t))) if (n !== "constructor" && typeof t[n] == "function") {
const r = t[n];
t[n] = (...i) => r.apply(t, i).then((o) => o.data);
}
return t;
}
}, Jp = class {
constructor() {
this.connections = [];
}
async handleAPIRequest(e) {
var i, o, s;
const t = [
{
method: "GET",
path: "/cells/:cellId/controllers",
handle() {
return ["mock-ur5e"];
}
},
{
method: "GET",
path: "/cells/:cellId/controllers/:controllerId",
handle() {
return {
configuration: {
initial_joint_position: "[0,-1.571,-1.571,-1.571,1.571,-1.571,0]",
kind: "VirtualController",
manufacturer: "universalrobots",
type: "universalrobots-ur5e"
},
name: "mock-ur5"
};
}
},
{
method: "GET",
path: "/cells/:cellId/controllers/:controllerId/state",
handle() {
return {
mode: "MODE_CONTROL",
last_error: [],
timestamp: "2025-10-16T09:19:26.634534092Z",
sequence_number: 1054764,
controller: "mock-ur5e",
operation_mode: "OPERATION_MODE_AUTO",
safety_state: "SAFETY_STATE_NORMAL",
velocity_override: 100,
motion_groups: [{
timestamp: "2025-10-16T09:19:26.634534092Z",
sequence_number: 1054764,
motion_group: "0@mock-ur5e",
controller: "mock-ur5e",
joint_position: [
1.487959623336792,
-1.8501918315887451,
1.8003005981445312,
6.034560203552246,
1.4921919107437134,
1.593459963798523
],
joint_limit_reached: { limit_reached: [
!1,
!1,
!1,
!1,
!1,
!1
] },
joint_torque: [],
joint_current: [
0,
0,
0,
0,
0,
0
],
flange_pose: {
position: [
107.6452433732927,
-409.0402987746852,
524.2402132330305
],
orientation: [
0.9874434028353319,
-0.986571714997442,
1.3336589451098142
]
},
tcp: "Flange",
tcp_pose: {
position: [
107.6452433732927,
-409.0402987746852,
524.2402132330305
],
orientation: [
0.9874434028353319,
-0.986571714997442,
1.3336589451098142
]
},
payload: "",
coordinate_system: "",
standstill: !0
}]
};
}
},
{
method: "GET",
path: "/cells/:cellId/controllers/:controllerId/motion-groups/:motionGroupId/description",
handle() {
return {
motion_group_model: "UniversalRobots_UR5e",
mounting: {
position: [
0,
0,
0
],
orientation: [
0,
0,
0
]
},
tcps: { Flange: {
name: "Default-Flange",
pose: {
position: [
0,
0,
0
],
orientation: [
0,
0,
0
]
}
} },
payloads: { "FPay-0": {
name: "FPay-0",
payload: 0,
center_of_mass: [
0,
0,
0
],
moment_of_inertia: [
0,
0,
0
]
} },
cycle_time: 8,
dh_parameters: [
{
alpha: 1.5707963267948966,
d: 162.25
},
{ a: -425 },
{ a: -392.2 },
{
alpha: 1.5707963267948966,
d: 133.3
},
{
alpha: -1.5707963267948966,
d: 99.7
},
{ d: 99.6 }
],
operation_limits: {
auto_limits: {
joints: [
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
}
],
tcp: { velocity: 5e3 },
elbow: { velocity: 5e3 },
flange: { velocity: 5e3 }
},
manual_limits: {
joints: [
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
}
],
tcp: { velocity: 5e3 }
},
manual_t1_limits: {
joints: [
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
}
],
tcp: { velocity: 5e3 }
},
manual_t2_limits: {
joints: [
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 150
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
},
{
position: {
lower_limit: -6.283185307179586,
upper_limit: 6.283185307179586
},
velocity: 3.34159255027771,
acceleration: 40,
torque: 28
}
],
tcp: { velocity: 5e3 }
}
},
serial_number: "WBVirtualRobot"
};
}
},
{
method: "GET",
path: "/cells/:cellId/controllers/:controllerId/coordinate-systems",
handle() {
return [{
coordinate_system: "",
name: "world",
reference_coordinate_system: "",
position: [
0,
0,
0
],
orientation: [
0,
0,
0
],
orientation_type: "ROTATION_VECTOR"
}, {
coordinate_system: "CS-0",
name: "Default-CS",
reference_coordinate_system: "",
position: [
0,
0,
0
],
orientation: [
0,
0,
0
],
orientation_type: "ROTATION_VECTOR"
}];
}
}
], n = ((i = e.method) == null ? void 0 : i.toUpperCase()) || "GET", r = `/cells${(s = (o = e.url) == null ? void 0 : o.split("/cells")[1]) == null ? void 0 : s.split("?")[0]}`;
for (const a of t) {
const l = qp.match(a.path)(r || "");
if (n === a.method && l) {
const c = a.handle();
return {
status: 200,
statusText: "Success",
data: JSON.stringify(c),
headers: {},
config: e,
request: { responseURL: e.url }
};
}
}
throw new Sf(`No mock handler matched this request: ${n} ${r}`, "404", e);
}
handleWebsocketConnection(e) {
this.connections.push(e), setTimeout(() => {
e.dispatchEvent(new Event("open")), console.log("Websocket connection opened from", e.url), e.url.includes("/state-stream") && e.dispatchEvent(new MessageEvent("message", { data: JSON.stringify(Xp) })), e.url.includes("/execution/jogging") && e.dispatchEvent(new MessageEvent("message", { data: JSON.stringify({ result: {
message: "string",
kind: "INITIALIZE_RECEIVED"
} }) }));
}, 10);
}
handleWebsocketMessage(e, t) {
console.log(`Received message on ${e.url}`, t);
}
};
const Xp = { result: {
motion_group: "0@universalrobots-ur5e",
controller: "universalrobots-ur5e",
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
sequence_number: 1,
joint_position: [
1.1699999570846558,
-1.5700000524520874,
1.3600000143051147,
1.0299999713897705,
1.2899999618530273,
1.2799999713897705
],
joint_limit_reached: { limit_reached: [
!1,
!1,
!1,
!1,
!1,
!1
] },
standstill: !1,
flange_pose: {
position: [
1.3300010259703043,
-409.2680714682808,
531.0203477065281
],
orientation: [
1.7564919306270736,
-1.7542521568325058,
0.7326972590614671
]
},
tcp_pose: {
position: [
1.3300010259703043,
-409.2680714682808,
531.0203477065281
],
orientation: [
1.7564919306270736,
-1.7542521568325058,
0.7326972590614671
]
}
} };
function Zp(e) {
return e.startsWith("http") || (e = `http://${e}`), new URL(e).toString();
}
var Qp = class {
constructor(e) {
this.authPromise = null, this.accessToken = null;
const t = e.cellId ?? "cell";
this.config = {
cellId: t,
...e
}, this.accessToken = e.accessToken || Vo.getString("wbjs.access_token") || null, this.config.instanceUrl === "https://mock.example.com" ? this.mock = new Jp() : this.config.instanceUrl = Zp(this.config.instanceUrl);
const n = ws.create({
baseURL: Wo(this.config.instanceUrl, "/api/v2"),
headers: typeof window < "u" && window.location.origin.includes("localhost") ? {} : { "X-Wandelbots-Client": "Wandelbots-Nova-JS-SDK" }
});
n.interceptors.request.use(async (r) => (r.headers.Authorization || (this.accessToken ? r.headers.Authorization = `Bearer ${this.accessToken}` : this.config.username && this.config.password && (r.headers.Authorization = `Basic ${btoa(`${e.username}:${e.password}`)}`)), r)), typeof window < "u" && n.interceptors.response.use((r) => r, async (r) => {
var i, o;
if (wf(r))
if (((i = r.response) == null ? void 0 : i.status) === 401) try {
if (await this.renewA