react-semaphor 0.0.217 → 0.0.219

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { P as L, b as k, j as e, Q as Ns, R as Cs, U as S, V as ea, W as Ss, X as ks, Y as ws, Z as zs, _ as R, $ as le, a0 as sa, J as aa, O as Ae, a1 as _a, a2 as Ha, a3 as Ba, a4 as $a, a5 as Pa, a6 as Ka, a7 as Hs, a8 as Be, a9 as Ge, aa as ns, T as Fs, e as ta, g as Os, ab as Oe, ac as Me, f as X, ad as Te, ae as Le, af as $e, ag as De, ah as Y, ai as Ms, G as c, aj as Je, ak as Qe, al as Ua, am as We, w as na, v as la, t as ue, an as Ga, r as Ja, N as ra, s as Qa, ao as Wa, B as Ya, ap as ia, aq as Xa, L as Pe, S as Ts, z as Za, n as Bs, ar as gs, A as js, u as Ye, as as me, at as be, au as Ke, av as oa, aw as ca, ax as da, ay as ha, az as ma, aA as et, aB as st, aC as ua, aD as at, aE as tt, aF as nt, aG as lt, aH as rt, aI as bs, aJ as it, aK as He, aL as ys, aM as Fe, aN as vs, aO as $s, aP as ot, aQ as ct, aR as dt, aS as ht, aT as mt, aU as xs, aV as ut, aW as Ps, aX as xt, aY as Ks, aZ as pt, a_ as ft, a$ as gt, b0 as xa, l as jt, C as bt, E as Us, d as yt, h as vt, i as Nt, o as Ct, b1 as St, m as kt, H as wt, b2 as zt, b3 as Ft, b4 as Ot, b5 as ps, b6 as Mt, b7 as fs, b8 as Gs, K as Tt, b9 as Lt, ba as At, bb as Ls, bc as Ee, bd as pa, be as Dt, bf as Et, bg as It, bh as Vt, bi as qt, bj as Rt, bk as Ce, bl as _, bm as H, bn as As, bo as B, bp as Js, bq as _t, br as Ht, bs as Bt, bt as $t, bu as Qs, bv as Pt, bw as Kt, bx as Ut, by as Gt, bz as Jt, bA as Qt } from "./index-D_kbj8T-.js";
2
- import xe, { useState as T, useEffect as K, useMemo as Wt, useRef as Ue } from "react";
1
+ import { P as L, b as k, j as e, Q as Ns, R as Cs, U as S, V as ea, W as Ss, X as ks, Y as ws, Z as zs, _ as R, $ as le, a0 as sa, J as aa, O as Ae, a1 as _a, a2 as Ha, a3 as Ba, a4 as $a, a5 as Pa, a6 as Ka, a7 as Hs, a8 as Be, a9 as Ge, aa as ns, T as Fs, e as ta, g as Os, ab as Oe, ac as Me, f as X, ad as Te, ae as Le, af as $e, ag as De, ah as Y, ai as Ms, G as c, aj as Je, ak as Qe, al as Ua, am as We, w as na, v as la, t as ue, an as Ga, r as Ja, N as ra, s as Qa, ao as Wa, B as Ya, ap as ia, aq as Xa, L as Pe, S as Ts, z as Za, n as Bs, ar as gs, A as js, u as Ye, as as me, at as be, au as Ke, av as oa, aw as ca, ax as da, ay as ha, az as ma, aA as et, aB as st, aC as ua, aD as at, aE as tt, aF as nt, aG as lt, aH as rt, aI as bs, aJ as it, aK as He, aL as ys, aM as Fe, aN as vs, aO as $s, aP as ot, aQ as ct, aR as dt, aS as ht, aT as mt, aU as xs, aV as ut, aW as Ps, aX as xt, aY as Ks, aZ as pt, a_ as ft, a$ as gt, b0 as xa, l as jt, C as bt, E as Us, d as yt, h as vt, i as Nt, o as Ct, b1 as St, m as kt, H as wt, b2 as zt, b3 as Ft, b4 as Ot, b5 as ps, b6 as Mt, b7 as fs, b8 as Gs, K as Tt, b9 as Lt, ba as At, bb as Ls, bc as Ee, bd as pa, be as Dt, bf as Et, bg as It, bh as Vt, bi as qt, bj as Rt, bk as Ce, bl as _, bm as H, bn as As, bo as B, bp as Js, bq as _t, br as Ht, bs as Bt, bt as $t, bu as Qs, bv as Pt, bw as Kt, bx as Ut, by as Gt, bz as Jt, bA as Qt } from "./index-s35YyUnE.js";
2
+ import xe, { useState as T, useEffect as U, useMemo as Wt, useRef as Ue } from "react";
3
3
  /**
4
4
  * @license lucide-react v0.379.0 - ISC
5
5
  *
@@ -471,7 +471,7 @@ function Cn() {
471
471
  ), u = k(
472
472
  (i) => i.actions.setBookmarkKey
473
473
  );
474
- K(() => {
474
+ U(() => {
475
475
  const i = Ae(o.id), x = JSON.parse(localStorage.getItem(i) || "[]");
476
476
  l(x);
477
477
  const f = x.find(
@@ -533,7 +533,7 @@ function Cn() {
533
533
  }
534
534
  function Sn() {
535
535
  const [s, n] = T(!1), a = k((h) => h.dashboard), t = k((h) => h.bookmarkKey);
536
- K(() => {
536
+ U(() => {
537
537
  if (!t) {
538
538
  n(!1);
539
539
  return;
@@ -883,9 +883,9 @@ function zn({
883
883
  schemaName: l,
884
884
  tableName: d
885
885
  }, V = [...p || [], z].filter(
886
- (F, U, G) => G.findIndex(
886
+ (F, P, G) => G.findIndex(
887
887
  (I) => I.connectinonId === F.connectinonId && I.tableName === F.tableName
888
- ) === U
888
+ ) === P
889
889
  );
890
890
  u(V), gs.success(`Added '${d}' to AI Scope`, {
891
891
  position: "top-right",
@@ -1064,7 +1064,7 @@ function Vs(s, n) {
1064
1064
  // Only fetch if authToken is present
1065
1065
  }), F = y == null ? void 0 : y.connections.find(
1066
1066
  (r) => r.id === o
1067
- ), U = F == null ? void 0 : F.type, G = (F == null ? void 0 : F.type) === "API" || (F == null ? void 0 : F.type) === "S3", {
1067
+ ), P = F == null ? void 0 : F.type, G = (F == null ? void 0 : F.type) === "API" || (F == null ? void 0 : F.type) === "S3", {
1068
1068
  data: I,
1069
1069
  isLoading: Z,
1070
1070
  isFetching: ae,
@@ -1079,7 +1079,7 @@ function Vs(s, n) {
1079
1079
  connection_id: o
1080
1080
  }
1081
1081
  ),
1082
- enabled: E(U)
1082
+ enabled: E(P)
1083
1083
  // !!selectedConnectionId && !isNonDbConnection, //currentConnection?.type !== 'API', // Only fetch if connectionId is present
1084
1084
  }), {
1085
1085
  data: $,
@@ -1121,12 +1121,12 @@ function Vs(s, n) {
1121
1121
  schema_name: l
1122
1122
  }
1123
1123
  ),
1124
- enabled: w(U)
1124
+ enabled: w(P)
1125
1125
  }), {
1126
1126
  data: ee,
1127
1127
  isLoading: ye,
1128
1128
  isFetching: ge,
1129
- isError: P
1129
+ isError: K
1130
1130
  } = me({
1131
1131
  queryKey: [
1132
1132
  "columns",
@@ -1148,7 +1148,7 @@ function Vs(s, n) {
1148
1148
  table_name: d
1149
1149
  }
1150
1150
  ),
1151
- enabled: N(U)
1151
+ enabled: N(P)
1152
1152
  // (!!selectedConnectionId &&
1153
1153
  // !!selectedDatabaseName &&
1154
1154
  // !!selectedSchemaName &&
@@ -1157,9 +1157,9 @@ function Vs(s, n) {
1157
1157
  //currentConnection?.type === 'API',
1158
1158
  // && currentConnection?.type !== 'API', // Only fetch if connectionId, database, and table is present
1159
1159
  });
1160
- K(() => {
1160
+ U(() => {
1161
1161
  p(a);
1162
- }, [ee, p, a]), K(() => {
1162
+ }, [ee, p, a]), U(() => {
1163
1163
  }, [
1164
1164
  G,
1165
1165
  f,
@@ -1184,7 +1184,7 @@ function Vs(s, n) {
1184
1184
  I && ((es = I == null ? void 0 : I.databases) == null ? void 0 : es.length) > 0, $ && ((qe = $ == null ? void 0 : $.schemas) == null ? void 0 : qe.length) > 0, ee && ((ss = ee == null ? void 0 : ee.columns) == null ? void 0 : ss.length) > 0 && (a = ee.columns.map((r) => ({
1185
1185
  ...r,
1186
1186
  data_type: r.data_type.toLowerCase()
1187
- }))), J && (a = []), (P || b) && (a = []);
1187
+ }))), J && (a = []), (K || b) && (a = []);
1188
1188
  const ke = y == null ? void 0 : y.connections.map(
1189
1189
  (r) => ({
1190
1190
  id: r.id,
@@ -1222,9 +1222,9 @@ function Vs(s, n) {
1222
1222
  isTableError: D,
1223
1223
  columns: a,
1224
1224
  isColumnsLoadingOrFetching: ye || ge,
1225
- isColumnsError: P,
1225
+ isColumnsError: K,
1226
1226
  isNonDbConnection: G,
1227
- connectionType: U,
1227
+ connectionType: P,
1228
1228
  tableName: re,
1229
1229
  schemaName: ie,
1230
1230
  handleConnectionChange: Ve,
@@ -1267,7 +1267,7 @@ function Na({
1267
1267
  isTableLoadingOrFetching: M,
1268
1268
  isTableError: V,
1269
1269
  connectionType: F,
1270
- isNonDbConnection: U,
1270
+ isNonDbConnection: P,
1271
1271
  handleConnectionChange: G,
1272
1272
  handleDatabaseChange: I,
1273
1273
  handleSchemaChange: Z,
@@ -1307,7 +1307,7 @@ function Na({
1307
1307
  );
1308
1308
  }
1309
1309
  function j() {
1310
- if (n && (!t || t === "none") && (!a || a === "none"))
1310
+ if (n && !P && (!t || t === "none") && (!a || a === "none"))
1311
1311
  return /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3", children: [
1312
1312
  /* @__PURE__ */ e.jsx("div", { className: "col-span-1 grid place-items-center", children: /* @__PURE__ */ e.jsx(Ke, {}) }),
1313
1313
  /* @__PURE__ */ e.jsx("div", { className: "col-span-1 grid place-items-center", children: /* @__PURE__ */ e.jsx(R, { children: "OR" }) }),
