import { X as x, Y as t, a3 as m, P as L, w as P, S as F, eh as k, O as g, a as A, Z as p, c2 as I, c3 as M, ek as N, N as D, U as H, F as n, a6 as a, G as S, a7 as o, a8 as r, el as O, af as c, dB as R, em as W, aa as B, ac as U, at as _, en as d } from "./603b75d9.js";
import { useContext as u, useEffect as $ } from "react";
import { treeCommonChildren as j, treeDataPropertyView as q, formSection as G, valuePropertyView as K, TreeNameConfigs as X, useTree as Y } from "./425a28f6.js";
import { getStyle as Z, baseSelectRefMethods as z } from "./0cdeb449.js";
import { SelectInputValidationSection as J, useSelectInputValidate as Q } from "./00d44232.js";
import "react-dom";
import "./f9847c56.js";
import "./7030eb81.js";
import "./d50792b8.js";
import "./f64a8554.js";
const ee = x(d)`
  width: 100%;
  ${(e) => e.$style && Z(e.$style)}
`, te = [{
  label: t("tree.singleSelect"),
  value: "single"
}, {
  label: t("tree.multiSelect"),
  value: "multi"
}, {
  label: t("tree.checkbox"),
  value: "check"
}], le = [{
  label: t("tree.showAll"),
  value: "all"
}, {
  label: t("tree.showParent"),
  value: "parent"
}, {
  label: t("tree.showChild"),
  value: "child"
}], ae = {
  ...j,
  selectType: m(te, "single"),
  checkedStrategy: m(le, "parent"),
  label: L,
  placeholder: P(F, t("tree.placeholder")),
  // TODO: more event
  onEvent: k,
  allowClear: g,
  showSearch: g.DEFAULT_TRUE,
  inputValue: A(""),
  // search value
  style: p(I, "style"),
  labelStyle: p(M, "labelStyle"),
  inputFieldStyle: p(N, "inputFieldStyle"),
  viewRef: D
};
function oe(e) {
  switch (e) {
    case "all":
      return d.SHOW_ALL;
    case "parent":
      return d.SHOW_PARENT;
    case "child":
      return d.SHOW_CHILD;
  }
}
const re = (e) => {
  const {
    treeData: y,
    selectType: s,
    value: i,
    expanded: b,
    style: C,
    labelStyle: f,
    inputValue: V
  } = e, h = s === "single", [v, E] = Q(e);
  return $(() => {
    h && i.value.length > 1 && i.onChange(i.value.slice(0, 1));
  }, [s]), Y(e), e.label({
    required: e.required,
    ...v,
    style: C,
    labelStyle: f,
    inputFieldStyle: e.inputFieldStyle,
    children: /* @__PURE__ */ n(ee, {
      ref: e.viewRef,
      $style: e.inputFieldStyle,
      popupMatchSelectWidth: !1,
      disabled: e.disabled,
      placeholder: e.placeholder,
      allowClear: e.allowClear,
      fieldNames: {
        label: "label",
        value: "value"
      },
      treeData: y,
      multiple: !h,
      value: h ? i.value[0] : i.value,
      treeCheckable: s === "check",
      showCheckedStrategy: oe(e.checkedStrategy),
      treeLine: e.showLine ? {
        showLeafIcon: e.showLeafIcon
      } : !1,
      treeExpandedKeys: V ? void 0 : b.value,
      onTreeExpand: (l) => {
        b.onChange(l);
      },
      onChange: (l) => {
        const T = Array.isArray(l) ? l : l !== void 0 ? [l] : [];
        E(T);
      },
      showSearch: e.showSearch,
      treeNodeFilterProp: "label",
      autoClearSearchValue: !1,
      onSearch: (l) => {
        e.dispatch(_("inputValue", l, !1));
      },
      onFocus: () => e.onEvent("focus"),
      onBlur: () => e.onEvent("blur")
    }, s),
    showValidationWhenEmpty: e.showValidationWhenEmpty
  });
};
let w = function() {
  return new H(ae, (e, y) => /* @__PURE__ */ n(re, {
    ...e,
    dispatch: y
  })).setPropertyViewFn((e) => /* @__PURE__ */ a(S, {
    children: [/* @__PURE__ */ a(o, {
      name: r.basic,
      children: [q(e), O(e)]
    }), ["logic", "both"].includes(u(c).editorModeStatus) && /* @__PURE__ */ a(S, {
      children: [/* @__PURE__ */ n(J, {
        ...e
      }), G(e), /* @__PURE__ */ a(o, {
        name: r.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), W(e)]
      })]
    }), ["layout", "both"].includes(u(c).editorModeStatus) && /* @__PURE__ */ a(o, {
      name: r.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__ */ a(S, {
      children: [/* @__PURE__ */ n(o, {
        name: r.style,
        children: e.style.getPropertyView()
      }), /* @__PURE__ */ n(o, {
        name: r.labelStyle,
        children: e.labelStyle.getPropertyView()
      }), /* @__PURE__ */ n(o, {
        name: r.inputFieldStyle,
        children: e.inputFieldStyle.getPropertyView()
      })]
    })]
  })).setExposeMethodConfigs(z).build();
}();
w = class extends w {
  autoHeight() {
    return !0;
  }
};
const we = B(w, [...X, new U("inputValue", t("select.inputValueDesc"))]);
export {
  we as TreeSelectComp
};
