/*
 * Copyright (c) 2023-2025 Datalayer, Inc.
 * Distributed under the terms of the Modified BSD License.
 */
import { validateJSON } from '../api/utils/validation.js';
/**
 * User model representing a Datalayer platform user.
 * Provides rich functionality for accessing user data and authentication providers.
 */
export class UserDTO {
    _data;
    /**
     * Create a User instance.
     *
     * @param data - User data from API
     * @param client - Client instance (currently unused but kept for compatibility)
     */
    constructor(data, client) {
        this._data = data;
    }
    // Basic properties
    get id() {
        return this._data.id;
    }
    get uid() {
        return this._data.uid;
    }
    get email() {
        return this._data.email_s;
    }
    get handle() {
        return this._data.handle_s;
    }
    get firstName() {
        return this._data.first_name_t;
    }
    get lastName() {
        return this._data.last_name_t;
    }
    get displayName() {
        return `${this.firstName} ${this.lastName}`.trim();
    }
    get avatarUrl() {
        return this._data.avatar_url_s;
    }
    // ========================================================================
    // Utility Methods
    // ========================================================================
    /**
     * Get user data in camelCase format.
     * Returns only the core fields that consumers need.
     * This provides a stable interface regardless of API changes.
     *
     * @returns Core user data with camelCase properties
     */
    toJSON() {
        const obj = {
            id: this.id,
            uid: this.uid,
            firstName: this.firstName,
            lastName: this.lastName,
            displayName: this.displayName,
            email: this.email,
            handle: this.handle,
            avatarUrl: this.avatarUrl,
        };
        validateJSON(obj, 'User');
        return obj;
    }
    /**
     * Get the raw user data exactly as received from the API.
     * This preserves the original snake_case naming from the API response.
     *
     * @returns Raw user data from API
     */
    rawData() {
        return this._data;
    }
    /** String representation of the user. */
    toString() {
        return `User(${this.uid}, ${this.displayName})`;
    }
}
export default UserDTO;
