import {
  ImageResult,
  PlatformService,
  PlatformCapabilities,
} from "../PlatformService";
import { logger } from "../../utils/logger";
import { QueryExecResult } from "@/interfaces/database";

/**
 * Platform service implementation for Electron (desktop) platform.
 * Note: This is a placeholder implementation with most methods currently unimplemented.
 * Implements the PlatformService interface but throws "Not implemented" errors for most operations.
 *
 * @remarks
 * This service is intended for desktop application functionality through Electron.
 * Future implementations should provide:
 * - Native file system access
 * - Desktop camera integration
 * - System-level features
 */
export class ElectronPlatformService implements PlatformService {
  /**
   * Gets the capabilities of the Electron platform
   * @returns Platform capabilities object
   */
  getCapabilities(): PlatformCapabilities {
    return {
      hasFileSystem: false, // Not implemented yet
      hasCamera: false, // Not implemented yet
      isMobile: false,
      isIOS: false,
      hasFileDownload: false, // Not implemented yet
      needsFileHandlingInstructions: false,
    };
  }

  /**
   * Reads a file from the filesystem.
   * @param _path - Path to the file to read
   * @returns Promise that should resolve to file contents
   * @throws Error with "Not implemented" message
   * @todo Implement file reading using Electron's file system API
   */
  async readFile(_path: string): Promise<string> {
    throw new Error("Not implemented");
  }

  /**
   * Writes content to a file.
   * @param _path - Path where to write the file
   * @param _content - Content to write to the file
   * @throws Error with "Not implemented" message
   * @todo Implement file writing using Electron's file system API
   */
  async writeFile(_path: string, _content: string): Promise<void> {
    throw new Error("Not implemented");
  }

  /**
   * Deletes a file from the filesystem.
   * @param _path - Path to the file to delete
   * @throws Error with "Not implemented" message
   * @todo Implement file deletion using Electron's file system API
   */
  async deleteFile(_path: string): Promise<void> {
    throw new Error("Not implemented");
  }

  /**
   * Lists files in the specified directory.
   * @param _directory - Path to the directory to list
   * @returns Promise that should resolve to array of filenames
   * @throws Error with "Not implemented" message
   * @todo Implement directory listing using Electron's file system API
   */
  async listFiles(_directory: string): Promise<string[]> {
    throw new Error("Not implemented");
  }

  /**
   * Should open system camera to take a picture.
   * @returns Promise that should resolve to captured image data
   * @throws Error with "Not implemented" message
   * @todo Implement camera access using Electron's media APIs
   */
  async takePicture(): Promise<ImageResult> {
    logger.error("takePicture not implemented in Electron platform");
    throw new Error("Not implemented");
  }

  /**
   * Should open system file picker for selecting an image.
   * @returns Promise that should resolve to selected image data
   * @throws Error with "Not implemented" message
   * @todo Implement file picker using Electron's dialog API
   */
  async pickImage(): Promise<ImageResult> {
    logger.error("pickImage not implemented in Electron platform");
    throw new Error("Not implemented");
  }

  /**
   * Should handle deep link URLs for the desktop application.
   * @param _url - The deep link URL to handle
   * @throws Error with "Not implemented" message
   * @todo Implement deep link handling using Electron's protocol handler
   */
  async handleDeepLink(_url: string): Promise<void> {
    logger.error("handleDeepLink not implemented in Electron platform");
    throw new Error("Not implemented");
  }

  dbQuery(sql: string, params?: unknown[]): Promise<QueryExecResult> {
    throw new Error("Not implemented for " + sql + " with params " + params);
  }
  dbExec(sql: string, params?: unknown[]): Promise<{ changes: number; lastId?: number }> {
    throw new Error("Not implemented for " + sql + " with params " + params);
  }
}