import { b9 as m, gq as h, bg as z, V as r, jF as R, P as b, jG as H, jH as B, bh as P, jI as j, ih as C, jJ as I, jK as E } from "./684d2f28.js";
import { useContext as $, useRef as L, useState as c, useMemo as M } from "react";
import { u as F, H as O } from "./63cfd7ef.js";
import "react-dom";
const U = m.div`
  right: calc(313px + 4px); // FIXME: don't rely on the width of the right panel
  bottom: ${(t) => t.$bottom ? t.$bottom + 4 + "px" : 285 + 4 + "px"};
  position: fixed;
  z-index: ${h.queryResultPanel};

  display: flex;
  flex-direction: column;
  width: 592px;
  height: fit-content;
  max-height: 250px;
  background: #ffffff;
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  pointer-events: auto;
  padding-bottom: 16px;
`, W = (t) => {
  const {
    bottom: e
  } = t, i = $(z), o = i.showResultComp(), a = o == null ? void 0 : o.result(), l = L(null), [u, n] = c(!0), [f, x] = c({
    left: 0,
    top: 0,
    bottom: 0,
    right: 0
  }), {
    header: w,
    body: y
  } = F({
    ...a ?? {
      data: "",
      dataType: "default",
      success: !0
    },
    onClose: () => i.setShowResultCompName(void 0)
  });
  return a ? /* @__PURE__ */ r(R, {
    disabled: u,
    bounds: f,
    enableUserSelectHack: !1,
    onStart: (J, d) => {
      var p;
      const {
        clientWidth: v,
        clientHeight: S
      } = window.document.documentElement, s = (p = l.current) == null ? void 0 : p.getBoundingClientRect();
      s && x({
        left: -s.left + d.x,
        right: v - (s.right - d.x),
        top: -s.top + d.y,
        bottom: S - (s.bottom - d.y)
      });
    },
    children: /* @__PURE__ */ b(U, {
      $bottom: e,
      ref: l,
      children: [/* @__PURE__ */ r(O, {
        onMouseOver: () => n(!1),
        onMouseOut: () => n(!0),
        children: w
      }), y]
    })
  }) : null;
}, k = m(E)`
  position: relative;
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  border-top: 1px solid #e1e3eb;
  z-index: ${h.bottomPanel};

  .react-resizable-handle {
    position: absolute;
    border-top: transparent solid 3px;
    width: 100%;
    padding: 0 3px 3px 0;
    top: 0;
    cursor: row-resize;
  }
`, g = (t) => {
  t.preventDefault();
}, q = () => {
  window.addEventListener("mousedown", g);
}, D = () => {
  window.removeEventListener("mousedown", g);
};
function T(t) {
  const e = M(() => B(), []), i = document.documentElement.clientHeight, o = (u, n) => {
    I({
      ...e,
      bottom: {
        h: n.size.height
      }
    }), l(n.size.height), D();
  }, [a, l] = c(e.bottom.h);
  return /* @__PURE__ */ b(P, {
    children: [/* @__PURE__ */ r(W, {
      bottom: a
    }), /* @__PURE__ */ r(k, {
      width: 1 / 0,
      height: e.bottom.h,
      resizeHandles: ["n"],
      minConstraints: [680, 285],
      maxConstraints: [1 / 0, i - 48 - 40],
      onResizeStart: q,
      onResizeStop: o,
      children: /* @__PURE__ */ r(j, {})
    })]
  });
}
const G = (t) => ({
  orgId: C(t).currentOrgId,
  datasourceInfos: t.entities.datasource.data
}), A = H(G, null)(T);
export {
  A as default
};
