/**
 * Local-First Data Infrastructure for rSpace
 *
 * 7-layer architecture:
 *   1. Crypto    — PRF key derivation, AES-256-GCM per-document encryption
 *   2. Document  — Automerge documents with typed schemas
 *   3. Storage   — Encrypted multi-document IndexedDB
 *   4. Sync      — Multi-doc WebSocket sync (client-side)
 *   5. Compute   — Deterministic transforms (local or server-delegated)
 *   6. Query     — Materialized views + full-text search
 *   7. Application (module-specific, not in this package)
 *
 * Plus: Memory Card interchange format for cross-module data exchange.
 */

// Layer 1: Crypto
export { DocCrypto, type EncryptedBlob } from './crypto';

// Layer 2: Document
export {
  type DocumentId,
  type ParsedDocumentId,
  type DocSchema,
  type DocMeta,
  parseDocumentId,
  makeDocumentId,
  DocumentManager,
} from './document';

// Layer 3: Storage
export { EncryptedDocStore } from './storage';

// Layer 4: Sync (client)
export {
  DocSyncManager,
  type DocSyncManagerOptions,
  type SyncMessage,
  type SubscribeMessage,
  type UnsubscribeMessage,
  type AwarenessMessage,
  type RelayBackupMessage,
  type RelayRestoreMessage,
  type WireMessage,
} from './sync';

// Runtime (singleton coordinator for offline-first)
export {
  RSpaceOfflineRuntime,
  type RuntimeStatus,
  type StatusCallback,
} from './runtime';

// Storage Quota
export {
  getStorageInfo,
  requestPersistentStorage,
  evictStaleDocs,
  isQuotaWarning,
  QUOTA_WARNING_PERCENT,
  type StorageInfo,
} from './storage-quota';

// Backup
export {
  BackupSyncManager,
  type BackupResult,
  type RestoreResult,
  type BackupStatus,
} from './backup';

// Layer 5: Compute
export {
  type Transform,
  ComputeEngine,
  type ComputeEngineOptions,
  localTransform,
  serverTransform,
} from './compute';

// Layer 6: Query
export {
  type MaterializedView,
  type SearchResult,
  ViewEngine,
  LocalSearchEngine,
} from './query';

// Memory Card interchange
export {
  type MemoryCard,
  type MemoryCardType,
  type CardExporter,
  createCard,
  filterByType,
  filterByTag,
  filterByModule,
  sortByNewest,
  searchCards,
  registerExporter,
  getExporter,
  getAllExporters,
} from './memory-card';
