"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VisualComparison = void 0; const AggregateRoot_1 = require("../../../../shared/domain/AggregateRoot"); const UniqueId_1 = require("../../../../shared/domain/UniqueId"); const ComparisonStatus_1 = require("../value-objects/ComparisonStatus"); const BaselineApproved_1 = require("../events/BaselineApproved"); const RegressionDetected_1 = require("../events/RegressionDetected"); class VisualComparison extends AggregateRoot_1.AggregateRoot { static create(props, id) { const comparison = new VisualComparison({ ...props, createdAt: new Date() }, id ?? UniqueId_1.UniqueId.create()); if (props.status.isFailed()) { comparison.addDomainEvent(new RegressionDetected_1.RegressionDetected(comparison.id.toString(), { sessionId: props.sessionId, stateId: props.stateId, diffPercent: props.diffPercent ?? 0, })); } return comparison; } static reconstitute(props, id) { return new VisualComparison(props, id); } get sessionId() { return this.props.sessionId; } get stateId() { return this.props.stateId; } get baselineId() { return this.props.baselineId; } get currentScreenshotPath() { return this.props.currentScreenshotPath; } get diffScreenshotPath() { return this.props.diffScreenshotPath; } get diffPixels() { return this.props.diffPixels; } get diffPercent() { return this.props.diffPercent; } get status() { return this.props.status; } get createdAt() { return this.props.createdAt; } approve(newBaselineId) { this.props.status = ComparisonStatus_1.ComparisonStatus.passed(); this.props.baselineId = newBaselineId; this.addDomainEvent(new BaselineApproved_1.BaselineApproved(this.id.toString(), { sessionId: this.props.sessionId, stateId: this.props.stateId, baselineId: newBaselineId, })); } reject() { this.props.status = ComparisonStatus_1.ComparisonStatus.failed(); } } exports.VisualComparison = VisualComparison;