import { j as e } from "../../node_modules/react/jsx-runtime.mjs";
import { useEffect as y } from "react";
import { useImmer as C } from "../../node_modules/use-immer/dist/use-immer.module.mjs";
import "../../node_modules/react-device-detect/dist/lib.mjs";
import "../BitzDrawer/index.less.mjs";
import o from "./index.module.less.mjs";
import b from "../../node_modules/antd/es/theme/index.mjs";
import N from "../../node_modules/antd/es/input/index.mjs";
import S from "../../node_modules/antd/es/tree/index.mjs";
import w from "../../node_modules/@ant-design/icons/es/icons/CaretDownFilled.mjs";
import z from "../../node_modules/antd/es/space/index.mjs";
import T from "../../node_modules/antd/es/button/button.mjs";
import v from "../../node_modules/@ant-design/icons/es/icons/SettingFilled.mjs";
import E from "../../node_modules/antd/es/tag/index.mjs";
const { CheckableTag: I } = E, R = (p) => {
  const { headerRender: s, tags: t, onTagChange: a, onSearch: i, treeTitle: f, defaultCheckedKeys: h, defaultExpandedKeys: u, treeData: d, onCheck: x } = p, { token: g } = b.useToken(), [c, l] = C({
    tags: []
  });
  y(() => {
    t && l((r) => {
      r.tags = t;
    });
  }, [t == null ? void 0 : t.length]);
  function j() {
    return c.tags.length ? /* @__PURE__ */ e.jsxs("div", { className: o.header, children: [
      /* @__PURE__ */ e.jsx(z, { size: [0, 8], wrap: !0, children: c.tags.map((r, m) => /* @__PURE__ */ e.jsx(
        I,
        {
          checked: !!r.checked,
          onChange: async (n) => {
            l((k) => {
              k.tags[m].checked = n;
            }), a == null || a({ ...r, checked: n }, n);
          },
          children: r.label
        },
        m
      )) }),
      /* @__PURE__ */ e.jsx(T, { icon: /* @__PURE__ */ e.jsx(v, { style: { color: g.colorPrimary } }), type: "text", className: o["setting-btn"] })
    ] }) : s == null ? void 0 : s();
  }
  return /* @__PURE__ */ e.jsxs("div", { className: o.container, children: [
    j(),
    i && /* @__PURE__ */ e.jsx(N, { className: o.search, placeholder: "组织名称查询", onChange: i }),
    f,
    /* @__PURE__ */ e.jsx(
      S,
      {
        checkable: !0,
        showLine: !0,
        blockNode: !0,
        selectable: !1,
        switcherIcon: /* @__PURE__ */ e.jsx(w, { style: { verticalAlign: "top", fontSize: 24, color: "#86909C" } }),
        defaultCheckedKeys: h,
        defaultExpandedKeys: u,
        treeData: d,
        onCheck: x
      }
    )
  ] });
};
export {
  R as default
};
