"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var AccountItem_exports = {};
__export(AccountItem_exports, {
  AccountItem: () => AccountItem
});
module.exports = __toCommonJS(AccountItem_exports);
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import_assets = require("../../../assets");
var import_components = require("../../../components");
var import_libs = require("../../libs");
var import_Address = require("../Address/Address");
var import_Checkbox = require("../Checkbox/Checkbox");
var import_Tag = require("../Tag/Tag");
const ICON_BUTTONS_SIZE = "32px";
const IconButton = import_styled_components.default.button`
  ${(0, import_libs.withTokens)("colors-content-default-default")}

  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: ${ICON_BUTTONS_SIZE};
  width: ${ICON_BUTTONS_SIZE};
`;
const Wrapper = import_styled_components.default.div`
  ${(0, import_libs.withTokens)(
  "spacing-xxxs",
  "spacing-xxs",
  "spacing-xs",
  "margin-s",
  "radius-s",
  "radius-m",
  "colors-content-default-default",
  "colors-surface-transparent-hover",
  "colors-surface-transparent-pressed",
  "colors-content-subdued-default-default",
  "colors-surface-transparent-subdued-default"
)}

  display: flex;
  cursor: ${(p) => p.isClickable ? "pointer" : "default"};
  justify-content: space-between;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
  min-width: 200px;
  overflow: hidden;

  background-color: ${(p) => p.backgroundColor ? p.backgroundColor : "transparent"};

  ${(p) => p.isClickable ? `
    border-radius: var(--radius-m);
    padding: var(--margin-s);
    &:hover {
      background-color: var(--colors-surface-transparent-hover);
    }

    &:active {
      background-color: var(--colors-surface-transparent-pressed);
    }
  ` : ""}
`;
const ContentContainer = import_styled_components.default.div`
  align-items: center;
  display: flex;
  flex: 1;
  gap: var(--spacing-xs);
  justify-content: space-between;
  min-width: 0;
  overflow: hidden;
  width: 100%;
`;
const AccountInfoContainer = import_styled_components.default.div`
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1;
  overflow: hidden;
`;
const NameRow = import_styled_components.default.div`
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-bottom: var(--spacing-xxxs);
  min-width: 0;
  width: 100%;
`;
const NameDiv = import_styled_components.default.div`
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
  max-width: fit-content;
`;
const TagWrapper = import_styled_components.default.div`
  flex-shrink: 0;
  margin-left: var(--spacing-xxs);
  display: flex;
  flex: 1;
  max-width: fit-content;
  align-items: center;
`;
const BalanceContainer = import_styled_components.default.div`
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  text-align: right;
`;
const AccountItem = ({
  onClick,
  account,
  rightElement,
  showIcon = true,
  backgroundColor
}) => {
  const { name, balance, fiatValue, protocol, address, ticker, cryptoId, parentId } = account;
  return /* @__PURE__ */ import_react.default.createElement(Wrapper, { backgroundColor, isClickable: Boolean(onClick), onClick }, /* @__PURE__ */ import_react.default.createElement(ContentContainer, null, /* @__PURE__ */ import_react.default.createElement(AccountInfoContainer, null, /* @__PURE__ */ import_react.default.createElement(NameRow, null, /* @__PURE__ */ import_react.default.createElement(NameDiv, null, /* @__PURE__ */ import_react.default.createElement(
    import_components.Text,
    {
      "data-testid": `account-row-${name}`,
      variant: "largeLineHeight",
      fontWeight: "semiBold",
      color: "var(--colors-content-default-default)",
      fontSize: "14px",
      lineHeight: "20px",
      title: name,
      style: {
        display: "block",
        whiteSpace: "nowrap",
        overflow: "hidden",
        textOverflow: "ellipsis"
      }
    },
    name
  )), protocol && /* @__PURE__ */ import_react.default.createElement(TagWrapper, null, /* @__PURE__ */ import_react.default.createElement(import_Tag.Tag, { textTransform: "uppercase" }, protocol))), /* @__PURE__ */ import_react.default.createElement(
    import_Address.Address,
    {
      address,
      cryptoId,
      ticker,
      parentId,
      showIcon,
      isShortened: true
    }
  )), /* @__PURE__ */ import_react.default.createElement(BalanceContainer, null, fiatValue && /* @__PURE__ */ import_react.default.createElement(import_components.Text, { fontSize: "14px" }, fiatValue), balance && /* @__PURE__ */ import_react.default.createElement(import_components.Text, { fontSize: "12px", color: "var(--colors-content-subdued-default-default)" }, balance)), rightElement && rightElement.type === "checkbox" && /* @__PURE__ */ import_react.default.createElement(import_components.Flex, { "data-testid": "right-element-checkbox", "aria-label": "Checkbox account item" }, /* @__PURE__ */ import_react.default.createElement(import_Checkbox.Checkbox, { ...rightElement.checkbox, size: 20 })), rightElement && rightElement.type === "arrow" && /* @__PURE__ */ import_react.default.createElement(import_components.Flex, { "data-testid": "right-element-arrow-icon", "aria-label": "Arrow account item" }, /* @__PURE__ */ import_react.default.createElement(import_components.Icon, { name: "ChevronRight", size: 24 })), rightElement && rightElement.type === "edit" && /* @__PURE__ */ import_react.default.createElement(
    IconButton,
    {
      "aria-label": "Edit account item",
      "data-testid": "right-element-edit-icon",
      onClick: (e) => {
        e.stopPropagation();
        if ((rightElement == null ? void 0 : rightElement.type) === "edit") {
          rightElement.onClick();
        }
      }
    },
    /* @__PURE__ */ import_react.default.createElement(import_assets.Icons.PenEdit, { size: "S", color: "var(--colors-content-default-default)" })
  )));
};
//# sourceMappingURL=AccountItem.js.map
