import { defineComponent as _, ref as E, watch as b, createBlock as f, openBlock as g, unref as a, withCtx as o, createCommentVNode as I, createVNode as i } from "vue";
import { useI18n as h } from "vue-i18n";
import { u as N, i as B, c as s, A as O, d as k, a as S } from "./start-CE9SawgU.js";
import "pinia";
import "./header-Bn1EKnBE.js";
import { S as A } from "./constants-CwfsvyFM.js";
import { b as C } from "./utils-BfOsse_-.js";
import { u as D } from "./units-B2_QriGO.js";
const Q = /* @__PURE__ */ _({
  __name: "DatahubDataTypeUnitValueEditor",
  props: {
    modelValue: {},
    readOnly: { type: Boolean },
    attribute: {},
    massEditing: { type: Boolean },
    label: {},
    fieldName: {},
    dataTypeInstance: {},
    loading: { type: Boolean },
    succeeded: { type: Boolean }
  },
  emits: ["validated", "update:model-value", "initialized"],
  setup(d, { emit: l }) {
    const n = d, V = l, { t: m } = h(), { root: v, dispatchEvent: c } = N(A), { units: p, isUnitsLoading: U } = D(
      () => n.attribute?.configuration?.dimensionId
    ), t = E(
      n.modelValue ?? { value: null, unitId: null }
    );
    return b(
      () => n.modelValue,
      (e) => {
        t.value = e ?? { value: null, unitId: null };
      },
      { deep: !0 }
    ), b(
      t,
      (e) => {
        V("update:model-value", e ?? { value: null, unitId: null }), c({
          data: {
            asString: C(e),
            asValue: e,
            attribute: n.attribute,
            fieldName: n.fieldName
          }
        });
      },
      { deep: !0 }
    ), (e, u) => (g(), f(a(B), {
      ref_key: "root",
      ref: v
    }, {
      default: o(() => [
        !e.massEditing && e.label ? (g(), f(a(s), { key: 0 }, {
          default: o(() => [
            i(a(O), {
              label: e.label,
              disabled: e.readOnly,
              variant: "plain",
              class: "pb-4"
            }, null, 8, ["label", "disabled"])
          ]),
          _: 1
        })) : I("", !0),
        i(a(s), {
          md: "6",
          lg: "4"
        }, {
          default: o(() => [
            i(a(k), {
              modelValue: t.value.value,
              "onUpdate:modelValue": u[0] || (u[0] = (r) => t.value.value = r),
              modelModifiers: { number: !0 },
              label: a(m)("datahub-plugin.unitValue.Quantity"),
              readonly: e.attribute?.configuration?.readOnly || e.readOnly,
              loading: e.loading,
              type: "number"
            }, null, 8, ["modelValue", "label", "readonly", "loading"])
          ]),
          _: 1
        }),
        i(a(s), {
          md: "6",
          lg: "4"
        }, {
          default: o(() => [
            i(a(S), {
              modelValue: t.value.unitId,
              "onUpdate:modelValue": u[1] || (u[1] = (r) => t.value.unitId = r),
              items: a(p),
              readonly: e.attribute?.configuration?.readOnly || e.readOnly,
              loading: a(U) || e.loading,
              disabled: !a(p).length,
              label: a(m)("datahub-plugin.unitValue.Unit"),
              "item-title": "name",
              "item-value": "id"
            }, null, 8, ["modelValue", "items", "readonly", "loading", "disabled", "label"])
          ]),
          _: 1
        })
      ]),
      _: 1
    }, 512));
  }
});
function y(d) {
  const l = d;
  l.__i18n = l.__i18n || [], l.__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 y == "function" && y(Q);
export {
  Q as default
};
