function deepMerge(target, source) {
    const result = { ...target };
    for (const key in source) {
        const sourceValue = source[key];
        const targetValue = target[key];
        if (sourceValue !== undefined &&
            typeof sourceValue === 'object' &&
            sourceValue !== null &&
            !Array.isArray(sourceValue) &&
            typeof targetValue === 'object' &&
            targetValue !== null &&
            !Array.isArray(targetValue)) {
            result[key] = deepMerge(targetValue, sourceValue);
        }
        else if (sourceValue !== undefined) {
            result[key] = sourceValue;
        }
    }
    return result;
}
export class GitLabEventFactory {
    static createMergeRequestEvent(overrides) {
        const base = {
            object_kind: 'merge_request',
            event_type: 'merge_request',
            user: {
                username: 'developer',
                name: 'Dev User',
            },
            project: {
                id: 1,
                name: 'test-project',
                path_with_namespace: 'test-org/test-project',
                web_url: 'https://gitlab.com/test-org/test-project',
                git_http_url: 'https://gitlab.com/test-org/test-project.git',
            },
            object_attributes: {
                iid: 42,
                title: 'Test MR',
                description: 'Test description',
                state: 'opened',
                action: 'open',
                source_branch: 'feature/test',
                target_branch: 'main',
                url: 'https://gitlab.com/test-org/test-project/-/merge_requests/42',
                draft: false,
            },
            reviewers: [],
            assignees: [],
        };
        return overrides ? deepMerge(base, overrides) : base;
    }
    static createWithAssignee(assigneeUsername, assigneeName = 'MR Assignee') {
        return this.createMergeRequestEvent({
            assignees: [{ username: assigneeUsername, name: assigneeName }],
        });
    }
    static createWithReviewerAdded(reviewerUsername) {
        return this.createMergeRequestEvent({
            object_attributes: {
                action: 'update',
            },
            reviewers: [{ username: reviewerUsername, name: 'Claude Reviewer' }],
            changes: {
                reviewers: {
                    previous: [],
                    current: [{ username: reviewerUsername }],
                },
            },
        });
    }
    static createDraftMr() {
        return this.createMergeRequestEvent({
            object_attributes: {
                draft: true,
            },
        });
    }
    static createClosedMr() {
        return this.createMergeRequestEvent({
            object_attributes: {
                state: 'closed',
                action: 'close',
            },
        });
    }
    static createMergedMr() {
        return this.createMergeRequestEvent({
            object_attributes: {
                state: 'merged',
                action: 'merge',
            },
        });
    }
    static createApprovedMr() {
        return this.createMergeRequestEvent({
            object_attributes: {
                state: 'opened',
                action: 'approved',
            },
        });
    }
    static createMrUpdate() {
        return this.createMergeRequestEvent({
            object_attributes: {
                action: 'update',
            },
        });
    }
    static createPushEvent(overrides) {
        const base = {
            object_kind: 'push',
            ref: 'refs/heads/feature/test',
            project: {
                id: 1,
                path_with_namespace: 'test-org/test-project',
                web_url: 'https://gitlab.com/test-org/test-project',
            },
            commits: [
                {
                    id: 'abc123',
                    message: 'Test commit',
                },
            ],
        };
        return overrides ? deepMerge(base, overrides) : base;
    }
}
//# sourceMappingURL=gitLabEvent.factory.js.map