import { default as default_2 } from 'react';
import { NiceBaseProps } from '@nice2dev/ui-core';

declare interface BlameAuthor {
    id: string;
    name: string;
    email: string;
    avatar?: string;
}

declare interface BlameCommit {
    id: string;
    shortId: string;
    message: string;
    author: BlameAuthor;
    timestamp: Date;
    parents?: string[];
}

declare interface BlameFile {
    path: string;
    revision: string;
    hunks: BlameHunk[];
    language?: string;
    totalLines: number;
}

declare interface BlameHunk {
    startLine: number;
    endLine: number;
    commit: BlameCommit;
    lines: BlameLine[];
}

declare interface BlameLine {
    lineNumber: number;
    content: string;
    commit: BlameCommit;
    originalLineNumber?: number;
    originalFilename?: string;
}

declare type BlameViewMode = 'inline' | 'gutter' | 'tooltip';

declare interface BranchProtectionRule {
    pattern: string;
    requirePullRequest?: boolean;
    requiredReviewers?: number;
    requireStatusChecks?: string[];
    requireSignedCommits?: boolean;
    allowForcePush?: boolean;
    allowDeletion?: boolean;
}

declare interface ConflictFile {
    path: string;
    language?: string;
    baseRef: string;
    oursRef: string;
    theirsRef: string;
    content: string;
    conflicts: ConflictRegion[];
}

declare interface ConflictRegion {
    id: string;
    startLine: number;
    endLine: number;
    baseContent: string[];
    oursContent: string[];
    theirsContent: string[];
    resolved: boolean;
    resolution?: 'ours' | 'theirs' | 'both' | 'custom';
    customContent?: string[];
}

declare type ConflictViewMode = 'inline' | 'split' | 'three-way';

declare interface DiffChunk {
    oldStart: number;
    oldLines: number;
    newStart: number;
    newLines: number;
    lines: DiffLine[];
    header?: string;
}

declare interface DiffComment {
    id: string;
    filePath: string;
    line: number;
    side: 'old' | 'new';
    author: {
        name: string;
        avatar?: string;
    };
    body: string;
    createdAt: Date;
    resolved?: boolean;
}

declare interface DiffFile {
    path: string;
    oldPath?: string;
    status: 'added' | 'modified' | 'deleted' | 'renamed' | 'copied';
    binary?: boolean;
    additions: number;
    deletions: number;
    chunks: DiffChunk[];
    language?: string;
}

declare interface DiffLine {
    lineNumberOld?: number;
    lineNumberNew?: number;
    content: string;
    type: 'context' | 'addition' | 'deletion' | 'header';
}

declare type DiffViewMode = 'split' | 'unified';

declare interface GitBranch {
    name: string;
    isRemote: boolean;
    isHead: boolean;
    upstream?: string;
    ahead?: number;
    behind?: number;
    lastCommit?: string;
    protected?: boolean;
}

declare interface GitBranch_2 {
    name: string;
    isRemote: boolean;
    isHead: boolean;
    upstream?: string;
    ahead?: number;
    behind?: number;
    lastCommit?: {
        hash: string;
        message: string;
        author: string;
        date: Date;
    };
    protected?: boolean;
    description?: string;
}

declare interface GitCommit {
    hash: string;
    shortHash: string;
    message: string;
    body?: string;
    author: {
        name: string;
        email: string;
        avatar?: string;
    };
    date: Date;
    parents: string[];
    /** Branch heads pointing at this commit */
    branches?: string[];
    /** Tags pointing at this commit */
    tags?: string[];
    /** Is this a merge commit */
    isMerge?: boolean;
    /** Files changed (summary) */
    stats?: {
        additions: number;
        deletions: number;
        filesChanged: number;
    };
}

declare interface GitHook {
    type: GitHookType;
    enabled: boolean;
    actions: HookAction[];
    parallel?: boolean;
    timeout?: number;
    verbose?: boolean;
}

