import React from "react";
import { createElement as createSyntaxElement } from "react-syntax-highlighter";
import { classes } from "../CodeArea.tokens";
const isLineNumberNode = (node)=>Array.isArray(node?.properties?.className) && node?.properties?.className.includes('linenumber');
export const renderCodeRows = ({ rows, stylesheet, useInlineStyles })=>rows.map((row, rowIndex)=>{
        const children = row.children || [];
        const [firstChild, ...restChildren] = children;
        const hasLineNumber = isLineNumberNode(firstChild);
        const codeChildren = hasLineNumber ? restChildren : children;
        const lineClassName = hasLineNumber ? classes.line : `${classes.line} ${classes.lineWithoutNumber}`;
        return /*#__PURE__*/ React.createElement("span", {
            key: `code-line-${rowIndex}`,
            className: lineClassName
        }, hasLineNumber && createSyntaxElement({
            node: firstChild,
            stylesheet,
            useInlineStyles,
            key: `line-number-${rowIndex}`
        }), /*#__PURE__*/ React.createElement("span", {
            className: classes.lineContent
        }, codeChildren.map((node, nodeIndex)=>createSyntaxElement({
                node,
                stylesheet,
                useInlineStyles,
                key: `line-${rowIndex}-segment-${nodeIndex}`
            }))));
    });
