"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require("../../../../../Class/$");
const Holder_1 = require("../../../../../Class/Holder");
const MethodNotImplementedError_1 = require("../../../../../exception/MethodNotImplementedError");
const MediaStreamTrack_1 = require("../../../../../wrap/MediaStreamTrack");
const _ids_1 = require("../../../../_ids");
class GetVideoTracks extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['stream', 'init'],
            fo: ['tracks'],
            i: [],
            o: [],
        }, {
            input: {
                stream: {
                    ref: true,
                },
            },
            output: {
                tracks: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_GET_VIDEO_TRACKS);
    }
    async f({ stream }, done) {
        let _tracks;
        try {
            _tracks = await stream.getVideoTracks();
        }
        catch (err) {
            done(undefined, err);
        }
        const tracks = new (class Array extends _1.$ {
            constructor() {
                super(...arguments);
                this.__ = ['A'];
            }
            async append(a) {
                throw new MethodNotImplementedError_1.MethodNotImplementedError();
            }
            async put(i, data) {
                throw new MethodNotImplementedError_1.MethodNotImplementedError();
            }
            async at(i) {
                const track = _tracks[i];
                const _track = (0, MediaStreamTrack_1.wrapMediaStreamTrack)(track, this.__system);
                return _track;
            }
            async length() {
                return _tracks.length;
            }
            async indexOf(a) {
                throw new MethodNotImplementedError_1.MethodNotImplementedError();
            }
        })(this.__system);
        done({ tracks });
    }
}
exports.default = GetVideoTracks;
//# sourceMappingURL=index.js.map