/**
 * @typedef {Object} PlatformCrypto
 * @property {() => Promise<{rsaPub: string, rsaPriv: string, edPub: string, edPriv: string}>} generateKeys
 * @property {(size: number) => Promise<string>} randomBytes - Returns hex string
 * @property {(data: string) => Promise<string>} sha256 - Returns hex hash
 * @property {(privateKey: string, message: string) => Promise<string>} signMessage
 * @property {(publicKey: string, message: string, signature: string) => Promise<boolean>} verifySignature
 * @property {(password: string, salt: string) => Promise<{dek: string, dak: string}>} deriveAuthKeys
 * @property {(data: string, key: string) => Promise<{content: string, iv: string, tag: string}>} encryptData
 * @property {(encryptedData: string, key: string, iv: string, tag: string, options?: object) => Promise<string>} decryptData
 * @property {(items: Array) => Promise<Array>} decryptBatch
 * @property {(items: Array) => Promise<Array>} verifyBatch
 * @property {(publicKey: string, data: string) => Promise<string>} publicEncrypt
 * @property {(privateKey: string, encryptedHex: string) => Promise<string>} privateDecrypt
 */

/**
 * @typedef {Object} PlatformSession
 * @property {(data: object) => Promise<void>} save
 * @property {() => Promise<object|null>} load
 * @property {() => Promise<void>} clear
 */

/**
 * @typedef {Object} PlatformSettings
 * @property {(key: string) => Promise<any>} get
 * @property {(key: string, value: any) => Promise<void>} set
 */

/**
 * @typedef {Object} PlatformIdle
 * @property {() => Promise<number>} getSystemIdleTime - Returns idle time in seconds
 * @property {(callback: function) => void} onIdleStateChanged
 * @property {() => void} removeIdleStateListener
 */

/**
 * @typedef {Object} PlatformLinks
 * @property {(url: string) => void} openExternal
 * @property {(url: string) => Promise<object>} fetchMetadata
 */

/**
 * @typedef {Object} PlatformScreenCapture
 * @property {() => Promise<Array>} getScreenSources
 */

/**
 * @typedef {Object} PlatformWindowControls
 * @property {() => void} minimize
 * @property {() => void} maximize
 * @property {() => void} close
 */

/**
 * @typedef {Object} PlatformRecording
 * @property {() => Promise<string>} getDefaultFolder - Default recording root (e.g. %APPDATA%/Brycord/recordings)
 * @property {() => Promise<{ok: boolean, path: string|null}>} pickFolder - Native folder picker dialog
 * @property {(dir: string) => Promise<{valid: boolean, error?: string|null}>} validateFolder
 * @property {(dir?: string|null) => Promise<{ok: boolean, error?: string|null}>} openFolder - Reveal the given (or default) root in file explorer
 * @property {(payload: {rootDir?: string|null, sessionId: string}) => Promise<{ok: boolean, error?: string|null}>} openSessionFolder
 * @property {(payload: {sessionId: string, rootDir?: string|null, channelId?: string|null, channelName?: string|null, startedAt: number}) => Promise<{ok: boolean, error?: string|null, rootDir?: string, sessionDir?: string}>} startSession
 * @property {(payload: {sessionId: string, participantId: string, displayName?: string|null, joinedOffsetMs: number}) => Promise<{ok: boolean, error?: string|null, trackKey?: string, fileName?: string}>} openTrack
 * @property {(payload: {sessionId: string, trackKey: string, chunk: ArrayBuffer}) => Promise<{ok: boolean, error?: string|null}>} append
 * @property {(payload: {sessionId: string, trackKey: string, leftOffsetMs?: number|null}) => Promise<{ok: boolean, error?: string|null}>} closeTrack
 * @property {(payload: {sessionId: string, endedAt: number}) => Promise<{ok: boolean, error?: string|null, dir?: string}>} finalize
 * @property {(payload?: {rootDir?: string|null}) => Promise<{ok: boolean, sessions: Array<{sessionId: string, sessionDir: string, channelId: string|null, channelName: string|null, startedAt: number, participantCount: number, trackCount: number}>}>} listRecoverable
 * @property {(payload: {sessionDir: string, action: 'keep'|'delete'}) => Promise<{ok: boolean, error?: string|null}>} recoverSession
 */

/**
 * @typedef {Object} PlatformUpdates
 * @property {() => Promise<object>} checkUpdate
 * @property {() => Promise<void>} [installUpdate] - Download and install APK (Android only)
 * @property {(callback: function) => void} [onDownloadProgress] - Listen for download progress events (Android only)
 */

/**
 * @typedef {Object} PlatformSearchDB
 * @property {(dbKeyHex: string, userId: string) => Promise<void>} open
 * @property {() => Promise<void>} close
 * @property {() => Promise<void>} save
 * @property {(messages: Array) => void} indexMessages
 * @property {(params: object) => Array} search
 * @property {(messageId: string) => boolean} isIndexed
 * @property {() => boolean} isOpen
 * @property {() => object} getStats
 */

/**
 * @typedef {Object} PlatformVoiceService
 * @property {(opts: {channelName: string, isMuted: boolean, isDeafened: boolean}) => Promise<void>} startService
 * @property {() => Promise<void>} stopService
 * @property {(opts: {channelName?: string, isMuted?: boolean, isDeafened?: boolean}) => Promise<void>} updateNotification
 * @property {(callback: function) => Promise<{remove: function}>} addNotificationActionListener
 */

/**
 * @typedef {Object} PlatformSystemBars
 * @property {(opts: {statusBarColor: string, navigationBarColor: string, isDarkContent: boolean}) => Promise<void>} setColors
 */

/**
 * @typedef {Object} PlatformFeatures
 * @property {boolean} hasWindowControls
 * @property {boolean} hasScreenCapture
 * @property {boolean} hasNativeUpdates
 * @property {boolean} hasSearch
 * @property {boolean} hasVoiceService
 * @property {boolean} hasSystemBars
 */

/**
 * @typedef {Object} Platform
 * @property {PlatformCrypto} crypto
 * @property {PlatformSession|null} session
 * @property {PlatformSettings|null} settings
 * @property {PlatformIdle|null} idle
 * @property {PlatformLinks} links
 * @property {PlatformScreenCapture|null} screenCapture
 * @property {PlatformWindowControls|null} windowControls
 * @property {PlatformRecording|null} recording
 * @property {PlatformUpdates|null} updates
 * @property {PlatformSearchDB|null} searchDB
 * @property {PlatformVoiceService|null} voiceService
 * @property {PlatformSystemBars|null} systemBars
 * @property {PlatformFeatures} features
 */

/**
 * @typedef {Object} PlatformFeaturesExtensions
 * @property {boolean} [hasRecording]
 */

export {};
