import { defineComponent as q, useSlots as O, inject as B, computed as a, watch as T, onMounted as U, onUnmounted as x, openBlock as s, createBlock as v, unref as l, mergeProps as P, withCtx as n, createSlots as z, createElementVNode as h, normalizeClass as f, createElementBlock as u, renderSlot as i, createCommentVNode as d, normalizeStyle as A, createVNode as b, createTextVNode as D, toDisplayString as M, withDirectives as Q, vShow as G } from "vue";
import { useNamespace as H, ElCol as J, ElFormItem as K, ElTooltip as L, ElIcon as R, colProps as X, formItemProps as Y } from "element-plus";
import { wetProFormItemProps as Z } from "../types.mjs";
import { SymbolState as ee } from "../symbol.mjs";
import "../../../confirm-button/index.mjs";
import "../../../count-down-button/index.mjs";
import { TextEllipsis as te } from "../../../ellipsis/index.mjs";
import "../../../rich-text-editor/index.mjs";
import "../../../form-fileds/index.mjs";
import "../../index.mjs";
import "../../../pro-table/index.mjs";
import "../../../pro-descriptions/index.mjs";
import "../../../layout/index.mjs";
import "../../../page/index.mjs";
import "../../../guide/index.mjs";
import { QuestionFilled as le } from "../../../node_modules/.pnpm/@element-plus_icons-vue@2.3.1_vue@3.4.21/node_modules/@element-plus/icons-vue/dist/index.mjs";
import oe from "../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isUndefined.mjs";
import re from "../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/get.mjs";
const se = {
  key: 0,
  class: "prepend"
}, ae = {
  key: 1,
  class: "append"
}, ne = {
  key: 0,
  class: "prepend"
}, ie = {
  key: 1,
  class: "append"
}, Ce = /* @__PURE__ */ q({
  name: "WetProFormItem",
  __name: "item",
  props: Z,
  setup(S) {
    const p = H("pro-form-item"), m = O(), e = S, {
      setFormStateValue: y,
      setFieldsValue: _,
      registerFiledsPaths: $,
      registerChangeEmit: g,
      formState: E,
      globalColProps: C,
      labelWidth: k,
      clearable: w
    } = B(ee), W = a(() => {
      const t = {
        ...C.value
      }, c = Object.keys(X);
      return Object.keys(e).forEach((r) => {
        c.includes(r) && e[r] && (t[r] = e[r]);
      }), t;
    }), F = a(() => {
      const t = {}, c = Object.keys(Y);
      return Object.keys(e).forEach((r) => {
        c.includes(r) && (t[r] = e[r]);
      }), t;
    }), I = a(() => e.label ? oe(e.labelWidth) || e.labelWidth === "" ? k.value : e.labelWidth : 0), o = a(() => Array.isArray(e.prop) ? e.prop : e.prop ? [e.prop] : []), j = a(() => {
      const t = [...e.rules || []];
      return e.required && t.unshift({
        required: !0,
        message: `${e.label}是必填项`
      }), t;
    }), N = a(() => re(E.value, o.value, void 0)), V = a(() => ({
      modelValue: N.value,
      onChange() {
        g(e.prop || "");
      },
      "onUpdate:modelValue": (t) => {
        o.value && _(o.value, t);
      },
      clearable: w.value,
      style: {
        width: "100%",
        maxWidth: e.fixedWidth ? "300px" : ""
      }
    }));
    return T(o, (t) => {
      t && y(t);
    }), U(() => {
      o.value && y(o.value);
    }), x(() => {
      o.value && (_(o.value, void 0), delete $.value[o.value.join(".")]);
    }), (t, c) => (s(), v(l(J), P(W.value, {
      class: [l(p).b()]
    }), {
      default: n(() => [
        e.noStyle ? (s(), u("div", {
          key: 1,
          class: f([l(p).e("form-iteminner")])
        }, [
          l(m).prepend ? (s(), u("div", ne, [
            i(t.$slots, "prepend")
          ])) : d("", !0),
          i(t.$slots, "default", { modelValue: V.value }),
          l(m).append ? (s(), u("div", ie, [
            i(t.$slots, "append")
          ])) : d("", !0)
        ], 2)) : (s(), v(l(K), P({ key: 0 }, F.value, {
          prop: o.value,
          rules: j.value,
          "label-width": I.value
        }), z({
          default: n(() => [
            h("div", {
              class: f([l(p).e("form-iteminner")])
            }, [
              l(m).prepend ? (s(), u("div", se, [
                i(t.$slots, "prepend")
              ])) : d("", !0),
              i(t.$slots, "default", { modelValue: V.value }),
              l(m).append ? (s(), u("div", ae, [
                i(t.$slots, "append")
              ])) : d("", !0)
            ], 2)
          ]),
          _: 2
        }, [
          e.label ? {
            name: "label",
            fn: n(() => [
              h("div", {
                class: f([l(p).e("label")]),
                style: A({ color: e.labelColor })
              }, [
                b(l(te), null, {
                  default: n(() => [
                    D(M(e.label), 1),
                    Q(h("span", null, ":", 512), [
                      [G, !1]
                    ])
                  ]),
                  _: 1
                }),
                e.description ? (s(), v(l(L), {
                  key: 0,
                  content: e.description,
                  placement: "top",
                  effect: "light"
                }, {
                  default: n(() => [
                    b(l(R), {
                      class: f([l(p).e("question")])
                    }, {
                      default: n(() => [
                        b(l(le))
                      ]),
                      _: 1
                    }, 8, ["class"])
                  ]),
                  _: 1
                }, 8, ["content"])) : d("", !0)
              ], 6)
            ]),
            key: "0"
          } : void 0
        ]), 1040, ["prop", "rules", "label-width"]))
      ]),
      _: 3
    }, 16, ["class"]));
  }
});
export {
  Ce as default
};
