import { defineComponent as s, ref as m, renderSlot as F } from "vue";
import { useInjectFormProvider as g, useProvideFormProvider as u } from "./context.mjs";
const a = /* @__PURE__ */ s({
  name: "ApFormProvider",
  __name: "index",
  props: {
    onFormChange: { type: Function },
    onFormFinish: { type: Function }
  },
  setup(i) {
    const n = i, e = m({}), t = g();
    return u({
      triggerFormChange(r, o) {
        n?.onFormChange && n.onFormChange(r, {
          changedFields: o,
          forms: e.value
        }), t?.triggerFormChange(r, o);
      },
      triggerFormFinish: (r, o) => {
        n?.onFormFinish && n.onFormFinish(r, {
          values: o,
          forms: e.value
        }), t?.triggerFormFinish(r, o);
      },
      registerForm: (r, o) => {
        r && (e.value = {
          ...e.value,
          [r]: o
        }), t?.registerForm(r, o);
      },
      unregisterForm: (r) => {
        const o = { ...e.value };
        delete o[r], e.value = o, t?.unregisterForm(r);
      }
    }), (r, o) => F(r.$slots, "default");
  }
});
export {
  a as default
};
