import { a3 as t, ht as S, hu as C, cC as d, H as r, ei as u, a4 as g, ad as x, I as R, hv as $, hw as F, hx as H, hy as J, hz as L } from "./56c67d3b.js";
import { useState as P, useEffect as W, useMemo as v } from "react";
const Q = t.div`
  display: flex;
  align-items: center;
  padding: 12px 16px 20px 16px;
  cursor: move;
  background-color: #ffffff;
  border-radius: inherit;
`, I = t.div`
  margin-right: 8px;
  height: 16px;

  svg {
    width: 16px;
    height: 16px;
  }
`, z = t.div`
  display: flex;
  align-items: center;
  flex-grow: 1;

  height: 24px;
  font-size: 13px;
  line-height: 13px;
  color: #222222;
  border-radius: 4px;
  border: none;
  word-break: break-all;
`, E = t.div`
  display: flex;
  flex-shrink: 0;
  align-items: center;
  margin-right: 24px;
  color: #8b8fa3;
  line-height: 13px;
  margin-left: auto;
`, M = t.div`
  margin-left: auto;
  width: 16px;
  height: 16px;
  cursor: pointer;

  color: ${S};

  &:hover {
    color: ${C};
  }
`, B = t.div`
  height: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  padding-left: 16px;
  background-color: #ffffff;

  &::-webkit-scrollbar {
    width: 16px;
  }

  &::-webkit-scrollbar-thumb {
    border: 4px solid transparent;
    background-clip: content-box;
    border-radius: 9999px;
    background-color: rgba(139, 143, 163, 0.2);
    min-height: 50px;
  }

  &::-webkit-scrollbar-thumb:hover {
    background-color: rgba(139, 143, 163, 0.36);
  }
`, D = t(L)`
  .ant-table {
    font-size: 13px;
    border: none;
  }

  .ant-table-thead {
    margin-bottom: 4px;
  }

  .ant-table-thead > tr > th {
    color: #8b8fa3;
    background: #ffffff;
    line-height: 13px;
    padding-bottom: 9px;
    // border-bottom: 1px solid #8b8fa3;
  }

  .ant-table-thead > tr > th::before {
    display: none;
  }

  .ant-table-tbody > tr > td {
    border: none;
  }

  .ant-table-row {
    margin-top: 4px;
  }

  .ant-table-cell {
    height: 22px;
    padding: 0 24px 0 0;
    margin-left: 24px;
    max-width: 184px; // actual width + padding right
  }

  // two-side shadow with scrollbar
  .ant-table-ping-left:not(.ant-table-has-fix-left) .ant-table-container::before {
    box-shadow: none;
  }

  .ant-table-ping-right:not(.ant-table-has-fix-right) .ant-table-container::after {
    box-shadow: none;
  }
`, m = t.pre`
  word-break: break-word;
  white-space: pre-wrap;
`, T = t.span`
  color: #b8b9bf;
  margin-left: 8px;
`, G = T;
function U(n) {
  const {
    success: l,
    errorMessage: f,
    dataType: a,
    data: e,
    title: j,
    runTime: w
  } = n, [b, y] = P(!1);
  W(() => y(!1), [n.data]);
  const [k, O] = v(() => {
    if (a !== "default")
      return [!1, []];
    if (Array.isArray(e)) {
      let o = !0;
      const p = e.reduce((h, i) => (i && d.isPlainObject(i) ? Object.keys(i).forEach((c) => h.add(c)) : o = !1, h), /* @__PURE__ */ new Set());
      if (o)
        return [!0, Array.from(p).reduce((h, i) => [...h, {
          title: i,
          dataIndex: i,
          ellipsis: !0,
          render: (c) => typeof c == "string" ? c : JSON.stringify(c)
        }], [])];
    }
    return [!1, []];
  }, [e, a]), A = v(() => {
    if (f)
      return f;
    if (b)
      return /* @__PURE__ */ r(u, {
        name: !1,
        src: e
      });
    switch (a) {
      case "function":
        return /* @__PURE__ */ r(m, {
          children: g("resultPanel.returnFunction")
        });
      case "json":
        return d.isObjectLike(e) ? /* @__PURE__ */ r(u, {
          name: !1,
          src: e
        }) : /* @__PURE__ */ r(m, {
          children: String(e)
        });
      default:
        return k ? /* @__PURE__ */ r(D, {
          tableLayout: "auto",
          scroll: {
            x: "100%"
          },
          columns: O,
          dataSource: e.map((o, p) => ({
            ...o,
            key: p
          })),
          pagination: !1
        }) : d.isObjectLike(e) ? /* @__PURE__ */ r(u, {
          name: !1,
          src: e
        }) : /* @__PURE__ */ r(m, {
          children: e
        });
    }
  }, [n, b]);
  let s = null;
  return a !== "function" && (d.isArray(e) ? s = `Array(${e.length})` : d.isObject(e) ? s = `Object(${Object.keys(e).length} keys)` : s = typeof e), {
    header: /* @__PURE__ */ x(R, {
      children: [/* @__PURE__ */ x(z, {
        children: [/* @__PURE__ */ r(I, {
          children: l ? /* @__PURE__ */ r($, {}) : /* @__PURE__ */ r(F, {})
        }), j, w ? /* @__PURE__ */ r(T, {
          children: g("resultPanel.consume", {
            time: N(w) || ""
          })
        }) : null, s && /* @__PURE__ */ r(G, {
          children: s
        }), k && /* @__PURE__ */ x(E, {
          children: [/* @__PURE__ */ r(H, {
            value: b,
            onChange: (o) => y(o)
          }), g("resultPanel.JSON")]
        })]
      }), /* @__PURE__ */ r(M, {
        onClick: n.onClose,
        children: /* @__PURE__ */ r(J, {})
      })]
    }),
    body: /* @__PURE__ */ r(B, {
      children: A
    })
  };
}
function N(n) {
  let l = n;
  const f = ["ms", "s", "min", "h"], a = [1, 1e3, 60, 60];
  for (let e = 0; e < 4; e++) {
    if (l / a[e] < 1)
      return l + f[e - 1];
    l /= a[e];
  }
}
export {
  Q as H,
  U as u
};
