import { defineComponent as _, useSlots as P, shallowRef as b, computed as p, openBlock as t, createBlock as s, mergeProps as d, createSlots as g, withCtx as a, createElementBlock as i, Fragment as m, renderList as w, unref as f, withDirectives as F, resolveDynamicComponent as h, normalizeProps as v, guardReactiveProps as C, vShow as y, renderSlot as x } from "vue";
import V from "./index.vue.mjs";
import { wetSchemaProps as R } from "./types.mjs";
import { WetFormAutocompleter as $, WetFormCascader as A, WetFormSelect as D, WetFormCheckbox as B, WetFormColorPicker as E, WetFormDatePicker as j, WetFormNumber as z, WetFormRadio as L, WetFormSlider as N, WetFormSwitch as q, WetFormTimePicker as G, WetFormTimeSelect as H, WetFormRate as J, WetFormArray as K, WetFormText as M } from "../../form-fileds/index.mjs";
import O from "./base/dependency.mjs";
const ee = /* @__PURE__ */ _({
  name: "WetSchemaForm",
  __name: "schema",
  props: R,
  setup(k, { expose: W }) {
    const I = P(), l = b(), u = k, T = p(() => u.properties ? u.properties.filter((r) => !r.hideInRender).map((r) => ({
      value: {
        ...r,
        renderFormItem: null,
        valueEnum: null,
        hideInForm: null,
        property: null,
        valueType: null,
        prop: r.property || r.prop,
        label: r.title || r.label,
        formInputProps: {
          options: r.valueEnum,
          ...r.formInputProps
        }
      },
      other: {
        key: Array.isArray(r.property) ? r.property.join(".") : r.property,
        renderFormItem: r.renderFormItem,
        dependency: r.dependency,
        hideInForm: r.hideInForm,
        valueType: r.valueType
      }
    })) : []), S = p(() => {
      const e = {
        ...u
      };
      return delete e.properties, e;
    }), c = (e, o) => o || (e === "autocomplete" ? $ : e === "cascader" ? A : e === "select" ? D : e === "checkbox" ? B : e === "color" ? E : e === "date" ? j : e === "number" ? z : e === "radio" ? L : e === "slider" ? N : e === "switch" ? q : e === "time-picker" ? G : e === "time-select" ? H : e === "rate" ? J : e === "array" ? K : M);
    return W({
      submit: () => {
        var e;
        return (e = l.value) == null ? void 0 : e.submit();
      },
      reset: () => {
        var e;
        return (e = l.value) == null ? void 0 : e.reset();
      },
      validateField: (e) => {
        var o;
        return (o = l.value) == null ? void 0 : o.validateField(e);
      },
      clearValidate: (e) => {
        var o;
        return (o = l.value) == null ? void 0 : o.clearValidate(e);
      },
      getFieldsValue: (e) => {
        var o;
        return (o = l.value) == null ? void 0 : o.getFieldsValue(e);
      },
      setFieldsValue: (e, o) => {
        var r;
        return (r = l.value) == null ? void 0 : r.setFieldsValue(e, o);
      },
      scrollToField: (e) => {
        var o;
        return (o = l.value) == null ? void 0 : o.scrollToField(e);
      }
    }), (e, o) => (t(), s(V, d(S.value, {
      ref_key: "formIns",
      ref: l
    }), g({
      default: a(() => [
        (t(!0), i(m, null, w(T.value, (r) => (t(), i(m, {
          key: r.other.key
        }, [
          r.other.dependency ? (t(), s(f(O), {
            key: 0,
            relyprops: r.other.dependency.relyprops,
            "dependency-change": r.other.dependency.dependencyChange
          }, {
            default: a(({ parames: n }) => [
              F((t(), s(h(c(
                (n == null ? void 0 : n.valueType) || r.other.valueType,
                r.other.renderFormItem
              )), v(C({
                ...r.value,
                ...n
              })), null, 16)), [
                [y, !r.other.hideInForm]
              ])
            ]),
            _: 2
          }, 1032, ["relyprops", "dependency-change"])) : F((t(), s(h(c(r.other.valueType, r.other.renderFormItem)), v(d({ key: 1 }, r.value)), null, 16)), [
            [y, !r.other.hideInForm]
          ])
        ], 64))), 128))
      ]),
      _: 2
    }, [
      f(I).actions ? {
        name: "actions",
        fn: a(() => [
          x(e.$slots, "actions")
        ]),
        key: "0"
      } : void 0
    ]), 1040));
  }
});
export {
  ee as default
};
