import { defineComponent as T, mergeModels as D, useModel as L, createElementBlock as U, openBlock as w, Fragment as P, createVNode as a, unref as e, withCtx as n, mergeProps as S } from "vue";
import { useI18n as h } from "vue-i18n";
import { storeToRefs as d } from "pinia";
import { O as I, c, d as R, e as E, j as M, a as p } from "./start-CE9SawgU.js";
import "./header-Bn1EKnBE.js";
import { u as $ } from "./pimDataType-C9MfxZo5.js";
import { P as k } from "./constants-3JiawOc1.js";
import { b as f } from "./price-field-value.json_vue_type_i18n_index_0_src_true_lang-DVkXvAUo.js";
const A = /* @__PURE__ */ T({
  __name: "PIMDataTypePriceFieldValueConfiguration",
  props: /* @__PURE__ */ D({
    attribute: {},
    dataTypeInstance: {},
    remoteScopes: {},
    remoteLanguages: {},
    remoteAttributes: {},
    readonly: { type: Boolean }
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(y) {
    const l = L(y, "modelValue"), { t: u } = h(), s = I(), { isCountriesLoading: V, countries: v } = d(s);
    s.ensureCountries();
    const m = $(), { isCurrenciesLoading: g, currencies: _ } = d(
      m
    );
    m.ensureCurrencies();
    function C() {
      l.value || (l.value = { precision: null, showTime: null, currencies: [] });
      const r = { currency: null, country: null };
      l.value.currencies ? l.value.currencies.push(r) : l.value.currencies = [r];
    }
    function b({ rowIndex: r }) {
      l.value.currencies.splice(r, 1);
    }
    return (r, i) => (w(), U(P, null, [
      a(e(c), { md: "6" }, {
        default: n(() => [
          a(e(R), {
            modelValue: l.value.precision,
            "onUpdate:modelValue": i[0] || (i[0] = (o) => l.value.precision = o),
            label: e(u)("pim-plugin.price-field.precision"),
            readonly: r.readonly
          }, null, 8, ["modelValue", "label", "readonly"])
        ]),
        _: 1
      }),
      a(e(c), { md: "6" }, {
        default: n(() => [
          a(e(E), {
            modelValue: l.value.showTime,
            "onUpdate:modelValue": i[1] || (i[1] = (o) => l.value.showTime = o),
            label: e(u)("pim-plugin.price-field.showTime"),
            readonly: r.readonly
          }, null, 8, ["modelValue", "label", "readonly"])
        ]),
        _: 1
      }),
      a(e(c), null, {
        default: n(() => [
          a(e(M), S({
            data: l.value.currencies ?? [],
            "table-name": e(u)("pim-plugin.price-field.supportedCurrencies")
          }, e(k), {
            onCreate: C,
            onRemove: b
          }), {
            "cell-currency": n(({ rowIndex: o }) => [
              a(e(p), {
                modelValue: l.value.currencies[o].currency,
                "onUpdate:modelValue": (t) => l.value.currencies[o].currency = t,
                items: e(_),
                loading: e(g),
                "item-title": "currency",
                "item-value": "currency",
                search: ""
              }, null, 8, ["modelValue", "onUpdate:modelValue", "items", "loading"])
            ]),
            "cell-country": n(({ rowIndex: o }) => [
              a(e(p), {
                modelValue: l.value.currencies[o].country,
                "onUpdate:modelValue": (t) => l.value.currencies[o].country = t,
                items: e(v),
                loading: e(V),
                "item-title": "name",
                "item-value": "code3digit",
                search: ""
              }, null, 8, ["modelValue", "onUpdate:modelValue", "items", "loading"])
            ]),
            _: 1
          }, 16, ["data", "table-name"])
        ]),
        _: 1
      })
    ], 64));
  }
});
typeof f == "function" && f(A);
export {
  A as default
};
