import { defineComponent as V, mergeModels as _, useModel as d, computed as r, watch as h, createElementBlock as B, openBlock as m, Fragment as k, renderList as M, createBlock as b, unref as w, mergeProps as x } from "vue";
import { useI18n as D } from "vue-i18n";
import { d as I } from "./start-CE9SawgU.js";
import "pinia";
import "./header-Bn1EKnBE.js";
const E = /* @__PURE__ */ V({
  __name: "SettingGroupedInputs",
  props: /* @__PURE__ */ _({
    modelValue: {},
    data: {},
    options: {},
    settings: {},
    loading: { type: Boolean },
    readonly: { type: Boolean },
    isDefault: { type: Boolean }
  }, {
    modelValue: {},
    modelModifiers: {},
    valid: { type: Boolean, default: !0 },
    validModifiers: {}
  }),
  emits: ["update:modelValue", "update:valid"],
  setup(l) {
    const t = l, a = d(l, "modelValue"), s = d(l, "valid"), { t: g } = D(), f = (e) => a.value?.find(({ key: o }) => o === e)?.value, p = r(
      () => t.options?.items?.map(({ key: e }) => f(e)) ?? []
    ), i = r(
      () => t.options?.items?.map(({ regex: e }, o) => {
        const n = p.value[o];
        return !t.isDefault && e && !new RegExp(e).test(n) ? g("setting-plugin.setting-grouped-input.regex", { pattern: e }) : void 0;
      }) ?? []
    ), v = r(
      () => t.options?.items?.map((e, o) => ({
        modelValue: p.value[o],
        id: e.key,
        label: e.label,
        hint: e.helperText,
        persistentHint: !!e.helperText,
        style: t.options?.width ? { width: t.options.width } : "",
        error: !t.isDefault && (!s.value || !!i),
        readonly: t.readonly,
        loading: t.loading,
        errorMessages: i.value[o]
      })) ?? []
    );
    function y(e, o) {
      const n = { key: e, value: o };
      if (!Array.isArray(a.value)) {
        a.value = [n];
        return;
      }
      a.value = a.value.filter((u) => u.key !== e).concat(n);
    }
    return h(
      () => i.value.some((e) => !e),
      (e) => {
        s.value = e;
      },
      { immediate: !0 }
    ), (e, o) => (m(!0), B(k, null, M(v.value, (n) => (m(), b(w(I), x({
      key: n.id
    }, { ref_for: !0 }, n, {
      "onUpdate:modelValue": (u) => y(n.id, u)
    }), null, 16, ["onUpdate:modelValue"]))), 128));
  }
});
function c(l) {
  const t = l;
  t.__i18n = t.__i18n || [], t.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "setting-plugin": {
          "setting-grouped-input": {
            regex: { t: 0, b: { t: 2, i: [{ t: 3, v: "Has to match " }, { t: 4, k: "pattern" }] } }
          }
        }
      },
      "de-DE": {
        "setting-plugin": {
          "setting-grouped-input": {
            regex: { t: 0, b: { t: 2, i: [{ t: 3, v: "Muss mit " }, { t: 4, k: "pattern" }, { t: 3, v: " übereinstimmen" }] } }
          }
        }
      }
    }
  });
}
typeof c == "function" && c(E);
export {
  E as default
};
