import { defineComponent as B, mergeModels as f, useModel as p, computed as M, watch as U, createBlock as v, openBlock as V, unref as e, withCtx as d, createVNode as i, withModifiers as h, renderSlot as I, createCommentVNode as N } from "vue";
import { aC as R, az as S, I as K, ad as T, f as D, g as O, a as Y, b as z, E as b } from "./start-BYfL32Oe.mjs";
import "vue-i18n";
import "pinia";
import "vue-router";
import { K as F } from "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { K as L } from "./validation-BkM0nwzq.mjs";
import { f as P } from "./topBarRoutes-0VuQ_i6D.mjs";
const Z = /* @__PURE__ */ B({
  __name: "CreateEntityModal",
  props: /* @__PURE__ */ f({
    title: {},
    controller: {},
    rules: {},
    loading: { type: Boolean },
    hideEditOnSave: { type: Boolean },
    pluginName: {}
  }, {
    modelValue: { type: Boolean },
    modelModifiers: {},
    form: {},
    formModifiers: {}
  }),
  emits: /* @__PURE__ */ f(["save"], ["update:modelValue", "update:form"]),
  setup(n, { emit: g }) {
    const k = n, y = g, r = p(n, "modelValue"), o = p(n, "form"), $ = M(() => ({
      key: { ...R, pattern: L(F) },
      active: {},
      ...k.rules
    })), { v$: s, isValid: m, keyErrors: E, markTouched: A, resetValidation: C, ...w } = S({
      rules: $,
      form: o
    });
    function u(a) {
      y("save", o.value, a);
    }
    return U(
      r,
      (a) => {
        a && (o.value.key = "", o.value.active = !0);
      },
      { immediate: !0 }
    ), (a, l) => (V(), v(e(K), {
      modelValue: r.value,
      "onUpdate:modelValue": l[5] || (l[5] = (t) => r.value = t),
      title: a.title,
      "min-width": "600px",
      "max-width": "600px"
    }, {
      actions: d(() => [
        i(e(b), {
          variant: "outlined",
          color: "on_dark",
          disabled: !e(m) || a.loading,
          text: a.$t("datahub-ui.dh-shared.save"),
          onClick: l[0] || (l[0] = (t) => u(!1))
        }, null, 8, ["disabled", "text"]),
        a.hideEditOnSave ? N("", !0) : (V(), v(e(b), {
          key: 0,
          variant: "elevated",
          disabled: !e(m) || a.loading,
          text: a.$t("datahub-ui.dh-shared.saveAndEdit"),
          onClick: l[1] || (l[1] = (t) => u(!0))
        }, null, 8, ["disabled", "text"]))
      ]),
      default: d(() => [
        i(e(T), {
          readonly: a.loading,
          onSubmit: l[4] || (l[4] = h(() => {
          }, ["prevent"]))
        }, {
          default: d(() => [
            i(e(D), {
              class: "pa-0 mt-1",
              fluid: ""
            }, {
              default: d(() => [
                i(e(O), null, {
                  default: d(() => [
                    i(P, {
                      modelValue: o.value,
                      "onUpdate:modelValue": l[2] || (l[2] = (t) => o.value = t),
                      controller: a.controller,
                      "plugin-name": a.pluginName,
                      onInit: e(C),
                      onUpdated: e(A)
                    }, null, 8, ["modelValue", "controller", "plugin-name", "onInit", "onUpdated"]),
                    i(e(Y), null, {
                      default: d(() => [
                        i(e(z), {
                          modelValue: e(s).key.$model,
                          "onUpdate:modelValue": l[3] || (l[3] = (t) => e(s).key.$model = t),
                          label: a.$t("datahub-ui.dh-table.key"),
                          "error-messages": e(E)
                        }, null, 8, ["modelValue", "label", "error-messages"])
                      ]),
                      _: 1
                    }),
                    I(a.$slots, "default", {
                      v: e(s),
                      validations: w,
                      form: o.value
                    })
                  ]),
                  _: 3
                })
              ]),
              _: 3
            })
          ]),
          _: 3
        }, 8, ["readonly"])
      ]),
      _: 3
    }, 8, ["modelValue", "title"]));
  }
});
export {
  Z as _
};
