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