//
// Copyright 2025 DXOS.org
//
import React, { useMemo } from 'react';
import { Obj } from '@dxos/echo';
import { TraceEvent as TraceEventSchema } from '@dxos/functions-runtime';
import { withTheme } from '@dxos/react-ui/testing';
import { LogPanel } from './LogPanel';
const makeEvents = () => {
    const base = Date.now() - 1000 * 60 * 5;
    const mk = (offset, idx) => Obj.make(TraceEventSchema, {
        outcome: 'success',
        truncated: false,
        ingestionTimestamp: base + offset,
        logs: [
            { timestamp: base + offset + 100 * 1, level: 'info', message: `Invocation ${idx} started.`, context: { idx } },
            { timestamp: base + offset + 100 * 2, level: 'debug', message: 'Processing step.', context: { step: 1 } },
            {
                timestamp: base + offset + 100 * 3,
                level: 'warn',
                message: 'Potential issue detected.',
                context: { code: 'W001' },
            },
        ],
        exceptions: [],
    });
    const errorEvent = Obj.make(TraceEventSchema, {
        outcome: 'failure',
        truncated: false,
        ingestionTimestamp: base + 4_000,
        logs: [
            { timestamp: base + 4_100, level: 'info', message: 'Doing work.', context: { job: 'X' } },
            {
                timestamp: base + 4_200,
                level: 'error',
                message: 'Unhandled error.',
                context: {
                    err: { _id: 'TestError', message: 'Something went wrong.' },
                    stack: 'Error: Something went wrong.\n    at doWork (index.ts:1:1)',
                },
            },
        ],
        exceptions: [],
    });
    return [mk(0, 1), mk(1_000, 2), mk(2_000, 3), errorEvent];
};
const DefaultStory = () => {
    const objects = useMemo(() => makeEvents(), []);
    return (React.createElement("div", { className: 'p-4' },
        React.createElement(LogPanel, { objects: objects })));
};
const meta = {
    title: 'devtools/devtools/InvocationTrace/LogPanel',
    component: LogPanel,
    render: DefaultStory,
    decorators: [withTheme],
    parameters: {
        layout: 'fullscreen',
    },
};
export default meta;
export const Default = {};
//# sourceMappingURL=LogPanel.stories.js.map