"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Brand = void 0;
const react_1 = __importDefault(require("react"));
const react_redux_1 = require("react-redux");
const styled_1 = __importDefault(require("@emotion/styled"));
const react_web_components_1 = require("@nimles/react-web-components");
const Link_1 = require("./Link");
const StyledBrand = (0, styled_1.default)(Link_1.NavLink) `
  color: ${({ theme }) => { var _a, _b, _c; return (_c = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.onColor) !== null && _c !== void 0 ? _c : react_web_components_1.defaultTheme.colors.primary.onColor; }};
  font-weight: 800;
  font-size: 30px;
  line-height: 32px;
  height: 48px;
  letter-spacing: 1px;
  text-align: left;
  text-decoration: none;
  padding: 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  color: #fff;
  font-family: 'Lato', sans-serif;
  margin-bottom: 0;

  @media (min-width: ${(props) => { var _a, _b, _c; return (_c = (_b = (_a = props.theme) === null || _a === void 0 ? void 0 : _a.thresholds) === null || _b === void 0 ? void 0 : _b.sm) !== null && _c !== void 0 ? _c : react_web_components_1.defaultTheme.thresholds.sm; }}px) {
    padding: 8px 32px;
  }
`;
const Logo = styled_1.default.img `
  height: 32px;
`;
const Brand = ({ showLogo, showName }) => {
    const tenant = (0, react_redux_1.useSelector)(({ publicTenants }) => publicTenants.selected);
    const organization = (0, react_redux_1.useSelector)(({ publicOrganizations }) => publicOrganizations.selected);
    const logoId = organization ? organization.logoId : tenant.logoId;
    const logoUrl = logoId && `https://media.nimles.com/file/${tenant.id}/${logoId}`;
    const name = organization ? organization.name : tenant.name;
    if (!showLogo && !showName) {
        if (logoUrl) {
            showLogo = true;
        }
        else {
            showName = true;
        }
    }
    return (<StyledBrand to="/">
      {showLogo && <Logo src={logoUrl} alt={name}/>}
      {showName && <span>{name}</span>}
    </StyledBrand>);
};
exports.Brand = Brand;
//# sourceMappingURL=Brand.jsx.map