import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import React from 'react';
import { DescriptionTooltip } from '../DescriptionTooltip';
import { MdxJSToJSX } from '../MDXElements';
import { registerWidget, Value } from '../Value';
import { RenderContext, IndentLevelContext, indent, renderTypeParameters } from '../widgetUtils';
registerWidget('function', ({ value }) => {
    const level = React.useContext(IndentLevelContext);
    return (_jsxs(RenderContext.Provider, { value: "inline", children: [value.name && _jsx(Value, { value: value.name }), renderTypeParameters(value.typeParameters), _jsx("span", { className: "token punctuation", children: "(" }), _jsx(_Fragment, { children: value.parameters.map((p, index) => (_jsxs(React.Fragment, { children: [index !== 0 && _jsx("span", { className: "token punctuation", children: ", " }), value.parameters.length > 1 && (_jsxs(_Fragment, { children: [_jsx("br", {}), indent(level + 1)] })), value.parameters.length > 1 ? (_jsx(IndentLevelContext.Provider, { value: level + 1, children: _jsx(Value, { value: p }) })) : (_jsx(Value, { value: p })), index === value.parameters.length - 1 && index > 0 && (_jsxs(_Fragment, { children: [_jsx("br", {}), indent(level)] }))] }, index))) }), _jsx("span", { className: "token operator", children: ")\u00A0=>\u00A0" }), _jsx(Value, { value: value.returnType })] }));
});
registerWidget('parameter', ({ value }) => {
    return (_jsxs(RenderContext.Provider, { value: "inline", children: [value.description ? (_jsx(DescriptionTooltip, { style: { maxWidth: '50em' }, title: _jsx(MdxJSToJSX, { children: value.description }), children: _jsx("span", { className: "token property", style: {
                        cursor: 'pointer',
                        textDecoration: 'underline',
                        textDecorationStyle: 'dotted',
                    }, children: value.name }) })) : (_jsx("span", { className: "token property", children: value.name })), _jsx("span", { className: "token punctuation", children: ":" }), "\u00A0", _jsx(Value, { value: value.type })] }));
});
