"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "MainLogo", {
    enumerable: true,
    get: function() {
        return MainLogo;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _appProvider = require("../provider/appProvider");
const _css = require("../utils/css");
const _hooks = require("@orderly.network/hooks");
const _types = require("@orderly.network/types");
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const MainLogo = ({ link = "/", // image,
title, size })=>{
    const matches = (0, _hooks.useMediaQuery)(_types.MEDIA_TABLET);
    const { appIcons } = (0, _react.useContext)(_appProvider.OrderlyAppContext);
    if (!appIcons?.main?.img && !appIcons?.main?.component) return null;
    // const [url, setUrl] = React.useState<string>();
    const _size = (0, _react.useMemo)(()=>{
        if (typeof size === "number") {
            return size;
        }
        if (matches) {
            return 50;
        }
        return 48;
    }, [
        size
    ]);
    const logoElement = (0, _react.useMemo)(()=>{
        if (appIcons?.main?.img) {
            return /*#__PURE__*/ (0, _jsxruntime.jsx)("img", {
                src: appIcons?.main?.img,
                height: _size
            });
        }
        return null;
    }, [
        appIcons?.main,
        _size
    ]);
    if (appIcons?.main?.component) {
        return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
            children: appIcons.main.component
        });
    }
    // if(matches){
    return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
        className: (0, _css.cn)("orderly-inline-flex orderly-flex-row orderly-justify-center orderly-items-center orderly-px-3", appIcons.main?.className),
        style: {
            height: `${_size}px`
        },
        children: /*#__PURE__*/ (0, _jsxruntime.jsx)("a", {
            href: link,
            children: logoElement
        })
    });
// }
};

//# sourceMappingURL=mainLogo.js.map