import ProvenancePayload from "../services/provenance/ProvenancePayload.js";
import WarpError from "../errors/WarpError.js";
/** One replay-sufficient strand interval inside a braid hologram. */
export default class GitWarpBraidHologramMember {
    strandId;
    payload;
    constructor(fields) {
        const checkedFields = requireFields(fields);
        this.strandId = requireNonEmptyString(checkedFields.strandId, 'strandId');
        this.payload = requirePayload(checkedFields.payload);
        if (this.payload.length === 0) {
            throw new WarpError('braid hologram member payload must not be empty', 'E_VALIDATION');
        }
        Object.freeze(this);
    }
}
function requireFields(value) {
    if (value === null || value === undefined) {
        throw new WarpError('GitWarpBraidHologramMember fields must be provided', 'E_VALIDATION');
    }
    return value;
}
function requirePayload(value) {
    if (!(value instanceof ProvenancePayload)) {
        throw new WarpError('payload must be a ProvenancePayload', 'E_VALIDATION');
    }
    return value;
}
function requireNonEmptyString(value, name) {
    if (typeof value !== 'string' || value.length === 0) {
        throw new WarpError(`${name} must be a non-empty string`, 'E_VALIDATION');
    }
    return value;
}
