import { defineComponent as m, mergeModels as f, useModel as c, watch as p, createBlock as v, createCommentVNode as b, openBlock as k, unref as r } from "vue";
import { useI18n as y } from "vue-i18n";
import { a_ as F } from "./start-CE9SawgU.js";
import "pinia";
import "./header-Bn1EKnBE.js";
import { b as i } from "./rma-address-field-extension.json_vue_type_i18n_index_0_src_true_lang-B0T8WrmL.js";
const g = /* @__PURE__ */ m({
  __name: "RMAFieldExtension",
  props: /* @__PURE__ */ f({
    attributeMap: {},
    destinationAttribute: {},
    sourceAttributes: {},
    etlAttributeSetMapId: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(u) {
    const l = c(u, "modelValue"), { t: o } = y(), s = [
      "reference",
      "paymentType",
      "sourceBusinessDocumentId",
      "sourceBusinessDocumentNumber",
      "trackingNumbers",
      "trackingLinks",
      "comment",
      "created",
      "returnsCnt"
    ];
    function d(a) {
      return typeof a == "string" || a && typeof a == "object" && !("key" in a);
    }
    return p(
      l,
      (a) => {
        a?.availableFields?.length || (l.value = {
          ...l.value,
          availableFields: s.map((e) => ({
            key: e,
            value: o(`rma-plugin.rma-address-field-extension.${e}`)
          }))
        }), l.value?.availableFields?.some(d) && (l.value = {
          ...l.value,
          availableFields: l.value?.availableFields?.map((e) => {
            if (typeof e == "string")
              return { key: e, value: e };
            if (e && typeof e == "object") {
              const n = e.key || e.field || e.name;
              return n ? {
                key: n,
                value: e.value || e.label || n
              } : null;
            }
            return null;
          })?.filter(Boolean) ?? []
        });
      },
      { immediate: !0 }
    ), (a, t) => l.value ? (k(), v(r(F), {
      key: 0,
      modelValue: l.value.field,
      "onUpdate:modelValue": t[0] || (t[0] = (e) => l.value.field = e),
      items: l.value.availableFields ?? [],
      label: r(o)("rma-plugin.rma-address-field-extension.rmaField"),
      "item-title": "value",
      "item-value": "key"
    }, null, 8, ["modelValue", "items", "label"])) : b("", !0);
  }
});
typeof i == "function" && i(g);
export {
  g as default
};
