import { j as e } from "../../node_modules/react/jsx-runtime.mjs";
import { useMemo as m } from "react";
import A from "../../node_modules/rc-resize-observer/es/index.mjs";
import M from "./QueryFilterContent.mjs";
import O from "../../hooks/useMergedState.mjs";
import P from "./QueryFilterMobile.mjs";
import x from "../../node_modules/antd/es/form/index.mjs";
import B from "../../node_modules/lodash-es/isArray.mjs";
import j from "../../node_modules/antd/es/grid/col.mjs";
import E from "../../node_modules/antd/es/grid/row.mjs";
const Q = {
  xs: 513,
  sm: 513,
  md: 785,
  lg: 992,
  xl: 1057,
  xxl: 1 / 0
}, z = {
  vertical: [
    // [breakpoint, cols, layout]
    [513, 1, "vertical"],
    [785, 2, "vertical"],
    [1057, 3, "vertical"],
    [1 / 0, 4, "vertical"]
  ],
  default: [
    [513, 1, "vertical"],
    [701, 2, "vertical"],
    [1062, 3, "horizontal"],
    [1352, 3, "horizontal"],
    [1 / 0, 4, "horizontal"]
  ]
}, G = (n, d, r) => {
  if (r && typeof r == "number")
    return {
      span: r,
      layout: n
    };
  const s = ((r ? ["xs", "sm", "md", "lg", "xl", "xxl"].map((t) => [Q[t], 24 / r[t], "horizontal"]) : z[n || "default"]) || z.default).find(
    (t) => d < t[0] + 16
    // 16 = 2 * (ant-row -8px margin)
  );
  return {
    span: 24 / s[1],
    layout: s[2]
  };
};
var g;
const K = (g = document == null ? void 0 : document.body) == null ? void 0 : g.clientWidth, V = (n) => {
  const {
    collapsed: d,
    onCollapse: r,
    defaultCollapsed: y = !0,
    searchGutter: s = 24,
    children: t,
    style: o,
    layout: v,
    span: C,
    defaultColsNumber: u,
    labelWidth: l = "80",
    showHiddenNum: R = !1,
    ignoreRules: F,
    split: I,
    preserve: c = !0,
    onReset: f,
    onFinish: b
  } = n, [a] = x.useForm(), [p, N] = O(() => typeof (o == null ? void 0 : o.width) == "number" ? o == null ? void 0 : o.width : K), i = m(() => G(v, p + 16, C), [v, p, C]), S = m(() => u !== void 0 ? u - 1 : Math.max(1, 24 / i.span - 1), [u, i.span]), W = m(() => {
    if (l && i.layout !== "vertical" && l !== "auto")
      return {
        labelCol: {
          flex: `0 0 ${l}px`
        },
        wrapperCol: {
          style: {
            maxWidth: `calc(100% - ${l}px)`
          }
        },
        style: {
          flexWrap: "nowrap"
        }
      };
  }, [i.layout, l]), w = m(() => B(t) ? t : [t], [t]);
  return /* @__PURE__ */ e.jsx(
    A,
    {
      onResize: (h) => {
        p !== h.width && h.width > 17 && N(h.width);
      },
      children: /* @__PURE__ */ e.jsxs(E, { children: [
        /* @__PURE__ */ e.jsx(j, { md: 24, sm: 0, xs: 0, children: /* @__PURE__ */ e.jsx(x, { preserve: c, form: a, layout: i.layout, ...W, children: /* @__PURE__ */ e.jsx(
          M,
          {
            onFinish: b,
            defaultCollapsed: y,
            collapsed: d,
            onCollapse: r,
            searchGutter: s,
            spanSize: i,
            items: w,
            split: I,
            ignoreRules: F,
            showLength: S,
            showHiddenNum: R,
            form: a,
            baseClassName: "bitz",
            preserve: c,
            onReset: f
          }
        ) }) }),
        /* @__PURE__ */ e.jsx(j, { md: 0, sm: 24, xs: 24, children: /* @__PURE__ */ e.jsx(x, { onReset: f, preserve: c, form: a, layout: "vertical", children: /* @__PURE__ */ e.jsx(P, { onFinish: b, form: a, items: w, onReset: f }) }) })
      ] })
    },
    "resize-observer"
  );
};
export {
  V as default
};
