import { defineComponent as V, computed as b, ref as U, watch as g, createBlock as D, openBlock as E, withCtx as B, createElementVNode as O, createVNode as v, unref as l } from "vue";
import { useI18n as C } from "vue-i18n";
import { h as _, l as T } from "./start-BYfL32Oe.mjs";
import "pinia";
import "vue-router";
import "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { _ as k } from "./DatahubDataComplexValue.vue_vue_type_script_setup_true_lang-CDTiMGxi.mjs";
const w = { class: "extension-config d-flex flex-wrap" }, h = /* @__PURE__ */ V({
  __name: "DatahubDataTypeSalesUnitValueEditor",
  props: {
    modelValue: {},
    readOnly: { type: Boolean },
    attribute: {},
    massEditing: { type: Boolean },
    label: {},
    fieldName: {},
    dataTypeInstance: {},
    loading: { type: Boolean }
  },
  emits: ["validated", "update:model-value"],
  setup(o, { emit: t }) {
    const s = o, I = t, { t: u } = C(), m = b(
      () => {
        var e, n;
        return ((n = (e = s.dataTypeInstance) == null ? void 0 : e.defaultConfiguration) == null ? void 0 : n.selectableDimensions) ?? [{ units: [{ name: "name 1", id: 1 }] }];
      }
    ), i = U({}), r = b(() => {
      var e, n;
      return (e = i.value) != null && e.dimensionId ? ((n = m.value.find(({ id: a }) => a === i.value.dimensionId)) == null ? void 0 : n.units) ?? [] : [];
    });
    return g(
      () => s.modelValue,
      (e) => {
        i.value = e ?? { dimensionId: null, unitId: null };
      },
      { deep: !0 }
    ), g(
      i,
      (e) => {
        I("update:model-value", e ?? { dimensionId: null, unitId: null });
      },
      { deep: !0 }
    ), (e, n) => (E(), D(k, { header: e.label }, {
      default: B(() => {
        var a, p, f, c;
        return [
          O("div", w, [
            v(l(_), {
              modelValue: i.value.dimensionId,
              "onUpdate:modelValue": n[0] || (n[0] = (d) => i.value.dimensionId = d),
              items: m.value,
              label: l(u)("datahub-plugin.salesUnit.dimension"),
              readonly: ((p = (a = e.attribute) == null ? void 0 : a.configuration) == null ? void 0 : p.readOnly) || e.readOnly,
              loading: e.loading,
              "item-title": "name",
              "item-value": "id",
              class: "extension-config__input",
              "persistent-placeholder": ""
            }, null, 8, ["modelValue", "items", "label", "readonly", "loading"]),
            v(l(_), {
              modelValue: i.value.dimensionId,
              "onUpdate:modelValue": n[1] || (n[1] = (d) => i.value.dimensionId = d),
              items: r.value,
              label: l(u)("datahub-plugin.salesUnit.dimension"),
              readonly: ((c = (f = e.attribute) == null ? void 0 : f.configuration) == null ? void 0 : c.readOnly) || e.readOnly,
              loading: e.loading,
              disabled: !r.value.length,
              "item-title": "name",
              "item-value": "id",
              class: "extension-config__input",
              "persistent-placeholder": ""
            }, null, 8, ["modelValue", "items", "label", "readonly", "loading", "disabled"])
          ])
        ];
      }),
      _: 1
    }, 8, ["header"]));
  }
});
function y(o) {
  const t = o;
  t.__i18n = t.__i18n || [], t.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "datahub-plugin": {
          salesUnit: {
            dimension: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Dimension" } },
            unit: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Unit" } }
          }
        }
      },
      "de-DE": {
        "datahub-plugin": {
          salesUnit: {
            dimension: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Dimension" } },
            unit: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Einheit" } }
          }
        }
      }
    }
  });
}
typeof y == "function" && y(h);
const F = /* @__PURE__ */ T(h, [["__scopeId", "data-v-8b8bfed1"]]);
export {
  F as default
};
