drizzle-cube
Version:
Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.
1,267 lines • 248 kB
JavaScript
var nr = Object.defineProperty;
var ar = (e, r, s) => r in e ? nr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[r] = s;
var ut = (e, r, s) => ar(e, typeof r != "symbol" ? r + "" : r, s);
import { jsxs as n, jsx as t, Fragment as Y } from "react/jsx-runtime";
import mt, { Component as ir, useRef as ee, useState as M, useLayoutEffect as lr, useEffect as K, forwardRef as $t, useMemo as ke, useImperativeHandle as Lt, useCallback as H } from "react";
import { useCubeQuery as or, useDebounce as cr, useFilterValues as dr } from "./hooks.js";
import { F as $e, a as It, b as Xe, c as de, d as ht, e as fe, f as Ae, g as ye, h as ne, i as Re, j as ur, k as De, l as Je, m as He, n as mr, o as Pt, p as pe, q as ft, r as hr, s as ge, t as fr, u as Vt, v as pr, w as gr, I as ie, x as br, y as yr, z as xr, A as vr, B as wr, C as Nr, D as Sr, E as kr, G as Ar, H as Dr, J as pt, K as Ue, L as gt } from "./chunks/icons-D95augkg.js";
import { t as Tr, b as Cr, i as _r, d as Te, l as Fr, g as Er, e as Rr, C as bt, h as yt, q as Or, j as qe, o as xt, k as Me, m as $r, D as qt, T as Lr, a as Ir, R as Pr, S as Vr, P as qr, A as Mr, L as Qr, B as Br } from "./chunks/charts-BadAUMmd.js";
import { c as Ga, s as Ja, r as Ha, p as Ua, n as Wa, v as Ya } from "./chunks/charts-BadAUMmd.js";
import { u as Ze } from "./chunks/providers-DI5zeeEU.js";
import { WidthProvider as zr, Responsive as jr } from "react-grid-layout";
class Gr extends ir {
constructor(s) {
super(s);
ut(this, "handleReset", () => {
this.setState({
hasError: !1,
error: null,
errorInfo: null
});
});
this.state = {
hasError: !1,
error: null,
errorInfo: null
};
}
static getDerivedStateFromError(s) {
return {
hasError: !0,
error: s,
errorInfo: null
};
}
componentDidCatch(s, a) {
this.setState({
error: s,
errorInfo: a.componentStack || null
}), console.error("Chart Error Boundary caught a rendering error:", s, a);
}
render() {
var s, a;
return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ n("div", { className: "flex flex-col items-center justify-center w-full h-full p-6 text-center border-2 border-dashed border-red-300 rounded-lg bg-red-50", children: [
/* @__PURE__ */ t("div", { className: "h-12 w-12 text-red-500 mb-4", children: "⚠️" }),
/* @__PURE__ */ t("h3", { className: "text-lg font-semibold text-red-600 mb-2", children: this.props.portletTitle ? `Rendering Error in ${this.props.portletTitle}` : "Chart Rendering Error" }),
/* @__PURE__ */ t("p", { className: "text-sm text-gray-600 mb-4 max-w-md", children: "There was an error rendering this chart component. This is different from query errors. The error details are shown below." }),
/* @__PURE__ */ t("div", { className: "w-full max-w-2xl mb-4", children: /* @__PURE__ */ n("div", { className: "bg-gray-100 rounded-lg p-3 text-left", children: [
/* @__PURE__ */ n("div", { className: "text-xs font-mono text-red-600 mb-2", children: [
/* @__PURE__ */ t("strong", { children: "Error:" }),
" ",
(s = this.state.error) == null ? void 0 : s.message
] }),
((a = this.state.error) == null ? void 0 : a.name) && /* @__PURE__ */ n("div", { className: "text-xs font-mono text-gray-600 mb-2", children: [
/* @__PURE__ */ t("strong", { children: "Type:" }),
" ",
this.state.error.name
] }),
this.props.portletConfig && /* @__PURE__ */ n("details", { className: "text-xs font-mono text-gray-600 mb-2", children: [
/* @__PURE__ */ t("summary", { className: "cursor-pointer", children: "Portlet Configuration" }),
/* @__PURE__ */ t("pre", { className: "mt-2 whitespace-pre-wrap bg-blue-50 p-2 rounded overflow-auto max-h-32", children: JSON.stringify(this.props.portletConfig, null, 2) })
] }),
this.props.cubeQuery && /* @__PURE__ */ n("details", { className: "text-xs font-mono text-gray-600 mb-2", children: [
/* @__PURE__ */ t("summary", { className: "cursor-pointer", children: "Cube Query" }),
/* @__PURE__ */ t("pre", { className: "mt-2 whitespace-pre-wrap bg-green-50 p-2 rounded overflow-auto max-h-32", children: typeof this.props.cubeQuery == "string" ? JSON.stringify(JSON.parse(this.props.cubeQuery), null, 2) : JSON.stringify(this.props.cubeQuery, null, 2) })
] }),
this.state.errorInfo && /* @__PURE__ */ n("details", { className: "text-xs font-mono text-gray-600", children: [
/* @__PURE__ */ t("summary", { className: "cursor-pointer", children: "Component Stack" }),
/* @__PURE__ */ t("pre", { className: "mt-2 whitespace-pre-wrap", children: this.state.errorInfo })
] })
] }) }),
/* @__PURE__ */ n(
"button",
{
onClick: this.handleReset,
className: "px-3 py-1 bg-blue-500 text-white rounded text-sm hover:bg-blue-600",
children: [
/* @__PURE__ */ t($e, { style: { width: "16px", height: "16px", display: "inline", marginRight: "4px" } }),
"Try Again"
]
}
)
] }) : this.props.children;
}
}
function vt(e, r) {
let s, a;
if (r === void 0)
for (const i of e)
i != null && (s === void 0 ? i >= i && (s = a = i) : (s > i && (s = i), a < i && (a = i)));
else {
let i = -1;
for (let l of e)
(l = r(l, ++i, e)) != null && (s === void 0 ? l >= l && (s = a = l) : (s > l && (s = l), a < l && (a = l)));
}
return [s, a];
}
function Jr(e, r) {
let s;
if (r === void 0)
for (const a of e)
a != null && (s < a || s === void 0 && a >= a) && (s = a);
else {
let a = -1;
for (let i of e)
(i = r(i, ++a, e)) != null && (s < i || s === void 0 && i >= i) && (s = i);
}
return s;
}
function Hr(e) {
return e;
}
var Qe = 1, Be = 2, We = 3, Ne = 4, wt = 1e-6;
function Ur(e) {
return "translate(" + e + ",0)";
}
function Wr(e) {
return "translate(0," + e + ")";
}
function Yr(e) {
return (r) => +e(r);
}
function Kr(e, r) {
return r = Math.max(0, e.bandwidth() - r * 2) / 2, e.round() && (r = Math.round(r)), (s) => +e(s) + r;
}
function Xr() {
return !this.__axis;
}
function Mt(e, r) {
var s = [], a = null, i = null, l = 6, c = 6, d = 3, u = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, h = e === Qe || e === Ne ? -1 : 1, o = e === Ne || e === Be ? "x" : "y", y = e === Qe || e === We ? Ur : Wr;
function p(A) {
var D = a ?? (r.ticks ? r.ticks.apply(r, s) : r.domain()), g = i ?? (r.tickFormat ? r.tickFormat.apply(r, s) : Hr), v = Math.max(l, 0) + d, m = r.range(), f = +m[0] + u, T = +m[m.length - 1] + u, w = (r.bandwidth ? Kr : Yr)(r.copy(), u), N = A.selection ? A.selection() : A, R = N.selectAll(".domain").data([null]), I = N.selectAll(".tick").data(D, r).order(), q = I.exit(), $ = I.enter().append("g").attr("class", "tick"), L = I.select("line"), B = I.select("text");
R = R.merge(R.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), I = I.merge($), L = L.merge($.append("line").attr("stroke", "currentColor").attr(o + "2", h * l)), B = B.merge($.append("text").attr("fill", "currentColor").attr(o, h * v).attr("dy", e === Qe ? "0em" : e === We ? "0.71em" : "0.32em")), A !== N && (R = R.transition(A), I = I.transition(A), L = L.transition(A), B = B.transition(A), q = q.transition(A).attr("opacity", wt).attr("transform", function(S) {
return isFinite(S = w(S)) ? y(S + u) : this.getAttribute("transform");
}), $.attr("opacity", wt).attr("transform", function(S) {
var E = this.parentNode.__axis;
return y((E && isFinite(E = E(S)) ? E : w(S)) + u);
})), q.remove(), R.attr("d", e === Ne || e === Be ? c ? "M" + h * c + "," + f + "H" + u + "V" + T + "H" + h * c : "M" + u + "," + f + "V" + T : c ? "M" + f + "," + h * c + "V" + u + "H" + T + "V" + h * c : "M" + f + "," + u + "H" + T), I.attr("opacity", 1).attr("transform", function(S) {
return y(w(S) + u);
}), L.attr(o + "2", h * l), B.attr(o, h * v).text(g), N.filter(Xr).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === Be ? "start" : e === Ne ? "end" : "middle"), N.each(function() {
this.__axis = w;
});
}
return p.scale = function(A) {
return arguments.length ? (r = A, p) : r;
}, p.ticks = function() {
return s = Array.from(arguments), p;
}, p.tickArguments = function(A) {
return arguments.length ? (s = A == null ? [] : Array.from(A), p) : s.slice();
}, p.tickValues = function(A) {
return arguments.length ? (a = A == null ? null : Array.from(A), p) : a && a.slice();
}, p.tickFormat = function(A) {
return arguments.length ? (i = A, p) : i;
}, p.tickSize = function(A) {
return arguments.length ? (l = c = +A, p) : l;
}, p.tickSizeInner = function(A) {
return arguments.length ? (l = +A, p) : l;
}, p.tickSizeOuter = function(A) {
return arguments.length ? (c = +A, p) : c;
}, p.tickPadding = function(A) {
return arguments.length ? (d = +A, p) : d;
}, p.offset = function(A) {
return arguments.length ? (u = +A, p) : u;
}, p;
}
function Nt(e) {
return Mt(We, e);
}
function St(e) {
return Mt(Ne, e);
}
var Ye = "http://www.w3.org/1999/xhtml";
const kt = {
svg: "http://www.w3.org/2000/svg",
xhtml: Ye,
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
};
function Qt(e) {
var r = e += "", s = r.indexOf(":");
return s >= 0 && (r = e.slice(0, s)) !== "xmlns" && (e = e.slice(s + 1)), kt.hasOwnProperty(r) ? { space: kt[r], local: e } : e;
}
function Zr(e) {
return function() {
var r = this.ownerDocument, s = this.namespaceURI;
return s === Ye && r.documentElement.namespaceURI === Ye ? r.createElement(e) : r.createElementNS(s, e);
};
}
function es(e) {
return function() {
return this.ownerDocument.createElementNS(e.space, e.local);
};
}
function Bt(e) {
var r = Qt(e);
return (r.local ? es : Zr)(r);
}
function ts() {
}
function zt(e) {
return e == null ? ts : function() {
return this.querySelector(e);
};
}
function rs(e) {
typeof e != "function" && (e = zt(e));
for (var r = this._groups, s = r.length, a = new Array(s), i = 0; i < s; ++i)
for (var l = r[i], c = l.length, d = a[i] = new Array(c), u, h, o = 0; o < c; ++o)
(u = l[o]) && (h = e.call(u, u.__data__, o, l)) && ("__data__" in u && (h.__data__ = u.__data__), d[o] = h);
return new te(a, this._parents);
}
function ss(e) {
return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function ns() {
return [];
}
function as(e) {
return e == null ? ns : function() {
return this.querySelectorAll(e);
};
}
function is(e) {
return function() {
return ss(e.apply(this, arguments));
};
}
function ls(e) {
typeof e == "function" ? e = is(e) : e = as(e);
for (var r = this._groups, s = r.length, a = [], i = [], l = 0; l < s; ++l)
for (var c = r[l], d = c.length, u, h = 0; h < d; ++h)
(u = c[h]) && (a.push(e.call(u, u.__data__, h, c)), i.push(u));
return new te(a, i);
}
function os(e) {
return function() {
return this.matches(e);
};
}
function jt(e) {
return function(r) {
return r.matches(e);
};
}
var cs = Array.prototype.find;
function ds(e) {
return function() {
return cs.call(this.children, e);
};
}
function us() {
return this.firstElementChild;
}
function ms(e) {
return this.select(e == null ? us : ds(typeof e == "function" ? e : jt(e)));
}
var hs = Array.prototype.filter;
function fs() {
return Array.from(this.children);
}
function ps(e) {
return function() {
return hs.call(this.children, e);
};
}
function gs(e) {
return this.selectAll(e == null ? fs : ps(typeof e == "function" ? e : jt(e)));
}
function bs(e) {
typeof e != "function" && (e = os(e));
for (var r = this._groups, s = r.length, a = new Array(s), i = 0; i < s; ++i)
for (var l = r[i], c = l.length, d = a[i] = [], u, h = 0; h < c; ++h)
(u = l[h]) && e.call(u, u.__data__, h, l) && d.push(u);
return new te(a, this._parents);
}
function Gt(e) {
return new Array(e.length);
}
function ys() {
return new te(this._enter || this._groups.map(Gt), this._parents);
}
function Oe(e, r) {
this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = r;
}
Oe.prototype = {
constructor: Oe,
appendChild: function(e) {
return this._parent.insertBefore(e, this._next);
},
insertBefore: function(e, r) {
return this._parent.insertBefore(e, r);
},
querySelector: function(e) {
return this._parent.querySelector(e);
},
querySelectorAll: function(e) {
return this._parent.querySelectorAll(e);
}
};
function xs(e) {
return function() {
return e;
};
}
function vs(e, r, s, a, i, l) {
for (var c = 0, d, u = r.length, h = l.length; c < h; ++c)
(d = r[c]) ? (d.__data__ = l[c], a[c] = d) : s[c] = new Oe(e, l[c]);
for (; c < u; ++c)
(d = r[c]) && (i[c] = d);
}
function ws(e, r, s, a, i, l, c) {
var d, u, h = /* @__PURE__ */ new Map(), o = r.length, y = l.length, p = new Array(o), A;
for (d = 0; d < o; ++d)
(u = r[d]) && (p[d] = A = c.call(u, u.__data__, d, r) + "", h.has(A) ? i[d] = u : h.set(A, u));
for (d = 0; d < y; ++d)
A = c.call(e, l[d], d, l) + "", (u = h.get(A)) ? (a[d] = u, u.__data__ = l[d], h.delete(A)) : s[d] = new Oe(e, l[d]);
for (d = 0; d < o; ++d)
(u = r[d]) && h.get(p[d]) === u && (i[d] = u);
}
function Ns(e) {
return e.__data__;
}
function Ss(e, r) {
if (!arguments.length) return Array.from(this, Ns);
var s = r ? ws : vs, a = this._parents, i = this._groups;
typeof e != "function" && (e = xs(e));
for (var l = i.length, c = new Array(l), d = new Array(l), u = new Array(l), h = 0; h < l; ++h) {
var o = a[h], y = i[h], p = y.length, A = ks(e.call(o, o && o.__data__, h, a)), D = A.length, g = d[h] = new Array(D), v = c[h] = new Array(D), m = u[h] = new Array(p);
s(o, y, g, v, m, A, r);
for (var f = 0, T = 0, w, N; f < D; ++f)
if (w = g[f]) {
for (f >= T && (T = f + 1); !(N = v[T]) && ++T < D; ) ;
w._next = N || null;
}
}
return c = new te(c, a), c._enter = d, c._exit = u, c;
}
function ks(e) {
return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function As() {
return new te(this._exit || this._groups.map(Gt), this._parents);
}
function Ds(e, r, s) {
var a = this.enter(), i = this, l = this.exit();
return typeof e == "function" ? (a = e(a), a && (a = a.selection())) : a = a.append(e + ""), r != null && (i = r(i), i && (i = i.selection())), s == null ? l.remove() : s(l), a && i ? a.merge(i).order() : i;
}
function Ts(e) {
for (var r = e.selection ? e.selection() : e, s = this._groups, a = r._groups, i = s.length, l = a.length, c = Math.min(i, l), d = new Array(i), u = 0; u < c; ++u)
for (var h = s[u], o = a[u], y = h.length, p = d[u] = new Array(y), A, D = 0; D < y; ++D)
(A = h[D] || o[D]) && (p[D] = A);
for (; u < i; ++u)
d[u] = s[u];
return new te(d, this._parents);
}
function Cs() {
for (var e = this._groups, r = -1, s = e.length; ++r < s; )
for (var a = e[r], i = a.length - 1, l = a[i], c; --i >= 0; )
(c = a[i]) && (l && c.compareDocumentPosition(l) ^ 4 && l.parentNode.insertBefore(c, l), l = c);
return this;
}
function _s(e) {
e || (e = Fs);
function r(y, p) {
return y && p ? e(y.__data__, p.__data__) : !y - !p;
}
for (var s = this._groups, a = s.length, i = new Array(a), l = 0; l < a; ++l) {
for (var c = s[l], d = c.length, u = i[l] = new Array(d), h, o = 0; o < d; ++o)
(h = c[o]) && (u[o] = h);
u.sort(r);
}
return new te(i, this._parents).order();
}
function Fs(e, r) {
return e < r ? -1 : e > r ? 1 : e >= r ? 0 : NaN;
}
function Es() {
var e = arguments[0];
return arguments[0] = this, e.apply(null, arguments), this;
}
function Rs() {
return Array.from(this);
}
function Os() {
for (var e = this._groups, r = 0, s = e.length; r < s; ++r)
for (var a = e[r], i = 0, l = a.length; i < l; ++i) {
var c = a[i];
if (c) return c;
}
return null;
}
function $s() {
let e = 0;
for (const r of this) ++e;
return e;
}
function Ls() {
return !this.node();
}
function Is(e) {
for (var r = this._groups, s = 0, a = r.length; s < a; ++s)
for (var i = r[s], l = 0, c = i.length, d; l < c; ++l)
(d = i[l]) && e.call(d, d.__data__, l, i);
return this;
}
function Ps(e) {
return function() {
this.removeAttribute(e);
};
}
function Vs(e) {
return function() {
this.removeAttributeNS(e.space, e.local);
};
}
function qs(e, r) {
return function() {
this.setAttribute(e, r);
};
}
function Ms(e, r) {
return function() {
this.setAttributeNS(e.space, e.local, r);
};
}
function Qs(e, r) {
return function() {
var s = r.apply(this, arguments);
s == null ? this.removeAttribute(e) : this.setAttribute(e, s);
};
}
function Bs(e, r) {
return function() {
var s = r.apply(this, arguments);
s == null ? this.removeAttributeNS(e.space, e.local) : this.setAttributeNS(e.space, e.local, s);
};
}
function zs(e, r) {
var s = Qt(e);
if (arguments.length < 2) {
var a = this.node();
return s.local ? a.getAttributeNS(s.space, s.local) : a.getAttribute(s);
}
return this.each((r == null ? s.local ? Vs : Ps : typeof r == "function" ? s.local ? Bs : Qs : s.local ? Ms : qs)(s, r));
}
function Jt(e) {
return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function js(e) {
return function() {
this.style.removeProperty(e);
};
}
function Gs(e, r, s) {
return function() {
this.style.setProperty(e, r, s);
};
}
function Js(e, r, s) {
return function() {
var a = r.apply(this, arguments);
a == null ? this.style.removeProperty(e) : this.style.setProperty(e, a, s);
};
}
function Hs(e, r, s) {
return arguments.length > 1 ? this.each((r == null ? js : typeof r == "function" ? Js : Gs)(e, r, s ?? "")) : Us(this.node(), e);
}
function Us(e, r) {
return e.style.getPropertyValue(r) || Jt(e).getComputedStyle(e, null).getPropertyValue(r);
}
function Ws(e) {
return function() {
delete this[e];
};
}
function Ys(e, r) {
return function() {
this[e] = r;
};
}
function Ks(e, r) {
return function() {
var s = r.apply(this, arguments);
s == null ? delete this[e] : this[e] = s;
};
}
function Xs(e, r) {
return arguments.length > 1 ? this.each((r == null ? Ws : typeof r == "function" ? Ks : Ys)(e, r)) : this.node()[e];
}
function Ht(e) {
return e.trim().split(/^|\s+/);
}
function et(e) {
return e.classList || new Ut(e);
}
function Ut(e) {
this._node = e, this._names = Ht(e.getAttribute("class") || "");
}
Ut.prototype = {
add: function(e) {
var r = this._names.indexOf(e);
r < 0 && (this._names.push(e), this._node.setAttribute("class", this._names.join(" ")));
},
remove: function(e) {
var r = this._names.indexOf(e);
r >= 0 && (this._names.splice(r, 1), this._node.setAttribute("class", this._names.join(" ")));
},
contains: function(e) {
return this._names.indexOf(e) >= 0;
}
};
function Wt(e, r) {
for (var s = et(e), a = -1, i = r.length; ++a < i; ) s.add(r[a]);
}
function Yt(e, r) {
for (var s = et(e), a = -1, i = r.length; ++a < i; ) s.remove(r[a]);
}
function Zs(e) {
return function() {
Wt(this, e);
};
}
function en(e) {
return function() {
Yt(this, e);
};
}
function tn(e, r) {
return function() {
(r.apply(this, arguments) ? Wt : Yt)(this, e);
};
}
function rn(e, r) {
var s = Ht(e + "");
if (arguments.length < 2) {
for (var a = et(this.node()), i = -1, l = s.length; ++i < l; ) if (!a.contains(s[i])) return !1;
return !0;
}
return this.each((typeof r == "function" ? tn : r ? Zs : en)(s, r));
}
function sn() {
this.textContent = "";
}
function nn(e) {
return function() {
this.textContent = e;
};
}
function an(e) {
return function() {
var r = e.apply(this, arguments);
this.textContent = r ?? "";
};
}
function ln(e) {
return arguments.length ? this.each(e == null ? sn : (typeof e == "function" ? an : nn)(e)) : this.node().textContent;
}
function on() {
this.innerHTML = "";
}
function cn(e) {
return function() {
this.innerHTML = e;
};
}
function dn(e) {
return function() {
var r = e.apply(this, arguments);
this.innerHTML = r ?? "";
};
}
function un(e) {
return arguments.length ? this.each(e == null ? on : (typeof e == "function" ? dn : cn)(e)) : this.node().innerHTML;
}
function mn() {
this.nextSibling && this.parentNode.appendChild(this);
}
function hn() {
return this.each(mn);
}
function fn() {
this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function pn() {
return this.each(fn);
}
function gn(e) {
var r = typeof e == "function" ? e : Bt(e);
return this.select(function() {
return this.appendChild(r.apply(this, arguments));
});
}
function bn() {
return null;
}
function yn(e, r) {
var s = typeof e == "function" ? e : Bt(e), a = r == null ? bn : typeof r == "function" ? r : zt(r);
return this.select(function() {
return this.insertBefore(s.apply(this, arguments), a.apply(this, arguments) || null);
});
}
function xn() {
var e = this.parentNode;
e && e.removeChild(this);
}
function vn() {
return this.each(xn);
}
function wn() {
var e = this.cloneNode(!1), r = this.parentNode;
return r ? r.insertBefore(e, this.nextSibling) : e;
}
function Nn() {
var e = this.cloneNode(!0), r = this.parentNode;
return r ? r.insertBefore(e, this.nextSibling) : e;
}
function Sn(e) {
return this.select(e ? Nn : wn);
}
function kn(e) {
return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function An(e) {
return function(r) {
e.call(this, r, this.__data__);
};
}
function Dn(e) {
return e.trim().split(/^|\s+/).map(function(r) {
var s = "", a = r.indexOf(".");
return a >= 0 && (s = r.slice(a + 1), r = r.slice(0, a)), { type: r, name: s };
});
}
function Tn(e) {
return function() {
var r = this.__on;
if (r) {
for (var s = 0, a = -1, i = r.length, l; s < i; ++s)
l = r[s], (!e.type || l.type === e.type) && l.name === e.name ? this.removeEventListener(l.type, l.listener, l.options) : r[++a] = l;
++a ? r.length = a : delete this.__on;
}
};
}
function Cn(e, r, s) {
return function() {
var a = this.__on, i, l = An(r);
if (a) {
for (var c = 0, d = a.length; c < d; ++c)
if ((i = a[c]).type === e.type && i.name === e.name) {
this.removeEventListener(i.type, i.listener, i.options), this.addEventListener(i.type, i.listener = l, i.options = s), i.value = r;
return;
}
}
this.addEventListener(e.type, l, s), i = { type: e.type, name: e.name, value: r, listener: l, options: s }, a ? a.push(i) : this.__on = [i];
};
}
function _n(e, r, s) {
var a = Dn(e + ""), i, l = a.length, c;
if (arguments.length < 2) {
var d = this.node().__on;
if (d) {
for (var u = 0, h = d.length, o; u < h; ++u)
for (i = 0, o = d[u]; i < l; ++i)
if ((c = a[i]).type === o.type && c.name === o.name)
return o.value;
}
return;
}
for (d = r ? Cn : Tn, i = 0; i < l; ++i) this.each(d(a[i], r, s));
return this;
}
function Kt(e, r, s) {
var a = Jt(e), i = a.CustomEvent;
typeof i == "function" ? i = new i(r, s) : (i = a.document.createEvent("Event"), s ? (i.initEvent(r, s.bubbles, s.cancelable), i.detail = s.detail) : i.initEvent(r, !1, !1)), e.dispatchEvent(i);
}
function Fn(e, r) {
return function() {
return Kt(this, e, r);
};
}
function En(e, r) {
return function() {
return Kt(this, e, r.apply(this, arguments));
};
}
function Rn(e, r) {
return this.each((typeof r == "function" ? En : Fn)(e, r));
}
function* On() {
for (var e = this._groups, r = 0, s = e.length; r < s; ++r)
for (var a = e[r], i = 0, l = a.length, c; i < l; ++i)
(c = a[i]) && (yield c);
}
var $n = [null];
function te(e, r) {
this._groups = e, this._parents = r;
}
function Ln() {
return this;
}
te.prototype = {
constructor: te,
select: rs,
selectAll: ls,
selectChild: ms,
selectChildren: gs,
filter: bs,
data: Ss,
enter: ys,
exit: As,
join: Ds,
merge: Ts,
selection: Ln,
order: Cs,
sort: _s,
call: Es,
nodes: Rs,
node: Os,
size: $s,
empty: Ls,
each: Is,
attr: zs,
style: Hs,
property: Xs,
classed: rn,
text: ln,
html: un,
raise: hn,
lower: pn,
append: gn,
insert: yn,
remove: vn,
clone: Sn,
datum: kn,
on: _n,
dispatch: Rn,
[Symbol.iterator]: On
};
function ve(e) {
return typeof e == "string" ? new te([[document.querySelector(e)]], [document.documentElement]) : new te([[e]], $n);
}
function At(e) {
return function(r) {
return r < 0 ? -Math.pow(-r, e) : Math.pow(r, e);
};
}
function In(e) {
return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function Pn(e) {
return e < 0 ? -e * e : e * e;
}
function Vn(e) {
var r = e(Te, Te), s = 1;
function a() {
return s === 1 ? e(Te, Te) : s === 0.5 ? e(In, Pn) : e(At(s), At(1 / s));
}
return r.exponent = function(i) {
return arguments.length ? (s = +i, a()) : s;
}, Fr(r);
}
function Xt() {
var e = Vn(Tr());
return e.copy = function() {
return Cr(e, Xt()).exponent(e.exponent());
}, _r.apply(e, arguments), e;
}
function qn() {
return Xt.apply(null, arguments).exponent(0.5);
}
function Mn({
data: e,
chartConfig: r,
displayConfig: s = {},
queryObject: a,
height: i = "100%"
}) {
const l = ee(null), c = ee(null), [, d] = M(null), [u, h] = M({ width: 0, height: 0 }), [o, y] = M(!1), { getFieldLabel: p } = Ze(), A = {
showLegend: (s == null ? void 0 : s.showLegend) ?? !0,
showGrid: (s == null ? void 0 : s.showGrid) ?? !0,
showTooltip: (s == null ? void 0 : s.showTooltip) ?? !0,
minBubbleSize: (s == null ? void 0 : s.minBubbleSize) ?? 5,
maxBubbleSize: (s == null ? void 0 : s.maxBubbleSize) ?? 50,
bubbleOpacity: (s == null ? void 0 : s.bubbleOpacity) ?? 0.7
};
return lr(() => {
let g = 0;
const v = 10;
let m, f;
const T = () => {
if (c.current) {
const { width: N, height: R } = c.current.getBoundingClientRect();
if (console.log("BubbleChart: Dimension measurement attempt", g + 1, { width: N, height: R }), N > 0 && R > 0)
return h({ width: N, height: R }), y(!0), console.log("BubbleChart: Dimensions successfully measured:", { width: N, height: R }), !0;
}
return !1;
};
if (!T() && g < v) {
const N = () => {
!T() && g < v && (g++, f = setTimeout(() => {
m = requestAnimationFrame(N);
}, 50 * g));
};
m = requestAnimationFrame(N);
}
return () => {
m && cancelAnimationFrame(m), f && clearTimeout(f);
};
}, []), K(() => {
let g = null;
const v = () => {
if (c.current) {
const { width: m, height: f } = c.current.getBoundingClientRect();
m > 0 && f > 0 && (h({ width: m, height: f }), o || (y(!0), console.log("BubbleChart: Dimensions ready via ResizeObserver:", { width: m, height: f })));
}
};
return c.current && (g = new ResizeObserver((m) => {
for (const f of m) {
const { width: T, height: w } = f.contentRect;
T > 0 && w > 0 && (h({ width: T, height: w }), o || (y(!0), console.log("BubbleChart: Dimensions ready via ResizeObserver:", { width: T, height: w })));
}
}), g.observe(c.current), v()), window.addEventListener("resize", v), () => {
g && g.disconnect(), window.removeEventListener("resize", v);
};
}, [o]), K(() => {
if (!e || e.length === 0 || !l.current || !o || u.width === 0) {
console.log("BubbleChart: Skipping render - conditions not met:", {
hasData: e && e.length > 0,
hasSvgRef: !!l.current,
dimensionsReady: o,
dimensions: u
});
return;
}
if (ve(l.current).selectAll("*").remove(), console.log("BubbleChart: chartConfig:", r), console.log("BubbleChart: data:", e), console.log("BubbleChart: dimensions:", u), !(r != null && r.xAxis) || !(r != null && r.yAxis) || !(r != null && r.series)) {
console.log("BubbleChart: Missing xAxis, yAxis, or series in chartConfig");
return;
}
const g = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, v = Array.isArray(r.yAxis) ? r.yAxis[0] : r.yAxis, m = Array.isArray(r.series) ? r.series[0] : r.series, f = Array.isArray(r.sizeField) ? r.sizeField[0] : r.sizeField || v, T = Array.isArray(r.colorField) ? r.colorField[0] : r.colorField;
if (console.log("BubbleChart: fields extracted:", {
xAxisField: g,
yAxisField: v,
seriesField: m,
sizeFieldName: f,
colorFieldName: T
}), !g || !v || !m || !f) {
console.log("BubbleChart: Missing required fields");
return;
}
const w = Er(a, g), N = e.map((b) => {
const P = Rr(b[g], w) || b[g], j = typeof b[v] == "string" ? parseFloat(b[v]) : b[v] || 0, W = typeof b[f] == "string" ? parseFloat(b[f]) : b[f] || 0, X = b[m];
return {
x: typeof P == "string" ? parseFloat(P) || 0 : P,
y: j,
size: Math.abs(W),
// Ensure positive size
color: T ? b[T] : X,
series: X,
label: `${X || "Unknown"}`
};
}).filter((b) => b.size > 0);
if (N.length === 0) return;
const R = {
...bt,
left: bt.left + 30,
// Add extra 30px left margin for Y-axis label
bottom: A.showLegend && T ? 100 : 40
// Add extra space for legend
}, I = u.width - R.left - R.right, q = u.height - R.top - R.bottom, $ = ve(l.current).attr("width", u.width).attr("height", u.height), L = $.append("g").attr("transform", `translate(${R.left},${R.top})`), B = yt().domain(vt(N, (b) => b.x)).range([0, I]).nice(), S = yt().domain(vt(N, (b) => b.y)).range([q, 0]).nice(), E = qn().domain([0, Jr(N, (b) => b.size)]).range([A.minBubbleSize, A.maxBubbleSize]);
let x, Q = !1, _ = [];
if (T && N.length > 0) {
const b = N.map((P) => {
const j = P.color;
return typeof j == "string" ? parseFloat(j) : j;
}).filter((P) => !isNaN(P));
if (Q = b.length === N.length && b.every((P) => typeof P == "number"), Q) {
const P = Math.min(...b), j = Math.max(...b);
x = Or().domain([P, j]).range(qe);
} else
_ = [...new Set(N.map((P) => String(P.color)))], x = xt().domain(_).range(Me);
} else
x = xt().domain(["default"]).range([Me[0]]);
A.showGrid && (L.append("g").attr("class", "grid").attr("transform", `translate(0,${q})`).call(
Nt(B).tickSize(-q).tickFormat(() => "")
).style("stroke-dasharray", "3,3").style("opacity", 0.3), L.append("g").attr("class", "grid").call(
St(S).tickSize(-I).tickFormat(() => "")
).style("stroke-dasharray", "3,3").style("opacity", 0.3)), L.append("g").attr("transform", `translate(0,${q})`).call(Nt(B)).append("text").attr("x", I / 2).attr("y", 35).attr("fill", "currentColor").style("text-anchor", "middle").style("font-size", "12px").text(p(g)), L.append("g").call(St(S)).append("text").attr("transform", "rotate(-90)").attr("y", -35).attr("x", -q / 2).attr("fill", "currentColor").style("text-anchor", "middle").style("font-size", "12px").text(p(v));
const z = ve("body").append("div").attr("class", "bubble-chart-tooltip").style("position", "absolute").style("padding", "8px").style("background", "rgba(0, 0, 0, 0.8)").style("color", "white").style("border-radius", "4px").style("font-size", "12px").style("pointer-events", "none").style("opacity", 0).style("z-index", 1e3), k = L.selectAll(".bubble").data(N).enter().append("circle").attr("class", "bubble").attr("cx", (b) => B(b.x)).attr("cy", (b) => S(b.y)).attr("r", (b) => E(b.size)).style("fill", (b) => T && b.color !== void 0 ? x(Q ? b.color : String(b.color)) : Me[0]).style("opacity", A.bubbleOpacity).style("stroke", "#fff").style("stroke-width", 1).style("cursor", "pointer");
if (A.showTooltip && k.on("mouseover", function(b, P) {
ve(this).transition().duration(200).style("opacity", 1).attr("r", E(P.size) * 1.1);
const j = [
`<strong>${P.series || "Unknown"}</strong>`,
`${p(g)}: ${P.x}`,
`${p(v)}: ${P.y}`,
`${p(f)}: ${P.size}`,
T && P.color ? `${p(T)}: ${P.color}` : ""
].filter(Boolean).join("<br>");
z.html(j).style("left", b.pageX + 10 + "px").style("top", b.pageY - 10 + "px").transition().duration(200).style("opacity", 1), d(P.label);
}).on("mousemove", function(b) {
z.style("left", b.pageX + 10 + "px").style("top", b.pageY - 10 + "px");
}).on("mouseout", function(b, P) {
ve(this).transition().duration(200).style("opacity", A.bubbleOpacity).attr("r", E(P.size)), z.transition().duration(200).style("opacity", 0), d(null);
}), A.showLegend && T)
if (Q) {
const j = Math.min(...N.map((F) => F.color)), W = Math.max(...N.map((F) => F.color)), X = L.append("g").attr("class", "color-legend").attr("transform", `translate(${I / 2 - 200 / 2}, ${q + 60})`), V = $.append("defs").append("linearGradient").attr("id", "color-scale-gradient").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%");
qe.forEach((F, O) => {
V.append("stop").attr("offset", `${O / (qe.length - 1) * 100}%`).attr("stop-color", F);
}), X.append("rect").attr("width", 200).attr("height", 20).style("fill", "url(#color-scale-gradient)").style("stroke", "#ccc").style("stroke-width", 1), X.append("text").attr("x", 0).attr("y", 35).attr("text-anchor", "start").style("font-size", "11px").style("fill", "currentColor").text(j.toFixed(2)), X.append("text").attr("x", 200).attr("y", 35).attr("text-anchor", "end").style("font-size", "11px").style("fill", "currentColor").text(W.toFixed(2)), X.append("text").attr("x", 200 / 2).attr("y", -5).attr("text-anchor", "middle").style("font-size", "12px").style("font-weight", "bold").style("fill", "currentColor").text(p(T));
} else {
const b = _;
if (b.length > 0) {
const j = L.append("g").attr("class", "legend").attr("transform", `translate(${I / 2 - b.length * 80 / 2}, ${q + 60})`).selectAll(".legend-item").data(b).enter().append("g").attr("class", "legend-item").attr("transform", (W, X) => `translate(${X * 80}, 0)`).style("cursor", "pointer");
j.append("circle").attr("cx", 5).attr("cy", 5).attr("r", 5).style("fill", (W) => x(W)).style("opacity", A.bubbleOpacity), j.append("text").attr("x", 15).attr("y", 5).attr("dy", ".35em").style("font-size", "11px").style("fill", "currentColor").text((W) => String(W)), j.on("mouseover", function(W, X) {
k.transition().duration(200).style("opacity", (C) => T && String(C.color) === X ? 1 : 0.2);
}).on("mouseout", function() {
k.transition().duration(200).style("opacity", A.bubbleOpacity);
});
}
}
return () => {
z.remove();
};
}, [e, r, s, a, u, o, A.showLegend, A.showGrid, A.showTooltip, A.minBubbleSize, A.maxBubbleSize, A.bubbleOpacity]), !e || e.length === 0 ? /* @__PURE__ */ t("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: i }, children: /* @__PURE__ */ n("div", { className: "text-center", children: [
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ t("div", { className: "text-xs", children: "No data points to display in bubble chart" })
] }) }) : (r == null ? void 0 : r.xAxis) && (r == null ? void 0 : r.yAxis) && (r == null ? void 0 : r.series) ? /* @__PURE__ */ t($r, { height: i, children: /* @__PURE__ */ n("div", { ref: c, className: "w-full h-full relative", children: [
/* @__PURE__ */ t("svg", { ref: l, className: "w-full h-full" }),
!o && /* @__PURE__ */ t("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ t("div", { className: "text-gray-400 text-sm", children: "Measuring chart dimensions..." }) })
] }) }) : /* @__PURE__ */ t("div", { className: "flex items-center justify-center w-full text-yellow-600", style: { height: i }, children: /* @__PURE__ */ n("div", { className: "text-center", children: [
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "Configuration Required" }),
/* @__PURE__ */ t("div", { className: "text-xs", children: "Bubble chart requires xAxis, yAxis, series, and sizeField dimensions" }),
/* @__PURE__ */ t("div", { className: "text-xs mt-1", children: "Optional: colorField for bubble coloring" })
] }) });
}
const tt = $t(({
query: e,
chartType: r,
chartConfig: s,
displayConfig: a,
height: i = 300,
title: l,
onDebugDataReady: c
}, d) => {
const [u, h] = M(0), o = ee(c);
K(() => {
o.current = c;
}, [c]);
const y = ke(() => {
try {
return {
...JSON.parse(e),
__refresh_counter: u
};
} catch (f) {
return console.error("AnalyticsPortlet: Invalid query JSON:", f), null;
}
}, [e, u]), { resultSet: p, isLoading: A, error: D } = or(y, {
skip: !y,
resetResultSetOnChange: !0
});
if (Lt(d, () => ({
refresh: () => {
h((f) => f + 1);
}
}), []), K(() => {
if (o.current && s && y && p && !D) {
const T = (() => {
switch (r) {
case "pie":
case "table":
return p.tablePivot();
default:
return p.rawData();
}
})();
T && o.current({
chartConfig: s || {},
displayConfig: a || {},
queryObject: y,
data: T,
chartType: r
});
}
}, [s, y, p, r, D]), !s)
return /* @__PURE__ */ t("div", { className: "flex items-center justify-center w-full text-red-500", style: { height: i }, children: /* @__PURE__ */ n("div", { className: "text-center", children: [
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ t("div", { className: "text-xs", children: "chartConfig is required but not provided" })
] }) });
if (A || y && !p && !D)
return /* @__PURE__ */ t("div", { className: "flex items-center justify-center w-full", style: { height: i }, children: /* @__PURE__ */ t("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500" }) });
if (D)
return /* @__PURE__ */ n("div", { className: "p-4 border border-red-300 bg-red-50 rounded", style: { height: i }, children: [
/* @__PURE__ */ t("div", { className: "mb-2", children: /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
/* @__PURE__ */ t("span", { className: "text-red-600 font-medium text-sm", children: "⚠️ Query Error" }),
/* @__PURE__ */ t(
"button",
{
onClick: () => h((f) => f + 1),
className: "px-2 py-1 bg-blue-500 text-white rounded text-xs hover:bg-blue-600",
children: "Retry"
}
)
] }) }),
/* @__PURE__ */ t("div", { className: "mb-3", children: /* @__PURE__ */ t("div", { className: "text-xs text-red-700 bg-white p-2 rounded border", children: D.message || D.toString() }) }),
/* @__PURE__ */ n("div", { className: "space-y-2 text-xs", children: [
/* @__PURE__ */ n("details", { children: [
/* @__PURE__ */ t("summary", { className: "cursor-pointer text-gray-700 font-medium", children: "Original Query" }),
/* @__PURE__ */ t("pre", { className: "mt-1 bg-blue-50 p-2 rounded text-xs overflow-auto max-h-20", children: e })
] }),
/* @__PURE__ */ n("details", { children: [
/* @__PURE__ */ t("summary", { className: "cursor-pointer text-gray-700 font-medium", children: "Chart Config" }),
/* @__PURE__ */ t("pre", { className: "mt-1 bg-purple-50 p-2 rounded text-xs overflow-auto max-h-20", children: JSON.stringify({
chartType: r,
chartConfig: s,
displayConfig: a
}, null, 2) })
] })
] })
] });
if (!p || !y)
return /* @__PURE__ */ t("div", { className: "flex items-center justify-center w-full text-gray-500", style: { height: i }, children: /* @__PURE__ */ n("div", { className: "text-center", children: [
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ t("div", { className: "text-xs", children: "Invalid query or no results" })
] }) });
const v = (() => {
switch (r) {
case "pie":
case "table":
return p.tablePivot();
default:
return p.rawData();
}
})();
return /* @__PURE__ */ t(
Gr,
{
portletTitle: l,
portletConfig: {
chartType: r,
chartConfig: s,
displayConfig: a,
height: i
},
cubeQuery: e,
children: /* @__PURE__ */ t("div", { className: "w-full h-full flex flex-col flex-1", style: { minHeight: "200px" }, children: (() => {
try {
const f = i;
switch (r) {
case "bar":
return /* @__PURE__ */ t(
Br,
{
data: v,
chartConfig: s,
displayConfig: a,
queryObject: y,
height: f
}
);
case "line":
return /* @__PURE__ */ t(
Qr,
{
data: v,
chartConfig: s,
displayConfig: a,
queryObject: y,
height: f
}
);
case "area":
return /* @__PURE__ */ t(
Mr,
{
data: v,
chartConfig: s,
displayConfig: a,
queryObject: y,
height: f
}
);
case "pie":
return /* @__PURE__ */ t(
qr,
{
data: v,
chartConfig: s,
displayConfig: a,
queryObject: y,
height: f
}
);
case "scatter":
return /* @__PURE__ */ t(
Vr,
{
data: v,
chartConfig: s,
displayConfig: a,
queryObject: y,
height: f
}
);
case "radar":
return /* @__PURE__ */ t(
Pr,
{
data: v,
chartConfig: s,
displayConfig: a,
queryObject: y,
height: f
}
);
case "radialBar":
return /* @__PURE__ */ t(
Ir,
{
data: v,
chartConfig: s,
displayConfig: a,
queryObject: y,
height: f
}
);
case "treemap":
return /* @__PURE__ */ t(
Lr,
{
data: v,
chartConfig: s,
displayConfig: a,
queryObject: y,
height: f
}
);
case "bubble":
return /* @__PURE__ */ t(
Mn,
{
data: v,
chartConfig: s,
displayConfig: a,
queryObject: y,
height: f
}
);
case "table":
return /* @__PURE__ */ t(
qt,
{
data: v,
chartConfig: s,
displayConfig: a,
queryObject: y,
height: f
}
);
default:
return /* @__PURE__ */ t("div", { className: "flex items-center justify-center w-full", style: { height: i }, children: /* @__PURE__ */ n("div", { className: "text-center text-gray-500", children: [
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "Unsupported chart type" }),
/* @__PURE__ */ t("div", { className: "text-xs", children: r })
] }) });
}
} catch (f) {
return console.error("Chart rendering error:", f), /* @__PURE__ */ t("div", { className: "flex items-center justify-center w-full text-red-500 p-4", style: { height: i }, children: /* @__PURE__ */ n("div", { className: "text-center", children: [
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "Error rendering chart" }),
/* @__PURE__ */ t("div", { className: "text-xs", children: f instanceof Error ? f.message : "Unknown error" })
] }) });
}
})() })
}
);
});
tt.displayName = "AnalyticsPortlet";
const rt = ({
isOpen: e,
onClose: r,
title: s,
size: a = "md",
closeOnBackdropClick: i = !0,
closeOnEscape: l = !0,
showCloseButton: c = !0,
children: d,
footer: u,
noPadding: h = !1
}) => {
const o = H((p) => {
p.key === "Escape" && l && r();
}, [l, r]);
return K(() => (e ? (l && document.addEventListener("keydown", o), document.body.style.overflow = "hidden") : document.body.style.overflow = "unset", () => {
document.removeEventListener("keydown", o), document.body.style.overflow = "unset";
}), [e, l, o]), e ? /* @__PURE__ */ t(
"div",
{
className: `fixed inset-0 z-[9999] backdrop-blur-md ${a === "fullscreen-mobile" ? "flex md:flex md:items-center md:justify-center" : "flex items-center justify-center"}`,
style: { backgroundColor: "rgba(0, 0, 0, 0.75)" },
onClick: i ? r : void 0,
children: /* @__PURE__ */ n(
"div",
{
className: `relative bg-white border border-gray-300 ${a === "fullscreen-mobile" ? "rounded-none md:rounded-lg" : "rounded-lg"} shadow-2xl ${a === "fullscreen" || a === "fullscreen-mobile" ? "" : "mx-4"} ${(() => {
switch (a) {
case "sm":
return "max-w-md";
case "md":
return "max-w-lg";
case "lg":
return "max-w-2xl";
case "xl":
return "max-w-6xl";
case "full":
return "max-w-7xl";
case "fullscreen":
return "w-[90vw] h-[90vh] max-w-none";
case "fullscreen-mobile":
return "w-full h-full md:w-[90vw] md:h-[90vh] max-w-none";
default:
return "max-w-lg";
}
})()} ${a === "fullscreen" || a === "fullscreen-mobile" ? "" : "max-h-[90vh]"} flex flex-col`,
onClick: (p) => p.stopPropagation(),
role: "dialog",
"aria-modal": "true",
"aria-labelledby": s ? "modal-title" : void 0,
children: [
(s || c) && /* @__PURE__ */ n("div", { className: "flex items-center justify-between px-6 py-4 border-b border-gray-200", children: [
s && /* @__PURE__ */ t("h2", { id: "modal-title", className: "text-xl font-semibold text-gray-900", children: s }),
c && /* @__PURE__ */ t(
"button",
{
type: "button",
onClick: r,
className: "text-gray-400 hover:text-gray-600 transition-colors p-2 -mr-2",
"aria-label": "Close modal",
children: /* @__PURE__ */ t("svg", { width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
}
)
] }),
/* @__PURE__ */ t("div", { className: `flex-1 overflow-y-auto ${h ? "" : "px-6 py-4"}`, children: d }),
u && /* @__PURE__ */ t("div", { className: "flex items-center justify-end space-x-3 px-6 py-4 border-t border-gray-200 bg-gray-50", children: u })
]
}
)
}
) : null;
}, Dt = ({
schema: e,
schemaStatus: r,
schemaError: s,
selectedFields: a,
onFieldSelect: i,
onFieldDeselect: l,
onRetrySchema: c,
onOpenSettings: d
}) => {
const [u, h] = M(/* @__PURE__ */ new Set()), [o, y] = M(/* @__PURE__ */ new Set()), [p, A] = M("");
if (r === "loading")
return /* @__PURE__ */ t("div", { className: "h-full flex items-center justify-center text-gray-500", children: /* @__PURE__ */ n("div", { className: "text-center", children: [
/* @__PURE__ */ t("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-3" }),
/* @__PURE__ */ t("div", { className: "text-sm font-semibold mb-1", children: "Loading Schema..." }),
/* @__PURE__ */ t("div", { className: "text-xs", children: "Fetching cube metadata" })
] }) });
if (r === "error") {
const w = (s == null ? void 0 : s.toLowerCase().includes("cors")) || (s == null ? void 0 : s.toLowerCase().includes("fetch"));
return /* @__PURE__ */ t("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ n("div", { className: "text-center max-w-sm p-6", children: [
/* @__PURE__ */ t(It, { className: "w-12 h-12 mx-auto text-red-500 mb-4" }),