/*
 * Copyright (c) 2023-2025 Datalayer, Inc.
 * Distributed under the terms of the Modified BSD License.
 */
import { asArray } from '../utils/index.js';
import { asUser } from './User.js';
export function asTeam(t, organizationId) {
    let members = new Array();
    if (t.members) {
        members = asArray(t.members).map(m => {
            const member = asUser(m);
            return member;
        });
    }
    const team = {
        id: t.uid,
        handle: t.handle_s,
        type: 'team',
        name: t.name_t,
        description: t.description_t,
        public: t.public_b,
        members,
        organization: {
            id: organizationId,
        },
        creationDate: new Date(t.creation_ts_dt),
        setMembers(members) {
            this.members = members;
        },
    };
    return team;
}
