import { defineComponent as V, mergeModels as k, useModel as x, ref as u, computed as C, watch as o, createElementBlock as p, createCommentVNode as v, openBlock as s, createBlock as I, unref as f, toDisplayString as T, Fragment as L, renderList as S, createVNode as w } from "vue";
import { useI18n as D } from "vue-i18n";
import { a4 as E, h as N } from "./start-BYfL32Oe.mjs";
import "pinia";
import "vue-router";
import "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { e as B } from "./ETLAttributeMaps-CQdXyXVn.mjs";
import "./IsActiveStatusCell-DlvB6_E-.mjs";
import "@vuelidate/validators";
import "./MultiLangScopeEditorsList.vue_vue_type_script_setup_true_lang-CWQeDnSm.mjs";
import "./DatahubDataTypeCompletenessRenderer.vue_vue_type_script_setup_true_lang-Btvu_WeF.mjs";
import "./topBarRoutes-0VuQ_i6D.mjs";
import "./VariantToVariantExtension-WcLvPNqG.mjs";
import "./DatahubDataTypeVariantValueEditor-f1gR3QCx.mjs";
import { t as $ } from "./TreeNodeValueController-C5jYAiH7.mjs";
import { t as z } from "./TaxClasses-BY8s9nMy.mjs";
import "./dictionary-TYJ-09MM.mjs";
const F = {
  key: 0,
  class: "container"
}, U = { key: 1 }, Z = /* @__PURE__ */ V({
  __name: "TaxesTreeNodeToTaxClassExtension",
  props: /* @__PURE__ */ k({
    attributeMap: {},
    destinationAttribute: {},
    sourceAttributes: {},
    etlAttributeSetMapId: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(r) {
    const i = r, t = x(r, "modelValue"), { t: A } = D(), m = u(!1), d = u(!1), c = u(!1), M = u([]), b = u([]), g = u([]), y = C(
      () => m.value || d.value || c.value
    );
    return o(
      t,
      () => {
        t.value || (t.value = {}), t.value.valueMaps || (t.value.valueMaps = {});
      },
      { immediate: !0 }
    ), o(
      () => i.etlAttributeSetMapId,
      async (e) => {
        if (e) {
          t.value = {
            ...t.value,
            etlAttributeMapId: e
          };
          try {
            m.value = !0;
            const { valueMaps: a } = await B.getValueMaps(e);
            M.value = a;
          } finally {
            m.value = !1;
          }
        }
      },
      { immediate: !0 }
    ), o(
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      () => {
        var e, a;
        return (a = (e = i.sourceAttributes) == null ? void 0 : e.p0) == null ? void 0 : a.id;
      },
      async (e) => {
        var a;
        if (e)
          try {
            d.value = !0;
            const { data: l } = await $.getTree({
              attributeId: e,
              scopeId: 0,
              languageId: 0
            });
            b.value = ((a = l == null ? void 0 : l.tree) == null ? void 0 : a.children) ?? [];
          } finally {
            d.value = !1;
          }
      },
      { immediate: !0 }
    ), o(
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      () => i.destinationAttribute,
      async (e) => {
        if (e)
          try {
            c.value = !0;
            const { data: a } = await z.getList();
            g.value = a;
          } finally {
            c.value = !1;
          }
      },
      { immediate: !0 }
    ), o(
      y,
      (e) => {
        var a;
        e || ((!t.value || !((a = t.value) != null && a.valueMaps)) && (t.value = {
          ...t.value,
          valueMaps: {}
        }), M.value.forEach(({ destinationValue: l, sourceValue: n }) => {
          t.value.valueMaps[l] = n;
        }));
      },
      { immediate: !0 }
    ), (e, a) => {
      var l;
      return (l = t.value) != null && l.valueMaps ? (s(), p("div", F, [
        y.value ? (s(), I(f(E), {
          key: 0,
          class: "overlay"
        })) : v("", !0),
        e.etlAttributeSetMapId ? v("", !0) : (s(), p("div", U, T(f(A)("datahub-plugin.etl.tree-node-to-tax-class.valueMapDisabled")), 1)),
        (s(!0), p(L, null, S(g.value, (n) => (s(), p("div", {
          key: n.id
        }, [
          w(f(N), {
            modelValue: t.value.valueMaps,
            "onUpdate:modelValue": a[0] || (a[0] = (h) => t.value.valueMaps = h),
            items: b.value,
            label: n.name,
            "item-value": "id",
            disabled: !e.etlAttributeSetMapId
          }, null, 8, ["modelValue", "items", "label", "disabled"])
        ]))), 128))
      ])) : v("", !0);
    };
  }
});
function _(r) {
  const i = r;
  i.__i18n = i.__i18n || [], i.__i18n.push({
    locale: "",
    resource: {
      en: {
        "datahub-plugin.etl.tree-node-to-tax-class": {
          valueMapDisabled: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Save once to configure mapping" } }
        }
      },
      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 _ == "function" && _(Z);
export {
  Z as default
};
