import { i as FileLockOptions } from "./file-lock-DARYL8wV.js";

//#region src/plugin-sdk/persistent-dedupe.d.ts
type PersistentDedupeOptions = {
  /** Milliseconds a recorded key remains recent; `0` keeps keys until cache pruning. */ttlMs: number; /** Maximum process-local cache entries used before consulting disk. */
  memoryMaxSize: number; /** Maximum persisted entries retained per namespace file. */
  fileMaxEntries: number; /** Maps a namespace to the JSON file that stores its persisted dedupe timestamps. */
  resolveFilePath: (namespace: string) => string;
  lockOptions?: Partial<FileLockOptions>;
  onDiskError?: (error: unknown) => void;
};
type PersistentDedupeCheckOptions = {
  /** Logical bucket for the key; omitted/blank values use `global`. */namespace?: string; /** Test or replay timestamp override used for TTL checks and writes. */
  now?: number; /** Per-call disk error hook, overriding the helper-level hook. */
  onDiskError?: (error: unknown) => void;
};
type PersistentDedupe = {
  /** Returns true only when the key was not recently seen and was recorded for future checks. */checkAndRecord: (key: string, options?: PersistentDedupeCheckOptions) => Promise<boolean>; /** Checks memory/disk recency without recording a new timestamp. */
  hasRecent: (key: string, options?: PersistentDedupeCheckOptions) => Promise<boolean>; /** Loads recent disk entries into memory for one namespace and returns the loaded count. */
  warmup: (namespace?: string, onError?: (error: unknown) => void) => Promise<number>; /** Clears only process-local memory; persisted namespace files are left intact. */
  clearMemory: () => void; /** Returns the current process-local cache size. */
  memorySize: () => number;
};
type ClaimableDedupeClaimResult = {
  kind: "claimed";
} | {
  kind: "duplicate";
} | {
  kind: "inflight";
  pending: Promise<boolean>;
};
type ClaimableDedupeOptions = {
  ttlMs: number;
  memoryMaxSize: number;
  resolveFilePath: (namespace: string) => string;
  fileMaxEntries: number;
  lockOptions?: Partial<FileLockOptions>;
  onDiskError?: (error: unknown) => void;
} | {
  ttlMs: number;
  memoryMaxSize: number;
  resolveFilePath?: undefined;
  fileMaxEntries?: undefined;
  lockOptions?: undefined;
  onDiskError?: undefined;
};
type ClaimableDedupe = {
  /** Starts ownership of a key, reports duplicates, or returns the active claim's pending result. */claim: (key: string, options?: PersistentDedupeCheckOptions) => Promise<ClaimableDedupeClaimResult>; /** Records a claimed key as handled and resolves any waiters with the recorded result. */
  commit: (key: string, options?: PersistentDedupeCheckOptions) => Promise<boolean>; /** Releases an active claim without recording it, rejecting waiters with the supplied error. */
  release: (key: string, options?: {
    namespace?: string;
    error?: unknown;
  }) => void; /** Checks whether the key is recent without claiming or committing it. */
  hasRecent: (key: string, options?: PersistentDedupeCheckOptions) => Promise<boolean>; /** Warms persistent storage into memory when configured; memory-only guards return zero. */
  warmup: (namespace?: string, onError?: (error: unknown) => void) => Promise<number>; /** Clears process-local caches and in-memory persistent state. */
  clearMemory: () => void; /** Returns the current process-local cache size. */
  memorySize: () => number;
};
/** Create a dedupe helper that combines in-memory fast checks with a lock-protected disk store. */
declare function createPersistentDedupe(options: PersistentDedupeOptions): PersistentDedupe;
/** Create a claim/commit/release dedupe guard backed by memory and optional persistent storage. */
declare function createClaimableDedupe(options: ClaimableDedupeOptions): ClaimableDedupe;
//#endregion
export { ClaimableDedupe, ClaimableDedupeClaimResult, ClaimableDedupeOptions, PersistentDedupe, PersistentDedupeCheckOptions, PersistentDedupeOptions, createClaimableDedupe, createPersistentDedupe };