declare type GitHookType = 'pre-commit' | 'prepare-commit-msg' | 'commit-msg' | 'post-commit' | 'pre-push' | 'pre-rebase' | 'post-merge' | 'post-checkout' | 'pre-auto-gc';

declare interface GitTag {
    name: string;
    commit: string;
    message?: string;
    tagger?: string;
    date?: Date;
    isAnnotated?: boolean;
}

declare interface HookAction {
    id: string;
    type: 'lint' | 'test' | 'format' | 'typecheck' | 'build' | 'custom';
    name: string;
    command: string;
    description?: string;
    icon?: string;
    runOn?: 'staged' | 'all' | 'changed';
    filePatterns?: string[];
    condition?: HookCondition;
    order: number;
    enabled: boolean;
    failOnError: boolean;
}

declare interface HookCondition {
    type: 'branch' | 'files' | 'env' | 'custom';
    operator: 'equals' | 'contains' | 'matches' | 'exists' | 'not';
    value: string;
}

declare interface HookTemplate {
    id: string;
    name: string;
    description: string;
    icon: string;
    category: 'lint' | 'test' | 'security' | 'quality' | 'ci';
    hook: GitHookType;
    actions: Omit<HookAction, 'id' | 'order'>[];
}

declare type JobStatus = 'pending' | 'running' | 'success' | 'failure' | 'cancelled' | 'skipped' | 'waiting';

declare interface MergeContext {
    baseCommit: {
        id: string;
        shortId: string;
        message: string;
        author: string;
    };
    oursCommit: {
        id: string;
        shortId: string;
        message: string;
        author: string;
        branch: string;
    };
    theirsCommit: {
        id: string;
        shortId: string;
        message: string;
        author: string;
        branch: string;
    };
}

declare interface MergeRequestData {
    title: string;
    description: string;
    sourceBranch: string;
    targetBranch: string;
    isDraft: boolean;
    labels: string[];
    reviewers: string[];
    assignees: string[];
    linkedIssues: string[];
    squashCommits: boolean;
    deleteSourceBranch: boolean;
}

declare interface MergeRequestDiff {
    additions: number;
    deletions: number;
    changedFiles: number;
    files: Array<{
        path: string;
        status: 'added' | 'modified' | 'deleted' | 'renamed';
        additions: number;
        deletions: number;
    }>;
}

declare interface MergeRequestIssue {
    id: string;
    number: number;
    title: string;
    state: 'open' | 'closed';
    labels?: MergeRequestLabel[];
}

declare interface MergeRequestLabel {
    id: string;
    name: string;
    color: string;
    description?: string;
}

declare interface MergeRequestTemplate {
    id: string;
    name: string;
    description: string;
    content: string;
}

declare interface MergeRequestUser {
    id: string;
    name: string;
    email: string;
    avatar?: string;
}

export declare const NiceBranchManager: default_2.FC<NiceBranchManagerProps>;

export declare interface NiceBranchManagerProps extends NiceBaseProps {
    /** All branches */
    branches: GitBranch_2[];
    /** Current HEAD branch */
    currentBranch?: string;
    /** Default branch */
    defaultBranch?: string;
    /** Protection rules */
    protectionRules?: BranchProtectionRule[];
    /** Show remote branches */
    showRemotes?: boolean;
    /** Selected branch */
    selectedBranch?: string;
    onBranchSelect?: (branch: string) => void;
    onCheckout?: (branch: string) => void;
    onCreateBranch?: (name: string, fromBranch?: string) => void;
    onDeleteBranch?: (branch: string, force?: boolean) => void;
    onRenameBranch?: (oldName: string, newName: string) => void;
    onMerge?: (source: string, target: string) => void;
    onRebase?: (branch: string, onto: string) => void;
    onSetUpstream?: (branch: string, upstream: string) => void;
    onPush?: (branch: string, force?: boolean) => void;
    onPull?: (branch: string) => void;
    onCompare?: (branch1: string, branch2: string) => void;
    onProtectionChange?: (branch: string, rule: BranchProtectionRule | null) => void;
}

export declare const NiceGitBlame: default_2.FC<NiceGitBlameProps>;

