import { b9 as E, a0 as t, bb as m, bK as L, w as P, ba as k, ei as A, bv as g, a as I, bB as C, el as M, bO as D, bf as H, U as N, V as s, P as l, bh as p, bi as r, bj as n, em as O, bg as c, dm as R, en as B, bn as F, bo as U, eo as d, ea as W } from "./684d2f28.js";
import { useContext as u, useEffect as _ } from "react";
import { treeCommonChildren as $, treeDataPropertyView as j, formSection as q, valuePropertyView as K, TreeNameConfigs as z, useTree as G } from "./639bcad1.js";
import { getStyle as J, baseSelectRefMethods as Q } from "./f9c25fbe.js";
import { SelectInputValidationSection as X, useSelectInputValidate as Y } from "./1312a48b.js";
import "react-dom";
import "./00dac55d.js";
import "./7ca8657c.js";
import "./2d5fc5ff.js";
import "./0f3d7a1a.js";
import "./d6402597.js";
const Z = E(d)`
  width: 100%;
  ${(e) => e.$style && J(e.$style)}
`, ee = [{
  label: t("tree.singleSelect"),
  value: "single"
}, {
  label: t("tree.multiSelect"),
  value: "multi"
}, {
  label: t("tree.checkbox"),
  value: "check"
}], te = [{
  label: t("tree.showAll"),
  value: "all"
}, {
  label: t("tree.showParent"),
  value: "parent"
}, {
  label: t("tree.showChild"),
  value: "child"
}], ae = {
  ...$,
  selectType: m(ee, "single"),
  checkedStrategy: m(te, "parent"),
  label: L,
  placeholder: P(k, t("tree.placeholder")),
  // TODO: more event
  onEvent: A,
  allowClear: g,
  showSearch: g.DEFAULT_TRUE,
  inputValue: I(""),
  // search value
  style: C(M),
  labelStyle: C(D),
  viewRef: H
};
function le(e) {
  switch (e) {
    case "all":
      return d.SHOW_ALL;
    case "parent":
      return d.SHOW_PARENT;
    case "child":
      return d.SHOW_CHILD;
  }
}
const oe = (e) => {
  const {
    treeData: h,
    selectType: i,
    value: o,
    expanded: y,
    style: S,
    labelStyle: f,
    inputValue: V
  } = e, b = i === "single", [v, T] = Y(e);
  return _(() => {
    b && o.value.length > 1 && o.onChange(o.value.slice(0, 1));
  }, [i]), G(e), e.label({
    required: e.required,
    ...v,
    style: S,
    labelStyle: f,
    children: /* @__PURE__ */ s(Z, {
      ref: e.viewRef,
      $style: S,
      popupMatchSelectWidth: !1,
      disabled: e.disabled,
      placeholder: e.placeholder,
      allowClear: e.allowClear,
      fieldNames: {
        label: "label",
        value: "value"
      },
      treeData: h,
      multiple: !b,
      value: b ? o.value[0] : o.value,
      treeCheckable: i === "check",
      showCheckedStrategy: le(e.checkedStrategy),
      treeLine: e.showLine ? {
        showLeafIcon: e.showLeafIcon
      } : !1,
      treeExpandedKeys: V ? void 0 : y.value,
      onTreeExpand: (a) => {
        y.onChange(a);
      },
      onChange: (a) => {
        const x = Array.isArray(a) ? a : a !== void 0 ? [a] : [];
        T(x);
      },
      showSearch: e.showSearch,
      treeNodeFilterProp: "label",
      autoClearSearchValue: !1,
      onSearch: (a) => {
        e.dispatch(W("inputValue", a, !1));
      },
      onFocus: () => e.onEvent("focus"),
      onBlur: () => e.onEvent("blur")
    }, i)
  });
};
let w = function() {
  return new N(ae, (e, h) => /* @__PURE__ */ s(oe, {
    ...e,
    dispatch: h
  })).setPropertyViewFn((e) => /* @__PURE__ */ l(p, {
    children: [/* @__PURE__ */ l(r, {
      name: n.basic,
      children: [j(e), O(e)]
    }), ["logic", "both"].includes(u(c).editorModeStatus) && /* @__PURE__ */ l(p, {
      children: [/* @__PURE__ */ s(X, {
        ...e
      }), q(e), /* @__PURE__ */ l(r, {
        name: n.interaction,
        children: [e.onEvent.getPropertyView(), e.hidden.propertyView({
          label: t("prop.hide")
        }), e.disabled.propertyView({
          label: t("prop.disabled")
        }), e.selectType.propertyView({
          label: t("tree.selectType")
        }), K(e), e.selectType.getView() === "check" && e.checkedStrategy.propertyView({
          label: t("tree.checkedStrategy")
        }), R(e), B(e)]
      })]
    }), ["layout", "both"].includes(u(c).editorModeStatus) && /* @__PURE__ */ l(r, {
      name: n.layout,
      children: [e.expanded.propertyView({
        label: t("tree.expanded")
      }), e.defaultExpandAll.propertyView({
        label: t("tree.defaultExpandAll")
      }), e.showLine.propertyView({
        label: t("tree.showLine")
      }), e.showLine.getView() && e.showLeafIcon.propertyView({
        label: t("tree.showLeafIcon")
      })]
    }), ["layout", "both"].includes(u(c).editorModeStatus) && e.label.getPropertyView(), ["layout", "both"].includes(u(c).editorModeStatus) && /* @__PURE__ */ l(p, {
      children: [/* @__PURE__ */ s(r, {
        name: n.style,
        children: e.style.getPropertyView()
      }), /* @__PURE__ */ s(r, {
        name: n.labelStyle,
        children: e.labelStyle.getPropertyView()
      })]
    })]
  })).setExposeMethodConfigs(Q).build();
}();
w = class extends w {
  autoHeight() {
    return !0;
  }
};
const ye = F(w, [...z, new U("inputValue", t("select.inputValueDesc"))]);
export {
  ye as TreeSelectComp
};
