import React, { useMemo } from 'react';
import { always, pipe } from 'ramda';
import i18n from 'ui-i18n';
import { parseJSON } from '@reltio/mdm-sdk';
import { ActivityTitle } from '../../../ActivityTitle';
import { useReadableSearchState } from '../../../../../hooks/useReadableSearchState';
import { useMdmAction } from '../../../../../contexts/MdmModuleContext';
import { useStyles } from './styles';
export var SearchActivity = function (_a) {
    var data = _a.data, type = _a.type;
    var styles = useStyles();
    var openSearch = useMdmAction('openSearch');
    var searchState = useMemo(function () {
        var searchData = parseJSON(data.description);
        return searchData.version === '2.0' ? searchData.activity.uiState : searchData;
    }, [data.description]);
    var handleOpenSearch = pipe(always(searchState), openSearch);
    var readableQueryString = useReadableSearchState(searchState).readableQueryString;
    return (React.createElement(ActivityTitle, { type: type, "data-reltio-id": "search-activity" },
        React.createElement("span", { className: styles.link, onClick: handleOpenSearch }, readableQueryString || i18n.text('all profiles'))));
};
