"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLogic = void 0;
const useTheme_1 = require("../../../theme/hooks/useTheme");
const utils_1 = require("../utils");
const useLogic = ({ value, keyPath, checkExpanded, toggleExpanded, ...props }) => {
    const theme = (0, useTheme_1.useTheme)();
    const { type, icon, color } = (0, utils_1.getTypeInfo)(value, theme);
    const isExpandable = type === 'object' || type === 'array';
    const isExpanded = checkExpanded(keyPath);
    const getNestedKeyPath = (key) => {
        return `${keyPath}.${key}`;
    };
    const handleToggle = () => {
        if (isExpandable) {
            toggleExpanded(keyPath);
        }
    };
    return {
        icon,
        type,
        color,
        isExpandable,
        isExpanded,
        value,
        handleToggle,
        toggleExpanded,
        checkExpanded,
        getNestedKeyPath,
        ...props,
    };
};
exports.useLogic = useLogic;