export declare interface NiceGitBlameProps extends NiceBaseProps {
    /** Blame data for the file */
    file: BlameFile;
    /** How to display blame info */
    viewMode?: BlameViewMode;
    /** Show commit ages as colors */
    showAgeHeatmap?: boolean;
    /** Show author avatars */
    showAvatars?: boolean;
    /** Group consecutive lines from same commit */
    groupHunks?: boolean;
    /** Highlight commit on hover */
    highlightOnHover?: boolean;
    /** Time zone for date formatting */
    timeZone?: string;
    /** Filter by date range */
    dateRange?: {
        from?: Date;
        to?: Date;
    };
    /** Filter by authors */
    authorFilter?: string[];
    /** Selected line */
    selectedLine?: number;
    /** Syntax highlighting theme */
    syntaxTheme?: 'dark' | 'light';
    onLineClick?: (line: BlameLine) => void;
    onCommitClick?: (commit: BlameCommit) => void;
    onAuthorClick?: (author: BlameAuthor) => void;
    onBlameParent?: (commit: BlameCommit) => void;
}

export declare const NiceGitConflictResolver: default_2.FC<NiceGitConflictResolverProps>;

export declare interface NiceGitConflictResolverProps extends NiceBaseProps {
    /** File with conflicts */
    file: ConflictFile;
    /** Merge context information */
    context?: MergeContext;
    /** View mode */
    viewMode?: ConflictViewMode;
    /** Show line numbers */
    showLineNumbers?: boolean;
    /** Show base (ancestor) version */
    showBase?: boolean;
    /** Current focused conflict index */
    currentConflictIndex?: number;
    /** Syntax highlighting theme */
    syntaxTheme?: 'dark' | 'light';
    onResolve?: (conflictId: string, resolution: ConflictRegion['resolution'], content?: string[]) => void;
    onResolveAll?: (resolution: 'ours' | 'theirs') => void;
    onNavigateConflict?: (index: number) => void;
    onSave?: (content: string) => void;
    onCancel?: () => void;
}

export declare const NiceGitDiffViewer: default_2.FC<NiceGitDiffViewerProps>;

export declare interface NiceGitDiffViewerProps extends NiceBaseProps {
    /** Diff files */
    files: DiffFile[];
    /** View mode */
    viewMode?: DiffViewMode;
    /** Show whitespace changes */
    showWhitespace?: boolean;
    /** Comments on the diff */
    comments?: DiffComment[];
    /** Selected file */
    selectedFile?: string;
    /** Show file tree */
    showFileTree?: boolean;
    /** Context lines around changes */
    contextLines?: number;
    /** Base commit/branch for comparison */
    baseRef?: string;
    /** Head commit/branch for comparison */
    headRef?: string;
    onFileSelect?: (path: string) => void;
    onViewModeChange?: (mode: DiffViewMode) => void;
    onAddComment?: (filePath: string, line: number, side: 'old' | 'new', body: string) => void;
    onResolveComment?: (commentId: string) => void;
    onExpandChunk?: (filePath: string, chunkIndex: number) => void;
}

export declare const NiceGitGraph: default_2.FC<NiceGitGraphProps>;

export declare interface NiceGitGraphProps extends NiceBaseProps {
    /** Commits to display (newest first) */
    commits: GitCommit[];
    /** All branches */
    branches: GitBranch[];
    /** All tags */
    tags: GitTag[];
    /** Currently checked out branch/commit */
    head?: string;
    /** Selected commit hash */
    selectedCommit?: string;
    /** Branch filter */
    branchFilter?: string[];
    /** Author filter */
    authorFilter?: string[];
    /** Date range filter */
    dateRange?: {
        from?: Date;
        to?: Date;
    };
    /** Search query */
    searchQuery?: string;
    /** Max commits to show */
    maxCommits?: number;
    /** Show remote branches */
    showRemotes?: boolean;
    /** Show tags */
    showTags?: boolean;
    /** Compact mode */
    compact?: boolean;
    onCommitSelect?: (commit: GitCommit) => void;
    onCommitDoubleClick?: (commit: GitCommit) => void;
    onBranchCheckout?: (branch: string) => void;
    onBranchCreate?: (fromCommit: string) => void;
    onTagCreate?: (commit: string) => void;
    onCherryPick?: (commit: string) => void;
    onRevert?: (commit: string) => void;
    onReset?: (commit: string, mode: 'soft' | 'mixed' | 'hard') => void;
    onCompare?: (commit1: string, commit2: string) => void;
    onViewDiff?: (commit: string) => void;
}

