import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { isBrowser } from '@websolutespa/bom-core';
import { useLabel } from '@websolutespa/bom-mixer-hooks';
import { Text } from '@websolutespa/bom-mixer-llm';
import { useState } from 'react';
const USE_INSPECT_PARAM = false;
function hasInspect() {
    if (!isBrowser) {
        return false;
    }
    const url = new URL(window.location.href);
    return url.searchParams.has('inspect');
}
export const StreamError = (props)=>{
    const { item } = props;
    const label = useLabel();
    const [show, setShow] = useState(false);
    const shouldShowStreamError = USE_INSPECT_PARAM ? hasInspect() : true;
    return shouldShowStreamError ? /*#__PURE__*/ _jsxs("div", {
        className: "llm__stream-error llm__row",
        children: [
            /*#__PURE__*/ _jsxs("div", {
                className: "llm__stream-error__info llm__col --sm-10 --md-8 --lg-6",
                children: [
                    /*#__PURE__*/ _jsx(Text, {
                        body: label('llm.streamError')
                    }),
                    /*#__PURE__*/ _jsx("button", {
                        className: "llm__stream-error__toggle",
                        type: "button",
                        onClick: ()=>setShow(!show),
                        "aria-label": show ? label('llm.hideError') : label('llm.showError'),
                        "aria-pressed": show,
                        children: show ? label('llm.hideError') : label('llm.showError')
                    })
                ]
            }),
            show && /*#__PURE__*/ _jsx("code", {
                className: "llm__stream-error__error llm__hint",
                children: JSON.stringify(item.error)
            })
        ]
    }) : undefined;
};

//# sourceMappingURL=StreamError.js.map