import { O as f, ce as C, cm as I, Y as u, cc as o, a6 as p, a7 as R, a8 as y, ca as g, cP as x, d8 as E, cR as w } from "./603b75d9.js";
import { useState as b, useRef as m, useEffect as h } from "react";
import "react-dom";
const W = {
  required: f,
  showValidationWhenEmpty: f,
  customRule: C
}, V = (e) => {
  if (e.customRule)
    return {
      validateStatus: "error",
      help: e.customRule
    };
  const t = e.value.value;
  return e.required && I.isEmpty(t) ? {
    validateStatus: "error",
    help: u("prop.required")
  } : {
    validateStatus: "success"
  };
}, L = (e) => {
  var r;
  const [t, l] = b({}), n = m(!1), c = m(e);
  c.current = e;
  const i = e.value.value, d = (r = e.defaultValue) == null ? void 0 : r.value, S = (a) => {
    l(V({
      ...c.current,
      value: {
        value: a
      }
    }));
  };
  return h(() => {
    var a, s;
    (s = (a = e.value).onChange) == null || s.call(a, d);
  }, [d]), h(() => {
    var a;
    n.current && (S(i), (a = e.onEvent) == null || a.call(e, "change"), n.current = !1);
  }, [i]), [
    t,
    (a) => {
      var s, v;
      (v = (s = e.value).onChange) == null || v.call(s, a), n.current = !0;
    }
  ];
}, O = o({
  name: "invalid",
  desc: u("export.invalidDesc"),
  depKeys: ["value", "required", "customRule"],
  func: (e) => V({
    ...e,
    value: {
      value: e.value
    }
  }).validateStatus !== "success"
}), P = (e) => /* @__PURE__ */ p(R, {
  name: y.validation,
  children: [g(e), e.showValidationWhenEmpty.propertyView({
    label: u("prop.showEmptyValidation")
  }), e.customRule.propertyView({})]
}), j = [o({
  name: "selectedIndex",
  desc: u("selectInput.selectedIndexDesc"),
  depKeys: ["value", "options"],
  func: (e) => {
    var t, l;
    return (l = (t = e.options).findIndex) == null ? void 0 : l.call(t, (n) => n.value === e.value);
  }
}), o({
  name: "selectedLabel",
  desc: u("selectInput.selectedLabelDesc"),
  depKeys: ["value", "options"],
  func: (e) => {
    var t, l, n;
    return (n = (l = (t = e.options).find) == null ? void 0 : l.call(t, (c) => c.value === e.value)) == null ? void 0 : n.label;
  }
})], B = x([E, w]);
export {
  j as SelectInputCommonConfig,
  O as SelectInputInvalidConfig,
  W as SelectInputValidationChildren,
  P as SelectInputValidationSection,
  B as selectDivRefMethods,
  V as selectInputValidate,
  L as useSelectInputValidate
};
