import { defineComponent as V, mergeModels as w, useModel as x, ref as u, computed as I, watch as r, createElementBlock as n, createCommentVNode as g, openBlock as o, createBlock as y, unref as c, Fragment as A, toDisplayString as T, renderList as L } from "vue";
import { useI18n as S } from "vue-i18n";
import { T as C, a as D } from "./start-CE9SawgU.js";
import "pinia";
import "./header-Bn1EKnBE.js";
import { e as E } from "./topBarRoutes-CBd5qLxn.js";
import "@vuelidate/validators";
import "./TreeView.vue_vue_type_style_index_0_scoped_0bd14ef7_lang-CZieIjgg.js";
import "./DatahubDataTypeCompletenessRenderer.vue_vue_type_script_setup_true_lang-5buor0oX.js";
import "./IsActiveStatusCell-xz7XnAYP.js";
import "./VariantToVariantExtension-DUC3WSrH.js";
import "./DatahubDataTypeVariantValueEditor-9WYNJneN.js";
import { t as B } from "./TreeNodeValueController-Cy6eyeVx.js";
import "./dataTypes-DocW2t0g.js";
import { t as N } from "./TaxClasses-BZyo8A_n.js";
import "./dictionary-BmJHcR-F.js";
const U = {
  key: 0,
  class: "d-flex flex-wrap align-center ga-2"
}, z = {
  key: 0,
  class: "w-100"
}, F = /* @__PURE__ */ V({
  __name: "TaxesTreeNodeToTaxClassExtension",
  props: /* @__PURE__ */ w({
    attributeMap: {},
    destinationAttribute: {},
    sourceAttributes: {},
    etlAttributeSetMapId: {},
    etlAttributeMapId: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(s) {
    const l = s, e = x(s, "modelValue"), { t: _ } = S(), d = u(!1), p = u(!1), m = u(!1), v = u([]), f = u([]), b = u([]), M = I(
      () => d.value || p.value || m.value
    );
    return r(
      e,
      () => {
        e.value || (e.value = {}), e.value.valueMaps || (e.value.valueMaps = {});
      },
      { immediate: !0 }
    ), r(
      () => l.etlAttributeSetMapId,
      async (t) => {
        if (t) {
          e.value = {
            ...e.value,
            etlAttributeMapId: t
          };
          try {
            d.value = !0;
            const { valueMaps: a } = await E.getValueMaps(t);
            v.value = a;
          } finally {
            d.value = !1;
          }
        }
      },
      { immediate: !0 }
    ), r(
      () => l.sourceAttributes?.[0]?.id,
      async (t) => {
        if (t)
          try {
            p.value = !0;
            const { data: a } = await B.getTree({
              attributeId: t,
              scopeId: 0,
              languageId: 0
            });
            f.value = a?.tree?.children ?? [];
          } finally {
            p.value = !1;
          }
      },
      { immediate: !0 }
    ), r(
      () => l.destinationAttribute,
      async (t) => {
        if (t)
          try {
            m.value = !0;
            const { data: a } = await N.getList();
            b.value = a;
          } finally {
            m.value = !1;
          }
      },
      { immediate: !0 }
    ), r(
      M,
      (t) => {
        t || ((!e.value || !e.value?.valueMaps) && (e.value = {
          ...e.value,
          valueMaps: {}
        }), v.value.forEach(({ destinationValue: a, sourceValue: i }) => {
          e.value.valueMaps[a] = i;
        }));
      },
      { immediate: !0 }
    ), (t, a) => e.value?.valueMaps ? (o(), n("div", U, [
      M.value ? (o(), y(c(C), {
        key: 0,
        type: "list-item@3"
      })) : (o(), n(A, { key: 1 }, [
        t.etlAttributeMapId ? g("", !0) : (o(), n("div", z, T(c(_)("datahub-plugin.etl.tree-node-to-tax-class.valueMapDisabled")), 1)),
        (o(!0), n(A, null, L(b.value, (i) => (o(), y(c(D), {
          key: i.id,
          modelValue: e.value.valueMaps[i.id],
          "onUpdate:modelValue": (k) => e.value.valueMaps[i.id] = k,
          items: f.value,
          label: i.name,
          "item-value": "id",
          disabled: !t.etlAttributeMapId || !t.sourceAttributes?.length,
          "max-width": "576",
          width: "100%"
        }, null, 8, ["modelValue", "onUpdate:modelValue", "items", "label", "disabled"]))), 128))
      ], 64))
    ])) : g("", !0);
  }
});
function h(s) {
  const l = s;
  l.__i18n = l.__i18n || [], l.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "datahub-plugin": {
          etl: {
            "tree-node-to-tax-class": {
              valueMapDisabled: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Save once to configure mapping" } }
            }
          }
        }
      },
      "de-DE": {
        "datahub-plugin": {
          etl: {
            "tree-node-to-tax-class": {
              valueMapDisabled: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Einmal speichern, um die Zuordnung zu konfigurieren" } }
            }
          }
        }
      }
    }
  });
}
typeof h == "function" && h(F);
export {
  F as default
};
