import { computed as P, defineComponent as N, watch as O, createBlock as h, openBlock as p, unref as e, withCtx as l, createCommentVNode as y, withModifiers as V, createVNode as a, createElementVNode as A, toDisplayString as M, inject as U, mergeProps as D } from "vue";
import { a7 as d, V as G, W as k, aa as L, ac as F, ad as j, f as H, g as R, a as r, b as n, c as Y, E as z, am as C, a3 as q } from "./start-BYfL32Oe.mjs";
import "vue-i18n";
import { storeToRefs as J } from "pinia";
import "vue-router";
import { E as T, R as I } from "./header-Droxy2Kd.mjs";
import "./moment-h96o7c8I.mjs";
import { L as K } from "./localPluginIntercom-Q4ih1XJC.mjs";
import { T as $, l as S, c as Q, p as X, R as Z } from "./topBarRoutes-0VuQ_i6D.mjs";
import { h as w, s as B, t as W } from "./DatahubDataTypeEditor.vue_vue_type_script_setup_true_lang-WxvRaHzL.mjs";
const x = {
  data: S.getList,
  gridId: "datahub-etl-processes",
  rowSelection: k.MULTI,
  hideGlobalSearch: !1,
  hideFilters: !1,
  hideColumnCustomization: !1,
  hidePagination: !1,
  sortType: G.SINGLE,
  createActions: !1,
  routableId: "etlProcessId",
  exactRowCount: !1,
  tableActions: [
    {
      icon: "restart_alt",
      title: "datahub-ui.etlProcesses.restart",
      variant: "elevated",
      color: "primary",
      event: $.RESTART,
      prepareIsDisabled: ({ selectedRows: u }) => P(
        () => !u.value.length || u.value.some(
          ({ status: o }) => !I.includes(o)
        )
      )
    }
  ],
  columns: [
    {
      id: "id",
      header: "common.id",
      isVisible: !1,
      minWidth: 200,
      filterable: d.NUMERIC,
      sortable: !0
    },
    {
      id: "status",
      header: "datahub-ui.dh-table.status",
      renderer: "EtlProcessStatusCell",
      minWidth: 200,
      filterable: d.LIST,
      filterListValues: Object.entries(T).map(
        ([u, { label: o }]) => ({ value: u, title: o })
      ),
      sortable: !0
    },
    {
      id: "fromTo",
      header: "datahub-ui.etlProcesses.fromTo",
      minWidth: 200,
      filterable: !1,
      sortable: !1,
      accessor: w
    },
    {
      id: "etlAttributeMap.sourcePorts",
      header: "datahub-ui.etlProcesses.sourceAttributes",
      minWidth: 200,
      filterable: !1,
      sortable: !1,
      accessor: B
    },
    {
      id: "etlAttributeMap.destinationType",
      header: "datahub-ui.dh-shared.targetAttribute",
      minWidth: 200,
      filterable: !1,
      sortable: !1,
      accessor: W
    },
    {
      id: "destinationLanguage.description",
      header: "datahub-ui.etlProcesses.destinationLanguage",
      minWidth: 200,
      filterable: d.STRING,
      sortable: !0
    },
    {
      id: "destinationScope.name",
      header: "datahub-ui.etlProcesses.destinationChannel",
      minWidth: 200,
      filterable: d.STRING,
      sortable: !0
    },
    {
      id: "accepted",
      header: "datahub-ui.etlProcesses.accepted",
      minWidth: 200,
      filterable: d.STRING,
      sortable: !0
    },
    {
      id: "acceptedBy",
      header: "datahub-ui.etlProcesses.acceptedBy",
      minWidth: 200,
      filterable: d.NUMERIC,
      sortable: !0
    },
    {
      id: "createdBy",
      header: "datahub-ui.etlProcesses.createdBy",
      minWidth: 200,
      filterable: d.NUMERIC,
      sortable: !0
    },
    {
      id: "error",
      header: "datahub-ui.etlProcesses.error",
      minWidth: 200,
      filterable: d.STRING,
      sortable: !0
    }
  ]
}, ee = { class: "d-flex align-center" }, ae = /* @__PURE__ */ N({
  __name: "EditBasicView",
  props: {
    id: {},
    pluginName: {}
  },
  setup(u) {
    const o = u, c = Q(o.pluginName), { selectedEtlProcess: s, isLoadingEtlProcess: i } = J(
      c
    ), { isLoading: g, showError: E, onEditRow: _ } = L({
      editApi: S.retryProcess
    }), b = P(
      () => g.value || !!(s.value && I.includes(
        s.value.status
      ))
    );
    async function f() {
      await _(Number(o.id)), !E.value && await c.fetchEtlProcess(Number(o.id));
    }
    return O(
      () => Number(o.id),
      (t) => {
        t && c.fetchEtlProcess(t);
      },
      { immediate: !0 }
    ), (t, v) => (p(), h(e(F), null, {
      "toolbar-title": l(() => {
        var m;
        return [
          A("div", ee, [
            A("span", null, M(t.$t("datahub-ui.etlProcesses.etlProcess")), 1),
            !e(i) && e(s) ? (p(), h(e(C), {
              key: 0,
              options: e(T)[(m = e(s)) == null ? void 0 : m.status],
              variant: "mini",
              class: "ml-2 pr-2"
            }, null, 8, ["options"])) : y("", !0)
          ])
        ];
      }),
      "toolbar-actions": l(() => [
        a(e(z), {
          variant: "elevated",
          disabled: !b.value,
          text: t.$t("datahub-ui.etlProcesses.restart"),
          onClick: f
        }, null, 8, ["disabled", "text"])
      ]),
      default: l(() => {
        var m;
        return [
          ((m = e(s)) == null ? void 0 : m.id) === Number(t.id) ? (p(), h(e(j), {
            key: 0,
            readonly: "",
            class: "h-100 overflow-auto",
            onSubmit: v[0] || (v[0] = V(() => {
            }, ["prevent"]))
          }, {
            default: l(() => [
              a(e(H), { fluid: "" }, {
                default: l(() => [
                  a(e(R), null, {
                    default: l(() => [
                      a(e(r), {
                        md: "6",
                        lg: "4"
                      }, {
                        default: l(() => [
                          a(e(R), null, {
                            default: l(() => [
                              a(e(r), null, {
                                default: l(() => [
                                  a(e(n), {
                                    "model-value": e(s).id,
                                    label: t.$t("common.id"),
                                    loading: e(i),
                                    readonly: ""
                                  }, null, 8, ["model-value", "label", "loading"])
                                ]),
                                _: 1
                              }),
                              a(e(r), null, {
                                default: l(() => [
                                  a(e(n), {
                                    "model-value": e(w)(e(s)),
                                    label: t.$t("datahub-ui.etlProcesses.fromTo"),
                                    loading: e(i),
                                    readonly: ""
                                  }, null, 8, ["model-value", "label", "loading"])
                                ]),
                                _: 1
                              }),
                              a(e(r), null, {
                                default: l(() => [
                                  a(e(n), {
                                    "model-value": e(B)(e(s)),
                                    label: t.$t("datahub-ui.etlProcesses.sourceAttributes"),
                                    loading: e(i),
                                    readonly: ""
                                  }, null, 8, ["model-value", "label", "loading"])
                                ]),
                                _: 1
                              }),
                              a(e(r), null, {
                                default: l(() => [
                                  a(e(n), {
                                    "model-value": e(W)(e(s)),
                                    label: t.$t("datahub-ui.dh-shared.targetAttribute"),
                                    loading: e(i),
                                    readonly: ""
                                  }, null, 8, ["model-value", "label", "loading"])
                                ]),
                                _: 1
                              }),
                              a(e(r), null, {
                                default: l(() => [
                                  a(e(n), {
                                    "model-value": e(s).destinationScope.name,
                                    label: t.$t("datahub-ui.etlProcesses.destinationLanguage"),
                                    loading: e(i),
                                    readonly: ""
                                  }, null, 8, ["model-value", "label", "loading"])
                                ]),
                                _: 1
                              }),
                              a(e(r), null, {
                                default: l(() => [
                                  a(e(Y), {
                                    "model-value": e(s).accepted,
                                    label: t.$t("datahub-ui.etlProcesses.accepted"),
                                    loading: e(i),
                                    readonly: ""
                                  }, null, 8, ["model-value", "label", "loading"])
                                ]),
                                _: 1
                              }),
                              a(e(r), null, {
                                default: l(() => [
                                  a(e(n), {
                                    "model-value": e(s).acceptedBy,
                                    label: t.$t("datahub-ui.etlProcesses.acceptedBy"),
                                    loading: e(i),
                                    readonly: ""
                                  }, null, 8, ["model-value", "label", "loading"])
                                ]),
                                _: 1
                              }),
                              a(e(r), null, {
                                default: l(() => [
                                  a(e(n), {
                                    "model-value": e(s).createdBy,
                                    label: t.$t("datahub-ui.etlProcesses.createdBy"),
                                    loading: e(i),
                                    readonly: ""
                                  }, null, 8, ["model-value", "label", "loading"])
                                ]),
                                _: 1
                              }),
                              a(e(r), null, {
                                default: l(() => [
                                  a(e(n), {
                                    "model-value": e(s).error,
                                    label: t.$t("datahub-ui.etlProcesses.error"),
                                    loading: e(i),
                                    readonly: ""
                                  }, null, 8, ["model-value", "label", "loading"])
                                ]),
                                _: 1
                              })
                            ]),
                            _: 1
                          })
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              })
            ]),
            _: 1
          })) : y("", !0)
        ];
      }),
      _: 1
    }));
  }
}), be = /* @__PURE__ */ N({
  __name: "EtlProcessesView",
  props: {
    pluginName: {}
  },
  setup(u) {
    const { navigationItem: o } = U(K), c = P(
      () => X(o.name, Z.ETL_PROCESSES)
    ), { table: s, isLoading: i, onEditRow: g, batchApiCalls: E } = L({
      editApi: S.retryProcess
    });
    async function _(b, f) {
      switch (b) {
        case $.RESTART:
          await E(
            g,
            f.map(({ id: t }) => [t]),
            !1
          );
      }
    }
    return (b, f) => (p(), h(e(q), D({
      ref_key: "table",
      ref: s,
      "disable-actions": e(i),
      routable: c.value
    }, e(x), { onAction: _ }), {
      "cell-status": l(({ cellValue: t }) => [
        a(e(C), {
          options: e(T)[t]
        }, null, 8, ["options"])
      ]),
      details: l(({ rowId: t }) => [
        a(ae, {
          id: t,
          "plugin-name": b.pluginName
        }, null, 8, ["id", "plugin-name"])
      ]),
      _: 1
    }, 16, ["disable-actions", "routable"]));
  }
});
export {
  be as default
};
