"use strict";

/**
 * Security Methods Mixin
 */

export function OxyServicesSecurityMixin(Base) {
  return class extends Base {
    constructor(...args) {
      super(...args);
    }

    /**
     * Get user's security activity with pagination
     * @param limit - Number of results (default: 50, max: 100)
     * @param offset - Pagination offset (default: 0)
     * @param eventType - Optional filter by event type
     * @returns Security activity response with pagination
     */
    async getSecurityActivity(limit, offset, eventType) {
      try {
        const params = {};
        if (limit !== undefined) params.limit = limit;
        if (offset !== undefined) params.offset = offset;
        if (eventType) params.eventType = eventType;
        const response = await this.makeRequest('GET', '/api/security/activity', params, {
          cache: false
        });
        return response;
      } catch (error) {
        throw this.handleError(error);
      }
    }

    /**
     * Get recent security activity (convenience method)
     * @param limit - Number of recent events to fetch (default: 10)
     * @returns Array of recent security activities
     */
    async getRecentSecurityActivity(limit = 10) {
      try {
        const response = await this.getSecurityActivity(limit, 0);
        return response.data || [];
      } catch (error) {
        throw this.handleError(error);
      }
    }

    /**
     * Log private key exported event
     * @param deviceId - Optional device ID for tracking
     * @returns Promise that resolves when event is logged
     */
    async logPrivateKeyExported(deviceId) {
      try {
        await this.makeRequest('POST', '/api/security/activity/private-key-exported', {
          deviceId
        }, {
          cache: false
        });
      } catch (error) {
        // Don't throw - logging failures shouldn't break user flow
        // But log for monitoring
        if (__DEV__) {
          console.warn('[OxyServices] Failed to log private key exported event:', error);
        }
      }
    }

    /**
     * Log backup created event
     * @param deviceId - Optional device ID for tracking
     * @returns Promise that resolves when event is logged
     */
    async logBackupCreated(deviceId) {
      try {
        await this.makeRequest('POST', '/api/security/activity/backup-created', {
          deviceId
        }, {
          cache: false
        });
      } catch (error) {
        // Don't throw - logging failures shouldn't break user flow
        // But log for monitoring
        if (__DEV__) {
          console.warn('[OxyServices] Failed to log backup created event:', error);
        }
      }
    }
  };
}
//# sourceMappingURL=OxyServices.security.js.map