import { jsx as _jsx } from "react/jsx-runtime";
import { fn } from '@storybook/test';
import { CodeReviewPanel } from './code-review-panel.js';
import { CodeReviewStatus, CommentSide } from '../../../../../../packages/core/src/domain/generated/output.js';
const now = new Date();
const sampleComments = [
    {
        path: 'src/services/auth.ts',
        line: 42,
        body: 'This function does not validate the input before using it in a SQL query, which could lead to SQL injection.',
        side: CommentSide.Right,
        inDiffRange: true,
    },
    {
        path: 'src/services/auth.ts',
        line: 58,
        body: 'Consider adding rate limiting to prevent brute-force attacks.',
        side: CommentSide.Right,
        suggestion: 'const limiter = rateLimit({\n  windowMs: 15 * 60 * 1000,\n  max: 100,\n});',
        inDiffRange: true,
    },
    {
        path: 'src/controllers/user.controller.ts',
        line: 15,
        body: 'Missing error handling for the async operation.',
        side: CommentSide.Right,
        inDiffRange: true,
    },
    {
        path: 'src/utils/helpers.ts',
        line: 100,
        body: 'This related utility function also has a potential issue but is outside the current diff range.',
        side: CommentSide.Right,
        inDiffRange: false,
    },
];
const completedReview = {
    id: 'review-1',
    repositoryPath: '/home/user/project',
    prNumber: 42,
    prUrl: 'https://github.com/org/repo/pull/42',
    status: CodeReviewStatus.Completed,
    summary: 'Found 4 issues: 1 critical SQL injection vulnerability, 1 missing rate limiting, 1 missing error handler, and 1 related issue outside the diff range.',
    comments: sampleComments,
    createdAt: now,
    updatedAt: now,
};
const meta = {
    title: 'Features/CodeReview/CodeReviewPanel',
    component: CodeReviewPanel,
    parameters: { layout: 'padded' },
    tags: ['autodocs'],
    decorators: [
        (Story) => (_jsx("div", { className: "max-w-3xl", children: _jsx(Story, {}) })),
    ],
    args: {
        onPostToGitHub: fn(),
    },
};
export default meta;
export const Default = {
    args: {
        review: completedReview,
    },
};
export const Loading = {
    args: {
        loading: true,
    },
};
export const Error = {
    args: {
        error: 'Failed to run code review: Agent timed out after 120 seconds.',
    },
};
export const Empty = {
    args: {
        review: {
            ...completedReview,
            summary: 'No issues found. The code changes look well-structured and follow best practices.',
            comments: [],
        },
    },
};
export const Posted = {
    args: {
        review: {
            ...completedReview,
            status: CodeReviewStatus.Posted,
            reviewUrl: 'https://github.com/org/repo/pull/42#pullrequestreview-123456',
        },
    },
};
export const FailedReview = {
    args: {
        review: {
            ...completedReview,
            status: CodeReviewStatus.Failed,
            summary: undefined,
            comments: [],
            errorMessage: 'Agent failed: structured output could not be parsed after 3 repair attempts.',
        },
    },
};
export const InProgress = {
    args: {
        review: {
            ...completedReview,
            status: CodeReviewStatus.InProgress,
            summary: undefined,
            comments: [],
        },
    },
};
