import { defineComponent as h, ref as I, watch as g, createBlock as y, openBlock as V, unref as a, withCtx as r, createCommentVNode as N, createVNode as d } from "vue";
import { useI18n as O } from "vue-i18n";
import { u as k, g as B, a as p, A as S, b as A, h as C } from "./start-BYfL32Oe.mjs";
import "pinia";
import "vue-router";
import "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { S as D } from "./constants-CwfsvyFM.mjs";
import { b as Q } from "./utils-PF9w8IEt.mjs";
import { u as T } from "./units-DogXJCIC.mjs";
const w = /* @__PURE__ */ h({
  __name: "DatahubDataTypeUnitValueEditor",
  props: {
    modelValue: {},
    readOnly: { type: Boolean },
    attribute: {},
    massEditing: { type: Boolean },
    label: {},
    fieldName: {},
    dataTypeInstance: {},
    loading: { type: Boolean }
  },
  emits: ["validated", "update:model-value"],
  setup(s, { emit: n }) {
    const i = s, c = n, { t: b } = O(), { root: U, dispatchEvent: _ } = k(D), { units: f, isUnitsLoading: E } = T(
      () => {
        var e, t;
        return (t = (e = i.attribute) == null ? void 0 : e.configuration) == null ? void 0 : t.dimensionId;
      }
    ), l = I(
      i.modelValue ?? { value: null, unitId: null }
    );
    return g(
      () => i.modelValue,
      (e) => {
        l.value = e ?? { value: null, unitId: null };
      },
      { deep: !0 }
    ), g(
      l,
      (e) => {
        c("update:model-value", e ?? { value: null, unitId: null }), _({
          data: {
            asString: Q(e),
            asValue: e,
            attribute: i.attribute,
            fieldName: i.fieldName
          }
        });
      },
      { deep: !0 }
    ), (e, t) => (V(), y(a(B), {
      ref_key: "root",
      ref: U
    }, {
      default: r(() => [
        !e.massEditing && e.label ? (V(), y(a(p), { key: 0 }, {
          default: r(() => [
            d(a(S), {
              label: e.label,
              disabled: e.readOnly,
              variant: "plain",
              class: "pb-4"
            }, null, 8, ["label", "disabled"])
          ]),
          _: 1
        })) : N("", !0),
        d(a(p), {
          md: "6",
          lg: "4"
        }, {
          default: r(() => {
            var u, o;
            return [
              d(a(A), {
                modelValue: l.value.value,
                "onUpdate:modelValue": t[0] || (t[0] = (m) => l.value.value = m),
                modelModifiers: { number: !0 },
                label: a(b)("datahub-plugin.unitValue.Quantity"),
                readonly: ((o = (u = e.attribute) == null ? void 0 : u.configuration) == null ? void 0 : o.readOnly) || e.readOnly,
                loading: e.loading,
                type: "number"
              }, null, 8, ["modelValue", "label", "readonly", "loading"])
            ];
          }),
          _: 1
        }),
        d(a(p), {
          md: "6",
          lg: "4"
        }, {
          default: r(() => {
            var u, o;
            return [
              d(a(C), {
                modelValue: l.value.unitId,
                "onUpdate:modelValue": t[1] || (t[1] = (m) => l.value.unitId = m),
                items: a(f),
                readonly: ((o = (u = e.attribute) == null ? void 0 : u.configuration) == null ? void 0 : o.readOnly) || e.readOnly,
                loading: a(E) || e.loading,
                disabled: !a(f).length,
                label: a(b)("datahub-plugin.unitValue.Unit"),
                "item-title": "name",
                "item-value": "id"
              }, null, 8, ["modelValue", "items", "readonly", "loading", "disabled", "label"])
            ];
          }),
          _: 1
        })
      ]),
      _: 1
    }, 512));
  }
});
function v(s) {
  const n = s;
  n.__i18n = n.__i18n || [], n.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "datahub-plugin": {
          unitValue: {
            Quantity: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Quantity" } },
            Unit: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Unit" } }
          }
        }
      },
      "de-DE": {
        "datahub-plugin": {
          unitValue: {
            Quantity: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Menge" } },
            Unit: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Einheit" } }
          }
        }
      }
    }
  });
}
typeof v == "function" && v(w);
export {
  w as default
};
