import EdgeRecord from "./EdgeRecord.js";
import LegacyEdgePropertyKey from "./LegacyEdgePropertyKey.js";
import LegacyPropertyValue from "./LegacyPropertyValue.js";
import WarpError from "../errors/WarpError.js";
/** Runtime-backed visible legacy property record owned by an edge. */
export default class VisibleEdgePropertyRecord {
    owner;
    key;
    value;
    constructor(fields) {
        const checkedFields = requireFields(fields);
        this.owner = requireOwner(checkedFields.owner);
        this.key = requireKey(checkedFields.key);
        this.value = requireValue(checkedFields.value);
        Object.freeze(this);
    }
}
/** Validates the edge property record constructor envelope. */
function requireFields(fields) {
    if (fields === null || fields === undefined) {
        throw new WarpError('VisibleEdgePropertyRecord fields must be provided', 'E_VALIDATION');
    }
    return fields;
}
/** Requires a runtime-backed edge owner. */
function requireOwner(owner) {
    if (!(owner instanceof EdgeRecord)) {
        throw new WarpError('VisibleEdgePropertyRecord owner must be an EdgeRecord', 'E_VALIDATION');
    }
    return owner;
}
/** Requires a runtime-backed edge property key. */
function requireKey(key) {
    if (!(key instanceof LegacyEdgePropertyKey)) {
        throw new WarpError('VisibleEdgePropertyRecord key must be a LegacyEdgePropertyKey', 'E_VALIDATION');
    }
    return key;
}
/** Requires a runtime-backed property value. */
function requireValue(value) {
    if (!(value instanceof LegacyPropertyValue)) {
        throw new WarpError('VisibleEdgePropertyRecord value must be a LegacyPropertyValue', 'E_VALIDATION');
    }
    return value;
}
