"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LinkCardImage = exports.LinkCardIcon = exports.LinkCardFooter = exports.LinkCardDescription = exports.LinkCardAnchor = exports.LinkCardTitle = exports.LinkCard = void 0;
const react_1 = __importStar(require("react"));
const typography_1 = require("../typography");
const link_anchor_1 = require("../utils/components/link-anchor");
const helpers_1 = require("../utils/helpers");
const { Provider: LinkCardContextProvider, useContext: useLinkCardContext } = (0, helpers_1.createStrictContext)({
    name: "LinkCardContextProvider",
});
/**
 * Accessible clickable card as a link.
 *
 * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/linkcard)
 * @see 🏷️ {@link LinkCardProps}
 *
 *
 * @example
 * ```tsx
 * <LinkCard>
 *   <LinkCard.Icon>
 *     <IconOrPictogram />
 *   </LinkCard.Icon>
 *   <LinkCard.Title>
 *     <LinkCard.Anchor href="/href">
 *       LinkCard title
 *     </LinkCard.Anchor>
 *   </LinkCard.Title>
 *   <LinkCard.Description>
 *     This is a description of the link card.
 *   </LinkCard.Description>
 *   <LinkCard.Footer>Footer content</LinkCard.Footer>
 * </LinkCard>
 * ```
 */
exports.LinkCard = (0, react_1.forwardRef)((_a, forwardedRef) => {
    var { children, className, arrow = true, arrowPosition = "baseline", size = "medium", as: Component = "div" } = _a, restProps = __rest(_a, ["children", "className", "arrow", "arrowPosition", "size", "as"]);
    return (react_1.default.createElement(LinkCardContextProvider, { size: size },
        react_1.default.createElement(link_anchor_1.LinkAnchorOverlay, { asChild: true },
            react_1.default.createElement(typography_1.BodyLong, Object.assign({ as: Component, size: size, ref: forwardedRef, "data-color": "neutral", className: (0, helpers_1.cl)("aksel-link-card", className, `aksel-link-card--${size}`), "data-align-arrow": arrowPosition }, restProps),
                children,
                arrow && (react_1.default.createElement(link_anchor_1.LinkAnchorArrow, { fontSize: size === "medium" ? "1.75rem" : "1.5rem", className: "aksel-link-card__arrow" }))))));
});
/**
 * @see 🏷️ {@link LinkCardTitleProps}
 */
exports.LinkCardTitle = (0, react_1.forwardRef)((_a, forwardedRef) => {
    var { children, as = "span", className } = _a, restProps = __rest(_a, ["children", "as", "className"]);
    const context = useLinkCardContext();
    return (react_1.default.createElement(typography_1.Heading, Object.assign({ ref: forwardedRef, as: as, size: context.size === "medium" ? "small" : "xsmall", className: (0, helpers_1.cl)("aksel-link-card__title", className) }, restProps), children));
});
/**
 * @see 🏷️ {@link LinkCardAnchorProps}
 */
exports.LinkCardAnchor = link_anchor_1.LinkAnchor;
/**
 * @see 🏷️ {@link LinkCardDescriptionProps}
 */
exports.LinkCardDescription = (0, react_1.forwardRef)((_a, forwardedRef) => {
    var { children, className } = _a, restProps = __rest(_a, ["children", "className"]);
    return (react_1.default.createElement("div", Object.assign({ ref: forwardedRef, className: (0, helpers_1.cl)("aksel-link-card__description", className) }, restProps), children));
});
/**
 * @see 🏷️ {@link LinkCardFooterProps}
 */
exports.LinkCardFooter = (0, react_1.forwardRef)((_a, forwardedRef) => {
    var { children, className } = _a, restProps = __rest(_a, ["children", "className"]);
    return (react_1.default.createElement("div", Object.assign({ ref: forwardedRef, className: (0, helpers_1.cl)("aksel-link-card__footer", className) }, restProps), children));
});
/**
 * @see 🏷️ {@link LinkCardIconProps}
 */
exports.LinkCardIcon = (0, react_1.forwardRef)((_a, forwardedRef) => {
    var { children, className } = _a, restProps = __rest(_a, ["children", "className"]);
    return (react_1.default.createElement("div", Object.assign({ ref: forwardedRef, "aria-hidden": true, className: (0, helpers_1.cl)("aksel-link-card__icon", className) }, restProps), children));
});
/**
 * @see 🏷️ {@link LinkCardImageProps}
 */
exports.LinkCardImage = (0, react_1.forwardRef)((_a, forwardedRef) => {
    var { children, className, aspectRatio, style } = _a, restProps = __rest(_a, ["children", "className", "aspectRatio", "style"]);
    return (react_1.default.createElement("div", Object.assign({ ref: forwardedRef, className: (0, helpers_1.cl)("aksel-link-card__image-container", className), style: Object.assign(Object.assign({}, style), { aspectRatio }) }, restProps), children));
});
exports.LinkCard.Title = exports.LinkCardTitle;
exports.LinkCard.Anchor = exports.LinkCardAnchor;
exports.LinkCard.Description = exports.LinkCardDescription;
exports.LinkCard.Footer = exports.LinkCardFooter;
exports.LinkCard.Icon = exports.LinkCardIcon;
exports.LinkCard.Image = exports.LinkCardImage;
//# sourceMappingURL=LinkCard.js.map