import { defineComponent as A, mergeModels as y, useModel as C, ref as V, computed as g, watch as k, createElementBlock as K, openBlock as n, createBlock as m, createCommentVNode as M, createVNode as r, unref as l, withCtx as p, createTextVNode as T, toDisplayString as E } from "vue";
import { H as N, b as h, E as $, I as S, J as U } from "./start-BYfL32Oe.mjs";
import "vue-i18n";
import "pinia";
import "vue-router";
import { K as D } from "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { k as B } from "./validation-BkM0nwzq.mjs";
const F = { class: "d-flex justify-space-between align-center" }, q = /* @__PURE__ */ A({
  __name: "KeyTextField",
  props: /* @__PURE__ */ y({
    editable: { type: Boolean },
    readonly: { type: Boolean },
    loading: { type: Boolean },
    label: { default: "datahub-ui.dh-table.key" },
    title: { default: "datahub-ui.dh-shared.updateKeyTitle" },
    warning: { default: "datahub-ui.dh-shared.updateKeyWarning" },
    pattern: { default: D }
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: /* @__PURE__ */ y(["updated", "validation"], ["update:modelValue"]),
  setup(v, { emit: w }) {
    const b = v, f = w, d = C(v, "modelValue"), i = V(!1), t = V(""), s = g(B(t, b.pattern)), u = g(B(d, b.pattern));
    function c() {
      d.value = t.value, i.value = !1, f("updated", t.value);
    }
    return k(u, (e) => f("validation", !!e), {
      immediate: !0
    }), k(
      d,
      (e) => {
        t.value = e;
      },
      { immediate: !0 }
    ), (e, a) => (n(), K("div", F, [
      e.loading ? (n(), m(l(N), {
        key: 0,
        height: "16",
        type: "text"
      })) : (n(), m(l(h), {
        key: 1,
        modelValue: d.value,
        "onUpdate:modelValue": a[0] || (a[0] = (o) => d.value = o),
        label: e.$t(e.label),
        readonly: !e.editable,
        "error-messages": u.value && e.$t(u.value)
      }, null, 8, ["modelValue", "label", "readonly", "error-messages"])),
      !e.readonly && !e.editable ? (n(), m(l($), {
        key: 2,
        class: "ml-4",
        icon: "edit",
        variant: "text",
        disabled: e.loading,
        onClick: a[1] || (a[1] = (o) => i.value = !0)
      }, null, 8, ["disabled"])) : M("", !0),
      r(l(S), {
        modelValue: i.value,
        "onUpdate:modelValue": a[3] || (a[3] = (o) => i.value = o),
        title: e.$t(e.title),
        "min-width": "600px",
        "max-width": "800px"
      }, {
        actions: p(() => [
          r(l($), {
            variant: "elevated",
            text: e.$t("datahub-ui.dh-shared.save"),
            disabled: !!s.value,
            onClick: c
          }, null, 8, ["text", "disabled"])
        ]),
        default: p(() => [
          r(l(U), {
            icon: "warning",
            type: "error",
            class: "mb-4"
          }, {
            default: p(() => [
              T(E(e.$t(e.warning)), 1)
            ]),
            _: 1
          }),
          r(l(h), {
            modelValue: t.value,
            "onUpdate:modelValue": a[2] || (a[2] = (o) => t.value = o),
            label: e.$t(e.label),
            "error-messages": s.value && e.$t(s.value)
          }, null, 8, ["modelValue", "label", "error-messages"])
        ]),
        _: 1
      }, 8, ["modelValue", "title"])
    ]));
  }
});
export {
  q as _
};
