import { ref as v, defineComponent as w, mergeModels as z, useModel as M, watch as g, createElementBlock as p, openBlock as m, createVNode as c, renderSlot as k, unref as a, Fragment as b, createCommentVNode as C, renderList as D, createBlock as N } from "vue";
import { useI18n as U } from "vue-i18n";
import { s as x, e as V, a as E } from "./start-CE9SawgU.js";
import "pinia";
import "./header-Bn1EKnBE.js";
import { B as L } from "./base-B7u32Mej.js";
const _ = `${L}VariantToVariant.`, B = {
  /** Return variant sets in source and destination set */
  async listDestinationAndSourceSets(r) {
    return x.post(`${_}listDestinationAndSourceSets`, {
      etlAttributeSetMapId: r
    });
  }
}, S = {}, $ = () => {
  const r = v([]), l = v([]), t = v(!1);
  async function s(o) {
    if (o) {
      if (S[o]) {
        const { sourceVariantSets: i = [], destinationVariantSets: u = [] } = await S[o];
        return this.sourceVariantSets = i, this.destinationVariantSets = u, { sourceVariantSets: i, destinationVariantSets: u };
      }
      try {
        t.value = !0, S[o] = B.listDestinationAndSourceSets(o);
        const { sourceVariantSets: i = [], destinationVariantSets: u = [] } = await S[o];
        return this.sourceVariantSets = i, this.destinationVariantSets = u, { sourceVariantSets: i, destinationVariantSets: u };
      } catch (i) {
        console.log(i.message);
      } finally {
        t.value = !1;
      }
    }
  }
  return {
    sourceVariantSets: r,
    destinationVariantSets: l,
    isVariantSetsLoading: t,
    fetchVariantSet: s
  };
}, T = /* @__PURE__ */ w({
  __name: "VariantToVariantExtension",
  props: /* @__PURE__ */ z({
    attributeMap: {},
    destinationAttribute: {},
    sourceAttributes: {},
    etlAttributeSetMapId: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(r) {
    const l = r, t = M(r, "modelValue"), { t: s } = U(), {
      sourceVariantSets: o,
      destinationVariantSets: i,
      isVariantSetsLoading: u,
      fetchVariantSet: A
    } = $();
    return g(
      t,
      (d) => {
        d || (t.value = {});
      },
      { immediate: !0 }
    ), g(
      () => l.etlAttributeSetMapId,
      async (d) => {
        t.value = {
          ...t.value,
          autocreateChildren: t.value.autocreateChildren ?? !0,
          automapVariantSets: t.value.automapVariantSets ?? !0,
          autocreateVariantSet: t.value.autocreateVariantSet ?? !0,
          addNotMappedDefiningAttributesAndAutomap: t.value.addNotMappedDefiningAttributesAndAutomap ?? !0,
          autosyncVariantSet: t.value.autosyncVariantSet ?? !0,
          variantSetMapping: t.value.variantSetMapping ?? []
        }, d && await A(d);
      },
      { immediate: !0 }
    ), (d, n) => (m(), p("div", null, [
      c(a(V), {
        modelValue: t.value.autocreateChildren,
        "onUpdate:modelValue": n[0] || (n[0] = (e) => t.value.autocreateChildren = e),
        label: a(s)("datahub-plugin.etl.variant-to-variant.AutocreateChildren"),
        "max-width": "567",
        class: "mb-2"
      }, null, 8, ["modelValue", "label"]),
      c(a(V), {
        modelValue: t.value.automapVariantSets,
        "onUpdate:modelValue": n[1] || (n[1] = (e) => t.value.automapVariantSets = e),
        label: a(s)("datahub-plugin.etl.variant-to-variant.automapVariantSets"),
        "max-width": "567",
        class: "mb-2"
      }, null, 8, ["modelValue", "label"]),
      t.value.automapVariantSets ? (m(), p(b, { key: 0 }, [
        c(a(V), {
          modelValue: t.value.autocreateVariantSet,
          "onUpdate:modelValue": n[2] || (n[2] = (e) => t.value.autocreateVariantSet = e),
          label: a(s)("datahub-plugin.etl.variant-to-variant.autocreateVariantSet"),
          "max-width": "567",
          class: "mb-2"
        }, null, 8, ["modelValue", "label"]),
        c(a(V), {
          modelValue: t.value.addNotMappedDefiningAttributesAndAutomap,
          "onUpdate:modelValue": n[3] || (n[3] = (e) => t.value.addNotMappedDefiningAttributesAndAutomap = e),
          label: a(s)(
            "datahub-plugin.etl.variant-to-variant.addNotMappedDefiningAttributesAndAutomap"
          ),
          "max-width": "567",
          class: "mb-2"
        }, null, 8, ["modelValue", "label"])
      ], 64)) : (m(), p(b, { key: 1 }, [
        c(a(V), {
          modelValue: t.value.autosyncVariantSet,
          "onUpdate:modelValue": n[4] || (n[4] = (e) => t.value.autosyncVariantSet = e),
          label: a(s)("datahub-plugin.etl.variant-to-variant.autosyncVariantSet"),
          "max-width": "567",
          class: "mb-2"
        }, null, 8, ["modelValue", "label"]),
        t.value.variantSetMapping ? (m(!0), p(b, { key: 0 }, D(a(o), (e, f) => (m(), N(a(E), {
          key: e.id,
          modelValue: t.value.variantSetMapping[f],
          "onUpdate:modelValue": (y) => t.value.variantSetMapping[f] = y,
          items: a(i),
          loading: a(u),
          label: a(s)("datahub-plugin.etl.variant-to-variant.SourceVariantSetLabel", {
            name: e.name
          }),
          "item-title": "name",
          "item-value": "id",
          "max-width": "567",
          "persistent-placeholder": "",
          class: "mb-2"
        }, null, 8, ["modelValue", "onUpdate:modelValue", "items", "loading", "label"]))), 128)) : C("", !0)
      ], 64)),
      k(d.$slots, "default")
    ]));
  }
});
function h(r) {
  const l = r;
  l.__i18n = l.__i18n || [], l.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "datahub-plugin": {
          etl: {
            "variant-to-variant": {
              AutocreateChildren: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Automatically generate all variant entities when main entity is created" } },
              automapVariantSets: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Automatically map variant sets" } },
              autocreateVariantSet: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Automatically create variant set if no suiting variant set can be found" } },
              addNotMappedDefiningAttributesAndAutomap: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Automatically add not mapped defining attributes to destination set when creating variant set" } },
              autosyncVariantSet: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Create and sync a new variant set in case the assigned variant sets do not match to each other" } },
              SourceVariantSetLabel: { t: 0, b: { t: 2, i: [{ t: 3, v: "Source variant sets " }, { t: 4, k: "name" }] } }
            }
          }
        }
      },
      "de-DE": {
        "datahub-plugin": {
          etl: {
            "variant-to-variant": {
              AutocreateChildren: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Alle Varianten-Entitäten automatisch erzeugen, wenn die Hauptentität erstellt wird" } },
              automapVariantSets: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Variantensätze automatisch zuordnen" } },
              autocreateVariantSet: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Variantensatz automatisch erstellen, falls kein passender Variantensatz gefunden werden kann" } },
              addNotMappedDefiningAttributesAndAutomap: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Nicht zugeordnete definierende Attribute bei der Erstellung eines Variantensatzes automatisch dem Ziel-Variantensatz hinzufügen" } },
              autosyncVariantSet: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Neuen Variantensatz erstellen und synchronisieren, falls die zugewiesenen Variantensätze nicht zueinander passen" } },
              SourceVariantSetLabel: { t: 0, b: { t: 2, i: [{ t: 3, v: "Quellvariantensätze " }, { t: 4, k: "name" }] } }
            }
          }
        }
      }
    }
  });
}
typeof h == "function" && h(T);
export {
  T as default
};
