{"version":3,"file":"index.cjs","sources":["../src/types.ts","../src/storage/idb.ts","../src/utils.ts","../src/adapters/fs-access.ts","../src/adapters/picker-idb.ts","../src/adapters/tauri.ts","../src/adapters/capacitor.ts","../src/index.ts"],"sourcesContent":["export type OneFSErrorCode =\n  | 'cancelled'\n  | 'permission_denied'\n  | 'not_supported'\n  | 'not_found'\n  | 'io_error'\n  | 'unknown'\n\nexport interface OneFSError {\n  code: OneFSErrorCode\n  message: string\n  cause?: unknown\n}\n\nexport type OneFSResult<T> =\n  | { ok: true; data: T }\n  | { ok: false; error: OneFSError }\n\n/**\n * Create a successful result.\n */\nexport function ok<T>(data: T): OneFSResult<T> {\n  return { ok: true, data }\n}\n\n/**\n * Create an error result.\n */\nexport function err<T>(code: OneFSErrorCode, message: string, cause?: unknown): OneFSResult<T> {\n  return { ok: false, error: { code, message, cause } }\n}\n\n/**\n * Represents a file with its content loaded into memory.\n * Content is always a Uint8Array - use OneFS helper methods to convert:\n * - `readAsText(file)` for UTF-8 string\n * - `readAsJSON(file)` for parsed JSON\n * - `readAsBlob(file)` for Blob\n */\nexport interface OneFSFile {\n  /** Unique identifier for this file instance */\n  id: string\n  /** File name (e.g., \"document.txt\") */\n  name: string\n  /** Full filesystem path (Tauri/Capacitor only, undefined on web) */\n  path?: string\n  /** File content as bytes - use readAsText() for string conversion */\n  content: Uint8Array\n  /** MIME type (e.g., \"text/plain\", \"application/json\") */\n  mimeType: string\n  /** File size in bytes */\n  size: number\n  /** Last modified timestamp (milliseconds since epoch) */\n  lastModified: number\n  /** Native file handle (web-fs-access only) - enables in-place saving */\n  handle?: FileSystemFileHandle\n}\n\n/**\n * Represents a directory entry without loaded content.\n * Use `readFileFromDirectory()` to load a specific file's content.\n */\nexport interface OneFSEntry {\n  /** Entry name (e.g., \"document.txt\" or \"subfolder\") */\n  name: string\n  /** Whether this is a file or directory */\n  kind: 'file' | 'directory'\n  /** File size in bytes (files only) */\n  size?: number\n  /** Last modified timestamp (files only) */\n  lastModified?: number\n  /** Full filesystem path (Tauri/Capacitor only) */\n  path?: string\n  /** Native handle (web-fs-access only) */\n  handle?: FileSystemHandle\n}\n\nexport interface OneFSOpenOptions {\n  /** File extensions to accept (e.g., ['.json', '.txt']) */\n  accept?: string[]\n  /** Allow selecting multiple files */\n  multiple?: boolean\n  /** Starting directory for the picker */\n  startIn?: 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos'\n  /** Whether to persist file/handle for later restoration (default: true) */\n  persist?: boolean\n}\n\nexport interface OneFSSaveOptions {\n  /** Suggested file name for the save dialog */\n  suggestedName?: string\n  /** File extensions to accept */\n  accept?: string[]\n  /** Starting directory for the picker */\n  startIn?: 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos'\n  /** Whether to persist file/handle for later restoration (default: true) */\n  persist?: boolean\n}\n\nexport interface OneFSDirectoryOptions {\n  /** Starting directory for the picker */\n  startIn?: 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos'\n  /** Access mode - 'readwrite' enables saving files to the directory */\n  mode?: 'read' | 'readwrite'\n  /** Whether to persist directory handle for later restoration (default: true) */\n  persist?: boolean\n}\n\nexport interface OneFSReadDirectoryOptions {\n  /** Skip stat() calls for faster scanning (size/lastModified will be undefined) */\n  skipStats?: boolean\n  /** Callback for errors encountered while reading entries (e.g. stat failures) */\n  onError?: (path: string, error: unknown) => void\n}\n\nexport interface OneFSScanOptions extends OneFSReadDirectoryOptions {\n  /** File extensions to include (e.g., ['.mp3', '.flac']). If not set, all files are included. */\n  extensions?: string[]\n  /** Callback for progress updates during recursive scan */\n  onProgress?: (scanned: number, found: number) => void\n  /** AbortSignal for cancellation support */\n  signal?: AbortSignal\n}\n\nexport type PermissionMode = 'read' | 'readwrite'\nexport type PermissionStatus = 'granted' | 'denied' | 'prompt'\n\n/**\n * Represents a directory reference.\n */\nexport interface OneFSDirectory {\n  /** Unique identifier for this directory instance */\n  id: string\n  /** Directory name */\n  name: string\n  /** Full filesystem path (Tauri/Capacitor only) */\n  path?: string\n  /** Native directory handle (web-fs-access only) */\n  handle?: FileSystemDirectoryHandle\n}\n\n/**\n * Metadata for a stored file or directory handle.\n * Used by getRecentFiles() to list previously opened items.\n */\nexport interface StoredHandle {\n  id: string\n  name: string\n  /** Full path (Tauri only) */\n  path?: string\n  type: 'file' | 'directory'\n  storedAt: number\n}\n\n/**\n * Internal storage format for file content in IndexedDB.\n */\nexport interface StoredFile {\n  id: string\n  name: string\n  path?: string\n  content: Uint8Array\n  mimeType: string\n  size: number\n  lastModified: number\n  storedAt: number\n}\n\nexport type Platform = 'web-fs-access' | 'web-fallback' | 'tauri' | 'capacitor'\n\n/**\n * Describes what operations are available on the current platform.\n */\nexport interface OneFSCapabilities {\n  /** Can open files via picker */\n  openFile: boolean\n  /** Can save to an existing file (in-place for fs-access/tauri, download for fallback) */\n  saveFile: boolean\n  /** Can save as a new file */\n  saveFileAs: boolean\n  /** Can open directory picker (false, true, or 'limited' for Capacitor) */\n  openDirectory: boolean | 'limited'\n  /** Can list directory contents */\n  readDirectory: boolean | 'limited'\n  /** Can persist and restore file handles across sessions (web-fs-access only) */\n  handlePersistence: boolean\n  /**\n   * Can save to the original file location without download.\n   * - true: web-fs-access (with handle), tauri (with path)\n   * - false: web-fallback (triggers download), capacitor (saves to app directory)\n   */\n  canSaveInPlace: boolean\n  /** Can check and request permissions on files/directories (web-fs-access only) */\n  permissions: boolean\n  /** Can delete files (web-fs-access, Tauri, Capacitor) */\n  deleteFile: boolean\n  /** Can rename files (web-fs-access, Tauri, Capacitor) */\n  renameFile: boolean\n}\n\nexport const PLATFORM_CAPABILITIES: Record<Platform, OneFSCapabilities> = {\n  'web-fs-access': {\n    openFile: true,\n    saveFile: true,\n    saveFileAs: true,\n    openDirectory: true,\n    readDirectory: true,\n    handlePersistence: true,\n    canSaveInPlace: true,\n    permissions: true,\n    deleteFile: true,\n    renameFile: true,\n  },\n  'web-fallback': {\n    openFile: true,\n    saveFile: true,\n    saveFileAs: true,\n    openDirectory: false,\n    readDirectory: false,\n    handlePersistence: false,\n    canSaveInPlace: false,\n    permissions: false,\n    deleteFile: false,\n    renameFile: false,\n  },\n  tauri: {\n    openFile: true,\n    saveFile: true,\n    saveFileAs: true,\n    openDirectory: true,\n    readDirectory: true,\n    handlePersistence: false,\n    canSaveInPlace: true,\n    permissions: false,\n    deleteFile: true,\n    renameFile: true,\n  },\n  capacitor: {\n    openFile: true,\n    saveFile: true,\n    saveFileAs: true,\n    openDirectory: 'limited',\n    readDirectory: 'limited',\n    handlePersistence: false,\n    canSaveInPlace: false,\n    permissions: false,\n    deleteFile: true,\n    renameFile: true,\n  },\n}\n\n/**\n * Adapter interface implemented by each platform backend.\n */\nexport interface OneFSAdapter {\n  platform: Platform\n\n  /** Check if this adapter can run in the current environment */\n  isSupported(): boolean\n\n  /** Open file picker and return selected file(s) with content */\n  openFile(options?: OneFSOpenOptions): Promise<OneFSResult<OneFSFile | OneFSFile[]>>\n\n  /** Save content to an existing file (behavior varies by platform - see canSaveInPlace) */\n  saveFile(file: OneFSFile, content: Uint8Array | string, options?: OneFSSaveOptions): Promise<OneFSResult<boolean>>\n\n  /** Open save dialog and write content to new file */\n  saveFileAs(content: Uint8Array | string, options?: OneFSSaveOptions): Promise<OneFSResult<OneFSFile>>\n\n  /** Open directory picker (optional - check capabilities first) */\n  openDirectory?(options?: OneFSDirectoryOptions): Promise<OneFSResult<OneFSDirectory>>\n\n  /** List directory contents as entries (metadata only, no content loaded) */\n  readDirectory?(directory: OneFSDirectory, options?: OneFSReadDirectoryOptions): Promise<OneFSResult<OneFSEntry[]>>\n\n  /** Load a specific file from a directory. Supports partial reads via maxBytes option. */\n  readFileFromDirectory?(directory: OneFSDirectory, entry: OneFSEntry, options?: { maxBytes?: number }): Promise<OneFSResult<OneFSFile>>\n\n  /** Recursively scan directory for files (Tauri/Capacitor only) */\n  scanDirectory?(directory: OneFSDirectory, options?: OneFSScanOptions): Promise<OneFSResult<OneFSEntry[]>>\n\n  /** Get efficient URL for file playback without loading into memory (Tauri only) */\n  getFileUrl?(file: OneFSFile): Promise<string>\n\n  /** Get efficient URL for entry without loading content (Tauri only) */\n  getEntryUrl?(entry: OneFSEntry): Promise<string | null>\n\n  /** Get list of recently opened files/directories */\n  getRecentFiles(): Promise<StoredHandle[]>\n\n  /** Restore a previously opened file from storage */\n  restoreFile(stored: StoredHandle): Promise<OneFSResult<OneFSFile>>\n\n  /** Restore a previously opened directory from storage (optional - check capabilities) */\n  restoreDirectory?(stored: StoredHandle, mode?: PermissionMode): Promise<OneFSResult<OneFSDirectory>>\n\n  /** Delete a file from disk and IDB storage (Tauri/Capacitor only) */\n  deleteFile?(file: OneFSFile): Promise<OneFSResult<boolean>>\n\n  /** Rename a file on disk and update IDB storage (Tauri/Capacitor only) */\n  renameFile?(file: OneFSFile, newName: string): Promise<OneFSResult<OneFSFile>>\n\n  /** Remove a file from recent list */\n  removeFromRecent(id: string): Promise<void>\n\n  /** Clear all recent files */\n  clearRecent(): Promise<void>\n\n  /** Check current permission status (optional - check capabilities.permissions) */\n  queryPermission?(target: OneFSFile | OneFSDirectory, mode: PermissionMode): Promise<PermissionStatus>\n\n  /** Request permission (optional - check capabilities.permissions) */\n  requestPermission?(target: OneFSFile | OneFSDirectory, mode: PermissionMode): Promise<OneFSResult<boolean>>\n\n  /** Store a directory by named key (optional - check capabilities.handlePersistence) */\n  setNamedDirectory?(key: string, directory: OneFSDirectory): Promise<OneFSResult<boolean>>\n\n  /** Retrieve a named directory (optional - check capabilities.handlePersistence) */\n  getNamedDirectory?(key: string, mode?: PermissionMode): Promise<OneFSResult<OneFSDirectory>>\n\n  /** Remove a named directory (optional - check capabilities.handlePersistence) */\n  removeNamedDirectory?(key: string): Promise<void>\n\n  /** Close underlying storage connections */\n  dispose?(): void\n}\n\nexport interface OneFSConfig {\n  /** Application name - used for IndexedDB database naming */\n  appName: string\n  /** Maximum number of recent files to store (default: 10) */\n  maxRecentFiles?: number\n  /** Whether to persist files/handles by default (default: true) */\n  persistByDefault?: boolean\n  /** Whether to use File System Access API when available (default: true) */\n  useNativeFSAccess?: boolean\n  /** Force a specific adapter (useful for testing) */\n  preferredAdapter?: Platform\n}\n","import type { StoredHandle, StoredFile } from '../types'\n\nconst DB_VERSION = 2\nconst PRUNE_BUFFER = 5\n\nexport class IDBStorage {\n  private dbName: string\n  private db: IDBDatabase | null = null\n  private dbPromise: Promise<IDBDatabase> | null = null\n  private maxRecentFiles: number\n  private maxCacheSize: number\n  /** Called with the records evicted by pruning, so adapters can clean up backing resources */\n  onFilesPruned?: (files: StoredFile[]) => void\n\n  constructor(appName: string, maxRecentFiles = 10, maxCacheSize = 50 * 1024 * 1024) {\n    if (!appName || !/^[\\w.\\-]+$/.test(appName)) {\n      throw new Error(`Invalid appName: must be non-empty and contain only alphanumeric, hyphens, underscores, or dots`)\n    }\n    this.dbName = `onefs-${appName}`\n    this.maxRecentFiles = maxRecentFiles\n    this.maxCacheSize = maxCacheSize\n  }\n\n  private getDB(): Promise<IDBDatabase> {\n    if (this.dbPromise) return this.dbPromise\n\n    this.dbPromise = new Promise((resolve, reject) => {\n      const request = indexedDB.open(this.dbName, DB_VERSION)\n\n      request.onerror = () => {\n        this.dbPromise = null\n        reject(request.error)\n      }\n      request.onsuccess = () => {\n        this.db = request.result\n        resolve(this.db)\n      }\n\n      request.onupgradeneeded = (event) => {\n        const db = (event.target as IDBOpenDBRequest).result\n\n        if (!db.objectStoreNames.contains('handles')) {\n          const handleStore = db.createObjectStore('handles', { keyPath: 'id' })\n          handleStore.createIndex('storedAt', 'storedAt', { unique: false })\n        }\n\n        if (!db.objectStoreNames.contains('files')) {\n          const fileStore = db.createObjectStore('files', { keyPath: 'id' })\n          fileStore.createIndex('storedAt', 'storedAt', { unique: false })\n        }\n\n        if (!db.objectStoreNames.contains('handleObjects')) {\n          db.createObjectStore('handleObjects', { keyPath: 'id' })\n        }\n\n        if (!db.objectStoreNames.contains('namedHandles')) {\n          db.createObjectStore('namedHandles', { keyPath: 'key' })\n        }\n      }\n    })\n    return this.dbPromise\n  }\n\n  async storeHandle(\n    handle: FileSystemFileHandle | FileSystemDirectoryHandle,\n    id: string,\n    path?: string\n  ): Promise<StoredHandle> {\n    const db = await this.getDB()\n    const storedHandle: StoredHandle = {\n      id,\n      name: handle.name,\n      path,\n      type: handle.kind === 'file' ? 'file' : 'directory',\n      storedAt: Date.now(),\n    }\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction(['handles', 'handleObjects'], 'readwrite')\n      tx.onerror = () => reject(tx.error)\n\n      const handleStore = tx.objectStore('handles')\n      const objectStore = tx.objectStore('handleObjects')\n\n      handleStore.put(storedHandle)\n      objectStore.put({ id, handle })\n\n      tx.oncomplete = () => {\n        this.pruneOldHandles().catch(() => {})\n        resolve(storedHandle)\n      }\n    })\n  }\n\n  async getStoredHandles(): Promise<StoredHandle[]> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('handles', 'readonly')\n      const store = tx.objectStore('handles')\n      const index = store.index('storedAt')\n      const request = index.getAll()\n\n      request.onerror = () => reject(request.error)\n      request.onsuccess = () => {\n        const handles = request.result as StoredHandle[]\n        resolve(handles.sort((a, b) => b.storedAt - a.storedAt))\n      }\n    })\n  }\n\n  async getHandleObject(id: string): Promise<FileSystemFileHandle | FileSystemDirectoryHandle | null> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('handleObjects', 'readonly')\n      const store = tx.objectStore('handleObjects')\n      const request = store.get(id)\n\n      request.onerror = () => reject(request.error)\n      request.onsuccess = () => {\n        const result = request.result as { id: string; handle: FileSystemFileHandle | FileSystemDirectoryHandle } | undefined\n        resolve(result?.handle ?? null)\n      }\n    })\n  }\n\n  async removeHandle(id: string): Promise<void> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction(['handles', 'handleObjects'], 'readwrite')\n      tx.onerror = () => reject(tx.error)\n\n      tx.objectStore('handles').delete(id)\n      tx.objectStore('handleObjects').delete(id)\n\n      tx.oncomplete = () => resolve()\n    })\n  }\n\n  async clearHandles(): Promise<void> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction(['handles', 'handleObjects'], 'readwrite')\n      tx.onerror = () => reject(tx.error)\n\n      tx.objectStore('handles').clear()\n      tx.objectStore('handleObjects').clear()\n\n      tx.oncomplete = () => resolve()\n    })\n  }\n\n  private async pruneOldHandles(): Promise<void> {\n    const handles = await this.getStoredHandles()\n    if (handles.length <= this.maxRecentFiles + PRUNE_BUFFER) return\n\n    const toRemove = handles.slice(this.maxRecentFiles)\n    const db = await this.getDB()\n    const tx = db.transaction(['handles', 'handleObjects'], 'readwrite')\n    const handleStore = tx.objectStore('handles')\n    const objectStore = tx.objectStore('handleObjects')\n    for (const handle of toRemove) {\n      handleStore.delete(handle.id)\n      objectStore.delete(handle.id)\n    }\n    await new Promise<void>((resolve, reject) => {\n      tx.oncomplete = () => resolve()\n      tx.onerror = () => reject(tx.error)\n    })\n  }\n\n  async storeFile(file: StoredFile): Promise<void> {\n    let toStore = file\n    if (file.content.byteLength > this.maxCacheSize) {\n      // Too large to cache. With a path the metadata record is still kept\n      // (content is re-read from disk on restore); without one there is\n      // nothing to restore from, so skip entirely.\n      if (!file.path) return\n      toStore = { ...file, content: new Uint8Array(0) }\n    }\n\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('files', 'readwrite')\n      tx.onerror = () => reject(tx.error)\n\n      const store = tx.objectStore('files')\n      store.put(toStore)\n\n      tx.oncomplete = () => {\n        this.pruneOldFiles().catch(() => {})\n        resolve()\n      }\n    })\n  }\n\n  /**\n   * Update name/path/mimeType on an existing record without touching its\n   * cached content. No-op (returns false) when the record does not exist.\n   */\n  async updateFileMetadata(\n    id: string,\n    updates: { name?: string; path?: string; mimeType?: string }\n  ): Promise<boolean> {\n    const existing = await this.getStoredFile(id)\n    if (!existing) return false\n\n    const db = await this.getDB()\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('files', 'readwrite')\n      tx.onerror = () => reject(tx.error)\n\n      tx.objectStore('files').put({ ...existing, ...updates, storedAt: Date.now() })\n\n      tx.oncomplete = () => resolve(true)\n    })\n  }\n\n  storeFileDeferred(file: StoredFile): void {\n    queueMicrotask(() => {\n      this.storeFile(file).catch(() => {})\n    })\n  }\n\n  async getStoredFile(id: string): Promise<StoredFile | null> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('files', 'readonly')\n      const store = tx.objectStore('files')\n      const request = store.get(id)\n\n      request.onerror = () => reject(request.error)\n      request.onsuccess = () => resolve(request.result ?? null)\n    })\n  }\n\n  async removeFile(id: string): Promise<void> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('files', 'readwrite')\n      tx.onerror = () => reject(tx.error)\n\n      tx.objectStore('files').delete(id)\n\n      tx.oncomplete = () => resolve()\n    })\n  }\n\n  async getStoredFiles(): Promise<StoredFile[]> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('files', 'readonly')\n      const store = tx.objectStore('files')\n      const index = store.index('storedAt')\n      const request = index.getAll()\n\n      request.onerror = () => reject(request.error)\n      request.onsuccess = () => {\n        const files = request.result as StoredFile[]\n        resolve(files.sort((a, b) => b.storedAt - a.storedAt))\n      }\n    })\n  }\n\n  async clearFiles(): Promise<void> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('files', 'readwrite')\n      tx.onerror = () => reject(tx.error)\n\n      tx.objectStore('files').clear()\n\n      tx.oncomplete = () => resolve()\n    })\n  }\n\n  private async pruneOldFiles(): Promise<void> {\n    const files = await this.getStoredFiles()\n    if (files.length <= this.maxRecentFiles + PRUNE_BUFFER) return\n\n    const toRemove = files.slice(this.maxRecentFiles)\n    const db = await this.getDB()\n    const tx = db.transaction('files', 'readwrite')\n    const store = tx.objectStore('files')\n    for (const file of toRemove) {\n      store.delete(file.id)\n    }\n    await new Promise<void>((resolve, reject) => {\n      tx.oncomplete = () => resolve()\n      tx.onerror = () => reject(tx.error)\n    })\n    if (toRemove.length > 0) {\n      this.onFilesPruned?.(toRemove)\n    }\n  }\n\n  async setNamedHandle(\n    key: string,\n    handle: FileSystemFileHandle | FileSystemDirectoryHandle\n  ): Promise<void> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('namedHandles', 'readwrite')\n      tx.onerror = () => reject(tx.error)\n\n      tx.objectStore('namedHandles').put({\n        key,\n        handle,\n        name: handle.name,\n        type: handle.kind,\n        storedAt: Date.now(),\n      })\n\n      tx.oncomplete = () => resolve()\n    })\n  }\n\n  async getNamedHandle(key: string): Promise<{\n    handle: FileSystemFileHandle | FileSystemDirectoryHandle\n    name: string\n    type: 'file' | 'directory'\n  } | null> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('namedHandles', 'readonly')\n      const request = tx.objectStore('namedHandles').get(key)\n\n      request.onerror = () => reject(request.error)\n      request.onsuccess = () => {\n        const result = request.result\n        if (!result) {\n          resolve(null)\n        } else {\n          resolve({\n            handle: result.handle,\n            name: result.name,\n            type: result.type,\n          })\n        }\n      }\n    })\n  }\n\n  async removeNamedHandle(key: string): Promise<void> {\n    const db = await this.getDB()\n\n    return new Promise((resolve, reject) => {\n      const tx = db.transaction('namedHandles', 'readwrite')\n      tx.onerror = () => reject(tx.error)\n\n      tx.objectStore('namedHandles').delete(key)\n\n      tx.oncomplete = () => resolve()\n    })\n  }\n\n  dispose(): void {\n    if (this.db) {\n      this.db.close()\n      this.db = null\n    }\n    this.dbPromise = null\n  }\n}\n","export function generateId(): string {\n  return crypto.randomUUID()\n}\n\nconst MIME_TYPES: Record<string, string> = {\n  txt: 'text/plain',\n  json: 'application/json',\n  js: 'text/javascript',\n  mjs: 'text/javascript',\n  ts: 'text/typescript',\n  tsx: 'text/typescript',\n  jsx: 'text/javascript',\n  html: 'text/html',\n  htm: 'text/html',\n  css: 'text/css',\n  md: 'text/markdown',\n  xml: 'application/xml',\n  csv: 'text/csv',\n  png: 'image/png',\n  jpg: 'image/jpeg',\n  jpeg: 'image/jpeg',\n  gif: 'image/gif',\n  svg: 'image/svg+xml',\n  webp: 'image/webp',\n  avif: 'image/avif',\n  ico: 'image/x-icon',\n  pdf: 'application/pdf',\n  zip: 'application/zip',\n  tar: 'application/x-tar',\n  gz: 'application/gzip',\n  mp3: 'audio/mpeg',\n  wav: 'audio/wav',\n  ogg: 'audio/ogg',\n  flac: 'audio/flac',\n  aac: 'audio/aac',\n  m4a: 'audio/mp4',\n  opus: 'audio/opus',\n  aiff: 'audio/aiff',\n  aif: 'audio/aiff',\n  mp4: 'video/mp4',\n  webm: 'video/webm',\n  mov: 'video/quicktime',\n  woff: 'font/woff',\n  woff2: 'font/woff2',\n  ttf: 'font/ttf',\n  otf: 'font/otf',\n}\n\nexport function getMimeType(name: string): string {\n  const ext = name.split('.').pop()?.toLowerCase()\n  return MIME_TYPES[ext ?? ''] ?? 'application/octet-stream'\n}\n\nexport function getFileName(path: string): string {\n  return path.split(/[/\\\\]/).pop() || path\n}\n\nexport function uint8ArrayToBase64(bytes: Uint8Array): string {\n  if (typeof Buffer !== 'undefined') {\n    return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('base64')\n  }\n  const CHUNK = 32768\n  let binary = ''\n  for (let i = 0; i < bytes.length; i += CHUNK) {\n    const slice = bytes.subarray(i, Math.min(i + CHUNK, bytes.length))\n    binary += String.fromCharCode.apply(null, slice as unknown as number[])\n  }\n  return btoa(binary)\n}\n\nexport function base64ToUint8Array(base64: string): Uint8Array {\n  const binary = atob(base64)\n  const bytes = new Uint8Array(binary.length)\n  for (let i = 0; i < binary.length; i++) {\n    bytes[i] = binary.charCodeAt(i)\n  }\n  return bytes\n}\n\nexport function toArrayBuffer(bytes: Uint8Array): ArrayBuffer {\n  return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer\n}\n\nexport function normalizePath(path: string): string {\n  const segments = path.replace(/\\\\/g, '/').split('/')\n  const result: string[] = []\n  for (const seg of segments) {\n    if (seg === '..') {\n      result.pop()\n    } else if (seg && seg !== '.') {\n      result.push(seg)\n    }\n  }\n  const normalized = result.join('/')\n  return path.startsWith('/') ? '/' + normalized : normalized\n}\n\nexport function isPathWithin(child: string, parent: string): boolean {\n  const normalChild = normalizePath(child)\n  const normalParent = normalizePath(parent)\n  const prefix = normalParent.endsWith('/') ? normalParent : normalParent + '/'\n  return normalChild === normalParent || normalChild.startsWith(prefix)\n}\n\nexport function sanitizeFileName(name: string): string {\n  return name.replace(/[/\\\\\\0]/g, '').replace(/\\.\\./g, '')\n}\n\n/**\n * Open a hidden <input type=\"file\"> picker. Resolves with the selected files,\n * or null when the user cancels. Uses the input `cancel` event where available,\n * with a window-focus fallback for browsers without it (pre-16.4 Safari) so the\n * promise cannot hang forever on cancel. Must be called from a user gesture.\n */\nexport function pickFilesViaInput(options: { accept?: string; multiple?: boolean }): Promise<FileList | null> {\n  return new Promise((resolve) => {\n    const input = document.createElement('input')\n    input.type = 'file'\n    if (options.accept) input.accept = options.accept\n    input.multiple = options.multiple ?? false\n\n    let settled = false\n    const finish = (files: FileList | null) => {\n      if (settled) return\n      settled = true\n      window.removeEventListener('focus', onFocus)\n      resolve(files)\n    }\n    const onFocus = () => {\n      // The change event can arrive after focus returns from the picker\n      setTimeout(() => finish(input.files?.length ? input.files : null), 1000)\n    }\n\n    input.onchange = () => finish(input.files?.length ? input.files : null)\n    if ('oncancel' in input) {\n      input.oncancel = () => finish(null)\n    } else {\n      window.addEventListener('focus', onFocus)\n    }\n    input.click()\n  })\n}\n\nexport function isSafeEntryName(name: string): boolean {\n  return (\n    name.length > 0 &&\n    !name.includes('/') &&\n    !name.includes('\\\\') &&\n    !name.includes('\\0') &&\n    name !== '.' &&\n    name !== '..'\n  )\n}\n","import type {\n  OneFSAdapter,\n  OneFSFile,\n  OneFSOpenOptions,\n  OneFSSaveOptions,\n  OneFSDirectory,\n  OneFSDirectoryOptions,\n  OneFSReadDirectoryOptions,\n  OneFSEntry,\n  StoredHandle,\n  OneFSResult,\n  PermissionMode,\n  PermissionStatus,\n} from '../types'\nimport { ok, err } from '../types'\nimport { IDBStorage } from '../storage/idb'\nimport { generateId, getMimeType, isSafeEntryName, toArrayBuffer } from '../utils'\n\nfunction buildAcceptTypes(accept?: string[]): FilePickerAcceptType[] {\n  if (!accept || accept.length === 0) return []\n\n  const extensions = accept.filter((a) => a.startsWith('.'))\n  if (extensions.length === 0) return []\n\n  return [\n    {\n      description: 'Accepted files',\n      accept: {\n        '*/*': extensions,\n      },\n    },\n  ]\n}\n\n/**\n * Adapter for the File System Access API (modern browsers).\n * Provides full read/write access with handle persistence.\n */\nexport class FSAccessAdapter implements OneFSAdapter {\n  platform = 'web-fs-access' as const\n  private storage: IDBStorage\n  private persistByDefault: boolean\n\n  constructor(appName: string, maxRecentFiles = 10, persistByDefault = true) {\n    this.storage = new IDBStorage(appName, maxRecentFiles)\n    this.persistByDefault = persistByDefault\n  }\n\n  isSupported(): boolean {\n    return typeof window !== 'undefined' && 'showOpenFilePicker' in window\n  }\n\n  async openFile(options: OneFSOpenOptions = {}): Promise<OneFSResult<OneFSFile | OneFSFile[]>> {\n    const shouldPersist = options.persist ?? this.persistByDefault\n\n    try {\n      const handles = await window.showOpenFilePicker({\n        multiple: options.multiple ?? false,\n        types: buildAcceptTypes(options.accept),\n        startIn: options.startIn,\n      })\n\n      const fileDataResults = await Promise.all(\n        handles.map(async (handle) => {\n          const file = await handle.getFile()\n          const content = new Uint8Array(await file.arrayBuffer())\n          return { handle, file, content }\n        })\n      )\n\n      const files: OneFSFile[] = fileDataResults.map(({ handle, file, content }) => {\n        const id = generateId()\n\n        if (shouldPersist) {\n          this.storage.storeHandle(handle, id).catch(() => {})\n        }\n\n        return {\n          id,\n          name: handle.name,\n          content,\n          mimeType: file.type || getMimeType(handle.name),\n          size: content.byteLength,\n          lastModified: file.lastModified,\n          handle,\n        }\n      })\n\n      return ok(options.multiple ? files : files[0])\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'AbortError') {\n        return err('cancelled', 'User cancelled file picker')\n      }\n      if (error.name === 'SecurityError') {\n        return err('permission_denied', 'Permission denied to access file', e)\n      }\n      return err('io_error', error.message || 'Failed to open file', e)\n    }\n  }\n\n  async saveFile(\n    file: OneFSFile,\n    content: Uint8Array | string,\n    _options?: OneFSSaveOptions\n  ): Promise<OneFSResult<boolean>> {\n    if (!file.handle) {\n      return err('not_supported', 'Cannot save file without handle - use saveFileAs instead')\n    }\n\n    try {\n      const permission = await file.handle.queryPermission({ mode: 'readwrite' })\n      if (permission !== 'granted') {\n        const requested = await file.handle.requestPermission({ mode: 'readwrite' })\n        if (requested !== 'granted') {\n          return err('permission_denied', 'Write permission denied')\n        }\n      }\n\n      const writable = await file.handle.createWritable()\n      const data = typeof content === 'string' ? content : new Blob([toArrayBuffer(content)])\n      await writable.write(data)\n      await writable.close()\n\n      return ok(true)\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'AbortError') {\n        return err('cancelled', 'User cancelled save operation')\n      }\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission denied to save file', e)\n      }\n      return err('io_error', error.message || 'Failed to save file', e)\n    }\n  }\n\n  async saveFileAs(content: Uint8Array | string, options: OneFSSaveOptions = {}): Promise<OneFSResult<OneFSFile>> {\n    const shouldPersist = options.persist ?? this.persistByDefault\n\n    try {\n      const handle = await window.showSaveFilePicker({\n        suggestedName: options.suggestedName,\n        types: buildAcceptTypes(options.accept),\n        startIn: options.startIn,\n      })\n\n      const writable = await handle.createWritable()\n      const data = typeof content === 'string' ? content : new Blob([toArrayBuffer(content)])\n      await writable.write(data)\n      await writable.close()\n\n      const id = generateId()\n      if (shouldPersist) {\n        await this.storage.storeHandle(handle, id)\n      }\n\n      const contentArray = typeof content === 'string' ? new TextEncoder().encode(content) : content\n\n      return ok({\n        id,\n        name: handle.name,\n        content: contentArray,\n        mimeType: getMimeType(handle.name),\n        size: contentArray.byteLength,\n        lastModified: Date.now(),\n        handle,\n      })\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'AbortError') {\n        return err('cancelled', 'User cancelled save dialog')\n      }\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission denied to save file', e)\n      }\n      return err('io_error', error.message || 'Failed to save file', e)\n    }\n  }\n\n  async openDirectory(options: OneFSDirectoryOptions = {}): Promise<OneFSResult<OneFSDirectory>> {\n    const shouldPersist = options.persist ?? this.persistByDefault\n\n    try {\n      const handle = await window.showDirectoryPicker({\n        startIn: options.startIn,\n        mode: options.mode ?? 'read',\n      })\n\n      const id = generateId()\n      if (shouldPersist) {\n        await this.storage.storeHandle(handle, id)\n      }\n\n      return ok({\n        id,\n        name: handle.name,\n        handle,\n      })\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'AbortError') {\n        return err('cancelled', 'User cancelled directory picker')\n      }\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission denied to access directory', e)\n      }\n      return err('io_error', error.message || 'Failed to open directory', e)\n    }\n  }\n\n  /**\n   * List directory contents as entries (metadata only, no content loaded).\n   * Use readFileFromDirectory() to load a specific file's content.\n   */\n  async readDirectory(directory: OneFSDirectory, options: OneFSReadDirectoryOptions = {}): Promise<OneFSResult<OneFSEntry[]>> {\n    if (!directory.handle) {\n      return err('not_supported', 'Cannot read directory without handle')\n    }\n\n    try {\n      const entries: OneFSEntry[] = []\n\n      for await (const entry of directory.handle.values()) {\n        if (entry.kind === 'file') {\n          if (options.skipStats) {\n            entries.push({\n              name: entry.name,\n              kind: 'file',\n              handle: entry,\n            })\n          } else {\n            try {\n              const file = await entry.getFile()\n              entries.push({\n                name: entry.name,\n                kind: 'file',\n                size: file.size,\n                lastModified: file.lastModified,\n                handle: entry,\n              })\n            } catch (entryError) {\n              options.onError?.(entry.name, entryError)\n              entries.push({\n                name: entry.name,\n                kind: 'file',\n                handle: entry,\n              })\n            }\n          }\n        } else {\n          entries.push({\n            name: entry.name,\n            kind: 'directory',\n            handle: entry,\n          })\n        }\n      }\n\n      return ok(entries)\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission denied to read directory', e)\n      }\n      return err('io_error', error.message || 'Failed to read directory', e)\n    }\n  }\n\n  /**\n   * Load a specific file from a directory.\n   * Note: maxBytes option is not supported on web-fs-access (full file is always loaded).\n   */\n  async readFileFromDirectory(\n    _directory: OneFSDirectory,\n    entry: OneFSEntry,\n    _options?: { maxBytes?: number }\n  ): Promise<OneFSResult<OneFSFile>> {\n    if (!entry.handle || entry.kind !== 'file') {\n      return err('not_supported', 'Cannot read file without handle')\n    }\n\n    try {\n      const fileHandle = entry.handle as FileSystemFileHandle\n      const file = await fileHandle.getFile()\n      const content = new Uint8Array(await file.arrayBuffer())\n\n      return ok({\n        id: generateId(),\n        name: entry.name,\n        content,\n        mimeType: file.type || getMimeType(entry.name),\n        size: content.byteLength,\n        lastModified: file.lastModified,\n        handle: fileHandle,\n      })\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'NotFoundError') {\n        return err('not_found', 'File no longer exists', e)\n      }\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission denied to read file', e)\n      }\n      return err('io_error', error.message || 'Failed to read file', e)\n    }\n  }\n\n  async getRecentFiles(): Promise<StoredHandle[]> {\n    return this.storage.getStoredHandles()\n  }\n\n  async restoreFile(stored: StoredHandle): Promise<OneFSResult<OneFSFile>> {\n    const handle = await this.storage.getHandleObject(stored.id)\n    if (!handle || handle.kind !== 'file') {\n      return err('not_found', 'File handle not found in storage')\n    }\n\n    const fileHandle = handle as FileSystemFileHandle\n\n    try {\n      const permission = await fileHandle.queryPermission({ mode: 'read' })\n      if (permission !== 'granted') {\n        const requested = await fileHandle.requestPermission({ mode: 'read' })\n        if (requested !== 'granted') {\n          return err('permission_denied', 'Read permission denied')\n        }\n      }\n\n      const file = await fileHandle.getFile()\n      const content = new Uint8Array(await file.arrayBuffer())\n\n      return ok({\n        id: stored.id,\n        name: fileHandle.name,\n        content,\n        mimeType: file.type || getMimeType(fileHandle.name),\n        size: content.byteLength,\n        lastModified: file.lastModified,\n        handle: fileHandle,\n      })\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'NotFoundError') {\n        return err('not_found', 'File no longer exists at original location', e)\n      }\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission denied to restore file', e)\n      }\n      return err('io_error', error.message || 'Failed to restore file', e)\n    }\n  }\n\n  async restoreDirectory(stored: StoredHandle, mode: PermissionMode = 'read'): Promise<OneFSResult<OneFSDirectory>> {\n    const handle = await this.storage.getHandleObject(stored.id)\n    if (!handle || handle.kind !== 'directory') {\n      return err('not_found', 'Directory handle not found in storage')\n    }\n\n    const dirHandle = handle as FileSystemDirectoryHandle\n\n    try {\n      const permission = await dirHandle.queryPermission({ mode })\n      if (permission !== 'granted') {\n        const requested = await dirHandle.requestPermission({ mode })\n        if (requested !== 'granted') {\n          return err('permission_denied', `${mode === 'readwrite' ? 'Write' : 'Read'} permission denied`)\n        }\n      }\n\n      return ok({\n        id: stored.id,\n        name: dirHandle.name,\n        handle: dirHandle,\n      })\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'NotFoundError') {\n        return err('not_found', 'Directory no longer exists at original location', e)\n      }\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission denied to restore directory', e)\n      }\n      return err('io_error', error.message || 'Failed to restore directory', e)\n    }\n  }\n\n  async queryPermission(target: OneFSFile | OneFSDirectory, mode: PermissionMode): Promise<PermissionStatus> {\n    const handle = target.handle\n    if (!handle) return 'denied'\n\n    try {\n      return await handle.queryPermission({ mode })\n    } catch {\n      return 'denied'\n    }\n  }\n\n  async requestPermission(target: OneFSFile | OneFSDirectory, mode: PermissionMode): Promise<OneFSResult<boolean>> {\n    const handle = target.handle\n    if (!handle) {\n      return err('not_supported', 'Cannot request permission without handle')\n    }\n\n    try {\n      const status = await handle.requestPermission({ mode })\n      if (status === 'granted') {\n        return ok(true)\n      }\n      return err('permission_denied', `${mode === 'readwrite' ? 'Write' : 'Read'} permission denied`)\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission request failed', e)\n      }\n      return err('io_error', error.message || 'Failed to request permission', e)\n    }\n  }\n\n  async setNamedDirectory(key: string, directory: OneFSDirectory): Promise<OneFSResult<boolean>> {\n    if (!directory.handle) {\n      return err('not_supported', 'Cannot persist directory without handle')\n    }\n    try {\n      await this.storage.setNamedHandle(key, directory.handle)\n      return ok(true)\n    } catch (e) {\n      return err('io_error', (e as Error).message || 'Failed to persist directory', e)\n    }\n  }\n\n  async getNamedDirectory(key: string, mode: PermissionMode = 'read'): Promise<OneFSResult<OneFSDirectory>> {\n    try {\n      const stored = await this.storage.getNamedHandle(key)\n      if (!stored || stored.type !== 'directory') {\n        return err('not_found', `No directory stored with key \"${key}\"`)\n      }\n\n      const handle = stored.handle as FileSystemDirectoryHandle\n      const permission = await handle.queryPermission({ mode })\n      if (permission !== 'granted') {\n        const requested = await handle.requestPermission({ mode })\n        if (requested !== 'granted') {\n          return err('permission_denied', `${mode === 'readwrite' ? 'Write' : 'Read'} permission denied`)\n        }\n      }\n\n      return ok({\n        id: key,\n        name: stored.name,\n        handle,\n      })\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'NotFoundError') {\n        return err('not_found', 'Directory no longer exists', e)\n      }\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission denied', e)\n      }\n      return err('io_error', error.message || 'Failed to get directory', e)\n    }\n  }\n\n  async removeNamedDirectory(key: string): Promise<void> {\n    await this.storage.removeNamedHandle(key)\n  }\n\n  async deleteFile(file: OneFSFile): Promise<OneFSResult<boolean>> {\n    if (!file.handle) {\n      return err('not_supported', 'Cannot delete file without handle')\n    }\n\n    try {\n      const permission = await file.handle.queryPermission({ mode: 'readwrite' })\n      if (permission !== 'granted') {\n        const requested = await file.handle.requestPermission({ mode: 'readwrite' })\n        if (requested !== 'granted') {\n          return err('permission_denied', 'Write permission denied')\n        }\n      }\n\n      await file.handle.remove()\n      await this.storage.removeHandle(file.id)\n      return ok(true)\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'NotFoundError') {\n        return err('not_found', 'File not found', e)\n      }\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission denied to delete file', e)\n      }\n      return err('io_error', error.message || 'Failed to delete file', e)\n    }\n  }\n\n  async renameFile(file: OneFSFile, newName: string): Promise<OneFSResult<OneFSFile>> {\n    if (!file.handle) {\n      return err('not_supported', 'Cannot rename file without handle')\n    }\n\n    if (!isSafeEntryName(newName)) {\n      return err('io_error', 'Invalid file name')\n    }\n\n    try {\n      const permission = await file.handle.queryPermission({ mode: 'readwrite' })\n      if (permission !== 'granted') {\n        const requested = await file.handle.requestPermission({ mode: 'readwrite' })\n        if (requested !== 'granted') {\n          return err('permission_denied', 'Write permission denied')\n        }\n      }\n\n      await file.handle.move(newName)\n\n      // Refresh stored metadata (name) if this handle was persisted\n      await this.storage.getHandleObject(file.id)\n        .then((existing) => (existing ? this.storage.storeHandle(file.handle!, file.id) : null))\n        .catch(() => {})\n\n      const updatedFile: OneFSFile = {\n        ...file,\n        name: newName,\n        mimeType: getMimeType(newName),\n      }\n      return ok(updatedFile)\n    } catch (e) {\n      const error = e as Error\n      if (error.name === 'NotFoundError') {\n        return err('not_found', 'File not found', e)\n      }\n      if (error.name === 'SecurityError' || error.name === 'NotAllowedError') {\n        return err('permission_denied', 'Permission denied to rename file', e)\n      }\n      return err('io_error', error.message || 'Failed to rename file', e)\n    }\n  }\n\n  async removeFromRecent(id: string): Promise<void> {\n    await this.storage.removeHandle(id)\n  }\n\n  async clearRecent(): Promise<void> {\n    await this.storage.clearHandles()\n  }\n\n  dispose(): void {\n    this.storage.dispose()\n  }\n}\n","import type {\n  OneFSAdapter,\n  OneFSFile,\n  OneFSOpenOptions,\n  OneFSSaveOptions,\n  StoredHandle,\n  StoredFile,\n  OneFSResult,\n} from '../types'\nimport { ok, err } from '../types'\nimport { IDBStorage } from '../storage/idb'\nimport { generateId, getMimeType, toArrayBuffer, sanitizeFileName, pickFilesViaInput } from '../utils'\n\n/**\n * Fallback adapter for browsers without File System Access API.\n * Uses <input type=\"file\"> for selection and downloads for saving.\n *\n * Note: saveFile() triggers a download rather than saving in-place.\n * Check capabilities.canSaveInPlace to detect this behavior.\n */\nexport class PickerIDBAdapter implements OneFSAdapter {\n  platform = 'web-fallback' as const\n  private storage: IDBStorage\n  private persistByDefault: boolean\n\n  constructor(appName: string, maxRecentFiles = 10, persistByDefault = true) {\n    this.storage = new IDBStorage(appName, maxRecentFiles)\n    this.persistByDefault = persistByDefault\n  }\n\n  isSupported(): boolean {\n    return typeof document !== 'undefined' && 'createElement' in document\n  }\n\n  async openFile(options: OneFSOpenOptions = {}): Promise<OneFSResult<OneFSFile | OneFSFile[]>> {\n    const shouldPersist = options.persist ?? this.persistByDefault\n\n    const fileList = await pickFilesViaInput({\n      accept: options.accept?.length ? options.accept.join(',') : undefined,\n      multiple: options.multiple ?? false,\n    })\n    if (!fileList) {\n      return err('cancelled', 'User cancelled file picker')\n    }\n\n    try {\n      const results = await Promise.all(\n        Array.from(fileList).map(async (file) => {\n          const content = new Uint8Array(await file.arrayBuffer())\n          return { file, content }\n        })\n      )\n\n      const files: OneFSFile[] = results.map(({ file, content }) => {\n        const id = generateId()\n\n        if (shouldPersist) {\n          this.storage.storeFileDeferred({\n            id,\n            name: file.name,\n            content,\n            mimeType: file.type || getMimeType(file.name),\n            size: content.byteLength,\n            lastModified: file.lastModified,\n            storedAt: Date.now(),\n          })\n        }\n\n        return {\n          id,\n          name: file.name,\n          content,\n          mimeType: file.type || getMimeType(file.name),\n          size: content.byteLength,\n          lastModified: file.lastModified,\n        }\n      })\n\n      return ok(options.multiple ? files : files[0])\n    } catch (e) {\n      const error = e as Error\n      return err('io_error', error.message || 'Failed to read file', e)\n    }\n  }\n\n  /**\n   * \"Save\" by triggering a download. Does not save in-place.\n   * The file is also stored in IndexedDB for restoration via getRecentFiles().\n   */\n  async saveFile(\n    file: OneFSFile,\n    content: Uint8Array | string,\n    options?: OneFSSaveOptions\n  ): Promise<OneFSResult<boolean>> {\n    const shouldPersist = options?.persist ?? this.persistByDefault\n    const contentArray = typeof content === 'string' ? new TextEncoder().encode(content) : content\n\n    try {\n      if (shouldPersist) {\n        const storedFile: StoredFile = {\n          id: file.id,\n          name: file.name,\n          content: contentArray,\n          mimeType: file.mimeType,\n          size: contentArray.byteLength,\n          lastModified: Date.now(),\n          storedAt: Date.now(),\n        }\n        await this.storage.storeFile(storedFile)\n      }\n\n      this.triggerDownload(file.name, contentArray, file.mimeType)\n      return ok(true)\n    } catch (e) {\n      const error = e as Error\n      return err('io_error', error.message || 'Failed to save file', e)\n    }\n  }\n\n  /**\n   * Save as a new file by triggering a download.\n   */\n  async saveFileAs(content: Uint8Array | string, options: OneFSSaveOptions = {}): Promise<OneFSResult<OneFSFile>> {\n    const shouldPersist = options.persist ?? this.persistByDefault\n    const contentArray = typeof content === 'string' ? new TextEncoder().encode(content) : content\n    const name = options.suggestedName ?? 'untitled'\n    const mimeType = getMimeType(name)\n    const id = generateId()\n\n    try {\n      if (shouldPersist) {\n        const storedFile: StoredFile = {\n          id,\n          name,\n          content: contentArray,\n          mimeType,\n          size: contentArray.byteLength,\n          lastModified: Date.now(),\n          storedAt: Date.now(),\n        }\n        await this.storage.storeFile(storedFile)\n      }\n\n      this.triggerDownload(name, contentArray, mimeType)\n\n      return ok({\n        id,\n        name,\n        content: contentArray,\n        mimeType,\n        size: contentArray.byteLength,\n        lastModified: Date.now(),\n      })\n    } catch (e) {\n      const error = e as Error\n      return err('io_error', error.message || 'Failed to save file', e)\n    }\n  }\n\n  private triggerDownload(name: string, content: Uint8Array, mimeType: string): void {\n    const blob = new Blob([toArrayBuffer(content)], { type: mimeType })\n    const url = URL.createObjectURL(blob)\n    const a = document.createElement('a')\n    a.href = url\n    a.download = sanitizeFileName(name)\n    document.body.appendChild(a)\n    a.click()\n    document.body.removeChild(a)\n    URL.revokeObjectURL(url)\n  }\n\n  async getRecentFiles(): Promise<StoredHandle[]> {\n    const files = await this.storage.getStoredFiles()\n    return files.map((f) => ({\n      id: f.id,\n      name: f.name,\n      type: 'file' as const,\n      storedAt: f.storedAt,\n    }))\n  }\n\n  async restoreFile(stored: StoredHandle): Promise<OneFSResult<OneFSFile>> {\n    const file = await this.storage.getStoredFile(stored.id)\n    if (!file) {\n      return err('not_found', 'File not found in storage')\n    }\n\n    return ok({\n      id: file.id,\n      name: file.name,\n      content: file.content,\n      mimeType: file.mimeType,\n      size: file.size,\n      lastModified: file.lastModified,\n    })\n  }\n\n  async removeFromRecent(id: string): Promise<void> {\n    await this.storage.removeFile(id)\n  }\n\n  async clearRecent(): Promise<void> {\n    await this.storage.clearFiles()\n  }\n\n  dispose(): void {\n    this.storage.dispose()\n  }\n}\n","import type {\n  OneFSAdapter,\n  OneFSFile,\n  OneFSOpenOptions,\n  OneFSSaveOptions,\n  OneFSDirectory,\n  OneFSDirectoryOptions,\n  OneFSReadDirectoryOptions,\n  OneFSScanOptions,\n  OneFSEntry,\n  StoredHandle,\n  OneFSResult,\n} from '../types'\nimport { ok, err } from '../types'\nimport { IDBStorage } from '../storage/idb'\nimport { generateId, getMimeType, getFileName, isPathWithin, normalizePath, toArrayBuffer, isSafeEntryName } from '../utils'\n\ntype TauriDialog = typeof import('@tauri-apps/plugin-dialog')\ntype TauriFS = typeof import('@tauri-apps/plugin-fs')\ntype TauriCore = typeof import('@tauri-apps/api/core')\n\nconst DIRECTORY_MIME_TYPE = 'inode/directory'\nconst STAT_CHUNK_SIZE = 25\n\nexport class TauriAdapter implements OneFSAdapter {\n  platform = 'tauri' as const\n  private storage: IDBStorage\n  private dialog: TauriDialog | null = null\n  private fs: TauriFS | null = null\n  private core: TauriCore | null = null\n  private persistByDefault: boolean\n  private scanLock: Promise<void> = Promise.resolve()\n  private sessionPaths = new Map<string, string>()\n\n  constructor(appName: string, maxRecentFiles = 10, persistByDefault = true) {\n    this.storage = new IDBStorage(appName, maxRecentFiles)\n    this.persistByDefault = persistByDefault\n  }\n\n  isSupported(): boolean {\n    if (typeof window === 'undefined') return false\n    return '__TAURI_INTERNALS__' in window\n  }\n\n  private async loadModules(): Promise<{ dialog: TauriDialog; fs: TauriFS; core: TauriCore }> {\n    if (!this.dialog || !this.fs || !this.core) {\n      const [dialog, fs, core] = await Promise.all([\n        import('@tauri-apps/plugin-dialog'),\n        import('@tauri-apps/plugin-fs'),\n        import('@tauri-apps/api/core'),\n      ])\n      this.dialog = dialog\n      this.fs = fs\n      this.core = core\n    }\n    return { dialog: this.dialog, fs: this.fs, core: this.core }\n  }\n\n  private async acquireScanLock(): Promise<() => void> {\n    let release: () => void\n    const next = new Promise<void>(resolve => { release = resolve })\n    const prev = this.scanLock\n    this.scanLock = next\n    await prev\n    return release!\n  }\n\n  private getPreferredSeparator(path: string): '/' | '\\\\' {\n    return path.includes('\\\\') && !path.includes('/') ? '\\\\' : '/'\n  }\n\n  private joinPath(parent: string, child: string): string {\n    if (!parent) return child\n    const separator = this.getPreferredSeparator(parent)\n    const normalizedParent = parent.endsWith('/') || parent.endsWith('\\\\') ? parent.slice(0, -1) : parent\n    return `${normalizedParent}${separator}${child}`\n  }\n\n  private splitParentPath(path: string): { parent: string; separator: '/' | '\\\\' } | null {\n    const forwardSlash = path.lastIndexOf('/')\n    const backwardSlash = path.lastIndexOf('\\\\')\n    const index = Math.max(forwardSlash, backwardSlash)\n    if (index < 0) return null\n\n    const parent = path.slice(0, index)\n    return {\n      parent,\n      separator: this.getPreferredSeparator(parent),\n    }\n  }\n\n  private registerSessionFile(file: Pick<OneFSFile, 'id' | 'path'>): void {\n    if (!file.path) return\n    this.sessionPaths.set(file.id, file.path)\n  }\n\n  private pathsMatch(left: string, right: string): boolean {\n    return normalizePath(left) === normalizePath(right)\n  }\n\n  private async resolveAuthorizedPath(file: OneFSFile): Promise<OneFSResult<string>> {\n    if (!file.path) {\n      return err('not_supported', 'Cannot operate on file without path')\n    }\n\n    const sessionPath = this.sessionPaths.get(file.id)\n    if (sessionPath && this.pathsMatch(sessionPath, file.path)) {\n      return ok(file.path)\n    }\n\n    try {\n      const stored = await this.storage.getStoredFile(file.id)\n      if (stored?.path && this.pathsMatch(stored.path, file.path)) {\n        return ok(stored.path)\n      }\n      return err('permission_denied', 'File was not opened through this adapter')\n    } catch (e) {\n      return err('io_error', 'Failed to verify file provenance', e)\n    }\n  }\n\n  async openFile(options: OneFSOpenOptions = {}): Promise<OneFSResult<OneFSFile | OneFSFile[]>> {\n    const shouldPersist = options.persist ?? this.persistByDefault\n\n    try {\n      const { dialog, fs } = await this.loadModules()\n\n      const filters =\n        options.accept?.length\n          ? [{ name: 'Accepted files', extensions: options.accept.map((a) => a.replace('.', '')) }]\n          : undefined\n\n      const result = await dialog.open({\n        multiple: options.multiple ?? false,\n        filters,\n      })\n\n      if (!result) {\n        return err('cancelled', 'User cancelled file picker')\n      }\n\n      const paths = Array.isArray(result) ? result : [result]\n\n      const fileDataResults = await Promise.all(\n        paths.map(async (path) => {\n          const content = await fs.readFile(path)\n          return { path, content }\n        })\n      )\n\n      const files: OneFSFile[] = fileDataResults.map(({ path, content }) => {\n        const name = getFileName(path)\n        const id = generateId()\n\n        if (shouldPersist) {\n          this.storage.storeFileDeferred({\n            id,\n            name,\n            path,\n            content,\n            mimeType: getMimeType(name),\n            size: content.byteLength,\n            lastModified: Date.now(),\n            storedAt: Date.now(),\n          })\n        }\n\n        const file: OneFSFile = {\n          id,\n          name,\n          path,\n          content,\n          mimeType: getMimeType(name),\n          size: content.byteLength,\n          lastModified: Date.now(),\n        }\n        this.registerSessionFile(file)\n        return file\n      })\n\n      return ok(options.multiple ? files : files[0])\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('No such file') || error.message?.includes('not found')) {\n        return err('not_found', 'File not found', e)\n      }\n      return err('io_error', error.message || 'Failed to open file', e)\n    }\n  }\n\n  async saveFile(\n    file: OneFSFile,\n    content: Uint8Array | string,\n    options?: OneFSSaveOptions\n  ): Promise<OneFSResult<boolean>> {\n    const shouldPersist = options?.persist ?? this.persistByDefault\n    const authorized = await this.resolveAuthorizedPath(file)\n    if (!authorized.ok) return authorized\n    const path = authorized.data\n\n    try {\n      const { fs } = await this.loadModules()\n      const contentArray = typeof content === 'string' ? new TextEncoder().encode(content) : content\n\n      await fs.writeFile(path, contentArray)\n      this.registerSessionFile({ id: file.id, path })\n\n      if (shouldPersist) {\n        this.storage.storeFileDeferred({\n          id: file.id,\n          name: file.name,\n          path,\n          content: contentArray,\n          mimeType: file.mimeType,\n          size: contentArray.byteLength,\n          lastModified: Date.now(),\n          storedAt: Date.now(),\n        })\n      }\n\n      return ok(true)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to save file', e)\n      }\n      return err('io_error', error.message || 'Failed to save file', e)\n    }\n  }\n\n  async saveFileAs(content: Uint8Array | string, options: OneFSSaveOptions = {}): Promise<OneFSResult<OneFSFile>> {\n    const shouldPersist = options.persist ?? this.persistByDefault\n\n    try {\n      const { dialog, fs } = await this.loadModules()\n\n      const filters =\n        options.accept?.length\n          ? [{ name: 'Accepted files', extensions: options.accept.map((a) => a.replace('.', '')) }]\n          : undefined\n\n      const path = await dialog.save({\n        defaultPath: options.suggestedName,\n        filters,\n      })\n\n      if (!path) {\n        return err('cancelled', 'User cancelled save dialog')\n      }\n\n      const contentArray = typeof content === 'string' ? new TextEncoder().encode(content) : content\n      await fs.writeFile(path, contentArray)\n\n      const name = getFileName(path)\n      const id = generateId()\n\n      if (shouldPersist) {\n        this.storage.storeFileDeferred({\n          id,\n          name,\n          path,\n          content: contentArray,\n          mimeType: getMimeType(name),\n          size: contentArray.byteLength,\n          lastModified: Date.now(),\n          storedAt: Date.now(),\n        })\n      }\n\n      const file: OneFSFile = {\n        id,\n        name,\n        path,\n        content: contentArray,\n        mimeType: getMimeType(name),\n        size: contentArray.byteLength,\n        lastModified: Date.now(),\n      }\n      this.registerSessionFile(file)\n      return ok(file)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to save file', e)\n      }\n      return err('io_error', error.message || 'Failed to save file', e)\n    }\n  }\n\n  async openDirectory(options: OneFSDirectoryOptions = {}): Promise<OneFSResult<OneFSDirectory>> {\n    const shouldPersist = options.persist ?? this.persistByDefault\n\n    try {\n      const { dialog } = await this.loadModules()\n\n      const path = await dialog.open({\n        directory: true,\n      })\n\n      if (!path || Array.isArray(path)) {\n        return err('cancelled', 'User cancelled directory picker')\n      }\n\n      const id = generateId()\n\n      if (shouldPersist) {\n        this.storage.storeFileDeferred({\n          id,\n          name: getFileName(path),\n          path,\n          content: new Uint8Array(0),\n          mimeType: DIRECTORY_MIME_TYPE,\n          size: 0,\n          lastModified: Date.now(),\n          storedAt: Date.now(),\n        })\n      }\n\n      return ok({\n        id,\n        name: getFileName(path),\n        path,\n      })\n    } catch (e) {\n      const error = e as Error\n      return err('io_error', error.message || 'Failed to open directory', e)\n    }\n  }\n\n  async readDirectory(\n    directory: OneFSDirectory,\n    options: OneFSReadDirectoryOptions = {}\n  ): Promise<OneFSResult<OneFSEntry[]>> {\n    if (!directory.path) {\n      return err('not_supported', 'Cannot read directory without path')\n    }\n\n    try {\n      const { fs } = await this.loadModules()\n      const dirEntries = await fs.readDir(directory.path)\n      const entries: OneFSEntry[] = []\n      const needsStat: { index: number; name: string; path: string }[] = []\n\n      for (const entry of dirEntries) {\n        if (!entry.name) continue\n\n        if (!isSafeEntryName(entry.name)) continue\n        const entryName = entry.name\n        const filePath = this.joinPath(directory.path, entryName)\n\n        if (!isPathWithin(filePath, directory.path)) continue\n\n        if (entry.isFile) {\n          if (options.skipStats) {\n            entries.push({ name: entryName, kind: 'file', path: filePath })\n          } else {\n            needsStat.push({ index: entries.length, name: entryName, path: filePath })\n            entries.push({ name: entryName, kind: 'file', path: filePath })\n          }\n        } else if (entry.isDirectory) {\n          entries.push({ name: entryName, kind: 'directory', path: filePath })\n        }\n      }\n\n      for (let i = 0; i < needsStat.length; i += STAT_CHUNK_SIZE) {\n        const chunk = needsStat.slice(i, i + STAT_CHUNK_SIZE)\n        const stats = await Promise.all(\n          chunk.map(entry =>\n            fs.stat(entry.path).catch(e => {\n              options.onError?.(entry.path, e)\n              return null\n            })\n          )\n        )\n        for (let j = 0; j < chunk.length; j++) {\n          const stat = stats[j]\n          if (stat) {\n            entries[chunk[j].index] = {\n              name: chunk[j].name,\n              kind: 'file',\n              size: stat.size,\n              lastModified: stat.mtime ? new Date(stat.mtime).getTime() : Date.now(),\n              path: chunk[j].path,\n            }\n          }\n        }\n      }\n\n      return ok(entries)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('No such file') || error.message?.includes('not found')) {\n        return err('not_found', 'Directory not found', e)\n      }\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to read directory', e)\n      }\n      return err('io_error', error.message || 'Failed to read directory', e)\n    }\n  }\n\n  async readFileFromDirectory(\n    directory: OneFSDirectory,\n    entry: OneFSEntry,\n    _options?: { maxBytes?: number }\n  ): Promise<OneFSResult<OneFSFile>> {\n    if (!entry.path || entry.kind !== 'file') {\n      return err('not_supported', 'Cannot read file without path')\n    }\n\n    if (directory.path && !isPathWithin(entry.path, directory.path)) {\n      return err('permission_denied', 'Path is outside the expected directory')\n    }\n\n    try {\n      const { fs } = await this.loadModules()\n      const content = await fs.readFile(entry.path)\n\n      const loadedFile: OneFSFile = {\n        id: generateId(),\n        name: entry.name,\n        path: entry.path,\n        content,\n        mimeType: getMimeType(entry.name),\n        size: content.byteLength,\n        lastModified: entry.lastModified ?? Date.now(),\n      }\n      this.registerSessionFile(loadedFile)\n      return ok(loadedFile)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('No such file') || error.message?.includes('not found')) {\n        return err('not_found', 'File not found', e)\n      }\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to read file', e)\n      }\n      return err('io_error', error.message || 'Failed to read file', e)\n    }\n  }\n\n  async scanDirectory(\n    directory: OneFSDirectory,\n    options: OneFSScanOptions = {}\n  ): Promise<OneFSResult<OneFSEntry[]>> {\n    const release = await this.acquireScanLock()\n    try {\n      return await this._scanDirectoryImpl(directory, options)\n    } finally {\n      release()\n    }\n  }\n\n  private async _scanDirectoryImpl(\n    directory: OneFSDirectory,\n    options: OneFSScanOptions = {}\n  ): Promise<OneFSResult<OneFSEntry[]>> {\n    if (!directory.path) {\n      return err('not_supported', 'Cannot scan directory without path')\n    }\n\n    const { extensions, onProgress, onError, signal, skipStats } = options\n    const extensionSet = extensions?.length\n      ? new Set(extensions.map((e) => e.toLowerCase().replace(/^\\./, '')))\n      : null\n\n    try {\n      const { fs } = await this.loadModules()\n      const files: OneFSEntry[] = []\n      const directoriesToScan: string[] = [directory.path]\n      let totalScanned = 0\n\n      while (directoriesToScan.length > 0) {\n        if (signal?.aborted) {\n          return err('cancelled', 'Scan was cancelled')\n        }\n\n        const currentDir = directoriesToScan.pop()!\n\n        try {\n          const dirEntries = await fs.readDir(currentDir)\n          const fileEntriesToStat: { name: string; path: string }[] = []\n\n          for (const entry of dirEntries) {\n            if (!entry.name) continue\n\n            if (!isSafeEntryName(entry.name)) continue\n            const entryName = entry.name\n            const entryPath = this.joinPath(currentDir, entryName)\n\n            if (!isPathWithin(entryPath, directory.path)) continue\n\n            if (entry.isDirectory) {\n              directoriesToScan.push(entryPath)\n            } else if (entry.isFile) {\n              if (extensionSet) {\n                const ext = entryName.split('.').pop()?.toLowerCase()\n                if (!ext || !extensionSet.has(ext)) continue\n              }\n\n              if (skipStats) {\n                files.push({ name: entryName, kind: 'file', path: entryPath })\n              } else {\n                fileEntriesToStat.push({ name: entryName, path: entryPath })\n              }\n            }\n\n            totalScanned++\n          }\n\n          for (let i = 0; i < fileEntriesToStat.length; i += STAT_CHUNK_SIZE) {\n            if (signal?.aborted) {\n              return err('cancelled', 'Scan was cancelled')\n            }\n\n            const chunk = fileEntriesToStat.slice(i, i + STAT_CHUNK_SIZE)\n            const stats = await Promise.all(\n              chunk.map(entry =>\n                fs.stat(entry.path).catch(statError => {\n                  onError?.(entry.path, statError)\n                  return null\n                })\n              )\n            )\n            for (let j = 0; j < chunk.length; j++) {\n              const stat = stats[j]\n              if (stat) {\n                files.push({\n                  name: chunk[j].name,\n                  kind: 'file',\n                  size: stat.size,\n                  lastModified: stat.mtime ? new Date(stat.mtime).getTime() : Date.now(),\n                  path: chunk[j].path,\n                })\n              } else {\n                files.push({ name: chunk[j].name, kind: 'file', path: chunk[j].path })\n              }\n            }\n\n            if (onProgress) {\n              onProgress(totalScanned, files.length)\n            }\n          }\n\n          if (onProgress && totalScanned % 100 === 0) {\n            onProgress(totalScanned, files.length)\n          }\n          if (totalScanned % 500 === 0) {\n            await new Promise((resolve) => setTimeout(resolve, 0))\n          }\n        } catch (dirError) {\n          onError?.(currentDir, dirError)\n        }\n      }\n\n      if (onProgress) {\n        onProgress(totalScanned, files.length)\n      }\n\n      return ok(files)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('No such file') || error.message?.includes('not found')) {\n        return err('not_found', 'Directory not found', e)\n      }\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to scan directory', e)\n      }\n      return err('io_error', error.message || 'Failed to scan directory', e)\n    }\n  }\n\n  async getRecentFiles(): Promise<StoredHandle[]> {\n    const files = await this.storage.getStoredFiles()\n    return files.map((f) => ({\n      id: f.id,\n      name: f.name,\n      path: f.path,\n      type: f.mimeType === DIRECTORY_MIME_TYPE ? 'directory' as const : 'file' as const,\n      storedAt: f.storedAt,\n    }))\n  }\n\n  async restoreFile(stored: StoredHandle): Promise<OneFSResult<OneFSFile>> {\n    const file = await this.storage.getStoredFile(stored.id)\n    if (!file) {\n      return err('not_found', 'File not found in storage')\n    }\n\n    if (file.mimeType === DIRECTORY_MIME_TYPE) {\n      return err('not_found', 'Stored record is a directory - use restoreDirectory()')\n    }\n\n    if (file.path) {\n      try {\n        const { fs } = await this.loadModules()\n        const content = await fs.readFile(file.path)\n        const stat = await fs.stat(file.path)\n\n        const restored: OneFSFile = {\n          id: file.id,\n          name: file.name,\n          path: file.path,\n          content,\n          mimeType: file.mimeType,\n          size: content.byteLength,\n          lastModified: stat.mtime ? new Date(stat.mtime).getTime() : file.lastModified,\n        }\n        this.registerSessionFile(restored)\n        return ok(restored)\n      } catch (e) {\n        const message = e instanceof Error ? e.message : 'File no longer accessible'\n        return err('not_found', message, e)\n      }\n    }\n\n    const restoredFromCache: OneFSFile = {\n      id: file.id,\n      name: file.name,\n      path: file.path,\n      content: file.content,\n      mimeType: file.mimeType,\n      size: file.size,\n      lastModified: file.lastModified,\n    }\n    this.registerSessionFile(restoredFromCache)\n    return ok(restoredFromCache)\n  }\n\n  async restoreDirectory(stored: StoredHandle): Promise<OneFSResult<OneFSDirectory>> {\n    const file = await this.storage.getStoredFile(stored.id)\n    if (!file || file.mimeType !== DIRECTORY_MIME_TYPE) {\n      return err('not_found', 'Directory not found in storage')\n    }\n\n    if (!file.path) {\n      return err('not_found', 'Directory path not found')\n    }\n\n    try {\n      const { fs } = await this.loadModules()\n      const stat = await fs.stat(file.path)\n      if (!stat.isDirectory) {\n        return err('not_found', 'Path is not a directory')\n      }\n\n      return ok({\n        id: file.id,\n        name: file.name,\n        path: file.path,\n      })\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('No such file') || error.message?.includes('not found')) {\n        return err('not_found', 'Directory no longer exists at original location', e)\n      }\n      return err('io_error', error.message || 'Failed to restore directory', e)\n    }\n  }\n\n  async deleteFile(file: OneFSFile): Promise<OneFSResult<boolean>> {\n    const authorized = await this.resolveAuthorizedPath(file)\n    if (!authorized.ok) return authorized\n    const path = authorized.data\n\n    try {\n      const { fs } = await this.loadModules()\n      await fs.remove(path)\n      await this.storage.removeFile(file.id)\n      this.sessionPaths.delete(file.id)\n      return ok(true)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('No such file') || error.message?.includes('not found')) {\n        return err('not_found', 'File not found', e)\n      }\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to delete file', e)\n      }\n      return err('io_error', error.message || 'Failed to delete file', e)\n    }\n  }\n\n  async renameFile(file: OneFSFile, newName: string): Promise<OneFSResult<OneFSFile>> {\n    if (!isSafeEntryName(newName)) {\n      return err('io_error', 'Invalid file name')\n    }\n    const authorized = await this.resolveAuthorizedPath(file)\n    if (!authorized.ok) return authorized\n    const oldPath = authorized.data\n\n    try {\n      const { fs } = await this.loadModules()\n      const parentPath = this.splitParentPath(oldPath)\n      const newPath = parentPath\n        ? `${parentPath.parent}${parentPath.separator}${newName}`\n        : newName\n\n      await fs.rename(oldPath, newPath)\n\n      const updatedFile: OneFSFile = {\n        ...file,\n        name: newName,\n        path: newPath,\n        mimeType: getMimeType(newName),\n      }\n\n      // Update the stored record's metadata without rewriting cached content\n      // (the in-memory file.content may be stale). Best-effort: the disk\n      // rename already succeeded.\n      await this.storage\n        .updateFileMetadata(file.id, { name: newName, path: newPath, mimeType: updatedFile.mimeType })\n        .catch(() => {})\n      this.registerSessionFile(updatedFile)\n\n      return ok(updatedFile)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('No such file') || error.message?.includes('not found')) {\n        return err('not_found', 'File not found', e)\n      }\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to rename file', e)\n      }\n      return err('io_error', error.message || 'Failed to rename file', e)\n    }\n  }\n\n  async removeFromRecent(id: string): Promise<void> {\n    await this.storage.removeFile(id)\n    this.sessionPaths.delete(id)\n  }\n\n  async clearRecent(): Promise<void> {\n    await this.storage.clearFiles()\n    this.sessionPaths.clear()\n  }\n\n  dispose(): void {\n    this.storage.dispose()\n    this.sessionPaths.clear()\n  }\n\n  async getFileUrl(file: OneFSFile): Promise<string> {\n    if (!file.path) {\n      return URL.createObjectURL(new Blob([toArrayBuffer(file.content)], { type: file.mimeType }))\n    }\n\n    try {\n      const { core } = await this.loadModules()\n      return core.convertFileSrc(file.path)\n    } catch {\n      return URL.createObjectURL(new Blob([toArrayBuffer(file.content)], { type: file.mimeType }))\n    }\n  }\n\n  async getEntryUrl(entry: OneFSEntry): Promise<string | null> {\n    if (!entry.path || entry.kind !== 'file') {\n      return null\n    }\n\n    try {\n      const { core } = await this.loadModules()\n      return core.convertFileSrc(entry.path)\n    } catch {\n      return null\n    }\n  }\n}\n","import type {\n  OneFSAdapter,\n  OneFSFile,\n  OneFSOpenOptions,\n  OneFSSaveOptions,\n  OneFSDirectory,\n  OneFSDirectoryOptions,\n  OneFSReadDirectoryOptions,\n  OneFSScanOptions,\n  OneFSEntry,\n  StoredHandle,\n  StoredFile,\n  OneFSResult,\n} from '../types'\nimport { ok, err } from '../types'\nimport { IDBStorage } from '../storage/idb'\nimport { generateId, getMimeType, base64ToUint8Array, uint8ArrayToBase64, toArrayBuffer, sanitizeFileName, isPathWithin, isSafeEntryName, pickFilesViaInput } from '../utils'\n\ntype CapacitorFilesystem = typeof import('@capacitor/filesystem')\ntype CapacitorCore = typeof import('@capacitor/core')\n\nconst DIRECTORY_MIME_TYPE = 'inode/directory'\n\ninterface FilePickerResult {\n  files: Array<{\n    name: string\n    path?: string\n    mimeType?: string\n    modifiedAt?: number\n    size?: number\n  }>\n}\n\ninterface FilePicker {\n  pickFiles(options: {\n    types?: string[]\n    multiple?: boolean\n    readData?: boolean\n  }): Promise<FilePickerResult>\n}\n\nexport class CapacitorAdapter implements OneFSAdapter {\n  platform = 'capacitor' as const\n  private storage: IDBStorage\n  private filesystem: CapacitorFilesystem | null = null\n  private core: CapacitorCore | null = null\n  private persistByDefault: boolean\n  private scanLock: Promise<void> = Promise.resolve()\n  private sessionPaths = new Map<string, string>()\n\n  constructor(appName: string, maxRecentFiles = 10, persistByDefault = true) {\n    this.storage = new IDBStorage(appName, maxRecentFiles)\n    this.storage.onFilesPruned = (files) => {\n      void this.removePrunedCopies(files)\n    }\n    this.persistByDefault = persistByDefault\n  }\n\n  isSupported(): boolean {\n    if (typeof window === 'undefined') return false\n    const cap = (window as { Capacitor?: { isNativePlatform?: () => boolean } }).Capacitor\n    return cap?.isNativePlatform?.() ?? false\n  }\n\n  /**\n   * Delete the Documents copies backing pruned records so they don't\n   * accumulate as orphans on disk.\n   */\n  private async removePrunedCopies(files: StoredFile[]): Promise<void> {\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n      for (const f of files) {\n        if (!f.path || f.mimeType === DIRECTORY_MIME_TYPE || !this.isSafeDocumentsPath(f.path)) continue\n        await Filesystem.deleteFile({ path: f.path, directory: Directory.Documents }).catch(() => {})\n      }\n    } catch {\n      // Filesystem module unavailable\n    }\n  }\n\n  private async loadFilesystem(): Promise<CapacitorFilesystem> {\n    if (!this.filesystem) {\n      this.filesystem = await import('@capacitor/filesystem')\n    }\n    return this.filesystem\n  }\n\n  private async loadCore(): Promise<CapacitorCore> {\n    if (!this.core) {\n      this.core = await import('@capacitor/core')\n    }\n    return this.core\n  }\n\n  private async acquireScanLock(): Promise<() => void> {\n    let release: () => void\n    const next = new Promise<void>(resolve => { release = resolve })\n    const prev = this.scanLock\n    this.scanLock = next\n    await prev\n    return release!\n  }\n\n  private isSafeDocumentsPath(path: string): boolean {\n    if (!path || path.includes('\\0')) return false\n\n    const normalized = path.replace(/\\\\/g, '/')\n    if (normalized.startsWith('/') || normalized.startsWith('../')) return false\n\n    const segments = normalized.split('/')\n    return segments.every((segment) => segment.length > 0 && segment !== '.' && segment !== '..')\n  }\n\n  private registerSessionFile(file: Pick<OneFSFile, 'id' | 'path'>): void {\n    if (!file.path || !this.isSafeDocumentsPath(file.path)) return\n    this.sessionPaths.set(file.id, file.path)\n  }\n\n  private async resolveAuthorizedPath(file: OneFSFile): Promise<OneFSResult<string>> {\n    const requestedPath = file.path ?? `${file.id}_${sanitizeFileName(file.name)}`\n    if (!this.isSafeDocumentsPath(requestedPath)) {\n      return err('permission_denied', 'Invalid file path')\n    }\n\n    // Session paths first: after a rename the stored record can lag behind\n    // (metadata updates are best-effort), but the session map is authoritative\n    const livePath = this.sessionPaths.get(file.id)\n    if (livePath === requestedPath) {\n      return ok(requestedPath)\n    }\n\n    try {\n      const stored = await this.storage.getStoredFile(file.id)\n      if (stored?.path === requestedPath) {\n        return ok(requestedPath)\n      }\n\n      return err('permission_denied', 'File was not opened through this adapter')\n    } catch (e) {\n      return err('io_error', 'Failed to verify file provenance', e)\n    }\n  }\n\n  async openFile(options: OneFSOpenOptions = {}): Promise<OneFSResult<OneFSFile | OneFSFile[]>> {\n    const shouldPersist = options.persist ?? this.persistByDefault\n\n    const pluginResult = await this.pickFilesWithPlugin(options)\n    if (pluginResult) {\n      if (!pluginResult.ok) return pluginResult\n      const files = pluginResult.data\n      for (const file of files) {\n        this.registerSessionFile(file)\n        if (shouldPersist) {\n          this.storage.storeFileDeferred({ ...file, storedAt: Date.now() })\n        }\n      }\n      return ok(options.multiple ? files : files[0])\n    }\n\n    return this.pickFilesWithInput(options, shouldPersist)\n  }\n\n  /**\n   * Pick via @capawesome/capacitor-file-picker. Returns null only when the\n   * plugin is not installed; once the picker has run, errors (including user\n   * cancellation) are returned as results rather than falling back to the\n   * HTML input, which would open a second picker.\n   */\n  private async pickFilesWithPlugin(options: OneFSOpenOptions): Promise<OneFSResult<OneFSFile[]> | null> {\n    let FilePicker: FilePicker\n    try {\n      const module = await import('@capawesome/capacitor-file-picker' as string) as { FilePicker: FilePicker }\n      FilePicker = module.FilePicker\n      if (!FilePicker) return null\n    } catch {\n      return null\n    }\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n\n      const types = options.accept\n        ? [...new Set(options.accept.map(ext => getMimeType(ext)))]\n        : ['*/*']\n\n      const result = await FilePicker.pickFiles({\n        types,\n        multiple: options.multiple ?? false,\n        readData: false,\n      })\n\n      if (result.files.length === 0) {\n        return err('cancelled', 'No files selected')\n      }\n\n      const fileResults = await Promise.all(\n        result.files.map(async (picked) => {\n          const id = generateId()\n          const safeName = sanitizeFileName(picked.name)\n          const destPath = `${id}_${safeName}`\n\n          const fileData = await Filesystem.readFile({ path: picked.path! })\n          await Filesystem.writeFile({\n            path: destPath,\n            data: fileData.data,\n            directory: Directory.Documents,\n          })\n\n          const content = typeof fileData.data === 'string'\n            ? base64ToUint8Array(fileData.data)\n            : new Uint8Array(await (fileData.data as Blob).arrayBuffer())\n\n          return {\n            id,\n            name: picked.name,\n            path: destPath,\n            content,\n            mimeType: picked.mimeType || getMimeType(picked.name),\n            size: content.byteLength,\n            lastModified: picked.modifiedAt ?? Date.now(),\n          }\n        })\n      )\n\n      return ok(fileResults)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.toLowerCase().includes('cancel')) {\n        return err('cancelled', 'User cancelled file picker')\n      }\n      return err('io_error', error.message || 'Failed to open file', e)\n    }\n  }\n\n  private async pickFilesWithInput(\n    options: OneFSOpenOptions,\n    shouldPersist: boolean\n  ): Promise<OneFSResult<OneFSFile | OneFSFile[]>> {\n    const fileList = await pickFilesViaInput({\n      accept: options.accept?.join(',') ?? '*/*',\n      multiple: options.multiple ?? false,\n    })\n    if (!fileList) {\n      return err('cancelled', 'User cancelled file picker')\n    }\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n\n      const results = await Promise.all(\n        Array.from(fileList).map(async (file) => {\n          const content = new Uint8Array(await file.arrayBuffer())\n          return { file, content }\n        })\n      )\n\n      const filesOut: OneFSFile[] = []\n\n      for (const { file, content } of results) {\n        const id = generateId()\n        const safeName = sanitizeFileName(file.name)\n        const destPath = `${id}_${safeName}`\n\n        await Filesystem.writeFile({\n          path: destPath,\n          data: uint8ArrayToBase64(content),\n          directory: Directory.Documents,\n        })\n\n        const onefsFile: OneFSFile = {\n          id,\n          name: file.name,\n          path: destPath,\n          content,\n          mimeType: file.type || getMimeType(file.name),\n          size: content.byteLength,\n          lastModified: file.lastModified,\n        }\n\n        if (shouldPersist) {\n          this.storage.storeFileDeferred({ ...onefsFile, storedAt: Date.now() })\n        }\n        this.registerSessionFile(onefsFile)\n\n        filesOut.push(onefsFile)\n      }\n\n      return ok(options.multiple ? filesOut : filesOut[0])\n    } catch (e) {\n      const error = e as Error\n      return err('io_error', error.message || 'Failed to read file', e)\n    }\n  }\n\n  async saveFile(\n    file: OneFSFile,\n    content: Uint8Array | string,\n    options?: OneFSSaveOptions\n  ): Promise<OneFSResult<boolean>> {\n    const shouldPersist = options?.persist ?? this.persistByDefault\n    const authorized = await this.resolveAuthorizedPath(file)\n    if (!authorized.ok) return authorized\n    const fileName = authorized.data\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n\n      const contentArray = typeof content === 'string' ? new TextEncoder().encode(content) : content\n\n      await Filesystem.writeFile({\n        path: fileName,\n        data: uint8ArrayToBase64(contentArray),\n        directory: Directory.Documents,\n      })\n      this.registerSessionFile({ id: file.id, path: fileName })\n\n      if (shouldPersist) {\n        this.storage.storeFileDeferred({\n          id: file.id,\n          name: file.name,\n          path: fileName,\n          content: contentArray,\n          mimeType: file.mimeType,\n          size: contentArray.byteLength,\n          lastModified: Date.now(),\n          storedAt: Date.now(),\n        })\n      }\n\n      return ok(true)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to save file', e)\n      }\n      return err('io_error', error.message || 'Failed to save file', e)\n    }\n  }\n\n  async saveFileAs(content: Uint8Array | string, options: OneFSSaveOptions = {}): Promise<OneFSResult<OneFSFile>> {\n    const shouldPersist = options.persist ?? this.persistByDefault\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n\n      const contentArray = typeof content === 'string' ? new TextEncoder().encode(content) : content\n      const name = options.suggestedName ?? 'untitled'\n      const id = generateId()\n      const fileName = `${id}_${sanitizeFileName(name)}`\n\n      await Filesystem.writeFile({\n        path: fileName,\n        data: uint8ArrayToBase64(contentArray),\n        directory: Directory.Documents,\n      })\n\n      const file: OneFSFile = {\n        id,\n        name,\n        path: fileName,\n        content: contentArray,\n        mimeType: getMimeType(name),\n        size: contentArray.byteLength,\n        lastModified: Date.now(),\n      }\n\n      if (shouldPersist) {\n        this.storage.storeFileDeferred({ ...file, storedAt: Date.now() })\n      }\n      this.registerSessionFile(file)\n\n      return ok(file)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to save file', e)\n      }\n      return err('io_error', error.message || 'Failed to save file', e)\n    }\n  }\n\n  async openDirectory(_options: OneFSDirectoryOptions = {}): Promise<OneFSResult<OneFSDirectory>> {\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n\n      await Filesystem.readdir({\n        path: '',\n        directory: Directory.Documents,\n      })\n\n      const id = generateId()\n\n      return ok({\n        id,\n        name: 'Documents',\n        path: '',\n      })\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to access directory', e)\n      }\n      return err('io_error', error.message || 'Failed to open directory', e)\n    }\n  }\n\n  async readDirectory(\n    directory: OneFSDirectory,\n    options: OneFSReadDirectoryOptions = {}\n  ): Promise<OneFSResult<OneFSEntry[]>> {\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n\n      const result = await Filesystem.readdir({\n        path: directory.path ?? '',\n        directory: Directory.Documents,\n      })\n\n      const entries: OneFSEntry[] = []\n\n      for (const entry of result.files) {\n        if (!isSafeEntryName(entry.name)) continue\n        const entryName = entry.name\n        const filePath = directory.path ? `${directory.path}/${entryName}` : entryName\n\n        if (entry.type === 'directory') {\n          entries.push({\n            name: entryName,\n            kind: 'directory',\n            path: filePath,\n          })\n        } else {\n          if (options.skipStats) {\n            entries.push({\n              name: entryName,\n              kind: 'file',\n              path: filePath,\n            })\n          } else {\n            entries.push({\n              name: entryName,\n              kind: 'file',\n              size: entry.size,\n              lastModified: entry.mtime ?? Date.now(),\n              path: filePath,\n            })\n          }\n        }\n      }\n\n      return ok(entries)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('not found') || error.message?.includes('does not exist')) {\n        return err('not_found', 'Directory not found', e)\n      }\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to read directory', e)\n      }\n      return err('io_error', error.message || 'Failed to read directory', e)\n    }\n  }\n\n  async scanDirectory(\n    directory: OneFSDirectory,\n    options: OneFSScanOptions = {}\n  ): Promise<OneFSResult<OneFSEntry[]>> {\n    const release = await this.acquireScanLock()\n    try {\n      return await this._scanDirectoryImpl(directory, options)\n    } finally {\n      release()\n    }\n  }\n\n  private async _scanDirectoryImpl(\n    directory: OneFSDirectory,\n    options: OneFSScanOptions = {}\n  ): Promise<OneFSResult<OneFSEntry[]>> {\n    const { extensions, onProgress, onError, signal, skipStats } = options\n    const extensionSet = extensions?.length\n      ? new Set(extensions.map(e => e.toLowerCase().replace(/^\\./, '')))\n      : null\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n      const files: OneFSEntry[] = []\n      const directoriesToScan: string[] = [directory.path ?? '']\n      let totalScanned = 0\n\n      while (directoriesToScan.length > 0) {\n        if (signal?.aborted) {\n          return err('cancelled', 'Scan was cancelled')\n        }\n\n        const currentDir = directoriesToScan.pop()!\n\n        try {\n          const result = await Filesystem.readdir({\n            path: currentDir,\n            directory: Directory.Documents,\n          })\n\n          for (const entry of result.files) {\n            if (!isSafeEntryName(entry.name)) continue\n            const entryName = entry.name\n            const entryPath = currentDir ? `${currentDir}/${entryName}` : entryName\n\n            if (entry.type === 'directory') {\n              directoriesToScan.push(entryPath)\n            } else {\n              if (extensionSet) {\n                const ext = entryName.split('.').pop()?.toLowerCase()\n                if (!ext || !extensionSet.has(ext)) {\n                  continue\n                }\n              }\n\n              if (skipStats) {\n                files.push({\n                  name: entryName,\n                  kind: 'file',\n                  path: entryPath,\n                })\n              } else {\n                files.push({\n                  name: entryName,\n                  kind: 'file',\n                  size: entry.size,\n                  lastModified: entry.mtime ?? Date.now(),\n                  path: entryPath,\n                })\n              }\n            }\n\n            totalScanned++\n          }\n\n          if (onProgress && totalScanned % 100 === 0) {\n            onProgress(totalScanned, files.length)\n          }\n          if (totalScanned % 500 === 0) {\n            await new Promise(resolve => setTimeout(resolve, 0))\n          }\n        } catch (dirError) {\n          onError?.(currentDir, dirError)\n        }\n      }\n\n      if (onProgress) {\n        onProgress(totalScanned, files.length)\n      }\n\n      return ok(files)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('not found') || error.message?.includes('does not exist')) {\n        return err('not_found', 'Directory not found', e)\n      }\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to scan directory', e)\n      }\n      return err('io_error', error.message || 'Failed to scan directory', e)\n    }\n  }\n\n  async readFileFromDirectory(\n    directory: OneFSDirectory,\n    entry: OneFSEntry,\n    options?: { maxBytes?: number }\n  ): Promise<OneFSResult<OneFSFile>> {\n    if (!entry.path || entry.kind !== 'file') {\n      return err('not_supported', 'Cannot read file without path')\n    }\n\n    if (!this.isSafeDocumentsPath(entry.path)) {\n      return err('permission_denied', 'Invalid file path')\n    }\n\n    if (directory.path && !isPathWithin(entry.path, directory.path)) {\n      return err('permission_denied', 'Path is outside the expected directory')\n    }\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n      const { Capacitor } = await this.loadCore()\n\n      if (options?.maxBytes && entry.size && entry.size > options.maxBytes) {\n        const uri = await Filesystem.getUri({\n          path: entry.path,\n          directory: Directory.Documents,\n        })\n        const nativeUrl = Capacitor.convertFileSrc(uri.uri)\n\n        const response = await fetch(nativeUrl, {\n          headers: { Range: `bytes=0-${options.maxBytes - 1}` }\n        })\n\n        if (response.ok || response.status === 206) {\n          const arrayBuffer = await response.arrayBuffer()\n          const content = new Uint8Array(arrayBuffer)\n          const partialFile: OneFSFile = {\n            id: generateId(),\n            name: entry.name,\n            path: entry.path,\n            content,\n            mimeType: getMimeType(entry.name),\n            size: content.byteLength,\n            lastModified: entry.lastModified ?? Date.now(),\n          }\n          this.registerSessionFile(partialFile)\n\n          return ok(partialFile)\n        }\n      }\n\n      const fileData = await Filesystem.readFile({\n        path: entry.path,\n        directory: Directory.Documents,\n      })\n\n      let content: Uint8Array\n      if (fileData.data instanceof Blob) {\n        content = new Uint8Array(await fileData.data.arrayBuffer())\n      } else {\n        content = base64ToUint8Array(fileData.data as string)\n      }\n\n      const loadedFile: OneFSFile = {\n        id: generateId(),\n        name: entry.name,\n        path: entry.path,\n        content,\n        mimeType: getMimeType(entry.name),\n        size: content.byteLength,\n        lastModified: entry.lastModified ?? Date.now(),\n      }\n      this.registerSessionFile(loadedFile)\n\n      return ok(loadedFile)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('not found') || error.message?.includes('does not exist')) {\n        return err('not_found', 'File not found', e)\n      }\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to read file', e)\n      }\n      return err('io_error', error.message || 'Failed to read file', e)\n    }\n  }\n\n  async getFileUrl(file: OneFSFile): Promise<string> {\n    if (!file.path) {\n      return URL.createObjectURL(new Blob([toArrayBuffer(file.content)], { type: file.mimeType }))\n    }\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n      const { Capacitor } = await this.loadCore()\n\n      const result = await Filesystem.getUri({\n        path: file.path,\n        directory: Directory.Documents,\n      })\n\n      return Capacitor.convertFileSrc(result.uri)\n    } catch {\n      return URL.createObjectURL(new Blob([toArrayBuffer(file.content)], { type: file.mimeType }))\n    }\n  }\n\n  async getEntryUrl(entry: OneFSEntry): Promise<string | null> {\n    if (!entry.path || entry.kind !== 'file') {\n      return null\n    }\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n      const { Capacitor } = await this.loadCore()\n\n      const result = await Filesystem.getUri({\n        path: entry.path,\n        directory: Directory.Documents,\n      })\n\n      return Capacitor.convertFileSrc(result.uri)\n    } catch {\n      return null\n    }\n  }\n\n  async getRecentFiles(): Promise<StoredHandle[]> {\n    const files = await this.storage.getStoredFiles()\n    return files.map(f => ({\n      id: f.id,\n      name: f.name,\n      path: f.path,\n      type: f.mimeType === DIRECTORY_MIME_TYPE ? 'directory' as const : 'file' as const,\n      storedAt: f.storedAt,\n    }))\n  }\n\n  async restoreFile(stored: StoredHandle): Promise<OneFSResult<OneFSFile>> {\n    const file = await this.storage.getStoredFile(stored.id)\n    if (!file || file.mimeType === DIRECTORY_MIME_TYPE) {\n      return err('not_found', 'File not found in storage')\n    }\n\n    if (file.path) {\n      if (!this.isSafeDocumentsPath(file.path)) {\n        return err('permission_denied', 'Invalid stored file path')\n      }\n\n      try {\n        const { Filesystem, Directory } = await this.loadFilesystem()\n\n        const fileData = await Filesystem.readFile({\n          path: file.path,\n          directory: Directory.Documents,\n        })\n\n        let content: Uint8Array\n        if (fileData.data instanceof Blob) {\n          content = new Uint8Array(await fileData.data.arrayBuffer())\n        } else {\n          content = base64ToUint8Array(fileData.data as string)\n        }\n\n        const stat = await Filesystem.stat({\n          path: file.path,\n          directory: Directory.Documents,\n        })\n\n        const restored: OneFSFile = {\n          id: file.id,\n          name: file.name,\n          path: file.path,\n          content,\n          mimeType: file.mimeType,\n          size: content.byteLength,\n          lastModified: stat.mtime ?? Date.now(),\n        }\n        this.registerSessionFile(restored)\n        return ok(restored)\n      } catch (e) {\n        const message = e instanceof Error ? e.message : 'File no longer accessible'\n        return err('not_found', message, e)\n      }\n    }\n\n    const restoredFromCache: OneFSFile = {\n      id: file.id,\n      name: file.name,\n      path: file.path,\n      content: file.content,\n      mimeType: file.mimeType,\n      size: file.size,\n      lastModified: file.lastModified,\n    }\n    this.registerSessionFile(restoredFromCache)\n    return ok(restoredFromCache)\n  }\n\n  async restoreDirectory(stored: StoredHandle): Promise<OneFSResult<OneFSDirectory>> {\n    if (stored.type !== 'directory') {\n      return err('not_found', 'Not a directory')\n    }\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n\n      await Filesystem.readdir({\n        path: stored.path ?? '',\n        directory: Directory.Documents,\n      })\n\n      return ok({\n        id: stored.id,\n        name: stored.name,\n        path: stored.path ?? '',\n      })\n    } catch (e) {\n      const error = e as Error\n      return err('not_found', error.message || 'Directory not found', e)\n    }\n  }\n\n  async deleteFile(file: OneFSFile): Promise<OneFSResult<boolean>> {\n    const authorized = await this.resolveAuthorizedPath(file)\n    if (!authorized.ok) return authorized\n    const path = authorized.data\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n      await Filesystem.deleteFile({\n        path,\n        directory: Directory.Documents,\n      })\n      await this.storage.removeFile(file.id)\n      this.sessionPaths.delete(file.id)\n      return ok(true)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('not found') || error.message?.includes('does not exist')) {\n        return err('not_found', 'File not found', e)\n      }\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to delete file', e)\n      }\n      return err('io_error', error.message || 'Failed to delete file', e)\n    }\n  }\n\n  async renameFile(file: OneFSFile, newName: string): Promise<OneFSResult<OneFSFile>> {\n    if (!isSafeEntryName(newName)) {\n      return err('io_error', 'Invalid file name')\n    }\n\n    const authorized = await this.resolveAuthorizedPath(file)\n    if (!authorized.ok) return authorized\n    const oldPath = authorized.data\n    const parentDir = oldPath.includes('/') ? oldPath.substring(0, oldPath.lastIndexOf('/')) : ''\n    const newPath = parentDir ? `${parentDir}/${newName}` : newName\n    if (!this.isSafeDocumentsPath(newPath)) {\n      return err('io_error', 'Invalid file name')\n    }\n\n    try {\n      const { Filesystem, Directory } = await this.loadFilesystem()\n      await Filesystem.rename({\n        from: oldPath,\n        to: newPath,\n        directory: Directory.Documents,\n        toDirectory: Directory.Documents,\n      })\n\n      const updatedFile: OneFSFile = {\n        ...file,\n        name: newName,\n        path: newPath,\n        mimeType: getMimeType(newName),\n      }\n\n      // Update the stored record's metadata without rewriting cached content\n      // (the in-memory file.content may be stale). Best-effort: the disk\n      // rename already succeeded.\n      await this.storage\n        .updateFileMetadata(file.id, { name: newName, path: newPath, mimeType: updatedFile.mimeType })\n        .catch(() => {})\n      this.registerSessionFile(updatedFile)\n\n      return ok(updatedFile)\n    } catch (e) {\n      const error = e as Error\n      if (error.message?.includes('not found') || error.message?.includes('does not exist')) {\n        return err('not_found', 'File not found', e)\n      }\n      if (error.message?.includes('Permission denied')) {\n        return err('permission_denied', 'Permission denied to rename file', e)\n      }\n      return err('io_error', error.message || 'Failed to rename file', e)\n    }\n  }\n\n  async removeFromRecent(id: string): Promise<void> {\n    await this.storage.removeFile(id)\n    this.sessionPaths.delete(id)\n  }\n\n  async clearRecent(): Promise<void> {\n    await this.storage.clearFiles()\n    this.sessionPaths.clear()\n  }\n\n  dispose(): void {\n    this.storage.dispose()\n    this.sessionPaths.clear()\n  }\n}\n","import type {\n  OneFSAdapter,\n  OneFSConfig,\n  OneFSFile,\n  OneFSOpenOptions,\n  OneFSSaveOptions,\n  OneFSDirectory,\n  OneFSDirectoryOptions,\n  OneFSReadDirectoryOptions,\n  OneFSScanOptions,\n  OneFSEntry,\n  StoredHandle,\n  Platform,\n  OneFSResult,\n  OneFSErrorCode,\n  OneFSError,\n  OneFSCapabilities,\n  PermissionMode,\n  PermissionStatus,\n} from './types'\nimport { ok, err, PLATFORM_CAPABILITIES } from './types'\n\nimport { FSAccessAdapter } from './adapters/fs-access'\nimport { PickerIDBAdapter } from './adapters/picker-idb'\nimport { TauriAdapter } from './adapters/tauri'\nimport { CapacitorAdapter } from './adapters/capacitor'\nimport { toArrayBuffer, uint8ArrayToBase64 } from './utils'\n\nexport type {\n  OneFSAdapter,\n  OneFSConfig,\n  OneFSFile,\n  OneFSOpenOptions,\n  OneFSSaveOptions,\n  OneFSDirectory,\n  OneFSDirectoryOptions,\n  OneFSReadDirectoryOptions,\n  OneFSScanOptions,\n  OneFSEntry,\n  StoredHandle,\n  Platform,\n  OneFSResult,\n  OneFSErrorCode,\n  OneFSError,\n  OneFSCapabilities,\n  PermissionMode,\n  PermissionStatus,\n}\n\nexport { ok, err, PLATFORM_CAPABILITIES }\nexport { FSAccessAdapter, PickerIDBAdapter, TauriAdapter, CapacitorAdapter }\n\n/**\n * Cross-platform file system abstraction.\n *\n * Provides a unified API for file operations across:\n * - Modern browsers (File System Access API)\n * - Fallback browsers (file picker + IndexedDB)\n * - Tauri desktop apps\n * - Capacitor mobile apps\n *\n * @example\n * ```typescript\n * const fs = createOneFS({ appName: 'myapp' })\n *\n * // Open a file\n * const result = await fs.openFile({ accept: ['.json'] })\n * if (result.ok) {\n *   const text = fs.readAsText(result.data)\n * }\n *\n * // Check platform capabilities\n * if (fs.capabilities.canSaveInPlace) {\n *   await fs.saveFile(file, newContent)\n * } else {\n *   // Will trigger download on web-fallback\n *   await fs.saveFile(file, newContent)\n * }\n * ```\n */\nexport class OneFS {\n  private adapter: OneFSAdapter\n  private config: OneFSConfig\n\n  constructor(config: OneFSConfig) {\n    this.config = {\n      maxRecentFiles: 10,\n      persistByDefault: true,\n      useNativeFSAccess: true,\n      ...config,\n    }\n\n    this.adapter = this.selectAdapter()\n  }\n\n  private selectAdapter(): OneFSAdapter {\n    const { appName, maxRecentFiles, persistByDefault, useNativeFSAccess, preferredAdapter } = this.config\n\n    const adapters: Record<Platform, () => OneFSAdapter> = {\n      tauri: () => new TauriAdapter(appName, maxRecentFiles, persistByDefault),\n      capacitor: () => new CapacitorAdapter(appName, maxRecentFiles, persistByDefault),\n      'web-fs-access': () => new FSAccessAdapter(appName, maxRecentFiles, persistByDefault),\n      'web-fallback': () => new PickerIDBAdapter(appName, maxRecentFiles, persistByDefault),\n    }\n\n    if (preferredAdapter && adapters[preferredAdapter]) {\n      const adapter = adapters[preferredAdapter]()\n      if (adapter.isSupported()) return adapter\n    }\n\n    const order: Platform[] = useNativeFSAccess\n      ? ['tauri', 'capacitor', 'web-fs-access', 'web-fallback']\n      : ['tauri', 'capacitor', 'web-fallback']\n\n    for (const platform of order) {\n      const adapter = adapters[platform]()\n      if (adapter.isSupported()) return adapter\n    }\n\n    return new PickerIDBAdapter(appName, maxRecentFiles, persistByDefault)\n  }\n\n  /** Current platform identifier */\n  get platform(): Platform {\n    return this.adapter.platform\n  }\n\n  /** Platform capabilities (what operations are available) */\n  get capabilities(): OneFSCapabilities {\n    return PLATFORM_CAPABILITIES[this.adapter.platform]\n  }\n\n  /** Whether directory operations are supported */\n  get supportsDirectories(): boolean {\n    return !!this.capabilities.openDirectory\n  }\n\n  /** Whether file handles can be persisted and restored across sessions */\n  get supportsHandlePersistence(): boolean {\n    return this.adapter.platform === 'web-fs-access'\n  }\n\n  /**\n   * Open a file picker dialog.\n   * @param options - Picker configuration (accept, startIn, persist)\n   * @returns The selected file with content loaded as Uint8Array\n   */\n  async openFile(options?: OneFSOpenOptions): Promise<OneFSResult<OneFSFile>>\n  async openFile(options: OneFSOpenOptions & { multiple: true }): Promise<OneFSResult<OneFSFile[]>>\n  async openFile(options: OneFSOpenOptions = {}): Promise<OneFSResult<OneFSFile | OneFSFile[]>> {\n    return this.adapter.openFile(options)\n  }\n\n  /**\n   * Open a file picker for multiple files.\n   * Convenience wrapper around openFile with multiple: true.\n   */\n  async openFiles(options: Omit<OneFSOpenOptions, 'multiple'> = {}): Promise<OneFSResult<OneFSFile[]>> {\n    const result = await this.adapter.openFile({ ...options, multiple: true })\n    if (!result.ok) return result\n    const data = Array.isArray(result.data) ? result.data : [result.data]\n    return ok(data)\n  }\n\n  /**\n   * Save content to an existing file.\n   *\n   * Behavior varies by platform:\n   * - web-fs-access: Saves in-place to original location\n   * - tauri: Saves in-place to original location\n   * - web-fallback: Triggers a download (not in-place)\n   * - capacitor: Saves to app's Data directory (not original location)\n   *\n   * Check `capabilities.canSaveInPlace` to detect behavior.\n   *\n   * @param file - The file to save to (must have handle/path from openFile)\n   * @param content - New content as string or Uint8Array\n   * @param options - Save options (persist)\n   */\n  async saveFile(file: OneFSFile, content: Uint8Array | string, options?: OneFSSaveOptions): Promise<OneFSResult<boolean>> {\n    return this.adapter.saveFile(file, content, options)\n  }\n\n  /**\n   * Open a save dialog and write content to a new file.\n   * @param content - Content to save as string or Uint8Array\n   * @param options - Save options (suggestedName, accept, persist)\n   * @returns The newly created file\n   */\n  async saveFileAs(content: Uint8Array | string, options?: OneFSSaveOptions): Promise<OneFSResult<OneFSFile>> {\n    return this.adapter.saveFileAs(content, options)\n  }\n\n  /**\n   * Open a directory picker dialog.\n   * Not available on web-fallback platform.\n   * @param options - Directory picker options (mode, persist)\n   */\n  async openDirectory(options?: OneFSDirectoryOptions): Promise<OneFSResult<OneFSDirectory>> {\n    if (!this.adapter.openDirectory) {\n      return err('not_supported', `Directory operations not supported on ${this.adapter.platform}`)\n    }\n    return this.adapter.openDirectory(options)\n  }\n\n  /**\n   * List directory contents as entries (metadata only, no content loaded).\n   * Use readFileFromDirectory() to load a specific file's content.\n   *\n   * @param directory - Directory from openDirectory()\n   * @returns Array of file and directory entries with metadata\n   */\n  async readDirectory(directory: OneFSDirectory, options?: OneFSReadDirectoryOptions): Promise<OneFSResult<OneFSEntry[]>> {\n    if (!this.adapter.readDirectory) {\n      return err('not_supported', `Directory operations not supported on ${this.adapter.platform}`)\n    }\n    return this.adapter.readDirectory(directory, options)\n  }\n\n  /**\n   * Load a specific file's content from a directory.\n   * Use this instead of readDirectory to avoid loading all files at once.\n   *\n   * @param directory - Directory containing the file\n   * @param entry - Entry from readDirectory() with kind === 'file'\n   * @param options - Optional: maxBytes to read only first N bytes (for metadata extraction)\n   * @returns The file with content loaded\n   */\n  async readFileFromDirectory(directory: OneFSDirectory, entry: OneFSEntry, options?: { maxBytes?: number }): Promise<OneFSResult<OneFSFile>> {\n    if (!this.adapter.readFileFromDirectory) {\n      return err('not_supported', `Directory operations not supported on ${this.adapter.platform}`)\n    }\n    return this.adapter.readFileFromDirectory(directory, entry, options)\n  }\n\n  /**\n   * Recursively scan a directory for files.\n   * Available on Tauri and Capacitor platforms.\n   *\n   * @param directory - Directory to scan\n   * @param options - Scan options (extensions filter, progress callback, abort signal)\n   */\n  async scanDirectory(directory: OneFSDirectory, options?: OneFSScanOptions): Promise<OneFSResult<OneFSEntry[]>> {\n    if (!this.adapter.scanDirectory) {\n      return err('not_supported', `Recursive scanning not supported on ${this.adapter.platform}`)\n    }\n    return this.adapter.scanDirectory(directory, options)\n  }\n\n  /**\n   * Get an efficient streaming URL for a directory entry without loading content.\n   * Available on Tauri and Capacitor platforms. Use for audio/video where you don't need file in memory.\n   *\n   * @param entry - Entry from readDirectory() or scanDirectory()\n   * @returns Asset URL or null if not supported/available\n   */\n  async getEntryUrl(entry: OneFSEntry): Promise<OneFSResult<string>> {\n    if (!this.adapter.getEntryUrl) {\n      return err('not_supported', `getEntryUrl not supported on ${this.adapter.platform}`)\n    }\n    try {\n      const url = await this.adapter.getEntryUrl(entry)\n      if (!url) {\n        return err('not_found', 'No URL available for entry')\n      }\n      return ok(url)\n    } catch (e) {\n      return err('io_error', 'Failed to get entry URL', e)\n    }\n  }\n\n  /**\n   * Get an efficient URL for a file without re-reading content.\n   * Available on Tauri and Capacitor. Falls back to blob URL.\n   *\n   * @param file - File to get URL for\n   */\n  async getFileUrl(file: OneFSFile): Promise<OneFSResult<string>> {\n    if (!this.adapter.getFileUrl) {\n      return err('not_supported', `getFileUrl not supported on ${this.adapter.platform}`)\n    }\n    try {\n      const url = await this.adapter.getFileUrl(file)\n      return ok(url)\n    } catch (e) {\n      return err('io_error', 'Failed to get file URL', e)\n    }\n  }\n\n  /**\n   * Get list of recently opened files.\n   * On web-fs-access, these can be restored without picker.\n   * On other platforms, content is restored from IndexedDB cache.\n   */\n  async getRecentFiles(): Promise<StoredHandle[]> {\n    return this.adapter.getRecentFiles()\n  }\n\n  /**\n   * Restore a previously opened file.\n   * On web-fs-access: Re-reads from disk (may request permission)\n   * On other platforms: Returns cached content from IndexedDB\n   *\n   * @param stored - Handle from getRecentFiles()\n   */\n  async restoreFile(stored: StoredHandle): Promise<OneFSResult<OneFSFile>> {\n    return this.adapter.restoreFile(stored)\n  }\n\n  /**\n   * Restore a previously opened directory.\n   * Only available on web-fs-access platform.\n   *\n   * @param stored - Handle from getRecentFiles() with type === 'directory'\n   * @param mode - Permission mode to request ('read' or 'readwrite')\n   */\n  async restoreDirectory(stored: StoredHandle, mode?: PermissionMode): Promise<OneFSResult<OneFSDirectory>> {\n    if (!this.adapter.restoreDirectory) {\n      return err('not_supported', `Directory restoration not supported on ${this.adapter.platform}`)\n    }\n    return this.adapter.restoreDirectory(stored, mode)\n  }\n\n  /**\n   * Check current permission status on a file or directory.\n   * Only available on web-fs-access platform - returns 'granted' on others.\n   *\n   * @param target - File or directory to check\n   * @param mode - Permission mode to check ('read' or 'readwrite')\n   */\n  async queryPermission(target: OneFSFile | OneFSDirectory, mode: PermissionMode): Promise<PermissionStatus> {\n    if (!this.adapter.queryPermission) {\n      return 'granted'\n    }\n    return this.adapter.queryPermission(target, mode)\n  }\n\n  /**\n   * Request permission on a file or directory.\n   * Only available on web-fs-access platform - returns ok(true) on others.\n   *\n   * @param target - File or directory to request permission for\n   * @param mode - Permission mode to request ('read' or 'readwrite')\n   */\n  async requestPermission(target: OneFSFile | OneFSDirectory, mode: PermissionMode): Promise<OneFSResult<boolean>> {\n    if (!this.adapter.requestPermission) {\n      return ok(true)\n    }\n    return this.adapter.requestPermission(target, mode)\n  }\n\n  /**\n   * Store a directory by a named key (separate from recent files).\n   * Useful for app preferences like \"output directory\".\n   * Only available on web-fs-access platform.\n   *\n   * @param key - Unique key to store the directory under\n   * @param directory - Directory to persist\n   */\n  async setNamedDirectory(key: string, directory: OneFSDirectory): Promise<OneFSResult<boolean>> {\n    if (!this.adapter.setNamedDirectory) {\n      return err('not_supported', `Named directory storage not supported on ${this.adapter.platform}`)\n    }\n    return this.adapter.setNamedDirectory(key, directory)\n  }\n\n  /**\n   * Retrieve a previously stored named directory.\n   * Only available on web-fs-access platform.\n   *\n   * @param key - Key the directory was stored under\n   * @param mode - Permission mode to request ('read' or 'readwrite')\n   */\n  async getNamedDirectory(key: string, mode?: PermissionMode): Promise<OneFSResult<OneFSDirectory>> {\n    if (!this.adapter.getNamedDirectory) {\n      return err('not_supported', `Named directory storage not supported on ${this.adapter.platform}`)\n    }\n    return this.adapter.getNamedDirectory(key, mode)\n  }\n\n  /**\n   * Remove a named directory from storage.\n   *\n   * @param key - Key the directory was stored under\n   */\n  async removeNamedDirectory(key: string): Promise<void> {\n    if (!this.adapter.removeNamedDirectory) return\n    return this.adapter.removeNamedDirectory(key)\n  }\n\n  /**\n   * Delete a file and remove it from storage.\n   * Available on web-fs-access, Tauri, and Capacitor platforms.\n   */\n  async deleteFile(file: OneFSFile): Promise<OneFSResult<boolean>> {\n    if (!this.adapter.deleteFile) {\n      return err('not_supported', `deleteFile not supported on ${this.adapter.platform}`)\n    }\n    try {\n      return await this.adapter.deleteFile(file)\n    } catch (e) {\n      return err('io_error', 'Failed to delete file', e)\n    }\n  }\n\n  /**\n   * Rename a file and update storage.\n   * Available on web-fs-access, Tauri, and Capacitor platforms.\n   */\n  async renameFile(file: OneFSFile, newName: string): Promise<OneFSResult<OneFSFile>> {\n    if (!this.adapter.renameFile) {\n      return err('not_supported', `renameFile not supported on ${this.adapter.platform}`)\n    }\n    if (!newName || typeof newName !== 'string') {\n      return err('io_error', 'New name must be a non-empty string')\n    }\n    try {\n      return await this.adapter.renameFile(file, newName)\n    } catch (e) {\n      return err('io_error', 'Failed to rename file', e)\n    }\n  }\n\n  /**\n   * Remove a file from the recent files list.\n   */\n  async removeFromRecent(id: string): Promise<void> {\n    return this.adapter.removeFromRecent(id)\n  }\n\n  /**\n   * Clear all recent files.\n   */\n  async clearRecent(): Promise<void> {\n    return this.adapter.clearRecent()\n  }\n\n  dispose(): void {\n    this.adapter.dispose?.()\n  }\n\n  // ─────────────────────────────────────────────────────────────\n  // Content conversion helpers\n  // ─────────────────────────────────────────────────────────────\n\n  /**\n   * Read file content as UTF-8 string.\n   */\n  readAsText(file: OneFSFile): string {\n    return new TextDecoder().decode(file.content)\n  }\n\n  /**\n   * Read file content as parsed JSON.\n   * Returns an error result if content is not valid JSON.\n   */\n  readAsJSON<T = unknown>(file: OneFSFile): OneFSResult<T> {\n    try {\n      return ok(JSON.parse(new TextDecoder().decode(file.content)))\n    } catch (e) {\n      return err('io_error', 'Failed to parse JSON', e)\n    }\n  }\n\n  /**\n   * Read file content as data URL (data:mime;base64,...).\n   */\n  readAsDataURL(file: OneFSFile): string {\n    return `data:${file.mimeType};base64,${uint8ArrayToBase64(file.content)}`\n  }\n\n  /**\n   * Read file content as Blob.\n   */\n  readAsBlob(file: OneFSFile): Blob {\n    return new Blob([toArrayBuffer(file.content)], { type: file.mimeType })\n  }\n\n  /**\n   * Read file content as object URL (blob:...).\n   * Remember to call URL.revokeObjectURL() when done.\n   */\n  readAsObjectURL(file: OneFSFile): string {\n    return URL.createObjectURL(this.readAsBlob(file))\n  }\n}\n\n/**\n * Create a new OneFS instance.\n *\n * @param config - Configuration options\n * @returns OneFS instance configured for the current platform\n *\n * @example\n * ```typescript\n * const fs = createOneFS({\n *   appName: 'myapp',\n *   maxRecentFiles: 20,\n *   persistByDefault: true,\n * })\n * ```\n */\nexport function createOneFS(config: OneFSConfig): OneFS {\n  return new OneFS(config)\n}\n"],"names":["DIRECTORY_MIME_TYPE","module","content"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBO,SAAS,GAAM,MAAyB;AAC7C,SAAO,EAAE,IAAI,MAAM,KAAA;AACrB;AAKO,SAAS,IAAO,MAAsB,SAAiB,OAAiC;AAC7F,SAAO,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,SAAS,QAAM;AACpD;AA0KO,MAAM,wBAA6D;AAAA,EACxE,iBAAiB;AAAA,IACf,UAAU;AAAA,IACV,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,eAAe;AAAA,IACf,mBAAmB;AAAA,IAC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