import { kinds } from "nostr-tools";
import { map } from "rxjs";
import { getCoordinateFromAddressPointer, isAddressPointer } from "../helpers/pointers.js";
import { isValidZap } from "../helpers/zap.js";
/** A model that gets all zap events for an event */
export function EventZapsModel(id) {
    return (events) => {
        if (isAddressPointer(id)) {
            return events
                .timeline([{ kinds: [kinds.Zap], "#a": [getCoordinateFromAddressPointer(id)] }])
                .pipe(map((events) => events.filter(isValidZap)));
        }
        else {
            id = typeof id === "string" ? id : id.id;
            return events.timeline([{ kinds: [kinds.Zap], "#e": [id] }]).pipe(map((events) => events.filter(isValidZap)));
        }
    };
}
/** A model that returns all zaps sent by a user */
export function SentZapsModel(pubkey) {
    return (events) => events.timeline([{ kinds: [kinds.Zap], authors: [pubkey] }]);
}
/** A model that returns all zaps received by a user */
export function ReceivedZapsModel(pubkey) {
    return (events) => events.timeline([{ kinds: [kinds.Zap], "#a": [pubkey] }]);
}
