"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ItemHeader = void 0;
const react_1 = __importDefault(require("react"));
const Theme_1 = require("../../../theme/Theme");
const link_anchor_1 = require("../../../utils/components/link-anchor");
const download_file_1 = require("../helpers/download-file");
const file_type_checker_1 = require("../helpers/file-type-checker");
const ItemIcon_1 = __importDefault(require("../item-icon/ItemIcon"));
const ItemHeader = ({ file, href, onClick }) => {
    const ctx = (0, Theme_1.useThemeInternal)();
    if (onClick && href) {
        return (react_1.default.createElement(link_anchor_1.LinkAnchor, { href: href, onClick: onClick, className: "aksel-file-item__link", "data-color": ctx.color },
            react_1.default.createElement(ItemIcon_1.default, { file: file }),
            file.name));
    }
    if (onClick) {
        return (react_1.default.createElement(link_anchor_1.LinkAnchor, { href: "#", onClick: (event) => {
                event.preventDefault();
                onClick(event);
            }, className: "aksel-file-item__link", "data-color": ctx.color },
            react_1.default.createElement(ItemIcon_1.default, { file: file }),
            file.name));
    }
    if (href) {
        return (react_1.default.createElement(link_anchor_1.LinkAnchor, { href: href, className: "aksel-file-item__link", "data-color": ctx.color },
            react_1.default.createElement(ItemIcon_1.default, { file: file }),
            file.name));
    }
    if ((0, file_type_checker_1.isNativeFile)(file)) {
        return (react_1.default.createElement(link_anchor_1.LinkAnchor, { href: "#", download: file.name, onClick: (event) => {
                event.preventDefault();
                (0, download_file_1.downloadFile)(file);
            }, className: "aksel-file-item__link", "data-color": ctx.color },
            react_1.default.createElement(ItemIcon_1.default, { file: file }),
            file.name));
    }
    return (react_1.default.createElement("span", { className: "aksel-file-item__link" },
        react_1.default.createElement(ItemIcon_1.default, { file: file }),
        file.name));
};
exports.ItemHeader = ItemHeader;
//# sourceMappingURL=ItemHeader.js.map