import { jsx, jsxs } from 'react/jsx-runtime';
import React from 'react';
import { cn } from '@windrun-huaiin/lib/utils';
import { themeRichTextMarkClass } from '@windrun-huaiin/base-ui/lib';

// default tag renderers
const defaultTagRenderers = {
    // text next line
    br: (chunks) => (jsxs(React.Fragment, { children: [jsx("br", {}), chunks] })),
    // text Stong
    strong: (chunks) => jsx("strong", { children: chunks }),
    // text Emphasis
    em: (chunks) => jsx("em", { children: chunks }),
    // text Underline
    u: (chunks) => jsx("u", { children: chunks }),
    // text Mark
    mark: (chunks) => jsx("mark", { className: cn(themeRichTextMarkClass, "text-neutral-800 dark:text-neutral-300 px-1 rounded"), children: chunks }),
    // text Delete
    del: (chunks) => jsx("del", { children: chunks }),
    // text Subscript
    sub: (chunks) => jsx("sub", { children: chunks }),
    // text Superscript
    sup: (chunks) => jsx("sup", { children: chunks }),
};
// create rich text renderer
function createRichTextRenderer(customRenderers) {
    const renderers = Object.assign(Object.assign({}, defaultTagRenderers), customRenderers);
    return function richText(t, key) {
        return t.rich(key, renderers);
    };
}
// default rich text renderer
const richText = createRichTextRenderer();

export { createRichTextRenderer, richText };
