import _ from "../../../@ant-design/icons/es/icons/QuestionCircleOutlined.mjs";
import v from "../../../classnames/index.mjs";
import * as l from "react";
import w from "../grid/col.mjs";
import A from "../locale/en_US.mjs";
import I from "../tooltip/index.mjs";
import { FormContext as M } from "./context.mjs";
import R from "../locale/useLocale.mjs";
var S = globalThis && globalThis.__rest || function(e, r) {
  var o = {};
  for (var t in e)
    Object.prototype.hasOwnProperty.call(e, t) && r.indexOf(t) < 0 && (o[t] = e[t]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var n = 0, t = Object.getOwnPropertySymbols(e); n < t.length; n++)
      r.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[n]) && (o[t[n]] = e[t[n]]);
  return o;
};
function B(e) {
  return e ? typeof e == "object" && !/* @__PURE__ */ l.isValidElement(e) ? e : {
    title: e
  } : null;
}
const D = (e) => {
  let {
    prefixCls: r,
    label: o,
    htmlFor: t,
    labelCol: n,
    labelAlign: y,
    colon: u,
    required: i,
    requiredMark: c,
    tooltip: O
  } = e;
  var s;
  const [m] = R("Form"), {
    vertical: x,
    labelAlign: E,
    labelCol: $,
    labelWrap: h,
    colon: F
  } = l.useContext(M);
  if (!o)
    return null;
  const b = n || $ || {}, L = y || E, f = `${r}-item-label`, N = v(f, L === "left" && `${f}-left`, b.className, {
    [`${f}-wrap`]: !!h
  });
  let a = o;
  const d = u === !0 || F !== !1 && u !== !1;
  d && !x && typeof o == "string" && o.trim() !== "" && (a = o.replace(/[:|：]\s*$/, ""));
  const p = B(O);
  if (p) {
    const {
      icon: P = /* @__PURE__ */ l.createElement(_, null)
    } = p, k = S(p, ["icon"]), q = /* @__PURE__ */ l.createElement(I, Object.assign({}, k), /* @__PURE__ */ l.cloneElement(P, {
      className: `${r}-item-tooltip`,
      title: "",
      onClick: (T) => {
        T.preventDefault();
      },
      tabIndex: null
    }));
    a = /* @__PURE__ */ l.createElement(l.Fragment, null, a, q);
  }
  const C = c === "optional", g = typeof c == "function";
  g ? a = c(a, {
    required: !!i
  }) : C && !i && (a = /* @__PURE__ */ l.createElement(l.Fragment, null, a, /* @__PURE__ */ l.createElement("span", {
    className: `${r}-item-optional`,
    title: ""
  }, (m == null ? void 0 : m.optional) || ((s = A.Form) === null || s === void 0 ? void 0 : s.optional))));
  const j = v({
    [`${r}-item-required`]: i,
    [`${r}-item-required-mark-optional`]: C || g,
    [`${r}-item-no-colon`]: !d
  });
  return /* @__PURE__ */ l.createElement(w, Object.assign({}, b, {
    className: N
  }), /* @__PURE__ */ l.createElement("label", {
    htmlFor: t,
    className: j,
    title: typeof o == "string" ? o : ""
  }, a));
}, U = D;
export {
  U as default
};
