// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import { Logger } from "./logger";
const logger = Logger.getLogger();
export function ensureWebCodecsSupported(target) {
    const supported = typeof target !== "undefined";
    if (!supported) {
        const isProtocolSupported = window.location.protocol === "https:" || window.location.protocol === "file:";
        const isLocalHostname = window.location.hostname === "127.0.0.1" || window.location.hostname === "localhost";
        const reason = isProtocolSupported || isLocalHostname
            ? "Unsupported browser"
            : `${target} only supports \`https\` or \`localhost\` or \`127.0.0.1\``;
        logger.error(`${target} is not available. Reason: ${reason}`);
        return false;
    }
    return true;
}
//# sourceMappingURL=compatibility.js.map