"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    MemorizedTabContent: function() {
        return MemorizedTabContent;
    },
    TabContent: function() {
        return TabContent;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _tabContext = require("./tabContext");
const _css = require("../utils/css");
const _constants = require("./constants");
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 TabContent = (props)=>{
    const { keepAlive, activeIndex, tabs, mode } = props;
    const { contentVisible } = (0, _tabContext.useTabContext)();
    // const contentVisible = true;
    const children = (0, _react.useMemo)(()=>{
        if (!tabs) return null;
        if (!keepAlive) {
            return tabs[activeIndex ?? 0];
        }
        return tabs.map((tab, index)=>{
            return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                className: (0, _css.cn)("orderly-h-full orderly-w-full orderly-transition-all orderly-min-w-0", mode === _constants.TabViewMode.Tab ? index === activeIndex ? "orderly-inset-0" : "orderly-hidden" : "orderly-border-l orderly-border-divider first:orderly-border-l-0"),
                children: tab
            }, index);
        });
    }, [
        activeIndex,
        keepAlive,
        tabs,
        mode
    ]);
    const layout = (0, _react.useMemo)(()=>{
        return {};
    }, []);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
        className: (0, _css.cn)("orderly-transition-all orderly-grid", contentVisible ? "orderly-grid-rows-[1fr]" : "orderly-grid-rows-[0fr]"),
        children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
            className: (0, _css.cn)("orderly-overflow-hidden orderly-relative", mode === _constants.TabViewMode.Group && "orderly-grid"),
            style: mode === _constants.TabViewMode.Group ? {
                gridTemplateColumns: `repeat(${props.tabs?.length}, 1fr)`,
                ...layout
            } : layout,
            children: children
        })
    });
};
const MemorizedTabContent = /*#__PURE__*/ (0, _react.memo)(TabContent);

//# sourceMappingURL=tabContent.js.map