import { LegacyMessageBlueprint, LegacyMessageReplyBlueprint, } from "applesauce-factory/blueprints";
import { kinds } from "nostr-tools";
/** Sends a legacy NIP-04 message to a recipient */
export function SendLegacyMessage(recipient, message, opts) {
    return async function* ({ factory }) {
        const draft = await factory.create(LegacyMessageBlueprint, recipient, message, opts);
        // Return the signed message
        yield await factory.sign(draft);
    };
}
/** Send a reply to a legacy message */
export function ReplyToLegacyMessage(parent, message, opts) {
    return async function* ({ factory }) {
        if (parent.kind !== kinds.EncryptedDirectMessage)
            throw new Error("Legacy messages can only reply to other legacy messages");
        const draft = await factory.create(LegacyMessageReplyBlueprint, parent, message, opts);
        // Return the signed message
        yield await factory.sign(draft);
    };
}