export declare const NiceGitHooks: default_2.FC<NiceGitHooksProps>;

export declare interface NiceGitHooksProps extends NiceBaseProps {
    /** Current hooks configuration */
    hooks: GitHook[];
    /** Available templates */
    templates?: HookTemplate[];
    /** Hook manager type */
    manager?: 'native' | 'husky' | 'lefthook' | 'simple-git-hooks';
    /** Repository path */
    repoPath?: string;
    /** Currently editing hook */
    selectedHook?: GitHookType;
    onHookChange?: (hook: GitHook) => void;
    onHookToggle?: (hookType: GitHookType, enabled: boolean) => void;
    onActionAdd?: (hookType: GitHookType, action: HookAction) => void;
    onActionRemove?: (hookType: GitHookType, actionId: string) => void;
    onActionUpdate?: (hookType: GitHookType, action: HookAction) => void;
    onInstall?: (hookType: GitHookType) => void;
    onUninstall?: (hookType: GitHookType) => void;
    onExport?: (hooks: GitHook[], format: 'shell' | 'husky' | 'lefthook') => void;
}

export declare const NiceMergeRequestBuilder: default_2.FC<NiceMergeRequestBuilderProps>;

export declare interface NiceMergeRequestBuilderProps extends NiceBaseProps {
    /** Available branches */
    branches: Array<{
        name: string;
        isRemote?: boolean;
    }>;
    /** Available users for assignment */
    users?: MergeRequestUser[];
    /** Available labels */
    labels?: MergeRequestLabel[];
    /** Open issues */
    issues?: MergeRequestIssue[];
    /** Description templates */
    templates?: MergeRequestTemplate[];
    /** Diff summary */
    diff?: MergeRequestDiff;
    /** Current branch */
    currentBranch?: string;
    /** Default target branch */
    defaultTargetBranch?: string;
    /** Initial source branch */
    initialSourceBranch?: string;
    /** Platform type */
    platform?: 'github' | 'gitlab' | 'bitbucket' | 'azure';
    onSubmit?: (data: MergeRequestData) => void;
    onCancel?: () => void;
    onBranchChange?: (source: string, target: string) => void;
    onPreview?: (data: MergeRequestData) => void;
}

export declare const NicePipelineEditor: default_2.FC<NicePipelineEditorProps>;

export declare interface NicePipelineEditorProps extends NiceBaseProps {
    pipeline: Pipeline;
    templates: PipelineTemplate[];
    runners: Array<{
        id: string;
        name: string;
        os: string;
        available: boolean;
    }>;
    environments: Array<{
        id: string;
        name: string;
        protection: boolean;
    }>;
    onPipelineChange: (pipeline: Pipeline) => void;
    onStageAdd: () => void;
    onStageRemove: (stageId: string) => void;
    onStageMove: (stageId: string, direction: 'up' | 'down') => void;
    onJobAdd: (stageId: string) => void;
    onJobRemove: (stageId: string, jobId: string) => void;
    onStepAdd: (stageId: string, jobId: string) => void;
    onStepRemove: (stageId: string, jobId: string, stepId: string) => void;
    onVariableAdd: () => void;
    onVariableRemove: (name: string) => void;
    onSecretAdd: () => void;
    onSecretRemove: (name: string) => void;
    onTemplateApply: (template: PipelineTemplate) => void;
    onSave: () => void;
    onRun: () => void;
    onValidate: () => void;
}

export declare const NicePipelineMonitor: default_2.FC<NicePipelineMonitorProps>;

