import { defineComponent as w, computed as c, watch as U, createBlock as g, openBlock as D, unref as e, withCtx as u, createCommentVNode as P, createVNode as v, createTextVNode as N, toDisplayString as _, mergeProps as $ } from "vue";
import { useI18n as L } from "vue-i18n";
import { storeToRefs as S } from "pinia";
import { ai as k, aj as x, I as R, af as d, a1 as F, a2 as G, aa as H, ah as M } from "./start-CE9SawgU.js";
import "./header-Bn1EKnBE.js";
import { c as O, m, i as B, I as Y, T as E } from "./topBarRoutes-CBd5qLxn.js";
import { q as C } from "./DatahubDataTypeEditor.vue_vue_type_script_setup_true_lang-Blx83HK-.js";
import { useRouter as j } from "vue-router";
import { _ as q } from "./EditBasicView.vue_vue_type_script_setup_true_lang-DY0kNPFh.js";
const z = /* @__PURE__ */ w({
  __name: "EditView",
  props: {
    id: {},
    pluginName: {}
  },
  setup(i) {
    const l = i, { locale: n, t: T } = L(), A = j(), h = O(l.pluginName), { languages: y, selectedDeletedAttribute: s } = S(
      h
    ), { isLoading: b, showError: f, onAddRow: r, onDeleteRows: p } = k({
      addApi: m.recoverDeletedAttributes,
      deleteApi: m.delete
    }), a = c(
      () => y.value.find(({ key: t }) => t === n.value) ?? {
        key: n.value,
        id: 0
      }
    ), o = c(
      () => `${T("datahub-ui.deletedAttributes.deletedAttribute")}: ${s.value ? C(s.value.name, a.value) : ""}`
    );
    function I() {
      A.push({ name: B.DELETED_ATTRIBUTES });
    }
    async function V() {
      await r([Number(l.id)]), f.value || I();
    }
    async function W() {
      await p([Number(l.id)]), f.value || I();
    }
    return U(
      () => l.id,
      async (t) => {
        t && await h.fetchDeletedAttribute(t);
      },
      { immediate: !0 }
    ), (t, K) => (D(), g(e(x), null, {
      "toolbar-title": u(() => [
        N(_(o.value), 1)
      ]),
      "toolbar-actions": u(() => [
        v(e(R), {
          text: t.$t("datahub-ui.shared.deletePermanently"),
          disabled: e(b),
          "prepend-icon": "lucide:trash",
          variant: "outlined",
          color: "secondary",
          destructive: "",
          onClick: W
        }, null, 8, ["text", "disabled"]),
        v(e(R), {
          text: t.$t("datahub-ui.deletedAttributes.recover"),
          disabled: e(b),
          color: "primary",
          onClick: V
        }, null, 8, ["text", "disabled"])
      ]),
      default: u(() => [
        e(s)?.id === Number(t.id) ? (D(), g(q, {
          key: 0,
          id: Number(t.id),
          attribute: e(s),
          "plugin-name": t.pluginName,
          readonly: ""
        }, null, 8, ["id", "attribute", "plugin-name"])) : P("", !0)
      ]),
      _: 1
    }));
  }
}), J = {
  data: m.getList,
  gridId: "datahub-deleted-attributes",
  rowSelection: G.MULTI,
  hideGlobalSearch: !1,
  hideFilters: !1,
  hideColumnCustomization: !1,
  hidePagination: !1,
  sortType: F.SINGLE,
  routableId: "deletedAttributeId",
  routable: B.DELETED_ATTRIBUTES,
  createActions: !1,
  exactRowCount: !1,
  reloadOnLocaleChange: !0,
  tableActions: [
    {
      title: "datahub-ui.deletedAttributes.recover",
      color: "primary",
      variant: "flat",
      event: E.RECOVER,
      prepareIsDisabled: ({ selectedRows: i }) => c(() => !i.value.length)
    },
    {
      icon: "lucide:trash",
      title: "datahub-ui.shared.deletePermanently",
      variant: "outlined",
      color: "secondary",
      destructive: !0,
      event: E.DELETE,
      prepareIsDisabled: ({ selectedRows: i }) => c(() => !i.value.length)
    }
  ],
  columns: [
    {
      id: "id",
      header: "common.id",
      isVisible: !1,
      minWidth: 200,
      filterable: d.NUMERIC,
      sortable: !0
    },
    {
      id: "active",
      header: "datahub-ui.dh-table.status",
      renderer: "IsActiveStatusCell",
      minWidth: 100,
      width: 150,
      ...Y,
      sortable: !0
    },
    {
      id: "renderFriendlyName",
      header: "datahub-ui.dh-table.name",
      minWidth: 200,
      filterable: !1,
      sortable: !1
    },
    {
      id: "key",
      header: "datahub-ui.dh-table.key",
      minWidth: 200,
      filterable: d.STRING,
      sortable: !0,
      className: "monospaced"
    },
    {
      id: "renderFriendlyDescription",
      header: "datahub-ui.dh-table.description",
      minWidth: 200,
      filterable: !1,
      sortable: !1
    },
    {
      id: "dataType",
      header: "datahub-ui.dh-table.dataType",
      minWidth: 200,
      accessor: ({ dataTypeInstance: i, dataType: l }) => i?.name ?? l,
      filterable: d.STRING,
      sortable: !0
    },
    {
      id: "readOnly",
      header: "datahub-ui.dh-table.readOnly",
      renderer: "CheckboxCell",
      minWidth: 200,
      filterable: d.BOOLEAN,
      sortable: !0
    },
    {
      id: "multilanguage",
      header: "datahub-ui.dh-table.multiLanguage",
      renderer: "CheckboxCell",
      minWidth: 200,
      filterable: d.BOOLEAN,
      sortable: !0
    },
    {
      id: "ownerPluginName",
      header: "datahub-ui.dh-table.ownerPluginName",
      minWidth: 200,
      filterable: !1,
      sortable: !1
    },
    {
      id: "created",
      header: "datahub-ui.dh-table.created",
      minWidth: 200,
      filterable: d.DATE,
      sortable: !0,
      renderer: "CellDateTime"
    },
    {
      id: "createdByUsername",
      header: "datahub-ui.dh-table.createdByUsername",
      minWidth: 200,
      isVisible: !1,
      filterable: !1,
      sortable: !1
    },
    {
      id: "modified",
      header: "datahub-ui.dh-table.modified",
      minWidth: 200,
      isVisible: !1,
      filterable: d.DATE,
      sortable: !0,
      renderer: "CellDateTime"
    },
    {
      id: "modifiedByUsername",
      header: "datahub-ui.dh-table.modifiedByUsername",
      minWidth: 200,
      isVisible: !1,
      filterable: !1,
      sortable: !1
    }
  ]
}, de = /* @__PURE__ */ w({
  __name: "DeletedAttributesView",
  props: {
    pluginName: {}
  },
  setup(i) {
    const l = i, { locale: n } = L(), { table: T, isLoading: A, onEditRow: h, onDeleteRows: y } = k({
      editApi: m.recoverDeletedAttributes,
      deleteApi: m.delete
    }), { languages: s } = S(O(l.pluginName)), b = c(
      () => s.value.find(({ key: r }) => r === n.value) ?? {
        key: n.value,
        id: 0
      }
    );
    async function f(r, p, a) {
      const o = M(p);
      switch (r) {
        case E.DELETE:
          await y(o);
          break;
        case E.RECOVER:
          h(o);
          break;
      }
      a && a();
    }
    return (r, p) => (D(), g(e(H), $({
      ref_key: "table",
      ref: T,
      key: e(n),
      "disable-actions": e(A)
    }, e(J), { onAction: f }), {
      "cell-renderFriendlyName": u(({ cellValue: a }) => [
        N(_(e(C)(a, b.value)), 1)
      ]),
      "cell-renderFriendlyDescription": u(({ cellValue: a }) => [
        N(_(e(C)(a, b.value)), 1)
      ]),
      details: u(({ rowId: a, close: o }) => [
        v(z, {
          id: Number(a),
          "plugin-name": r.pluginName,
          onClose: o
        }, null, 8, ["id", "plugin-name", "onClose"])
      ]),
      _: 1
    }, 16, ["disable-actions"]));
  }
});
export {
  de as default
};
