import { jsx as _jsx } from "@emotion/react/jsx-runtime";
import { Button, Link, Td } from '@chakra-ui/react';
import { LIST_ITEM_EXP } from '../../../constants';
export const TableTd = props => {
    const { item, column, onClickItem, services } = props;
    let value = item[column.key];
    if (column.displayValue) {
        value = services.stateManager.maskedEval(column.displayValue, true, {
            [LIST_ITEM_EXP]: item,
        });
    }
    let content = value;
    switch (column.type) {
        case 'image':
            content = _jsx("img", { src: value }, void 0);
            break;
        case 'link':
            content = (_jsx(Link, Object.assign({ href: value, color: "blue.600" }, { children: value }), void 0));
            break;
        case 'button':
            const onClick = () => {
                onClickItem();
                column.buttonConfig.handlers.forEach(handler => {
                    services.apiService.send('uiMethod', {
                        componentId: handler.componentId,
                        name: handler.method.name,
                        parameters: handler.method.parameters,
                    });
                });
            };
            content = _jsx(Button, Object.assign({ onClick: onClick }, { children: column.buttonConfig.text }), void 0);
            break;
    }
    return (_jsx(Td, Object.assign({ paddingX: "4", paddingY: "2" }, { children: content }), void 0));
};
//# sourceMappingURL=TableTd.js.map