export declare interface NicePipelineMonitorProps extends NiceBaseProps {
    runs: PipelineRun[];
    stats?: PipelineStats;
    selectedRunId?: string;
    onRunSelect: (runId: string) => void;
    onCancel: (runId: string) => void;
    onRerun: (runId: string) => void;
    onRerunFromStage: (runId: string, stageId: string) => void;
    onDownloadArtifact: (artifact: PipelineArtifact) => void;
    onDownloadLogs: (runId: string) => void;
    onApprove?: (runId: string, stageId: string) => void;
    onReject?: (runId: string, stageId: string) => void;
    refreshInterval?: number;
}

declare interface Pipeline {
    id: string;
    name: string;
    description?: string;
    repository: string;
    branch?: string;
    triggers: PipelineTrigger[];
    stages: PipelineStage[];
    variables: PipelineVariable[];
    secrets: PipelineSecret[];
    isEnabled: boolean;
    createdAt: Date;
    updatedAt: Date;
}

declare interface PipelineArtifact {
    id: string;
    name: string;
    size: number;
    jobId: string;
    downloadUrl: string;
    expiresAt?: Date;
}

declare interface PipelineJob {
    id: string;
    name: string;
    runner?: string;
    environment?: string;
    steps: PipelineStep[];
    timeout?: number;
    condition?: string;
    services?: string[];
}

declare interface PipelineRun {
    id: string;
    pipelineId: string;
    pipelineName: string;
    runNumber: number;
    status: RunStatus;
    branch: string;
    commit: {
        sha: string;
        message: string;
        author: string;
        authorAvatar?: string;
    };
    trigger: 'push' | 'pull_request' | 'schedule' | 'manual' | 'api';
    startedAt?: Date;
    completedAt?: Date;
    duration?: number;
    stages: PipelineRunStage[];
    artifacts: PipelineArtifact[];
    environment?: string;
}

declare interface PipelineRunJob {
    id: string;
    name: string;
    status: JobStatus;
    runner?: string;
    startedAt?: Date;
    completedAt?: Date;
    duration?: number;
    steps: PipelineRunStep[];
}

declare interface PipelineRunStage {
    id: string;
    name: string;
    status: JobStatus;
    startedAt?: Date;
    completedAt?: Date;
    duration?: number;
    jobs: PipelineRunJob[];
}

declare interface PipelineRunStep {
    id: string;
    name: string;
    status: JobStatus;
    startedAt?: Date;
    completedAt?: Date;
    duration?: number;
    logs?: string[];
    errorMessage?: string;
}

declare interface PipelineSecret {
    name: string;
    source: 'vault' | 'environment' | 'repository';
    key: string;
}

declare interface PipelineStage {
    id: string;
    name: string;
    jobs: PipelineJob[];
    condition?: string;
    dependsOn?: string[];
    parallel: boolean;
}

declare interface PipelineStats {
    totalRuns: number;
    successRate: number;
    avgDuration: number;
    failedRuns: number;
    runsByDay: {
        date: string;
        success: number;
        failed: number;
    }[];
}

declare interface PipelineStep {
    id: string;
    name: string;
    type: 'script' | 'action' | 'checkout' | 'upload_artifact' | 'download_artifact' | 'docker' | 'deploy';
    script?: string;
    action?: string;
    actionVersion?: string;
    with?: Record<string, string>;
    env?: Record<string, string>;
    condition?: string;
    continueOnError?: boolean;
}

declare interface PipelineTemplate {
    id: string;
    name: string;
    description: string;
    category: string;
    icon: string;
    pipeline: Partial<Pipeline>;
}

declare type PipelineTrigger = 'push' | 'pull_request' | 'schedule' | 'manual' | 'tag' | 'workflow_dispatch';

declare interface PipelineVariable {
    name: string;
    value: string;
    isSecret: boolean;
    scope: 'pipeline' | 'stage' | 'job';
}

declare type RunStatus = 'queued' | 'in_progress' | 'completed' | 'failed' | 'cancelled' | 'waiting' | 'skipped';

export { }
