UNPKG

@deephaven/js-plugin-ui

Version:
1,381 lines 3.52 MB
"use strict"; var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2; var __publicField = (obj, key, value2) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value2); Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const React = require("react"); const dashboard = require("@deephaven/dashboard"); const Log = require("@deephaven/log"); const jsapiBootstrap = require("@deephaven/jsapi-bootstrap"); const components = require("@deephaven/components"); const dashboardCorePlugins = require("@deephaven/dashboard-core-plugins"); const ReactDOM = require("react-dom"); const plugin = require("@deephaven/plugin"); const icons = require("@deephaven/icons"); const irisGrid = require("@deephaven/iris-grid"); const jsapiComponents = require("@deephaven/jsapi-components"); const reactRedux = require("react-redux"); const console$1 = require("@deephaven/console"); function _interopNamespaceDefault(e2) { const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } }); if (e2) { for (const k2 in e2) { if (k2 !== "default") { const d2 = Object.getOwnPropertyDescriptor(e2, k2); Object.defineProperty(n2, k2, d2.get ? d2 : { enumerable: true, get: () => e2[k2] }); } } } n2.default = e2; return Object.freeze(n2); } const icons__namespace = /* @__PURE__ */ _interopNamespaceDefault(icons); var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function getDefaultExportFromCjs(x2) { return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; } function getAugmentedNamespace(n2) { if (n2.__esModule) return n2; var f2 = n2.default; if (typeof f2 == "function") { var a = function a2() { if (this instanceof a2) { return Reflect.construct(f2, arguments, this.constructor); } return f2.apply(this, arguments); }; a.prototype = f2.prototype; } else a = {}; Object.defineProperty(a, "__esModule", { value: true }); Object.keys(n2).forEach(function(k2) { var d2 = Object.getOwnPropertyDescriptor(n2, k2); Object.defineProperty(a, k2, d2.get ? d2 : { enumerable: true, get: function() { return n2[k2]; } }); }); return a; } var jsxRuntime = { exports: {} }; var reactJsxRuntime_production_min = {}; /* object-assign (c) Sindre Sorhus @license MIT */ var getOwnPropertySymbols = Object.getOwnPropertySymbols; var hasOwnProperty$4 = Object.prototype.hasOwnProperty; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function toObject(val) { if (val === null || val === void 0) { throw new TypeError("Object.assign cannot be called with null or undefined"); } return Object(val); } function shouldUseNative() { try { if (!Object.assign) { return false; } var test1 = new String("abc"); test1[5] = "de"; if (Object.getOwnPropertyNames(test1)[0] === "5") { return false; } var test2 = {}; for (var i = 0; i < 10; i++) { test2["_" + String.fromCharCode(i)] = i; } var order2 = Object.getOwnPropertyNames(test2).map(function(n2) { return test2[n2]; }); if (order2.join("") !== "0123456789") { return false; } var test3 = {}; "abcdefghijklmnopqrst".split("").forEach(function(letter) { test3[letter] = letter; }); if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") { return false; } return true; } catch (err) { return false; } } shouldUseNative() ? Object.assign : function(target, source) { var from2; var to = toObject(target); var symbols; for (var s2 = 1; s2 < arguments.length; s2++) { from2 = Object(arguments[s2]); for (var key in from2) { if (hasOwnProperty$4.call(from2, key)) { to[key] = from2[key]; } } if (getOwnPropertySymbols) { symbols = getOwnPropertySymbols(from2); for (var i = 0; i < symbols.length; i++) { if (propIsEnumerable.call(from2, symbols[i])) { to[symbols[i]] = from2[symbols[i]]; } } } } return to; }; /** @license React v17.0.2 * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var f$1 = React, g$2 = 60103; reactJsxRuntime_production_min.Fragment = 60107; if ("function" === typeof Symbol && Symbol.for) { var h$2 = Symbol.for; g$2 = h$2("react.element"); reactJsxRuntime_production_min.Fragment = h$2("react.fragment"); } var m$2 = f$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, n$1 = Object.prototype.hasOwnProperty, p$3 = { key: true, ref: true, __self: true, __source: true }; function q$1(c2, a, k2) { var b2, d2 = {}, e2 = null, l2 = null; void 0 !== k2 && (e2 = "" + k2); void 0 !== a.key && (e2 = "" + a.key); void 0 !== a.ref && (l2 = a.ref); for (b2 in a) n$1.call(a, b2) && !p$3.hasOwnProperty(b2) && (d2[b2] = a[b2]); if (c2 && c2.defaultProps) for (b2 in a = c2.defaultProps, a) void 0 === d2[b2] && (d2[b2] = a[b2]); return { $$typeof: g$2, type: c2, key: e2, ref: l2, props: d2, _owner: m$2.current }; } reactJsxRuntime_production_min.jsx = q$1; reactJsxRuntime_production_min.jsxs = q$1; { jsxRuntime.exports = reactJsxRuntime_production_min; } var jsxRuntimeExports = jsxRuntime.exports; const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"; let nanoid = (size = 21) => { let id = ""; let bytes = crypto.getRandomValues(new Uint8Array(size |= 0)); while (size--) { id += urlAlphabet[bytes[size] & 63]; } return id; }; function isElementOfType(node2, type) { return /* @__PURE__ */ React.isValidElement(node2) && node2.type === type; } var EMPTY_ARRAY = Object.freeze([]); var EMPTY_MAP = /* @__PURE__ */ new Map(); var EMPTY_FUNCTION$5 = () => void 0; function ensureArray(value2) { return Array.isArray(value2) ? value2 : [value2]; } function removeNullAndUndefined() { for (var _len = arguments.length, maybeDefined = new Array(_len), _key = 0; _key < _len; _key++) { maybeDefined[_key] = arguments[_key]; } return maybeDefined.filter((m2) => m2 != null); } function _defineProperty$i(e2, r2, t2) { return (r2 = _toPropertyKey$h(r2)) in e2 ? Object.defineProperty(e2, r2, { value: t2, enumerable: true, configurable: true, writable: true }) : e2[r2] = t2, e2; } function _toPropertyKey$h(t2) { var i = _toPrimitive$h(t2, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive$h(t2, r2) { if ("object" != typeof t2 || !t2) return t2; var e2 = t2[Symbol.toPrimitive]; if (void 0 !== e2) { var i = e2.call(t2, r2); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r2 ? String : Number)(t2); } class CanceledPromiseError extends Error { constructor() { super(...arguments); _defineProperty$i(this, "isCanceled", true); } } function bindAllMethods(instance) { var traversePrototypeChain = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; var methodNames = getAllMethodNames(instance, traversePrototypeChain); methodNames.forEach((methodName) => { instance[methodName] = instance[methodName].bind(instance); }); } function getAllMethodNames(instance, traversePrototypeChain) { var methodNames = /* @__PURE__ */ new Set(); var current = instance; var level = 0; while (current != null && current !== Object.prototype && (level <= 1 || traversePrototypeChain)) { for (var name of Object.getOwnPropertyNames(current)) { var _Object$getOwnPropert; if (name !== "constructor" && // Ensure this is a method and not a getter typeof ((_Object$getOwnPropert = Object.getOwnPropertyDescriptor(current, name)) === null || _Object$getOwnPropert === void 0 ? void 0 : _Object$getOwnPropert.value) === "function") { methodNames.add(name); } } current = Object.getPrototypeOf(current); level += 1; } return [...methodNames.keys()]; } class ColorUtils { /** * THIS HAS POOR PERFORMANCE DUE TO DOM MANIPULATION * Attempt to get the rgb or rgba string for a color string. If the color string * can't be resolved to a valid color, null is returned. * @param colorString The color string to resolve */ static asRgbOrRgbaString(colorString) { if ( // Since dom manipulation is expensive, we want to avoid it if possible. /^rgb/.test(colorString) || /^rgba/.test(colorString) || /^color\(srgb/.test(colorString) ) { return colorString; } var divEl = document.createElement("div"); divEl.style.display = "none"; divEl.style.backgroundColor = colorString; var color2 = window.getComputedStyle(document.body.appendChild(divEl)).getPropertyValue("background-color"); divEl.remove(); return color2 || null; } /** * THIS HAS POOR PERFORMANCE DUE TO DOM MANIPULATION * DO NOT USE HEAVILY * Checks if a background color is dark (i.e. should use a light foreground). * * @param background the background color */ static isDark(background) { var d2 = document.createElement("div"); d2.style.display = "none"; d2.style.backgroundColor = background; var computedColor = getComputedStyle(document.body.appendChild(d2)).backgroundColor; var colorTokens = computedColor.match(/\d+/g); var color2 = []; if (colorTokens) { color2 = colorTokens.map((a) => parseInt(a, 10)); } else { throw new Error("Invalid color received. Got ".concat(computedColor)); } document.body.removeChild(d2); var brightness = ColorUtils.getBrightness(color2); return brightness < 125; } // Note: leaving this as arbitrary length number[] in case of RGBA(). static getBrightness(color2) { return Math.round((color2[0] * 299 + color2[1] * 587 + color2[2] * 114) / 1e3); } /** * THIS HAS POOR PERFORMANCE DUE TO DOM MANIPULATION * Normalize a css color to 8 character hex value (or 6 character hex if * isAlphaOptional is true and alpha is 'ff'). If the color can't be resolved, * return the original string. * @param colorString The color string to normalize * @param isAlphaOptional If true, the alpha value will be dropped if it is 'ff'. * Defaults to false. */ static normalizeCssColor(colorString) { var isAlphaOptional = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; var maybeRgbOrRgba = ColorUtils.asRgbOrRgbaString(colorString); if (maybeRgbOrRgba == null) { return colorString; } var rgba = ColorUtils.parseRgba(maybeRgbOrRgba); if (rgba === null) { return colorString; } var hex8 = ColorUtils.rgbaToHex8(rgba); if (isAlphaOptional === true) { return hex8.replace(/^(#[a-f0-9]{6})ff$/, "$1"); } return hex8; } /** * Parse a given `rgb` or `rgba` css expression into its constituent r, g, b, a * values. If the expression cannot be parsed, it will return null. * Note that this parser is more permissive than the CSS spec and shouldn't be * relied on as a full validation mechanism. For the most part, it assumes that * the input is already a valid rgb or rgba expression. * * e.g. `rgb(255, 255, 255)` -> `{ r: 255, g: 255, b: 255, a: 1 }` * e.g. `rgba(255, 255, 255, 0.5)` -> `{ r: 255, g: 255, b: 255, a: 0.5 }` * e.g. `color(srgb 1 1 0 / 0.25)` -> `{ r: 255, g: 255, b: 0, a: 0.25 }` * @param rgbOrRgbaString The rgb or rgba string to parse */ static parseRgba(rgbOrRgbaString) { var _rgbOrRgbaString$matc; var [r2, g2, b2, a] = (_rgbOrRgbaString$matc = rgbOrRgbaString.match( // loose with the regex to allow for different formats between browsers // take the first 4 digits that look like numbers, including decimals // We've already checked it's a valid color with CSS.supports /(?:\b\d+\.\d*|\b\d+|\.\d+)/g )) !== null && _rgbOrRgbaString$matc !== void 0 ? _rgbOrRgbaString$matc : []; if (r2 == null || g2 == null || b2 == null) { return null; } if (rgbOrRgbaString.startsWith("color(srgb")) { return { r: Math.round(Number(r2) * 255), g: Math.round(Number(g2) * 255), b: Math.round(Number(b2) * 255), a: Number(a !== null && a !== void 0 ? a : 1) }; } return { r: Number(r2), g: Number(g2), b: Number(b2), a: Math.min(Number(a !== null && a !== void 0 ? a : 1), 1) }; } /** * Convert an rgba object to an 8 character hex color string. * @param r The red value * @param g The green value * @param b The blue value * @param a The alpha value (defaults to 1) * @returns The a character hex string with # prefix */ static rgbaToHex8(_ref) { var { r: r2, g: g2, b: b2, a = 1 } = _ref; a = Math.round(a * 255); var [rh, gh, bh, ah] = [r2, g2, b2, a].map((v2) => v2.toString(16).padStart(2, "0")); return "#".concat(rh).concat(gh).concat(bh).concat(ah); } } function _defineProperty$h(e2, r2, t2) { return (r2 = _toPropertyKey$g(r2)) in e2 ? Object.defineProperty(e2, r2, { value: t2, enumerable: true, configurable: true, writable: true }) : e2[r2] = t2, e2; } function _toPropertyKey$g(t2) { var i = _toPrimitive$g(t2, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive$g(t2, r2) { if ("object" != typeof t2 || !t2) return t2; var e2 = t2[Symbol.toPrimitive]; if (void 0 !== e2) { var i = e2.call(t2, r2); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r2 ? String : Number)(t2); } class TimeoutError extends Error { constructor() { super(...arguments); _defineProperty$h(this, "isTimeout", true); } } function assertNotNull(value2) { var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Value is null or undefined"; if (value2 == null) throw new Error(message); } function getOrThrow(map2, key) { var _map$get; var defaultValue = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : void 0; var value2 = (_map$get = map2.get(key)) !== null && _map$get !== void 0 ? _map$get : defaultValue; if (value2 !== void 0) { return value2; } throw new Error("Missing value for key ".concat(key)); } class PromiseUtils { /** * Creates a promise that can be canceled by calling the `cancel` function * Pass an optional `cleanupFunc` to perform actions on the resolved item after promise is cancelled. * @param promise The item to resolve * @param cleanup Function to cleanup the resolved item after cancelation. Called after both this promise is cancelled and the wrapped item was resolved (order does not matter). */ static makeCancelable(promise2, cleanup) { var hasCanceled = false; var resolved; var rejectFn; var wrappedPromise = new Promise((resolve, reject) => { rejectFn = reject; Promise.resolve(promise2).then((val) => { if (hasCanceled) { if (cleanup) { cleanup(val); } } else { resolved = val; resolve(val); } }).catch((error) => reject(error)); }); wrappedPromise.cancel = () => { hasCanceled = true; rejectFn(new CanceledPromiseError()); if (resolved != null && cleanup) { cleanup(resolved); } }; return wrappedPromise; } static isCanceled(error) { return error instanceof CanceledPromiseError; } static isTimedOut(error) { return error instanceof TimeoutError; } /** * Wrap a callback call in a Promise + setTimeout. * @param timeoutMs * @param callback */ static withTimeout(timeoutMs, callback) { return new Promise((resolve, reject) => { setTimeout(() => { try { resolve(callback()); } catch (err) { reject(err); } }, timeoutMs); }); } } class TextUtils { /** * Joins a list of strings with a comma, keeping the oxford comma and adding "and" as appropriate. * Eg. * One * One and Two * One, Two, and Three * @param items The items to join in a list * @param conjunction Conjunction to use between the last two items */ static join(items) { var conjunction = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "and"; if (items == null || items.length === 0) { return ""; } if (items.length === 1) { return items[0]; } if (items.length === 2) { return "".concat(items[0], " ").concat(conjunction, " ").concat(items[1]); } var itemText = items.slice(0, items.length - 1).join(", "); var lastItem = items[items.length - 1]; return "".concat(itemText, ", ").concat(conjunction, " ").concat(lastItem); } /** * Converts text to lower case, handling null if necessary and returning an empty string * @param text The text to convert to lower case * @param isNullAllowed True if a null string should return an empty string from this function. If false an error is thrown if null is passed in. */ static toLower(text2) { var isNullAllowed = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true; if (text2 == null) { if (isNullAllowed) { return ""; } throw new Error("Null string passed in to TextUtils.toLower"); } return text2.toLowerCase(); } /** * * @param a The string to sort * @param b Second string to sort * @param isAscending Whether to sort ascending or descending */ static sort(a, b2) { var isAscending = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true; if (a < b2) { return isAscending ? -1 : 1; } if (a > b2) { return isAscending ? 1 : -1; } return 0; } } function useContextOrThrow(context) { var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "No value available in context. Was code wrapped in a provider?"; var value2 = React.useContext(context); if (value2 == null) { throw new Error(message); } return value2; } var FUNC_ERROR_TEXT = "Expected a function"; var NAN$1 = 0 / 0; var symbolTag$1 = "[object Symbol]"; var reTrim$1 = /^\s+|\s+$/g; var reIsBadHex$1 = /^[-+]0x[0-9a-f]+$/i; var reIsBinary$1 = /^0b[01]+$/i; var reIsOctal$1 = /^0o[0-7]+$/i; var freeParseInt$1 = parseInt; var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; var freeSelf = typeof self == "object" && self && self.Object === Object && self; var root$2 = freeGlobal || freeSelf || Function("return this")(); var objectProto$1 = Object.prototype; var objectToString$1 = objectProto$1.toString; var nativeMax = Math.max, nativeMin = Math.min; var now = function() { return root$2.Date.now(); }; function debounce(func, wait, options) { var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true; if (typeof func != "function") { throw new TypeError(FUNC_ERROR_TEXT); } wait = toNumber$1(wait) || 0; if (isObject$5(options)) { leading = !!options.leading; maxing = "maxWait" in options; maxWait = maxing ? nativeMax(toNumber$1(options.maxWait) || 0, wait) : maxWait; trailing = "trailing" in options ? !!options.trailing : trailing; } function invokeFunc(time) { var args = lastArgs, thisArg = lastThis; lastArgs = lastThis = void 0; lastInvokeTime = time; result = func.apply(thisArg, args); return result; } function leadingEdge(time) { lastInvokeTime = time; timerId = setTimeout(timerExpired, wait); return leading ? invokeFunc(time) : result; } function remainingWait(time) { var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall; return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2; } function shouldInvoke(time) { var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime; return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; } function timerExpired() { var time = now(); if (shouldInvoke(time)) { return trailingEdge(time); } timerId = setTimeout(timerExpired, remainingWait(time)); } function trailingEdge(time) { timerId = void 0; if (trailing && lastArgs) { return invokeFunc(time); } lastArgs = lastThis = void 0; return result; } function cancel() { if (timerId !== void 0) { clearTimeout(timerId); } lastInvokeTime = 0; lastArgs = lastCallTime = lastThis = timerId = void 0; } function flush() { return timerId === void 0 ? result : trailingEdge(now()); } function debounced() { var time = now(), isInvoking = shouldInvoke(time); lastArgs = arguments; lastThis = this; lastCallTime = time; if (isInvoking) { if (timerId === void 0) { return leadingEdge(lastCallTime); } if (maxing) { timerId = setTimeout(timerExpired, wait); return invokeFunc(lastCallTime); } } if (timerId === void 0) { timerId = setTimeout(timerExpired, wait); } return result; } debounced.cancel = cancel; debounced.flush = flush; return debounced; } function isObject$5(value2) { var type = typeof value2; return !!value2 && (type == "object" || type == "function"); } function isObjectLike$1(value2) { return !!value2 && typeof value2 == "object"; } function isSymbol$2(value2) { return typeof value2 == "symbol" || isObjectLike$1(value2) && objectToString$1.call(value2) == symbolTag$1; } function toNumber$1(value2) { if (typeof value2 == "number") { return value2; } if (isSymbol$2(value2)) { return NAN$1; } if (isObject$5(value2)) { var other = typeof value2.valueOf == "function" ? value2.valueOf() : value2; value2 = isObject$5(other) ? other + "" : other; } if (typeof value2 != "string") { return value2 === 0 ? value2 : +value2; } value2 = value2.replace(reTrim$1, ""); var isBinary = reIsBinary$1.test(value2); return isBinary || reIsOctal$1.test(value2) ? freeParseInt$1(value2.slice(2), isBinary ? 2 : 8) : reIsBadHex$1.test(value2) ? NAN$1 : +value2; } var lodash_debounce = debounce; const debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(lodash_debounce); function useDebouncedCallback(callback, debounceMs) { var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; var { leading = false, trailing = true, maxWait } = options; var debouncedCallback = React.useMemo(() => debounce$1(callback, debounceMs, maxWait != null ? ( // lodash checks `'maxWait' in options` // and lower clamps to the debounce if it exists at all { leading, trailing, maxWait } ) : { leading, trailing }), [callback, debounceMs, leading, trailing, maxWait]); React.useEffect(() => () => debouncedCallback.cancel(), [debouncedCallback]); return debouncedCallback; } function usePrevious(value2) { var ref = React.useRef(); React.useEffect(function getPrev() { ref.current = value2; }); return ref.current; } function asyncGeneratorStep$1(n2, t2, e2, r2, o2, a, c2) { try { var i = n2[a](c2), u2 = i.value; } catch (n3) { return void e2(n3); } i.done ? t2(u2) : Promise.resolve(u2).then(r2, o2); } function _asyncToGenerator$1(n2) { return function() { var t2 = this, e2 = arguments; return new Promise(function(r2, o2) { var a = n2.apply(t2, e2); function _next(n3) { asyncGeneratorStep$1(a, r2, o2, _next, _throw, "next", n3); } function _throw(n3) { asyncGeneratorStep$1(a, r2, o2, _next, _throw, "throw", n3); } _next(void 0); }); }; } function usePromiseFactory(promiseFactory) { var args = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : EMPTY_ARRAY; var { autoLoad = true } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; var [data2, setData] = React.useState(null); var [error, setError] = React.useState(null); var [isLoading, setIsLoading] = React.useState(autoLoad); var loadPromise = React.useCallback(/* @__PURE__ */ _asyncToGenerator$1(function* () { setIsLoading(true); try { var resolved = yield promiseFactory(...args); setData(resolved); setError(null); } catch (err) { setData(null); setError(err); } finally { setIsLoading(false); } }), [promiseFactory, ...args]); React.useEffect(() => { if (autoLoad) { loadPromise(); } }, [autoLoad, loadPromise]); return { data: data2, error, isError: error != null, isLoading, reload: loadPromise }; } const styles$3 = '/* stylelint-disable scss/at-import-no-partial-leading-underscore */\n/* stylelint-disable-next-line number-max-precision */\n.ui-portal-panel {\n height: 100%;\n width: 100%;\n position: relative;\n overflow: hidden;\n}\n.ui-table-container {\n height: 100%;\n width: 100%;\n position: relative;\n}\n.dh-react-panel {\n display: grid;\n}\n.dh-react-panel .dh-inner-react-panel {\n min-width: 0;\n}\n.dh-react-panel .dh-inner-react-panel > .dh-flex,\n.dh-react-panel .dh-inner-react-panel > .dh-grid {\n align-self: stretch;\n}\n.dh-react-panel .dh-inner-react-panel .dh-tabs {\n flex: auto;\n height: 100%;\n}\n.dh-react-panel .dh-inner-react-panel .iris-grid {\n min-height: 70px;\n border: 1px solid var(--dh-color-bg);\n border-radius: 4px;\n}\n.dh-react-panel .dh-inner-react-panel .iris-grid canvas {\n position: absolute;\n}\n.dh-react-panel:has(.dh-inner-react-panel > .iris-grid:only-child), .dh-react-panel:has(.dh-inner-react-panel > .ui-table-container:only-child > .iris-grid:only-child), .dh-react-panel:has(.dh-inner-react-panel > .chart-wrapper:only-child) {\n padding: 0 !important;\n}\n.dh-react-panel:has(.dh-inner-react-panel > .iris-grid:only-child) .iris-grid, .dh-react-panel:has(.dh-inner-react-panel > .ui-table-container:only-child > .iris-grid:only-child) .iris-grid, .dh-react-panel:has(.dh-inner-react-panel > .chart-wrapper:only-child) .iris-grid {\n border: none;\n border-radius: 0;\n}\n.ui-text-wrap-balance {\n text-wrap: balance;\n}\n.ui-monospace-text {\n font-family: "Fira Mono", menlo, monaco, consolas, "Liberation Mono", "Courier New", monospace;\n white-space: pre;\n}\n.ui-widget-error-view {\n overflow: hidden;\n width: 100%;\n}\n.ui-widget-error-contextual-help section[class*=spectrum-ContextualHelp-dialog] {\n width: fit-content;\n}\n.ui-markdown {\n padding: 0;\n}'; const PORTAL_OPENED = "PortalPanelEvent.PORTAL_OPENED"; const PORTAL_CLOSED = "PortalPanelEvent.PORTAL_CLOSED"; function listenForEvent(eventHub, event, handler) { eventHub.on(event, handler); return () => { eventHub.off(event, handler); }; } function makeListenFunction(event) { return (eventHub, handler) => listenForEvent(eventHub, event, handler); } function makeEmitFunction(event) { return (eventHub, payload) => { eventHub.emit(event, payload); }; } function makeUseListenerFunction(event) { return (eventHub, handler) => { React.useEffect( () => listenForEvent(eventHub, event, handler), [eventHub, handler] ); }; } function makeEventFunctions(event) { return { listen: makeListenFunction(event), emit: makeEmitFunction(event), useListener: makeUseListenerFunction(event) }; } const { emit: emitPortalOpened, useListener: usePortalOpenedListener } = makeEventFunctions(PORTAL_OPENED); const { emit: emitPortalClosed, useListener: usePortalClosedListener } = makeEventFunctions(PORTAL_CLOSED); function PortalPanel({ glContainer, glEventHub }) { const ref = React.useRef(null); React.useEffect(() => { const { current } = ref; if (current == null) { return; } emitPortalOpened(glEventHub, { container: glContainer, element: current }); return () => { emitPortalClosed(glEventHub, { container: glContainer }); }; }, [glContainer, glEventHub]); return /* @__PURE__ */ jsxRuntimeExports.jsx(dashboardCorePlugins.CorePanel, { glContainer, glEventHub, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ui-portal-panel", ref }) }); } PortalPanel.displayName = "@deephaven/js-plugin-ui/PortalPanel"; const PortalPanelManagerContext = React.createContext(null); function usePortalPanelManager() { return useContextOrThrow(PortalPanelManagerContext, "PortalPanelManager"); } function PortalPanelManager({ children }) { const { eventHub } = dashboard.useLayoutManager(); const [portals, setPortals] = React.useState(/* @__PURE__ */ new Map()); const handlePortalOpened = React.useCallback(({ container, element: element2 }) => { setPortals((prevPortals) => { const containerId = dashboard.LayoutUtils.getIdFromContainer(container); if (containerId == null) { throw new Error("Invalid panel ID"); } const panelId = Array.isArray(containerId) ? containerId[0] : containerId; const newPortals = new Map(prevPortals); newPortals.set(panelId, element2); return newPortals; }); }, []); const handlePortalClosed = React.useCallback(({ container }) => { setPortals((prevPortals) => { const containerId = dashboard.LayoutUtils.getIdFromContainer(container); if (containerId == null) { throw new Error("Invalid panel ID"); } const panelId = Array.isArray(containerId) ? containerId[0] : containerId; const newPortals = new Map(prevPortals); newPortals.delete(panelId); return newPortals; }); }, []); usePortalOpenedListener(eventHub, handlePortalOpened); usePortalClosedListener(eventHub, handlePortalClosed); return /* @__PURE__ */ jsxRuntimeExports.jsx(PortalPanelManagerContext.Provider, { value: portals, children }); } /*! * https://github.com/Starcounter-Jack/JSON-Patch * (c) 2017-2022 Joachim Wester * MIT licensed */ var __extends$1r = /* @__PURE__ */ function() { var extendStatics = function(d2, b2) { extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) { d3.__proto__ = b3; } || function(d3, b3) { for (var p2 in b3) if (b3.hasOwnProperty(p2)) d3[p2] = b3[p2]; }; return extendStatics(d2, b2); }; return function(d2, b2) { extendStatics(d2, b2); function __() { this.constructor = d2; } d2.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __()); }; }(); var _hasOwnProperty = Object.prototype.hasOwnProperty; function hasOwnProperty$3(obj, key) { return _hasOwnProperty.call(obj, key); } function _objectKeys(obj) { if (Array.isArray(obj)) { var keys_1 = new Array(obj.length); for (var k2 = 0; k2 < keys_1.length; k2++) { keys_1[k2] = "" + k2; } return keys_1; } if (Object.keys) { return Object.keys(obj); } var keys2 = []; for (var i in obj) { if (hasOwnProperty$3(obj, i)) { keys2.push(i); } } return keys2; } function _deepClone(obj) { switch (typeof obj) { case "object": return JSON.parse(JSON.stringify(obj)); case "undefined": return null; default: return obj; } } function isInteger(str2) { var i = 0; var len = str2.length; var charCode; while (i < len) { charCode = str2.charCodeAt(i); if (charCode >= 48 && charCode <= 57) { i++; continue; } return false; } return true; } function escapePathComponent(path2) { if (path2.indexOf("/") === -1 && path2.indexOf("~") === -1) return path2; return path2.replace(/~/g, "~0").replace(/\//g, "~1"); } function unescapePathComponent(path2) { return path2.replace(/~1/g, "/").replace(/~0/g, "~"); } function hasUndefined(obj) { if (obj === void 0) { return true; } if (obj) { if (Array.isArray(obj)) { for (var i_1 = 0, len = obj.length; i_1 < len; i_1++) { if (hasUndefined(obj[i_1])) { return true; } } } else if (typeof obj === "object") { var objKeys = _objectKeys(obj); var objKeysLength = objKeys.length; for (var i = 0; i < objKeysLength; i++) { if (hasUndefined(obj[objKeys[i]])) { return true; } } } } return false; } function patchErrorMessageFormatter(message, args) { var messageParts = [message]; for (var key in args) { var value2 = typeof args[key] === "object" ? JSON.stringify(args[key], null, 2) : args[key]; if (typeof value2 !== "undefined") { messageParts.push(key + ": " + value2); } } return messageParts.join("\n"); } var PatchError = ( /** @class */ function(_super) { __extends$1r(PatchError2, _super); function PatchError2(message, name, index2, operation, tree) { var _newTarget = this.constructor; var _this = _super.call(this, patchErrorMessageFormatter(message, { name, index: index2, operation, tree })) || this; _this.name = name; _this.index = index2; _this.operation = operation; _this.tree = tree; Object.setPrototypeOf(_this, _newTarget.prototype); _this.message = patchErrorMessageFormatter(message, { name, index: index2, operation, tree }); return _this; } return PatchError2; }(Error) ); var JsonPatchError = PatchError; var deepClone = _deepClone; var objOps = { add: function(obj, key, document2) { obj[key] = this.value; return { newDocument: document2 }; }, remove: function(obj, key, document2) { var removed = obj[key]; delete obj[key]; return { newDocument: document2, removed }; }, replace: function(obj, key, document2) { var removed = obj[key]; obj[key] = this.value; return { newDocument: document2, removed }; }, move: function(obj, key, document2) { var removed = getValueByPointer(document2, this.path); if (removed) { removed = _deepClone(removed); } var originalValue = applyOperation(document2, { op: "remove", path: this.from }).removed; applyOperation(document2, { op: "add", path: this.path, value: originalValue }); return { newDocument: document2, removed }; }, copy: function(obj, key, document2) { var valueToCopy = getValueByPointer(document2, this.from); applyOperation(document2, { op: "add", path: this.path, value: _deepClone(valueToCopy) }); return { newDocument: document2 }; }, test: function(obj, key, document2) { return { newDocument: document2, test: _areEquals(obj[key], this.value) }; }, _get: function(obj, key, document2) { this.value = obj[key]; return { newDocument: document2 }; } }; var arrOps = { add: function(arr, i, document2) { if (isInteger(i)) { arr.splice(i, 0, this.value); } else { arr[i] = this.value; } return { newDocument: document2, index: i }; }, remove: function(arr, i, document2) { var removedList = arr.splice(i, 1); return { newDocument: document2, removed: removedList[0] }; }, replace: function(arr, i, document2) { var removed = arr[i]; arr[i] = this.value; return { newDocument: document2, removed }; }, move: objOps.move, copy: objOps.copy, test: objOps.test, _get: objOps._get }; function getValueByPointer(document2, pointer) { if (pointer == "") { return document2; } var getOriginalDestination = { op: "_get", path: pointer }; applyOperation(document2, getOriginalDestination); return getOriginalDestination.value; } function applyOperation(document2, operation, validateOperation, mutateDocument, banPrototypeModifications, index2) { if (validateOperation === void 0) { validateOperation = false; } if (mutateDocument === void 0) { mutateDocument = true; } if (banPrototypeModifications === void 0) { banPrototypeModifications = true; } if (index2 === void 0) { index2 = 0; } if (validateOperation) { if (typeof validateOperation == "function") { validateOperation(operation, 0, document2, operation.path); } else { validator(operation, 0); } } if (operation.path === "") { var returnValue = { newDocument: document2 }; if (operation.op === "add") { returnValue.newDocument = operation.value; return returnValue; } else if (operation.op === "replace") { returnValue.newDocument = operation.value; returnValue.removed = document2; return returnValue; } else if (operation.op === "move" || operation.op === "copy") { returnValue.newDocument = getValueByPointer(document2, operation.from); if (operation.op === "move") { returnValue.removed = document2; } return returnValue; } else if (operation.op === "test") { returnValue.test = _areEquals(document2, operation.value); if (returnValue.test === false) { throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index2, operation, document2); } returnValue.newDocument = document2; return returnValue; } else if (operation.op === "remove") { returnValue.removed = document2; returnValue.newDocument = null; return returnValue; } else if (operation.op === "_get") { operation.value = document2; return returnValue; } else { if (validateOperation) { throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index2, operation, document2); } else { return returnValue; } } } else { if (!mutateDocument) { document2 = _deepClone(document2); } var path2 = operation.path || ""; var keys2 = path2.split("/"); var obj = document2; var t2 = 1; var len = keys2.length; var existingPathFragment = void 0; var key = void 0; var validateFunction = void 0; if (typeof validateOperation == "function") { validateFunction = validateOperation; } else { validateFunction = validator; } while (true) { key = keys2[t2]; if (key && key.indexOf("~") != -1) { key = unescapePathComponent(key); } if (banPrototypeModifications && (key == "__proto__" || key == "prototype" && t2 > 0 && keys2[t2 - 1] == "constructor")) { throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README"); } if (validateOperation) { if (existingPathFragment === void 0) { if (obj[key] === void 0) { existingPathFragment = keys2.slice(0, t2).join("/"); } else if (t2 == len - 1) { existingPathFragment = operation.path; } if (existingPathFragment !== void 0) { validateFunction(operation, 0, document2, existingPathFragment); } } } t2++; if (Array.isArray(obj)) { if (key === "-") { key = obj.length; } else { if (validateOperation && !isInteger(key)) { throw new JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", index2, operation, document2); } else if (isInteger(key)) { key = ~~key; } } if (t2 >= len) { if (validateOperation && operation.op === "add" && key > obj.length) { throw new JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", index2, operation, document2); } var returnValue = arrOps[operation.op].call(operation, obj, key, document2); if (returnValue.test === false) { throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index2, operation, document2); } return returnValue; } } else { if (t2 >= len) { var returnValue = objOps[operation.op].call(operation, obj, key, document2); if (returnValue.test === false) { throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index2, operation, document2); } return returnValue; } } obj = obj[key]; if (validateOperation && t2 < len && (!obj || typeof obj !== "object")) { throw new JsonPatchError("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", index2, operation, document2); } } } } function applyPatch(document2, patch2, validateOperation, mutateDocument, banPrototypeModifications) { if (mutateDocument === void 0) { mutateDocument = true; } if (banPrototypeModifications === void 0) { banPrototypeModifications = true; } if (validateOperation) { if (!Array.isArray(patch2)) { throw new JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY"); } } if (!mutateDocument) { document2 = _deepClone(document2); } var results = new Array(patch2.length); for (var i = 0, length_1 = patch2.length; i < length_1; i++) { results[i] = applyOperation(document2, patch2[i], validateOperation, true, banPrototypeModifications, i); document2 = results[i].newDocument; } results.newDocument = document2; return results; } function applyReducer(document2, operation, index2) { var operationResult = applyOperation(document2, operation); if (operationResult.test === false) { throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index2, operation, document2); } return operationResult.newDocument; } function validator(operation, index2, document2, existingPathFragment) { if (typeof operation !== "object" || operation === null || Array.isArray(operation)) { throw new JsonPatchError("Operation is not an object", "OPERATION_NOT_AN_OBJECT", index2, operation, document2); } else if (!objOps[operation.op]) { throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index2, operation, document2); } else if (typeof operation.path !== "string") { throw new JsonPatchError("Operation `path` property is not a string", "OPERATION_PATH_INVALID", index2, operation, document2); } else if (operation.path.indexOf("/") !== 0 && operation.path.length > 0) { throw new JsonPatchError('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", index2, operation, document2); } else if ((operation.op === "move" || operation.op === "copy") && typeof operation.from !== "string") { throw new JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", index2, operation, document2); } else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && operation.value === void 0) { throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", index2, operation, document2); } else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && hasUndefined(operation.value)) { throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", index2, operation, document2); } else if (document2) { if (operation.op == "add") { var pathLen = operation.path.split("/").length; var existingPathLen = existingPathFragment.split("/").length; if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) { throw new JsonPatchError("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", index2, operation, document2); } } else if (operation.op === "replace" || operation.op === "remove" || operation.op === "_get") { if (operation.path !== existingPathFragment) { throw new JsonPatchError("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", index2, operation, document2); } } else if (operation.op === "move" || operation.op === "copy") { var existingValue = { op: "_get", path: operation.from, value: void 0 }; var error = validate([existingValue], document2); if (error && error.name === "OPERATION_PATH_UNRESOLVABLE") { throw new JsonPatchError("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", index2, operation, document2); } } } } function validate(sequence, document2, externalValidator) { try { if (!Array.isArray(sequence)) { throw new JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY"); } if (document2) { applyPatch(_deepClone(document2), _deepClone(sequence), externalValidator || true); } else { externalValidator = externalValidator || validator; for (var i = 0; i < sequence.length; i++) { externalValidator(sequence[i], i, document2, void 0); } } } catch (e2) { if (e2 instanceof JsonPatchError) { return e2; } else { throw e2; } } } function _areEquals(a, b2) { if (a === b2) return true; if (a && b2 && typeof a == "object" && typeof b2 == "object") { var arrA = Array.isArray(a), arrB = Array.isArray(b2), i, length, key; if (arrA && arrB) { length = a.length; if (length != b2.length) return false; for (i = length; i-- !== 0; ) if (!_areEquals(a[i], b2[i])) return false; return true; } if (arrA != arrB) return false; var keys2 = Object.keys(a); length = keys2.length; if (length !== Object.keys(b2).length) return false; for (i = length; i-- !== 0; ) if (!b2.hasOwnProperty(keys2[i])) return false; for (i = length; i-- !== 0; ) { key = keys2[i]; if (!_areEquals(a[key], b2[key])) return false; } return true; } return a !== a && b2 !== b2; } const core$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, JsonPatchError, _areEquals, applyOperation, applyPatch, applyReducer, deepClone, getValueByPointer, validate, validator }, Symbol.toStringTag, { value: "Module" })); /*! * https://github.com/Starcounter-Jack/JSON-Patch * (c) 2017-2021 Joachim Wester * MIT license */ var beforeDict = /* @__PURE__ */ new WeakMap(); var Mirror = ( /** @class */ /* @__PURE__ */ function() { function Mirror2(obj) { this.observers = /* @__PURE__ */ new Map(); this.obj = obj; } return Mirror2; }() ); var ObserverInfo = ( /** @class */ /* @__PURE__ */ function() { function ObserverInfo2(callback, observer) { this.callback = callback; this.observer = observer; } return ObserverInfo2; }() ); function getMirror(obj) { return beforeDict.get(obj); } function getObserverFromMirror(mirror, callback) { return mirror.observers.get(callback); } function removeObserverFromMirror(mirror, observer) { mirror.observers.delete(observer.callback); } function unobserve(root2, observer) { observer.unobserve(); } function observe$1(obj, callback) { var patches = []; var observer; var mirror = getMirror(obj); if (!mirror) { mirror = new Mirror(obj); beforeDict.set(obj, mirror); } else { var observerInfo = getObserverFromMirror(mirror, callback); observer = observerInfo && observerInfo.observer; } if (observer) { return observer; } observer = {}; mirror.value = _deepClone(obj); if (callback) { observer.callback = callback; observer.next = null; var dirtyCheck = function() { generate$1(observer); }; var fastCheck = function() { clearTimeout(observer.next); observer.next = setTimeout(dirtyCheck); }; if (typeof window !== "undefined") { window.addEventListener("mouseup", fastCheck); window.addEventListener("keyup", fastCheck); window.addEventListener("mousedown", fastCheck); window.addEventListener("keydown", fastCheck); window.addEventListener("change", fastCheck); } } observer.patches = patches; observer.object = obj; observer.unobserve = function() { generate$1(observer); clearTimeout(observer.next); removeObserverFromMirror(mirror, observer); if (typeof window !== "undefined") { window.removeEventListener("mouseup", fastCheck); window.removeEventListener("keyup", fastCheck); window.removeEventListener("mousedown", fastCheck); window.removeEventListener("keydown", fastCheck); window.removeEventListener("change", fastCheck); } }; mirror.observers.set(callback, new ObserverInfo(callback, observer)); return observer; } function generate$1(observer, invertible) { if (invertible === void 0) { invertible = false