import { computed as E, defineComponent as R, watch as O, createBlock as f, openBlock as h, unref as e, withCtx as l, createCommentVNode as v, withModifiers as W, createVNode as a, createElementVNode as A, toDisplayString as M, inject as U, mergeProps as D } from "vue";
import { af as d, a1 as V, a2 as k, ai as N, aj as G, ak as F, h as j, i as y, c as r, d as n, e as H, I as Y, as as L, aa as z } from "./start-CE9SawgU.js";
import "vue-i18n";
import { storeToRefs as q } from "pinia";
import { E as P, R as C } from "./header-Bn1EKnBE.js";
import { L as J } from "./localPluginIntercom-4lCtV0uu.js";
import { T as I, l as T, c as K, p as Q, i as X } from "./topBarRoutes-CBd5qLxn.js";
import { h as w, s as $, t as B } from "./DatahubDataTypeEditor.vue_vue_type_script_setup_true_lang-Blx83HK-.js";
const Z = {
  data: T.getList,
  gridId: "datahub-etl-processes",
  rowSelection: k.MULTI,
  hideGlobalSearch: !1,
  hideFilters: !1,
  hideColumnCustomization: !1,
  hidePagination: !1,
  sortType: V.SINGLE,
  createActions: !1,
  routableId: "etlProcessId",
  exactRowCount: !1,
  reloadOnLocaleChange: !0,
  tableActions: [
    {
      icon: "lucide:rotate-ccw",
      title: "datahub-ui.etlProcesses.restart",
      color: "primary",
      variant: "flat",
      event: I.RESTART,
      prepareIsDisabled: ({ selectedRows: u }) => E(
        () => !u.value.length || u.value.some(
          ({ status: o }) => !C.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(P).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: $
    },
    {
      id: "etlAttributeMap.destinationType",
      header: "datahub-ui.dh-shared.targetAttribute",
      minWidth: 200,
      filterable: !1,
      sortable: !1,
      accessor: B
    },
    {
      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
    }
  ]
}, x = { class: "d-flex align-center" }, ee = /* @__PURE__ */ R({
  __name: "EditBasicView",
  props: {
    id: {},
    pluginName: {}
  },
  setup(u) {
    const o = u, c = K(o.pluginName), { selectedEtlProcess: s, isLoadingEtlProcess: i } = q(
      c
    ), { isLoading: p, showError: g, onEditRow: _ } = N({
      editApi: T.retryProcess
    }), b = E(
      () => p.value || !!(s.value && C.includes(
        s.value.status
      ))
    );
    async function m() {
      await _(Number(o.id)), !g.value && await c.fetchEtlProcess(Number(o.id));
    }
    return O(
      () => Number(o.id),
      (t) => {
        t && c.fetchEtlProcess(t);
      },
      { immediate: !0 }
    ), (t, S) => (h(), f(e(G), null, {
      "toolbar-title": l(() => [
        A("div", x, [
          A("span", null, M(t.$t("datahub-ui.etlProcesses.etlProcess")), 1),
          !e(i) && e(s) ? (h(), f(e(L), {
            key: 0,
            options: e(P)[e(s)?.status],
            variant: "mini",
            class: "ml-2 pr-2"
          }, null, 8, ["options"])) : v("", !0)
        ])
      ]),
      "toolbar-actions": l(() => [
        a(e(Y), {
          disabled: !b.value,
          text: t.$t("datahub-ui.etlProcesses.restart"),
          onClick: m
        }, null, 8, ["disabled", "text"])
      ]),
      default: l(() => [
        e(s)?.id === Number(t.id) ? (h(), f(e(F), {
          key: 0,
          readonly: "",
          class: "h-100 overflow-auto",
          onSubmit: S[0] || (S[0] = W(() => {
          }, ["prevent"]))
        }, {
          default: l(() => [
            a(e(j), { fluid: "" }, {
              default: l(() => [
                a(e(y), null, {
                  default: l(() => [
                    a(e(r), {
                      md: "6",
                      lg: "4"
                    }, {
                      default: l(() => [
                        a(e(y), 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($)(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(B)(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(H), {
                                  "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
        })) : v("", !0)
      ]),
      _: 1
    }));
  }
}), ne = /* @__PURE__ */ R({
  __name: "EtlProcessesView",
  props: {
    pluginName: {}
  },
  setup(u) {
    const { navigationItem: o } = U(J), c = E(
      () => Q(o.name, X.ETL_PROCESSES)
    ), { table: s, isLoading: i, onEditRow: p, batchApiCalls: g } = N({
      editApi: T.retryProcess
    });
    async function _(b, m) {
      switch (b) {
        case I.RESTART:
          await g(
            p,
            m.map(({ id: t }) => [t]),
            !1
          );
      }
    }
    return (b, m) => (h(), f(e(z), D({
      ref_key: "table",
      ref: s,
      "disable-actions": e(i),
      routable: c.value
    }, e(Z), { onAction: _ }), {
      "cell-status": l(({ cellValue: t }) => [
        a(e(L), {
          options: e(P)[t]
        }, null, 8, ["options"])
      ]),
      details: l(({ rowId: t }) => [
        a(ee, {
          id: t,
          "plugin-name": b.pluginName
        }, null, 8, ["id", "plugin-name"])
      ]),
      _: 1
    }, 16, ["disable-actions", "routable"]));
  }
});
export {
  ne as default
};
