@wandelbots/wandelbots-js-react-components
Version:
React UI toolkit for building applications on top of the Wandelbots platform
1,407 lines (1,405 loc) • 772 kB
JavaScript
var Af = Object.defineProperty;
var If = (e, t, n) => t in e ? Af(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var U = (e, t, n) => If(e, typeof t != "symbol" ? t + "" : t, n);
import { a as ks, b as kf, A as Of, j as b, e as Be } from "./index-CAib4NKw.js";
import { SvgIcon as Bu, AppBar as Rf, Toolbar as Pf, Box as q, Typography as ee, IconButton as yn, alpha as gl, Backdrop as Vu, Menu as Df, MenuItem as Bn, useTheme as $e, Fade as un, Divider as qt, Slider as $f, Stack as be, Alert as jf, AlertTitle as Lf, Button as Jn, styled as ra, InputLabel as Nf, Select as zf, FormControl as Ff, ToggleButtonGroup as Gf, ToggleButton as ml, Tabs as Uu, Tab as Wu, Tooltip as Bf, Paper as Vf, Dialog as Uf, DialogTitle as Wf, DialogContent as Hf, DialogActions as Yf, Chip as qf, Popover as Kf, Fab as Jf, Badge as Xf, createTheme as Zf, rgbToHex as Qf } from "@mui/material";
import { observer as de, useLocalObservable as Qi } from "mobx-react-lite";
import * as k from "react";
import eo, { useState as De, useRef as ge, useCallback as ce, useEffect as xe, useMemo as wi, forwardRef as Oe, useId as to } from "react";
import { useTranslation as je, Trans as pt } from "react-i18next";
import x from "prop-types";
import { S as ep, C as tp, g as np, h as rp, i as ip, j as op, T as sp, k as ap, l as lp, A as yl, J as cp, K as up, B as dp, m as hp, n as fp, o as pp, p as gp, q as mp, r as yp, f as Hu, e as ia, d as bp } from "./index-CxasuX80.js";
import { useGridApiRef as xp, DataGrid as vp, Toolbar as wp, FilterPanelTrigger as Sp, ToolbarButton as Zo, QuickFilter as Cp, QuickFilterTrigger as Tp, QuickFilterControl as Ep, QuickFilterClear as _p } from "@mui/x-data-grid";
import { countBy as Mp, isString as Ap } from "lodash-es";
import { runInAction as Ne, makeAutoObservable as oa, when as Qo, autorun as Ip, makeObservable as kp, action as bl, observable as Op } from "mobx";
import { tryParseJson as kt, XYZ_TO_VECTOR as xr, radiansToDegrees as Si, degreesToRadians as Rp } from "@wandelbots/nova-js";
import { L as Pp, b as Dp } from "./LoadingCover-Dr9hDTku.js";
import { DescriptionOutlined as $p, ContentCopy as jp, ExpandLess as Lp, ExpandMore as Np } from "@mui/icons-material";
import zp from "@emotion/styled";
import { ThemeContext as Fp } from "@emotion/react";
import { Gauge as Gp } from "@mui/x-charts";
import * as xl from "three";
import { Vector3 as vl } from "three";
function Bp(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 Os = function(e, t) {
return Os = 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]);
}, Os(e, t);
};
function Yu(e, t) {
Os(e, t);
function n() {
this.constructor = e;
}
e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
}
function Vp(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 Up(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 Wp() {
for (var e = [], t = 0; t < arguments.length; t++)
e = e.concat(Up(arguments[t]));
return e;
}
var qu = (
/** @class */
/* @__PURE__ */ (function() {
function e(t, n) {
this.target = n, this.type = t;
}
return e;
})()
), Hp = (
/** @class */
(function(e) {
Yu(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;
})(qu)
), Yp = (
/** @class */
(function(e) {
Yu(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;
})(qu)
);
/*!
* Reconnecting WebSocket
* by Pedro Ladaria <pedro.ladaria@gmail.com>
* https://github.com/pladaria/reconnecting-websocket
* License MIT
*/
var qp = function() {
if (typeof WebSocket < "u")
return WebSocket;
}, Kp = function(e) {
return typeof e < "u" && !!e && e.CLOSING === 2;
}, sn = {
maxReconnectionDelay: 1e4,
minReconnectionDelay: 1e3 + Math.random() * 4e3,
minUptime: 5e3,
reconnectionDelayGrowFactor: 1.3,
connectionTimeout: 4e3,
maxRetries: 1 / 0,
maxEnqueuedMessages: 1 / 0
}, Jp = (
/** @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 ? sn.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 ? sn.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 = Vp(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, Wp(["RWS>"], t));
}, e.prototype._getNextDelay = function() {
var t = this._options, n = t.reconnectionDelayGrowFactor, r = n === void 0 ? sn.reconnectionDelayGrowFactor : n, i = t.minReconnectionDelay, o = i === void 0 ? sn.minReconnectionDelay : i, s = t.maxReconnectionDelay, a = s === void 0 ? sn.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 ? sn.maxRetries : r, o = n.connectionTimeout, s = o === void 0 ? sn.connectionTimeout : o, a = n.WebSocket, l = a === void 0 ? qp() : a;
if (this._retryCount >= i) {
this._debug("max retries reached", this._retryCount, ">=", i);
return;
}
if (this._retryCount++, this._debug("connect", this._retryCount), this._removeListeners(), !Kp(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 Hp(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 Yp(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;
})()
), Xp = class extends Jp {
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);
});
}
}, Zp = 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 Jr = new Zp();
function Rs(e, t = {}) {
const { scheme: n, defaultScheme: r } = t, i = /^[a-zA-Z]+:\/\//;
return n ? (e = e.replace(i, ""), e = `${n}://${e}`) : r && !i.test(e) && (e = `${r}://${e}`), new URL(e);
}
function Qp(e, t = {}) {
try {
return Rs(e, t);
} catch {
return;
}
}
function eg(e) {
var t;
return (t = Qp(e, { defaultScheme: "http" })) != null && t.host.endsWith(".wandelbots.io") ? Rs(e, { defaultScheme: "https" }) : Rs(e, { defaultScheme: "http" });
}
const es = {
dev: {
domain: "https://auth.portal.dev.wandelbots.io",
clientId: "fLbJD0RLp5r2Dpucm5j8BjwMR6Hunfha"
},
stg: {
domain: "https://auth.portal.stg.wandelbots.io",
clientId: "joVDeD9e786WzFNSGCqoVq7HNkWt5j6s"
},
prod: {
domain: "https://auth.portal.wandelbots.io",
clientId: "J7WJUi38xVQdJAEBNRT9Xw1b0fXDb4J2"
}
}, tg = (e) => {
if (e.host.endsWith(".dev.wandelbots.io")) return es.dev;
if (e.host.endsWith(".stg.wandelbots.io")) return es.stg;
if (e.host.endsWith(".wandelbots.io")) return es.prod;
throw new Error(`Unable to authenticate with NOVA instance "${e}". Auth0 login is only supported for cloud instances with hosts of the form "**.wandelbots.io".`);
}, ng = async (e) => {
if (typeof window > "u") throw new Error("Access token must be set to use NovaClient when not in a browser environment.");
if (e.origin === window.location.origin)
throw window.location.reload(), new Error("Failed to reload page to get auth details, please refresh manually");
const { Auth0Client: t } = await import("./auth0-spa-js.production.esm-DL9f1uDJ.js"), n = tg(e), r = new t({
domain: n.domain,
clientId: n.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 rg(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 ts() {
var e;
return typeof arguments[0] == "object" ? e = arguments[0] : e = [].slice.call(arguments), rg(e);
}
var Ze = {}, wl;
function ig() {
if (wl) return Ze;
wl = 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 = (E) => E, n = /^[$_\p{ID_Start}]$/u, r = /^[$\u200c\u200d\p{ID_Continue}]$/u, i = {
// Groups.
"{": "{",
"}": "}",
// Reserved.
"(": "(",
")": ")",
"[": "[",
"]": "]",
"+": "+",
"?": "?",
"!": "!"
};
function o(E) {
return E.replace(/[{}()\[\]+?!:*\\]/g, "\\$&");
}
function s(E) {
return E.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
}
class a {
constructor(I, O) {
this.tokens = I, this.originalPath = O;
}
}
Ze.TokenData = a;
class l extends TypeError {
constructor(I, O) {
let P = I;
O && (P += `: ${O}`), P += "; visit https://git.new/pathToRegexpError for info", super(P), this.originalPath = O;
}
}
Ze.PathError = l;
function c(E, I = {}) {
const { encodePath: O = t } = I, P = [...E], D = [];
let m = 0, A = 0;
function _() {
let j = "";
if (n.test(P[m]))
do
j += P[m++];
while (r.test(P[m]));
else if (P[m] === '"') {
let V = m;
for (; m++ < P.length; ) {
if (P[m] === '"') {
m++, V = 0;
break;
}
P[m] === "\\" && m++, j += P[m];
}
if (V)
throw new l(`Unterminated quote at index ${V}`, E);
}
if (!j)
throw new l(`Missing parameter name at index ${m}`, E);
return j;
}
for (; m < P.length; ) {
const j = P[m], V = i[j];
V ? D.push({ type: V, index: m++, value: j }) : j === "\\" ? D.push({ type: "escape", index: m++, value: P[m++] }) : j === ":" ? D.push({ type: "param", index: m++, value: _() }) : j === "*" ? D.push({ type: "wildcard", index: m++, value: _() }) : D.push({ type: "char", index: m++, value: j });
}
D.push({ type: "end", index: m, value: "" });
function L(j) {
const V = [];
for (; ; ) {
const z = D[A++];
if (z.type === j)
break;
if (z.type === "char" || z.type === "escape") {
let X = z.value, Z = D[A];
for (; Z.type === "char" || Z.type === "escape"; )
X += Z.value, Z = D[++A];
V.push({
type: "text",
value: O(X)
});
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: L("}")
});
continue;
}
throw new l(`Unexpected ${z.type} at index ${z.index}, expected ${j}`, E);
}
return V;
}
return new a(L("end"), E);
}
function u(E, I = {}) {
const { encode: O = encodeURIComponent, delimiter: P = e } = I, D = typeof E == "object" ? E : c(E, I), m = d(D.tokens, P, O);
return function(_ = {}) {
const [L, ...j] = m(_);
if (j.length)
throw new TypeError(`Missing parameters: ${j.join(", ")}`);
return L;
};
}
function d(E, I, O) {
const P = E.map((D) => h(D, I, O));
return (D) => {
const m = [""];
for (const A of P) {
const [_, ...L] = A(D);
m[0] += _, m.push(...L);
}
return m;
};
}
function h(E, I, O) {
if (E.type === "text")
return () => [E.value];
if (E.type === "group") {
const D = d(E.tokens, I, O);
return (m) => {
const [A, ..._] = D(m);
return _.length ? [""] : [A];
};
}
const P = O || t;
return E.type === "wildcard" && O !== !1 ? (D) => {
const m = D[E.name];
if (m == null)
return ["", E.name];
if (!Array.isArray(m) || m.length === 0)
throw new TypeError(`Expected "${E.name}" to be a non-empty array`);
return [
m.map((A, _) => {
if (typeof A != "string")
throw new TypeError(`Expected "${E.name}/${_}" to be a string`);
return P(A);
}).join(I)
];
} : (D) => {
const m = D[E.name];
if (m == null)
return ["", E.name];
if (typeof m != "string")
throw new TypeError(`Expected "${E.name}" to be a string`);
return [P(m)];
};
}
function f(E, I = {}) {
const { decode: O = decodeURIComponent, delimiter: P = e } = I, { regexp: D, keys: m } = g(E, I), A = m.map((_) => O === !1 ? t : _.type === "param" ? O : (L) => L.split(P).map(O));
return function(L) {
const j = D.exec(L);
if (!j)
return !1;
const V = j[0], z = /* @__PURE__ */ Object.create(null);
for (let X = 1; X < j.length; X++) {
if (j[X] === void 0)
continue;
const Z = m[X - 1], Q = A[X - 1];
z[Z.name] = Q(j[X]);
}
return { path: V, params: z };
};
}
function g(E, I = {}) {
const { delimiter: O = e, end: P = !0, sensitive: D = !1, trailing: m = !0 } = I, A = [], _ = D ? "" : "i", L = [];
for (const z of p(E, [])) {
const X = typeof z == "object" ? z : c(z, I);
for (const Z of y(X.tokens, 0, []))
L.push(v(Z, O, A, X.originalPath));
}
let j = `^(?:${L.join("|")})`;
return m && (j += `(?:${s(O)}$)?`), j += P ? "$" : `(?=${s(O)}|$)`, { regexp: new RegExp(j, _), keys: A };
}
function p(E, I) {
if (Array.isArray(E))
for (const O of E)
p(O, I);
else
I.push(E);
return I;
}
function* y(E, I, O) {
if (I === E.length)
return yield O;
const P = E[I];
if (P.type === "group")
for (const D of y(P.tokens, 0, O.slice()))
yield* y(E, I + 1, D);
else
O.push(P);
yield* y(E, I + 1, O);
}
function v(E, I, O, P) {
let D = "", m = "", A = !0;
for (const _ of E) {
if (_.type === "text") {
D += s(_.value), m += _.value, A || (A = _.value.includes(I));
continue;
}
if (_.type === "param" || _.type === "wildcard") {
if (!A && !m)
throw new l(`Missing text before "${_.name}" ${_.type}`, P);
_.type === "param" ? D += `(${T(I, A ? "" : m)}+)` : D += "([\\s\\S]+)", O.push(_), m = "", A = !1;
continue;
}
}
return D;
}
function T(E, I) {
return I.length < 2 ? E.length < 2 ? `[^${s(E + I)}]` : `(?:(?!${s(E)})[^${s(I)}])` : E.length < 2 ? `(?:(?!${s(I)})[^${s(E)}])` : `(?:(?!${s(I)}|${s(E)})[\\s\\S])`;
}
function S(E) {
let I = "", O = 0;
function P(D) {
return M(D) && w(E[O]) ? D : JSON.stringify(D);
}
for (; O < E.length; ) {
const D = E[O++];
if (D.type === "text") {
I += o(D.value);
continue;
}
if (D.type === "group") {
I += `{${S(D.tokens)}}`;
continue;
}
if (D.type === "param") {
I += `:${P(D.name)}`;
continue;
}
if (D.type === "wildcard") {
I += `*${P(D.name)}`;
continue;
}
throw new TypeError(`Unknown token type: ${D.type}`);
}
return I;
}
function C(E) {
return S(E.tokens);
}
function M(E) {
const [I, ...O] = E;
return n.test(I) && O.every((P) => r.test(P));
}
function w(E) {
return E && E.type === "text" ? !r.test(E.value[0]) : !0;
}
return Ze;
}
var og = ig(), sg = class {
constructor(e, t) {
this.cellId = e, this.opts = t, this.system = this.withUnwrappedResponsesOnly(ep), this.cell = this.withUnwrappedResponsesOnly(tp), this.motionGroup = this.withCellId(np), this.motionGroupModels = this.withCellId(rp), this.controller = this.withCellId(ip), this.controllerIOs = this.withCellId(op), this.trajectoryPlanning = this.withCellId(sp), this.trajectoryExecution = this.withCellId(ap), this.trajectoryCaching = this.withCellId(lp), this.application = this.withCellId(yl), this.applicationGlobal = this.withUnwrappedResponsesOnly(yl), this.jogging = this.withCellId(cp), this.kinematics = this.withCellId(up), this.busInputsOutputs = this.withCellId(dp), this.virtualController = this.withCellId(hp), this.virtualControllerBehavior = this.withCellId(fp), this.virtualControllerIOs = this.withCellId(pp), this.storeObject = this.withCellId(gp), this.storeCollisionComponents = this.withCellId(mp), this.storeCollisionSetups = this.withCellId(yp);
}
/**
* 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 ?? ks.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 ?? ks.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;
}
}, ag = 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 = og.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 Of(`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(lg) })), 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 lg = { 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
]
}
} };
var cg = class {
constructor(e) {
this.authPromise = null, this.accessToken = null;
const t = e.cellId ?? "cell";
this.config = {
cellId: t,
...e
}, this.accessToken = e.accessToken || Jr.getString("wbjs.access_token") || null, this.config.instanceUrl === "https://mock.example.com" && (this.mock = new ag()), this.instanceUrl = eg(this.config.instanceUrl);
const n = ks.create({
baseURL: ts(this.instanceUrl.href, "/api/v2"),
headers: typeof window < "u" && window.location.origin.includes("localhost") ? {} : { "X-Wandelbots-Client": "Wandelbots-Nova-JS-SDK" }
});
n.