import { h as b, defineComponent as p, mergeModels as m, useModel as f, computed as A, createBlock as C, createCommentVNode as V, openBlock as h, unref as g, mergeProps as N } from "vue";
import { D as a } from "./constants-CwfsvyFM.js";
import { useI18n as E } from "vue-i18n";
import { F as D, G as $ } from "./start-CE9SawgU.js";
import "pinia";
import { N as v, S as y } from "./header-Bn1EKnBE.js";
function j(e) {
  return e.sourceType !== y.EMPTY ? e.sourceAttribute?.name ?? e.sourceNativeField : e.sourceDataTypeInstance ? E().t("datahub-ui.etl.constValueDataType", {
    value: e.sourceDataTypeInstance.name
  }) : "";
}
function k(e) {
  return !e.sourceLanguage && !e.sourceScope ? "" : ` ( ${[e.sourceLanguage?.description, e.sourceScope?.name].filter(Boolean).join(" / ")} )`;
}
function Y(e) {
  return !e?.destinationLanguage && !e?.destinationScope ? "" : ` ( ${[e.destinationLanguage?.description, e.destinationScope?.name].filter(Boolean).join(" / ")} )`;
}
const q = (e) => `${e.sourceEntityType.name} (${e.sourceEntityFriendlyIdentifier}) -> ${e.destinationEntityType.name} (${e.destinationEntityFriendlyIdentifier})`, H = (e) => e.etlAttributeMap.sourcePorts ? e.etlAttributeMap.sourcePorts.map(({ sourceType: t, sourceAttribute: o, sourceNativeField: u }) => {
  switch (t) {
    case 0:
      return o.name;
    case 2:
      return E().t("datahub-ui.shared.constantValue");
    default:
      return u;
  }
}).join(", ") : "", W = (e) => {
  switch (e.etlAttributeMap.destinationType) {
    case 0:
      return e.etlAttributeMap.destinationAttribute.name;
    case 1:
      return e.etlAttributeMap.destinationNativeField;
    default:
      return "";
  }
}, M = (e, t) => ({
  ...e,
  title: e.title || e.name,
  children: e.children?.map(M),
  sortOrder: t
}), x = (e) => Math.min(
  0,
  ...e.flatMap(({ id: t, children: o = [] }) => [
    t,
    ...o.map((u) => u.id)
  ])
) - 1, d = (e, t) => (o, u) => ({
  ...o,
  title: o[t],
  name: o[t],
  parent_id: e,
  active: !0,
  sortOrder: u,
  children: o.children?.map(
    (r) => d(r.id, t)(r, u)
  )
}), _ = (e, t = "de-DE", o = v, u) => {
  const r = `_${o}__${t}`;
  return e.reduce((i, n, s) => {
    if (Number(n.id) < 0) {
      const l = d(n.id, r), c = {
        ...n,
        title: n[r],
        name: n[r],
        sortOrder: s,
        children: n.children?.map(l),
        parent_id: u
      };
      i.push(c);
    } else n.children?.length && i.push(
      ..._(
        n.children,
        t,
        o,
        n.id
      )
    );
    return i;
  }, []);
}, F = (e, t = "de-DE", o = v, u) => {
  const r = `_${o}__${t}`;
  return e.reduce((i, n, s) => {
    if (Number(n.id) < 0)
      return i;
    if (n.updated || s !== n.sortOrder) {
      const l = d(Number(n.id), r), c = {
        ...n,
        title: n[r],
        name: n[r],
        sortOrder: s,
        children: n.children?.map(l),
        parent_id: u
      };
      i.push(c);
    } else n.children?.length && i.push(
      ...F(
        n.children,
        t,
        o,
        n.id
      )
    );
    return i;
  }, []);
}, P = (e, t) => {
  if (!e)
    return null;
  if (e.vueComponents)
    switch (t) {
      case a.CONFIG:
        return {
          name: e.vueComponents.configurationComponent,
          url: e.vueComponents.configurationImportPath
        };
      case a.VALUE:
        return {
          name: e.vueComponents.editComponent,
          url: e.vueComponents.editImportPath
        };
      case a.ETL_CONFIG:
        return {
          name: e.vueComponents.etlComponent,
          url: e.vueComponents.etlImportPath
        };
      case a.RENDER:
      default:
        return {
          name: e.vueComponents.renderComponent,
          url: e.vueComponents.renderImportPath
        };
    }
  switch (console.error(
    "==> FAILED in getExternalComponentConfig",
    t,
    e
  ), t) {
    case a.CONFIG:
      return {
        name: e.configurationWebComponent,
        url: e.configurationImport
      };
    case a.VALUE:
      return {
        name: e.valueEditWebComponent,
        url: e.valueEditHtmlImport
      };
    case a.ETL_CONFIG:
      return {
        name: e.vueComponents?.etlComponent,
        url: e.vueComponents?.etlImportPath
      };
    case a.RENDER:
    default:
      return {
        name: e.render?.component,
        url: e.render?.importPath
      };
  }
}, S = (e, t) => e.name ? $(e, t) : b(D, { error: e.url, name: e.name }), w = (e, t) => e ? e[t.key] ?? e[t.id] ?? Object.values(e)[0] : "", z = (e) => e ? e[0].toUpperCase() : "", J = (e) => `child-group-${e}`, T = (e) => e.endsWith(".") ? e : `${e}.`, Q = (e, t) => `${T(e)}${t}`, X = (e) => e ? isNaN(e.id) ? e.const ? 2 : e.dataType === "Actindo\\Modules\\Actindo\\DataHub\\DataTypes\\EntityCollectionValue" ? 3 : 1 : 0 : null, Z = (e) => {
  if (!e)
    return null;
  switch (e.sourceType) {
    case 1:
    case 3:
      return e.sourceNativeField;
    case 0:
      return e.sourceAttribute.id;
    case 2:
      return "-" + e.sourceDataType;
    default:
      return null;
  }
}, O = /* @__PURE__ */ p({
  __name: "DatahubExternalComponent",
  props: /* @__PURE__ */ m({
    dataTypeInstance: {},
    type: {}
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: /* @__PURE__ */ m(["loaded"], ["update:modelValue"]),
  setup(e, { emit: t }) {
    const o = e, u = f(e, "modelValue"), r = t, i = A(
      () => o.dataTypeInstance ? S(
        P(o.dataTypeInstance, o.type),
        () => {
          r("loaded");
        }
      ) : null
    );
    return (n, s) => i.value ? (h(), C(g(i), {
      key: 0,
      modelValue: u.value,
      "onUpdate:modelValue": s[0] || (s[0] = (l) => u.value = l),
      "data-type-instance": n.dataTypeInstance
    }, null, 8, ["modelValue", "data-type-instance"])) : V("", !0);
  }
}), K = /* @__PURE__ */ p({
  __name: "DatahubDataTypeEditor",
  props: /* @__PURE__ */ m({
    modelValue: {},
    readOnly: { type: Boolean },
    attribute: {},
    massEditing: { type: Boolean },
    label: {},
    fieldName: {},
    dataTypeInstance: {},
    loading: { type: Boolean },
    succeeded: { type: Boolean }
  }, {
    modelValue: {},
    modelModifiers: {}
  }),
  emits: /* @__PURE__ */ m(["loaded"], ["update:modelValue"]),
  setup(e) {
    const t = e, o = f(e, "modelValue");
    return (u, r) => (h(), C(O, N({
      modelValue: o.value,
      "onUpdate:modelValue": r[0] || (r[0] = (i) => o.value = i),
      type: g(a).VALUE
    }, t, {
      onLoaded: r[1] || (r[1] = (i) => u.$emit("loaded"))
    }), null, 16, ["modelValue", "type"]));
  }
});
export {
  K as _,
  _ as a,
  z as b,
  F as c,
  J as d,
  Q as e,
  O as f,
  x as g,
  q as h,
  j as i,
  k as j,
  Y as k,
  S as l,
  M as m,
  P as n,
  X as o,
  Z as p,
  w as q,
  H as s,
  W as t
};
