import computeShardKey from "../../utils/shardKey.js";
import { CheckpointBasisFact } from "./CheckpointBasisFactBase.js";
import { eventSortKey, eventTransport, validateEventId, validateText, } from "./CheckpointBasisFactValidation.js";
export class CheckpointContentAnchorFact extends CheckpointBasisFact {
    kind = 'content-anchor';
    owner;
    contentOid;
    retainedPayloadByteHash;
    eventId;
    constructor(options) {
        super();
        this.owner = validateText(options.owner, 'owner');
        this.contentOid = validateText(options.contentOid, 'contentOid');
        this.retainedPayloadByteHash = options.retainedPayloadByteHash === undefined
            || options.retainedPayloadByteHash === null
            ? null
            : validateText(options.retainedPayloadByteHash, 'retainedPayloadByteHash');
        this.eventId = validateEventId(options.eventId);
        Object.freeze(this);
    }
    shardFamily() {
        return 'content-anchor';
    }
    shardPath() {
        return `content_${computeShardKey(this.owner)}.cbor`;
    }
    sortKey() {
        return `${this.owner}:${this.contentOid}:${eventSortKey(this.eventId)}`;
    }
    toTransport() {
        return {
            kind: this.kind,
            owner: this.owner,
            contentOid: this.contentOid,
            retainedPayloadByteHash: this.retainedPayloadByteHash,
            eventId: eventTransport(this.eventId),
        };
    }
}
