
//#region src/internal/test-fixtures.ts
/**
* Test fixture factories for creating Event objects with minimal boilerplate.
* These factories provide sensible defaults while allowing customization.
*/
function createFrame(overrides = {}) {
	return {
		filename: "/app/main.js",
		function: "main",
		lineNo: 42,
		...overrides
	};
}
const frameFactories = {
	python: (overrides = {}) => createFrame({
		filename: "/app/main.py",
		function: "process_data",
		...overrides
	}),
	java: (overrides = {}) => createFrame({
		filename: "Example.java",
		module: "com.example.Example",
		function: "doSomething",
		...overrides
	}),
	javascript: (overrides = {}) => createFrame({
		filename: "/app/main.js",
		function: "handleRequest",
		colNo: 15,
		...overrides
	}),
	ruby: (overrides = {}) => createFrame({
		filename: "/app/main.rb",
		function: "process",
		...overrides
	}),
	php: (overrides = {}) => createFrame({
		filename: "/app/main.php",
		function: "handleRequest",
		...overrides
	})
};
function createStackTrace(frames) {
	return { frames };
}
function createExceptionValue(overrides = {}) {
	return {
		type: "Error",
		value: "Something went wrong",
		stacktrace: createStackTrace([createFrame()]),
		...overrides
	};
}
function createThread(overrides = {}) {
	return {
		id: 1,
		name: "main",
		crashed: true,
		stacktrace: createStackTrace([createFrame()]),
		...overrides
	};
}
var EventBuilder = class {
	event;
	constructor(platform = "javascript") {
		this.event = {
			id: "test123",
			title: "Test Event",
			message: null,
			platform,
			type: "error",
			entries: [],
			contexts: {},
			culprit: null,
			dateCreated: (/* @__PURE__ */ new Date()).toISOString()
		};
	}
	withId(id) {
		this.event.id = id;
		return this;
	}
	withPlatform(platform) {
		this.event.platform = platform;
		return this;
	}
	withException(exception) {
		this.event.entries.push({
			type: "exception",
			data: { values: [exception] }
		});
		return this;
	}
	withChainedExceptions(exceptions) {
		this.event.entries.push({
			type: "exception",
			data: { values: exceptions }
		});
		return this;
	}
	withThread(thread) {
		const existingThread = this.event.entries.find((e) => e.type === "threads");
		if (existingThread?.data && typeof existingThread.data === "object" && "values" in existingThread.data && Array.isArray(existingThread.data.values)) existingThread.data.values.push(thread);
		else this.event.entries.push({
			type: "threads",
			data: { values: [thread] }
		});
		return this;
	}
	withMessage(message) {
		this.event.entries.push({
			type: "message",
			data: { formatted: message }
		});
		return this;
	}
	withTitle(title) {
		this.event.title = title;
		return this;
	}
	withType(type) {
		this.event.type = type;
		return this;
	}
	withContexts(contexts) {
		this.event.contexts = contexts;
		return this;
	}
	withOccurrence(occurrence) {
		this.event.occurrence = occurrence;
		return this;
	}
	withEntry(entry) {
		this.event.entries.push(entry);
		return this;
	}
	build() {
		return { ...this.event };
	}
};
const testEvents = {
	pythonException: (errorMessage = "Invalid value") => new EventBuilder("python").withException(createExceptionValue({
		type: "ValueError",
		value: errorMessage,
		stacktrace: createStackTrace([frameFactories.python({ lineNo: 42 }), frameFactories.python({
			filename: "/app/utils.py",
			function: "validate",
			lineNo: 15
		})])
	})).build(),
	javaThreadError: (message = "Test error") => new EventBuilder("java").withTitle("Test Error").withType("error").withMessage(message).withThread(createThread({
		id: 187,
		name: "CONTRACT_WORKER",
		state: "RUNNABLE",
		stacktrace: createStackTrace([frameFactories.java({
			filename: "Thread.java",
			module: "java.lang.Thread",
			function: "run",
			lineNo: 833
		}), frameFactories.java({
			filename: "AeronServer.java",
			module: "com.citics.eqd.mq.aeron.AeronServer",
			function: "lambda$start$3",
			lineNo: 110
		})])
	})).build(),
	enhancedFrame: (platform = "python") => {
		const frame = frameFactories[platform]({
			inApp: true,
			context: [
				[40, "    raise ValueError(\"User not found\")"],
				[41, "    "],
				[42, "    balance = user.account.balance"],
				[43, "    if balance < amount:"],
				[44, "        raise InsufficientFundsError()"]
			],
			vars: {
				amount: 150,
				user_id: "usr_123456",
				user: null
			}
		});
		return new EventBuilder(platform).withException(createExceptionValue({
			type: "ValueError",
			value: "Something went wrong",
			stacktrace: createStackTrace([frame])
		})).build();
	}
};
function createFrameWithContext(frame, contextLines, vars) {
	return createFrame({
		...frame,
		inApp: true,
		context: contextLines,
		vars
	});
}
const advancedFixtures = {
	minimalError: (message, platform = "javascript") => new EventBuilder(platform).withException(createExceptionValue({ value: message })).build(),
	chainedExceptions: (platform = "javascript") => new EventBuilder(platform).withException(createExceptionValue({
		type: "Error",
		value: "High level error",
		stacktrace: createStackTrace([createFrame({ lineNo: 100 })])
	})).withException(createExceptionValue({
		type: "CausedBy",
		value: "Low level error",
		stacktrace: createStackTrace([createFrame({ lineNo: 50 })])
	})).build(),
	withContextData: (contexts) => {
		return new EventBuilder().withContexts(contexts).build();
	}
};

//#endregion
exports.EventBuilder = EventBuilder;
exports.advancedFixtures = advancedFixtures;
exports.createExceptionValue = createExceptionValue;
exports.createFrame = createFrame;
exports.createFrameWithContext = createFrameWithContext;
exports.createStackTrace = createStackTrace;
exports.createThread = createThread;
exports.frameFactories = frameFactories;
exports.testEvents = testEvents;
//# sourceMappingURL=test-fixtures.cjs.map