import { shallowRef as m, ref as y, computed as d } from "vue";
const h = 300, v = m(!1), F = (s, u, c) => {
  const a = y({}), l = m(), n = d(() => {
    if (s.search) {
      const r = { span: 6, labelWidth: 70, collapsed: !0 };
      if (typeof s.search == "boolean") {
        const t = h + r.labelWidth, o = Math.ceil(c.value / t);
        return o < 4 && (r.span = 24 / o), r;
      } else {
        const t = {
          ...r,
          ...s.search
        }, o = h + t.labelWidth, e = Math.ceil(c.value / o);
        return e < 4 && (t.span = 24 / e), t;
      }
    } else
      return !1;
  }), I = async () => {
    var t;
    const r = await ((t = l.value) == null ? void 0 : t.submit());
    a.value = r;
  }, P = () => {
    var t;
    const r = (t = l.value) == null ? void 0 : t.reset();
    a.value = r;
  }, b = d(() => {
    let r = [];
    if (u.value && n.value) {
      const t = u.value.filter((e) => e.search), o = 24 / n.value.span;
      r = t.map((e, W) => {
        var p, f, i;
        return {
          valueType: e.valueType,
          valueEnum: e.valueEnum,
          ...e.formItemProps,
          fixedWidth: !0,
          label: e.title || ((p = e.formItemProps) == null ? void 0 : p.label),
          property: e.dataIndex || ((f = e.formItemProps) == null ? void 0 : f.prop),
          hideInForm: !v.value && W + 1 >= o,
          formInputProps: {
            ...e.fieldProps,
            ...(i = e.formItemProps) == null ? void 0 : i.formInputProps
          }
        };
      });
    }
    return r;
  });
  return {
    formState: a,
    formPorps: n,
    formIns: l,
    getSearchValue: I,
    resetForm: P,
    properties: b,
    collapsed: v
  };
};
export {
  F as default
};