@@ -1574,7 +1574,7 @@ function Dn({
1574
1574
  Table Columns: ${N == null ? void 0 : N.map((v) => `${v.column_name} | ${v.data_type}`).join(", ")}
1575
1575
  User SQL: ${E}
1576
1576
  ${C && `Base Queries: ${JSON.stringify(C)} `}`, b = ` When the user asks for a specific chart please use the following query structure to generate the chart query. Do not make up the column names. Use only the table columns provided above for the query. Replace x-axis, y-axis, and lables with the appropriate column names.
1577
- Visual Query Syntax: ${An}`, { data: z, isLoading: M, isFetching: V, isError: F, refetch: U } = me({
1577
+ Visual Query Syntax: ${An}`, { data: z, isLoading: M, isFetching: V, isError: F, refetch: P } = me({
1578
1578
  queryKey: ["ai-query"],
1579
1579
  queryFn: () => be(
1580
1580
  "https://semaphor.cloud/api/v1/ai",
@@ -1607,9 +1607,9 @@ function Dn({
1607
1607
  return x("bar"), !1;
1608
1608
  return !0;
1609
1609
  }
1610
- K(() => {
1610
+ U(() => {
1611
1611
  z && w((v) => [...v, { role: "ai", content: z.response }]);
1612
- }, [z]), K(() => {
1612
+ }, [z]), U(() => {
1613
1613
  const v = setTimeout(() => {
1614
1614
  var j;
1615
1615
  l.current && (l.current.scroll({
@@ -1620,9 +1620,9 @@ function Dn({
1620
1620
  return () => clearTimeout(v);
1621
1621
  }, [f]);
1622
1622
  function I() {
1623
- a && (w((v) => [...v, { role: "user", content: a }]), G(a) && u(!0), t(""), U());
1623
+ a && (w((v) => [...v, { role: "user", content: a }]), G(a) && u(!0), t(""), P());
1624
1624
  }
1625
- K(() => {
1625
+ U(() => {
1626
1626
  o && (I(), h(!1));
1627
1627
  }, [o, h]);
1628
1628
  const Z = {
@@ -1901,7 +1901,7 @@ function $n() {
1901
1901
  k(
1902
1902
  (r) => r.actions.updateFrameCard
1903
1903
  );
1904
- const z = c((r) => r.selectedTableName), M = c((r) => r.card.sql), V = c((r) => r.card.python), F = rt(M, x), U = c((r) => r.selectedConnectionId), G = c((r) => r.frame), I = c((r) => r.filterValues), Z = c((r) => r.applyFilters), {
1904
+ const z = c((r) => r.selectedTableName), M = c((r) => r.card.sql), V = c((r) => r.card.python), F = rt(M, x), P = c((r) => r.selectedConnectionId), G = c((r) => r.frame), I = c((r) => r.filterValues), Z = c((r) => r.applyFilters), {
1905
1905
  setCardCustomCfg: ae,
1906
1906
  setQueryResultColumns: J,
1907
1907
  setFilterValues: te,
@@ -1915,7 +1915,7 @@ function $n() {
1915
1915
  ), se = c((r) => r.onClose), D = c((r) => r.actions.setCardData), Q = c((r) => r.actions.setSqlGen), ee = c((r) => r.runSql), ye = c((r) => r.actions.setRunSql), ge = c(
1916
1916
  (r) => r.actions.setIsSqlRunning
1917
1917
  ), {
1918
- data: P,
1918
+ data: K,
1919
1919
  isLoading: re,
1920
1920
  isFetching: ie,
1921
1921
  isSuccess: ve,
@@ -1929,7 +1929,7 @@ function $n() {
1929
1929
  "https://semaphor.cloud/api/v1/query",
1930
1930
  (i == null ? void 0 : i.accessToken) || "",
1931
1931
  {
1932
- connection_id: U,
1932
+ connection_id: P,
1933
1933
  sql: F,
1934
1934
  python: V === $s ? "" : V,
1935
1935
  active_filters: Z ? I : []
@@ -1938,22 +1938,22 @@ function $n() {
1938
1938
  enabled: !1,
1939
1939
  retry: !1
1940
1940
  });
1941
- K(() => {
1942
- if (P && (D(P.records), P.rowLimitExceeded && gs.error("Row limit (10,000) exceeded. Refine your query.", {
1941
+ U(() => {
1942
+ if (K && (D(K.records), K.rowLimitExceeded && gs.error("Row limit (10,000) exceeded. Refine your query.", {
1943
1943
  position: "top-center",
1944
1944
  richColors: !0
1945
- }), j((P == null ? void 0 : P.output) || ""), P.records.length > 0)) {
1946
- const { dimensionKeys: r } = bs(P.records);
1945
+ }), j((K == null ? void 0 : K.output) || ""), K.records.length > 0)) {
1946
+ const { dimensionKeys: r } = bs(K.records);
1947
1947
  J(r);
1948
1948
  }
1949
- }, [P, D, J, j]), K(() => {
1949
+ }, [K, D, J, j]), U(() => {
1950
1950
  ee && (ke(), ye(!1));
1951
- }, [ee, ke, ye]), K(() => {
1951
+ }, [ee, ke, ye]), U(() => {
1952
1952
  (re || ie) && ge(!0), (Se || ve) && ge(!1), Se ? (v(Ve.message), D([]), J([]), j("")) : v("");
1953
1953
  }, [
1954
1954
  re,
1955
1955
  ie,
1956
- P,
1956
+ K,
1957
1957
  j,
1958
1958
  Se,
1959
1959
  ve,
@@ -2009,7 +2009,7 @@ function $n() {
2009
2009
  };
2010
2010
  return `#${ms(ce)}${ms(de)}${ms(he)}`;
2011
2011
  }
2012
- K(() => {
2012
+ U(() => {
2013
2013
  const r = n.current, oe = a.current;
2014
2014
  if (r) {
2015
2015
  const Re = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", Ne = w === "system" ? Re : w;
@@ -2393,7 +2393,7 @@ function ka({
2393
2393
  var m;
2394
2394
  xe.useState(0);
2395
2395
  const a = k((l) => l.themeStyle), t = c((l) => l.card), o = c((l) => l.actions.setCard);
2396
- if (K(() => {
2396
+ if (U(() => {
2397
2397
  }, [
2398
2398
  t.data,
2399
2399
  t.type,
@@ -2960,7 +2960,7 @@ function Ie() {
2960
2960
  var g;
2961
2961
  return (g = u.card.preferences) == null ? void 0 : g.filterOnClickColumnIndex;
2962
2962
  }
2963
- ), K(() => {
2963
+ ), U(() => {
2964
2964
  m && n(new Array(m.length).fill(!1));
2965
2965
  }, [m]);
2966
2966
  function l(u, g) {
@@ -3118,15 +3118,15 @@ function Da() {
3118
3118
  var O;
3119
3119
  return (O = j.card) == null ? void 0 : O.type;
3120
3120
  }), F = ["pie", "doughnut", "polarArea"].includes(V);
3121
- K(() => {
3122
- var j, O, q, fe, se, D, Q, ee, ye, ge, P, re, ie, ve;
3121
+ U(() => {
3122
+ var j, O, q, fe, se, D, Q, ee, ye, ge, K, re, ie, ve;
3123
3123
  m(Zs(a)), d(
3124
3124
  ((q = (O = (j = a == null ? void 0 : a.chartOptions) == null ? void 0 : j.scales) == null ? void 0 : O[o]) == null ? void 0 : q.min) === 0 ? 0 : ""
3125
3125
  ), u(((D = (se = (fe = a == null ? void 0 : a.chartOptions) == null ? void 0 : fe.scales) == null ? void 0 : se[o]) == null ? void 0 : D.max) || ""), x(
3126
3126
  ((ge = (ye = (ee = (Q = a == null ? void 0 : a.chartOptions) == null ? void 0 : Q.scales) == null ? void 0 : ee[o]) == null ? void 0 : ye.ticks) == null ? void 0 : ge.stepSize) || ""
3127
- ), w(((P = a == null ? void 0 : a.numberAxisFormat) == null ? void 0 : P.decimalPlaces) || 0), E(((re = a == null ? void 0 : a.numberAxisFormat) == null ? void 0 : re.suffix) || ""), A(((ie = a == null ? void 0 : a.numberAxisFormat) == null ? void 0 : ie.currency) || ""), z(((ve = a == null ? void 0 : a.numberAxisFormat) == null ? void 0 : ve.locale) || "");
3127
+ ), w(((K = a == null ? void 0 : a.numberAxisFormat) == null ? void 0 : K.decimalPlaces) || 0), E(((re = a == null ? void 0 : a.numberAxisFormat) == null ? void 0 : re.suffix) || ""), A(((ie = a == null ? void 0 : a.numberAxisFormat) == null ? void 0 : ie.currency) || ""), z(((ve = a == null ? void 0 : a.numberAxisFormat) == null ? void 0 : ve.locale) || "");
3128
3128
  }, [s, a, o]);
3129
- function U(j, O) {
3129
+ function P(j, O) {
3130
3130
  return O === "" || /^[0-9\b]+$/.test(O) ? Number(O) : Number(j);
3131
3131
  }
3132
3132
  function G() {
@@ -3191,7 +3191,7 @@ function Da() {
3191
3191
  {
3192
3192
  id: "min",
3193
3193
  value: l,
3194
- onChange: (j) => d((O) => U(O, j.target.value)),
3194
+ onChange: (j) => d((O) => P(O, j.target.value)),
3195
3195
  className: `col-span-1 h-8 w-full ${ze}`
3196
3196
  }
3197
3197
  ),
@@ -3199,7 +3199,7 @@ function Da() {
3199
3199
  le,
3200
3200
  {
3201
3201
  value: p,
3202
- onChange: (j) => u((O) => U(O, j.target.value)),
3202
+ onChange: (j) => u((O) => P(O, j.target.value)),
3203
3203
  id: "max",
3204
3204
  className: `col-span-1 h-8 w-full ${ze}`
3205
3205
  }
@@ -3211,7 +3211,7 @@ function Da() {
3211
3211
  le,
3212
3212
  {
3213
3213
  value: i,
3214
- onChange: (j) => x((O) => U(O, j.target.value)),
3214
+ onChange: (j) => x((O) => P(O, j.target.value)),
3215
3215
  id: "step-size",
3216
3216
  className: `col-span-1 h-8 w-full ${ze}`
3217
3217
  }
@@ -4289,9 +4289,9 @@ function xl() {
4289
4289
  }
4290
4290
  function pl({ authToken: s, onSave: n, onClose: a }) {
4291
4291
  const t = c((m) => m.actions.setOnSave), o = c((m) => m.actions.setOnClose), h = k((m) => m.actions.setAuthToken);
4292
- return K(() => {
4292
+ return U(() => {
4293
4293
  n && t(n), a && o(a);
4294
- }, [n, t, a, o]), K(() => {
4294
+ }, [n, t, a, o]), U(() => {
4295
4295
  s && s.accessToken && h(s);
4296
4296
  }, [s, h]), /* @__PURE__ */ e.jsxs(Ht, { className: "rounded-none", role: "editor-panel", children: [
4297
4297
  /* @__PURE__ */ e.jsx(Bt, { className: "rounded-none border-r-[1.5px]", children: /* @__PURE__ */ e.jsx(Na, {}) }),
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("./index-4Wp9Iidj.js"),f=require("react");/**
1
+ "use strict";const e=require("./index-uA5XMQEz.js"),f=require("react");/**
2
2
  * @license lucide-react v0.379.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -158,7 +158,7 @@
158
158
  *
159
159
  * This source code is licensed under the ISC license.
160
160
  * See the LICENSE file in the root directory of this source tree.
161
- */const Fs=e.createLucideIcon("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);function Os(){const[s,n]=f.useState(""),[t,r]=f.useState(!1),[l,x]=f.useState(!1),u=e.useDashboardStore(c=>c.dashboard);function o(){const c=e.getDashbaordStateWithoutData(u),p=e.getBookmarkKey(u.id),d=JSON.parse(localStorage.getItem(p)||"[]");if(d.some(y=>y.name===s)){r(!0);return}d.push({name:s,template:c}),localStorage.setItem(p,JSON.stringify(d)),x(!1)}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:l,onOpenChange:x,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",children:[e.jsxRuntimeExports.jsx(e.Plus,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Lens"]})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Add a Lens"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsxRuntimeExports.jsx("div",{className:"grid gap-4 py-4",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-right",children:"Name"}),e.jsxRuntimeExports.jsx(e.Input,{value:s,onChange:c=>{t&&r(!1),n(c.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),t&&e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"The bookmark name already exists. Use a differnet name."}),e.jsxRuntimeExports.jsx(e.DialogFooter,{children:e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",type:"submit",disabled:!s,onClick:o,children:"Save"})})]})]})}function Ms(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),l=e.useDashboardStore(a=>a.dashboard),x=e.useDashboardStore(a=>a.bookmarkKey),[u,o]=f.useState([]),c=e.useDashboardStore(a=>a.actions.setDashboard),p=e.useDashboardStore(a=>a.actions.setFilterValues),d=e.useDashboardStore(a=>a.actions.setBookmarkKey);f.useEffect(()=>{const a=e.getBookmarkKey(l.id),m=JSON.parse(localStorage.getItem(a)||"[]");o(m);const h=m.find(v=>v.default);h&&h.name===x&&r(h.name)},[s,l,x]);function j(a){if(a===t)return;const m=u.find(v=>v.name===a),h=m==null?void 0:m.template;h&&(c(h),p(m.filterValues||[]),d(a==="Original"?"":a)),r(a)}function y(a){const m=e.getBookmarkKey(l.id),v=JSON.parse(localStorage.getItem(m)||"[]").filter(S=>S.name!==a);localStorage.setItem(m,JSON.stringify(v)),o(v)}return e.jsxRuntimeExports.jsxs(e.DropdownMenu,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",className:"h-7 p-2",children:e.jsxRuntimeExports.jsx(fs,{className:"h-4 w-4",strokeWidth:1.5})})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{className:"w-56",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuLabel,{children:"Lenses"}),e.jsxRuntimeExports.jsx(e.DropdownMenuSeparator,{}),e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioGroup,{value:t,onValueChange:j,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuRadioItem,{value:"Original",children:"Original"}),u.filter(a=>a.name!="Original").map((a,m)=>e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioItem,{className:"xbg-red-100 flex justify-between",value:a.name,defaultChecked:a.name===x,children:[e.jsxRuntimeExports.jsx("p",{children:a.name}),e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:h=>{h.preventDefault(),y(a.name)},className:"h-3 w-3 hover:cursor-pointer",strokeWidth:1.5})]},m))]})]})]})}function qs(){const[s,n]=f.useState(!1),t=e.useDashboardStore(x=>x.dashboard),r=e.useDashboardStore(x=>x.bookmarkKey);f.useEffect(()=>{if(!r){n(!1);return}const x=e.getBookmarkKey(t.id),o=JSON.parse(localStorage.getItem(x)||"[]").find(c=>c.name===r);n(o?o.default:!1)},[r,t.id]);function l(x){if(n(x),!r)return;const u=e.getBookmarkKey(t.id),c=JSON.parse(localStorage.getItem(u)||"[]").map(p=>(p.name===r?p.default=x:p.default=!1,p));console.log(c),localStorage.setItem(u,JSON.stringify(c))}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:s,onCheckedChange:l,id:"terms"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Set as default"})]})}function Bs(){const s=e.useDashboardStore(S=>S.bookmarkKey),n=e.useDashboardStore(S=>S.dashboard);e.useDashboardStore(S=>S.selectedSheetId);const t=e.useDashboardStore(S=>S.isDashboardEditing),r=e.useDashboardStore(S=>S.filterValues),l=e.useDashboardStore(S=>S.isVisualEditing),x=e.useDashboardStore(S=>S.showFilters);e.useDashboardStore(S=>S.showDashboardJSON);const u=e.useDashboardStore(S=>S.onSaveFunction),o=e.useDashboardStore(S=>S.actions.setShowFilters),{addFrame:c,setSelectedFrameId:p}=e.useDashboardStore(S=>S.actions),{getSelectedSheet:d,setIsDashboardEditing:j,setShowDashboardJSON:y}=e.useDashboardStore(S=>S.actions),a=d(),m=()=>{if(!t||!a)return;const S={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},z={id:e.v4(),cards:[S],activeCardId:S.id};c(a.id,z),p(z.id)},h=()=>{j(!0)};function v(){if(!s||s==="")return;const S=e.getDashbaordStateWithoutData(n),z=e.getBookmarkKey(n.id),R=JSON.parse(localStorage.getItem(z)||"[]"),A=R.findIndex(g=>g.name===s);A!==-1?R[A]={name:s,template:S,default:R[A].default,filterValues:r}:R.push({name:s,template:S,filterValues:r}),localStorage.setItem(z,JSON.stringify(R)),u==null||u(S)}return l?null:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-2 border-b bg-muted/50 px-2 py-2",role:"dashboard-controls",children:[!l&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:s}),!!s&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsxRuntimeExports.jsx(qs,{})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[t&&!l&&e.jsxRuntimeExports.jsx(Os,{}),!l&&e.jsxRuntimeExports.jsx(Ms,{}),t&&!l&&e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!t,onClick:m,children:[e.jsxRuntimeExports.jsx(e.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Add Frame"]}),!t&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",className:"h-7 p-2",onClick:h,size:"sm",children:e.jsxRuntimeExports.jsx($e,{className:"h-4 w-4",strokeWidth:1.5})}),t&&!l&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>{j(!1),y(!1)},size:"sm",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),t&&!l&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:v,size:"sm",children:e.jsxRuntimeExports.jsx(As,{className:"h-4 w-4",strokeWidth:1.5})}),!x&&!l&&t&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>o(!0),size:"sm",children:e.jsxRuntimeExports.jsx(He,{className:"h-4 w-4",strokeWidth:1.5})}),!l&&t&&!1,!l&&!1]})]})}function ue({title:s,items:n,value:t,isLoading:r,isError:l,connectionTooltip:x,onChange:u,showNone:o=!1,className:c,showIcon:p=!0,disabled:d=!1}){const j=r?"Loading...":l?"Error":t;function y(){if(s==="Connection")return e.jsxRuntimeExports.jsx(ws,{className:"size-4 rotate-90"});if(s==="Database")return e.jsxRuntimeExports.jsx(js,{className:"size-4"});if(s==="Schema")return e.jsxRuntimeExports.jsx(Ns,{className:"size-4"});if(s==="Table")return e.jsxRuntimeExports.jsx(e.Table,{className:"size-4"});if(s==="Dataset")return e.jsxRuntimeExports.jsx(ps,{className:"size-4"})}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[p&&e.jsxRuntimeExports.jsx("div",{className:"shrink-0",children:x?e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:y()}),e.jsxRuntimeExports.jsx(e.TooltipContent,{className:"text-xs",align:"start",children:x})]}):y()}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:d,value:j,onValueChange:u,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("h-9 w-full focus:ring-1 focus:ring-offset-0",c),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:r?"Loading...":l?"Error":`Select ${s}`})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[r?e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Loading..."}):e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[o&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),n&&n.map((a,m)=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.id,children:a.name},m))]}),(r||l)&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:j,children:j})]})})]})]})}function Vs({column:s}){const[n,t]=f.useState(!1),r=e.useEditorStore(d=>d.selectedTableName),l=e.useEditorStore(d=>d.selectedSchemaName),x=e.useEditorStore(d=>d.sqlGen),u=e.useEditorStore(d=>d.actions.setSqlGen),o=e.useEditorStore(d=>d.actions.setCardSql),c=e.useEditorStore(d=>d.actions.setRunSql);function p(d,j){const y=e.createSqlGenConfig(d,x,j);u(y);const a=e.getSql(y,e.fmt(l||""),e.fmt(r));a&&(o(a),c(!0)),t(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:n,onOpenChange:t,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.ChevronDown,{className:"h-4 w-4 cursor-pointer text-foreground/40"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"w-18 rounded-md p-0 shadow-none",children:e.jsxRuntimeExports.jsxs("ul",{className:"text-xs",children:[e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})})]})}function Qe({column:s}){return e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.$a093c7e1ec25a057$export$8c610744efcf8a1d,{asChild:!0,children:e.TEXT_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Te,{className:"size-3"}):e.NUMBER_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Rs,{className:"size-3"}):e.DATE_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(e.Calendar,{className:"size-3"}):e.BOOLEAN_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Ts,{className:"size-3"}):e.jsxRuntimeExports.jsx(Is,{className:"size-3"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{children:e.jsxRuntimeExports.jsx("p",{className:"font-mono text-xs",children:s.data_type})})]})}function _s({schemaName:s,tableName:n,columns:t,status:r}){const l=e.useEditorStore(g=>g.sqlGen),x=e.useEditorStore(g=>g.selectedConnectionId),u=e.useEditorStore(g=>g.selectedDatabaseName),o=e.useEditorStore(g=>g.selectedSchemaName),c=e.useEditorStore(g=>g.selectedTableName),p=e.useDashboardStore(g=>g.dashboard.aiScopeTables),{setAIScopeTables:d}=e.useDashboardStore(g=>g.actions),j=e.useEditorStore(g=>g.actions.setRunSql),y=e.useEditorStore(g=>g.actions.setSqlGen),a=e.useEditorStore(g=>g.actions.setIsShowingVisual),m=e.useEditorStore(g=>g.actions.setCardSql),{connectionType:h}=ve();function v(g){const C=e.createSqlGenConfig(g,l);y(C);const w=e.getSql(C,e.fmt(s),e.fmt(n));w&&(m(w),j(!0))}function S(){return(p==null?void 0:p.find(g=>g.connectinonId===x&&g.tableName===c))!==void 0}function z(g){if(g===!0&&c&&x){const C={connectinonId:x,connectionType:h,databaseName:u,schemaName:o,tableName:c},L=[...p||[],C].filter((N,M,q)=>q.findIndex(D=>D.connectinonId===N.connectinonId&&D.tableName===N.tableName)===M);d(L),e.Jt.success(`Added '${c}' to AI Scope`,{position:"top-right",duration:2500,richColors:!0})}else{const C=(p||[]).filter(w=>w.connectinonId!==x&&w.tableName!==c);d(C),e.Jt(`Removed '${c}' from AI Scope`,{position:"top-right",duration:2e3,richColors:!0})}}function R(){let C=e.getQualifiedTableName(s,n);(N=>N.charAt(0)===N.charAt(0).toUpperCase())(n)&&(C=`"${n}"`),a(!1);const L=h==="MSSQL"?`SELECT top 10 * FROM ${C}`:`SELECT * FROM ${C} LIMIT 10`;m(L),j(!0)}function A(){let C=e.getQualifiedTableName(s,n);(L=>L.charAt(0)===L.charAt(0).toUpperCase())(n)&&(C=`"${n}"`),a(!1),m(`SELECT COUNT(*) as count FROM ${C}`),j(!0)}return e.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Toggle,{title:`${S()?"Remove from":"Add to"} AI Scope`,pressed:S(),onPressedChange:z,variant:"outline",className:"h-9 px-2",children:e.jsxRuntimeExports.jsx(e.Bot,{className:e.cn("size-4",{"text-primary":S(),"text-muted-foreground":!S()})})}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:r!=="Success",onClick:R,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(Ds,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:r!=="Success",onClick:A,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(zs,{className:"mr-2 size-4"}),"Count"]})]}),e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"flex-1 basis-0 overflow-y-auto border-b border-t border-muted py-3",children:[t==null?void 0:t.map(g=>e.jsxRuntimeExports.jsxs("div",{onClick:()=>v(g),className:e.cn("mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":e.isColumnInSqlGen(g,l)}),children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(Qe,{column:g}),e.jsxRuntimeExports.jsx("span",{children:g.column_name})]}),e.NUMBER_DATA_TYPES.includes(g.data_type)&&e.jsxRuntimeExports.jsx("div",{onClick:C=>C.stopPropagation(),className:"flex items-center justify-end",children:e.jsxRuntimeExports.jsx(Vs,{column:g})})]},g.column_name)),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"vertical"}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})]})}function ve(s,n){var Ee,fe,pe,ge,Re;let t=f.useMemo(()=>[],[]);const r=e.useSemaphorContext().authToken||s,l=e.useEditorStore(i=>i.selectedConnectionId),x=e.useEditorStore(i=>i.selectedDatamodelId),u=e.useEditorStore(i=>i.selectedDatabaseName),o=e.useEditorStore(i=>i.selectedSchemaName),c=e.useEditorStore(i=>i.selectedTableName),p=e.useEditorStore(i=>i.actions.setCurrentColumns),d=e.useEditorStore(i=>i.actions.setSelectedConnectionId),j=e.useEditorStore(i=>i.actions.setSelectedDatamodelId),y=e.useEditorStore(i=>i.actions.setSelectedDatabaseName),a=e.useEditorStore(i=>i.actions.setSelectedSchemaName),m=e.useEditorStore(i=>i.actions.setSelectedTableName),h=e.useEditorStore(i=>i.actions.setCardSql);function v(i){return l&&u&&o&&u!=="NA"?!0:l&&i==="API"?!1:!!(l&&i==="S3")}function S(i){return!!(l&&u&&u!=="NA"&&o&&c||l&&(i==="S3"||i==="API")||x&&x)}function z(i){return l&&i?!(i==="API"||i==="S3"):!1}const{data:R,isLoading:A,isError:g}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(r==null?void 0:r.accessToken)||""),enabled:!!(r!=null&&r.accessToken)}),{data:C,isLoading:w,isError:L}=e.useQuery({queryKey:["models",l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/datamodels",(r==null?void 0:r.accessToken)||"",{connection_id:l}),enabled:!!(r!=null&&r.accessToken)&&!!l}),N=R==null?void 0:R.connections.find(i=>i.id===l),M=N==null?void 0:N.type,q=(N==null?void 0:N.type)==="API"||(N==null?void 0:N.type)==="S3",{data:D,isLoading:H,isFetching:K,isError:B,refetch:G}=e.useQuery({queryKey:["databases",l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/databases",(r==null?void 0:r.accessToken)||"",{connection_id:l}),enabled:z(M)}),{data:F,isLoading:Q,isFetching:b,isError:E,refetch:k}=e.useQuery({queryKey:["schemas",l,u],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/schemas",(r==null?void 0:r.accessToken)||"",{connection_id:l,database_name:u}),enabled:!!l&&!!u&&!q&&u!=="NA"}),{data:T,isLoading:se,isFetching:$,isError:I,refetch:V}=e.useQuery({queryKey:["tables",l,u,o],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/tables",(r==null?void 0:r.accessToken)||"",{connection_id:l,database_name:u,schema_name:o}),enabled:v(M)}),{data:P,isLoading:ne,isFetching:te,isError:O}=e.useQuery({queryKey:["columns",l,u,x,o,c],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/columns",(r==null?void 0:r.accessToken)||"",{connection_id:l,datamodel_id:x||"",database_name:u,schema_name:o,table_name:c}),enabled:S(M)});f.useEffect(()=>{p(t)},[P,p,t]),f.useEffect(()=>{},[q,h,m,a,y,N]);const U=(N==null?void 0:N.type)==="API"?(Ee=N==null?void 0:N.type)==null?void 0:Ee.toLowerCase():c||"",J=q?"":o||"";function oe(i){a(i),m("")}function ae(i){y(i==="none"?"":i),a(""),m(""),i!=="none"&&i!==""&&j("")}function me(i){d(i)}function Oe(i){j(i==="none"?"":i),i!=="none"&&i!==""&&y("")}D&&((fe=D==null?void 0:D.databases)==null?void 0:fe.length)>0,F&&((pe=F==null?void 0:F.schemas)==null?void 0:pe.length)>0,P&&((ge=P==null?void 0:P.columns)==null?void 0:ge.length)>0&&(t=P.columns.map(i=>({...i,data_type:i.data_type.toLowerCase()}))),B&&(t=[]),(O||g)&&(t=[]);const le=R==null?void 0:R.connections.map(i=>({id:i.id,name:i.name,type:i.type})),Ne=(Re=C==null?void 0:C.datamodels)==null?void 0:Re.map(i=>({id:i.id,name:i.name})),je=D==null?void 0:D.databases.map(i=>({id:i.database_name,name:i.database_name})),ke=F==null?void 0:F.schemas.map(i=>({id:i.schema_name,name:i.schema_name})),we=T==null?void 0:T.tables.map(i=>({id:i.table_name,name:i.table_name}));return{connectionItems:le,isConnectionsLoading:A,isConnectionsError:g,modelItems:Ne,isModelsLoading:w,isModelsError:L,databaseItems:je,isDatabasesLoadingOrFetching:H||K,isDatabaseError:B,schemaItems:ke,isSchemaLoadingOrFetching:Q||b,isSchemaError:E,tableItems:we,isTableLoadingOrFetching:se||$,isTableError:I,columns:t,isColumnsLoadingOrFetching:ne||te,isColumnsError:O,isNonDbConnection:q,connectionType:M,tableName:U,schemaName:J,handleConnectionChange:me,handleDatamodelChange:Oe,handleDatabaseChange:ae,handleSchemaChange:oe}}function Ue({ColumnsComponent:s}){var $;const n=e.useEditorStore(I=>I.selectedConnectionId),t=e.useEditorStore(I=>I.selectedDatamodelId),r=e.useEditorStore(I=>I.selectedDatabaseName),l=e.useEditorStore(I=>I.selectedSchemaName),x=e.useEditorStore(I=>I.selectedTableName),u=e.useEditorStore(I=>I.actions.setSelectedTableName),{connectionItems:o,modelItems:c,schemaItems:p,databaseItems:d,tableItems:j,columns:y,isConnectionsLoading:a,isModelsLoading:m,isConnectionsError:h,isModelsError:v,isDatabasesLoadingOrFetching:S,isDatabaseError:z,isSchemaLoadingOrFetching:R,isSchemaError:A,isColumnsError:g,isColumnsLoadingOrFetching:C,isTableLoadingOrFetching:w,isTableError:L,connectionType:N,isNonDbConnection:M,handleConnectionChange:q,handleDatabaseChange:D,handleSchemaChange:H,handleDatamodelChange:K,tableName:B,schemaName:G}=ve();function F(){return s?s(G,B,y):e.jsxRuntimeExports.jsx(_s,{schemaName:G,tableName:B,columns:y,status:C?"Loading...":g?"Error":"Success"})}function Q(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function b(){if(!n||N==="S3"||N==="API")return null;if(!t||t==="none")return e.jsxRuntimeExports.jsx(ue,{showNone:!0,onChange:D,isError:z,isLoading:S,items:d,value:r||"",title:"Database"})}function E(){if(n&&(!r||r==="none")&&(!t||t==="none"))return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Separator,{})}),e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Label,{children:"OR"})}),e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Separator,{})})]})}function k(){if(!n||N==="S3"||N==="API")return null;if(!r||r==="none")return e.jsxRuntimeExports.jsx(ue,{showNone:!0,onChange:K,isError:v,isLoading:m,items:c,value:t||"",title:"Dataset"})}function T(){return!n||N==="S3"||N==="API"||!r||r==="none"?null:e.jsxRuntimeExports.jsx(ue,{onChange:H,isError:A,isLoading:R,items:p,value:l||"",title:"Schema"})}function se(){function I(){let V=!1;return N==="API"?(V=!1,V):((N==="S3"||n&&r&&r!=="none"&&l)&&(V=!0),V)}return I()?e.jsxRuntimeExports.jsx(ue,{onChange:u,isError:L,items:j,isLoading:w,value:x||"",title:"Table"}):null}return e.jsxRuntimeExports.jsxs("aside",{className:"xbg-red-100 flex grow flex-col justify-between",children:[e.jsxRuntimeExports.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsxRuntimeExports.jsx(ue,{items:o,title:"Connection",value:n||"",onChange:q,isLoading:a,isError:h,connectionTooltip:(($=o==null?void 0:o.find(I=>I.id===n))==null?void 0:$.type)||""}),k(),E(),b(),T(),se()]}),F(),e.jsxRuntimeExports.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxRuntimeExports.jsxs(e.Button,{onClick:Q,size:"sm",variant:"secondary",className:"w-full",children:[e.jsxRuntimeExports.jsx(Cs,{className:"mr-2 size-4"}),"Help"]})})]})}function Hs(s){const n=s.toUpperCase().indexOf("WHERE"),t=s.toUpperCase().indexOf("GROUP BY"),r=s.toUpperCase().indexOf("LIMIT"),l=s.toUpperCase().indexOf("ORDER BY");let x=s.length;if(l!==-1&&(x=l),r!==-1&&r<x&&(x=r),n!==-1){const u=s.substring(0,n),o=s.substring(n);return`${u} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const u=s.substring(0,t),o=s.substring(t);return`${u} {{ filters | where }} ${o}`}else{const u=s.substring(0,x),o=s.substring(x);return`${u} {{ filters | where }} ${o}`}}function Ps({error:s,setShowAIDialog:n,setUserInputforAI:t,setTriggerAIRun:r}){return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"link",className:" p-0 h-5",children:e.jsxRuntimeExports.jsx(hs,{className:"h-4 w-4 text-red-500"})})}),e.jsxRuntimeExports.jsx(e.HoverCardContent,{align:"start",className:" min-w-fit max-w-[500px]",children:e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsxs("div",{className:"grow space-y-1 flex flex-col ",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:()=>{n(!0),t(s),r(!0)},size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(gs,{className:"h-4 w-4 mr-2"}),"Fix It"]}),e.jsxRuntimeExports.jsx(e.ScrollArea,{className:" min-h-0 max-h-[250px] overflow-scroll ",children:e.jsxRuntimeExports.jsx("p",{className:" overflow-auto text-sm leading-relaxed font-mono ",children:s})})]})})})]})}function $s({text:s,onCheckedChange:n,checked:t}){return e.jsxRuntimeExports.jsxs("div",{className:"xbg-red-100 ml-6 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:t,onCheckedChange:n}),e.jsxRuntimeExports.jsx("label",{className:"text-xs leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:s})]})}function Ks(){const{authToken:s}=e.useSemaphorContext(),n=e.useEditorStore(x=>x.selectedConnectionId),{data:t}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(s==null?void 0:s.accessToken)||""),enabled:!!(s!=null&&s.accessToken)}),r=t==null?void 0:t.connections.find(x=>x.id===n);return r==null?void 0:r.type}function Gs(){const{authToken:s}=e.useSemaphorContext(),n=f.useRef(null),t=e.useEditorStore(c=>c.applyFilters),[r,l]=f.useState(""),x=e.useEditorStore(c=>c.filterValues),u=e.useEditorStore(c=>c.card.sql),o=Ks();return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,onOpenChange:async c=>{if(!c)return;console.log("onOpenChange");const p=await e.postRequest("https://semaphor.cloud/api/v1/filter-sql",(s==null?void 0:s.accessToken)||"",{sql:u,active_filters:x,connection_type:o});console.log(p),p.sql?(console.log(p.records),l(p.sql)):l("Error")},children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:t&&e.jsxRuntimeExports.jsx("p",{className:"p-0 text-xs hover:cursor-pointer",children:"|  Filter Query"})}),e.jsxRuntimeExports.jsxs(e.HoverCardContent,{align:"end",className:"w-[600px]",children:[e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-sm bg-muted p-2",children:e.jsxRuntimeExports.jsxs("code",{ref:n,className:"font-mono text-sm",children:[r,e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{onClick:()=>e.copyToClipboard(n),className:"ml-3 inline-block h-4 w-4 opacity-70 hover:cursor-pointer hover:opacity-100"})]})})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsxRuntimeExports.jsx(e.InfoCircledIcon,{className:"h-4 w-4 opacity-70"}),e.jsxRuntimeExports.jsx("span",{className:"text-xs text-muted-foreground",children:"A preview of the query with filters applied."})]})]})]})}const Qs=`
161
+ */const Fs=e.createLucideIcon("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);function Os(){const[s,n]=f.useState(""),[t,r]=f.useState(!1),[l,x]=f.useState(!1),u=e.useDashboardStore(c=>c.dashboard);function o(){const c=e.getDashbaordStateWithoutData(u),p=e.getBookmarkKey(u.id),d=JSON.parse(localStorage.getItem(p)||"[]");if(d.some(y=>y.name===s)){r(!0);return}d.push({name:s,template:c}),localStorage.setItem(p,JSON.stringify(d)),x(!1)}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:l,onOpenChange:x,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",children:[e.jsxRuntimeExports.jsx(e.Plus,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Lens"]})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Add a Lens"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsxRuntimeExports.jsx("div",{className:"grid gap-4 py-4",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-right",children:"Name"}),e.jsxRuntimeExports.jsx(e.Input,{value:s,onChange:c=>{t&&r(!1),n(c.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),t&&e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"The bookmark name already exists. Use a differnet name."}),e.jsxRuntimeExports.jsx(e.DialogFooter,{children:e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",type:"submit",disabled:!s,onClick:o,children:"Save"})})]})]})}function Ms(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),l=e.useDashboardStore(a=>a.dashboard),x=e.useDashboardStore(a=>a.bookmarkKey),[u,o]=f.useState([]),c=e.useDashboardStore(a=>a.actions.setDashboard),p=e.useDashboardStore(a=>a.actions.setFilterValues),d=e.useDashboardStore(a=>a.actions.setBookmarkKey);f.useEffect(()=>{const a=e.getBookmarkKey(l.id),m=JSON.parse(localStorage.getItem(a)||"[]");o(m);const h=m.find(v=>v.default);h&&h.name===x&&r(h.name)},[s,l,x]);function j(a){if(a===t)return;const m=u.find(v=>v.name===a),h=m==null?void 0:m.template;h&&(c(h),p(m.filterValues||[]),d(a==="Original"?"":a)),r(a)}function y(a){const m=e.getBookmarkKey(l.id),v=JSON.parse(localStorage.getItem(m)||"[]").filter(S=>S.name!==a);localStorage.setItem(m,JSON.stringify(v)),o(v)}return e.jsxRuntimeExports.jsxs(e.DropdownMenu,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",className:"h-7 p-2",children:e.jsxRuntimeExports.jsx(fs,{className:"h-4 w-4",strokeWidth:1.5})})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{className:"w-56",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuLabel,{children:"Lenses"}),e.jsxRuntimeExports.jsx(e.DropdownMenuSeparator,{}),e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioGroup,{value:t,onValueChange:j,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuRadioItem,{value:"Original",children:"Original"}),u.filter(a=>a.name!="Original").map((a,m)=>e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioItem,{className:"xbg-red-100 flex justify-between",value:a.name,defaultChecked:a.name===x,children:[e.jsxRuntimeExports.jsx("p",{children:a.name}),e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:h=>{h.preventDefault(),y(a.name)},className:"h-3 w-3 hover:cursor-pointer",strokeWidth:1.5})]},m))]})]})]})}function qs(){const[s,n]=f.useState(!1),t=e.useDashboardStore(x=>x.dashboard),r=e.useDashboardStore(x=>x.bookmarkKey);f.useEffect(()=>{if(!r){n(!1);return}const x=e.getBookmarkKey(t.id),o=JSON.parse(localStorage.getItem(x)||"[]").find(c=>c.name===r);n(o?o.default:!1)},[r,t.id]);function l(x){if(n(x),!r)return;const u=e.getBookmarkKey(t.id),c=JSON.parse(localStorage.getItem(u)||"[]").map(p=>(p.name===r?p.default=x:p.default=!1,p));console.log(c),localStorage.setItem(u,JSON.stringify(c))}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:s,onCheckedChange:l,id:"terms"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Set as default"})]})}function Bs(){const s=e.useDashboardStore(S=>S.bookmarkKey),n=e.useDashboardStore(S=>S.dashboard);e.useDashboardStore(S=>S.selectedSheetId);const t=e.useDashboardStore(S=>S.isDashboardEditing),r=e.useDashboardStore(S=>S.filterValues),l=e.useDashboardStore(S=>S.isVisualEditing),x=e.useDashboardStore(S=>S.showFilters);e.useDashboardStore(S=>S.showDashboardJSON);const u=e.useDashboardStore(S=>S.onSaveFunction),o=e.useDashboardStore(S=>S.actions.setShowFilters),{addFrame:c,setSelectedFrameId:p}=e.useDashboardStore(S=>S.actions),{getSelectedSheet:d,setIsDashboardEditing:j,setShowDashboardJSON:y}=e.useDashboardStore(S=>S.actions),a=d(),m=()=>{if(!t||!a)return;const S={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},z={id:e.v4(),cards:[S],activeCardId:S.id};c(a.id,z),p(z.id)},h=()=>{j(!0)};function v(){if(!s||s==="")return;const S=e.getDashbaordStateWithoutData(n),z=e.getBookmarkKey(n.id),R=JSON.parse(localStorage.getItem(z)||"[]"),A=R.findIndex(g=>g.name===s);A!==-1?R[A]={name:s,template:S,default:R[A].default,filterValues:r}:R.push({name:s,template:S,filterValues:r}),localStorage.setItem(z,JSON.stringify(R)),u==null||u(S)}return l?null:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-2 border-b bg-muted/50 px-2 py-2",role:"dashboard-controls",children:[!l&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:s}),!!s&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsxRuntimeExports.jsx(qs,{})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[t&&!l&&e.jsxRuntimeExports.jsx(Os,{}),!l&&e.jsxRuntimeExports.jsx(Ms,{}),t&&!l&&e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!t,onClick:m,children:[e.jsxRuntimeExports.jsx(e.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Add Frame"]}),!t&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",className:"h-7 p-2",onClick:h,size:"sm",children:e.jsxRuntimeExports.jsx($e,{className:"h-4 w-4",strokeWidth:1.5})}),t&&!l&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>{j(!1),y(!1)},size:"sm",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),t&&!l&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:v,size:"sm",children:e.jsxRuntimeExports.jsx(As,{className:"h-4 w-4",strokeWidth:1.5})}),!x&&!l&&t&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>o(!0),size:"sm",children:e.jsxRuntimeExports.jsx(He,{className:"h-4 w-4",strokeWidth:1.5})}),!l&&t&&!1,!l&&!1]})]})}function ue({title:s,items:n,value:t,isLoading:r,isError:l,connectionTooltip:x,onChange:u,showNone:o=!1,className:c,showIcon:p=!0,disabled:d=!1}){const j=r?"Loading...":l?"Error":t;function y(){if(s==="Connection")return e.jsxRuntimeExports.jsx(ws,{className:"size-4 rotate-90"});if(s==="Database")return e.jsxRuntimeExports.jsx(js,{className:"size-4"});if(s==="Schema")return e.jsxRuntimeExports.jsx(Ns,{className:"size-4"});if(s==="Table")return e.jsxRuntimeExports.jsx(e.Table,{className:"size-4"});if(s==="Dataset")return e.jsxRuntimeExports.jsx(ps,{className:"size-4"})}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[p&&e.jsxRuntimeExports.jsx("div",{className:"shrink-0",children:x?e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:y()}),e.jsxRuntimeExports.jsx(e.TooltipContent,{className:"text-xs",align:"start",children:x})]}):y()}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:d,value:j,onValueChange:u,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("h-9 w-full focus:ring-1 focus:ring-offset-0",c),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:r?"Loading...":l?"Error":`Select ${s}`})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[r?e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Loading..."}):e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[o&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),n&&n.map((a,m)=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.id,children:a.name},m))]}),(r||l)&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:j,children:j})]})})]})]})}function Vs({column:s}){const[n,t]=f.useState(!1),r=e.useEditorStore(d=>d.selectedTableName),l=e.useEditorStore(d=>d.selectedSchemaName),x=e.useEditorStore(d=>d.sqlGen),u=e.useEditorStore(d=>d.actions.setSqlGen),o=e.useEditorStore(d=>d.actions.setCardSql),c=e.useEditorStore(d=>d.actions.setRunSql);function p(d,j){const y=e.createSqlGenConfig(d,x,j);u(y);const a=e.getSql(y,e.fmt(l||""),e.fmt(r));a&&(o(a),c(!0)),t(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:n,onOpenChange:t,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.ChevronDown,{className:"h-4 w-4 cursor-pointer text-foreground/40"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"w-18 rounded-md p-0 shadow-none",children:e.jsxRuntimeExports.jsxs("ul",{className:"text-xs",children:[e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>p(s,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})})]})}function Qe({column:s}){return e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.$a093c7e1ec25a057$export$8c610744efcf8a1d,{asChild:!0,children:e.TEXT_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Te,{className:"size-3"}):e.NUMBER_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Rs,{className:"size-3"}):e.DATE_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(e.Calendar,{className:"size-3"}):e.BOOLEAN_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Ts,{className:"size-3"}):e.jsxRuntimeExports.jsx(Is,{className:"size-3"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{children:e.jsxRuntimeExports.jsx("p",{className:"font-mono text-xs",children:s.data_type})})]})}function _s({schemaName:s,tableName:n,columns:t,status:r}){const l=e.useEditorStore(g=>g.sqlGen),x=e.useEditorStore(g=>g.selectedConnectionId),u=e.useEditorStore(g=>g.selectedDatabaseName),o=e.useEditorStore(g=>g.selectedSchemaName),c=e.useEditorStore(g=>g.selectedTableName),p=e.useDashboardStore(g=>g.dashboard.aiScopeTables),{setAIScopeTables:d}=e.useDashboardStore(g=>g.actions),j=e.useEditorStore(g=>g.actions.setRunSql),y=e.useEditorStore(g=>g.actions.setSqlGen),a=e.useEditorStore(g=>g.actions.setIsShowingVisual),m=e.useEditorStore(g=>g.actions.setCardSql),{connectionType:h}=ve();function v(g){const C=e.createSqlGenConfig(g,l);y(C);const w=e.getSql(C,e.fmt(s),e.fmt(n));w&&(m(w),j(!0))}function S(){return(p==null?void 0:p.find(g=>g.connectinonId===x&&g.tableName===c))!==void 0}function z(g){if(g===!0&&c&&x){const C={connectinonId:x,connectionType:h,databaseName:u,schemaName:o,tableName:c},L=[...p||[],C].filter((N,O,q)=>q.findIndex(D=>D.connectinonId===N.connectinonId&&D.tableName===N.tableName)===O);d(L),e.Jt.success(`Added '${c}' to AI Scope`,{position:"top-right",duration:2500,richColors:!0})}else{const C=(p||[]).filter(w=>w.connectinonId!==x&&w.tableName!==c);d(C),e.Jt(`Removed '${c}' from AI Scope`,{position:"top-right",duration:2e3,richColors:!0})}}function R(){let C=e.getQualifiedTableName(s,n);(N=>N.charAt(0)===N.charAt(0).toUpperCase())(n)&&(C=`"${n}"`),a(!1);const L=h==="MSSQL"?`SELECT top 10 * FROM ${C}`:`SELECT * FROM ${C} LIMIT 10`;m(L),j(!0)}function A(){let C=e.getQualifiedTableName(s,n);(L=>L.charAt(0)===L.charAt(0).toUpperCase())(n)&&(C=`"${n}"`),a(!1),m(`SELECT COUNT(*) as count FROM ${C}`),j(!0)}return e.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Toggle,{title:`${S()?"Remove from":"Add to"} AI Scope`,pressed:S(),onPressedChange:z,variant:"outline",className:"h-9 px-2",children:e.jsxRuntimeExports.jsx(e.Bot,{className:e.cn("size-4",{"text-primary":S(),"text-muted-foreground":!S()})})}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:r!=="Success",onClick:R,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(Ds,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:r!=="Success",onClick:A,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(zs,{className:"mr-2 size-4"}),"Count"]})]}),e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"flex-1 basis-0 overflow-y-auto border-b border-t border-muted py-3",children:[t==null?void 0:t.map(g=>e.jsxRuntimeExports.jsxs("div",{onClick:()=>v(g),className:e.cn("mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":e.isColumnInSqlGen(g,l)}),children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(Qe,{column:g}),e.jsxRuntimeExports.jsx("span",{children:g.column_name})]}),e.NUMBER_DATA_TYPES.includes(g.data_type)&&e.jsxRuntimeExports.jsx("div",{onClick:C=>C.stopPropagation(),className:"flex items-center justify-end",children:e.jsxRuntimeExports.jsx(Vs,{column:g})})]},g.column_name)),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"vertical"}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})]})}function ve(s,n){var Ee,fe,pe,ge,Re;let t=f.useMemo(()=>[],[]);const r=e.useSemaphorContext().authToken||s,l=e.useEditorStore(i=>i.selectedConnectionId),x=e.useEditorStore(i=>i.selectedDatamodelId),u=e.useEditorStore(i=>i.selectedDatabaseName),o=e.useEditorStore(i=>i.selectedSchemaName),c=e.useEditorStore(i=>i.selectedTableName),p=e.useEditorStore(i=>i.actions.setCurrentColumns),d=e.useEditorStore(i=>i.actions.setSelectedConnectionId),j=e.useEditorStore(i=>i.actions.setSelectedDatamodelId),y=e.useEditorStore(i=>i.actions.setSelectedDatabaseName),a=e.useEditorStore(i=>i.actions.setSelectedSchemaName),m=e.useEditorStore(i=>i.actions.setSelectedTableName),h=e.useEditorStore(i=>i.actions.setCardSql);function v(i){return l&&u&&o&&u!=="NA"?!0:l&&i==="API"?!1:!!(l&&i==="S3")}function S(i){return!!(l&&u&&u!=="NA"&&o&&c||l&&(i==="S3"||i==="API")||x&&x)}function z(i){return l&&i?!(i==="API"||i==="S3"):!1}const{data:R,isLoading:A,isError:g}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(r==null?void 0:r.accessToken)||""),enabled:!!(r!=null&&r.accessToken)}),{data:C,isLoading:w,isError:L}=e.useQuery({queryKey:["models",l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/datamodels",(r==null?void 0:r.accessToken)||"",{connection_id:l}),enabled:!!(r!=null&&r.accessToken)&&!!l}),N=R==null?void 0:R.connections.find(i=>i.id===l),O=N==null?void 0:N.type,q=(N==null?void 0:N.type)==="API"||(N==null?void 0:N.type)==="S3",{data:D,isLoading:H,isFetching:K,isError:B,refetch:G}=e.useQuery({queryKey:["databases",l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/databases",(r==null?void 0:r.accessToken)||"",{connection_id:l}),enabled:z(O)}),{data:F,isLoading:Q,isFetching:b,isError:E,refetch:k}=e.useQuery({queryKey:["schemas",l,u],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/schemas",(r==null?void 0:r.accessToken)||"",{connection_id:l,database_name:u}),enabled:!!l&&!!u&&!q&&u!=="NA"}),{data:T,isLoading:se,isFetching:$,isError:I,refetch:V}=e.useQuery({queryKey:["tables",l,u,o],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/tables",(r==null?void 0:r.accessToken)||"",{connection_id:l,database_name:u,schema_name:o}),enabled:v(O)}),{data:P,isLoading:ne,isFetching:te,isError:M}=e.useQuery({queryKey:["columns",l,u,x,o,c],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/columns",(r==null?void 0:r.accessToken)||"",{connection_id:l,datamodel_id:x||"",database_name:u,schema_name:o,table_name:c}),enabled:S(O)});f.useEffect(()=>{p(t)},[P,p,t]),f.useEffect(()=>{},[q,h,m,a,y,N]);const U=(N==null?void 0:N.type)==="API"?(Ee=N==null?void 0:N.type)==null?void 0:Ee.toLowerCase():c||"",J=q?"":o||"";function oe(i){a(i),m("")}function ae(i){y(i==="none"?"":i),a(""),m(""),i!=="none"&&i!==""&&j("")}function me(i){d(i)}function Oe(i){j(i==="none"?"":i),i!=="none"&&i!==""&&y("")}D&&((fe=D==null?void 0:D.databases)==null?void 0:fe.length)>0,F&&((pe=F==null?void 0:F.schemas)==null?void 0:pe.length)>0,P&&((ge=P==null?void 0:P.columns)==null?void 0:ge.length)>0&&(t=P.columns.map(i=>({...i,data_type:i.data_type.toLowerCase()}))),B&&(t=[]),(M||g)&&(t=[]);const le=R==null?void 0:R.connections.map(i=>({id:i.id,name:i.name,type:i.type})),Ne=(Re=C==null?void 0:C.datamodels)==null?void 0:Re.map(i=>({id:i.id,name:i.name})),je=D==null?void 0:D.databases.map(i=>({id:i.database_name,name:i.database_name})),ke=F==null?void 0:F.schemas.map(i=>({id:i.schema_name,name:i.schema_name})),we=T==null?void 0:T.tables.map(i=>({id:i.table_name,name:i.table_name}));return{connectionItems:le,isConnectionsLoading:A,isConnectionsError:g,modelItems:Ne,isModelsLoading:w,isModelsError:L,databaseItems:je,isDatabasesLoadingOrFetching:H||K,isDatabaseError:B,schemaItems:ke,isSchemaLoadingOrFetching:Q||b,isSchemaError:E,tableItems:we,isTableLoadingOrFetching:se||$,isTableError:I,columns:t,isColumnsLoadingOrFetching:ne||te,isColumnsError:M,isNonDbConnection:q,connectionType:O,tableName:U,schemaName:J,handleConnectionChange:me,handleDatamodelChange:Oe,handleDatabaseChange:ae,handleSchemaChange:oe}}function Ue({ColumnsComponent:s}){var $;const n=e.useEditorStore(I=>I.selectedConnectionId),t=e.useEditorStore(I=>I.selectedDatamodelId),r=e.useEditorStore(I=>I.selectedDatabaseName),l=e.useEditorStore(I=>I.selectedSchemaName),x=e.useEditorStore(I=>I.selectedTableName),u=e.useEditorStore(I=>I.actions.setSelectedTableName),{connectionItems:o,modelItems:c,schemaItems:p,databaseItems:d,tableItems:j,columns:y,isConnectionsLoading:a,isModelsLoading:m,isConnectionsError:h,isModelsError:v,isDatabasesLoadingOrFetching:S,isDatabaseError:z,isSchemaLoadingOrFetching:R,isSchemaError:A,isColumnsError:g,isColumnsLoadingOrFetching:C,isTableLoadingOrFetching:w,isTableError:L,connectionType:N,isNonDbConnection:O,handleConnectionChange:q,handleDatabaseChange:D,handleSchemaChange:H,handleDatamodelChange:K,tableName:B,schemaName:G}=ve();function F(){return s?s(G,B,y):e.jsxRuntimeExports.jsx(_s,{schemaName:G,tableName:B,columns:y,status:C?"Loading...":g?"Error":"Success"})}function Q(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function b(){if(!n||N==="S3"||N==="API")return null;if(!t||t==="none")return e.jsxRuntimeExports.jsx(ue,{showNone:!0,onChange:D,isError:z,isLoading:S,items:d,value:r||"",title:"Database"})}function E(){if(n&&!O&&(!r||r==="none")&&(!t||t==="none"))return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Separator,{})}),e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Label,{children:"OR"})}),e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Separator,{})})]})}function k(){if(!n||N==="S3"||N==="API")return null;if(!r||r==="none")return e.jsxRuntimeExports.jsx(ue,{showNone:!0,onChange:K,isError:v,isLoading:m,items:c,value:t||"",title:"Dataset"})}function T(){return!n||N==="S3"||N==="API"||!r||r==="none"?null:e.jsxRuntimeExports.jsx(ue,{onChange:H,isError:A,isLoading:R,items:p,value:l||"",title:"Schema"})}function se(){function I(){let V=!1;return N==="API"?(V=!1,V):((N==="S3"||n&&r&&r!=="none"&&l)&&(V=!0),V)}return I()?e.jsxRuntimeExports.jsx(ue,{onChange:u,isError:L,items:j,isLoading:w,value:x||"",title:"Table"}):null}return e.jsxRuntimeExports.jsxs("aside",{className:"xbg-red-100 flex grow flex-col justify-between",children:[e.jsxRuntimeExports.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsxRuntimeExports.jsx(ue,{items:o,title:"Connection",value:n||"",onChange:q,isLoading:a,isError:h,connectionTooltip:(($=o==null?void 0:o.find(I=>I.id===n))==null?void 0:$.type)||""}),k(),E(),b(),T(),se()]}),F(),e.jsxRuntimeExports.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxRuntimeExports.jsxs(e.Button,{onClick:Q,size:"sm",variant:"secondary",className:"w-full",children:[e.jsxRuntimeExports.jsx(Cs,{className:"mr-2 size-4"}),"Help"]})})]})}function Hs(s){const n=s.toUpperCase().indexOf("WHERE"),t=s.toUpperCase().indexOf("GROUP BY"),r=s.toUpperCase().indexOf("LIMIT"),l=s.toUpperCase().indexOf("ORDER BY");let x=s.length;if(l!==-1&&(x=l),r!==-1&&r<x&&(x=r),n!==-1){const u=s.substring(0,n),o=s.substring(n);return`${u} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const u=s.substring(0,t),o=s.substring(t);return`${u} {{ filters | where }} ${o}`}else{const u=s.substring(0,x),o=s.substring(x);return`${u} {{ filters | where }} ${o}`}}function Ps({error:s,setShowAIDialog:n,setUserInputforAI:t,setTriggerAIRun:r}){return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"link",className:" p-0 h-5",children:e.jsxRuntimeExports.jsx(hs,{className:"h-4 w-4 text-red-500"})})}),e.jsxRuntimeExports.jsx(e.HoverCardContent,{align:"start",className:" min-w-fit max-w-[500px]",children:e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsxs("div",{className:"grow space-y-1 flex flex-col ",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:()=>{n(!0),t(s),r(!0)},size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(gs,{className:"h-4 w-4 mr-2"}),"Fix It"]}),e.jsxRuntimeExports.jsx(e.ScrollArea,{className:" min-h-0 max-h-[250px] overflow-scroll ",children:e.jsxRuntimeExports.jsx("p",{className:" overflow-auto text-sm leading-relaxed font-mono ",children:s})})]})})})]})}function $s({text:s,onCheckedChange:n,checked:t}){return e.jsxRuntimeExports.jsxs("div",{className:"xbg-red-100 ml-6 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:t,onCheckedChange:n}),e.jsxRuntimeExports.jsx("label",{className:"text-xs leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:s})]})}function Ks(){const{authToken:s}=e.useSemaphorContext(),n=e.useEditorStore(x=>x.selectedConnectionId),{data:t}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(s==null?void 0:s.accessToken)||""),enabled:!!(s!=null&&s.accessToken)}),r=t==null?void 0:t.connections.find(x=>x.id===n);return r==null?void 0:r.type}function Gs(){const{authToken:s}=e.useSemaphorContext(),n=f.useRef(null),t=e.useEditorStore(c=>c.applyFilters),[r,l]=f.useState(""),x=e.useEditorStore(c=>c.filterValues),u=e.useEditorStore(c=>c.card.sql),o=Ks();return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,onOpenChange:async c=>{if(!c)return;console.log("onOpenChange");const p=await e.postRequest("https://semaphor.cloud/api/v1/filter-sql",(s==null?void 0:s.accessToken)||"",{sql:u,active_filters:x,connection_type:o});console.log(p),p.sql?(console.log(p.records),l(p.sql)):l("Error")},children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:t&&e.jsxRuntimeExports.jsx("p",{className:"p-0 text-xs hover:cursor-pointer",children:"|  Filter Query"})}),e.jsxRuntimeExports.jsxs(e.HoverCardContent,{align:"end",className:"w-[600px]",children:[e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-sm bg-muted p-2",children:e.jsxRuntimeExports.jsxs("code",{ref:n,className:"font-mono text-sm",children:[r,e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{onClick:()=>e.copyToClipboard(n),className:"ml-3 inline-block h-4 w-4 opacity-70 hover:cursor-pointer hover:opacity-100"})]})})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsxRuntimeExports.jsx(e.InfoCircledIcon,{className:"h-4 w-4 opacity-70"}),e.jsxRuntimeExports.jsx("span",{className:"text-xs text-muted-foreground",children:"A preview of the query with filters applied."})]})]})]})}const Qs=`
162
162
 
163
163
  Use the following syntax to create a chart query. Please replace the x-axis, y-axis, stack-by, label, and measure with the actual column names of the table.
164
164
 
@@ -212,4 +212,4 @@ SELECT label, measure FROM table
212
212
  Table Columns: ${S==null?void 0:S.map(b=>`${b.column_name} | ${b.data_type}`).join(", ")}
213
213
  User SQL: ${z}
214
214
  ${y&&`Base Queries: ${JSON.stringify(y)} `}`,g=` When the user asks for a specific chart please use the following query structure to generate the chart query. Do not make up the column names. Use only the table columns provided above for the query. Replace x-axis, y-axis, and lables with the appropriate column names.
215
- Visual Query Syntax: ${Qs}`,{data:C,isLoading:w,isFetching:L,isError:N,refetch:M}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(c==null?void 0:c.accessToken)||"",{user_content:`userContent: ${A} ${p?g:""}`}),enabled:!1});function q(b){if(b.toLowerCase().includes("bar"))m("bar");else if(b.toLowerCase().includes("line"))m("line");else if(b.toLowerCase().includes("bubble"))m("bubble");else if(b.toLowerCase().includes("scatter"))m("scatter");else if(b.toLowerCase().includes("stacked"))m("stackedBar");else if(b.toLowerCase().includes("pie"))m("pie");else if(b.toLowerCase().includes("donut")||b.toLowerCase().includes("doughnut"))m("doughnut");else if(b.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}f.useEffect(()=>{C&&v(b=>[...b,{role:"ai",content:C.response}])},[C]),f.useEffect(()=>{const b=setTimeout(()=>{var E;o.current&&(o.current.scroll({top:o.current.scrollHeight,behavior:"smooth"}),(E=u.current)==null||E.focus())},100);return()=>clearTimeout(b)},[h]);function D(){t&&(v(b=>[...b,{role:"user",content:t}]),q(t)&&d(!0),r(""),M())}f.useEffect(()=>{l&&(D(),x(!1))},[l,x]);const H={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},K={fontFamily:"monospace",fontSize:14,lineHeight:1.6},B={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},G={p:({node:b,...E})=>e.jsxRuntimeExports.jsx("p",{style:H,...E}),code:({node:b,...E})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...E}),pre:({node:b,...E})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:K,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:E.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:F,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:k=>{const T=F(k);T&&(n(!1),j(T),a(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:b,...E})=>e.jsxRuntimeExports.jsx("li",{style:B,...E})};function F(b){const E=b.currentTarget.closest("pre");if(!E)return;const k=E.textContent||E.innerText;return navigator.clipboard.writeText(k).then(()=>console.log("Text copied to clipboard")).catch(T=>console.error("Error in copying text: ",T)),k}function Q(){return h==null?void 0:h.map((b,E)=>b.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Fs,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:b.content})]},E):b.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:G,children:C==null?void 0:C.response.replace(/DuckDB/gi,"Semaphor")},E):e.jsxRuntimeExports.jsx("div",{},E))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:o,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:Q()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:u,onKeyDown:b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),r(""),D())},placeholder:"Type your question here...",onFocus:b=>{const E=b.target,k=E.value.length;E.setSelectionRange(k,k)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:w||L,value:t,onChange:b=>r(b.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:D,children:!w&&!L?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Je={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},qe=f.createContext&&f.createContext(Je),Js=["attr","size","title"];function Ws(s,n){if(s==null)return{};var t=Ys(s,n),r,l;if(Object.getOwnPropertySymbols){var x=Object.getOwnPropertySymbols(s);for(l=0;l<x.length;l++)r=x[l],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(t[r]=s[r])}return t}function Ys(s,n){if(s==null)return{};var t={},r=Object.keys(s),l,x;for(x=0;x<r.length;x++)l=r[x],!(n.indexOf(l)>=0)&&(t[l]=s[l]);return t}function Se(){return Se=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},Se.apply(this,arguments)}function Be(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);n&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(s,l).enumerable})),t.push.apply(t,r)}return t}function ye(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?Be(Object(t),!0).forEach(function(r){Xs(s,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Be(Object(t)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(t,r))})}return s}function Xs(s,n,t){return n=Zs(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Zs(s){var n=et(s,"string");return typeof n=="symbol"?n:String(n)}function et(s,n){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var r=t.call(s,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(s)}function We(s){return s&&s.map((n,t)=>f.createElement(n.tag,ye({key:t},n.attr),We(n.child)))}function ee(s){return n=>f.createElement(st,Se({attr:ye({},s.attr)},n),We(s.child))}function st(s){var n=t=>{var{attr:r,size:l,title:x}=s,u=Ws(s,Js),o=l||t.size||"1em",c;return t.className&&(c=t.className),s.className&&(c=(c?c+" ":"")+s.className),f.createElement("svg",Se({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,u,{className:c,style:ye(ye({color:s.color||t.color},t.style),s.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),x&&f.createElement("title",null,x),s.children)};return qe!==void 0?f.createElement(qe.Consumer,null,t=>n(t)):n(Je)}function tt(s){return ee({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(s)}function rt(){const{theme:s}=e.useTheme(),n=f.useRef(),t=f.useRef(),[r,l]=f.useState(!1),[x,u]=f.useState(!1),[o,c]=f.useState(!1),[p,d]=f.useState(""),[j,y]=f.useState(!1),{authToken:a}=e.useSemaphorContext();e.useDashboardStore(i=>i.selectedSheetId);const m=e.useDashboardStore(i=>i.dashboard.baseQueries),h=e.useEditorStore(i=>i.card),v=e.useDashboardStore(i=>i.theme),S=e.useEditorStore(i=>i.isShowingVisual),z=e.useEditorStore(i=>i.selectedConnectionId),R=e.useEditorStore(i=>i.selectedDatabaseName),A=e.useEditorStore(i=>i.selectedDatamodelId),g=e.useEditorStore(i=>i.selectedSchemaName);e.useDashboardStore(i=>i.actions.updateFrameCard);const C=e.useEditorStore(i=>i.selectedTableName),w=e.useEditorStore(i=>i.card.sql),L=e.useEditorStore(i=>i.card.python),N=e.resolveBaseQuery(w,m),M=e.useEditorStore(i=>i.selectedConnectionId),q=e.useEditorStore(i=>i.frame),D=e.useEditorStore(i=>i.filterValues),H=e.useEditorStore(i=>i.applyFilters),{setCardCustomCfg:K,setQueryResultColumns:B,setFilterValues:G,setCardSql:F,setCardPython:Q,setQueryError:b,setPythonStdOut:E,setCardPreferences:k}=e.useEditorStore(i=>i.actions),T=e.useEditorStore(i=>i.onSave),se=e.useEditorStore(i=>i.actions.setApplyFilters),$=e.useEditorStore(i=>i.onClose),I=e.useEditorStore(i=>i.actions.setCardData),V=e.useEditorStore(i=>i.actions.setSqlGen),P=e.useEditorStore(i=>i.runSql),ne=e.useEditorStore(i=>i.actions.setRunSql),te=e.useEditorStore(i=>i.actions.setIsSqlRunning),{data:O,isLoading:U,isFetching:J,isSuccess:oe,isError:ae,error:me,status:Oe,refetch:le}=e.useQuery({queryKey:[N,L],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(a==null?void 0:a.accessToken)||"",{connection_id:M,sql:N,python:L===e.PYTHON_DEFAULT_CODE?"":L,active_filters:H?D:[]}),enabled:!1,retry:!1});f.useEffect(()=>{if(O&&(I(O.records),O.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),E((O==null?void 0:O.output)||""),O.records.length>0)){const{dimensionKeys:i}=e.getKeys(O.records);B(i)}},[O,I,B,E]),f.useEffect(()=>{P&&(le(),ne(!1))},[P,le,ne]),f.useEffect(()=>{(U||J)&&te(!0),(ae||oe)&&te(!1),ae?(b(me.message),I([]),B([]),E("")):b("")},[U,J,O,E,ae,oe,te,I,B,b,me]);function Ne(){F(""),I([]),V({}),K(""),k({})}const je=i=>{t.current=i};function ke(){let i=w;w&&!w.includes("{{")&&(i=Hs(w),F(i));const W={...h,lastSelectedSchema:g,lastSelectedDatamodelId:A,lastSelectedDatabase:R,lastSelectedTable:C,connectionId:z,type:S?h.type:"table",sql:i,customCfg:S?h.customCfg:null},he=q.cards.map(ie=>ie.id===h.id?W:ie);T==null||T({...q,cards:he})}function we(){$==null||$()}function Ee(i){const W=getComputedStyle(document.documentElement).getPropertyValue(i);return fe(W)}function fe(i){const[W,he,ie]=i.split(" "),_=parseFloat(W),ls=parseFloat(he),cs=parseFloat(ie),xs=ls/100,Me=cs/100,re=(1-Math.abs(2*Me-1))*xs,ce=re*(1-Math.abs(_/60%2-1)),Ae=Me-re/2;let Y=0,X=0,Z=0;0<=_&&_<60?(Y=re,X=ce,Z=0):60<=_&&_<120?(Y=ce,X=re,Z=0):120<=_&&_<180?(Y=0,X=re,Z=ce):180<=_&&_<240?(Y=0,X=ce,Z=re):240<=_&&_<300?(Y=ce,X=0,Z=re):300<=_&&_<360&&(Y=re,X=0,Z=ce),Y=Math.round((Y+Ae)*255),X=Math.round((X+Ae)*255),Z=Math.round((Z+Ae)*255);const Ie=us=>{const ze=us.toString(16);return ze.length==1?"0"+ze:ze};return`#${Ie(Y)}${Ie(X)}${Ie(Z)}`}f.useEffect(()=>{const i=n.current,W=t.current;if(i){const he=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",ie=v==="system"?he:v;i.editor.defineTheme("default",{base:ie==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":ie==="light"?"#ffffff":Ee("--semaphor-background")}}),i.editor.setTheme("default")}return W&&i&&W.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return console.log("Executing query..."),le(),!1}),()=>{}},[s,v,n.current]);function pe(i){n.current=i}function ge(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx($s,{checked:H,onCheckedChange:()=>se(!H),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Gs,{}),D&&x&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>u(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:i=>{if(i)try{JSON.parse(i),G(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(D,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),D&&!x&&e.jsxRuntimeExports.jsx(He,{onClick:()=>u(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":H})})]})}function Re(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:i=>{F(i)},value:w,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:pe,onMount:je})}),r&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),r&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:i=>{Q(i&&i.trim()||"")},value:L||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:pe,onMount:je})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[Re(),ge()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:U||J,onClick:()=>{le()},className:"shrink-0",size:"sm",variant:"outline",children:[U||J?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(ks,{className:"mr-2 h-4 w-4"}),"Run"]}),ae&&e.jsxRuntimeExports.jsx(Ps,{error:me.message,setShowAIDialog:c,setTriggerAIRun:y,setUserInputforAI:d}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ne,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Es,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:r,onPressedChange:i=>l(i),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(tt,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Us,{open:o,setOpen:c,userInput:p,triggerAIRun:j,setTriggerAIRun:y,setUserInput:i=>d(i)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:ke,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:we,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function nt({data:s}){var u;const[n,t]=f.useState([]),l=Object.keys(s[0]).map(o=>({accessorKey:o,header:({column:c})=>{const p=c.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>c.toggleSorting(c.getIsSorted()==="asc"),children:[o,p==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):p==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),x=e.useReactTable({data:s,columns:l,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:x.getHeaderGroups().map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{children:o.headers.map(c=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:c.isPlaceholder?null:e.flexRender(c.column.columnDef.header,c.getContext())},c.id))},o.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(u=x.getRowModel().rows)!=null&&u.length?x.getRowModel().rows.map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":o.getIsSelected()&&"selected",children:o.getVisibleCells().map(c=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(c.column.columnDef.cell,c.getContext())},c.id))},o.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:l.length,className:"h-24 text-center",children:"No results."})})})]})}function Ye({className:s,...n}){var u;f.useState(0);const t=e.useDashboardStore(o=>o.themeStyle),r=e.useEditorStore(o=>o.card),l=e.useEditorStore(o=>o.actions.setCard);if(f.useEffect(()=>{},[r.data,r.type,r.cfg,r.customCfg,t,r.preferences]),!r.id)return null;let x;return r.data&&r.data.length>0&&(x=e.createChartConfig({data:r.data,cardType:r.type,cfg:r.cfg,customCfg:r.customCfg,preferences:r.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...n,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:r.title,onSave:o=>l({...r,title:o}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:r.title})})},r.title),e.jsxRuntimeExports.jsx(e.Editable,{text:r.description||"",onSave:o=>l({...r,description:o}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",r.description]})},r.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[r.type!=="table"&&x&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x},JSON.stringify(x)+JSON.stringify(r.preferences)+((u=r==null?void 0:r.preferences)==null?void 0:u.customVisualCode)),r.type==="table"&&r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:r,data:r==null?void 0:r.data})})]})]})}function ot(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),[l,x]=f.useState(""),[u,o]=f.useState(""),[c,p]=f.useState(""),d=e.useEditorStore(R=>R.card),j=e.useEditorStore(R=>R.card.customCfg),{setCardCustomCfg:y,setCustomVisualCode:a}=e.useEditorActions();function m(R){var C,w;const A={...R,data:{...R==null?void 0:R.data,datasets:(w=(C=R==null?void 0:R.data)==null?void 0:C.datasets)==null?void 0:w.map(L=>({...L,data:[]}))}};return JSON.stringify(A,null,1)}function h(){var A,g;if(!d.data||d.data.length===0)return;const R=e.createChartConfig({data:d.data,cardType:d.type,cfg:d.cfg,preferences:d.preferences});R&&(r(JSON.stringify(R,null,1)),(A=d==null?void 0:d.preferences)!=null&&A.customVisualCode&&o((g=d==null?void 0:d.preferences)==null?void 0:g.customVisualCode),j&&x(JSON.stringify(j,null,1)))}function v(){if(u&&a(u),!!l)try{const R=JSON.parse(l);return R?(y(R),p(""),x(""),R):void 0}catch(R){console.log(R),p("Invalid JSON")}}function S(){x(""),y(null)}function z(){let R;if(j){const A=e._.cloneDeep(d.cfg),g=e._.merge(A,j);return R=m(g),R}return t?(R=m(JSON.parse(t)),R):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:h,className:` ${j&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(bs,{onClick:()=>{navigator.clipboard.writeText(d.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Ye,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[j&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),j?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:z(),onChange:R=>x(R)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:u,onChange:R=>o(R||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:c}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!j,onClick:S,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:v,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Xe(s){return ee({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(s)}function Ze(s){return ee({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(s)}function es(s){return ee({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(s)}function ss(s){return ee({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(s)}function ts(s){return ee({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(s)}function rs(s){return ee({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(s)}function ns(s){return ee({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(s)}function os(s){return ee({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(s)}function it(){const[s,n]=f.useState(!1),t=e.useEditorStore(c=>c.card.type),{setCardType:r,setCardPreferences:l,setChartOrientation:x}=e.useEditorStore(c=>c.actions),u=e.useEditorStore(c=>c.actions.setCardCustomCfg);function o(c){u(null),l({}),r(c),n(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(at,{className:"h-4 w-4",chartType:t})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(De,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(rs,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ts,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ss,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ke,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ze,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Xe,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(es,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(os,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Pe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ns,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Te,{className:"size-4"})})]})})]})}function at({chartType:s,className:n}){switch(s){case"bar":return e.jsxRuntimeExports.jsx(De,{className:n});case"line":return e.jsxRuntimeExports.jsx(Le,{className:n});case"pie":return e.jsxRuntimeExports.jsx(Ke,{className:n});case"radar":return e.jsxRuntimeExports.jsx(Xe,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Ge,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(ss,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(Ze,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(rs,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(ts,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(es,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(os,{className:n});case"range":return e.jsxRuntimeExports.jsx(Pe,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(ns,{className:n});case"text":return e.jsxRuntimeExports.jsx(Te,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function lt(){const s=e.useEditorStore(t=>t.card.refreshInterval),n=e.useEditorStore(t=>t.actions.setCardRefreshInterval);return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ds,{className:"w-4 h-4"})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px]",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),e.jsxRuntimeExports.jsx(e.Input,{value:s||"",onChange:t=>n(t.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function Ve(){e.useEditorStore(o=>o.frame);const s=e.useEditorStore(o=>o.card),n=e.useEditorStore(o=>o.card.data),t=e.useEditorStore(o=>o.isShowingVisual),r=e.useEditorStore(o=>o.isSqlRunning),l=e.useEditorStore(o=>o.queryError),x=e.useEditorStore(o=>o.pythonStdOut);if(e.useEditorStore(o=>o.onSave),e.useEditorStore(o=>o.onClose),e.useEditorStore(o=>o.actions.setCardSql),e.useEditorStore(o=>o.actions.setCardType),e.useEditorStore(o=>o.actions.setSqlGen),!s)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function u(){return s.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:r,card:s})})}):s.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:r,card:s})})}):e.jsxRuntimeExports.jsx(Ye,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[r&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[t&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(it,{}),s.type!=="table"&&e.jsxRuntimeExports.jsx(ot,{}),e.jsxRuntimeExports.jsx(lt,{})]}),e.jsxRuntimeExports.jsx(xt,{})]}),t?u():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[x&&e.jsxRuntimeExports.jsx(ct,{}),s.data&&s.data.length>0&&e.jsxRuntimeExports.jsx(nt,{data:n||[]}),l&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:l})]})]})}function ct(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const n=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function xt(){const s=e.useEditorStore(t=>t.isShowingVisual),n=e.useEditorStore(t=>t.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:s,onCheckedChange:()=>n(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function de(){const[s,n]=f.useState([]);e.useEditorStore(d=>d.card.cfg);const t=e.useEditorStore(d=>d.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:l,setCardPreferences:x}=e.useEditorStore(d=>d.actions),u=e.useEditorStore(d=>d.queryResultColumns);e.useEditorStore(d=>{var j;return(j=d.card.preferences)==null?void 0:j.filterOnClickColumnIndex}),f.useEffect(()=>{u&&n(new Array(u.length).fill(!1))},[u]);function o(d,j){var y,a;j?t!=null&&t.onClickFilter&&((y=t==null?void 0:t.onClickFilter)==null?void 0:y.length)>0?x({...t,onClickFilter:[...t.onClickFilter,{columnIndex:d,expression:""}]}):x({...t,onClickFilter:[{columnIndex:d,expression:""}]}):(x({...t,onClickFilter:(a=t==null?void 0:t.onClickFilter)==null?void 0:a.filter(m=>m.columnIndex!==d)}),n(m=>{const h=[...m];return h[d]=!1,h}))}function c(d,j){var a;const y=(a=t==null?void 0:t.onClickFilter)==null?void 0:a.map(m=>m.columnIndex===d?{...m,expression:j.target.value}:m);x({...t,onClickFilter:y})}function p(d){var j,y,a,m;if(s!=null&&s[d]||(y=(j=t==null?void 0:t.onClickFilter)==null?void 0:j.find(h=>h.columnIndex===d))!=null&&y.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(a=t==null?void 0:t.onClickFilter)==null?void 0:a.find(h=>h.columnIndex===d))==null?void 0:m.expression,onChange:h=>c(d,h),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:u==null?void 0:u.map((d,j)=>{var y,a;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((y=t==null?void 0:t.onClickFilter)!=null&&y.find(m=>m.columnIndex===j)),onCheckedChange:m=>o(j,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:d}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((a=t==null?void 0:t.onClickFilter)==null?void 0:a.find(m=>m.columnIndex===j))&&e.jsxRuntimeExports.jsx($e,{onClick:()=>{n(m=>{const h=[...m];return h[j]=!m[j],h})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),p(j)]})},d)})})}function Ce(){var u,o,c;const s=e.useEditorStore(p=>p.card.preferences),n=e.useEditorStore(p=>p.card.cfg),{setCardCfg:t,setCardPreferences:r,setChartOrientation:l}=e.useEditorStore(p=>p.actions);(u=n==null?void 0:n.options)!=null&&u.indexAxis;function x(p){l(p)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((o=s==null?void 0:s.chartOptions)==null?void 0:o.indexAxis)||((c=n==null?void 0:n.options)==null?void 0:c.indexAxis)||"x",onValueChange:x,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const xe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function _e(s,n){var r,l,x;const t=e.getNumberAxis(s,n);return((x=(l=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:l[t])==null?void 0:x.type)||"linear"}function is(){var K,B,G,F,Q,b;const[s,n]=f.useState(!1),t=e.useEditorStore(E=>{var k;return(k=E.card)==null?void 0:k.preferences}),r=e.useEditorStore(E=>{var k;return(k=E.card)==null?void 0:k.cfg}),l=e.getNumberAxis(t,r),[x,u]=f.useState(_e(t)),[o,c]=f.useState(((G=(B=(K=t==null?void 0:t.chartOptions)==null?void 0:K.scales)==null?void 0:B[l])==null?void 0:G.min)||""),[p,d]=f.useState(((b=(Q=(F=t==null?void 0:t.chartOptions)==null?void 0:F.scales)==null?void 0:Q[l])==null?void 0:b.max)||""),[j,y]=f.useState(o||p?"custom":"auto"),[a,m]=f.useState(""),[h,v]=f.useState(0),[S,z]=f.useState(""),[R,A]=f.useState(""),[g,C]=f.useState(""),w=e.useEditorStore(E=>E.actions.setCardPreferences),L=e.useEditorStore(E=>{var k;return(k=E.card)==null?void 0:k.type}),N=["pie","doughnut","polarArea"].includes(L);f.useEffect(()=>{var E,k,T,se,$,I,V,P,ne,te,O,U,J,oe;u(_e(t)),c(((T=(k=(E=t==null?void 0:t.chartOptions)==null?void 0:E.scales)==null?void 0:k[l])==null?void 0:T.min)===0?0:""),d(((I=($=(se=t==null?void 0:t.chartOptions)==null?void 0:se.scales)==null?void 0:$[l])==null?void 0:I.max)||""),m(((te=(ne=(P=(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales)==null?void 0:P[l])==null?void 0:ne.ticks)==null?void 0:te.stepSize)||""),v(((O=t==null?void 0:t.numberAxisFormat)==null?void 0:O.decimalPlaces)||0),z(((U=t==null?void 0:t.numberAxisFormat)==null?void 0:U.suffix)||""),A(((J=t==null?void 0:t.numberAxisFormat)==null?void 0:J.currency)||""),C(((oe=t==null?void 0:t.numberAxisFormat)==null?void 0:oe.locale)||"")},[s,t,l]);function M(E,k){return k===""||/^[0-9\b]+$/.test(k)?Number(k):Number(E)}function q(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:R,placeholder:"USD",onChange:E=>A(E.target.value),id:"currency",className:`col-span-2 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:g,placeholder:"en-US",onChange:E=>C(E.target.value),id:"locale",className:`col-span-2 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:E=>v(Number(E.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${xe}`})]})]})}function D(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:o,onChange:E=>c(k=>M(k,E.target.value)),className:`col-span-1 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:p,onChange:E=>d(k=>M(k,E.target.value)),id:"max",className:`col-span-1 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:a,onChange:E=>m(k=>M(k,E.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${xe}`})]})]})}function H(){var T;let E={};j==="custom"&&(E={min:o,max:p,ticks:{stepSize:a}});const k={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(T=t==null?void 0:t.chartOptions)==null?void 0:T.scales,[l]:{type:x,...x==="linear"?E:{}}}},numberAxisFormat:{decimalPlaces:h,suffix:S,currency:R,locale:g}};console.log(k),w(k)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:E=>n(E),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:N,value:x,onValueChange:E=>u(E),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),x=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:N,id:"scale-option",value:j,onValueChange:E=>y(E),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),j==="custom"&&x=="linear"&&D(),q(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:H,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function ut({idx:s}){var o;const n=e.useEditorStore(c=>{var p;return(p=c.card)==null?void 0:p.preferences}),t=e.useEditorStore(c=>{var p;return(p=c.card.preferences)==null?void 0:p.datasetOptions}),r=e.useEditorStore(c=>c.actions.setCardPreferences),l=(o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis,x=t==null?void 0:t.find(c=>c.idx===s);function u(c,p){(c==="end"||c==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const d={display:c!=="none",align:c,anchor:c,clamp:!0};if(!x)r({...n,datasetOptions:[...t||[],{idx:p,datalabels:d}]});else{const j={...x};j.datalabels=d;const y=t==null?void 0:t.map(a=>a.idx===p?j:a);r({...n,datasetOptions:y})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(Ls,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(Ss,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(vs,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ys,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})})]})})]})}function as(){const s=e.useEditorStore(c=>c.card),n=e.useEditorStore(c=>{var p,d,j;return(j=(d=(p=c==null?void 0:c.card)==null?void 0:p.preferences)==null?void 0:d.chartOptions)==null?void 0:j.indexAxis}),t=n==="y"?"Y axis":"X axis",r=n==="y"?"X axis":"Y axis",{keys:l,metricKeys:x,dimensionKeys:u}=e.getKeys(s.data||[]);let o=x;if(["stackedBar","stackedLine"].includes(s.type)){const c=e.pivotData({dataArray:s.data||[],groupKey:u[0],pivotKey:u[1],valueKey:o[0]}),{metricKeys:p}=e.getKeys(c);o=p}return l.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:t}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:u[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(is,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:o.map((c,p)=>e.jsxRuntimeExports.jsx(dt,{col:c,idx:p},c))})]})]})}function dt({col:s,idx:n}){const t=e.useEditorStore(o=>{var c;return(c=o.card)==null?void 0:c.preferences}),r=e.useEditorStore(o=>{var c;return(c=o.card.preferences)==null?void 0:c.datasetOptions}),l=r==null?void 0:r.find(o=>o.idx===n),{setCardPreferences:x}=e.useEditorStore(o=>o.actions);function u(o){if(!l)x({...t,datasetOptions:[...r||[],{idx:n,type:o==="area"?"line":o,fill:o==="area"?"origin":""}]});else{const c={...l};c.type=o==="area"?"line":o,c.fill=o==="area"?"origin":"";const p=r==null?void 0:r.map(d=>d.idx===n?c:d);x({...t,datasetOptions:p})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(De,{onClick:()=>u("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Le,{onClick:()=>u("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ms,{onClick:()=>u("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ut,{idx:n})]})]})}function mt({cardType:s}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ce,{}),e.jsxRuntimeExports.jsx(as,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function Fe(){var l,x,u;const s=e.useEditorStore(o=>o.card.cfg),n=e.useEditorStore(o=>o.actions.setCardCfg),t=e.useEditorStore(o=>o.card.type);function r(o){var d;const c={datalabels:{display:o!=="none",align:o,anchor:o,clamp:!0}},p={...s,options:{...s==null?void 0:s.options,plugins:{...(d=s==null?void 0:s.options)==null?void 0:d.plugins,...c}}};n(p),console.log(o)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(t)&&e.jsxRuntimeExports.jsx(is,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(u=(x=(l=s==null?void 0:s.options)==null?void 0:l.plugins)==null?void 0:x.datalabels)==null?void 0:u.anchor,onValueChange:r,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function pt({cardType:s}){function n(t){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",l="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:t==="bubble"?r:l}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:x=>x.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(s)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Fe,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}const ht={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},jt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Et(){const s=e.useEditorStore(n=>n.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:ft(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(Ce,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(Fe,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(de,{})})]})}function ft(s){if(["line","bar"].includes(s))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(ht,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(jt,null,2)})]})]})]});if(s==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function gt(){var c,p,d,j,y;const s=e.useEditorStore(a=>a.card.preferences),n=e.useEditorStore(a=>a.actions.setCardPreferences),t=e.useEditorStore(a=>a.actions.setNumberFormat);e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.decimalPlaces});const r=e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.locale}),l=e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.currency});e.useEditorStore(a=>a.actions.setFilterOnClickField);const x=e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.colorRanges})||[],u=e.useEditorStore(a=>a.actions.setColorRanges),o=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(a=>a.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((c=s==null?void 0:s.formatNumber)!=null&&c.enabled),onCheckedChange:a=>{n({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:a}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((p=s==null?void 0:s.formatNumber)==null?void 0:p.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:r||"en-US",onValueChange:a=>{var m,h,v;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",a||"en-US",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.locale,children:a.locale},a.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:l||"none",onValueChange:a=>{var m,h,v;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,a==="none"?"":a,((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),o.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((j=(d=s==null?void 0:s.formatNumber)==null?void 0:d.decimalPlaces)==null?void 0:j.toString())||"0",onValueChange:a=>{var m,h,v;return t(Number(a),((m=s==null?void 0:s.formatNumber)==null?void 0:m.currency)||"",((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:a=>{var m,h,v;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.locale)||"",a.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:x,setColorRanges:u})]})]})}function Rt(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(gt,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function bt(){var r;const s=e.useEditorStore(l=>l.card.preferences),{setCardPreferences:n}=e.useEditorStore(l=>l.actions);function t(l){n({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:l==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(r=s==null?void 0:s.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:t,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function be({cardType:s,docContent:n,suffix:t="Chart"}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} ${t}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:n||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[s==="range"&&e.jsxRuntimeExports.jsx(Ce,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Fe,{}),s==="text"&&e.jsxRuntimeExports.jsx(bt,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function St(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ce,{}),e.jsxRuntimeExports.jsx(as,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function yt({}){const s=e.useEditorStore(r=>{var l;return(l=r.card)==null?void 0:l.preferences}),n=e.useEditorStore(r=>r.actions.setCardPreferences),t=r=>{n({...s,allowDownload:r})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const vt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),Ct=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Nt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function kt(){const s=e.useEditorStore(t=>t.card.type);function n(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(St,{});case"pyramid":return e.jsxRuntimeExports.jsx(be,{docContent:vt,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Rt,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(mt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(be,{docContent:Ct,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(be,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(pt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(yt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(be,{docContent:Nt,cardType:t,suffix:"Visual"});default:return e.jsxRuntimeExports.jsx(Et,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(s)})}function wt(){const s=e.useEditorStore(n=>n.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(rt,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:s?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(kt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(Ve,{})})]}):e.jsxRuntimeExports.jsx(Ve,{})})]})}function At({authToken:s,onSave:n,onClose:t}){const r=e.useEditorStore(u=>u.actions.setOnSave),l=e.useEditorStore(u=>u.actions.setOnClose),x=e.useDashboardStore(u=>u.actions.setAuthToken);return f.useEffect(()=>{n&&r(n),t&&l(t)},[n,r,t,l]),f.useEffect(()=>{s&&s.accessToken&&x(s)},[s,x]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Ue,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(wt,{})})]})}function It(){e.useDashboardStore(u=>u.selectedCardId);const s=e.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(u=>u.actions),t=e.useDashboardStore(u=>u.isVisualEditing),r=e.useDashboardStore(u=>u.actions.updateFrame);function l(u){s&&(r(s,u),n(!1))}function x(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(At,{onSave:l,onClose:x})})}function zt({columns:s,tableName:n}){const t=e.useEditorStore(a=>a.selectedConnectionId),r=e.useEditorStore(a=>a.selectedDatamodelId),l=e.useEditorStore(a=>a.selectedDatabaseName),x=e.useEditorStore(a=>a.selectedSchemaName),u=e.useEditorStore(a=>a.selectedTableName),o=e.useDashboardStore(a=>a.dashboard.filters)||[],c=e.useDashboardStore(a=>a.actions.addFilter),p=e.useDashboardStore(a=>a.actions.removeFilter),d=e.useDashboardStore(a=>a.actions.removeFilterValue),{modelItems:j}=ve();function y(a){var C;const m=e.fmt(a.column_name),h=e.fmt(l||""),v=e.fmt(x||""),S=e.fmt(n);let z=e.getQualifiedTableName(v,S),R=`${z}.${m}`;const A=(C=j==null?void 0:j.find(w=>w.id===r))==null?void 0:C.name;r&&r!=="none"&&(R=`d.${A}.${m}`,z=`d.${A}`),console.log("find",R,S,h);const g=o==null?void 0:o.find(w=>w.column===R&&w.table===S&&(w.database===h||w.database===l));if(g)d(g.id),p(g.id);else{if(n==="api"&&t){c({id:e.v4(),column:R,title:a.column_name,dataType:a.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:e.getDefaultFilterSql(a.data_type,z,m)});return}c({id:e.v4(),column:R,title:a.column_name,dataType:a.data_type,table:u||"",database:l||"",connectionId:t||"",operation:"in",sql:e.getDefaultFilterSql(a.data_type,z,m)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:s==null?void 0:s.map(a=>{const m=o==null?void 0:o.find(h=>h.column===e.fmt(a.column_name)&&h.table===u&&h.database===l);return e.jsxRuntimeExports.jsx("div",{onClick:()=>y(a),className:e.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":m}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Qe,{column:a}),e.jsxRuntimeExports.jsx("span",{children:a.column_name})]})},a.column_name)})})}function Dt(){e.useDashboardStore(n=>n.showFilters);const s=e.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(Ue,{ColumnsComponent:(n,t,r)=>e.jsxRuntimeExports.jsx(zt,{schemaName:n,tableName:t,columns:r})})})]})}function Lt(){e.useDashboardStore(t=>t.dashboard);const s=e.useDashboardStore(t=>t.showFilters),n=e.useDashboardStore(t=>t.isVisualEditing);return e.useDashboardStore(t=>t.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:n,flex:!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Dt,{})})]})}function Tt(){const s=e.useDashboardStore(r=>r.dashboard),n=e.useDashboardStore(r=>r.actions.setDashboard),t=e.useDashboardStore(r=>r.showDashboardJSON);return e.useDashboardStore(r=>r.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:r=>{if(r)try{JSON.parse(r),n(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Ft({showControls:s=!1,showFooter:n=!0,...t}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Tt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Bs,{}),e.jsxRuntimeExports.jsx(It,{}),e.jsxRuntimeExports.jsx(Lt,{})]})]})]})}exports.DashboardPlus=Ft;exports.SelectComponent=ue;exports.useEditorAside=ve;
215
+ Visual Query Syntax: ${Qs}`,{data:C,isLoading:w,isFetching:L,isError:N,refetch:O}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(c==null?void 0:c.accessToken)||"",{user_content:`userContent: ${A} ${p?g:""}`}),enabled:!1});function q(b){if(b.toLowerCase().includes("bar"))m("bar");else if(b.toLowerCase().includes("line"))m("line");else if(b.toLowerCase().includes("bubble"))m("bubble");else if(b.toLowerCase().includes("scatter"))m("scatter");else if(b.toLowerCase().includes("stacked"))m("stackedBar");else if(b.toLowerCase().includes("pie"))m("pie");else if(b.toLowerCase().includes("donut")||b.toLowerCase().includes("doughnut"))m("doughnut");else if(b.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}f.useEffect(()=>{C&&v(b=>[...b,{role:"ai",content:C.response}])},[C]),f.useEffect(()=>{const b=setTimeout(()=>{var E;o.current&&(o.current.scroll({top:o.current.scrollHeight,behavior:"smooth"}),(E=u.current)==null||E.focus())},100);return()=>clearTimeout(b)},[h]);function D(){t&&(v(b=>[...b,{role:"user",content:t}]),q(t)&&d(!0),r(""),O())}f.useEffect(()=>{l&&(D(),x(!1))},[l,x]);const H={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},K={fontFamily:"monospace",fontSize:14,lineHeight:1.6},B={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},G={p:({node:b,...E})=>e.jsxRuntimeExports.jsx("p",{style:H,...E}),code:({node:b,...E})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...E}),pre:({node:b,...E})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:K,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:E.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:F,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:k=>{const T=F(k);T&&(n(!1),j(T),a(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:b,...E})=>e.jsxRuntimeExports.jsx("li",{style:B,...E})};function F(b){const E=b.currentTarget.closest("pre");if(!E)return;const k=E.textContent||E.innerText;return navigator.clipboard.writeText(k).then(()=>console.log("Text copied to clipboard")).catch(T=>console.error("Error in copying text: ",T)),k}function Q(){return h==null?void 0:h.map((b,E)=>b.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Fs,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:b.content})]},E):b.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:G,children:C==null?void 0:C.response.replace(/DuckDB/gi,"Semaphor")},E):e.jsxRuntimeExports.jsx("div",{},E))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:o,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:Q()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:u,onKeyDown:b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),r(""),D())},placeholder:"Type your question here...",onFocus:b=>{const E=b.target,k=E.value.length;E.setSelectionRange(k,k)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:w||L,value:t,onChange:b=>r(b.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:D,children:!w&&!L?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Je={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},qe=f.createContext&&f.createContext(Je),Js=["attr","size","title"];function Ws(s,n){if(s==null)return{};var t=Ys(s,n),r,l;if(Object.getOwnPropertySymbols){var x=Object.getOwnPropertySymbols(s);for(l=0;l<x.length;l++)r=x[l],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(t[r]=s[r])}return t}function Ys(s,n){if(s==null)return{};var t={},r=Object.keys(s),l,x;for(x=0;x<r.length;x++)l=r[x],!(n.indexOf(l)>=0)&&(t[l]=s[l]);return t}function Se(){return Se=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},Se.apply(this,arguments)}function Be(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);n&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(s,l).enumerable})),t.push.apply(t,r)}return t}function ye(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?Be(Object(t),!0).forEach(function(r){Xs(s,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Be(Object(t)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(t,r))})}return s}function Xs(s,n,t){return n=Zs(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Zs(s){var n=et(s,"string");return typeof n=="symbol"?n:String(n)}function et(s,n){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var r=t.call(s,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(s)}function We(s){return s&&s.map((n,t)=>f.createElement(n.tag,ye({key:t},n.attr),We(n.child)))}function ee(s){return n=>f.createElement(st,Se({attr:ye({},s.attr)},n),We(s.child))}function st(s){var n=t=>{var{attr:r,size:l,title:x}=s,u=Ws(s,Js),o=l||t.size||"1em",c;return t.className&&(c=t.className),s.className&&(c=(c?c+" ":"")+s.className),f.createElement("svg",Se({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,u,{className:c,style:ye(ye({color:s.color||t.color},t.style),s.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),x&&f.createElement("title",null,x),s.children)};return qe!==void 0?f.createElement(qe.Consumer,null,t=>n(t)):n(Je)}function tt(s){return ee({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(s)}function rt(){const{theme:s}=e.useTheme(),n=f.useRef(),t=f.useRef(),[r,l]=f.useState(!1),[x,u]=f.useState(!1),[o,c]=f.useState(!1),[p,d]=f.useState(""),[j,y]=f.useState(!1),{authToken:a}=e.useSemaphorContext();e.useDashboardStore(i=>i.selectedSheetId);const m=e.useDashboardStore(i=>i.dashboard.baseQueries),h=e.useEditorStore(i=>i.card),v=e.useDashboardStore(i=>i.theme),S=e.useEditorStore(i=>i.isShowingVisual),z=e.useEditorStore(i=>i.selectedConnectionId),R=e.useEditorStore(i=>i.selectedDatabaseName),A=e.useEditorStore(i=>i.selectedDatamodelId),g=e.useEditorStore(i=>i.selectedSchemaName);e.useDashboardStore(i=>i.actions.updateFrameCard);const C=e.useEditorStore(i=>i.selectedTableName),w=e.useEditorStore(i=>i.card.sql),L=e.useEditorStore(i=>i.card.python),N=e.resolveBaseQuery(w,m),O=e.useEditorStore(i=>i.selectedConnectionId),q=e.useEditorStore(i=>i.frame),D=e.useEditorStore(i=>i.filterValues),H=e.useEditorStore(i=>i.applyFilters),{setCardCustomCfg:K,setQueryResultColumns:B,setFilterValues:G,setCardSql:F,setCardPython:Q,setQueryError:b,setPythonStdOut:E,setCardPreferences:k}=e.useEditorStore(i=>i.actions),T=e.useEditorStore(i=>i.onSave),se=e.useEditorStore(i=>i.actions.setApplyFilters),$=e.useEditorStore(i=>i.onClose),I=e.useEditorStore(i=>i.actions.setCardData),V=e.useEditorStore(i=>i.actions.setSqlGen),P=e.useEditorStore(i=>i.runSql),ne=e.useEditorStore(i=>i.actions.setRunSql),te=e.useEditorStore(i=>i.actions.setIsSqlRunning),{data:M,isLoading:U,isFetching:J,isSuccess:oe,isError:ae,error:me,status:Oe,refetch:le}=e.useQuery({queryKey:[N,L],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(a==null?void 0:a.accessToken)||"",{connection_id:O,sql:N,python:L===e.PYTHON_DEFAULT_CODE?"":L,active_filters:H?D:[]}),enabled:!1,retry:!1});f.useEffect(()=>{if(M&&(I(M.records),M.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),E((M==null?void 0:M.output)||""),M.records.length>0)){const{dimensionKeys:i}=e.getKeys(M.records);B(i)}},[M,I,B,E]),f.useEffect(()=>{P&&(le(),ne(!1))},[P,le,ne]),f.useEffect(()=>{(U||J)&&te(!0),(ae||oe)&&te(!1),ae?(b(me.message),I([]),B([]),E("")):b("")},[U,J,M,E,ae,oe,te,I,B,b,me]);function Ne(){F(""),I([]),V({}),K(""),k({})}const je=i=>{t.current=i};function ke(){let i=w;w&&!w.includes("{{")&&(i=Hs(w),F(i));const W={...h,lastSelectedSchema:g,lastSelectedDatamodelId:A,lastSelectedDatabase:R,lastSelectedTable:C,connectionId:z,type:S?h.type:"table",sql:i,customCfg:S?h.customCfg:null},he=q.cards.map(ie=>ie.id===h.id?W:ie);T==null||T({...q,cards:he})}function we(){$==null||$()}function Ee(i){const W=getComputedStyle(document.documentElement).getPropertyValue(i);return fe(W)}function fe(i){const[W,he,ie]=i.split(" "),_=parseFloat(W),ls=parseFloat(he),cs=parseFloat(ie),xs=ls/100,Me=cs/100,re=(1-Math.abs(2*Me-1))*xs,ce=re*(1-Math.abs(_/60%2-1)),Ae=Me-re/2;let Y=0,X=0,Z=0;0<=_&&_<60?(Y=re,X=ce,Z=0):60<=_&&_<120?(Y=ce,X=re,Z=0):120<=_&&_<180?(Y=0,X=re,Z=ce):180<=_&&_<240?(Y=0,X=ce,Z=re):240<=_&&_<300?(Y=ce,X=0,Z=re):300<=_&&_<360&&(Y=re,X=0,Z=ce),Y=Math.round((Y+Ae)*255),X=Math.round((X+Ae)*255),Z=Math.round((Z+Ae)*255);const Ie=us=>{const ze=us.toString(16);return ze.length==1?"0"+ze:ze};return`#${Ie(Y)}${Ie(X)}${Ie(Z)}`}f.useEffect(()=>{const i=n.current,W=t.current;if(i){const he=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",ie=v==="system"?he:v;i.editor.defineTheme("default",{base:ie==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":ie==="light"?"#ffffff":Ee("--semaphor-background")}}),i.editor.setTheme("default")}return W&&i&&W.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return console.log("Executing query..."),le(),!1}),()=>{}},[s,v,n.current]);function pe(i){n.current=i}function ge(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx($s,{checked:H,onCheckedChange:()=>se(!H),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Gs,{}),D&&x&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>u(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:i=>{if(i)try{JSON.parse(i),G(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(D,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),D&&!x&&e.jsxRuntimeExports.jsx(He,{onClick:()=>u(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":H})})]})}function Re(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:i=>{F(i)},value:w,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:pe,onMount:je})}),r&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),r&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:i=>{Q(i&&i.trim()||"")},value:L||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:pe,onMount:je})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[Re(),ge()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:U||J,onClick:()=>{le()},className:"shrink-0",size:"sm",variant:"outline",children:[U||J?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(ks,{className:"mr-2 h-4 w-4"}),"Run"]}),ae&&e.jsxRuntimeExports.jsx(Ps,{error:me.message,setShowAIDialog:c,setTriggerAIRun:y,setUserInputforAI:d}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ne,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Es,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:r,onPressedChange:i=>l(i),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(tt,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Us,{open:o,setOpen:c,userInput:p,triggerAIRun:j,setTriggerAIRun:y,setUserInput:i=>d(i)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:ke,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:we,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function nt({data:s}){var u;const[n,t]=f.useState([]),l=Object.keys(s[0]).map(o=>({accessorKey:o,header:({column:c})=>{const p=c.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>c.toggleSorting(c.getIsSorted()==="asc"),children:[o,p==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):p==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),x=e.useReactTable({data:s,columns:l,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:x.getHeaderGroups().map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{children:o.headers.map(c=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:c.isPlaceholder?null:e.flexRender(c.column.columnDef.header,c.getContext())},c.id))},o.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(u=x.getRowModel().rows)!=null&&u.length?x.getRowModel().rows.map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":o.getIsSelected()&&"selected",children:o.getVisibleCells().map(c=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(c.column.columnDef.cell,c.getContext())},c.id))},o.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:l.length,className:"h-24 text-center",children:"No results."})})})]})}function Ye({className:s,...n}){var u;f.useState(0);const t=e.useDashboardStore(o=>o.themeStyle),r=e.useEditorStore(o=>o.card),l=e.useEditorStore(o=>o.actions.setCard);if(f.useEffect(()=>{},[r.data,r.type,r.cfg,r.customCfg,t,r.preferences]),!r.id)return null;let x;return r.data&&r.data.length>0&&(x=e.createChartConfig({data:r.data,cardType:r.type,cfg:r.cfg,customCfg:r.customCfg,preferences:r.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...n,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:r.title,onSave:o=>l({...r,title:o}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:r.title})})},r.title),e.jsxRuntimeExports.jsx(e.Editable,{text:r.description||"",onSave:o=>l({...r,description:o}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",r.description]})},r.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[r.type!=="table"&&x&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x},JSON.stringify(x)+JSON.stringify(r.preferences)+((u=r==null?void 0:r.preferences)==null?void 0:u.customVisualCode)),r.type==="table"&&r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:r,data:r==null?void 0:r.data})})]})]})}function ot(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),[l,x]=f.useState(""),[u,o]=f.useState(""),[c,p]=f.useState(""),d=e.useEditorStore(R=>R.card),j=e.useEditorStore(R=>R.card.customCfg),{setCardCustomCfg:y,setCustomVisualCode:a}=e.useEditorActions();function m(R){var C,w;const A={...R,data:{...R==null?void 0:R.data,datasets:(w=(C=R==null?void 0:R.data)==null?void 0:C.datasets)==null?void 0:w.map(L=>({...L,data:[]}))}};return JSON.stringify(A,null,1)}function h(){var A,g;if(!d.data||d.data.length===0)return;const R=e.createChartConfig({data:d.data,cardType:d.type,cfg:d.cfg,preferences:d.preferences});R&&(r(JSON.stringify(R,null,1)),(A=d==null?void 0:d.preferences)!=null&&A.customVisualCode&&o((g=d==null?void 0:d.preferences)==null?void 0:g.customVisualCode),j&&x(JSON.stringify(j,null,1)))}function v(){if(u&&a(u),!!l)try{const R=JSON.parse(l);return R?(y(R),p(""),x(""),R):void 0}catch(R){console.log(R),p("Invalid JSON")}}function S(){x(""),y(null)}function z(){let R;if(j){const A=e._.cloneDeep(d.cfg),g=e._.merge(A,j);return R=m(g),R}return t?(R=m(JSON.parse(t)),R):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:h,className:` ${j&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(bs,{onClick:()=>{navigator.clipboard.writeText(d.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Ye,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[j&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),j?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:z(),onChange:R=>x(R)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:u,onChange:R=>o(R||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:c}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!j,onClick:S,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:v,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Xe(s){return ee({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(s)}function Ze(s){return ee({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(s)}function es(s){return ee({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(s)}function ss(s){return ee({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(s)}function ts(s){return ee({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(s)}function rs(s){return ee({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(s)}function ns(s){return ee({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(s)}function os(s){return ee({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(s)}function it(){const[s,n]=f.useState(!1),t=e.useEditorStore(c=>c.card.type),{setCardType:r,setCardPreferences:l,setChartOrientation:x}=e.useEditorStore(c=>c.actions),u=e.useEditorStore(c=>c.actions.setCardCustomCfg);function o(c){u(null),l({}),r(c),n(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(at,{className:"h-4 w-4",chartType:t})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(De,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(rs,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ts,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ss,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ke,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ze,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Xe,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(es,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(os,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Pe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ns,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Te,{className:"size-4"})})]})})]})}function at({chartType:s,className:n}){switch(s){case"bar":return e.jsxRuntimeExports.jsx(De,{className:n});case"line":return e.jsxRuntimeExports.jsx(Le,{className:n});case"pie":return e.jsxRuntimeExports.jsx(Ke,{className:n});case"radar":return e.jsxRuntimeExports.jsx(Xe,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Ge,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(ss,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(Ze,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(rs,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(ts,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(es,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(os,{className:n});case"range":return e.jsxRuntimeExports.jsx(Pe,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(ns,{className:n});case"text":return e.jsxRuntimeExports.jsx(Te,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function lt(){const s=e.useEditorStore(t=>t.card.refreshInterval),n=e.useEditorStore(t=>t.actions.setCardRefreshInterval);return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ds,{className:"w-4 h-4"})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px]",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),e.jsxRuntimeExports.jsx(e.Input,{value:s||"",onChange:t=>n(t.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function Ve(){e.useEditorStore(o=>o.frame);const s=e.useEditorStore(o=>o.card),n=e.useEditorStore(o=>o.card.data),t=e.useEditorStore(o=>o.isShowingVisual),r=e.useEditorStore(o=>o.isSqlRunning),l=e.useEditorStore(o=>o.queryError),x=e.useEditorStore(o=>o.pythonStdOut);if(e.useEditorStore(o=>o.onSave),e.useEditorStore(o=>o.onClose),e.useEditorStore(o=>o.actions.setCardSql),e.useEditorStore(o=>o.actions.setCardType),e.useEditorStore(o=>o.actions.setSqlGen),!s)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function u(){return s.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:r,card:s})})}):s.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:r,card:s})})}):e.jsxRuntimeExports.jsx(Ye,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[r&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[t&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(it,{}),s.type!=="table"&&e.jsxRuntimeExports.jsx(ot,{}),e.jsxRuntimeExports.jsx(lt,{})]}),e.jsxRuntimeExports.jsx(xt,{})]}),t?u():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[x&&e.jsxRuntimeExports.jsx(ct,{}),s.data&&s.data.length>0&&e.jsxRuntimeExports.jsx(nt,{data:n||[]}),l&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:l})]})]})}function ct(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const n=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function xt(){const s=e.useEditorStore(t=>t.isShowingVisual),n=e.useEditorStore(t=>t.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:s,onCheckedChange:()=>n(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function de(){const[s,n]=f.useState([]);e.useEditorStore(d=>d.card.cfg);const t=e.useEditorStore(d=>d.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:l,setCardPreferences:x}=e.useEditorStore(d=>d.actions),u=e.useEditorStore(d=>d.queryResultColumns);e.useEditorStore(d=>{var j;return(j=d.card.preferences)==null?void 0:j.filterOnClickColumnIndex}),f.useEffect(()=>{u&&n(new Array(u.length).fill(!1))},[u]);function o(d,j){var y,a;j?t!=null&&t.onClickFilter&&((y=t==null?void 0:t.onClickFilter)==null?void 0:y.length)>0?x({...t,onClickFilter:[...t.onClickFilter,{columnIndex:d,expression:""}]}):x({...t,onClickFilter:[{columnIndex:d,expression:""}]}):(x({...t,onClickFilter:(a=t==null?void 0:t.onClickFilter)==null?void 0:a.filter(m=>m.columnIndex!==d)}),n(m=>{const h=[...m];return h[d]=!1,h}))}function c(d,j){var a;const y=(a=t==null?void 0:t.onClickFilter)==null?void 0:a.map(m=>m.columnIndex===d?{...m,expression:j.target.value}:m);x({...t,onClickFilter:y})}function p(d){var j,y,a,m;if(s!=null&&s[d]||(y=(j=t==null?void 0:t.onClickFilter)==null?void 0:j.find(h=>h.columnIndex===d))!=null&&y.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(a=t==null?void 0:t.onClickFilter)==null?void 0:a.find(h=>h.columnIndex===d))==null?void 0:m.expression,onChange:h=>c(d,h),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:u==null?void 0:u.map((d,j)=>{var y,a;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((y=t==null?void 0:t.onClickFilter)!=null&&y.find(m=>m.columnIndex===j)),onCheckedChange:m=>o(j,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:d}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((a=t==null?void 0:t.onClickFilter)==null?void 0:a.find(m=>m.columnIndex===j))&&e.jsxRuntimeExports.jsx($e,{onClick:()=>{n(m=>{const h=[...m];return h[j]=!m[j],h})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),p(j)]})},d)})})}function Ce(){var u,o,c;const s=e.useEditorStore(p=>p.card.preferences),n=e.useEditorStore(p=>p.card.cfg),{setCardCfg:t,setCardPreferences:r,setChartOrientation:l}=e.useEditorStore(p=>p.actions);(u=n==null?void 0:n.options)!=null&&u.indexAxis;function x(p){l(p)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((o=s==null?void 0:s.chartOptions)==null?void 0:o.indexAxis)||((c=n==null?void 0:n.options)==null?void 0:c.indexAxis)||"x",onValueChange:x,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const xe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function _e(s,n){var r,l,x;const t=e.getNumberAxis(s,n);return((x=(l=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:l[t])==null?void 0:x.type)||"linear"}function is(){var K,B,G,F,Q,b;const[s,n]=f.useState(!1),t=e.useEditorStore(E=>{var k;return(k=E.card)==null?void 0:k.preferences}),r=e.useEditorStore(E=>{var k;return(k=E.card)==null?void 0:k.cfg}),l=e.getNumberAxis(t,r),[x,u]=f.useState(_e(t)),[o,c]=f.useState(((G=(B=(K=t==null?void 0:t.chartOptions)==null?void 0:K.scales)==null?void 0:B[l])==null?void 0:G.min)||""),[p,d]=f.useState(((b=(Q=(F=t==null?void 0:t.chartOptions)==null?void 0:F.scales)==null?void 0:Q[l])==null?void 0:b.max)||""),[j,y]=f.useState(o||p?"custom":"auto"),[a,m]=f.useState(""),[h,v]=f.useState(0),[S,z]=f.useState(""),[R,A]=f.useState(""),[g,C]=f.useState(""),w=e.useEditorStore(E=>E.actions.setCardPreferences),L=e.useEditorStore(E=>{var k;return(k=E.card)==null?void 0:k.type}),N=["pie","doughnut","polarArea"].includes(L);f.useEffect(()=>{var E,k,T,se,$,I,V,P,ne,te,M,U,J,oe;u(_e(t)),c(((T=(k=(E=t==null?void 0:t.chartOptions)==null?void 0:E.scales)==null?void 0:k[l])==null?void 0:T.min)===0?0:""),d(((I=($=(se=t==null?void 0:t.chartOptions)==null?void 0:se.scales)==null?void 0:$[l])==null?void 0:I.max)||""),m(((te=(ne=(P=(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales)==null?void 0:P[l])==null?void 0:ne.ticks)==null?void 0:te.stepSize)||""),v(((M=t==null?void 0:t.numberAxisFormat)==null?void 0:M.decimalPlaces)||0),z(((U=t==null?void 0:t.numberAxisFormat)==null?void 0:U.suffix)||""),A(((J=t==null?void 0:t.numberAxisFormat)==null?void 0:J.currency)||""),C(((oe=t==null?void 0:t.numberAxisFormat)==null?void 0:oe.locale)||"")},[s,t,l]);function O(E,k){return k===""||/^[0-9\b]+$/.test(k)?Number(k):Number(E)}function q(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:R,placeholder:"USD",onChange:E=>A(E.target.value),id:"currency",className:`col-span-2 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:g,placeholder:"en-US",onChange:E=>C(E.target.value),id:"locale",className:`col-span-2 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:E=>v(Number(E.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${xe}`})]})]})}function D(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:o,onChange:E=>c(k=>O(k,E.target.value)),className:`col-span-1 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:p,onChange:E=>d(k=>O(k,E.target.value)),id:"max",className:`col-span-1 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:a,onChange:E=>m(k=>O(k,E.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${xe}`})]})]})}function H(){var T;let E={};j==="custom"&&(E={min:o,max:p,ticks:{stepSize:a}});const k={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(T=t==null?void 0:t.chartOptions)==null?void 0:T.scales,[l]:{type:x,...x==="linear"?E:{}}}},numberAxisFormat:{decimalPlaces:h,suffix:S,currency:R,locale:g}};console.log(k),w(k)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:E=>n(E),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:N,value:x,onValueChange:E=>u(E),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),x=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:N,id:"scale-option",value:j,onValueChange:E=>y(E),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),j==="custom"&&x=="linear"&&D(),q(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:H,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function ut({idx:s}){var o;const n=e.useEditorStore(c=>{var p;return(p=c.card)==null?void 0:p.preferences}),t=e.useEditorStore(c=>{var p;return(p=c.card.preferences)==null?void 0:p.datasetOptions}),r=e.useEditorStore(c=>c.actions.setCardPreferences),l=(o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis,x=t==null?void 0:t.find(c=>c.idx===s);function u(c,p){(c==="end"||c==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const d={display:c!=="none",align:c,anchor:c,clamp:!0};if(!x)r({...n,datasetOptions:[...t||[],{idx:p,datalabels:d}]});else{const j={...x};j.datalabels=d;const y=t==null?void 0:t.map(a=>a.idx===p?j:a);r({...n,datasetOptions:y})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(Ls,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(Ss,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(vs,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ys,{className:e.cn("h-4 w-4",{"rotate-90":l==="y"})})})]})})]})}function as(){const s=e.useEditorStore(c=>c.card),n=e.useEditorStore(c=>{var p,d,j;return(j=(d=(p=c==null?void 0:c.card)==null?void 0:p.preferences)==null?void 0:d.chartOptions)==null?void 0:j.indexAxis}),t=n==="y"?"Y axis":"X axis",r=n==="y"?"X axis":"Y axis",{keys:l,metricKeys:x,dimensionKeys:u}=e.getKeys(s.data||[]);let o=x;if(["stackedBar","stackedLine"].includes(s.type)){const c=e.pivotData({dataArray:s.data||[],groupKey:u[0],pivotKey:u[1],valueKey:o[0]}),{metricKeys:p}=e.getKeys(c);o=p}return l.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:t}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:u[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(is,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:o.map((c,p)=>e.jsxRuntimeExports.jsx(dt,{col:c,idx:p},c))})]})]})}function dt({col:s,idx:n}){const t=e.useEditorStore(o=>{var c;return(c=o.card)==null?void 0:c.preferences}),r=e.useEditorStore(o=>{var c;return(c=o.card.preferences)==null?void 0:c.datasetOptions}),l=r==null?void 0:r.find(o=>o.idx===n),{setCardPreferences:x}=e.useEditorStore(o=>o.actions);function u(o){if(!l)x({...t,datasetOptions:[...r||[],{idx:n,type:o==="area"?"line":o,fill:o==="area"?"origin":""}]});else{const c={...l};c.type=o==="area"?"line":o,c.fill=o==="area"?"origin":"";const p=r==null?void 0:r.map(d=>d.idx===n?c:d);x({...t,datasetOptions:p})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(De,{onClick:()=>u("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Le,{onClick:()=>u("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ms,{onClick:()=>u("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ut,{idx:n})]})]})}function mt({cardType:s}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ce,{}),e.jsxRuntimeExports.jsx(as,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function Fe(){var l,x,u;const s=e.useEditorStore(o=>o.card.cfg),n=e.useEditorStore(o=>o.actions.setCardCfg),t=e.useEditorStore(o=>o.card.type);function r(o){var d;const c={datalabels:{display:o!=="none",align:o,anchor:o,clamp:!0}},p={...s,options:{...s==null?void 0:s.options,plugins:{...(d=s==null?void 0:s.options)==null?void 0:d.plugins,...c}}};n(p),console.log(o)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(t)&&e.jsxRuntimeExports.jsx(is,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(u=(x=(l=s==null?void 0:s.options)==null?void 0:l.plugins)==null?void 0:x.datalabels)==null?void 0:u.anchor,onValueChange:r,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function pt({cardType:s}){function n(t){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",l="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:t==="bubble"?r:l}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:x=>x.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(s)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Fe,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}const ht={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},jt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Et(){const s=e.useEditorStore(n=>n.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:ft(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(Ce,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(Fe,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(de,{})})]})}function ft(s){if(["line","bar"].includes(s))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(ht,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(jt,null,2)})]})]})]});if(s==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function gt(){var c,p,d,j,y;const s=e.useEditorStore(a=>a.card.preferences),n=e.useEditorStore(a=>a.actions.setCardPreferences),t=e.useEditorStore(a=>a.actions.setNumberFormat);e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.decimalPlaces});const r=e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.locale}),l=e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.currency});e.useEditorStore(a=>a.actions.setFilterOnClickField);const x=e.useEditorStore(a=>{var m,h;return(h=(m=a.card.preferences)==null?void 0:m.formatNumber)==null?void 0:h.colorRanges})||[],u=e.useEditorStore(a=>a.actions.setColorRanges),o=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(a=>a.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((c=s==null?void 0:s.formatNumber)!=null&&c.enabled),onCheckedChange:a=>{n({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:a}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((p=s==null?void 0:s.formatNumber)==null?void 0:p.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:r||"en-US",onValueChange:a=>{var m,h,v;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",a||"en-US",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.locale,children:a.locale},a.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:l||"none",onValueChange:a=>{var m,h,v;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,a==="none"?"":a,((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),o.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((j=(d=s==null?void 0:s.formatNumber)==null?void 0:d.decimalPlaces)==null?void 0:j.toString())||"0",onValueChange:a=>{var m,h,v;return t(Number(a),((m=s==null?void 0:s.formatNumber)==null?void 0:m.currency)||"",((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a,children:a},a))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:a=>{var m,h,v;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.locale)||"",a.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:x,setColorRanges:u})]})]})}function Rt(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(gt,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function bt(){var r;const s=e.useEditorStore(l=>l.card.preferences),{setCardPreferences:n}=e.useEditorStore(l=>l.actions);function t(l){n({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:l==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(r=s==null?void 0:s.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:t,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function be({cardType:s,docContent:n,suffix:t="Chart"}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} ${t}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:n||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[s==="range"&&e.jsxRuntimeExports.jsx(Ce,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Fe,{}),s==="text"&&e.jsxRuntimeExports.jsx(bt,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function St(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Ce,{}),e.jsxRuntimeExports.jsx(as,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})]})})}function yt({}){const s=e.useEditorStore(r=>{var l;return(l=r.card)==null?void 0:l.preferences}),n=e.useEditorStore(r=>r.actions.setCardPreferences),t=r=>{n({...s,allowDownload:r})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(de,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const vt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),Ct=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Nt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function kt(){const s=e.useEditorStore(t=>t.card.type);function n(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(St,{});case"pyramid":return e.jsxRuntimeExports.jsx(be,{docContent:vt,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Rt,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(mt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(be,{docContent:Ct,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(be,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(pt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(yt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(be,{docContent:Nt,cardType:t,suffix:"Visual"});default:return e.jsxRuntimeExports.jsx(Et,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(s)})}function wt(){const s=e.useEditorStore(n=>n.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(rt,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:s?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(kt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(Ve,{})})]}):e.jsxRuntimeExports.jsx(Ve,{})})]})}function At({authToken:s,onSave:n,onClose:t}){const r=e.useEditorStore(u=>u.actions.setOnSave),l=e.useEditorStore(u=>u.actions.setOnClose),x=e.useDashboardStore(u=>u.actions.setAuthToken);return f.useEffect(()=>{n&&r(n),t&&l(t)},[n,r,t,l]),f.useEffect(()=>{s&&s.accessToken&&x(s)},[s,x]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Ue,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(wt,{})})]})}function It(){e.useDashboardStore(u=>u.selectedCardId);const s=e.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(u=>u.actions),t=e.useDashboardStore(u=>u.isVisualEditing),r=e.useDashboardStore(u=>u.actions.updateFrame);function l(u){s&&(r(s,u),n(!1))}function x(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(At,{onSave:l,onClose:x})})}function zt({columns:s,tableName:n}){const t=e.useEditorStore(a=>a.selectedConnectionId),r=e.useEditorStore(a=>a.selectedDatamodelId),l=e.useEditorStore(a=>a.selectedDatabaseName),x=e.useEditorStore(a=>a.selectedSchemaName),u=e.useEditorStore(a=>a.selectedTableName),o=e.useDashboardStore(a=>a.dashboard.filters)||[],c=e.useDashboardStore(a=>a.actions.addFilter),p=e.useDashboardStore(a=>a.actions.removeFilter),d=e.useDashboardStore(a=>a.actions.removeFilterValue),{modelItems:j}=ve();function y(a){var C;const m=e.fmt(a.column_name),h=e.fmt(l||""),v=e.fmt(x||""),S=e.fmt(n);let z=e.getQualifiedTableName(v,S),R=`${z}.${m}`;const A=(C=j==null?void 0:j.find(w=>w.id===r))==null?void 0:C.name;r&&r!=="none"&&(R=`d.${A}.${m}`,z=`d.${A}`),console.log("find",R,S,h);const g=o==null?void 0:o.find(w=>w.column===R&&w.table===S&&(w.database===h||w.database===l));if(g)d(g.id),p(g.id);else{if(n==="api"&&t){c({id:e.v4(),column:R,title:a.column_name,dataType:a.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:e.getDefaultFilterSql(a.data_type,z,m)});return}c({id:e.v4(),column:R,title:a.column_name,dataType:a.data_type,table:u||"",database:l||"",connectionId:t||"",operation:"in",sql:e.getDefaultFilterSql(a.data_type,z,m)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:s==null?void 0:s.map(a=>{const m=o==null?void 0:o.find(h=>h.column===e.fmt(a.column_name)&&h.table===u&&h.database===l);return e.jsxRuntimeExports.jsx("div",{onClick:()=>y(a),className:e.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":m}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Qe,{column:a}),e.jsxRuntimeExports.jsx("span",{children:a.column_name})]})},a.column_name)})})}function Dt(){e.useDashboardStore(n=>n.showFilters);const s=e.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(Ue,{ColumnsComponent:(n,t,r)=>e.jsxRuntimeExports.jsx(zt,{schemaName:n,tableName:t,columns:r})})})]})}function Lt(){e.useDashboardStore(t=>t.dashboard);const s=e.useDashboardStore(t=>t.showFilters),n=e.useDashboardStore(t=>t.isVisualEditing);return e.useDashboardStore(t=>t.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:n,flex:!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Dt,{})})]})}function Tt(){const s=e.useDashboardStore(r=>r.dashboard),n=e.useDashboardStore(r=>r.actions.setDashboard),t=e.useDashboardStore(r=>r.showDashboardJSON);return e.useDashboardStore(r=>r.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:r=>{if(r)try{JSON.parse(r),n(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Ft({showControls:s=!1,showFooter:n=!0,...t}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Tt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Bs,{}),e.jsxRuntimeExports.jsx(It,{}),e.jsxRuntimeExports.jsx(Lt,{})]})]})]})}exports.DashboardPlus=Ft;exports.SelectComponent=ue;exports.useEditorAside=ve;
@@ -4664,6 +4664,7 @@ const _1 = [
4664
4664
  // javascript number
4665
4665
  "integer",
4666
4666
  "int",
4667
+ "int64",
4667
4668
  "bigint",
4668
4669
  "smallint",
4669
4670
  "tinyint",
@@ -4676,7 +4677,8 @@ const _1 = [
4676
4677
  "double precision",
4677
4678
  "float",
4678
4679
  "float4",
4679
- "float8"
4680
+ "float8",
4681
+ "float64"
4680
4682
  ], cm = [
4681
4683
  "date",
4682
4684
  "datetime",
@@ -59,7 +59,7 @@ Check the top-level render call using <`+ue+">.")}return ee}}function ni(T,ee){{
59
59
  */var YE;function lz(){if(YE)return Ob;YE=1;var e=m,t=gw();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return Ob.useSyncExternalStoreWithSelector=function(c,u,f,h,g){var v=i(null);if(v.current===null){var b={hasValue:!1,value:null};v.current=b}else b=v.current;v=a(function(){function x(P){if(!_){if(_=!0,S=P,P=h(P),g!==void 0&&b.hasValue){var $=b.value;if(g($,P))return C=$}return C=P}if($=C,r(S,P))return $;var k=h(P);return g!==void 0&&g($,k)?$:(S=P,C=k)}var _=!1,S,C,E=f===void 0?null:f;return[function(){return x(u())},E===null?void 0:function(){return x(E())}]},[u,f,h,g]);var w=o(c,v[0],v[1]);return s(function(){b.hasValue=!0,b.value=w},[w]),l(w),w},Ob}process.env.NODE_ENV==="production"?h0.exports=lz():h0.exports=az();var cz=h0.exports;const uz=nu(cz);var J2={VITE_SEMAPHOR_API:"https://semaphor.cloud/api/v1",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{useDebugValue:dz}=m,{useSyncExternalStoreWithSelector:fz}=uz;let KE=!1;function hz(e,t=e.getState,n){(J2?"production":void 0)!=="production"&&n&&!KE&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),KE=!0);const r=fz(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return dz(r),r}const XE=e=>{(J2?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?oz(e):e,n=(r,o)=>hz(t,r,o);return Object.assign(n,t),n},Z2=e=>e?XE(e):XE;var eD=Symbol.for("immer-nothing"),QE=Symbol.for("immer-draftable"),ao=Symbol.for("immer-state"),pz=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Mr(e,...t){if(process.env.NODE_ENV!=="production"){const n=pz[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var jc=Object.getPrototypeOf;function zc(e){return!!e&&!!e[ao]}function fl(e){var t;return e?tD(e)||Array.isArray(e)||!!e[QE]||!!((t=e.constructor)!=null&&t[QE])||nm(e)||rm(e):!1}var gz=Object.prototype.constructor.toString();function tD(e){if(!e||typeof e!="object")return!1;const t=jc(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===gz}function Ed(e,t){tm(e)===0?Object.entries(e).forEach(([n,r])=>{t(n,r,e)}):e.forEach((n,r)=>t(r,n,e))}function tm(e){const t=e[ao];return t?t.type_:Array.isArray(e)?1:nm(e)?2:rm(e)?3:0}function p0(e,t){return tm(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function nD(e,t,n){const r=tm(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function mz(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function nm(e){return e instanceof Map}function rm(e){return e instanceof Set}function La(e){return e.copy_||e.base_}function g0(e,t){if(nm(e))return new Map(e);if(rm(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&tD(e))return jc(e)?{...e}:Object.assign(Object.create(null),e);const n=Object.getOwnPropertyDescriptors(e);delete n[ao];let r=Reflect.ownKeys(n);for(let o=0;o<r.length;o++){const i=r[o],s=n[i];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(n[i]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[i]})}return Object.create(jc(e),n)}function mw(e,t=!1){return om(e)||zc(e)||!fl(e)||(tm(e)>1&&(e.set=e.add=e.clear=e.delete=vz),Object.freeze(e),t&&Ed(e,(n,r)=>mw(r,!0))),e}function vz(){Mr(2)}function om(e){return Object.isFrozen(e)}var bz={};function hl(e){const t=bz[e];return t||Mr(0,e),t}var Rd;function rD(){return Rd}function yz(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function JE(e,t){t&&(hl("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function m0(e){v0(e),e.drafts_.forEach(xz),e.drafts_=null}function v0(e){e===Rd&&(Rd=e.parent_)}function ZE(e){return Rd=yz(Rd,e)}function xz(e){const t=e[ao];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function eR(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[ao].modified_&&(m0(t),Mr(4)),fl(e)&&(e=dg(t,e),t.parent_||fg(t,e)),t.patches_&&hl("Patches").generateReplacementPatches_(n[ao].base_,e,t.patches_,t.inversePatches_)):e=dg(t,n,[]),m0(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==eD?e:void 0}function dg(e,t,n){if(om(t))return t;const r=t[ao];if(!r)return Ed(t,(o,i)=>tR(e,r,t,o,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return fg(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const o=r.copy_;let i=o,s=!1;r.type_===3&&(i=new Set(o),o.clear(),s=!0),Ed(i,(a,l)=>tR(e,r,o,a,l,n,s)),fg(e,o,!1),n&&e.patches_&&hl("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function tR(e,t,n,r,o,i,s){if(process.env.NODE_ENV!=="production"&&o===n&&Mr(5),zc(o)){const a=i&&t&&t.type_!==3&&!p0(t.assigned_,r)?i.concat(r):void 0,l=dg(e,o,a);if(nD(n,r,l),zc(l))e.canAutoFreeze_=!1;else return}else s&&n.add(o);if(fl(o)&&!om(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;dg(e,o),(!t||!t.scope_.parent_)&&fg(e,o)}}function fg(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&mw(t,n)}function wz(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:rD(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,i=vw;n&&(o=[r],i=Od);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,a}var vw={get(e,t){if(t===ao)return e;const n=La(e);if(!p0(n,t))return _z(e,n,t);const r=n[t];return e.finalized_||!fl(r)?r:r===Pb(e.base_,t)?(Tb(e),e.copy_[t]=y0(r,e)):r},has(e,t){return t in La(e)},ownKeys(e){return Reflect.ownKeys(La(e))},set(e,t,n){const r=oD(La(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=Pb(La(e),t),i=o==null?void 0:o[ao];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(mz(n,o)&&(n!==void 0||p0(e.base_,t)))return!0;Tb(e),b0(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Pb(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Tb(e),b0(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=La(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){Mr(11)},getPrototypeOf(e){return jc(e.base_)},setPrototypeOf(){Mr(12)}},Od={};Ed(vw,(e,t)=>{Od[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Od.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Mr(13),Od.set.call(this,e,t,void 0)};Od.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Mr(14),vw.set.call(this,e[0],t,n,e[0])};function Pb(e,t){const n=e[ao];return(n?La(n):e)[t]}function _z(e,t,n){var o;const r=oD(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function oD(e,t){if(!(t in e))return;let n=jc(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=jc(n)}}function b0(e){e.modified_||(e.modified_=!0,e.parent_&&b0(e.parent_))}function Tb(e){e.copy_||(e.copy_=g0(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Sz=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const s=this;return function(l=i,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&Mr(6),r!==void 0&&typeof r!="function"&&Mr(7);let o;if(fl(t)){const i=ZE(this),s=y0(t,void 0);let a=!0;try{o=n(s),a=!1}finally{a?m0(i):v0(i)}return JE(i,r),eR(o,i)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===eD&&(o=void 0),this.autoFreeze_&&mw(o,!0),r){const i=[],s=[];hl("Patches").generateReplacementPatches_(t,o,i,s),r(i,s)}return o}else Mr(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,l=>t(l,...a));let r,o;return[this.produce(t,n,(s,a)=>{r=s,o=a}),r,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){fl(e)||Mr(8),zc(e)&&(e=Cz(e));const t=ZE(this),n=y0(e,void 0);return n[ao].isManual_=!0,v0(t),n}finishDraft(e,t){const n=e&&e[ao];(!n||!n.isManual_)&&Mr(9);const{scope_:r}=n;return JE(r,t),eR(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=hl("Patches").applyPatches_;return zc(e)?r(e,t):this.produce(e,o=>r(o,t))}};function y0(e,t){const n=nm(e)?hl("MapSet").proxyMap_(e,t):rm(e)?hl("MapSet").proxySet_(e,t):wz(e,t);return(t?t.scope_:rD()).drafts_.push(n),n}function Cz(e){return zc(e)||Mr(10,e),iD(e)}function iD(e){if(!fl(e)||om(e))return e;const t=e[ao];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=g0(e,t.scope_.immer_.useStrictShallowCopy_)}else n=g0(e,!0);return Ed(n,(r,o)=>{nD(n,r,iD(o))}),t&&(t.finalized_=!1),n}var lo=new Sz,Ez=lo.produce;lo.produceWithPatches.bind(lo);lo.setAutoFreeze.bind(lo);lo.setUseStrictShallowCopy.bind(lo);lo.applyPatches.bind(lo);lo.createDraft.bind(lo);lo.finishDraft.bind(lo);const Rz=e=>(t,n,r)=>(r.setState=(o,i,...s)=>{const a=typeof o=="function"?Ez(o):o;return t(a,i,...s)},e(r.setState,n,r)),sD=Rz;var x0,Uh=ko;if(process.env.NODE_ENV==="production")x0=Uh.createRoot,Uh.hydrateRoot;else{var nR=Uh.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;x0=function(e,t){nR.usingClientEntryPoint=!0;try{return Uh.createRoot(e,t)}finally{nR.usingClientEntryPoint=!1}}}var aD={},lD={},bw={exports:{}},dn=String,cD=function(){return{isColorSupported:!1,reset:dn,bold:dn,dim:dn,italic:dn,underline:dn,inverse:dn,hidden:dn,strikethrough:dn,black:dn,red:dn,green:dn,yellow:dn,blue:dn,magenta:dn,cyan:dn,white:dn,gray:dn,bgBlack:dn,bgRed:dn,bgGreen:dn,bgYellow:dn,bgBlue:dn,bgMagenta:dn,bgCyan:dn,bgWhite:dn}};bw.exports=cD();bw.exports.createColors=cD;var Oz=bw.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0});function t(l,c){for(var u in c)Object.defineProperty(l,u,{enumerable:!0,get:c[u]})}t(e,{dim:function(){return s},default:function(){return a}});const n=r(Oz);function r(l){return l&&l.__esModule?l:{default:l}}let o=new Set;function i(l,c,u){typeof process<"u"&&process.env.JEST_WORKER_ID||u&&o.has(u)||(u&&o.add(u),console.warn(""),c.forEach(f=>console.warn(l,"-",f)))}function s(l){return n.default.dim(l)}const a={info(l,c){i(n.default.bold(n.default.cyan("info")),...Array.isArray(l)?[l]:[c,l])},warn(l,c){i(n.default.bold(n.default.yellow("warn")),...Array.isArray(l)?[l]:[c,l])},risk(l,c){i(n.default.bold(n.default.magenta("risk")),...Array.isArray(l)?[l]:[c,l])}}})(lD);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const t=n(lD);function n(i){return i&&i.__esModule?i:{default:i}}function r({version:i,from:s,to:a}){t.default.warn(`${s}-color-renamed`,[`As of Tailwind CSS ${i}, \`${s}\` has been renamed to \`${a}\`.`,"Update your configuration file to silence this warning."])}const o={inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000",white:"#fff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"},get lightBlue(){return r({version:"v2.2",from:"lightBlue",to:"sky"}),this.sky},get warmGray(){return r({version:"v3.0",from:"warmGray",to:"stone"}),this.stone},get trueGray(){return r({version:"v3.0",from:"trueGray",to:"neutral"}),this.neutral},get coolGray(){return r({version:"v3.0",from:"coolGray",to:"gray"}),this.gray},get blueGray(){return r({version:"v3.0",from:"blueGray",to:"slate"}),this.slate}}})(aD);let Db=aD;var Pz=(Db.__esModule?Db:{default:Db}).default;const Bt=nu(Pz),uD=`import pandas as pd
60
60
  df = pd.DataFrame(data) # 'data' contains the query result
61
61
  result = df.to_dict('records') # must return 'result' as [dict] type
62
- `,w0=[{locale:"en-US",currency:"USD",currencyName:"US Dollar"},{locale:"en-GB",currency:"GBP",currencyName:"British Pound"},{locale:"en-CA",currency:"CAD",currencyName:"Canadian Dollar"},{locale:"en-AU",currency:"AUD",currencyName:"Australian Dollar"},{locale:"en-IN",currency:"INR",currencyName:"Indian Rupee"},{locale:"ja-JP",currency:"JPY",currencyName:"Japanese Yen"},{locale:"de-DE",currency:"EUR",currencyName:"Germany (Eurozone)"},{locale:"fr-FR",currency:"EUR",currencyName:"France (Eurozone)"},{locale:"es-ES",currency:"EUR",currencyName:"Spain (Eurozone)"},{locale:"it-IT",currency:"EUR",currencyName:"Italy (Eurozone)"},{locale:"fi-FI",currency:"EUR",currencyName:"Finland (Eurozone)"},{locale:"nl-NL",currency:"EUR",currencyName:"Netherlands (Eurozone)"},{locale:"zh-CN",currency:"CNY",currencyName:"Chinese Yuan"},{locale:"ru-RU",currency:"RUB",currencyName:"Russian Ruble"},{locale:"pt-BR",currency:"BRL",currencyName:"Brazilian Real"},{locale:"ko-KR",currency:"KRW",currencyName:"South Korean Won"},{locale:"ar-SA",currency:"SAR",currencyName:"Saudi Riyal"},{locale:"sv-SE",currency:"SEK",currencyName:"Swedish Krona"},{locale:"no-NO",currency:"NOK",currencyName:"Norwegian Krone"},{locale:"da-DK",currency:"DKK",currencyName:"Danish Krone"},{locale:"pl-PL",currency:"PLN",currencyName:"Polish Zloty"},{locale:"tr-TR",currency:"TRY",currencyName:"Turkish Lira"},{locale:"he-IL",currency:"ILS",currencyName:"Israeli Shekel"},{locale:"th-TH",currency:"THB",currencyName:"Thai Baht"},{locale:"vi-VN",currency:"VND",currencyName:"Vietnamese Dong"},{locale:"id-ID",currency:"IDR",currencyName:"Indonesian Rupiah"},{locale:"mx-MX",currency:"MXN",currencyName:"Mexican Peso"},{locale:"za-ZA",currency:"ZAR",currencyName:"South African Rand"},{locale:"sg-SG",currency:"SGD",currencyName:"Singapore Dollar"},{locale:"hk-HK",currency:"HKD",currencyName:"Hong Kong Dollar"},{locale:"ch-CH",currency:"CHF",currencyName:"Swiss Franc"},{locale:"my-MY",currency:"MYR",currencyName:"Malaysian Ringgit"},{locale:"ph-PH",currency:"PHP",currencyName:"Philippine Peso"},{locale:"eg-EG",currency:"EGP",currencyName:"Egyptian Pound"},{locale:"nz-NZ",currency:"NZD",currencyName:"New Zealand Dollar"}],Tz=[{label:"English",locales:[{code:"en-US",name:"US English"},{code:"en-GB",name:"British English"},{code:"en-AU",name:"Australian English"},{code:"en-CA",name:"Canadian English"}]},{label:"French",locales:[{code:"fr-FR",name:"France French"},{code:"fr-CA",name:"Canadian French"}]},{label:"Spanish",locales:[{code:"es-ES",name:"Spain Spanish"},{code:"es-MX",name:"Mexican Spanish"},{code:"es-419",name:"Latin American Spanish"}]},{label:"German",locales:[{code:"de-DE",name:"Germany German"},{code:"de-CH",name:"Swiss German"}]},{label:"Chinese",locales:[{code:"zh-CN",name:"Simplified Chinese (China)"},{code:"zh-TW",name:"Traditional Chinese (Taiwan)"},{code:"zh-HK",name:"Hong Kong Chinese"}]},{label:"Japanese",locales:[{code:"ja-JP",name:"Japanese"}]},{label:"Arabic",locales:[{code:"ar-EG",name:"Egypt Arabic"},{code:"ar-SA",name:"Saudi Arabia Arabic"}]},{label:"Russian",locales:[{code:"ru-RU",name:"Russian"}]},{label:"Portuguese",locales:[{code:"pt-PT",name:"Portugal Portuguese"},{code:"pt-BR",name:"Brazil Portuguese"}]},{label:"Indian Languages",locales:[{code:"hi-IN",name:"Hindi (India)"},{code:"ta-IN",name:"Tamil (India)"}]},{label:"Korean",locales:[{code:"ko-KR",name:"Korean"}]},{label:"Italian",locales:[{code:"it-IT",name:"Italian (Italy)"}]},{label:"Dutch",locales:[{code:"nl-NL",name:"Dutch (Netherlands)"}]},{label:"Swedish",locales:[{code:"sv-SE",name:"Swedish (Sweden)"}]},{label:"Turkish",locales:[{code:"tr-TR",name:"Turkish (Turkey)"}]},{label:"Hebrew",locales:[{code:"he-IL",name:"Hebrew (Israel)"}]},{label:"Thai",locales:[{code:"th-TH",name:"Thai (Thailand)"}]},{label:"Polish",locales:[{code:"pl-PL",name:"Polish (Poland)"}]},{label:"Greek",locales:[{code:"el-GR",name:"Greek (Greece)"}]},{label:"Norwegian",locales:[{code:"no-NO",name:"Norwegian (Norway)"}]}],yw=["lg","md","sm","xs","xxs"],_0={default:{dashboardPanel:"",dashboardTabsContainer:"",gridLayout:{className:""},chart:{font:{family:"Open Sans, Arial, sans-serif"},dataset:{backgroundColor:[Bt.blue[500],Bt.teal[500],Bt.amber[500],Bt.red[500],Bt.indigo[500],Bt.green[500]],borderColor:[Bt.blue[500],Bt.teal[500],Bt.amber[500],Bt.red[500],Bt.indigo[500],Bt.green[500]]},options:{interaction:{mode:"index"},plugins:{datalabels:{display:!1,color:S0},title:{display:!0},tooltip:{backgroundColor:"#fff",bodyColor:"#000",borderWidth:.25,titleColor:"#000",borderColor:"rgb(128,131,139)",cornerRadius:4,usePointStyle:!0,pointStyle:"rectRounded",boxPadding:4},legend:{position:"top",align:"center",maxHeight:0,labels:{useBorderRadius:!0,borderRadius:2}}},scales:{y:{grid:{display:!0},title:{display:!0,text:""},beginAtZero:!0,ticks:{precision:0}},x:{grid:{display:!0},title:{display:!0}}},layout:{padding:{top:-40}},borderRadius:2,responsive:!0,maintainAspectRatio:!1}}},dark:{chart:{dataset:{backgroundColor:[Bt.blue[500],Bt.teal[500],Bt.amber[500],Bt.red[500],Bt.indigo[500],Bt.green[500]],borderColor:[Bt.blue[500],Bt.teal[500],Bt.amber[500],Bt.red[500],Bt.indigo[500],Bt.green[500]],datalables:{color:S0}},options:{plugins:{tooltip:{backgroundColor:"#000",bodyColor:"#fff",borderWidth:.25,titleColor:"#fff",borderColor:"rgb(128,131,139)",cornerRadius:2,boxPadding:4}},datalabels:{display:!1},scales:{x:{grid:{display:!0,color:Bt.slate[800]}},y:{grid:{display:!0,color:Bt.slate[800]}}}}}}};function S0(e){var r,o,i,s,a,l;const t=(a=(s=(i=(o=(r=e==null?void 0:e.chart)==null?void 0:r.config)==null?void 0:o._config)==null?void 0:i.options)==null?void 0:s.plugins)==null?void 0:a.datalabels;let n=(l=e==null?void 0:e.dataset)==null?void 0:l.backgroundColor;return(t==null?void 0:t.align)==="end"&&(t==null?void 0:t.anchor)==="end"&&(n=Pd()),(t==null?void 0:t.align)==="start"&&(t==null?void 0:t.anchor)==="start"&&(n=Pd()),Bc(n)}function Pd(){return ke.getState().theme==="dark"?"#000000":"#FFFFFF"}function Bc(e){let t=0,n=0,r=0,o=0;const i=u=>{if(!u)return Bt.gray[500];const f=u.replace("#",""),h=parseInt(f.substring(0,2),16),g=parseInt(f.substring(2,4),16),v=parseInt(f.substring(4,6),16);t+=h,n+=g,r+=v,o++};Array.isArray(e)?e.forEach(u=>{i(u)}):i(e);const s=t/o,a=n/o,l=r/o;return(s*299+a*587+l*114)/1e3>=180?"black":"white"}const im=["text","enum","varchar","nvarchar","nvarchar2","char","character","longtext","nchar","char varying","nchar varying","character varying","string"],Vc=["number","integer","int","bigint","smallint","tinyint","byteint","numeric","decimal","dec","double","real","double precision","float","float4","float8"],Pf=["date","datetime","time","timestamp","timestamp without time zone","timestamp_ns"],xw=["boolean"];function ww(e){return e.match(/[A-Z]/)?`"${e}"`:e}function Dz(e,t,n){const{measures:r,dimensions:o}=e,i=r==null?void 0:r.map(c=>`${c.calc}(${c.name}) as ${c.calc}_${c.name.replace(/"/g,"")}`).join(", "),s=(o==null?void 0:o.join(", "))||"";let a="";const l=dD(t,n);if(i&&s)return a=`SELECT ${s}, COUNT(*) as count, ${i} FROM ${l} GROUP BY ${s} ORDER BY ${s} DESC`,a;if(!i&&s)return a=`SELECT ${s}, COUNT(*) as count FROM ${l} GROUP BY ${s} ORDER BY ${s} DESC`,a;if(i&&!s)return a=`SELECT ${i} FROM ${l}`,a}function $z(e,t,n="AVG"){var i,s,a,l;let r={};const o=ww(e.column_name);return im.includes(e.data_type)&&(((i=t.dimensions)==null?void 0:i.includes(o))?r={...t,dimensions:(s=t.dimensions)==null?void 0:s.filter(u=>u!==o)}:r={...t,dimensions:[...t.dimensions||[],o]}),Vc.includes(e.data_type)&&(((a=t.measures)==null?void 0:a.some(u=>u.name===o&&u.calc===n))?r={...t,measures:(l=t.measures)==null?void 0:l.filter(u=>!(u.name===o&&u.calc===n))}:r={...t,measures:[...t.measures||[],{name:o,calc:n||"SUM"}]}),r}function hg(e){return im.includes(e.dataType)?"string":Vc.includes(e.dataType)?"number":Pf.includes(e.dataType)?"date":xw.includes(e.dataType)?"boolean":"string"}function Az(e){let t;const n=e.data_type.toLowerCase();return im.includes(n)?t="T":Vc.includes(n)?t="#":Pf.includes(n)?t="D":xw.includes(n)?t="B":t="?",t}function kz(e,t){const{dimensions:n,measures:r}=t,o=n==null?void 0:n.includes(e.column_name),i=r==null?void 0:r.some(s=>s.name===e.column_name);return o||i}function dD(e,t){return t==="api"||e===ww("NA")||e==="public"?t:e?`${e}.${t}`:`${t}`}const Mz=e=>{const t=new Date(e);return!isNaN(t.getTime())},Iz=e=>!isNaN(Number(e))&&!isNaN(parseFloat(e)),Td=e=>{let t;return typeof e=="number"?t="number":typeof e=="string"?Mz(e)?t="date":Iz(e)?t="number":t="string":typeof e=="boolean"?t="boolean":e instanceof Date?t="date":t="unknown",t};function Nz({get:e,dataPoint:t,card:n}){var h;const{addOrUpdateFilterValue:r,addFilteringCard:o,removeFilterValue:i,replaceFilterValue:s,removeFilteringCard:a}=e().actions,l=e().filteringCards,{columnName:c,columnValue:u}=t,f={filterId:n.id,connectionId:n==null?void 0:n.connectionId,tableName:n.lastSelectedTable,name:c,expression:(h=n.preferences)==null?void 0:h.filterOnClickField,valueType:Td(u),operation:"=",values:[u]};if(l!=null&&l.find(g=>g.id===n.id)){const g=n.id;if(u==null){a(n),i(g);return}else s(f)}o(n),r(f)}var pg={exports:{}};/**
62
+ `,w0=[{locale:"en-US",currency:"USD",currencyName:"US Dollar"},{locale:"en-GB",currency:"GBP",currencyName:"British Pound"},{locale:"en-CA",currency:"CAD",currencyName:"Canadian Dollar"},{locale:"en-AU",currency:"AUD",currencyName:"Australian Dollar"},{locale:"en-IN",currency:"INR",currencyName:"Indian Rupee"},{locale:"ja-JP",currency:"JPY",currencyName:"Japanese Yen"},{locale:"de-DE",currency:"EUR",currencyName:"Germany (Eurozone)"},{locale:"fr-FR",currency:"EUR",currencyName:"France (Eurozone)"},{locale:"es-ES",currency:"EUR",currencyName:"Spain (Eurozone)"},{locale:"it-IT",currency:"EUR",currencyName:"Italy (Eurozone)"},{locale:"fi-FI",currency:"EUR",currencyName:"Finland (Eurozone)"},{locale:"nl-NL",currency:"EUR",currencyName:"Netherlands (Eurozone)"},{locale:"zh-CN",currency:"CNY",currencyName:"Chinese Yuan"},{locale:"ru-RU",currency:"RUB",currencyName:"Russian Ruble"},{locale:"pt-BR",currency:"BRL",currencyName:"Brazilian Real"},{locale:"ko-KR",currency:"KRW",currencyName:"South Korean Won"},{locale:"ar-SA",currency:"SAR",currencyName:"Saudi Riyal"},{locale:"sv-SE",currency:"SEK",currencyName:"Swedish Krona"},{locale:"no-NO",currency:"NOK",currencyName:"Norwegian Krone"},{locale:"da-DK",currency:"DKK",currencyName:"Danish Krone"},{locale:"pl-PL",currency:"PLN",currencyName:"Polish Zloty"},{locale:"tr-TR",currency:"TRY",currencyName:"Turkish Lira"},{locale:"he-IL",currency:"ILS",currencyName:"Israeli Shekel"},{locale:"th-TH",currency:"THB",currencyName:"Thai Baht"},{locale:"vi-VN",currency:"VND",currencyName:"Vietnamese Dong"},{locale:"id-ID",currency:"IDR",currencyName:"Indonesian Rupiah"},{locale:"mx-MX",currency:"MXN",currencyName:"Mexican Peso"},{locale:"za-ZA",currency:"ZAR",currencyName:"South African Rand"},{locale:"sg-SG",currency:"SGD",currencyName:"Singapore Dollar"},{locale:"hk-HK",currency:"HKD",currencyName:"Hong Kong Dollar"},{locale:"ch-CH",currency:"CHF",currencyName:"Swiss Franc"},{locale:"my-MY",currency:"MYR",currencyName:"Malaysian Ringgit"},{locale:"ph-PH",currency:"PHP",currencyName:"Philippine Peso"},{locale:"eg-EG",currency:"EGP",currencyName:"Egyptian Pound"},{locale:"nz-NZ",currency:"NZD",currencyName:"New Zealand Dollar"}],Tz=[{label:"English",locales:[{code:"en-US",name:"US English"},{code:"en-GB",name:"British English"},{code:"en-AU",name:"Australian English"},{code:"en-CA",name:"Canadian English"}]},{label:"French",locales:[{code:"fr-FR",name:"France French"},{code:"fr-CA",name:"Canadian French"}]},{label:"Spanish",locales:[{code:"es-ES",name:"Spain Spanish"},{code:"es-MX",name:"Mexican Spanish"},{code:"es-419",name:"Latin American Spanish"}]},{label:"German",locales:[{code:"de-DE",name:"Germany German"},{code:"de-CH",name:"Swiss German"}]},{label:"Chinese",locales:[{code:"zh-CN",name:"Simplified Chinese (China)"},{code:"zh-TW",name:"Traditional Chinese (Taiwan)"},{code:"zh-HK",name:"Hong Kong Chinese"}]},{label:"Japanese",locales:[{code:"ja-JP",name:"Japanese"}]},{label:"Arabic",locales:[{code:"ar-EG",name:"Egypt Arabic"},{code:"ar-SA",name:"Saudi Arabia Arabic"}]},{label:"Russian",locales:[{code:"ru-RU",name:"Russian"}]},{label:"Portuguese",locales:[{code:"pt-PT",name:"Portugal Portuguese"},{code:"pt-BR",name:"Brazil Portuguese"}]},{label:"Indian Languages",locales:[{code:"hi-IN",name:"Hindi (India)"},{code:"ta-IN",name:"Tamil (India)"}]},{label:"Korean",locales:[{code:"ko-KR",name:"Korean"}]},{label:"Italian",locales:[{code:"it-IT",name:"Italian (Italy)"}]},{label:"Dutch",locales:[{code:"nl-NL",name:"Dutch (Netherlands)"}]},{label:"Swedish",locales:[{code:"sv-SE",name:"Swedish (Sweden)"}]},{label:"Turkish",locales:[{code:"tr-TR",name:"Turkish (Turkey)"}]},{label:"Hebrew",locales:[{code:"he-IL",name:"Hebrew (Israel)"}]},{label:"Thai",locales:[{code:"th-TH",name:"Thai (Thailand)"}]},{label:"Polish",locales:[{code:"pl-PL",name:"Polish (Poland)"}]},{label:"Greek",locales:[{code:"el-GR",name:"Greek (Greece)"}]},{label:"Norwegian",locales:[{code:"no-NO",name:"Norwegian (Norway)"}]}],yw=["lg","md","sm","xs","xxs"],_0={default:{dashboardPanel:"",dashboardTabsContainer:"",gridLayout:{className:""},chart:{font:{family:"Open Sans, Arial, sans-serif"},dataset:{backgroundColor:[Bt.blue[500],Bt.teal[500],Bt.amber[500],Bt.red[500],Bt.indigo[500],Bt.green[500]],borderColor:[Bt.blue[500],Bt.teal[500],Bt.amber[500],Bt.red[500],Bt.indigo[500],Bt.green[500]]},options:{interaction:{mode:"index"},plugins:{datalabels:{display:!1,color:S0},title:{display:!0},tooltip:{backgroundColor:"#fff",bodyColor:"#000",borderWidth:.25,titleColor:"#000",borderColor:"rgb(128,131,139)",cornerRadius:4,usePointStyle:!0,pointStyle:"rectRounded",boxPadding:4},legend:{position:"top",align:"center",maxHeight:0,labels:{useBorderRadius:!0,borderRadius:2}}},scales:{y:{grid:{display:!0},title:{display:!0,text:""},beginAtZero:!0,ticks:{precision:0}},x:{grid:{display:!0},title:{display:!0}}},layout:{padding:{top:-40}},borderRadius:2,responsive:!0,maintainAspectRatio:!1}}},dark:{chart:{dataset:{backgroundColor:[Bt.blue[500],Bt.teal[500],Bt.amber[500],Bt.red[500],Bt.indigo[500],Bt.green[500]],borderColor:[Bt.blue[500],Bt.teal[500],Bt.amber[500],Bt.red[500],Bt.indigo[500],Bt.green[500]],datalables:{color:S0}},options:{plugins:{tooltip:{backgroundColor:"#000",bodyColor:"#fff",borderWidth:.25,titleColor:"#fff",borderColor:"rgb(128,131,139)",cornerRadius:2,boxPadding:4}},datalabels:{display:!1},scales:{x:{grid:{display:!0,color:Bt.slate[800]}},y:{grid:{display:!0,color:Bt.slate[800]}}}}}}};function S0(e){var r,o,i,s,a,l;const t=(a=(s=(i=(o=(r=e==null?void 0:e.chart)==null?void 0:r.config)==null?void 0:o._config)==null?void 0:i.options)==null?void 0:s.plugins)==null?void 0:a.datalabels;let n=(l=e==null?void 0:e.dataset)==null?void 0:l.backgroundColor;return(t==null?void 0:t.align)==="end"&&(t==null?void 0:t.anchor)==="end"&&(n=Pd()),(t==null?void 0:t.align)==="start"&&(t==null?void 0:t.anchor)==="start"&&(n=Pd()),Bc(n)}function Pd(){return ke.getState().theme==="dark"?"#000000":"#FFFFFF"}function Bc(e){let t=0,n=0,r=0,o=0;const i=u=>{if(!u)return Bt.gray[500];const f=u.replace("#",""),h=parseInt(f.substring(0,2),16),g=parseInt(f.substring(2,4),16),v=parseInt(f.substring(4,6),16);t+=h,n+=g,r+=v,o++};Array.isArray(e)?e.forEach(u=>{i(u)}):i(e);const s=t/o,a=n/o,l=r/o;return(s*299+a*587+l*114)/1e3>=180?"black":"white"}const im=["text","enum","varchar","nvarchar","nvarchar2","char","character","longtext","nchar","char varying","nchar varying","character varying","string"],Vc=["number","integer","int","int64","bigint","smallint","tinyint","byteint","numeric","decimal","dec","double","real","double precision","float","float4","float8","float64"],Pf=["date","datetime","time","timestamp","timestamp without time zone","timestamp_ns"],xw=["boolean"];function ww(e){return e.match(/[A-Z]/)?`"${e}"`:e}function Dz(e,t,n){const{measures:r,dimensions:o}=e,i=r==null?void 0:r.map(c=>`${c.calc}(${c.name}) as ${c.calc}_${c.name.replace(/"/g,"")}`).join(", "),s=(o==null?void 0:o.join(", "))||"";let a="";const l=dD(t,n);if(i&&s)return a=`SELECT ${s}, COUNT(*) as count, ${i} FROM ${l} GROUP BY ${s} ORDER BY ${s} DESC`,a;if(!i&&s)return a=`SELECT ${s}, COUNT(*) as count FROM ${l} GROUP BY ${s} ORDER BY ${s} DESC`,a;if(i&&!s)return a=`SELECT ${i} FROM ${l}`,a}function $z(e,t,n="AVG"){var i,s,a,l;let r={};const o=ww(e.column_name);return im.includes(e.data_type)&&(((i=t.dimensions)==null?void 0:i.includes(o))?r={...t,dimensions:(s=t.dimensions)==null?void 0:s.filter(u=>u!==o)}:r={...t,dimensions:[...t.dimensions||[],o]}),Vc.includes(e.data_type)&&(((a=t.measures)==null?void 0:a.some(u=>u.name===o&&u.calc===n))?r={...t,measures:(l=t.measures)==null?void 0:l.filter(u=>!(u.name===o&&u.calc===n))}:r={...t,measures:[...t.measures||[],{name:o,calc:n||"SUM"}]}),r}function hg(e){return im.includes(e.dataType)?"string":Vc.includes(e.dataType)?"number":Pf.includes(e.dataType)?"date":xw.includes(e.dataType)?"boolean":"string"}function Az(e){let t;const n=e.data_type.toLowerCase();return im.includes(n)?t="T":Vc.includes(n)?t="#":Pf.includes(n)?t="D":xw.includes(n)?t="B":t="?",t}function kz(e,t){const{dimensions:n,measures:r}=t,o=n==null?void 0:n.includes(e.column_name),i=r==null?void 0:r.some(s=>s.name===e.column_name);return o||i}function dD(e,t){return t==="api"||e===ww("NA")||e==="public"?t:e?`${e}.${t}`:`${t}`}const Mz=e=>{const t=new Date(e);return!isNaN(t.getTime())},Iz=e=>!isNaN(Number(e))&&!isNaN(parseFloat(e)),Td=e=>{let t;return typeof e=="number"?t="number":typeof e=="string"?Mz(e)?t="date":Iz(e)?t="number":t="string":typeof e=="boolean"?t="boolean":e instanceof Date?t="date":t="unknown",t};function Nz({get:e,dataPoint:t,card:n}){var h;const{addOrUpdateFilterValue:r,addFilteringCard:o,removeFilterValue:i,replaceFilterValue:s,removeFilteringCard:a}=e().actions,l=e().filteringCards,{columnName:c,columnValue:u}=t,f={filterId:n.id,connectionId:n==null?void 0:n.connectionId,tableName:n.lastSelectedTable,name:c,expression:(h=n.preferences)==null?void 0:h.filterOnClickField,valueType:Td(u),operation:"=",values:[u]};if(l!=null&&l.find(g=>g.id===n.id)){const g=n.id;if(u==null){a(n),i(g);return}else s(f)}o(n),r(f)}var pg={exports:{}};/**
63
63
  * @license
64
64
  * Lodash <https://lodash.com/>
65
65
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-4Wp9Iidj.js");require("react");require("react-dom");exports.Dashboard=e.Dashboard;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-uA5XMQEz.js");require("react");require("react-dom");exports.Dashboard=e.Dashboard;
@@ -1,4 +1,4 @@
1
- import { D as p } from "../chunks/index-D_kbj8T-.js";
1
+ import { D as p } from "../chunks/index-s35YyUnE.js";
2
2
  import "react";
3
3
  import "react-dom";
4
4
  export {
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-4Wp9Iidj.js"),d=require("./chunks/dashboard-plus-hkbefCny.js"),I=require("react");require("react-dom");function N({card:t,footer:u,className:m,...c}){const{customCards:r}=e.useSemaphorContext(),h=I.useRef(null),{isError:p,isLoading:n,isFetching:i,cfg:x,visualKey:C,handleDatapointClick:f}=e.useDashboardCard(t),a=e.useDashboardStore(s=>s.themeStyle),l=e.useDashboardStore(s=>s.selectedSheetId),E=e.useDashboardStore(s=>s.selectedCardId),j=e.useDashboardStore(s=>s.isDashboardEditing),{setCardTitle:g,setCardDescription:D,setSelectedCardId:b}=e.useDashboardActions();function S(s){s.stopPropagation(),b(l,t.id)}function T(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.replaceDefault){const o=s.content;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return t.type==="kpi"?t.data&&t.data.length>0&&e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:n||i,card:t}):y}function R(){if(p)return e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(t.type==="table"&&t.data&&t.data.length>0)return e.jsxRuntimeExports.jsxs(e.ScrollArea,{children:[e.jsxRuntimeExports.jsx(e.TableVisual,{card:t,data:t.data}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]});if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.content){const o=s.content;return e.jsxRuntimeExports.jsx(o,{card:t})}}if(x)return e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x,onDatapointClick:f},C)}function A(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.footer){const o=s.footer;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return u||null}if(!t.id)return null;const y=e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"pb-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:s=>g(l,t.id,s),children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title})}),t.refreshInterval&&e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{className:"pr-1",children:e.jsxRuntimeExports.jsx("div",{className:e.cn("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":n||i})})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:`Realtime (${t==null?void 0:t.refreshInterval})`})})]}),!t.refreshInterval&&(n||i)&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),e.jsxRuntimeExports.jsx(e.Editable,{text:(t==null?void 0:t.description)||"",onSave:s=>D(l,t.id,s),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",t.description]})})]}),e.jsxRuntimeExports.jsx(e.CardContent,{className:"relative flex grow flex-col overflow-auto pb-0",children:R()}),e.jsxRuntimeExports.jsx(e.CardFooter,{children:A()})]});return e.jsxRuntimeExports.jsx(e.Card,{tabIndex:-1,ref:h,role:"dashboard-card",onClick:S,className:e.cn("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":E===t.id&&j},a==null?void 0:a.dashboardCard,m),...c,children:T()})}exports.BOOLEAN_DATA_TYPES=e.BOOLEAN_DATA_TYPES;exports.DATE_DATA_TYPES=e.DATE_DATA_TYPES;exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.NUMBER_DATA_TYPES=e.NUMBER_DATA_TYPES;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.TEXT_DATA_TYPES=e.TEXT_DATA_TYPES;exports.cleanCard=e.cleanCard;exports.createSqlGenConfig=e.createSqlGenConfig;exports.fmt=e.fmt;exports.getBookmarkKey=e.getBookmarkKey;exports.getColumnDataType=e.getColumnDataType;exports.getDashbaordStateWithoutData=e.getDashbaordStateWithoutData;exports.getFilterValueType=e.getFilterValueType;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.resolveDataType=e.resolveDataType;exports.useCard=e.useCard;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useEditorActions=e.useEditorActions;exports.useEditorStore=e.useEditorStore;exports.SelectComponent=d.SelectComponent;exports.Surfboard=d.DashboardPlus;exports.useEditorAside=d.useEditorAside;exports.DashboardCard=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-uA5XMQEz.js"),d=require("./chunks/dashboard-plus-CEShCre6.js"),I=require("react");require("react-dom");function N({card:t,footer:u,className:m,...c}){const{customCards:r}=e.useSemaphorContext(),h=I.useRef(null),{isError:p,isLoading:n,isFetching:i,cfg:x,visualKey:C,handleDatapointClick:f}=e.useDashboardCard(t),a=e.useDashboardStore(s=>s.themeStyle),l=e.useDashboardStore(s=>s.selectedSheetId),E=e.useDashboardStore(s=>s.selectedCardId),j=e.useDashboardStore(s=>s.isDashboardEditing),{setCardTitle:g,setCardDescription:D,setSelectedCardId:b}=e.useDashboardActions();function S(s){s.stopPropagation(),b(l,t.id)}function T(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.replaceDefault){const o=s.content;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return t.type==="kpi"?t.data&&t.data.length>0&&e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:n||i,card:t}):y}function R(){if(p)return e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(t.type==="table"&&t.data&&t.data.length>0)return e.jsxRuntimeExports.jsxs(e.ScrollArea,{children:[e.jsxRuntimeExports.jsx(e.TableVisual,{card:t,data:t.data}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]});if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.content){const o=s.content;return e.jsxRuntimeExports.jsx(o,{card:t})}}if(x)return e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x,onDatapointClick:f},C)}function A(){if(r&&r.length>0){const s=r.find(o=>o.cardId===t.id);if(s&&s.footer){const o=s.footer;if(o)return e.jsxRuntimeExports.jsx(o,{card:t})}}return u||null}if(!t.id)return null;const y=e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"pb-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:s=>g(l,t.id,s),children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title})}),t.refreshInterval&&e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{className:"pr-1",children:e.jsxRuntimeExports.jsx("div",{className:e.cn("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":n||i})})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:`Realtime (${t==null?void 0:t.refreshInterval})`})})]}),!t.refreshInterval&&(n||i)&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),e.jsxRuntimeExports.jsx(e.Editable,{text:(t==null?void 0:t.description)||"",onSave:s=>D(l,t.id,s),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",t.description]})})]}),e.jsxRuntimeExports.jsx(e.CardContent,{className:"relative flex grow flex-col overflow-auto pb-0",children:R()}),e.jsxRuntimeExports.jsx(e.CardFooter,{children:A()})]});return e.jsxRuntimeExports.jsx(e.Card,{tabIndex:-1,ref:h,role:"dashboard-card",onClick:S,className:e.cn("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":E===t.id&&j},a==null?void 0:a.dashboardCard,m),...c,children:T()})}exports.BOOLEAN_DATA_TYPES=e.BOOLEAN_DATA_TYPES;exports.DATE_DATA_TYPES=e.DATE_DATA_TYPES;exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.NUMBER_DATA_TYPES=e.NUMBER_DATA_TYPES;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.TEXT_DATA_TYPES=e.TEXT_DATA_TYPES;exports.cleanCard=e.cleanCard;exports.createSqlGenConfig=e.createSqlGenConfig;exports.fmt=e.fmt;exports.getBookmarkKey=e.getBookmarkKey;exports.getColumnDataType=e.getColumnDataType;exports.getDashbaordStateWithoutData=e.getDashbaordStateWithoutData;exports.getFilterValueType=e.getFilterValueType;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.resolveDataType=e.resolveDataType;exports.useCard=e.useCard;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useEditorActions=e.useEditorActions;exports.useEditorStore=e.useEditorStore;exports.SelectComponent=d.SelectComponent;exports.Surfboard=d.DashboardPlus;exports.useEditorAside=d.useEditorAside;exports.DashboardCard=N;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { u as _, a as k, b as n, c as w, j as s, C as F, E as f, d as P, T as R, e as B, f as h, g as L, L as q, h as K, i as O, k as Y, l as G, K as V, S as z, m as H, n as J, o as M } from "./chunks/index-D_kbj8T-.js";
2
- import { B as se, s as te, D as ae, q as oe, N as ne, I as re, r as ie, M as le, w as de, t as ue, O as ce, y as fe, J as he, x as Ce, A as xe, v as me, z as pe, F as ge, p as je, H as De, G as be } from "./chunks/index-D_kbj8T-.js";
3
- import { S as Te, D as Ee, u as Ie } from "./chunks/dashboard-plus-TntWBpXD.js";
1
+ import { u as _, a as k, b as n, c as w, j as s, C as F, E as f, d as P, T as R, e as B, f as h, g as L, L as q, h as K, i as O, k as Y, l as G, K as V, S as z, m as H, n as J, o as M } from "./chunks/index-s35YyUnE.js";
2
+ import { B as se, s as te, D as ae, q as oe, N as ne, I as re, r as ie, M as le, w as de, t as ue, O as ce, y as fe, J as he, x as Ce, A as xe, v as me, z as pe, F as ge, p as je, H as De, G as be } from "./chunks/index-s35YyUnE.js";
3
+ import { S as Te, D as Ee, u as Ie } from "./chunks/dashboard-plus--e-e-oPV.js";
4
4
  import Q from "react";
5
5
  import "react-dom";
6
6
  function $({
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/dashboard-plus-hkbefCny.js");require("../chunks/index-4Wp9Iidj.js");require("react");require("react-dom");exports.Surfboard=r.DashboardPlus;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/dashboard-plus-CEShCre6.js");require("../chunks/index-uA5XMQEz.js");require("react");require("react-dom");exports.Surfboard=r.DashboardPlus;
@@ -1,5 +1,5 @@
1
- import { D as i } from "../chunks/dashboard-plus-TntWBpXD.js";
2
- import "../chunks/index-D_kbj8T-.js";
1
+ import { D as i } from "../chunks/dashboard-plus--e-e-oPV.js";
2
+ import "../chunks/index-s35YyUnE.js";
3
3
  import "react";
4
4
  import "react-dom";
5
5
  export {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.0.217",
8
+ "version": "0.0.219",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",