import { defineComponent as S, mergeModels as _, useModel as k, ref as b, computed as v, watch as D, createBlock as p, openBlock as r, unref as a, withCtx as m, createVNode as c, createElementVNode as U, createCommentVNode as f, toDisplayString as y, createElementBlock as C, Fragment as N, createTextVNode as E, mergeProps as I } from "vue";
import { useI18n as M } from "vue-i18n";
import { h as T, i as $, c as V, a as h, j as z, d as F } from "./start-CE9SawgU.js";
import "pinia";
import "./header-Bn1EKnBE.js";
import { D as P } from "./constants-DiSFhhBB.js";
const R = { class: "form-title mr-2 mb-1" }, j = /* @__PURE__ */ S({
  __name: "DatahubBadWordFilter",
  props: /* @__PURE__ */ _({
    modelValue: {},
    scopable: { type: Boolean },
    remoteScopes: { default: () => [] },
    multiLanguage: { type: Boolean },
    remoteLanguages: { default: () => [] },
    readonly: { type: Boolean }
  }, {
    modelValue: {
      default: () => ({})
    },
    modelModifiers: {}
  }),
  emits: ["update:modelValue"],
  setup(g) {
    const s = g, { t: i } = M(), l = k(g, "modelValue"), t = b(0), o = b(0), w = v(
      () => s.multiLanguage && !o.value || s.scopable && !t.value
    ), B = v(
      () => l.value?.[t.value]?.[o.value] ?? [""]
    );
    D(
      [t, o],
      ([e, n]) => {
        const d = l.value instanceof Array && l.value.length === 1 && l.value[0].length === 1 ? { 0: { 0: l.value[0][0] } } : l.value;
        d[e] || (d[e] = {}), d[e][n] || (d[e][n] = [""]), l.value = d;
      },
      { immediate: !0 }
    );
    function L({ rowIndex: e }) {
      l.value[t.value][o.value].length > 1 ? l.value[t.value][o.value].splice(
        e,
        1
      ) : l.value[t.value][o.value] = [""];
    }
    function A() {
      l.value[t.value][o.value].push("");
    }
    return (e, n) => (r(), p(a(T), { fluid: "" }, {
      default: m(() => [
        c(a($), null, {
          default: m(() => [
            c(a(V), { class: "d-flex align-center" }, {
              default: m(() => [
                U("div", R, y(a(i)("datahub-plugin.stringValue.badWords")), 1),
                e.scopable && e.remoteScopes.length ? (r(), p(a(h), {
                  key: 0,
                  modelValue: t.value,
                  "onUpdate:modelValue": n[0] || (n[0] = (u) => t.value = u),
                  items: e.remoteScopes,
                  label: a(i)("datahub-plugin.stringValue.scope"),
                  readonly: e.readonly,
                  disabled: e.readonly,
                  "item-title": "name",
                  "item-value": "id",
                  class: "mr-2"
                }, null, 8, ["modelValue", "items", "label", "readonly", "disabled"])) : f("", !0),
                e.multiLanguage && e.remoteLanguages.length ? (r(), p(a(h), {
                  key: 1,
                  modelValue: o.value,
                  "onUpdate:modelValue": n[1] || (n[1] = (u) => o.value = u),
                  items: e.remoteLanguages,
                  label: a(i)("datahub-plugin.stringValue.language"),
                  readonly: e.readonly,
                  disabled: e.readonly,
                  "item-title": "description",
                  "item-value": "id",
                  class: "mr-2"
                }, null, 8, ["modelValue", "items", "label", "readonly", "disabled"])) : f("", !0)
              ]),
              _: 1
            }),
            c(a(V), null, {
              default: m(() => [
                w.value ? (r(), C(N, { key: 0 }, [
                  E(y(a(i)("datahub-plugin.stringValue.wrongScopeLanguage")), 1)
                ], 64)) : (r(), p(a(z), I({
                  key: 1,
                  data: B.value,
                  "create-actions": e.readonly || [
                    {
                      title: a(i)("datahub-plugin.stringValue.addWord"),
                      icon: "lucide:plus"
                    }
                  ],
                  readonly: e.readonly
                }, a(P), {
                  onCreate: A,
                  onRemove: L
                }), {
                  "cell-text": m(({ rowIndex: u }) => [
                    c(a(F), {
                      modelValue: l.value[t.value][o.value][u],
                      "onUpdate:modelValue": (d) => l.value[t.value][o.value][u] = d,
                      readonly: e.readonly
                    }, null, 8, ["modelValue", "onUpdate:modelValue", "readonly"])
                  ]),
                  _: 1
                }, 16, ["data", "create-actions", "readonly"]))
              ]),
              _: 1
            })
          ]),
          _: 1
        })
      ]),
      _: 1
    }));
  }
});
function W(g) {
  const s = g;
  s.__i18n = s.__i18n || [], s.__i18n.push({
    locale: "",
    resource: {
      "en-US": {
        "datahub-plugin": {
          stringValue: {
            badWords: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Bad words" } },
            scope: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Scope" } },
            language: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Language" } },
            wrongScopeLanguage: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Please select a valid scope and language combination to edit bad words" } },
            addWord: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Add word" } }
          }
        }
      },
      "de-DE": {
        "datahub-plugin": {
          stringValue: {
            badWords: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Unerwünschte Wörter" } },
            scope: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Domäne" } },
            language: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Sprache" } },
            wrongScopeLanguage: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Bitte wählen Sie eine gültige Domänen- und Sprachkombination aus, um unerwünschte Wörter zu bearbeiten" } },
            addWord: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Wort hinzufügen" } }
          }
        }
      }
    }
  });
}
typeof W == "function" && W(j);
export {
  j as _
};
