import { jsx as s, jsxs as n, Fragment as b } from "react/jsx-runtime";
import { Children as X, cloneElement as Y, createElement as I, useState as R, useMemo as Z, Fragment as ee, useCallback as T } from "react";
import { cq as F, u as G, a as M, cr as se, B as w, c as $, ch as ae, cs as re, b4 as C, ct as oe, aK as O, a5 as te, cu as ne, cv as le, cw as L, U as j, cx as N, S, E as f, T as p, cy as ce, ac as ie, co as P, aJ as de, z as A, bp as pe, cz as he, cA as me, cB as ue, V, aO as ge, cC as be, br as fe, bL as we, bM as ye, aS as ve } from "./index-CUr2awEp.mjs";
var H = { root: "m_8b3717df", breadcrumb: "m_f678d540", separator: "m_3b8f2208" };
const xe = {
  separator: "/"
}, _e = $((a, { separatorMargin: r }) => ({
  root: {
    "--bc-separator-margin": ae(r)
  }
})), E = F((a, r) => {
  const e = G("Breadcrumbs", xe, a), {
    classNames: l,
    className: c,
    style: i,
    styles: t,
    unstyled: o,
    vars: d,
    children: x,
    separator: m,
    separatorMargin: y,
    ...u
  } = e, g = M({
    name: "Breadcrumbs",
    classes: H,
    props: e,
    className: c,
    style: i,
    classNames: l,
    styles: t,
    unstyled: o,
    vars: d,
    varsResolver: _e
  }), z = X.toArray(x).reduce((D, _, k, K) => {
    const U = se(_) ? Y(_, {
      ...g("breadcrumb", { className: _.props?.className }),
      key: k
    }) : /* @__PURE__ */ I("div", { ...g("breadcrumb"), key: k }, _);
    return D.push(U), k !== K.length - 1 && D.push(
      /* @__PURE__ */ I(w, { ...g("separator"), key: `separator-${k}` }, m)
    ), D;
  }, []);
  return /* @__PURE__ */ s(w, { ref: r, ...g("root"), ...u, children: z });
});
E.classes = H;
E.displayName = "@mantine/core/Breadcrumbs";
var Q = { root: "m_b183c0a2" };
const ke = {}, Ce = $((a, { color: r }) => ({
  root: {
    "--code-bg": r ? re(r, a) : void 0
  }
})), v = F((a, r) => {
  const e = G("Code", ke, a), {
    classNames: l,
    className: c,
    style: i,
    styles: t,
    unstyled: o,
    vars: d,
    color: x,
    block: m,
    variant: y,
    mod: u,
    ...g
  } = e, z = M({
    name: "Code",
    props: e,
    classes: Q,
    className: c,
    style: i,
    classNames: l,
    styles: t,
    unstyled: o,
    vars: d,
    varsResolver: Ce
  });
  return /* @__PURE__ */ s(
    w,
    {
      component: m ? "pre" : "code",
      variant: y,
      ref: r,
      mod: [{ block: m }, u],
      ...z("root"),
      ...g,
      dir: "ltr"
    }
  );
});
v.classes = Q;
v.displayName = "@mantine/core/Code";
const Se = "_breadcrumbs_fo0zv_1", ze = "_separator_fo0zv_6", De = "_anchor_fo0zv_10", Te = "_anchorClickable_fo0zv_14", Le = "_anchorStatic_fo0zv_18", h = {
  breadcrumbs: Se,
  separator: ze,
  anchor: De,
  anchorClickable: Te,
  anchorStatic: Le
};
function Ne(a) {
  return "type" in a && a.type === "ellipsis";
}
const q = 2, W = 2, Pe = q + W + 1, Oe = ({
  items: a,
  size: r = "lg",
  ...e
}) => {
  const [l, c] = R(null), i = l === a.length, t = Z(() => i || a.length <= Pe ? a : [
    ...a.slice(0, q),
    { type: "ellipsis" },
    ...a.slice(a.length - W)
  ], [a, i]);
  return /* @__PURE__ */ s(
    E,
    {
      ...e,
      classNames: {
        root: h.breadcrumbs,
        separator: h.separator
      },
      children: t.map((o, d) => {
        if (Ne(o))
          return /* @__PURE__ */ s(
            C,
            {
              size: r,
              fw: 500,
              c: "ldGray.6",
              className: `${h.anchor} ${h.anchorClickable}`,
              onClick: () => c(a.length),
              children: "..."
            },
            "ellipsis"
          );
        const x = !!(o.onClick || o.to), m = `${h.anchor} ${x ? h.anchorClickable : h.anchorStatic}`, y = {
          size: r,
          fw: o.active ? 600 : 500,
          c: o.active ? "ldGray.9" : "ldGray.6",
          onClick: o.onClick,
          className: m
        }, u = o.to ? /* @__PURE__ */ s(
          C,
          {
            component: oe,
            to: o.to,
            ...y,
            children: o.title
          },
          o.tooltipProps ? void 0 : d
        ) : /* @__PURE__ */ s(
          C,
          {
            ...y,
            children: o.title
          },
          o.tooltipProps ? void 0 : d
        );
        return o.tooltipProps ? /* @__PURE__ */ s(O, { ...o.tooltipProps, children: u }, d) : u;
      })
    }
  );
}, Be = (a, r, e) => {
  a.type === "element" && a.tagName === "a" && e && e.type === "element" && /^h(1|2|3|4|5|6)/.test(e.tagName) && (e.children = e.children.slice(1));
}, J = ({ source: a }) => {
  const r = te();
  return /* @__PURE__ */ s(
    ne,
    {
      skipHtml: !0,
      components: {
        h1: ({ children: e }) => /* @__PURE__ */ s(L, { order: 2, children: e }),
        h2: ({ children: e }) => /* @__PURE__ */ s(L, { order: 3, children: e }),
        h3: ({ children: e }) => /* @__PURE__ */ s(L, { order: 4, children: e })
      },
      rehypePlugins: [[le, { target: "_blank" }]],
      rehypeRewrite: Be,
      source: a,
      disallowedElements: ["img"],
      style: {
        fontSize: r.fontSizes.sm,
        color: r.colors.ldGray[7],
        backgroundColor: "transparent"
      }
    }
  );
}, Ee = ({ description: a, onViewDescription: r, metricInfo: e }) => {
  const l = a && a.length > 180 || a && a.split(`
`).length > 2, [c, i] = R(!1);
  return /* @__PURE__ */ n(S, { gap: "xs", children: [
    e && /* @__PURE__ */ s(b, { children: /* @__PURE__ */ n(f, { gap: "xs", justify: "space-between", children: [
      /* @__PURE__ */ s(p, { fz: "sm", fw: 500, c: "ldDark.7", children: e.name }),
      /* @__PURE__ */ s(
        ce,
        {
          radius: "sm",
          color: "indigo",
          p: 2,
          style: {
            boxShadow: "var(--mantine-shadow-subtle)",
            border: "1px solid var(--mantine-color-indigo-1)"
          },
          children: ie(e.type)
        }
      )
    ] }) }),
    a && /* @__PURE__ */ s(
      w,
      {
        mah: 120,
        style: {
          overflow: "hidden",
          // If we're over the truncation limit, use a mask to fade out the bottom of the container.
          maskImage: l ? "linear-gradient(180deg, white 0%, white 80%, transparent 100%)" : void 0
        },
        children: /* @__PURE__ */ n(S, { gap: "xs", children: [
          e && /* @__PURE__ */ n(b, { children: [
            /* @__PURE__ */ s(P, { color: "ldGray.2" }),
            /* @__PURE__ */ s(p, { fz: "xs", fw: 500, c: "ldDark.7", children: "Description" })
          ] }),
          /* @__PURE__ */ s(J, { source: a })
        ] })
      }
    ),
    l && /* @__PURE__ */ s(w, { ta: "center", children: /* @__PURE__ */ s(
      C,
      {
        size: "xs",
        onClick: (t) => {
          t.preventDefault(), r();
        },
        children: "Read full description"
      }
    ) }),
    e && /* @__PURE__ */ n(b, { children: [
      /* @__PURE__ */ s(P, { color: "ldGray.2" }),
      /* @__PURE__ */ n(S, { gap: "xs", children: [
        /* @__PURE__ */ n(f, { gap: "xs", align: "center", justify: "space-between", children: [
          /* @__PURE__ */ s(p, { fz: "xs", fw: 500, c: "ldDark.7", children: "SQL" }),
          /* @__PURE__ */ s(
            O,
            {
              variant: "xs",
              position: "right",
              label: c ? "Show original SQL" : "Show compiled SQL",
              children: /* @__PURE__ */ s(
                de,
                {
                  variant: "subtle",
                  color: "gray",
                  onClick: (t) => {
                    t.stopPropagation(), i(!c);
                  },
                  size: "compact-xs",
                  leftSection: /* @__PURE__ */ s(A, { icon: pe }),
                  children: c ? "Original SQL" : "Compiled SQL"
                }
              )
            }
          )
        ] }),
        /* @__PURE__ */ s(v, { maw: 400, children: c ? e.compiledSql : e.sql }),
        e.filters && e.filters.length > 0 && /* @__PURE__ */ n(b, { children: [
          /* @__PURE__ */ s(P, { color: "ldGray.2" }),
          /* @__PURE__ */ s(p, { fz: "xs", fw: 500, c: "ldDark.7", children: "Filters" }),
          e.filters.map((t) => {
            const o = he[t.operator];
            return /* @__PURE__ */ n(f, { gap: 4, children: [
              /* @__PURE__ */ s(v, { fz: "xs", fw: 500, children: t.target.fieldRef }),
              /* @__PURE__ */ s(p, { fz: "xs", fw: 500, children: o }),
              /* @__PURE__ */ n(v, { fz: "xs", children: [
                ue(
                  t.operator
                ) ? t.values?.map(
                  (d) => d
                ).join(", ") : "",
                me(
                  t
                ) && /* @__PURE__ */ n(ee, { children: [
                  " ",
                  t.settings?.completed ? "completed" : "",
                  t.settings?.unitOfTime
                ] })
              ] })
            ] }, t.id);
          })
        ] })
      ] })
    ] })
  ] });
}, je = ({
  showPreview: a,
  closePreview: r,
  label: e,
  description: l,
  /** Position offset for the preview popover */
  offset: c = 20,
  children: i
}) => {
  const t = j(), o = () => {
    r(), t(
      V.openItemDetail({
        itemType: "table",
        label: e,
        description: l
      })
    );
  };
  return /* @__PURE__ */ n(
    N,
    {
      opened: a,
      keepMounted: !1,
      shadow: "sm",
      withinPortal: !0,
      disabled: !l,
      position: "right",
      withArrow: !0,
      offset: c,
      children: [
        /* @__PURE__ */ s(N.Target, { children: i }),
        /* @__PURE__ */ s(
          N.Dropdown,
          {
            maw: 500,
            onClick: (d) => d.stopPropagation(),
            children: /* @__PURE__ */ s(
              Ee,
              {
                onViewDescription: o,
                description: l
              }
            )
          }
        )
      ]
    }
  );
}, Ae = ({ children: a }) => {
  const r = j(), e = ge(be), l = T(() => {
    r(V.closeItemDetail());
  }, [r]), c = T(() => {
    if (!e.itemType || !e.label) return null;
    switch (e.itemType) {
      case "field":
        return /* @__PURE__ */ n(f, { children: [
          e.fieldItem && /* @__PURE__ */ s(
            we,
            {
              item: e.fieldItem,
              color: ye(e.fieldItem),
              size: "md"
            }
          ),
          /* @__PURE__ */ s(p, { fz: "md", children: e.label })
        ] });
      case "table":
        return /* @__PURE__ */ n(f, { gap: "sm", children: [
          /* @__PURE__ */ s(
            A,
            {
              icon: fe,
              size: "lg",
              color: "ldGray.7"
            }
          ),
          /* @__PURE__ */ s(p, { fz: "md", children: e.label })
        ] });
      case "group":
        return /* @__PURE__ */ s(f, { children: /* @__PURE__ */ s(p, { fz: "md", children: e.label }) });
      default:
        return null;
    }
  }, [e.itemType, e.label, e.fieldItem]), i = T(() => e.description ? /* @__PURE__ */ s(J, { source: e.description }) : /* @__PURE__ */ s(p, { c: "gray", children: "No description available." }), [e.description]);
  return /* @__PURE__ */ n(b, { children: [
    e.isOpen && /* @__PURE__ */ s(
      ve,
      {
        p: "xl",
        size: "lg",
        opened: e.isOpen,
        onClose: l,
        title: c(),
        children: i()
      }
    ),
    a
  ] });
}, Ie = "_warningsList_1fmja_1", Re = "_warningBox_1fmja_5", Fe = "_warningText_1fmja_9", B = {
  warningsList: Ie,
  warningBox: Re,
  warningText: Fe
}, Ve = ({
  type: a,
  warnings: r
}) => /* @__PURE__ */ n(b, { children: [
  /* @__PURE__ */ n(p, { fz: "sm", fw: 600, mb: "xs", children: [
    "Compilation ",
    a,
    " (",
    r.length,
    ")"
  ] }),
  /* @__PURE__ */ s(S, { className: B.warningsList, gap: "xs", mah: 250, children: r.map((e, l) => /* @__PURE__ */ s(
    w,
    {
      className: B.warningBox,
      p: "xs",
      bg: "ldGray.0",
      children: /* @__PURE__ */ s(p, { className: B.warningText, fz: "xs", children: e.message })
    },
    l
  )) })
] });
export {
  Ee as I,
  Oe as P,
  je as T,
  Ve as W,
  Ae as a
};
//# sourceMappingURL=WarningsHoverCardContent-BSRvQsTK.mjs.map
