"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageCircle = void 0;
const color_hash_1 = __importDefault(require("color-hash"));
const react_1 = __importDefault(require("react"));
const styled_components_1 = __importDefault(require("styled-components"));
const colorHash = new color_hash_1.default({ saturation: 0.7, lightness: 0.6 });
const Circle = styled_components_1.default.div `
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f5f5f5;
  width: 3em;
  height: 3em;
  overflow: hidden;
  border-radius: 100%;
  background-position: 50%;
  background-size: cover;
  margin-right: 0.6em;
  text-transform: uppercase;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
`;
const ImageCircle = (_a) => {
    var { src, alt = '', size = 24 } = _a, rest = __rest(_a, ["src", "alt", "size"]);
    const validImageSrc = src && /\.(jpg|jpeg|svg|png)$/i.test(src);
    return (react_1.default.createElement(Circle, Object.assign({}, rest, { style: {
            backgroundColor: validImageSrc
                ? 'transparent'
                : colorHash.hex(String(alt)),
            backgroundImage: validImageSrc ? `url(${src})` : 'none',
            fontSize: size,
        } }), !validImageSrc && alt.toString().slice(0, 2)));
};
exports.ImageCircle = ImageCircle;
//# sourceMappingURL=index.js.map