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;
};
import React, { useMemo } from "react";
import * as styles from "./styles";
import { useNeighborhoodMatch } from "~/sdks/NeighborhoodMatch/context";
import NeighborhoodFallbackImage from "~/assets/images/neighborhood-fallback.jpg";
export const Card = (_a) => {
    var { url, imageSrc, expanded, onClick, children } = _a, rest = __rest(_a, ["url", "imageSrc", "expanded", "onClick", "children"]);
    const { hideThumbnails, hideAffordabilityTags } = useNeighborhoodMatch();
    const style = useMemo(() => hideThumbnails
        ? {}
        : {
            backgroundImage: `url(${imageSrc || NeighborhoodFallbackImage})`,
        }, [hideThumbnails]);
    const heightStyle = useMemo(() => {
        if (!hideThumbnails)
            return "normal";
        if (expanded)
            return "expanded";
        return "hidden";
    }, [hideThumbnails, expanded]);
    const handleOnClick = (event) => {
        event.preventDefault();
        const { href } = event.currentTarget;
        if (!href ||
            typeof event.currentTarget.href === "undefined" ||
            href.length === 0) {
            return;
        }
        if (typeof onClick !== "undefined") {
            onClick();
        }
        if (window.top !== null) {
            window.top.location.href = event.currentTarget.href;
        }
    };
    return (React.createElement("a", Object.assign({ onClick: handleOnClick, href: url || undefined, className: styles.container, "data-has-url": !!url, "data-height-style": heightStyle }, rest),
        (!hideThumbnails || !hideAffordabilityTags) && (React.createElement("div", { className: styles.imageCover, style: style })),
        children));
};
//# sourceMappingURL=index.js.map