import ContinuumFamilyId from "./ContinuumFamilyId.js";
import ContinuumGeneratedFamilyStatus from "./ContinuumGeneratedFamilyStatus.js";
import WarpError from "../errors/WarpError.js";
/** One current Continuum-family readiness row for git-warp planning. */
export default class ContinuumGeneratedFamilyInventoryEntry {
    familyId;
    version;
    authoredSchemaPath;
    status;
    gitWarpSourceFacts;
    warpTtdConsumerNeed;
    openCut;
    constructor(fields) {
        const checkedFields = requireFields(fields);
        this.familyId = normalizeFamilyId(checkedFields.familyId);
        this.version = requireNonEmptyString(checkedFields.version, 'version');
        this.authoredSchemaPath = requireNonEmptyString(checkedFields.authoredSchemaPath, 'authoredSchemaPath');
        this.status = normalizeStatus(checkedFields.status);
        this.gitWarpSourceFacts = requireNonEmptyString(checkedFields.gitWarpSourceFacts, 'gitWarpSourceFacts');
        this.warpTtdConsumerNeed = requireNonEmptyString(checkedFields.warpTtdConsumerNeed, 'warpTtdConsumerNeed');
        this.openCut = requireNonEmptyString(checkedFields.openCut, 'openCut');
        Object.freeze(this);
    }
    /** Returns true when this row is safe for generated-family projection work. */
    isProjectionReady() {
        return this.status.isProjectionReady();
    }
}
/** Validates the entry constructor envelope. */
function requireFields(value) {
    if (value === null || value === undefined) {
        throw new WarpError('ContinuumGeneratedFamilyInventoryEntry fields must be provided', 'E_VALIDATION');
    }
    return value;
}
/** Normalizes a family id carrier. */
function normalizeFamilyId(value) {
    if (value instanceof ContinuumFamilyId) {
        return value;
    }
    return new ContinuumFamilyId(value);
}
/** Normalizes a generated-family status carrier. */
function normalizeStatus(value) {
    if (value instanceof ContinuumGeneratedFamilyStatus) {
        return value;
    }
    return new ContinuumGeneratedFamilyStatus(value);
}
/** Validates a required non-empty string. */
function requireNonEmptyString(value, name) {
    if (typeof value !== 'string' || value.trim().length === 0) {
        throw new WarpError(`${name} must be a non-empty string`, 'E_VALIDATION');
    }
    return value;
}
