"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const image_1 = __importDefault(require("next/image"));
const util_1 = require("./util");
const base_path_1 = __importDefault(require("lib/base-path"));
const path_1 = require("path");
function Image({ src, style, alt, width, height, priority = false, }) {
    if (typeof src == "string") {
        return ((0, jsx_runtime_1.jsx)("img", { src: (0, util_1.MediaURL)(src), style: { ...style, maxWidth: "100%" }, alt: alt, width: width, height: height }));
    }
    if (base_path_1.default.length > 1 && !src.src?.startsWith(base_path_1.default)) {
        // This is a hack to workaround the very annoying fact that
        // next/image does NOT properly support the nextjs basePath
        // option.  This is definitely a bug in nextjs, and when it
        // gets fixed, this workaround will break our site!
        // The next/image implementation is in packages/next/client/image.tsx of nextjs itself.
        // Here's the issue: https://github.com/vercel/next.js/issues/22244
        src.src = (0, path_1.join)(base_path_1.default, src.src);
    }
    if (height != null && width != null) {
        return (0, jsx_runtime_1.jsx)(image_1.default, { src: src, alt: alt, height: height, width: width });
    }
    return ((0, jsx_runtime_1.jsx)("div", { style: {
            width: "100%",
            ...style,
            display: "inline-block",
        }, children: (0, jsx_runtime_1.jsx)("div", { style: { position: "relative", width: "100%" }, children: (0, jsx_runtime_1.jsx)(image_1.default, { src: src, alt: alt, layout: "responsive", width: width, priority: priority }) }) }));
}
exports.default = Image;
//# sourceMappingURL=image.js.map