import { eF as b, g8 as d, g9 as m, bv as l, bd as h, a0 as r, V as c, P as x, bi as C, bh as D, bo as i, bp as v, fb as n } from "./684d2f28.js";
import { useEffect as V } from "react";
import { formDataChildren as g, FormDataPropertyView as w } from "./00dac55d.js";
import { SelectInputValidationChildren as y, SelectInputInvalidConfig as k } from "./1312a48b.js";
import { defaultTreeData as S, treeDataTooltip as j } from "./7ca8657c.js";
import "react-dom";
import "./d6402597.js";
function u(e, t) {
  return n(e, ["string", "number"], t);
}
function f(e, t) {
  return n(e, ["array", "undefined"], t, (a, o) => (n(a, ["object"], o), n(a.label, ["string"], "label"), u(a.value, "value"), n(a.disabled, ["boolean", "undefined"], "disabled"), n(a.selectable, ["boolean", "undefined"], "selectable"), n(a.checkable, ["boolean", "undefined"], "checkable"), n(a.disableCheckbox, ["boolean", "undefined"], "disableCheckbox"), n(a.isLeaf, ["boolean", "undefined"], "isLeaf"), f(a.children, "children"), a));
}
function E(e) {
  return e === "" ? [] : f(e) ?? [];
}
function s(e) {
  return e === "" ? [] : n(e, ["array"], void 0, u);
}
function p(e, t) {
  if (e) {
    for (const a of e)
      if (t(a) === !1 || !p(a.children, t))
        return !1;
  }
  return !0;
}
function N(e) {
  const t = [];
  return p(e, (a) => {
    a.children && a.children.length > 0 && t.push(a.value);
  }), t;
}
const q = {
  // TODO: support loading mode
  treeData: b(E, S),
  defaultValue: d("value", s, []),
  value: d("value", s, []),
  expanded: m(s, []),
  defaultExpandAll: l,
  showLine: l,
  showLeafIcon: l,
  disabled: h,
  ...y,
  ...g
};
function z(e) {
  const {
    treeData: t,
    expanded: a,
    defaultExpandAll: o
  } = e;
  V(() => {
    o ? a.onChange(N(t)) : a.reset();
  }, [o]);
}
const G = (e) => e.treeData.propertyView({
  label: r("tree.treeData"),
  tooltip: j
}), H = (e) => e.defaultValue.propertyView({
  label: r("tree.value")
}), J = (e) => /* @__PURE__ */ c(w, {
  ...e
}), K = (e, t) => /* @__PURE__ */ x(C, {
  name: r("prop.expand"),
  children: [e.expanded.propertyView({
    label: r("tree.expanded")
  }), e.defaultExpandAll.propertyView({
    label: r("tree.defaultExpandAll")
  }), t]
}), M = (e, t) => /* @__PURE__ */ c(D, {}), O = [
  // TODO: more data
  new i("value", r("tree.valueDesc")),
  new i("treeData", r("tree.treeDataDesc")),
  new i("expanded", r("tree.expandedDesc")),
  k,
  ...v
];
export {
  O as TreeNameConfigs,
  M as advancedSection,
  K as expandSection,
  J as formSection,
  q as treeCommonChildren,
  G as treeDataPropertyView,
  z as useTree,
  H as valuePropertyView
};
