import { aK as ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT, aw as UserHelper, a as Ctx, j as Alert, h as AlertType, T as Trans, i as CommonError } from "./index.js";
import React__default from "react";
const LinkedAccountsErrorAlert = (props) => {
  var _a;
  const { error, accountConflictInformation, onDismiss } = props;
  if ((accountConflictInformation == null ? void 0 : accountConflictInformation.errorCode) === ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT && accountConflictInformation) {
    const platformName = UserHelper.getPlatformName(accountConflictInformation.platformId);
    const customAttributes = ((_a = Ctx.getUserManager().state.userProfile) == null ? void 0 : _a.customAttributes) || {};
    const { displayName, platformUserId } = customAttributes[accountConflictInformation.platformId] || {
      displayName: "",
      platformUserId: ""
    };
    return /* @__PURE__ */ React__default.createElement(Alert, {
      className: "mb-6",
      type: AlertType.danger,
      onDismiss
    }, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "LinkedAccountpage.cannotLinkWithAnotherAccount"
    }, "Unable to link this ", { platformName }, " account. Please link the ", { platformName }, " account previously linked to this account :", " ", { displayName }, " ( ", { platformUserId }, " )."));
  }
  if (accountConflictInformation) {
    const platformName = UserHelper.getPlatformName(accountConflictInformation.platformId);
    return /* @__PURE__ */ React__default.createElement(Alert, {
      className: "mb-6",
      type: AlertType.danger,
      onDismiss
    }, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "LinkedAccountPage.linkConflictError"
    }, "That ", { platformName }, " account is already linked with another AccelByte account.", /* @__PURE__ */ React__default.createElement("br", null), " Please unlink it first or try linking a different ", { platformName }, " account."));
  }
  if (error) {
    return /* @__PURE__ */ React__default.createElement(Alert, {
      type: AlertType.danger,
      className: "alert",
      onDismiss
    }, /* @__PURE__ */ React__default.createElement(CommonError, {
      error
    }));
  }
  return null;
};
export { LinkedAccountsErrorAlert as L };
