import { defineComponent as R, computed as M, watch as k, createBlock as C, openBlock as $, unref as e, withCtx as u, createVNode as o, withModifiers as B, createCommentVNode as D, isRef as T } from "vue";
import { useI18n as F } from "vue-i18n";
import { storeToRefs as H } from "pinia";
import { az as P, ad as j, f as z, g as O, a as s, c as f, b as G, h as b } from "./start-BYfL32Oe.mjs";
import "vue-router";
import { a as q, L as J } from "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { c as K, g as Q } from "./topBarRoutes-0VuQ_i6D.mjs";
import { _ as W } from "./KeyTextField.vue_vue_type_script_setup_true_lang-CZdba5bh.mjs";
import { _ as X } from "./MultiLangScopeEditorsList.vue_vue_type_script_setup_true_lang-CWQeDnSm.mjs";
const re = /* @__PURE__ */ R({
  __name: "EditBasicView",
  props: {
    id: {},
    disableCustomSelection: { type: Boolean },
    pluginName: {}
  },
  setup(Y) {
    let y = [];
    const { t: p } = F(), g = K(props.pluginName), {
      selectedAttributeSet: l,
      attributeSetHeritages: _,
      entityTypes: h,
      isLoadingEntityTypes: A
    } = H(g), { attributesApi: I, attributeSetsApi: U } = g, w = M(
      () => Object.entries(q).map(([i, t]) => ({
        value: i,
        title: p(t)
      }))
    ), E = {
      active: {},
      heritageMode: {},
      parentSetId: {},
      entityTypeClassName: {},
      syncConfiguration: {}
    }, { v$: m, markTouched: c, resetValidation: v } = P({
      form: l,
      rules: E,
      formId: "attribute-sets-basic",
      onSubmit: L
    });
    k(
      () => {
        var i;
        return (i = l.value) == null ? void 0 : i.id;
      },
      (i) => {
        i && v();
      }
    );
    async function L() {
      try {
        const i = l.value.parentSetId ? {
          heritageMode: Number(l.value.heritageMode),
          parentSetId: l.value.parentSetId,
          syncConfiguration: l.value.syncConfiguration
        } : void 0, t = Object.fromEntries(
          Object.entries(l.value).filter(
            ([d]) => y.includes(d)
          )
        ), n = {
          id: l.value.id,
          active: l.value.active,
          entityTypeClassName: l.value.entityTypeClassName,
          ...t,
          ...i
        };
        return await U.save(n), v(), !0;
      } catch {
        return !1;
      }
    }
    return (i, t) => ($(), C(Q, {
      controller: e(J).ATTRIBUTES,
      api: e(I).getListOfLanguagesScopesAndFields,
      "disable-custom-selection": i.disableCustomSelection,
      "plugin-name": i.pluginName
    }, {
      default: u(({ selected: n, loading: d }) => {
        var V;
        return [
          o(e(j), {
            readonly: (V = e(l)) == null ? void 0 : V.readOnly,
            class: "h-100 overflow-auto",
            onSubmit: t[9] || (t[9] = B(() => {
            }, ["prevent"]))
          }, {
            default: u(() => [
              o(e(z), { fluid: "" }, {
                default: u(() => [
                  o(e(O), null, {
                    default: u(() => [
                      o(e(s), { cols: "4" }, {
                        default: u(() => [
                          o(e(O), null, {
                            default: u(() => {
                              var N, S;
                              return [
                                o(e(s), null, {
                                  default: u(() => {
                                    var a;
                                    return [
                                      o(e(f), {
                                        modelValue: e(m).active.$model,
                                        "onUpdate:modelValue": t[0] || (t[0] = (r) => e(m).active.$model = r),
                                        label: i.$t("datahub-ui.dh-table.isActive"),
                                        readonly: (a = e(l)) == null ? void 0 : a.readOnly,
                                        loading: d
                                      }, null, 8, ["modelValue", "label", "readonly", "loading"])
                                    ];
                                  }),
                                  _: 2
                                }, 1024),
                                o(e(s), null, {
                                  default: u(() => {
                                    var a;
                                    return [
                                      o(W, {
                                        "model-value": (a = e(l)) == null ? void 0 : a.key,
                                        loading: d,
                                        readonly: ""
                                      }, null, 8, ["model-value", "loading"])
                                    ];
                                  }),
                                  _: 2
                                }, 1024),
                                (N = n == null ? void 0 : n.attributes) != null && N.length ? ($(), C(X, {
                                  key: 0,
                                  modelValue: e(l),
                                  "onUpdate:modelValue": t[1] || (t[1] = (a) => T(l) ? l.value = a : null),
                                  attributes: n == null ? void 0 : n.attributes,
                                  readonly: (S = e(l)) == null ? void 0 : S.readOnly,
                                  scopes: n == null ? void 0 : n.scopes,
                                  languages: n == null ? void 0 : n.languages,
                                  selection: n == null ? void 0 : n.custom,
                                  loading: d,
                                  onUpdated: e(c),
                                  onFieldNames: t[2] || (t[2] = (a) => T(y) ? y.value = a : y = a)
                                }, null, 8, ["modelValue", "attributes", "readonly", "scopes", "languages", "selection", "loading", "onUpdated"])) : D("", !0),
                                o(e(s), null, {
                                  default: u(() => {
                                    var a;
                                    return [
                                      o(e(f), {
                                        "model-value": (a = e(l)) == null ? void 0 : a.readOnly,
                                        label: i.$t("datahub-ui.dh-table.readOnly"),
                                        loading: d,
                                        readonly: "",
                                        "onUpdate:modelValue": t[3] || (t[3] = (r) => e(l).readOnly = r)
                                      }, null, 8, ["model-value", "label", "loading"])
                                    ];
                                  }),
                                  _: 2
                                }, 1024),
                                o(e(s), null, {
                                  default: u(() => {
                                    var a;
                                    return [
                                      o(e(G), {
                                        "model-value": (a = e(l)) == null ? void 0 : a.ownerPluginName,
                                        label: i.$t("datahub-ui.dh-table.ownerPluginName"),
                                        loading: d,
                                        readonly: "",
                                        "onUpdate:modelValue": t[4] || (t[4] = (r) => e(l).ownerPluginName = r)
                                      }, null, 8, ["model-value", "label", "loading"])
                                    ];
                                  }),
                                  _: 2
                                }, 1024),
                                o(e(s), null, {
                                  default: u(() => {
                                    var a;
                                    return [
                                      o(e(b), {
                                        modelValue: e(m).entityTypeClassName.$model,
                                        "onUpdate:modelValue": t[5] || (t[5] = (r) => e(m).entityTypeClassName.$model = r),
                                        items: e(h),
                                        label: e(p)("datahub-ui.dh-shared.entityType"),
                                        loading: e(A) || d,
                                        readonly: (a = e(l)) == null ? void 0 : a.readOnly,
                                        "item-title": "name",
                                        "item-value": "className"
                                      }, null, 8, ["modelValue", "items", "label", "loading", "readonly"])
                                    ];
                                  }),
                                  _: 2
                                }, 1024),
                                o(e(s), { cols: "6" }, {
                                  default: u(() => {
                                    var a;
                                    return [
                                      o(e(b), {
                                        modelValue: e(m).heritageMode.$model,
                                        "onUpdate:modelValue": t[6] || (t[6] = (r) => e(m).heritageMode.$model = r),
                                        items: w.value,
                                        label: e(p)("datahub-ui.dh-shared.inheritCopy"),
                                        readonly: (a = e(l)) == null ? void 0 : a.readOnly,
                                        loading: d
                                      }, null, 8, ["modelValue", "items", "label", "readonly", "loading"])
                                    ];
                                  }),
                                  _: 2
                                }, 1024),
                                o(e(s), { cols: "6" }, {
                                  default: u(() => {
                                    var a;
                                    return [
                                      o(e(b), {
                                        modelValue: e(m).parentSetId.$model,
                                        "onUpdate:modelValue": t[7] || (t[7] = (r) => e(m).parentSetId.$model = r),
                                        items: e(_),
                                        label: e(p)("datahub-ui.dh-shared.from"),
                                        readonly: (a = e(l)) == null ? void 0 : a.readOnly,
                                        loading: d,
                                        "item-title": "name",
                                        "item-value": "id"
                                      }, null, 8, ["modelValue", "items", "label", "readonly", "loading"])
                                    ];
                                  }),
                                  _: 2
                                }, 1024),
                                o(e(s), null, {
                                  default: u(() => {
                                    var a;
                                    return [
                                      o(e(f), {
                                        modelValue: e(m).syncConfiguration.$model,
                                        "onUpdate:modelValue": t[8] || (t[8] = (r) => e(m).syncConfiguration.$model = r),
                                        label: e(p)("datahub-ui.dh-shared.inheritConfiguration"),
                                        readonly: (a = e(l)) == null ? void 0 : a.readOnly,
                                        loading: d
                                      }, null, 8, ["modelValue", "label", "readonly", "loading"])
                                    ];
                                  }),
                                  _: 2
                                }, 1024)
                              ];
                            }),
                            _: 2
                          }, 1024)
                        ]),
                        _: 2
                      }, 1024)
                    ]),
                    _: 2
                  }, 1024)
                ]),
                _: 2
              }, 1024)
            ]),
            _: 2
          }, 1032, ["readonly"])
        ];
      }),
      _: 1
    }, 8, ["controller", "api", "disable-custom-selection", "plugin-name"]));
  }
});
export {
  re as default
};
