import type NDK from "@nostr-dev-kit/ndk";
import { type Hexpubkey, type NDKCacheAdapter, type NDKCacheEntry, NDKEvent, type NDKEventId, type NDKFilter, type NDKNutzapState, type NDKRelay, type NDKSubscription, type NDKUserProfile } from "@nostr-dev-kit/ndk";
import * as SQLite from "expo-sqlite";
export type NDKSqliteEventRecord = {
    id: string;
    created_at: number;
    pubkey: string;
    event: string;
    kind: number;
    relay: string;
};
export type NDKSqliteProfileRecord = {
    pubkey: string;
    name: string;
    about: string;
    picture: string;
    banner: string;
    nip05: string;
    lud16: string;
    lud06: string;
    display_name: string;
    website: string;
    catched_at: number;
    created_at: number;
};
export declare class NDKCacheAdapterSqlite implements NDKCacheAdapter {
    readonly dbName: string;
    db: SQLite.SQLiteDatabase;
    ndk?: NDK;
    locking: boolean;
    private unpublishedEventIds;
    /**
     * This tracks the events we have written to the database along with their timestamp.
     */
    private knownEventTimestamps;
    private writeBuffer;
    private bufferFlushTimeout;
    private bufferFlushTimer;
    getMintInfo: any;
    getMintInfoRecord: any;
    getAllMintInfo: any;
    setMintInfo: any;
    getMintKeys: any;
    getMintKeyset: any;
    getMintKeysetRecord: any;
    getAllMintKeysets: any;
    setMintKeys: any;
    getAllProfilesSync: any;
    getAllNutzapStates: any;
    constructor(dbName: string, ndkInstance?: NDK);
    /**
     * Initialize the cache adapter.
     *
     * This should be called before using it.
     */
    initialize(): void;
    /**
     * Runs the function only if the cache adapter is ready, if it's not ready,
     * it ignores the function.
     */
    query(subscription: NDKSubscription): NDKEvent[];
    private flushWriteBuffer;
    private bufferWrite;
    setEvent(event: NDKEvent, _filters: NDKFilter[], relay?: NDKRelay): Promise<void>;
    deleteEventIds(eventIds: NDKEventId[]): Promise<void>;
    fetchProfileSync(pubkey: Hexpubkey): NDKCacheEntry<NDKUserProfile> | null;
    fetchProfile(pubkey: Hexpubkey): Promise<NDKCacheEntry<NDKUserProfile> | null>;
    saveProfile(pubkey: Hexpubkey, profile: NDKUserProfile): Promise<void>;
    private _unpublishedEvents;
    private _addUnpublishedEvent;
    addUnpublishedEvent(event: NDKEvent, relayUrls: WebSocket["url"][]): void;
    getUnpublishedEvents(): Promise<{
        event: NDKEvent;
        relays?: WebSocket["url"][];
        lastTryAt?: number;
    }[]>;
    /**
     * This loads the unpublished events from the database into _unpublishedEvents.
     *
     * This should be called during initialization.
     */
    private loadUnpublishedEventsSync;
    discardUnpublishedEvent(eventId: NDKEventId): void;
    saveWot(wot: Map<Hexpubkey, number>): Promise<void>;
    fetchWot(): Promise<Map<Hexpubkey, number>>;
    clear(): Promise<void>;
    /**
     * Get an event from the database by ID.
     *
     * @param id - The ID of the event to get.
     * @returns The event, or null if it doesn't exist.
     */
    getEventId(id: NDKEventId): NDKEvent | null;
    /**
     * This function runs a query and returns parsed events.
     * @param query The query to run.
     * @param params The parameters to pass to the query.
     * @param filterFn An optional filter function to filter events before deserializing them.
     * @returns
     */
    getEvents(query: string, params: any[], filterFn?: (record: NDKSqliteEventRecord) => boolean): NDKEvent[];
    /**
     * Get a decrypted event from the database by ID.
     *
     * @param eventId - The ID of the decrypted event to get.
     * @returns The decrypted event, or null if it doesn't exist.
     */
    getDecryptedEvent(eventId: NDKEventId): NDKEvent | null;
    /**
     * Store a decrypted event in the database.
     *
     * @param event - The decrypted event to store.
     */
    addDecryptedEvent(event: NDKEvent): void;
    /**
     * Get the current timestamp in seconds
     * @returns Current timestamp in seconds
     */
    private nowSeconds;
    /**
     * Get the timestamp when a profile was last cached
     * @param pubkey - The public key of the user
     * @returns Timestamp in seconds when the profile was cached, or null if not found
     */
    getProfileCacheTimestamp(pubkey: Hexpubkey): number | null;
    /**
     * Update the cache timestamp for a profile
     * Used when checking for updates but not finding anything newer
     * @param pubkey - The user's public key
     */
    updateProfileCacheTimestamp(pubkey: Hexpubkey): void;
    /**
     * Sets the state of a nutzap in the cache.
     * This method prepares the update using prepareNutzapStateUpdate and then buffers the write.
     * @param id The ID of the nutzap event.
     * @param stateChange The partial state change to apply.
     */
    setNutzapState(id: NDKEventId, stateChange: Partial<NDKNutzapState>): Promise<void>;
}
export declare function foundEvents(subscription: NDKSubscription, records: NDKSqliteEventRecord[], filter?: NDKFilter): NDKEvent[];
export declare function foundEvent(subscription: NDKSubscription, event: NDKSqliteEventRecord, relayUrl: WebSocket["url"] | undefined, filter?: NDKFilter): NDKEvent | null;
//# sourceMappingURL=index.d.ts.map