/**
 * TVox v1.1.1
 * Referenced: 22.0.0
 * 
 * Dependencies:
 * tslib -- 1.14.1
 * rxjs -- 6.6.7
 * ms -- 2.1.2
 * debug -- 4.3.4
 * lodash-es -- 4.17.21
 * cookie -- 0.4.2
 * detect-browser -- 5.3.0
 * retry -- 0.12.0
 * eventemitter3 -- 4.0.7
 */

(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    typeof define === 'function' && define.amd ? define('TVox', ['exports'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TVox = {}));
})(this, (function (exports) { 'use strict';

    var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    function __extends$d(d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    }
    var __assign$4 = function() {
        __assign$4 = Object.assign || function __assign(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
            }
            return t;
        };
        return __assign$4.apply(this, arguments);
    };
    function __awaiter$d(thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    }

    var __extends$c = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var WebAPI =  (function () {
        function WebAPI(data) {
            this.code = data.code;
            this.exceptionName = data.exceptionName;
            this.cause = data.cause;
            this.stackTrace = data.stackTrace;
            this.localizedMessage = data.localizedMessage;
            this.message = data.message;
            this.suppressed = data.suppressed;
        }
        return WebAPI;
    }());
    var GenericObject =  (function (_super) {
        __extends$c(GenericObject, _super);
        function GenericObject(data) {
            var _this = _super.call(this, data) || this;
            _this.value = data.value;
            _this.field = data.field;
            _this.className = data.className || "GenericObjectException";
            return _this;
        }
        return GenericObject;
    }(WebAPI));
    var NoRouteToHost =  (function (_super) {
        __extends$c(NoRouteToHost, _super);
        function NoRouteToHost(data) {
            var _this = _super.call(this, data) || this;
            _this.exceptionName = data.exceptionName || "NoRouteToHostException";
            return _this;
        }
        return NoRouteToHost;
    }(WebAPI));
    var ReconnectingInProgress =  (function (_super) {
        __extends$c(ReconnectingInProgress, _super);
        function ReconnectingInProgress(data) {
            var _this = _super.call(this, data) || this;
            _this.exceptionName = data.exceptionName || "ReconnectingInProgressException";
            return _this;
        }
        return ReconnectingInProgress;
    }(WebAPI));
    var SocketClosed =  (function (_super) {
        __extends$c(SocketClosed, _super);
        function SocketClosed(data) {
            var _this = _super.call(this, data) || this;
            _this.exceptionName = data.exceptionName || "SocketClosedException";
            return _this;
        }
        return SocketClosed;
    }(WebAPI));
    var StopOpenSocket =  (function (_super) {
        __extends$c(StopOpenSocket, _super);
        function StopOpenSocket(data) {
            var _this = _super.call(this, data) || this;
            _this.exceptionName = data.exceptionName || "StopOpenSocketException";
            return _this;
        }
        return StopOpenSocket;
    }(WebAPI));
    var AuthorizationRequired =  (function (_super) {
        __extends$c(AuthorizationRequired, _super);
        function AuthorizationRequired(data) {
            var _this = _super.call(this, data) || this;
            _this.sessionId = data.sessionId;
            _this.exceptionName = data.exceptionName || "AuthorizationRequiredException";
            return _this;
        }
        AuthorizationRequired.CODE = 401;
        return AuthorizationRequired;
    }(WebAPI));
    var PasswordExpired =  (function (_super) {
        __extends$c(PasswordExpired, _super);
        function PasswordExpired() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        PasswordExpired.newInstance = function (username, checkPasswordSecurityEnabled) {
            var result = new PasswordExpired({
                clazz: null,
                code: PasswordExpired.CODE,
                exceptionName: "PasswordExpiredException",
                message: "Password expired",
            });
            result.username = username;
            result.checkPasswordSecurityEnabled = checkPasswordSecurityEnabled;
            return result;
        };
        PasswordExpired.CODE = 403;
        return PasswordExpired;
    }(WebAPI));
    var UserNotEnabledOnMcs =  (function (_super) {
        __extends$c(UserNotEnabledOnMcs, _super);
        function UserNotEnabledOnMcs() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        UserNotEnabledOnMcs.newInstance = function (username) {
            var result = new UserNotEnabledOnMcs({
                clazz: null,
                code: UserNotEnabledOnMcs.CODE,
                exceptionName: "UserNotEnabledOnMcsException",
                message: "Login via MCS not enabled for user",
            });
            result.username = username;
            return result;
        };
        UserNotEnabledOnMcs.CODE = 497;
        return UserNotEnabledOnMcs;
    }(WebAPI));
    var UserNotEnabled =  (function (_super) {
        __extends$c(UserNotEnabled, _super);
        function UserNotEnabled() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        UserNotEnabled.newInstance = function (username) {
            var result = new UserNotEnabled({
                clazz: null,
                code: UserNotEnabled.CODE,
                exceptionName: "UserNotEnabled",
                message: "Login not enabled for user",
            });
            result.username = username;
            return result;
        };
        UserNotEnabled.CODE = 498;
        return UserNotEnabled;
    }(WebAPI));
    var CallInProgress =  (function (_super) {
        __extends$c(CallInProgress, _super);
        function CallInProgress() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        CallInProgress.newInstance = function (callId) {
            var result = new CallInProgress({
                clazz: null,
                code: 803,
                exceptionName: "CallInProgressException",
                message: "Call is in progress",
            });
            result.callId = callId;
            return result;
        };
        return CallInProgress;
    }(WebAPI));
    var TimeoutResponse =  (function (_super) {
        __extends$c(TimeoutResponse, _super);
        function TimeoutResponse() {
            return _super.call(this, {
                code: 1003,
                clazz: null,
                exceptionName: "TimeoutResponseException",
                message: "Timeout has occurred",
            }) || this;
        }
        TimeoutResponse.newInstance = function (message) {
            var result = new TimeoutResponse();
            if (message) {
                result.message = message;
            }
            return result;
        };
        return TimeoutResponse;
    }(WebAPI));
    var CacheLimitSizeExceeded =  (function (_super) {
        __extends$c(CacheLimitSizeExceeded, _super);
        function CacheLimitSizeExceeded(data) {
            var _this = _super.call(this, data) || this;
            _this.exceededByte = data.exceededByte;
            return _this;
        }
        return CacheLimitSizeExceeded;
    }(WebAPI));
    var GenericObjectExists =  (function (_super) {
        __extends$c(GenericObjectExists, _super);
        function GenericObjectExists(data) {
            return _super.call(this, data) || this;
        }
        return GenericObjectExists;
    }(GenericObject));
    var GenericObjectFormat =  (function (_super) {
        __extends$c(GenericObjectFormat, _super);
        function GenericObjectFormat(data) {
            return _super.call(this, data) || this;
        }
        return GenericObjectFormat;
    }(GenericObject));
    var GenericObjectIsInUse =  (function (_super) {
        __extends$c(GenericObjectIsInUse, _super);
        function GenericObjectIsInUse(data) {
            var _this = _super.call(this, data) || this;
            _this.users = data.users;
            return _this;
        }
        return GenericObjectIsInUse;
    }(GenericObject));
    var GenericObjectMinSize =  (function (_super) {
        __extends$c(GenericObjectMinSize, _super);
        function GenericObjectMinSize(data) {
            var _this = _super.call(this, data) || this;
            _this.minSize = data.minSize;
            return _this;
        }
        return GenericObjectMinSize;
    }(GenericObject));
    var GenericObjectMaxSize =  (function (_super) {
        __extends$c(GenericObjectMaxSize, _super);
        function GenericObjectMaxSize(data) {
            var _this = _super.call(this, data) || this;
            _this.maxSize = data.maxSize;
            return _this;
        }
        return GenericObjectMaxSize;
    }(GenericObject));
    var GenericObjectRangeValue =  (function (_super) {
        __extends$c(GenericObjectRangeValue, _super);
        function GenericObjectRangeValue(data) {
            var _this = _super.call(this, data) || this;
            _this.minValue = data.minValue;
            _this.maxValue = data.maxValue;
            return _this;
        }
        return GenericObjectRangeValue;
    }(GenericObject));
    var GenericObjectMaxValue =  (function (_super) {
        __extends$c(GenericObjectMaxValue, _super);
        function GenericObjectMaxValue(data) {
            return _super.call(this, data) || this;
        }
        return GenericObjectMaxValue;
    }(GenericObjectRangeValue));
    var GenericObjectMinValue =  (function (_super) {
        __extends$c(GenericObjectMinValue, _super);
        function GenericObjectMinValue(data) {
            return _super.call(this, data) || this;
        }
        return GenericObjectMinValue;
    }(GenericObjectRangeValue));
    var GenericObjectRequiredDigitValue =  (function (_super) {
        __extends$c(GenericObjectRequiredDigitValue, _super);
        function GenericObjectRequiredDigitValue(data) {
            return _super.call(this, data) || this;
        }
        return GenericObjectRequiredDigitValue;
    }(GenericObject));
    var GenericObjectRequiredNumberValue =  (function (_super) {
        __extends$c(GenericObjectRequiredNumberValue, _super);
        function GenericObjectRequiredNumberValue(data) {
            return _super.call(this, data) || this;
        }
        return GenericObjectRequiredNumberValue;
    }(GenericObject));
    var GenericObjectSameSize =  (function (_super) {
        __extends$c(GenericObjectSameSize, _super);
        function GenericObjectSameSize(data) {
            var _this = _super.call(this, data) || this;
            _this.maxSize = data.maxSize;
            return _this;
        }
        return GenericObjectSameSize;
    }(GenericObject));
    var GenericObjectUnchangeable =  (function (_super) {
        __extends$c(GenericObjectUnchangeable, _super);
        function GenericObjectUnchangeable(data) {
            return _super.call(this, data) || this;
        }
        return GenericObjectUnchangeable;
    }(GenericObject));
    var LogoutNotEnable =  (function (_super) {
        __extends$c(LogoutNotEnable, _super);
        function LogoutNotEnable(data) {
            return _super.call(this, data) || this;
        }
        return LogoutNotEnable;
    }(GenericObject));
    var UseOfAgExternalNotEnableCauseNoMobilePhone =  (function (_super) {
        __extends$c(UseOfAgExternalNotEnableCauseNoMobilePhone, _super);
        function UseOfAgExternalNotEnableCauseNoMobilePhone(data) {
            return _super.call(this, data) || this;
        }
        return UseOfAgExternalNotEnableCauseNoMobilePhone;
    }(GenericObject));
    var GenericObjectWasNotFound =  (function (_super) {
        __extends$c(GenericObjectWasNotFound, _super);
        function GenericObjectWasNotFound(data) {
            return _super.call(this, data) || this;
        }
        return GenericObjectWasNotFound;
    }(GenericObject));
    var InvalidArgument =  (function (_super) {
        __extends$c(InvalidArgument, _super);
        function InvalidArgument(data) {
            return _super.call(this, data) || this;
        }
        return InvalidArgument;
    }(GenericObject));
    var InvalidAction =  (function (_super) {
        __extends$c(InvalidAction, _super);
        function InvalidAction(data) {
            return _super.call(this, data) || this;
        }
        return InvalidAction;
    }(GenericObject));
    var InvalidLicence =  (function (_super) {
        __extends$c(InvalidLicence, _super);
        function InvalidLicence(data) {
            return _super.call(this, data) || this;
        }
        return InvalidLicence;
    }(WebAPI));
    var LicenceExceeded =  (function (_super) {
        __extends$c(LicenceExceeded, _super);
        function LicenceExceeded(data) {
            return _super.call(this, data) || this;
        }
        return LicenceExceeded;
    }(WebAPI));
    var MaxRetryExceeded =  (function (_super) {
        __extends$c(MaxRetryExceeded, _super);
        function MaxRetryExceeded(data) {
            return _super.call(this, data) || this;
        }
        return MaxRetryExceeded;
    }(WebAPI));
    var NoFileOnCache =  (function (_super) {
        __extends$c(NoFileOnCache, _super);
        function NoFileOnCache(data) {
            var _this = _super.call(this, data) || this;
            _this.fileName = data.fileName;
            return _this;
        }
        return NoFileOnCache;
    }(WebAPI));
    var OperationIsNotAllowedToUser =  (function (_super) {
        __extends$c(OperationIsNotAllowedToUser, _super);
        function OperationIsNotAllowedToUser(data) {
            var _this = _super.call(this, data) || this;
            _this.sessionId = data.sessionId;
            _this.mandatoryPermission = data.mandatoryPermission;
            return _this;
        }
        return OperationIsNotAllowedToUser;
    }(GenericObject));
    var WriteOperationIsNotAllowedToUser =  (function (_super) {
        __extends$c(WriteOperationIsNotAllowedToUser, _super);
        function WriteOperationIsNotAllowedToUser(data) {
            return _super.call(this, data) || this;
        }
        return WriteOperationIsNotAllowedToUser;
    }(OperationIsNotAllowedToUser));
    var WrongSessionId =  (function (_super) {
        __extends$c(WrongSessionId, _super);
        function WrongSessionId(data) {
            var _this = _super.call(this, data) || this;
            _this.sessionId = data.sessionId;
            _this.newSessionId = data.newSessionId;
            return _this;
        }
        return WrongSessionId;
    }(WebAPI));
    var WrongVersion =  (function (_super) {
        __extends$c(WrongVersion, _super);
        function WrongVersion(data) {
            var _this = _super.call(this, data) || this;
            _this.sessionId = data.sessionId;
            _this.versionRequired = data.versionRequired;
            return _this;
        }
        return WrongVersion;
    }(WebAPI));
    var ConvertFile =  (function (_super) {
        __extends$c(ConvertFile, _super);
        function ConvertFile(data) {
            var _this = _super.call(this, data) || this;
            _this.reason = data.reason;
            return _this;
        }
        return ConvertFile;
    }(WebAPI));
    var GenericObjectRequired =  (function (_super) {
        __extends$c(GenericObjectRequired, _super);
        function GenericObjectRequired(data) {
            var _this = _super.call(this, data) || this;
            _this.mandatoryFields = data.mandatoryFields;
            return _this;
        }
        return GenericObjectRequired;
    }(GenericObject));
    var DeviceRequestFailed =  (function (_super) {
        __extends$c(DeviceRequestFailed, _super);
        function DeviceRequestFailed(data) {
            return _super.call(this, data) || this;
        }
        return DeviceRequestFailed;
    }(WebAPI));
    var DeviceClosed =  (function (_super) {
        __extends$c(DeviceClosed, _super);
        function DeviceClosed(data) {
            return _super.call(this, data) || this;
        }
        return DeviceClosed;
    }(WebAPI));
    var DeviceTimeout =  (function (_super) {
        __extends$c(DeviceTimeout, _super);
        function DeviceTimeout(data) {
            return _super.call(this, data) || this;
        }
        return DeviceTimeout;
    }(WebAPI));
    var TTS =  (function (_super) {
        __extends$c(TTS, _super);
        function TTS(data) {
            var _this = _super.call(this, data) || this;
            _this.result = data.result;
            return _this;
        }
        return TTS;
    }(WebAPI));
    var WidgetFormUpdate =  (function (_super) {
        __extends$c(WidgetFormUpdate, _super);
        function WidgetFormUpdate(data) {
            return _super.call(this, data) || this;
        }
        return WidgetFormUpdate;
    }(WebAPI));
    var ConfigurationError =  (function (_super) {
        __extends$c(ConfigurationError, _super);
        function ConfigurationError() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        ConfigurationError.newInstance = function (parameter, value, data) {
            var result = new ConfigurationError({
                clazz: null,
                code: 498,
                exceptionName: "ConfigurationErrorException",
                message: value ? "Invalid value " + JSON.stringify(value, MapOrSet_toJSON) + " for parameter \"" + parameter + "\"" : "Missing parameter: " + parameter,
            });
            result.parameter = parameter;
            result.value = value;
            result.data = data;
            return result;
        };
        return ConfigurationError;
    }(WebAPI));

    var AbandonedCallInfoClosedResult;
    (function (AbandonedCallInfoClosedResult) {
        AbandonedCallInfoClosedResult["SUCCESS"] = "SUCCESS";
        AbandonedCallInfoClosedResult["DELETED_BY_AGENT"] = "DELETED_BY_AGENT";
        AbandonedCallInfoClosedResult["EXPIRED"] = "EXPIRED";
        AbandonedCallInfoClosedResult["RETRY_EXCEEDED"] = "RETRY_EXCEEDED";
        AbandonedCallInfoClosedResult["CONTACT_RECALL"] = "CONTACT_RECALL";
        AbandonedCallInfoClosedResult["SUCCESS_FROM_CALLBACK"] = "SUCCESS_FROM_CALLBACK";
        AbandonedCallInfoClosedResult["DELETED_BY_AGENT_FROM_CALLBACK"] = "DELETED_BY_AGENT_FROM_CALLBACK";
    })(AbandonedCallInfoClosedResult || (AbandonedCallInfoClosedResult = {}));
    var AbandonedCallInfoStatus;
    (function (AbandonedCallInfoStatus) {
        AbandonedCallInfoStatus["NEW"] = "NEW";
        AbandonedCallInfoStatus["UNLOCKED"] = "UNLOCKED";
        AbandonedCallInfoStatus["LOCKED"] = "LOCKED";
        AbandonedCallInfoStatus["CLOSED"] = "CLOSED";
    })(AbandonedCallInfoStatus || (AbandonedCallInfoStatus = {}));
    var AccessPattern;
    (function (AccessPattern) {
        AccessPattern["ALWAYS_NULL"] = "ALWAYS_NULL";
        AccessPattern["CONSTANT"] = "CONSTANT";
        AccessPattern["DYNAMIC"] = "DYNAMIC";
    })(AccessPattern || (AccessPattern = {}));
    var ActionToDoType;
    (function (ActionToDoType) {
        ActionToDoType["DIAL"] = "DIAL";
        ActionToDoType["BACK_PO"] = "BACK_PO";
        ActionToDoType["VOICEMAIL"] = "VOICEMAIL";
        ActionToDoType["HANGUP"] = "HANGUP";
        ActionToDoType["PLAY"] = "PLAY";
    })(ActionToDoType || (ActionToDoType = {}));
    var AddressBookContactAddressType;
    (function (AddressBookContactAddressType) {
        AddressBookContactAddressType["MAIN"] = "MAIN";
        AddressBookContactAddressType["OTHER"] = "OTHER";
    })(AddressBookContactAddressType || (AddressBookContactAddressType = {}));
    var AddressBookContactForgottenStatus;
    (function (AddressBookContactForgottenStatus) {
        AddressBookContactForgottenStatus["NONE"] = "NONE";
        AddressBookContactForgottenStatus["WAIT"] = "WAIT";
        AddressBookContactForgottenStatus["RUN"] = "RUN";
        AddressBookContactForgottenStatus["ERR"] = "ERR";
        AddressBookContactForgottenStatus["END"] = "END";
    })(AddressBookContactForgottenStatus || (AddressBookContactForgottenStatus = {}));
    var AddressBookContactMailType;
    (function (AddressBookContactMailType) {
        AddressBookContactMailType["INTERNET_WORK"] = "INTERNET_WORK";
        AddressBookContactMailType["INTERNET_HOME"] = "INTERNET_HOME";
    })(AddressBookContactMailType || (AddressBookContactMailType = {}));
    var AddressBookContactNumberType;
    (function (AddressBookContactNumberType) {
        AddressBookContactNumberType["FAX"] = "FAX";
        AddressBookContactNumberType["HOME"] = "HOME";
        AddressBookContactNumberType["CELL"] = "CELL";
        AddressBookContactNumberType["WORK"] = "WORK";
        AddressBookContactNumberType["CELL_WORK"] = "CELL_WORK";
        AddressBookContactNumberType["FAX_WORK"] = "FAX_WORK";
        AddressBookContactNumberType["FAX_HOME"] = "FAX_HOME";
        AddressBookContactNumberType["CELL_HOME"] = "CELL_HOME";
        AddressBookContactNumberType["MAIN"] = "MAIN";
        AddressBookContactNumberType["OTHER"] = "OTHER";
    })(AddressBookContactNumberType || (AddressBookContactNumberType = {}));
    var AddressBookContactType;
    (function (AddressBookContactType) {
        AddressBookContactType["USER"] = "USER";
        AddressBookContactType["SERVICE"] = "SERVICE";
        AddressBookContactType["SERVICE_CODE"] = "SERVICE_CODE";
        AddressBookContactType["SHORT_NUMBER"] = "SHORT_NUMBER";
        AddressBookContactType["EXTERNAL_ITEM"] = "EXTERNAL_ITEM";
        AddressBookContactType["EXTERNAL_ORGANIZATION"] = "EXTERNAL_ORGANIZATION";
        AddressBookContactType["PERSONAL_ITEM"] = "PERSONAL_ITEM";
        AddressBookContactType["UNKNOWN"] = "UNKNOWN";
        AddressBookContactType["MULTIPLE"] = "MULTIPLE";
        AddressBookContactType["MEETING"] = "MEETING";
        AddressBookContactType["ERROR"] = "ERROR";
        AddressBookContactType["DELAYED"] = "DELAYED";
        AddressBookContactType["ANONYMOUS"] = "ANONYMOUS";
    })(AddressBookContactType || (AddressBookContactType = {}));
    var AddressBookContactWebType;
    (function (AddressBookContactWebType) {
        AddressBookContactWebType["WORK"] = "WORK";
        AddressBookContactWebType["HOME"] = "HOME";
    })(AddressBookContactWebType || (AddressBookContactWebType = {}));
    var AddressBookField;
    (function (AddressBookField) {
        AddressBookField["img"] = "img";
        AddressBookField["number"] = "number";
        AddressBookField["email"] = "email";
        AddressBookField["webLink"] = "webLink";
        AddressBookField["note"] = "note";
        AddressBookField["department"] = "department";
        AddressBookField["street"] = "street";
        AddressBookField["city"] = "city";
        AddressBookField["district"] = "district";
        AddressBookField["cap"] = "cap";
        AddressBookField["country"] = "country";
        AddressBookField["site"] = "site";
        AddressBookField["category"] = "category";
        AddressBookField["company"] = "company";
        AddressBookField["vip"] = "vip";
        AddressBookField["name"] = "name";
        AddressBookField["surname"] = "surname";
        AddressBookField["otherName"] = "otherName";
        AddressBookField["role"] = "role";
        AddressBookField["customField"] = "customField";
        AddressBookField["priority"] = "priority";
    })(AddressBookField || (AddressBookField = {}));
    var AddressBookFieldKey;
    (function (AddressBookFieldKey) {
        AddressBookFieldKey["UID"] = "UID";
        AddressBookFieldKey["N"] = "N";
        AddressBookFieldKey["ORG"] = "ORG";
        AddressBookFieldKey["RELATED"] = "RELATED";
        AddressBookFieldKey["ADR"] = "ADR";
        AddressBookFieldKey["CATEGORIES"] = "CATEGORIES";
        AddressBookFieldKey["NOTE"] = "NOTE";
        AddressBookFieldKey["X_TELENIA_VIP"] = "X-TELENIA-VIP";
        AddressBookFieldKey["X_TELENIA_SITE"] = "X-TELENIA-SITE";
        AddressBookFieldKey["X_TELENIA_ROLE"] = "X-TELENIA-ROLE";
        AddressBookFieldKey["X_TELENIA_PERSISTENT_INTERACTIONS"] = "X-TELENIA-PERSISTENT-INTERACTIONS";
        AddressBookFieldKey["X_TELENIA_CUSTOM_A"] = "X-TELENIA-CUSTOM-A";
        AddressBookFieldKey["X_TELENIA_CUSTOM_B"] = "X-TELENIA-CUSTOM-B";
        AddressBookFieldKey["X_TELENIA_CUSTOM_C"] = "X-TELENIA-CUSTOM-C";
        AddressBookFieldKey["X_TELENIA_CUSTOM_D"] = "X-TELENIA-CUSTOM-D";
        AddressBookFieldKey["X_TELENIA_CUSTOM_E"] = "X-TELENIA-CUSTOM-E";
        AddressBookFieldKey["X_TELENIA_CUSTOM_F"] = "X-TELENIA-CUSTOM-F";
        AddressBookFieldKey["X_TELENIA_CUSTOM_G"] = "X-TELENIA-CUSTOM-G";
        AddressBookFieldKey["X_TELENIA_CUSTOM_H"] = "X-TELENIA-CUSTOM-H";
        AddressBookFieldKey["X_TELENIA_CUSTOM_I"] = "X-TELENIA-CUSTOM-I";
        AddressBookFieldKey["X_TELENIA_CUSTOM_J"] = "X-TELENIA-CUSTOM-J";
        AddressBookFieldKey["X_TELENIA_BACKEND_CONFIG_NAME"] = "X-TELENIA-BACKEND-CONFIG-NAME";
        AddressBookFieldKey["TEL"] = "TEL";
        AddressBookFieldKey["EMAIL"] = "EMAIL";
        AddressBookFieldKey["KIND"] = "KIND";
        AddressBookFieldKey["URL"] = "URL";
        AddressBookFieldKey["X_TELENIA_NOTE_AGENT"] = "X-TELENIA-NOTE-AGENT";
        AddressBookFieldKey["X_TELENIA_ACCEPT_CENSUS"] = "X-TELENIA-ACCEPT-CENSUS";
        AddressBookFieldKey["X_TELENIA_PRIORITY"] = "X-TELENIA-PRIORITY";
        AddressBookFieldKey["X_TELENIA_CUSTOMER_CODE"] = "X-TELENIA-CUSTOMER-CODE";
        AddressBookFieldKey["X_TELENIA_FORGOTTEN_CONTACT"] = "X-TELENIA-FORGOTTEN-CONTACT";
    })(AddressBookFieldKey || (AddressBookFieldKey = {}));
    var AddressBookFieldType;
    (function (AddressBookFieldType) {
        AddressBookFieldType["MAIN"] = "MAIN";
        AddressBookFieldType["WORK"] = "WORK";
        AddressBookFieldType["CELL"] = "CELL";
        AddressBookFieldType["HOME"] = "HOME";
        AddressBookFieldType["NONE"] = "NONE";
        AddressBookFieldType["FAX"] = "FAX";
    })(AddressBookFieldType || (AddressBookFieldType = {}));
    var AddressBookSearchMode;
    (function (AddressBookSearchMode) {
        AddressBookSearchMode["EQUAL"] = "EQUAL";
        AddressBookSearchMode["LIKE"] = "LIKE";
        AddressBookSearchMode["START_WITH"] = "START_WITH";
        AddressBookSearchMode["END_WITH"] = "END_WITH";
    })(AddressBookSearchMode || (AddressBookSearchMode = {}));
    var AddressBookSourceOriginType;
    (function (AddressBookSourceOriginType) {
        AddressBookSourceOriginType["SOURCE_SYNC"] = "SOURCE_SYNC";
        AddressBookSourceOriginType["DIRECT_SYNC"] = "DIRECT_SYNC";
        AddressBookSourceOriginType["T4YOU_USER_AGENT"] = "T4YOU_USER_AGENT";
        AddressBookSourceOriginType["MC0"] = "MC0";
        AddressBookSourceOriginType["MC1"] = "MC1";
        AddressBookSourceOriginType["MC2"] = "MC2";
        AddressBookSourceOriginType["MC3"] = "MC3";
        AddressBookSourceOriginType["MC1000"] = "MC1000";
        AddressBookSourceOriginType["MC1001"] = "MC1001";
        AddressBookSourceOriginType["MC1002"] = "MC1002";
        AddressBookSourceOriginType["MC1003"] = "MC1003";
        AddressBookSourceOriginType["MC1004"] = "MC1004";
        AddressBookSourceOriginType["MC1005"] = "MC1005";
    })(AddressBookSourceOriginType || (AddressBookSourceOriginType = {}));
    var AddressBookType;
    (function (AddressBookType) {
        AddressBookType["PERSONAL"] = "PERSONAL";
        AddressBookType["EXTERNAL"] = "EXTERNAL";
        AddressBookType["INTERNAL"] = "INTERNAL";
    })(AddressBookType || (AddressBookType = {}));
    var AddressBookWritePermission;
    (function (AddressBookWritePermission) {
        AddressBookWritePermission["ENABLED"] = "ENABLED";
        AddressBookWritePermission["DISABLED"] = "DISABLED";
        AddressBookWritePermission["ENABLED_ON_NOSYNC"] = "ENABLED_ON_NOSYNC";
    })(AddressBookWritePermission || (AddressBookWritePermission = {}));
    var AddressbookField;
    (function (AddressbookField) {
        AddressbookField["N"] = "N";
        AddressbookField["FN"] = "FN";
        AddressbookField["ORG"] = "ORG";
        AddressbookField["ADR"] = "ADR";
        AddressbookField["CATEGORIES"] = "CATEGORIES";
        AddressbookField["NOTE"] = "NOTE";
        AddressbookField["TEL"] = "TEL";
        AddressbookField["EMAIL"] = "EMAIL";
        AddressbookField["URL"] = "URL";
        AddressbookField["RELATED"] = "RELATED";
        AddressbookField["KIND"] = "KIND";
        AddressbookField["TELENIA_NOTE_AGENT"] = "TELENIA_NOTE_AGENT";
        AddressbookField["TELENIA_NOTE_AGENT_LAST_UPDATE"] = "TELENIA_NOTE_AGENT_LAST_UPDATE";
        AddressbookField["TELENIA_NOTE_AGENT_USER_UPDATE"] = "TELENIA_NOTE_AGENT_USER_UPDATE";
        AddressbookField["TELENIA_NOTE_AGENT_MODIFIED"] = "TELENIA_NOTE_AGENT_MODIFIED";
        AddressbookField["TELENIA_VCARD_ORIGIN"] = "TELENIA_VCARD_ORIGIN";
        AddressbookField["TELENIA_VIP"] = "TELENIA_VIP";
        AddressbookField["TELENIA_SITE"] = "TELENIA_SITE";
        AddressbookField["TELENIA_ROLE"] = "TELENIA_ROLE";
        AddressbookField["TELENIA_CUSTOM_01"] = "TELENIA_CUSTOM_01";
        AddressbookField["TELENIA_CUSTOM_02"] = "TELENIA_CUSTOM_02";
        AddressbookField["TELENIA_CUSTOM_03"] = "TELENIA_CUSTOM_03";
        AddressbookField["TELENIA_CUSTOM_04"] = "TELENIA_CUSTOM_04";
        AddressbookField["TELENIA_CUSTOM_05"] = "TELENIA_CUSTOM_05";
        AddressbookField["TELENIA_CUSTOM_06"] = "TELENIA_CUSTOM_06";
        AddressbookField["TELENIA_CUSTOM_07"] = "TELENIA_CUSTOM_07";
        AddressbookField["TELENIA_CUSTOM_08"] = "TELENIA_CUSTOM_08";
        AddressbookField["TELENIA_CUSTOM_09"] = "TELENIA_CUSTOM_09";
        AddressbookField["TELENIA_CUSTOM_10"] = "TELENIA_CUSTOM_10";
        AddressbookField["TELENIA_CHANNEL_PHONE"] = "TELENIA_CHANNEL_PHONE";
        AddressbookField["TELENIA_CHANNEL_CALLBACK"] = "TELENIA_CHANNEL_CALLBACK";
        AddressbookField["TELENIA_CHANNEL_VIDEO"] = "TELENIA_CHANNEL_VIDEO";
        AddressbookField["TELENIA_CHANNEL_MAIL"] = "TELENIA_CHANNEL_MAIL";
        AddressbookField["TELENIA_CHANNEL_MAIL_ORG"] = "TELENIA_CHANNEL_MAIL_ORG";
        AddressbookField["TELENIA_CHANNEL_LIVEHELP"] = "TELENIA_CHANNEL_LIVEHELP";
        AddressbookField["TELENIA_CHANNEL_WHATSAPP_TWILIO"] = "TELENIA_CHANNEL_WHATSAPP_TWILIO";
        AddressbookField["TELENIA_CHANNEL_CHAT"] = "TELENIA_CHANNEL_CHAT";
        AddressbookField["TELENIA_CHANNEL_1"] = "TELENIA_CHANNEL_1";
        AddressbookField["TELENIA_CHANNEL_2"] = "TELENIA_CHANNEL_2";
        AddressbookField["TELENIA_CHANNEL_3"] = "TELENIA_CHANNEL_3";
        AddressbookField["TELENIA_BACKEND_CONFIG_NAME"] = "TELENIA_BACKEND_CONFIG_NAME";
        AddressbookField["TELENIA_PERSISTENT_INTERACTIONS"] = "TELENIA_PERSISTENT_INTERACTIONS";
        AddressbookField["TELENIA_ACCEPT_CENSUS"] = "TELENIA_ACCEPT_CENSUS";
        AddressbookField["TELENIA_CUSTOMER_CODE"] = "TELENIA_CUSTOMER_CODE";
        AddressbookField["TELENIA_LAST_A_TYPE"] = "TELENIA_LAST_A_TYPE";
        AddressbookField["TELENIA_NPS"] = "TELENIA_NPS";
        AddressbookField["TELENIA_SOURCE_ORIGIN_TYPE"] = "TELENIA_SOURCE_ORIGIN_TYPE";
        AddressbookField["TELENIA_PRIORITY"] = "TELENIA_PRIORITY";
        AddressbookField["TELENIA_FORGOTTEN_CONTACT"] = "TELENIA_FORGOTTEN_CONTACT";
    })(AddressbookField || (AddressbookField = {}));
    var AddressbookFieldType;
    (function (AddressbookFieldType) {
        AddressbookFieldType["FAX"] = "FAX";
        AddressbookFieldType["HOME"] = "HOME";
        AddressbookFieldType["CELL"] = "CELL";
        AddressbookFieldType["WORK"] = "WORK";
        AddressbookFieldType["CELL_WORK"] = "CELL_WORK";
        AddressbookFieldType["FAX_WORK"] = "FAX_WORK";
        AddressbookFieldType["FAX_HOME"] = "FAX_HOME";
        AddressbookFieldType["CELL_HOME"] = "CELL_HOME";
        AddressbookFieldType["MAIN"] = "MAIN";
        AddressbookFieldType["NONE"] = "NONE";
        AddressbookFieldType["OTHER"] = "OTHER";
        AddressbookFieldType["INTERNET_WORK"] = "INTERNET_WORK";
        AddressbookFieldType["INTERNET_HOME"] = "INTERNET_HOME";
    })(AddressbookFieldType || (AddressbookFieldType = {}));
    var AlarmIssuedDetailStatus;
    (function (AlarmIssuedDetailStatus) {
        AlarmIssuedDetailStatus["IDLE"] = "IDLE";
        AlarmIssuedDetailStatus["TO_RUN"] = "TO_RUN";
        AlarmIssuedDetailStatus["RUNNING"] = "RUNNING";
        AlarmIssuedDetailStatus["WAITING_FEEDBACK"] = "WAITING_FEEDBACK";
        AlarmIssuedDetailStatus["BUSY"] = "BUSY";
        AlarmIssuedDetailStatus["NOANSWER"] = "NOANSWER";
        AlarmIssuedDetailStatus["ANSWERED"] = "ANSWERED";
        AlarmIssuedDetailStatus["ERROR"] = "ERROR";
        AlarmIssuedDetailStatus["ERROR_CALLING"] = "ERROR_CALLING";
        AlarmIssuedDetailStatus["ERROR_CONGESTION"] = "ERROR_CONGESTION";
        AlarmIssuedDetailStatus["ERROR_CHANUNAVAIL"] = "ERROR_CHANUNAVAIL";
        AlarmIssuedDetailStatus["ERROR_NOFEEDBACK"] = "ERROR_NOFEEDBACK";
        AlarmIssuedDetailStatus["DELETED"] = "DELETED";
        AlarmIssuedDetailStatus["SKIPPED"] = "SKIPPED";
        AlarmIssuedDetailStatus["UNPROCESSED"] = "UNPROCESSED";
    })(AlarmIssuedDetailStatus || (AlarmIssuedDetailStatus = {}));
    var AlarmIssuedDetailType;
    (function (AlarmIssuedDetailType) {
        AlarmIssuedDetailType["MAIL"] = "MAIL";
        AlarmIssuedDetailType["SMS"] = "SMS";
        AlarmIssuedDetailType["CALL"] = "CALL";
        AlarmIssuedDetailType["CHAT"] = "CHAT";
        AlarmIssuedDetailType["SNMP"] = "SNMP";
        AlarmIssuedDetailType["WEBPORTAL"] = "WEBPORTAL";
        AlarmIssuedDetailType["ALL"] = "ALL";
    })(AlarmIssuedDetailType || (AlarmIssuedDetailType = {}));
    var AllowedAction;
    (function (AllowedAction) {
        AllowedAction["ADD"] = "ADD";
        AllowedAction["ENABLE"] = "ENABLE";
        AllowedAction["DISABLE"] = "DISABLE";
        AllowedAction["COPY"] = "COPY";
        AllowedAction["UPDATE"] = "UPDATE";
        AllowedAction["DELETE"] = "DELETE";
    })(AllowedAction || (AllowedAction = {}));
    var AppFeature;
    (function (AppFeature) {
        AppFeature["ACK"] = "ACK";
        AppFeature["DEVICE_EMBEDDED"] = "DEVICE_EMBEDDED";
        AppFeature["FAVS"] = "FAVS";
    })(AppFeature || (AppFeature = {}));
    var AppStatusOnConnect;
    (function (AppStatusOnConnect) {
        AppStatusOnConnect["terminate"] = "terminate";
        AppStatusOnConnect["login"] = "login";
        AppStatusOnConnect["background"] = "background";
    })(AppStatusOnConnect || (AppStatusOnConnect = {}));
    var ArticleSender;
    (function (ArticleSender) {
        ArticleSender["Agent"] = "Agent";
        ArticleSender["Customer"] = "Customer";
        ArticleSender["System"] = "System";
    })(ArticleSender || (ArticleSender = {}));
    var ArticleType;
    (function (ArticleType) {
        ArticleType["email"] = "email";
        ArticleType["sms"] = "sms";
        ArticleType["chat"] = "chat";
        ArticleType["fax"] = "fax";
        ArticleType["phone"] = "phone";
        ArticleType["TWITTER_STATUS"] = "twitter status";
        ArticleType["TWITTER_DIRECT_MESSAGE"] = "twitter direct-message";
        ArticleType["FACEBOOK_FEED_POST"] = "facebook feed post";
        ArticleType["FACEBOOK_FEED_COMMENT"] = "facebook feed comment";
        ArticleType["note"] = "note";
        ArticleType["web"] = "web";
        ArticleType["TELEGRAM_PERSONAL_MESSAGE"] = "telegram personal-message";
    })(ArticleType || (ArticleType = {}));
    var As;
    (function (As) {
        As["PROPERTY"] = "PROPERTY";
        As["WRAPPER_OBJECT"] = "WRAPPER_OBJECT";
        As["WRAPPER_ARRAY"] = "WRAPPER_ARRAY";
        As["EXTERNAL_PROPERTY"] = "EXTERNAL_PROPERTY";
        As["EXISTING_PROPERTY"] = "EXISTING_PROPERTY";
    })(As || (As = {}));
    var AutoAnswerMode;
    (function (AutoAnswerMode) {
        AutoAnswerMode["DISABLED"] = "DISABLED";
        AutoAnswerMode["BEFORE_POPUP"] = "BEFORE_POPUP";
        AutoAnswerMode["AFTER_POPUP"] = "AFTER_POPUP";
    })(AutoAnswerMode || (AutoAnswerMode = {}));
    var BridgeDeviceType;
    (function (BridgeDeviceType) {
        BridgeDeviceType["WEBCLIENT"] = "WEBCLIENT";
        BridgeDeviceType["APP"] = "APP";
        BridgeDeviceType["PHONE"] = "PHONE";
    })(BridgeDeviceType || (BridgeDeviceType = {}));
    var CCBSResult;
    (function (CCBSResult) {
        CCBSResult["DEFAULT"] = "DEFAULT";
        CCBSResult["CHANUNAVAIL"] = "CHANUNAVAIL";
        CCBSResult["CONGESTION"] = "CONGESTION";
        CCBSResult["NOANSWER"] = "NOANSWER";
        CCBSResult["BUSY"] = "BUSY";
        CCBSResult["ANSWER"] = "ANSWER";
        CCBSResult["CANCEL"] = "CANCEL";
        CCBSResult["DONTCALL"] = "DONTCALL";
        CCBSResult["TORTURE"] = "TORTURE";
        CCBSResult["INVALIDARGS"] = "INVALIDARGS";
        CCBSResult["ERROR"] = "ERROR";
    })(CCBSResult || (CCBSResult = {}));
    var CalendarFrequency;
    (function (CalendarFrequency) {
        CalendarFrequency["SECONDLY"] = "SECONDLY";
        CalendarFrequency["MINUTELY"] = "MINUTELY";
        CalendarFrequency["HOURLY"] = "HOURLY";
        CalendarFrequency["DAILY"] = "DAILY";
        CalendarFrequency["WEEKLY"] = "WEEKLY";
        CalendarFrequency["MONTHLY"] = "MONTHLY";
        CalendarFrequency["YEARLY"] = "YEARLY";
    })(CalendarFrequency || (CalendarFrequency = {}));
    var CalendarWeekDay;
    (function (CalendarWeekDay) {
        CalendarWeekDay["UNKNOWN"] = "UNKNOWN";
        CalendarWeekDay["SUNDAY"] = "SUNDAY";
        CalendarWeekDay["MONDAY"] = "MONDAY";
        CalendarWeekDay["TUESDAY"] = "TUESDAY";
        CalendarWeekDay["WEDNESDAY"] = "WEDNESDAY";
        CalendarWeekDay["THURSDAY"] = "THURSDAY";
        CalendarWeekDay["FRIDAY"] = "FRIDAY";
        CalendarWeekDay["SATURDAY"] = "SATURDAY";
    })(CalendarWeekDay || (CalendarWeekDay = {}));
    var CallDeviceState;
    (function (CallDeviceState) {
        CallDeviceState["INITIALING"] = "INITIALING";
        CallDeviceState["CONNECTED"] = "CONNECTED";
        CallDeviceState["DIALING"] = "DIALING";
        CallDeviceState["RINGING"] = "RINGING";
        CallDeviceState["CALL_CONNECTED"] = "CALL_CONNECTED";
    })(CallDeviceState || (CallDeviceState = {}));
    var CallDirection;
    (function (CallDirection) {
        CallDirection["inbound"] = "inbound";
        CallDirection["outbound"] = "outbound";
    })(CallDirection || (CallDirection = {}));
    var CallFeature;
    (function (CallFeature) {
        CallFeature["ANSWER"] = "ANSWER";
        CallFeature["CANCEL"] = "CANCEL";
        CallFeature["CONFERENCE"] = "CONFERENCE";
        CallFeature["DIAL"] = "DIAL";
        CallFeature["HOLD"] = "HOLD";
        CallFeature["GENERATE_DTMF"] = "GENERATE_DTMF";
        CallFeature["MONITOR_START"] = "MONITOR_START";
        CallFeature["SETCALLDATA"] = "SETCALLDATA";
        CallFeature["TRANSFER_BLIND"] = "TRANSFER_BLIND";
        CallFeature["TRANSFER_ATTENDED"] = "TRANSFER_ATTENDED";
        CallFeature["UNHOLD"] = "UNHOLD";
        CallFeature["MONITOR_STOP"] = "MONITOR_STOP";
        CallFeature["MUTE"] = "MUTE";
        CallFeature["REJECT"] = "REJECT";
        CallFeature["ACCEPT"] = "ACCEPT";
        CallFeature["UNMUTE"] = "UNMUTE";
        CallFeature["UPDATE"] = "UPDATE";
        CallFeature["VIDEO_START"] = "VIDEO_START";
        CallFeature["VIDEO_STOP"] = "VIDEO_STOP";
        CallFeature["SWITCH_TO_GSM"] = "SWITCH_TO_GSM";
    })(CallFeature || (CallFeature = {}));
    var CallFowardMode;
    (function (CallFowardMode) {
        CallFowardMode["EMAIL"] = "EMAIL";
        CallFowardMode["SMS"] = "SMS";
        CallFowardMode["ALL"] = "ALL";
    })(CallFowardMode || (CallFowardMode = {}));
    var CallFowardStatus;
    (function (CallFowardStatus) {
        CallFowardStatus["ENABLE_ALL"] = "ENABLE_ALL";
        CallFowardStatus["ENABLE_INTERNAL"] = "ENABLE_INTERNAL";
        CallFowardStatus["ENABLE_EXTERNAL"] = "ENABLE_EXTERNAL";
        CallFowardStatus["DISABLE"] = "DISABLE";
    })(CallFowardStatus || (CallFowardStatus = {}));
    var CallHistoryType;
    (function (CallHistoryType) {
        CallHistoryType["INBOUND"] = "INBOUND";
        CallHistoryType["OUTBOUND"] = "OUTBOUND";
    })(CallHistoryType || (CallHistoryType = {}));
    var CallHistoryWebRTCResult;
    (function (CallHistoryWebRTCResult) {
        CallHistoryWebRTCResult["OK"] = "OK";
        CallHistoryWebRTCResult["ERROR_ICE"] = "ERROR_ICE";
        CallHistoryWebRTCResult["ERROR_DTLS"] = "ERROR_DTLS";
        CallHistoryWebRTCResult["ERROR_MEDIA"] = "ERROR_MEDIA";
        CallHistoryWebRTCResult["ERROR_CONNECTIVITY"] = "ERROR_CONNECTIVITY";
        CallHistoryWebRTCResult["ERROR_BAD_MEDIA"] = "ERROR_BAD_MEDIA";
        CallHistoryWebRTCResult["NO_SMARTWORKING"] = "NO_SMARTWORKING";
    })(CallHistoryWebRTCResult || (CallHistoryWebRTCResult = {}));
    var CallMedia;
    (function (CallMedia) {
        CallMedia["audio"] = "audio";
        CallMedia["video"] = "video";
        CallMedia["desktop"] = "desktop";
        CallMedia["data"] = "data";
    })(CallMedia || (CallMedia = {}));
    var CallMediaFeature;
    (function (CallMediaFeature) {
        CallMediaFeature["MUTE"] = "MUTE";
        CallMediaFeature["UNMUTE"] = "UNMUTE";
        CallMediaFeature["START"] = "START";
        CallMediaFeature["STOP"] = "STOP";
    })(CallMediaFeature || (CallMediaFeature = {}));
    var CallMediaLinkStatus;
    (function (CallMediaLinkStatus) {
        CallMediaLinkStatus["MUTE"] = "MUTE";
        CallMediaLinkStatus["UNMUTE"] = "UNMUTE";
    })(CallMediaLinkStatus || (CallMediaLinkStatus = {}));
    var CallMediaStatus;
    (function (CallMediaStatus) {
        CallMediaStatus["OK"] = "OK";
        CallMediaStatus["ERROR_BAD_MEDIA"] = "ERROR_BAD_MEDIA";
        CallMediaStatus["ERROR_ICE"] = "ERROR_ICE";
        CallMediaStatus["ERROR_DTLS"] = "ERROR_DTLS";
        CallMediaStatus["ERROR_MEDIA"] = "ERROR_MEDIA";
        CallMediaStatus["ERROR_CONNECTIVITY"] = "ERROR_CONNECTIVITY";
    })(CallMediaStatus || (CallMediaStatus = {}));
    var CallPopupMode;
    (function (CallPopupMode) {
        CallPopupMode["DISABLED"] = "DISABLED";
        CallPopupMode["IFRAME"] = "IFRAME";
        CallPopupMode["NEW_TAB"] = "NEW_TAB";
        CallPopupMode["ACTIVEX"] = "ACTIVEX";
    })(CallPopupMode || (CallPopupMode = {}));
    var CallPopupType;
    (function (CallPopupType) {
        CallPopupType["onRing"] = "onRing";
        CallPopupType["onAnswer"] = "onAnswer";
        CallPopupType["onHangup"] = "onHangup";
        CallPopupType["onDemand"] = "onDemand";
        CallPopupType["webClientOpenNewTab"] = "webClientOpenNewTab";
        CallPopupType["webClientTabLabel"] = "webClientTabLabel";
        CallPopupType["custom"] = "custom";
    })(CallPopupType || (CallPopupType = {}));
    var CallRecordingFileType;
    (function (CallRecordingFileType) {
        CallRecordingFileType["WAV"] = "wav";
        CallRecordingFileType["MP3"] = "mp3";
        CallRecordingFileType["WAVE"] = "wave";
        CallRecordingFileType["ZIP"] = "zip";
    })(CallRecordingFileType || (CallRecordingFileType = {}));
    var CallResultStatusType;
    (function (CallResultStatusType) {
        CallResultStatusType["inbound"] = "inbound";
        CallResultStatusType["outbound"] = "outbound";
        CallResultStatusType["abandoned_call"] = "abandoned_call";
        CallResultStatusType["callback_call"] = "callback_call";
    })(CallResultStatusType || (CallResultStatusType = {}));
    var CallState;
    (function (CallState) {
        CallState["NEW_INBOUND"] = "NEW_INBOUND";
        CallState["NEW_OUTBOUND"] = "NEW_OUTBOUND";
        CallState["CONNECTED"] = "CONNECTED";
        CallState["CONFERENCED"] = "CONFERENCED";
        CallState["HOLD"] = "HOLD";
        CallState["IDLE"] = "IDLE";
    })(CallState || (CallState = {}));
    var CallStatus;
    (function (CallStatus) {
        CallStatus["ACTIVE"] = "ACTIVE";
        CallStatus["ON_QUEUE"] = "ON_QUEUE";
        CallStatus["AGENT"] = "AGENT";
        CallStatus["OUT_OF_QUEUE"] = "OUT_OF_QUEUE";
        CallStatus["ABANDONED"] = "ABANDONED";
    })(CallStatus || (CallStatus = {}));
    var CallbackRequestCloseResult;
    (function (CallbackRequestCloseResult) {
        CallbackRequestCloseResult["SUCCESS"] = "SUCCESS";
        CallbackRequestCloseResult["DELETED_BY_AGENT"] = "DELETED_BY_AGENT";
        CallbackRequestCloseResult["EXPIRED"] = "EXPIRED";
        CallbackRequestCloseResult["RETRY_EXCEEDED"] = "RETRY_EXCEEDED";
        CallbackRequestCloseResult["CONTACT_RECALL"] = "CONTACT_RECALL";
        CallbackRequestCloseResult["SUCCESS_FROM_ABANDONED"] = "SUCCESS_FROM_ABANDONED";
        CallbackRequestCloseResult["DELETED_BY_AGENT_FROM_ABANDONED"] = "DELETED_BY_AGENT_FROM_ABANDONED";
    })(CallbackRequestCloseResult || (CallbackRequestCloseResult = {}));
    var CallbackRequestStatus;
    (function (CallbackRequestStatus) {
        CallbackRequestStatus["NEW"] = "NEW";
        CallbackRequestStatus["UNLOCKED"] = "UNLOCKED";
        CallbackRequestStatus["LOCKED"] = "LOCKED";
        CallbackRequestStatus["CLOSED"] = "CLOSED";
    })(CallbackRequestStatus || (CallbackRequestStatus = {}));
    var CallbackRequestType;
    (function (CallbackRequestType) {
        CallbackRequestType["IVR"] = "IVR";
        CallbackRequestType["WEB"] = "WEB";
    })(CallbackRequestType || (CallbackRequestType = {}));
    var CampaignPhoneChannelType;
    (function (CampaignPhoneChannelType) {
        CampaignPhoneChannelType["AVAILABLE"] = "AVAILABLE";
        CampaignPhoneChannelType["PRESENT"] = "PRESENT";
    })(CampaignPhoneChannelType || (CampaignPhoneChannelType = {}));
    var CampaignStatusValue;
    (function (CampaignStatusValue) {
        CampaignStatusValue["DISABLE"] = "DISABLE";
        CampaignStatusValue["ACTIVE"] = "ACTIVE";
        CampaignStatusValue["ACTIVE_QUEUED"] = "ACTIVE_QUEUED";
        CampaignStatusValue["EVALUATING_RESULT"] = "EVALUATING_RESULT";
        CampaignStatusValue["PENDING"] = "PENDING";
        CampaignStatusValue["STOP"] = "STOP";
        CampaignStatusValue["END"] = "END";
        CampaignStatusValue["ERROR"] = "ERROR";
        CampaignStatusValue["STOPPING"] = "STOPPING";
        CampaignStatusValue["LOADING_DATA"] = "LOADING_DATA";
        CampaignStatusValue["SCHEDULED"] = "SCHEDULED";
    })(CampaignStatusValue || (CampaignStatusValue = {}));
    var CampaignType;
    (function (CampaignType) {
        CampaignType["CALL"] = "CALL";
        CampaignType["MASSIVE_SMS"] = "MASSIVE_SMS";
        CampaignType["SMS"] = "SMS";
        CampaignType["MASSIVE_MAIL"] = "MASSIVE_MAIL";
        CampaignType["MAIL"] = "MAIL";
        CampaignType["APP"] = "APP";
    })(CampaignType || (CampaignType = {}));
    var CancelReason;
    (function (CancelReason) {
        CancelReason["BUSY"] = "BUSY";
        CancelReason["REJECTED"] = "REJECTED";
        CancelReason["NORMAL_CLEARING"] = "NORMAL_CLEARING";
    })(CancelReason || (CancelReason = {}));
    var ChannelInfoImprovementDataType;
    (function (ChannelInfoImprovementDataType) {
        ChannelInfoImprovementDataType["STRING"] = "STRING";
        ChannelInfoImprovementDataType["DATE"] = "DATE";
        ChannelInfoImprovementDataType["CHECKBOX"] = "CHECKBOX";
    })(ChannelInfoImprovementDataType || (ChannelInfoImprovementDataType = {}));
    var ChatChannelEventMessageStatus;
    (function (ChatChannelEventMessageStatus) {
        ChatChannelEventMessageStatus["WROTE"] = "WROTE";
        ChatChannelEventMessageStatus["COMPOSING"] = "COMPOSING";
        ChatChannelEventMessageStatus["IDLE"] = "IDLE";
    })(ChatChannelEventMessageStatus || (ChatChannelEventMessageStatus = {}));
    var ChatHistoryType;
    (function (ChatHistoryType) {
        ChatHistoryType["INBOUND"] = "INBOUND";
        ChatHistoryType["OUTBOUND"] = "OUTBOUND";
    })(ChatHistoryType || (ChatHistoryType = {}));
    var ChatStatus;
    (function (ChatStatus) {
        ChatStatus["ACTIVE"] = "ACTIVE";
        ChatStatus["ON_DISTRIBUTION"] = "ON_DISTRIBUTION";
        ChatStatus["ON_AGENT"] = "ON_AGENT";
        ChatStatus["ON_QUEUE"] = "ON_QUEUE";
        ChatStatus["AGENT"] = "AGENT";
        ChatStatus["OUT_OF_QUEUE"] = "OUT_OF_QUEUE";
        ChatStatus["ABANDONED"] = "ABANDONED";
        ChatStatus["ERROR"] = "ERROR";
        ChatStatus["TRANSFER"] = "TRANSFER";
        ChatStatus["TERMINATED"] = "TERMINATED";
        ChatStatus["ANSWERED"] = "ANSWERED";
        ChatStatus["ANSWERED_TRANSFER"] = "ANSWERED_TRANSFER";
    })(ChatStatus || (ChatStatus = {}));
    var ClientCommandRequest;
    (function (ClientCommandRequest) {
        ClientCommandRequest["DIAL"] = "DIAL";
        ClientCommandRequest["SEND_FEEDBACK"] = "SEND_FEEDBACK";
    })(ClientCommandRequest || (ClientCommandRequest = {}));
    var ClientCommandResult;
    (function (ClientCommandResult) {
        ClientCommandResult["OK"] = "OK";
        ClientCommandResult["RECEIVED"] = "RECEIVED";
        ClientCommandResult["FAILED"] = "FAILED";
        ClientCommandResult["TIMEOUT_EXPIRED"] = "TIMEOUT_EXPIRED";
        ClientCommandResult["FEATURE_UNSUPPORTED"] = "FEATURE_UNSUPPORTED";
    })(ClientCommandResult || (ClientCommandResult = {}));
    var ClientParamType;
    (function (ClientParamType) {
        ClientParamType["NUMBER"] = "NUMBER";
        ClientParamType["STRING"] = "STRING";
        ClientParamType["BOOLEAN"] = "BOOLEAN";
    })(ClientParamType || (ClientParamType = {}));
    var Condition;
    (function (Condition) {
        Condition["ticketAction"] = "ticket.action";
        Condition["ticketStateId"] = "ticket.state_id";
        Condition["ticketOwnerId"] = "ticket.owner_id";
        Condition["ticketCustomerId"] = "ticket.customer_id";
        Condition["ticketGroupId"] = "ticket.group_id";
        Condition["articleTypeId"] = "article.type_id";
        Condition["articleSenderId"] = "article.sender_id";
    })(Condition || (Condition = {}));
    var ConfigurationPermission;
    (function (ConfigurationPermission) {
        ConfigurationPermission["DEFAULT"] = "DEFAULT";
        ConfigurationPermission["NONE"] = "NONE";
        ConfigurationPermission["READ"] = "READ";
        ConfigurationPermission["READ_WRITE"] = "READ_WRITE";
        ConfigurationPermission["READ_ADD"] = "READ_ADD";
        ConfigurationPermission["READ_WRITE_ADD"] = "READ_WRITE_ADD";
    })(ConfigurationPermission || (ConfigurationPermission = {}));
    var ConnectionType;
    (function (ConnectionType) {
        ConnectionType["APP_IOS_2"] = "APP_IOS_2";
        ConnectionType["APP_ANDROID_2"] = "APP_ANDROID_2";
        ConnectionType["APP_IOS"] = "APP_IOS";
        ConnectionType["APP_ANDROID"] = "APP_ANDROID";
        ConnectionType["EXE_CLIENT"] = "EXE_CLIENT";
        ConnectionType["WEB"] = "WEB";
        ConnectionType["WEB_FOR_APP"] = "WEB_FOR_APP";
    })(ConnectionType || (ConnectionType = {}));
    var Context;
    (function (Context) {
        Context["ENABLE_FROM_PHONE"] = "ENABLE_FROM_PHONE";
        Context["ALWAYS"] = "ALWAYS";
        Context["CHANUNAVAIL"] = "CHANUNAVAIL";
        Context["BUSY"] = "BUSY";
        Context["NOANSWER"] = "NOANSWER";
        Context["NOT_PRESENT"] = "NOT_PRESENT";
    })(Context || (Context = {}));
    var CustomCliType;
    (function (CustomCliType) {
        CustomCliType["CUST"] = "CUST";
        CustomCliType["SERV"] = "SERV";
    })(CustomCliType || (CustomCliType = {}));
    var CustomFieldConfigType;
    (function (CustomFieldConfigType) {
        CustomFieldConfigType["TEXT"] = "TEXT";
        CustomFieldConfigType["LIST"] = "LIST";
    })(CustomFieldConfigType || (CustomFieldConfigType = {}));
    var CustomFieldType;
    (function (CustomFieldType) {
        CustomFieldType["SELECT"] = "SELECT";
        CustomFieldType["TEXT"] = "TEXT";
    })(CustomFieldType || (CustomFieldType = {}));
    var CustomTicketFieldConfigType;
    (function (CustomTicketFieldConfigType) {
        CustomTicketFieldConfigType["TEXT"] = "TEXT";
        CustomTicketFieldConfigType["TEXTAREA"] = "TEXTAREA";
        CustomTicketFieldConfigType["HYPERLINK"] = "HYPERLINK";
        CustomTicketFieldConfigType["CHECKBOX"] = "CHECKBOX";
        CustomTicketFieldConfigType["LIST"] = "LIST";
        CustomTicketFieldConfigType["DATE"] = "DATE";
        CustomTicketFieldConfigType["DATETIME"] = "DATETIME";
        CustomTicketFieldConfigType["INTEGER"] = "INTEGER";
        CustomTicketFieldConfigType["DECIMAL"] = "DECIMAL";
        CustomTicketFieldConfigType["REGEX"] = "REGEX";
        CustomTicketFieldConfigType["PHONEBOOK_INTERNAL"] = "PHONEBOOK_INTERNAL";
        CustomTicketFieldConfigType["PHONEBOOK_GLOBAL"] = "PHONEBOOK_GLOBAL";
        CustomTicketFieldConfigType["PHONEBOOK_COMPANY"] = "PHONEBOOK_COMPANY";
        CustomTicketFieldConfigType["PHONEBOOK_CONTACT"] = "PHONEBOOK_CONTACT";
    })(CustomTicketFieldConfigType || (CustomTicketFieldConfigType = {}));
    var CustomerJourneyCallStatus;
    (function (CustomerJourneyCallStatus) {
        CustomerJourneyCallStatus["HANGUP"] = "HANGUP";
        CustomerJourneyCallStatus["CLOSED_BY_SYSTEM"] = "CLOSED_BY_SYSTEM";
        CustomerJourneyCallStatus["CLOSED_WITH_TRANSFER"] = "CLOSED_WITH_TRANSFER";
        CustomerJourneyCallStatus["ANSWERED_CLOSED_BY_CALLER"] = "ANSWERED_CLOSED_BY_CALLER";
        CustomerJourneyCallStatus["ANSWERED_CLOSED_BY_CALLED"] = "ANSWERED_CLOSED_BY_CALLED";
        CustomerJourneyCallStatus["ANSWERED_WITH_BLIND_TRANSFER"] = "ANSWERED_WITH_BLIND_TRANSFER";
        CustomerJourneyCallStatus["ANSWERED_WITH_CONSULTATION_TRANSFER"] = "ANSWERED_WITH_CONSULTATION_TRANSFER";
        CustomerJourneyCallStatus["ERROR"] = "ERROR";
        CustomerJourneyCallStatus["CLOSED_LIMIT_INBOUND"] = "CLOSED_LIMIT_INBOUND";
        CustomerJourneyCallStatus["CLOSED_LIMIT_QUEUE"] = "CLOSED_LIMIT_QUEUE";
        CustomerJourneyCallStatus["CLOSED_NO_SELECTION"] = "CLOSED_NO_SELECTION";
    })(CustomerJourneyCallStatus || (CustomerJourneyCallStatus = {}));
    var CustomerJourneyCallbackStatus;
    (function (CustomerJourneyCallbackStatus) {
        CustomerJourneyCallbackStatus["NEW"] = "NEW";
        CustomerJourneyCallbackStatus["LOCKED"] = "LOCKED";
        CustomerJourneyCallbackStatus["UNLOCKED"] = "UNLOCKED";
        CustomerJourneyCallbackStatus["CLOSED_SUCCESS"] = "CLOSED_SUCCESS";
        CustomerJourneyCallbackStatus["CLOSED_DELETED_BY_AGENT"] = "CLOSED_DELETED_BY_AGENT";
        CustomerJourneyCallbackStatus["CLOSED_EXPIRED"] = "CLOSED_EXPIRED";
        CustomerJourneyCallbackStatus["CLOSED_RETRY_EXCEEDED"] = "CLOSED_RETRY_EXCEEDED";
        CustomerJourneyCallbackStatus["CLOSED_CONTACT_RECALL"] = "CLOSED_CONTACT_RECALL";
        CustomerJourneyCallbackStatus["CLOSED_SUCCESS_FROM_CALLBACK"] = "CLOSED_SUCCESS_FROM_CALLBACK";
        CustomerJourneyCallbackStatus["CLOSED_DELETED_BY_AGENT_FROM_CALLBACK"] = "CLOSED_DELETED_BY_AGENT_FROM_CALLBACK";
        CustomerJourneyCallbackStatus["CLOSED_SUCCESS_FROM_ABANDONED"] = "CLOSED_SUCCESS_FROM_ABANDONED";
        CustomerJourneyCallbackStatus["CLOSED_DELETED_BY_AGENT_FROM_ABANDONED"] = "CLOSED_DELETED_BY_AGENT_FROM_ABANDONED";
        CustomerJourneyCallbackStatus["CLOSED"] = "CLOSED";
    })(CustomerJourneyCallbackStatus || (CustomerJourneyCallbackStatus = {}));
    var CustomerJourneyInteractionSubType;
    (function (CustomerJourneyInteractionSubType) {
        CustomerJourneyInteractionSubType["EMAIL"] = "EMAIL";
        CustomerJourneyInteractionSubType["SMS"] = "SMS";
        CustomerJourneyInteractionSubType["CHAT"] = "CHAT";
        CustomerJourneyInteractionSubType["FAX"] = "FAX";
        CustomerJourneyInteractionSubType["PHONE"] = "PHONE";
        CustomerJourneyInteractionSubType["TWITTER_STATUS"] = "TWITTER_STATUS";
        CustomerJourneyInteractionSubType["TWITTER_DIRECT_MESSAGE"] = "TWITTER_DIRECT_MESSAGE";
        CustomerJourneyInteractionSubType["FACEBOOK_FEED_POST"] = "FACEBOOK_FEED_POST";
        CustomerJourneyInteractionSubType["FACEBOOK_FEED_COMMENT"] = "FACEBOOK_FEED_COMMENT";
        CustomerJourneyInteractionSubType["NOTE"] = "NOTE";
        CustomerJourneyInteractionSubType["WEB"] = "WEB";
        CustomerJourneyInteractionSubType["TELEGRAM_PERSONAL_MESSAGE"] = "TELEGRAM_PERSONAL_MESSAGE";
    })(CustomerJourneyInteractionSubType || (CustomerJourneyInteractionSubType = {}));
    var CustomerJourneyInteractionType;
    (function (CustomerJourneyInteractionType) {
        CustomerJourneyInteractionType["CALL"] = "CALL";
        CustomerJourneyInteractionType["CALL_SERVICE"] = "CALL_SERVICE";
        CustomerJourneyInteractionType["SMS"] = "SMS";
        CustomerJourneyInteractionType["CALLBACK_IVR"] = "CALLBACK_IVR";
        CustomerJourneyInteractionType["CALLBACK_WEB"] = "CALLBACK_WEB";
        CustomerJourneyInteractionType["ABANDONED_CALL"] = "ABANDONED_CALL";
        CustomerJourneyInteractionType["VIDEO"] = "VIDEO";
        CustomerJourneyInteractionType["TICKET"] = "TICKET";
        CustomerJourneyInteractionType["CHAT"] = "CHAT";
        CustomerJourneyInteractionType["WHATSAPP_TWILIO"] = "WHATSAPP_TWILIO";
        CustomerJourneyInteractionType["IOT"] = "IOT";
        CustomerJourneyInteractionType["FAX"] = "FAX";
        CustomerJourneyInteractionType["VOICEMAIL"] = "VOICEMAIL";
    })(CustomerJourneyInteractionType || (CustomerJourneyInteractionType = {}));
    var CustomerJourneySmsStatus;
    (function (CustomerJourneySmsStatus) {
        CustomerJourneySmsStatus["SMS_FAILED"] = "SMS_FAILED";
        CustomerJourneySmsStatus["SMS_ANSWERED"] = "SMS_ANSWERED";
    })(CustomerJourneySmsStatus || (CustomerJourneySmsStatus = {}));
    var CustomerJourneyTicketStatus;
    (function (CustomerJourneyTicketStatus) {
        CustomerJourneyTicketStatus["NEW"] = "NEW";
        CustomerJourneyTicketStatus["OPEN"] = "OPEN";
        CustomerJourneyTicketStatus["PENDING_REMINDER"] = "PENDING_REMINDER";
        CustomerJourneyTicketStatus["CLOSED"] = "CLOSED";
        CustomerJourneyTicketStatus["MERGED"] = "MERGED";
        CustomerJourneyTicketStatus["REMOVED"] = "REMOVED";
        CustomerJourneyTicketStatus["PENDING_CLOSE"] = "PENDING_CLOSE";
    })(CustomerJourneyTicketStatus || (CustomerJourneyTicketStatus = {}));
    var CustomerPortalRole;
    (function (CustomerPortalRole) {
        CustomerPortalRole["USER"] = "USER";
        CustomerPortalRole["USER_FACTORY"] = "USER_FACTORY";
    })(CustomerPortalRole || (CustomerPortalRole = {}));
    var DTOStatus;
    (function (DTOStatus) {
        DTOStatus["DELETED"] = "DELETED";
        DTOStatus["NEW"] = "NEW";
        DTOStatus["MODIFIED"] = "MODIFIED";
    })(DTOStatus || (DTOStatus = {}));
    var DelayedTaskStatus;
    (function (DelayedTaskStatus) {
        DelayedTaskStatus["WAITING"] = "WAITING";
        DelayedTaskStatus["RUNNING"] = "RUNNING";
        DelayedTaskStatus["END"] = "END";
        DelayedTaskStatus["ERROR"] = "ERROR";
    })(DelayedTaskStatus || (DelayedTaskStatus = {}));
    var DelayedTaskType;
    (function (DelayedTaskType) {
        DelayedTaskType["CONTACT_MERGE"] = "CONTACT_MERGE";
        DelayedTaskType["CONTACT_FORGET"] = "CONTACT_FORGET";
    })(DelayedTaskType || (DelayedTaskType = {}));
    var DevStatus;
    (function (DevStatus) {
        DevStatus["TRASF"] = "TRASF";
        DevStatus["TRASF_CANCEL"] = "TRASF_CANCEL";
        DevStatus["TRASF_ANSWER"] = "TRASF_ANSWER";
        DevStatus["TRASF_VM"] = "TRASF_VM";
        DevStatus["TRASF_VM_NO"] = "TRASF_VM_NO";
        DevStatus["RETURN"] = "RETURN";
    })(DevStatus || (DevStatus = {}));
    var DeviceCommandRequest;
    (function (DeviceCommandRequest) {
        DeviceCommandRequest["DIAL"] = "DIAL";
        DeviceCommandRequest["ANSWER"] = "ANSWER";
        DeviceCommandRequest["CANCEL"] = "CANCEL";
        DeviceCommandRequest["HOLD"] = "HOLD";
        DeviceCommandRequest["UNHOLD"] = "UNHOLD";
        DeviceCommandRequest["DTMF"] = "DTMF";
        DeviceCommandRequest["TRANSFER_BLIND"] = "TRANSFER_BLIND";
        DeviceCommandRequest["TRANSFER_ATTENDED"] = "TRANSFER_ATTENDED";
    })(DeviceCommandRequest || (DeviceCommandRequest = {}));
    var DeviceCommandResult;
    (function (DeviceCommandResult) {
        DeviceCommandResult["OK"] = "OK";
        DeviceCommandResult["FAILED"] = "FAILED";
        DeviceCommandResult["TIMEOUT_EXPIRED"] = "TIMEOUT_EXPIRED";
        DeviceCommandResult["DEVICE_CLOSED"] = "DEVICE_CLOSED";
        DeviceCommandResult["FEATURE_UNSUPPORTED"] = "FEATURE_UNSUPPORTED";
    })(DeviceCommandResult || (DeviceCommandResult = {}));
    var DeviceEventType;
    (function (DeviceEventType) {
        DeviceEventType["CALL_NEW_INCOMING"] = "CALL_NEW_INCOMING";
        DeviceEventType["CALL_NEW_OUTGOING"] = "CALL_NEW_OUTGOING";
    })(DeviceEventType || (DeviceEventType = {}));
    var DialStatus;
    (function (DialStatus) {
        DialStatus["CHANUNAVAIL"] = "CHANUNAVAIL";
        DialStatus["CONGESTION"] = "CONGESTION";
        DialStatus["NOANSWER"] = "NOANSWER";
        DialStatus["BUSY"] = "BUSY";
        DialStatus["ANSWER"] = "ANSWER";
        DialStatus["CANCEL"] = "CANCEL";
        DialStatus["ERROR"] = "ERROR";
        DialStatus["NON_PRESENTE"] = "NON_PRESENTE";
        DialStatus["ALWAYS"] = "ALWAYS";
        DialStatus["ENABLE_FROM_PHONE"] = "ENABLE_FROM_PHONE";
        DialStatus["PICKUPED"] = "PICKUPED";
        DialStatus["PICKUPER"] = "PICKUPER";
        DialStatus["TVOX_NO_PERMISSION"] = "TVOX_NO_PERMISSION";
        DialStatus["DONTCALL"] = "DONTCALL";
        DialStatus["REJECTED"] = "REJECTED";
    })(DialStatus || (DialStatus = {}));
    var Direction;
    (function (Direction) {
        Direction["IN"] = "IN";
        Direction["OUT"] = "OUT";
        Direction["UNKNOWN"] = "UNKNOWN";
    })(Direction || (Direction = {}));
    var EmailBoxTicketingResult;
    (function (EmailBoxTicketingResult) {
        EmailBoxTicketingResult["SUCCESS"] = "success";
        EmailBoxTicketingResult["DUPLICATE"] = "duplicate";
        EmailBoxTicketingResult["INVALID"] = "invalid";
        EmailBoxTicketingResult["OK"] = "ok";
    })(EmailBoxTicketingResult || (EmailBoxTicketingResult = {}));
    var Enable;
    (function (Enable) {
        Enable["ENABLED"] = "ENABLED";
        Enable["DISABLED"] = "DISABLED";
    })(Enable || (Enable = {}));
    var Enabled;
    (function (Enabled) {
        Enabled["ENABLED"] = "ENABLED";
        Enabled["DISABLED"] = "DISABLED";
        Enabled["DEFAULT"] = "DEFAULT";
    })(Enabled || (Enabled = {}));
    var EventColor;
    (function (EventColor) {
        EventColor["WHITE"] = "WHITE";
        EventColor["YELLOW"] = "YELLOW";
        EventColor["RED"] = "RED";
        EventColor["GREEN"] = "GREEN";
        EventColor["ORANGE"] = "ORANGE";
    })(EventColor || (EventColor = {}));
    var EventType;
    (function (EventType) {
        EventType["MESSAGE"] = "MESSAGE";
        EventType["OPEN_SESSION"] = "OPEN_SESSION";
        EventType["CLOSE_SESSION"] = "CLOSE_SESSION";
    })(EventType || (EventType = {}));
    var ExeOpenType;
    (function (ExeOpenType) {
        ExeOpenType["DISABLED"] = "DISABLED";
        ExeOpenType["WEBVIEW_SINGLE"] = "WEBVIEW_SINGLE";
        ExeOpenType["WEBVIEW_MULTI"] = "WEBVIEW_MULTI";
        ExeOpenType["WEBVIEW_NEW_TAB"] = "WEBVIEW_NEW_TAB";
        ExeOpenType["BROWSER"] = "BROWSER";
    })(ExeOpenType || (ExeOpenType = {}));
    var ExtenStatus;
    (function (ExtenStatus) {
        ExtenStatus["IDLE"] = "IDLE";
        ExtenStatus["IN_USE"] = "IN_USE";
        ExtenStatus["BUSY"] = "BUSY";
        ExtenStatus["UNAVAILABLE"] = "UNAVAILABLE";
        ExtenStatus["RINGING"] = "RINGING";
        ExtenStatus["IN_USE_AND_RINGING"] = "IN_USE_AND_RINGING";
        ExtenStatus["HOLD"] = "HOLD";
        ExtenStatus["IN_USE_AND_HOLD"] = "IN_USE_AND_HOLD";
        ExtenStatus["UNKNOWN"] = "UNKNOWN";
    })(ExtenStatus || (ExtenStatus = {}));
    var ExtenType;
    (function (ExtenType) {
        ExtenType["MCS_SIP"] = "MCS_SIP";
        ExtenType["MCS_APP"] = "MCS_APP";
        ExtenType["MCS_APP_WEBRTC"] = "MCS_APP_WEBRTC";
        ExtenType["SIP"] = "SIP";
        ExtenType["EXTERNAL"] = "EXTERNAL";
        ExtenType["WEBRTC"] = "WEBRTC";
    })(ExtenType || (ExtenType = {}));
    var FavouriteUserItemType;
    (function (FavouriteUserItemType) {
        FavouriteUserItemType["USER"] = "USER";
        FavouriteUserItemType["GROUP"] = "GROUP";
    })(FavouriteUserItemType || (FavouriteUserItemType = {}));
    var FaxDocumentStatus;
    (function (FaxDocumentStatus) {
        FaxDocumentStatus["IDLE"] = "IDLE";
        FaxDocumentStatus["CREATING_FILE"] = "CREATING_FILE";
        FaxDocumentStatus["TO_SEND"] = "TO_SEND";
        FaxDocumentStatus["CALLING"] = "CALLING";
        FaxDocumentStatus["SENDING"] = "SENDING";
        FaxDocumentStatus["SEND"] = "SEND";
        FaxDocumentStatus["RECEIVING"] = "RECEIVING";
        FaxDocumentStatus["RECEIVED"] = "RECEIVED";
        FaxDocumentStatus["ERROR"] = "ERROR";
        FaxDocumentStatus["ERROR_NO_LICENSE"] = "ERROR_NO_LICENSE";
        FaxDocumentStatus["ERROR_CALLING"] = "ERROR_CALLING";
        FaxDocumentStatus["ERROR_CREATE_FILE"] = "ERROR_CREATE_FILE";
        FaxDocumentStatus["ERROR_SENDING"] = "ERROR_SENDING";
        FaxDocumentStatus["ERROR_NO_USER_FAXBOX"] = "ERROR_NO_USER_FAXBOX";
        FaxDocumentStatus["ERROR_NO_USER_FAXBOX_SEND_ENABLED"] = "ERROR_NO_USER_FAXBOX_SEND_ENABLED";
    })(FaxDocumentStatus || (FaxDocumentStatus = {}));
    var FaxDocumentType;
    (function (FaxDocumentType) {
        FaxDocumentType["INBOUND"] = "INBOUND";
        FaxDocumentType["OUTBOUND"] = "OUTBOUND";
    })(FaxDocumentType || (FaxDocumentType = {}));
    var Field;
    (function (Field) {
        Field["dtoStatus"] = "dtoStatus";
        Field["ownerPanels"] = "ownerPanels";
    })(Field || (Field = {}));
    var FieldType;
    (function (FieldType) {
        FieldType["MAIN"] = "MAIN";
        FieldType["WORK"] = "WORK";
        FieldType["CELL"] = "CELL";
        FieldType["HOME"] = "HOME";
        FieldType["NONE"] = "NONE";
        FieldType["FAX"] = "FAX";
    })(FieldType || (FieldType = {}));
    var GeneralParamType;
    (function (GeneralParamType) {
        GeneralParamType["NUMBER"] = "NUMBER";
        GeneralParamType["STRING"] = "STRING";
        GeneralParamType["BOOLEAN"] = "BOOLEAN";
    })(GeneralParamType || (GeneralParamType = {}));
    var IciReason;
    (function (IciReason) {
        IciReason["DIRECT"] = "DIRECT";
        IciReason["REDIRECT"] = "REDIRECT";
        IciReason["FWDNOANSWER"] = "FWDNOANSWER";
        IciReason["FWDBUSY"] = "FWDBUSY";
        IciReason["FWDUNCOND"] = "FWDUNCOND";
        IciReason["UNAVAIL"] = "UNAVAIL";
    })(IciReason || (IciReason = {}));
    var IciType;
    (function (IciType) {
        IciType["INTERNAL"] = "INTERNAL";
        IciType["EXTERNAL"] = "EXTERNAL";
        IciType["REMOTE"] = "REMOTE";
    })(IciType || (IciType = {}));
    var Id;
    (function (Id) {
        Id["NONE"] = "NONE";
        Id["CLASS"] = "CLASS";
        Id["MINIMAL_CLASS"] = "MINIMAL_CLASS";
        Id["NAME"] = "NAME";
        Id["CUSTOM"] = "CUSTOM";
    })(Id || (Id = {}));
    var IdType;
    (function (IdType) {
        IdType["CALL"] = "CALL";
        IdType["MC_1"] = "MC_1";
        IdType["MC_2"] = "MC_2";
        IdType["MC_3"] = "MC_3";
        IdType["MC_VIDEO"] = "MC_VIDEO";
        IdType["MC_MAIL_IFRAME"] = "MC_MAIL_IFRAME";
        IdType["MC_CHAT"] = "MC_CHAT";
        IdType["MC_WHATSAPP_TWILIO"] = "MC_WHATSAPP_TWILIO";
        IdType["MC_OMNIDESK"] = "MC_OMNIDESK";
    })(IdType || (IdType = {}));
    var IdleReason;
    (function (IdleReason) {
        IdleReason["HANGUP"] = "HANGUP";
        IdleReason["BUSY"] = "BUSY";
        IdleReason["CONGESTION"] = "CONGESTION";
    })(IdleReason || (IdleReason = {}));
    var JQGridOp;
    (function (JQGridOp) {
        JQGridOp["AND"] = "AND";
        JQGridOp["OR"] = "OR";
    })(JQGridOp || (JQGridOp = {}));
    var JQGridRuleOp;
    (function (JQGridRuleOp) {
        JQGridRuleOp["EQUAL"] = "EQUAL";
        JQGridRuleOp["NOT_EQUAL"] = "NOT_EQUAL";
        JQGridRuleOp["LESS"] = "LESS";
        JQGridRuleOp["LESS_EQUAL"] = "LESS_EQUAL";
        JQGridRuleOp["GREATER"] = "GREATER";
        JQGridRuleOp["GREATER_EQUAL"] = "GREATER_EQUAL";
        JQGridRuleOp["CONTAINS"] = "CONTAINS";
        JQGridRuleOp["NOT_CONTAINS"] = "NOT_CONTAINS";
        JQGridRuleOp["BEGIN_WITH"] = "BEGIN_WITH";
        JQGridRuleOp["NOT_BEGIN_WITH"] = "NOT_BEGIN_WITH";
        JQGridRuleOp["END_WITH"] = "END_WITH";
        JQGridRuleOp["NOT_END_WITH"] = "NOT_END_WITH";
        JQGridRuleOp["IS_NULL"] = "IS_NULL";
        JQGridRuleOp["IS_NOT_NULL"] = "IS_NOT_NULL";
        JQGridRuleOp["IS_IN"] = "IS_IN";
        JQGridRuleOp["IS_NOT_IN"] = "IS_NOT_IN";
    })(JQGridRuleOp || (JQGridRuleOp = {}));
    var KnowledgeBaseCategoryViewType;
    (function (KnowledgeBaseCategoryViewType) {
        KnowledgeBaseCategoryViewType["FAQ"] = "FAQ";
        KnowledgeBaseCategoryViewType["TREE"] = "TREE";
    })(KnowledgeBaseCategoryViewType || (KnowledgeBaseCategoryViewType = {}));
    var KnowledgebaseUserEnabling;
    (function (KnowledgebaseUserEnabling) {
        KnowledgebaseUserEnabling["DISABLED"] = "DISABLED";
        KnowledgebaseUserEnabling["READ"] = "READ";
        KnowledgebaseUserEnabling["READWRITE"] = "READWRITE";
    })(KnowledgebaseUserEnabling || (KnowledgebaseUserEnabling = {}));
    var Language;
    (function (Language) {
        Language["IT"] = "IT";
        Language["it_IT"] = "it_IT";
        Language["EN"] = "EN";
        Language["en_US"] = "en_US";
    })(Language || (Language = {}));
    var LastActivityType;
    (function (LastActivityType) {
        LastActivityType["CHAT"] = "CHAT";
        LastActivityType["CALL"] = "CALL";
        LastActivityType["MAIL"] = "MAIL";
        LastActivityType["WEB"] = "WEB";
        LastActivityType["FACEBOOK"] = "FACEBOOK";
        LastActivityType["TWITTER"] = "TWITTER";
        LastActivityType["VIDEO"] = "VIDEO";
        LastActivityType["TELEGRAM"] = "TELEGRAM";
        LastActivityType["CHANNEL_1"] = "CHANNEL_1";
        LastActivityType["CHANNEL_2"] = "CHANNEL_2";
        LastActivityType["CHANNEL_3"] = "CHANNEL_3";
    })(LastActivityType || (LastActivityType = {}));
    var LicenseModule;
    (function (LicenseModule) {
        LicenseModule["CUSTOMER_JOURNEY"] = "CUSTOMER_JOURNEY";
        LicenseModule["INSIGHT"] = "INSIGHT";
    })(LicenseModule || (LicenseModule = {}));
    var LinkType;
    (function (LinkType) {
        LinkType["PARENT"] = "parent";
        LinkType["CHILD"] = "child";
        LinkType["NORMAL"] = "normal";
    })(LinkType || (LinkType = {}));
    var LoginProfileStatus;
    (function (LoginProfileStatus) {
        LoginProfileStatus["UNKNOWN"] = "UNKNOWN";
        LoginProfileStatus["LOGGED"] = "LOGGED";
        LoginProfileStatus["NOTLOGGED"] = "NOTLOGGED";
        LoginProfileStatus["RETRY"] = "RETRY";
        LoginProfileStatus["REFRESH"] = "REFRESH";
        LoginProfileStatus["SOCKET_NOTLOGGED"] = "SOCKET_NOTLOGGED";
        LoginProfileStatus["PASSWORD_EXPIRED"] = "PASSWORD_EXPIRED";
        LoginProfileStatus["SOCKET_CLOSED_REQUEST_FORCE"] = "SOCKET_CLOSED_REQUEST_FORCE";
        LoginProfileStatus["SOCKET_CLOSED_BY_USER"] = "SOCKET_CLOSED_BY_USER";
        LoginProfileStatus["SOCKET_CLOSED_USER_NOT_ENABLED"] = "SOCKET_CLOSED_USER_NOT_ENABLED";
        LoginProfileStatus["SOCKET_CLOSED_USER_NOT_ENABLED_MCS"] = "SOCKET_CLOSED_USER_NOT_ENABLED_MCS";
    })(LoginProfileStatus || (LoginProfileStatus = {}));
    var LookupResult;
    (function (LookupResult) {
        LookupResult["SUCCESS"] = "SUCCESS";
        LookupResult["MULTIPLE"] = "MULTIPLE";
        LookupResult["ERROR"] = "ERROR";
        LookupResult["NONE"] = "NONE";
    })(LookupResult || (LookupResult = {}));
    var Mode;
    (function (Mode) {
        Mode["EMAIL"] = "EMAIL";
        Mode["SMS"] = "SMS";
    })(Mode || (Mode = {}));
    var MultiChannelCategory;
    (function (MultiChannelCategory) {
        MultiChannelCategory["STANDARD"] = "STANDARD";
        MultiChannelCategory["TELEPHONY"] = "TELEPHONY";
        MultiChannelCategory["VIDEOCALL"] = "VIDEOCALL";
        MultiChannelCategory["CHAT"] = "CHAT";
        MultiChannelCategory["EMAIL"] = "EMAIL";
    })(MultiChannelCategory || (MultiChannelCategory = {}));
    var NoteRemainderStatus;
    (function (NoteRemainderStatus) {
        NoteRemainderStatus["WITHOUT_EXPIRED_TIME"] = "WITHOUT_EXPIRED_TIME";
        NoteRemainderStatus["WITH_EXPIRED_TIME"] = "WITH_EXPIRED_TIME";
        NoteRemainderStatus["EXPIRED"] = "EXPIRED";
        NoteRemainderStatus["EXPIRING"] = "EXPIRING";
        NoteRemainderStatus["NOT_EXPIRED"] = "NOT_EXPIRED";
    })(NoteRemainderStatus || (NoteRemainderStatus = {}));
    var NoteType;
    (function (NoteType) {
        NoteType["NOTE"] = "NOTE";
        NoteType["LIST"] = "LIST";
    })(NoteType || (NoteType = {}));
    var NotificationMode;
    (function (NotificationMode) {
        NotificationMode["MAIL"] = "MAIL";
        NotificationMode["SMS"] = "SMS";
    })(NotificationMode || (NotificationMode = {}));
    var NotifyChange;
    (function (NotifyChange) {
        NotifyChange["ALWAYS"] = "ALWAYS";
        NotifyChange["ONETIME"] = "ONETIME";
        NotifyChange["NEVER"] = "NEVER";
    })(NotifyChange || (NotifyChange = {}));
    var NotifyMethod;
    (function (NotifyMethod) {
        NotifyMethod["CALL"] = "CALL";
        NotifyMethod["MAIL"] = "MAIL";
        NotifyMethod["SMS"] = "SMS";
        NotifyMethod["CHAT"] = "CHAT";
        NotifyMethod["ALL"] = "ALL";
    })(NotifyMethod || (NotifyMethod = {}));
    var Nulls;
    (function (Nulls) {
        Nulls["SET"] = "SET";
        Nulls["SKIP"] = "SKIP";
        Nulls["FAIL"] = "FAIL";
        Nulls["AS_EMPTY"] = "AS_EMPTY";
        Nulls["DEFAULT"] = "DEFAULT";
    })(Nulls || (Nulls = {}));
    var NumberType;
    (function (NumberType) {
        NumberType["INTERNAL"] = "INTERNAL";
        NumberType["EXTERNAL"] = "EXTERNAL";
        NumberType["REMOTE"] = "REMOTE";
    })(NumberType || (NumberType = {}));
    var OmnideskFeature;
    (function (OmnideskFeature) {
        OmnideskFeature["microphone"] = "microphone";
        OmnideskFeature["camera"] = "camera";
        OmnideskFeature["closedcaptions"] = "closedcaptions";
        OmnideskFeature["desktop"] = "desktop";
        OmnideskFeature["fodeviceselection"] = "fodeviceselection";
        OmnideskFeature["hangup"] = "hangup";
        OmnideskFeature["recording"] = "recording";
        OmnideskFeature["livestreaming"] = "livestreaming";
        OmnideskFeature["sharedvideo"] = "sharedvideo";
        OmnideskFeature["settings"] = "settings";
        OmnideskFeature["raisehand"] = "raisehand";
        OmnideskFeature["videoquality"] = "videoquality";
        OmnideskFeature["invite"] = "invite";
        OmnideskFeature["feedback"] = "feedback";
        OmnideskFeature["stats"] = "stats";
        OmnideskFeature["select_background"] = "select_background";
        OmnideskFeature["mute_everyone"] = "mute_everyone";
        OmnideskFeature["mute_video_everyone"] = "mute_video_everyone";
    })(OmnideskFeature || (OmnideskFeature = {}));
    var OmnideskMeetingEventParticipantFeature;
    (function (OmnideskMeetingEventParticipantFeature) {
        OmnideskMeetingEventParticipantFeature["LIVE_STREAMING"] = "LIVE_STREAMING";
        OmnideskMeetingEventParticipantFeature["RECORDING"] = "RECORDING";
        OmnideskMeetingEventParticipantFeature["MODERATOR"] = "MODERATOR";
        OmnideskMeetingEventParticipantFeature["ORGANIZER"] = "ORGANIZER";
    })(OmnideskMeetingEventParticipantFeature || (OmnideskMeetingEventParticipantFeature = {}));
    var OmnideskMeetingEventParticipantStatus;
    (function (OmnideskMeetingEventParticipantStatus) {
        OmnideskMeetingEventParticipantStatus["ACCEPTED"] = "ACCEPTED";
        OmnideskMeetingEventParticipantStatus["DECLINED"] = "DECLINED";
        OmnideskMeetingEventParticipantStatus["PENDING_RESPONSE"] = "PENDING_RESPONSE";
        OmnideskMeetingEventParticipantStatus["COMPLETED"] = "COMPLETED";
    })(OmnideskMeetingEventParticipantStatus || (OmnideskMeetingEventParticipantStatus = {}));
    var OperationType;
    (function (OperationType) {
        OperationType["EQUAL"] = "EQUAL";
        OperationType["NOT_EQUAL"] = "NOT_EQUAL";
        OperationType["CONTAINS"] = "CONTAINS";
        OperationType["GT"] = "GT";
        OperationType["GE"] = "GE";
        OperationType["LT"] = "LT";
        OperationType["LE"] = "LE";
        OperationType["NOT_NULL"] = "NOT_NULL";
        OperationType["BETWEEN"] = "BETWEEN";
    })(OperationType || (OperationType = {}));
    var Operator;
    (function (Operator) {
        Operator["is"] = "is";
        Operator["isNot"] = "is not";
        Operator["hasChanged"] = "has changed";
        Operator["contains"] = "contains";
        Operator["containsNot"] = "contains not";
        Operator["absoluteBefore"] = "before (absolute)";
        Operator["relativeBefore"] = "before (relative)";
        Operator["absoluteAfter"] = "after (absolute)";
        Operator["relativeAfter"] = "after (relative)";
        Operator["relativeWithinNext"] = "within next (relative)";
        Operator["relativeWithinLast"] = "within last (relative)";
    })(Operator || (Operator = {}));
    var OrderType;
    (function (OrderType) {
        OrderType["ASC"] = "ASC";
        OrderType["DESC"] = "DESC";
    })(OrderType || (OrderType = {}));
    var OrdinationType;
    (function (OrdinationType) {
        OrdinationType["ASC"] = "ASC";
        OrdinationType["DESC"] = "DESC";
    })(OrdinationType || (OrdinationType = {}));
    var PartType;
    (function (PartType) {
        PartType["START"] = "START";
        PartType["END"] = "END";
    })(PartType || (PartType = {}));
    var PeerStatus;
    (function (PeerStatus) {
        PeerStatus["UNKNOWN"] = "UNKNOWN";
        PeerStatus["UNREGISTERED"] = "UNREGISTERED";
        PeerStatus["LAGGED"] = "LAGGED";
        PeerStatus["UNMONITORED"] = "UNMONITORED";
        PeerStatus["UNREACHABLE"] = "UNREACHABLE";
        PeerStatus["REGISTERED"] = "REGISTERED";
        PeerStatus["REACHABLE"] = "REACHABLE";
    })(PeerStatus || (PeerStatus = {}));
    var PeerType;
    (function (PeerType) {
        PeerType["SIP"] = "SIP";
        PeerType["IAX2"] = "IAX2";
        PeerType["ENUM"] = "ENUM";
        PeerType["UNKNOWN"] = "UNKNOWN";
    })(PeerType || (PeerType = {}));
    var Phase;
    (function (Phase) {
        Phase["START_REMOVE"] = "START_REMOVE";
        Phase["END_REMOVE"] = "END_REMOVE";
        Phase["START_IMPORT"] = "START_IMPORT";
        Phase["NOTIFY_IMPORT"] = "NOTIFY_IMPORT";
        Phase["END_IMPORT"] = "END_IMPORT";
        Phase["MSG"] = "MSG";
        Phase["NO_IMPORT_RUNNING"] = "NO_IMPORT_RUNNING";
    })(Phase || (Phase = {}));
    var Platform;
    (function (Platform) {
        Platform["WEB"] = "WEB";
        Platform["IOS"] = "IOS";
        Platform["ANDROID"] = "ANDROID";
        Platform["EXE"] = "EXE";
    })(Platform || (Platform = {}));
    var PresenceStatus;
    (function (PresenceStatus) {
        PresenceStatus["chat"] = "chat";
        PresenceStatus["available"] = "available";
        PresenceStatus["away"] = "away";
        PresenceStatus["xa"] = "xa";
        PresenceStatus["dnd"] = "dnd";
        PresenceStatus["unavailable"] = "unavailable";
    })(PresenceStatus || (PresenceStatus = {}));
    var ProductPrefix;
    (function (ProductPrefix) {
        ProductPrefix["TVOX"] = "TVOX";
        ProductPrefix["TSAM"] = "TSAM";
        ProductPrefix["TAM"] = "TAM";
        ProductPrefix["LDAP"] = "LDAP";
        ProductPrefix["SYSTEM"] = "SYSTEM";
        ProductPrefix["T4YOU"] = "T4YOU";
        ProductPrefix["WEB_CLIENT_PROXY"] = "WEB_CLIENT_PROXY";
        ProductPrefix["MCS"] = "MCS";
        ProductPrefix["CUSTOMER"] = "CUSTOMER";
    })(ProductPrefix || (ProductPrefix = {}));
    var Products;
    (function (Products) {
        Products["WSO2IS"] = "WSO2IS";
        Products["MCS_SERVER"] = "MCS_SERVER";
        Products["T4YOU"] = "T4YOU";
        Products["TCS"] = "TCS";
        Products["TSAM"] = "TSAM";
        Products["TVOX"] = "TVOX";
    })(Products || (Products = {}));
    var ProfileType;
    (function (ProfileType) {
        ProfileType["UC"] = "UC";
        ProfileType["AG"] = "AG";
        ProfileType["AG_EXTERNAL"] = "AG_EXTERNAL";
        ProfileType["AG_REMOTE"] = "AG_REMOTE";
        ProfileType["TQM"] = "TQM";
    })(ProfileType || (ProfileType = {}));
    var Reason;
    (function (Reason) {
        Reason["FILE_EXISTS"] = "FILE_EXISTS";
        Reason["WRONG_PERMISSION"] = "WRONG_PERMISSION";
        Reason["UNMANAGED_FILE_FORMAT"] = "UNMANAGED_FILE_FORMAT";
        Reason["GENERIC_ERROR"] = "GENERIC_ERROR";
    })(Reason || (Reason = {}));
    var RecType;
    (function (RecType) {
        RecType["ondemand"] = "ondemand";
        RecType["service"] = "service";
        RecType["automatic"] = "automatic";
        RecType["ondemand_start"] = "ondemand_start";
        RecType["ondemand_stop"] = "ondemand_stop";
        RecType["error"] = "error";
    })(RecType || (RecType = {}));
    var Recipient;
    (function (Recipient) {
        Recipient["article_last_sender"] = "article_last_sender";
        Recipient["ticket_owner"] = "ticket_owner";
        Recipient["ticket_customer"] = "ticket_customer";
        Recipient["ticket_agents"] = "ticket_agents";
    })(Recipient || (Recipient = {}));
    var RegistrationConfiguration;
    (function (RegistrationConfiguration) {
        RegistrationConfiguration["DISABLED"] = "DISABLED";
        RegistrationConfiguration["ENABLED"] = "ENABLED";
        RegistrationConfiguration["CUSTOMIZABLE"] = "CUSTOMIZABLE";
        RegistrationConfiguration["AUTO"] = "AUTO";
        RegistrationConfiguration["AUTO_CUSTOMIZABLE"] = "AUTO_CUSTOMIZABLE";
        RegistrationConfiguration["ENABLED_ON_PHONE"] = "ENABLED_ON_PHONE";
    })(RegistrationConfiguration || (RegistrationConfiguration = {}));
    var Result;
    (function (Result) {
        Result["SUCCESS"] = "SUCCESS";
        Result["ERR_INITIALIZATION"] = "ERR_INITIALIZATION";
        Result["ERR_OPTIONS"] = "ERR_OPTIONS";
        Result["IN_PROGRESS"] = "IN_PROGRESS";
        Result["MRCP_FAILURE"] = "MRCP_FAILURE";
        Result["MRCP_TERMINATE"] = "MRCP_TERMINATE";
        Result["MRCP_CANCEL"] = "MRCP_CANCEL";
        Result["MRCP_UNKNOWN"] = "MRCP_UNKNOWN";
        Result["PARAM_ERROR"] = "PARAM_ERROR";
        Result["UNKNOWN"] = "UNKNOWN";
    })(Result || (Result = {}));
    var Roles;
    (function (Roles) {
        Roles["ADMIN"] = "Admin";
        Roles["AGENT"] = "Agent";
        Roles["CUSTOMER"] = "Customer";
    })(Roles || (Roles = {}));
    var RunPhase;
    (function (RunPhase) {
        RunPhase["START_REMOVE"] = "START_REMOVE";
        RunPhase["END_REMOVE"] = "END_REMOVE";
        RunPhase["START_IMPORT"] = "START_IMPORT";
        RunPhase["NOTIFY_IMPORT"] = "NOTIFY_IMPORT";
        RunPhase["END_IMPORT"] = "END_IMPORT";
        RunPhase["MSG"] = "MSG";
        RunPhase["NO_IMPORT_RUNNING"] = "NO_IMPORT_RUNNING";
    })(RunPhase || (RunPhase = {}));
    var SIPCompatibility;
    (function (SIPCompatibility) {
        SIPCompatibility["full"] = "full";
        SIPCompatibility["applicationLayerGateway"] = "applicationLayerGateway";
    })(SIPCompatibility || (SIPCompatibility = {}));
    var ScheduledJobTimeplanDays;
    (function (ScheduledJobTimeplanDays) {
        ScheduledJobTimeplanDays["Mon"] = "Mon";
        ScheduledJobTimeplanDays["Tue"] = "Tue";
        ScheduledJobTimeplanDays["Wed"] = "Wed";
        ScheduledJobTimeplanDays["Thu"] = "Thu";
        ScheduledJobTimeplanDays["Fri"] = "Fri";
        ScheduledJobTimeplanDays["Sat"] = "Sat";
        ScheduledJobTimeplanDays["Sun"] = "Sun";
    })(ScheduledJobTimeplanDays || (ScheduledJobTimeplanDays = {}));
    var SearchFilterApplication;
    (function (SearchFilterApplication) {
        SearchFilterApplication["ALL"] = "ALL";
        SearchFilterApplication["WEBCLIENT"] = "WEBCLIENT";
        SearchFilterApplication["ELEMENTMANAGER"] = "ELEMENTMANAGER";
        SearchFilterApplication["REPORT"] = "REPORT";
    })(SearchFilterApplication || (SearchFilterApplication = {}));
    var SearchFilterFieldComparator;
    (function (SearchFilterFieldComparator) {
        SearchFilterFieldComparator["EQ"] = "EQ";
        SearchFilterFieldComparator["NOTEQ"] = "NOTEQ";
        SearchFilterFieldComparator["IN"] = "IN";
        SearchFilterFieldComparator["NOTIN"] = "NOTIN";
        SearchFilterFieldComparator["CONTAIN"] = "CONTAIN";
        SearchFilterFieldComparator["NOTCONTAIN"] = "NOTCONTAIN";
        SearchFilterFieldComparator["STARTWITH"] = "STARTWITH";
        SearchFilterFieldComparator["ENDWITH"] = "ENDWITH";
        SearchFilterFieldComparator["GREATER"] = "GREATER";
        SearchFilterFieldComparator["GREATEREQ"] = "GREATEREQ";
        SearchFilterFieldComparator["LESS"] = "LESS";
        SearchFilterFieldComparator["LESSEQ"] = "LESSEQ";
    })(SearchFilterFieldComparator || (SearchFilterFieldComparator = {}));
    var SearchFilterScope;
    (function (SearchFilterScope) {
        SearchFilterScope["TICKET"] = "TICKET";
        SearchFilterScope["CALL"] = "CALL";
        SearchFilterScope["CHAT"] = "CHAT";
        SearchFilterScope["PHONEBOOK"] = "PHONEBOOK";
    })(SearchFilterScope || (SearchFilterScope = {}));
    var SearchFilterType;
    (function (SearchFilterType) {
        SearchFilterType["SYSTEM"] = "SYSTEM";
        SearchFilterType["PUBLIC"] = "PUBLIC";
        SearchFilterType["PRIVATE"] = "PRIVATE";
    })(SearchFilterType || (SearchFilterType = {}));
    var ServiceDevStatus;
    (function (ServiceDevStatus) {
        ServiceDevStatus["TRANSFER_TO_SERVICE"] = "TRANSFER_TO_SERVICE";
        ServiceDevStatus["TRANSFER_TO_NUMBER"] = "TRANSFER_TO_NUMBER";
        ServiceDevStatus["TRANSFER_TO_CALLBACK"] = "TRANSFER_TO_CALLBACK";
    })(ServiceDevStatus || (ServiceDevStatus = {}));
    var ServiceType;
    (function (ServiceType) {
        ServiceType["UC"] = "UC";
        ServiceType["CALLCENTER"] = "CALLCENTER";
        ServiceType["POWER_DIALER"] = "POWER_DIALER";
        ServiceType["TQM"] = "TQM";
        ServiceType["IVR"] = "IVR";
    })(ServiceType || (ServiceType = {}));
    var SocialType;
    (function (SocialType) {
        SocialType["instagram"] = "instagram";
        SocialType["facebook"] = "facebook";
        SocialType["telegram"] = "telegram";
        SocialType["twitter"] = "twitter";
        SocialType["google"] = "google";
    })(SocialType || (SocialType = {}));
    var Status;
    (function (Status) {
        Status["CLIENT_ENABLED"] = "CLIENT_ENABLED";
        Status["SERVER_ENABLED"] = "SERVER_ENABLED";
        Status["DISABLED"] = "DISABLED";
    })(Status || (Status = {}));
    var StatusManagement;
    (function (StatusManagement) {
        StatusManagement["MANUAL"] = "MANUAL";
        StatusManagement["ALL_READY"] = "ALL_READY";
        StatusManagement["PRESERVE_READY"] = "PRESERVE_READY";
    })(StatusManagement || (StatusManagement = {}));
    var SwitchToGSMType;
    (function (SwitchToGSMType) {
        SwitchToGSMType["DISABLED"] = "DISABLED";
        SwitchToGSMType["BEFORE_ANSWER"] = "BEFORE_ANSWER";
        SwitchToGSMType["AFTER_ANSWER"] = "AFTER_ANSWER";
    })(SwitchToGSMType || (SwitchToGSMType = {}));
    var TicketChannel;
    (function (TicketChannel) {
        TicketChannel["EMAIL"] = "EMAIL";
        TicketChannel["PHONE"] = "PHONE";
        TicketChannel["NOTE"] = "NOTE";
        TicketChannel["TWITTER"] = "TWITTER";
        TicketChannel["FACEBOOK"] = "FACEBOOK";
        TicketChannel["TELEGRAM"] = "TELEGRAM";
        TicketChannel["CHAT"] = "CHAT";
        TicketChannel["WEB"] = "WEB";
    })(TicketChannel || (TicketChannel = {}));
    var TicketEscalationLevel;
    (function (TicketEscalationLevel) {
        TicketEscalationLevel["ESCALATION_NEAR"] = "ESCALATION_NEAR";
        TicketEscalationLevel["ESCALATION_DONE"] = "ESCALATION_DONE";
    })(TicketEscalationLevel || (TicketEscalationLevel = {}));
    var TicketFieldMultiUpdate;
    (function (TicketFieldMultiUpdate) {
        TicketFieldMultiUpdate["state_id"] = "state_id";
        TicketFieldMultiUpdate["group"] = "group";
        TicketFieldMultiUpdate["owner_username"] = "owner_username";
        TicketFieldMultiUpdate["priority_id"] = "priority_id";
        TicketFieldMultiUpdate["read"] = "read";
        TicketFieldMultiUpdate["unread"] = "unread";
        TicketFieldMultiUpdate["t_custom_01"] = "t_custom_01";
        TicketFieldMultiUpdate["t_custom_02"] = "t_custom_02";
        TicketFieldMultiUpdate["t_custom_03"] = "t_custom_03";
        TicketFieldMultiUpdate["t_custom_04"] = "t_custom_04";
        TicketFieldMultiUpdate["t_custom_05"] = "t_custom_05";
        TicketFieldMultiUpdate["t_custom_06"] = "t_custom_06";
        TicketFieldMultiUpdate["t_custom_07"] = "t_custom_07";
        TicketFieldMultiUpdate["t_custom_08"] = "t_custom_08";
        TicketFieldMultiUpdate["t_custom_09"] = "t_custom_09";
        TicketFieldMultiUpdate["t_custom_10"] = "t_custom_10";
        TicketFieldMultiUpdate["t_custom_11"] = "t_custom_11";
        TicketFieldMultiUpdate["t_custom_12"] = "t_custom_12";
        TicketFieldMultiUpdate["t_custom_13"] = "t_custom_13";
        TicketFieldMultiUpdate["t_custom_14"] = "t_custom_14";
        TicketFieldMultiUpdate["t_custom_15"] = "t_custom_15";
        TicketFieldMultiUpdate["t_custom_16"] = "t_custom_16";
        TicketFieldMultiUpdate["t_custom_17"] = "t_custom_17";
        TicketFieldMultiUpdate["t_custom_18"] = "t_custom_18";
        TicketFieldMultiUpdate["t_custom_19"] = "t_custom_19";
        TicketFieldMultiUpdate["t_custom_20"] = "t_custom_20";
    })(TicketFieldMultiUpdate || (TicketFieldMultiUpdate = {}));
    var TicketMergeResult;
    (function (TicketMergeResult) {
        TicketMergeResult["SUCCESS"] = "success";
        TicketMergeResult["FAILED"] = "failed";
    })(TicketMergeResult || (TicketMergeResult = {}));
    var TicketPriority;
    (function (TicketPriority) {
        TicketPriority["LOW"] = "1 low";
        TicketPriority["NORMAL"] = "2 normal";
        TicketPriority["HIGH"] = "3 high";
    })(TicketPriority || (TicketPriority = {}));
    var TicketQueueType;
    (function (TicketQueueType) {
        TicketQueueType["PICKUP"] = "PICKUP";
        TicketQueueType["ACD"] = "ACD";
    })(TicketQueueType || (TicketQueueType = {}));
    var TicketState;
    (function (TicketState) {
        TicketState["NEW"] = "new";
        TicketState["OPEN"] = "open";
        TicketState["PENDING_REMINDER"] = "pending reminder";
        TicketState["CLOSED"] = "closed";
        TicketState["MERGED"] = "merged";
        TicketState["REMOVED"] = "removed";
        TicketState["PENDING_CLOSE"] = "pending close";
    })(TicketState || (TicketState = {}));
    var TicketStateId;
    (function (TicketStateId) {
        TicketStateId["NEW"] = "NEW";
        TicketStateId["OPEN"] = "OPEN";
        TicketStateId["PENDING_REMINDER"] = "PENDING_REMINDER";
        TicketStateId["CLOSED"] = "CLOSED";
        TicketStateId["MERGED"] = "MERGED";
        TicketStateId["REMOVED"] = "REMOVED";
        TicketStateId["PENDING_CLOSE"] = "PENDING_CLOSE";
    })(TicketStateId || (TicketStateId = {}));
    var TicketUnmanagedType;
    (function (TicketUnmanagedType) {
        TicketUnmanagedType["EMAIL"] = "EMAIL";
        TicketUnmanagedType["TWITTER"] = "TWITTER";
        TicketUnmanagedType["FACEBOOK"] = "FACEBOOK";
        TicketUnmanagedType["TELEGRAM"] = "TELEGRAM";
        TicketUnmanagedType["TICKET"] = "TICKET";
    })(TicketUnmanagedType || (TicketUnmanagedType = {}));
    var TransportType;
    (function (TransportType) {
        TransportType["PHONE"] = "PHONE";
        TransportType["VOICEMAIL"] = "VOICEMAIL";
        TransportType["FAX"] = "FAX";
        TransportType["SMS"] = "SMS";
    })(TransportType || (TransportType = {}));
    var TypeValue;
    (function (TypeValue) {
        TypeValue["CALL"] = "CALL";
        TypeValue["CHANNEL_1"] = "CHANNEL_1";
        TypeValue["CHANNEL_2"] = "CHANNEL_2";
        TypeValue["CHANNEL_3"] = "CHANNEL_3";
        TypeValue["MAIL"] = "MAIL";
        TypeValue["LIVEHELP"] = "LIVEHELP";
        TypeValue["VIDEO"] = "VIDEO";
        TypeValue["CHAT"] = "CHAT";
        TypeValue["WHATSAPP"] = "WHATSAPP";
        TypeValue["OMNIDESK"] = "OMNIDESK";
        TypeValue["CALLBACK"] = "CALLBACK";
    })(TypeValue || (TypeValue = {}));
    var UseDTLS;
    (function (UseDTLS) {
        UseDTLS["YES"] = "YES";
        UseDTLS["NO"] = "NO";
    })(UseDTLS || (UseDTLS = {}));
    var UserFavouriteContactType;
    (function (UserFavouriteContactType) {
        UserFavouriteContactType["user"] = "user";
        UserFavouriteContactType["service"] = "service";
        UserFavouriteContactType["external_addressbook"] = "external_addressbook";
        UserFavouriteContactType["personal_addressbook"] = "personal_addressbook";
        UserFavouriteContactType["short_number"] = "short_number";
    })(UserFavouriteContactType || (UserFavouriteContactType = {}));
    var UserInteractionServiceCode;
    (function (UserInteractionServiceCode) {
        UserInteractionServiceCode["DIR_GO"] = "DIR_GO";
        UserInteractionServiceCode["INBOUND_CALL_LIMIT"] = "INBOUND_CALL_LIMIT";
        UserInteractionServiceCode["AUTH_CODE"] = "AUTH_CODE";
        UserInteractionServiceCode["BLOCCO_TEL"] = "BLOCCO_TEL";
        UserInteractionServiceCode["VOICEMAIL"] = "VOICEMAIL";
        UserInteractionServiceCode["VOICEMAIL_SERVIZI"] = "VOICEMAIL_SERVIZI";
        UserInteractionServiceCode["LOGIN"] = "LOGIN";
        UserInteractionServiceCode["Ready_NotReady"] = "Ready_NotReady";
        UserInteractionServiceCode["CFWD"] = "CFWD";
        UserInteractionServiceCode["CFWD_VOICEMAIL"] = "CFWD_VOICEMAIL";
        UserInteractionServiceCode["CFWD_INT"] = "CFWD_INT";
        UserInteractionServiceCode["CFWD_CFWD_INT_VMAIL"] = "CFWD_CFWD_INT_VMAIL";
        UserInteractionServiceCode["CFWD_EXT"] = "CFWD_EXT";
        UserInteractionServiceCode["CFWD_CFWD_EXT_VMAIL"] = "CFWD_CFWD_EXT_VMAIL";
        UserInteractionServiceCode["CHANSPY"] = "CHANSPY";
        UserInteractionServiceCode["SEND_ALARM"] = "SEND_ALARM";
        UserInteractionServiceCode["ECHO_CODE"] = "ECHO_CODE";
        UserInteractionServiceCode["PRIVATE_CONFERENCE"] = "PRIVATE_CONFERENCE";
        UserInteractionServiceCode["PUBLIC_CONFERENCE"] = "PUBLIC_CONFERENCE";
        UserInteractionServiceCode["PARK"] = "PARK";
        UserInteractionServiceCode["PICKUP"] = "PICKUP";
        UserInteractionServiceCode["DND"] = "DND";
        UserInteractionServiceCode["REMOTE_FOWARD"] = "REMOTE_FOWARD";
    })(UserInteractionServiceCode || (UserInteractionServiceCode = {}));
    var UserInteractionStatus;
    (function (UserInteractionStatus) {
        UserInteractionStatus["ACTIVE"] = "ACTIVE";
        UserInteractionStatus["REMAINDER"] = "REMAINDER";
        UserInteractionStatus["CLOSED"] = "CLOSED";
    })(UserInteractionStatus || (UserInteractionStatus = {}));
    var UserInteractionType;
    (function (UserInteractionType) {
        UserInteractionType["call"] = "call";
        UserInteractionType["chat"] = "chat";
        UserInteractionType["note"] = "note";
        UserInteractionType["voicemail"] = "voicemail";
        UserInteractionType["fax"] = "fax";
        UserInteractionType["ticket"] = "ticket";
    })(UserInteractionType || (UserInteractionType = {}));
    var UserNoteType;
    (function (UserNoteType) {
        UserNoteType["note"] = "note";
        UserNoteType["list"] = "list";
    })(UserNoteType || (UserNoteType = {}));
    var UserOfGenericType;
    (function (UserOfGenericType) {
        UserOfGenericType["MOH"] = "MOH";
        UserOfGenericType["REC"] = "REC";
        UserOfGenericType["SERVICE"] = "SERVICE";
        UserOfGenericType["SERVICE_CODE"] = "SERVICE_CODE";
        UserOfGenericType["SKILLSET"] = "SKILLSET";
        UserOfGenericType["SKILLSET_SCHEDULE"] = "SKILLSET_SCHEDULE";
        UserOfGenericType["ADS_ALARM"] = "ADS_ALARM";
        UserOfGenericType["ADS_ALARM_LIST"] = "ADS_ALARM_LIST";
        UserOfGenericType["CONFERENCE"] = "CONFERENCE";
        UserOfGenericType["CONFERENCE_USER"] = "CONFERENCE_USER";
        UserOfGenericType["PARK"] = "PARK";
        UserOfGenericType["MOBILITY"] = "MOBILITY";
        UserOfGenericType["IVR"] = "IVR";
        UserOfGenericType["IVR_NODE"] = "IVR_NODE";
        UserOfGenericType["USER"] = "USER";
        UserOfGenericType["EXTEN"] = "EXTEN";
        UserOfGenericType["FAX"] = "FAX";
        UserOfGenericType["UNKNOWN"] = "UNKNOWN";
        UserOfGenericType["UC_DIRETTORE"] = "UC_DIRETTORE";
        UserOfGenericType["UC_ASSESSORE"] = "UC_ASSESSORE";
        UserOfGenericType["UC_SEGRETARIA"] = "UC_SEGRETARIA";
        UserOfGenericType["QUALITY_INTERVIEW"] = "QUALITY_INTERVIEW";
        UserOfGenericType["INBOUND_RULE"] = "INBOUND_RULE";
        UserOfGenericType["OUTBOUND_RULE"] = "OUTBOUND_RULE";
        UserOfGenericType["EMAIL_BOX"] = "EMAIL_BOX";
        UserOfGenericType["CALLRESULT_CODE"] = "CALLRESULT_CODE";
        UserOfGenericType["SWITCH_TO_GSM_HOLD"] = "SWITCH_TO_GSM_HOLD";
        UserOfGenericType["ABILITAZIONE_CALL"] = "ABILITAZIONE_CALL";
        UserOfGenericType["EMERGENCY_NUMBERS"] = "EMERGENCY_NUMBERS";
        UserOfGenericType["SITE"] = "SITE";
        UserOfGenericType["TRUNK"] = "TRUNK";
        UserOfGenericType["GENERIC_PARAM"] = "GENERIC_PARAM";
        UserOfGenericType["PICKUP_GROUP"] = "PICKUP_GROUP";
        UserOfGenericType["SHORT_NUMBER"] = "SHORT_NUMBER";
        UserOfGenericType["SLA"] = "SLA";
        UserOfGenericType["WIDGET"] = "WIDGET";
        UserOfGenericType["POWERDIALER_CAMPAIGN"] = "POWERDIALER_CAMPAIGN";
        UserOfGenericType["EXTERNAL_ACCOUNT"] = "EXTERNAL_ACCOUNT";
        UserOfGenericType["MEETING"] = "MEETING";
        UserOfGenericType["TCONSOLE_BLFSERVER"] = "TCONSOLE_BLFSERVER";
        UserOfGenericType["SUPPORT_CUSTOM_FIELD"] = "SUPPORT_CUSTOM_FIELD";
        UserOfGenericType["BPM_PROCESS"] = "BPM_PROCESS";
    })(UserOfGenericType || (UserOfGenericType = {}));
    var UserPermission;
    (function (UserPermission) {
        UserPermission["SUPERUSER"] = "SUPERUSER";
        UserPermission["SYSTEM_ADMIN"] = "SYSTEM_ADMIN";
        UserPermission["SUPERVISOR"] = "SUPERVISOR";
        UserPermission["UC_USERS"] = "UC_USERS";
        UserPermission["UC_SERVICES"] = "UC_SERVICES";
        UserPermission["UC_GROUP"] = "UC_GROUP";
        UserPermission["CC_USERS"] = "CC_USERS";
        UserPermission["CC_SERVICES"] = "CC_SERVICES";
        UserPermission["CC_SKILLSET"] = "CC_SKILLSET";
        UserPermission["ADDRESSBOOK"] = "ADDRESSBOOK";
        UserPermission["ACTIVITY_CODES"] = "ACTIVITY_CODES";
        UserPermission["CALL_RESULTS"] = "CALL_RESULTS";
        UserPermission["SURVEY"] = "SURVEY";
        UserPermission["AUDIO"] = "AUDIO";
        UserPermission["POPUP_MANAGER"] = "POPUP_MANAGER";
        UserPermission["MAIL_CHANNEL"] = "MAIL_CHANNEL";
        UserPermission["FACEBOOK_CHANNEL"] = "FACEBOOK_CHANNEL";
        UserPermission["TWITTER_CHANNEL"] = "TWITTER_CHANNEL";
        UserPermission["TELEGRAM_CHANNEL"] = "TELEGRAM_CHANNEL";
        UserPermission["IVR"] = "IVR";
        UserPermission["DEVICES"] = "DEVICES";
        UserPermission["DIALPLAN_ROUTING"] = "DIALPLAN_ROUTING";
        UserPermission["SHORT_NUMBERS"] = "SHORT_NUMBERS";
        UserPermission["CONFERENCE"] = "CONFERENCE";
        UserPermission["PICKUP_GROUPS"] = "PICKUP_GROUPS";
        UserPermission["FAX"] = "FAX";
        UserPermission["ADVANCED_SETTINGS"] = "ADVANCED_SETTINGS";
        UserPermission["EMAIL_SETTINGS"] = "EMAIL_SETTINGS";
        UserPermission["WIDGET"] = "WIDGET";
        UserPermission["CALENDAR"] = "CALENDAR";
        UserPermission["GRTD"] = "GRTD";
        UserPermission["CALL_NAVIGATOR"] = "CALL_NAVIGATOR";
        UserPermission["DOWNLOAD_FILE_AUDIO_RECORDED"] = "DOWNLOAD_FILE_AUDIO_RECORDED";
        UserPermission["CHAT_NAVIGATOR"] = "CHAT_NAVIGATOR";
        UserPermission["TICKET_NAVIGATOR"] = "TICKET_NAVIGATOR";
        UserPermission["LIVE_HELP_NAVIGATOR"] = "LIVE_HELP_NAVIGATOR";
        UserPermission["VIDEO_NAVIGATOR"] = "VIDEO_NAVIGATOR";
        UserPermission["SEND_ADMIN_CHAT"] = "SEND_ADMIN_CHAT";
        UserPermission["RESET_PASSWORD"] = "RESET_PASSWORD";
        UserPermission["CHANSPY"] = "CHANSPY";
        UserPermission["KNOWLEDGEBASE_READ"] = "KNOWLEDGEBASE_READ";
        UserPermission["KNOWLEDGEBASE_WRITE"] = "KNOWLEDGEBASE_WRITE";
        UserPermission["SUPPORT_EMAIL_FILTER"] = "SUPPORT_EMAIL_FILTER";
        UserPermission["REPORT_EXPORT"] = "REPORT_EXPORT";
        UserPermission["CUSTOM_CHANNEL_NAVIGATOR"] = "CUSTOM_CHANNEL_NAVIGATOR";
        UserPermission["INTRANET_CONFIG"] = "INTRANET_CONFIG";
        UserPermission["REPORT_MULTICHANNEL_AGENT"] = "REPORT_MULTICHANNEL_AGENT";
        UserPermission["TVOX_UPGRADE"] = "TVOX_UPGRADE";
        UserPermission["INSIGHT"] = "INSIGHT";
        UserPermission["SYSTEM_MONITOR"] = "SYSTEM_MONITOR";
        UserPermission["BPMN"] = "BPMN";
        UserPermission["CUSTOMER_PORTAL_ADMIN"] = "CUSTOMER_PORTAL_ADMIN";
        UserPermission["CDR"] = "CDR";
    })(UserPermission || (UserPermission = {}));
    var UserStatus;
    (function (UserStatus) {
        UserStatus["BOOKED"] = "BOOKED";
        UserStatus["BUSY"] = "BUSY";
        UserStatus["NOTLOGGED"] = "NOTLOGGED";
        UserStatus["NR"] = "NR";
        UserStatus["NR_BUSY"] = "NR_BUSY";
        UserStatus["READY"] = "READY";
        UserStatus["WNR"] = "WNR";
    })(UserStatus || (UserStatus = {}));
    var WebOpenType;
    (function (WebOpenType) {
        WebOpenType["DISABLED"] = "DISABLED";
        WebOpenType["IFRAME"] = "IFRAME";
        WebOpenType["NEW_TAB"] = "NEW_TAB";
    })(WebOpenType || (WebOpenType = {}));
    var WhatToDoWithList;
    (function (WhatToDoWithList) {
        WhatToDoWithList["ADD"] = "ADD";
        WhatToDoWithList["DEL"] = "DEL";
        WhatToDoWithList["SUBSTITUTE"] = "SUBSTITUTE";
    })(WhatToDoWithList || (WhatToDoWithList = {}));
    var ZammadTriggerValue;
    (function (ZammadTriggerValue) {
        ZammadTriggerValue["create"] = "create";
        ZammadTriggerValue["update"] = "update";
    })(ZammadTriggerValue || (ZammadTriggerValue = {}));
    function isUserContact(addressBookContact) {
        return addressBookContact.type === "USER";
    }
    function isServiceContact(addressBookContact) {
        return addressBookContact.type === "SERVICE";
    }
    function isShortNumberContact(addressBookContact) {
        return addressBookContact.type === "SHORT_NUMBER";
    }
    function isExternalContact(addressBookContact) {
        return addressBookContact.type === "EXTERNAL_ITEM";
    }
    function isPersonalContact(addressBookContact) {
        return addressBookContact.type === "PERSONAL_ITEM";
    }
    function isExternalOrganizationContact(addressBookContact) {
        return addressBookContact.type === "EXTERNAL_ORGANIZATION";
    }

    var __awaiter$c = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$b = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    var ChannelType;
    (function (ChannelType) {
        ChannelType["PhoneCall"] = "PHONE_CALL";
        ChannelType["MC1"] = "CHANNEL_1";
        ChannelType["MC2"] = "CHANNEL_2";
        ChannelType["MC3"] = "CHANNEL_3";
        ChannelType["Video"] = "VIDEO";
        ChannelType["Mail"] = "MAIL";
        ChannelType["LiveHelp"] = "LIVEHELP";
        ChannelType["Chat"] = "CHAT";
        ChannelType["CallBack"] = "CALLBACK";
        ChannelType["Omnidesk"] = "OMNIDESK";
    })(ChannelType || (ChannelType = {}));
    var multiChannelMapper = new Map([
        [ChannelType.PhoneCall, "0"],
        [ChannelType.MC1, "1"],
        [ChannelType.MC2, "2"],
        [ChannelType.MC3, "3"],
        [ChannelType.CallBack, "1000"],
        [ChannelType.Video, "1001"],
        [ChannelType.Mail, "1002"],
        [ChannelType.LiveHelp, "1003"],
        [ChannelType.Chat, "1004"],
        [ChannelType.Omnidesk, "1006"],
    ]);
    var multiChannelIdMapper = (function initMultiChannelIdMapper() {
        var map = new Map();
        multiChannelMapper.forEach(function (channelId, channelType) {
            map.set(channelId, channelType);
        });
        return map;
    })();
    function channelTypeToId(channelType) {
        return channelType ? multiChannelMapper.get(channelType) : null;
    }
    function channelIdToChannelType(channelId) {
        return multiChannelIdMapper.get((channelId !== null && channelId !== void 0 ? channelId : "").trim());
    }
    function buildCallMedia(mediaParam) {
        var media = new Set();
        if (mediaParam) {
            if (mediaParam.audio)
                media.add(CallMedia.audio);
            if (mediaParam.video)
                media.add(CallMedia.video);
            if (mediaParam.desktop)
                media.add(CallMedia.desktop);
            if (mediaParam.data)
                media.add(CallMedia.data);
        }
        return media;
    }
    var asyncTimeout = function (timeout) { return __awaiter$c(void 0, void 0, void 0, function () { return __generator$b(this, function (_a) {
        return [2 , new Promise(function (resolve) { return setTimeout(resolve, timeout); })];
    }); }); };
    function arrayConcat() {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        var result = [];
        if (args && args.length) {
            args.forEach(function (arr) {
                if (Array.isArray(arr) && !isEmpty(arr)) {
                    result.push.apply(result, arr);
                }
            });
        }
        return result;
    }
    function isEmpty(value) {
        return value === null || value === "" || value === undefined || (Array.isArray(value) && value.length === 0) || (typeof value === "number" && isNaN(value));
    }
    var functionCheck = function (value) {
        return typeof value == "function" ? value : undefined;
    };
    var objectCheck = function (value) {
        return typeof value == "object" ? value : undefined;
    };
    var stringCheck = function (value) {
        return typeof value == "string" ? value : undefined;
    };
    var numberCheck = function (value) {
        return typeof value == "number" ? value : undefined;
    };
    var booleanCheck = function (value) {
        return typeof value == "boolean" ? value : undefined;
    };
    function loadConfig(prefix, checks, destination, source) {
        if (prefix === void 0) { prefix = []; }
        if (source == null || typeof source !== "object") {
            throw new Error("Configuration is not valid object");
        }
        prefix = arrayConcat(prefix);
        for (var parameter in checks.mandatory) {
            if (!source.hasOwnProperty(parameter)) {
                throw ConfigurationError.newInstance(arrayConcat(prefix, [parameter]).join("."));
            }
            else {
                var value = source[parameter];
                try {
                    var checked_value = checks.mandatory[parameter](value, destination[parameter], prefix);
                    if (checked_value === undefined) {
                        throw ConfigurationError.newInstance(arrayConcat(prefix, [parameter]).join("."), value);
                    }
                    else {
                        destination[parameter] = checked_value;
                    }
                }
                catch (e) {
                    if (e.parameter) {
                        throw e;
                    }
                    else {
                        throw ConfigurationError.newInstance(arrayConcat(prefix, [parameter]).join("."), value, e);
                    }
                }
            }
        }
        for (var parameter in checks.optional) {
            if (source.hasOwnProperty(parameter)) {
                var value = source[parameter];
                if (isEmpty(value)) {
                    continue;
                }
                try {
                    var checked_value = checks.optional[parameter](value, destination[parameter], prefix);
                    if (checked_value === undefined) {
                        throw ConfigurationError.newInstance(arrayConcat(prefix, [parameter]).join("."), value);
                    }
                    else {
                        destination[parameter] = checked_value;
                    }
                }
                catch (e) {
                    if (e.parameter) {
                        throw e;
                    }
                    else {
                        throw ConfigurationError.newInstance(arrayConcat(prefix, [parameter]).join("."), value, e);
                    }
                }
            }
        }
        return destination;
    }
    function MapOrSet_toJSON(key, value) {
        if (value && typeof value === "object") {
            if (value instanceof Set) {
                var result_1 = [];
                value.forEach(function (m) { return result_1.push(m); });
                return result_1;
            }
            else if (value instanceof Map) {
                var result_2 = {};
                value.forEach(function (value, key) {
                    result_2[key] = value;
                });
                return result_2;
            }
        }
        return value;
    }

    var ConnectionKey;
    (function (ConnectionKey) {
        ConnectionKey["pingToMaster"] = "pingToMaster";
        ConnectionKey["pingToSlave"] = "pingToSlave";
        ConnectionKey["pongToSlave"] = "pongToSlave";
        ConnectionKey["pongToMaster"] = "pongToMaster";
        ConnectionKey["hierarchy"] = "hierarchy";
        ConnectionKey["toWsRequest"] = "toWsRequest";
        ConnectionKey["toWsRequestComplete"] = "toWsRequestComplete";
        ConnectionKey["fromWsRequestId"] = "fromWsRequestId";
        ConnectionKey["fromWsRequestIdUpdate"] = "fromWsRequestIdUpdate";
        ConnectionKey["fromWsResponse"] = "fromWsResponse";
        ConnectionKey["videoChannelConfig"] = "videochannelConfig";
        ConnectionKey["chatChannelConfig"] = "chatChannelConfig";
        ConnectionKey["commonMethodsMessage"] = "commonMethodsMessage";
        ConnectionKey["closeChatSession"] = "closeChatSession";
        ConnectionKey["closeVideoSession"] = "closeVideoSession";
        ConnectionKey["closeCallSession"] = "closeCallSession";
        ConnectionKey["chatChannelSession"] = "chatChannelSession";
        ConnectionKey["jsessionId"] = "jsessionId";
        ConnectionKey["deviceId"] = "deviceId";
    })(ConnectionKey || (ConnectionKey = {}));
    var Storagelevel;
    (function (Storagelevel) {
        Storagelevel[Storagelevel["master"] = 0] = "master";
        Storagelevel[Storagelevel["slave"] = 1] = "slave";
        Storagelevel[Storagelevel["futureMaster"] = 2] = "futureMaster";
    })(Storagelevel || (Storagelevel = {}));
    var HierarchyMessage =  (function () {
        function HierarchyMessage(master, slave) {
            this.connectionMaster = master;
            this.connectionSlave = slave;
        }
        return HierarchyMessage;
    }());
    var RegisterRequestObj =  (function () {
        function RegisterRequestObj(idSlaves, request, requestIdentifierNotification) {
            this.id_slaves = idSlaves;
            this.request = request;
            this.requestIdentifierNotification = requestIdentifierNotification;
            this.lastResponse = new Array();
        }
        return RegisterRequestObj;
    }());
    var ToWsMessage =  (function () {
        function ToWsMessage(from_id, data) {
            this.from_id = from_id;
            this.data = data;
        }
        ToWsMessage.fromStringMessage = function (data) {
            var msg = JSON.parse(data);
            return new ToWsMessage(msg.from_id, new StorageMessage(msg.data.connection_id, msg.data.message));
        };
        return ToWsMessage;
    }());
    var FromWsMessage =  (function () {
        function FromWsMessage(to_id, data) {
            this.to_ids = to_id;
            this.data = data;
        }
        FromWsMessage.fromStringMessage = function (data) {
            var msg = JSON.parse(data);
            return new FromWsMessage(msg.to_ids, new StorageMessage(msg.data.connection_id, msg.data.message));
        };
        return FromWsMessage;
    }());
    var StorageMessage =  (function () {
        function StorageMessage(connection_id, message) {
            this.connection_id = connection_id;
            this.message = message;
        }
        StorageMessage.fromStringMessage = function (data) {
            var msg = JSON.parse(data);
            return new StorageMessage(msg.connection_id, msg.message);
        };
        return StorageMessage;
    }());

    function isFunction$1(x) {
        return typeof x === 'function';
    }

    var _enable_super_gross_mode_that_will_cause_bad_things = false;
    var config = {
        Promise: undefined,
        set useDeprecatedSynchronousErrorHandling(value) {
            if (value) {
                var error =  new Error();
                 console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
            }
            else if (_enable_super_gross_mode_that_will_cause_bad_things) {
                 console.log('RxJS: Back to a better error behavior. Thank you. <3');
            }
            _enable_super_gross_mode_that_will_cause_bad_things = value;
        },
        get useDeprecatedSynchronousErrorHandling() {
            return _enable_super_gross_mode_that_will_cause_bad_things;
        },
    };

    function hostReportError(err) {
        setTimeout(function () { throw err; }, 0);
    }

    var empty$1 = {
        closed: true,
        next: function (value) { },
        error: function (err) {
            if (config.useDeprecatedSynchronousErrorHandling) {
                throw err;
            }
            else {
                hostReportError(err);
            }
        },
        complete: function () { }
    };

    var isArray$2 =  (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();

    function isObject$1(x) {
        return x !== null && typeof x === 'object';
    }

    var UnsubscriptionErrorImpl =  (function () {
        function UnsubscriptionErrorImpl(errors) {
            Error.call(this);
            this.message = errors ?
                errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n  ') : '';
            this.name = 'UnsubscriptionError';
            this.errors = errors;
            return this;
        }
        UnsubscriptionErrorImpl.prototype =  Object.create(Error.prototype);
        return UnsubscriptionErrorImpl;
    })();
    var UnsubscriptionError = UnsubscriptionErrorImpl;

    var Subscription =  (function () {
        function Subscription(unsubscribe) {
            this.closed = false;
            this._parentOrParents = null;
            this._subscriptions = null;
            if (unsubscribe) {
                this._ctorUnsubscribe = true;
                this._unsubscribe = unsubscribe;
            }
        }
        Subscription.prototype.unsubscribe = function () {
            var errors;
            if (this.closed) {
                return;
            }
            var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
            this.closed = true;
            this._parentOrParents = null;
            this._subscriptions = null;
            if (_parentOrParents instanceof Subscription) {
                _parentOrParents.remove(this);
            }
            else if (_parentOrParents !== null) {
                for (var index = 0; index < _parentOrParents.length; ++index) {
                    var parent_1 = _parentOrParents[index];
                    parent_1.remove(this);
                }
            }
            if (isFunction$1(_unsubscribe)) {
                if (_ctorUnsubscribe) {
                    this._unsubscribe = undefined;
                }
                try {
                    _unsubscribe.call(this);
                }
                catch (e) {
                    errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
                }
            }
            if (isArray$2(_subscriptions)) {
                var index = -1;
                var len = _subscriptions.length;
                while (++index < len) {
                    var sub = _subscriptions[index];
                    if (isObject$1(sub)) {
                        try {
                            sub.unsubscribe();
                        }
                        catch (e) {
                            errors = errors || [];
                            if (e instanceof UnsubscriptionError) {
                                errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
                            }
                            else {
                                errors.push(e);
                            }
                        }
                    }
                }
            }
            if (errors) {
                throw new UnsubscriptionError(errors);
            }
        };
        Subscription.prototype.add = function (teardown) {
            var subscription = teardown;
            if (!teardown) {
                return Subscription.EMPTY;
            }
            switch (typeof teardown) {
                case 'function':
                    subscription = new Subscription(teardown);
                case 'object':
                    if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
                        return subscription;
                    }
                    else if (this.closed) {
                        subscription.unsubscribe();
                        return subscription;
                    }
                    else if (!(subscription instanceof Subscription)) {
                        var tmp = subscription;
                        subscription = new Subscription();
                        subscription._subscriptions = [tmp];
                    }
                    break;
                default: {
                    throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
                }
            }
            var _parentOrParents = subscription._parentOrParents;
            if (_parentOrParents === null) {
                subscription._parentOrParents = this;
            }
            else if (_parentOrParents instanceof Subscription) {
                if (_parentOrParents === this) {
                    return subscription;
                }
                subscription._parentOrParents = [_parentOrParents, this];
            }
            else if (_parentOrParents.indexOf(this) === -1) {
                _parentOrParents.push(this);
            }
            else {
                return subscription;
            }
            var subscriptions = this._subscriptions;
            if (subscriptions === null) {
                this._subscriptions = [subscription];
            }
            else {
                subscriptions.push(subscription);
            }
            return subscription;
        };
        Subscription.prototype.remove = function (subscription) {
            var subscriptions = this._subscriptions;
            if (subscriptions) {
                var subscriptionIndex = subscriptions.indexOf(subscription);
                if (subscriptionIndex !== -1) {
                    subscriptions.splice(subscriptionIndex, 1);
                }
            }
        };
        Subscription.EMPTY = (function (empty) {
            empty.closed = true;
            return empty;
        }(new Subscription()));
        return Subscription;
    }());
    function flattenUnsubscriptionErrors(errors) {
        return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
    }

    var rxSubscriber =  (function () {
        return typeof Symbol === 'function'
            ?  Symbol('rxSubscriber')
            : '@@rxSubscriber_' +  Math.random();
    })();

    var Subscriber =  (function (_super) {
        __extends$d(Subscriber, _super);
        function Subscriber(destinationOrNext, error, complete) {
            var _this = _super.call(this) || this;
            _this.syncErrorValue = null;
            _this.syncErrorThrown = false;
            _this.syncErrorThrowable = false;
            _this.isStopped = false;
            switch (arguments.length) {
                case 0:
                    _this.destination = empty$1;
                    break;
                case 1:
                    if (!destinationOrNext) {
                        _this.destination = empty$1;
                        break;
                    }
                    if (typeof destinationOrNext === 'object') {
                        if (destinationOrNext instanceof Subscriber) {
                            _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
                            _this.destination = destinationOrNext;
                            destinationOrNext.add(_this);
                        }
                        else {
                            _this.syncErrorThrowable = true;
                            _this.destination = new SafeSubscriber(_this, destinationOrNext);
                        }
                        break;
                    }
                default:
                    _this.syncErrorThrowable = true;
                    _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
                    break;
            }
            return _this;
        }
        Subscriber.prototype[rxSubscriber] = function () { return this; };
        Subscriber.create = function (next, error, complete) {
            var subscriber = new Subscriber(next, error, complete);
            subscriber.syncErrorThrowable = false;
            return subscriber;
        };
        Subscriber.prototype.next = function (value) {
            if (!this.isStopped) {
                this._next(value);
            }
        };
        Subscriber.prototype.error = function (err) {
            if (!this.isStopped) {
                this.isStopped = true;
                this._error(err);
            }
        };
        Subscriber.prototype.complete = function () {
            if (!this.isStopped) {
                this.isStopped = true;
                this._complete();
            }
        };
        Subscriber.prototype.unsubscribe = function () {
            if (this.closed) {
                return;
            }
            this.isStopped = true;
            _super.prototype.unsubscribe.call(this);
        };
        Subscriber.prototype._next = function (value) {
            this.destination.next(value);
        };
        Subscriber.prototype._error = function (err) {
            this.destination.error(err);
            this.unsubscribe();
        };
        Subscriber.prototype._complete = function () {
            this.destination.complete();
            this.unsubscribe();
        };
        Subscriber.prototype._unsubscribeAndRecycle = function () {
            var _parentOrParents = this._parentOrParents;
            this._parentOrParents = null;
            this.unsubscribe();
            this.closed = false;
            this.isStopped = false;
            this._parentOrParents = _parentOrParents;
            return this;
        };
        return Subscriber;
    }(Subscription));
    var SafeSubscriber =  (function (_super) {
        __extends$d(SafeSubscriber, _super);
        function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
            var _this = _super.call(this) || this;
            _this._parentSubscriber = _parentSubscriber;
            var next;
            var context = _this;
            if (isFunction$1(observerOrNext)) {
                next = observerOrNext;
            }
            else if (observerOrNext) {
                next = observerOrNext.next;
                error = observerOrNext.error;
                complete = observerOrNext.complete;
                if (observerOrNext !== empty$1) {
                    context = Object.create(observerOrNext);
                    if (isFunction$1(context.unsubscribe)) {
                        _this.add(context.unsubscribe.bind(context));
                    }
                    context.unsubscribe = _this.unsubscribe.bind(_this);
                }
            }
            _this._context = context;
            _this._next = next;
            _this._error = error;
            _this._complete = complete;
            return _this;
        }
        SafeSubscriber.prototype.next = function (value) {
            if (!this.isStopped && this._next) {
                var _parentSubscriber = this._parentSubscriber;
                if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                    this.__tryOrUnsub(this._next, value);
                }
                else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
                    this.unsubscribe();
                }
            }
        };
        SafeSubscriber.prototype.error = function (err) {
            if (!this.isStopped) {
                var _parentSubscriber = this._parentSubscriber;
                var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
                if (this._error) {
                    if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                        this.__tryOrUnsub(this._error, err);
                        this.unsubscribe();
                    }
                    else {
                        this.__tryOrSetError(_parentSubscriber, this._error, err);
                        this.unsubscribe();
                    }
                }
                else if (!_parentSubscriber.syncErrorThrowable) {
                    this.unsubscribe();
                    if (useDeprecatedSynchronousErrorHandling) {
                        throw err;
                    }
                    hostReportError(err);
                }
                else {
                    if (useDeprecatedSynchronousErrorHandling) {
                        _parentSubscriber.syncErrorValue = err;
                        _parentSubscriber.syncErrorThrown = true;
                    }
                    else {
                        hostReportError(err);
                    }
                    this.unsubscribe();
                }
            }
        };
        SafeSubscriber.prototype.complete = function () {
            var _this = this;
            if (!this.isStopped) {
                var _parentSubscriber = this._parentSubscriber;
                if (this._complete) {
                    var wrappedComplete = function () { return _this._complete.call(_this._context); };
                    if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                        this.__tryOrUnsub(wrappedComplete);
                        this.unsubscribe();
                    }
                    else {
                        this.__tryOrSetError(_parentSubscriber, wrappedComplete);
                        this.unsubscribe();
                    }
                }
                else {
                    this.unsubscribe();
                }
            }
        };
        SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
            try {
                fn.call(this._context, value);
            }
            catch (err) {
                this.unsubscribe();
                if (config.useDeprecatedSynchronousErrorHandling) {
                    throw err;
                }
                else {
                    hostReportError(err);
                }
            }
        };
        SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
            if (!config.useDeprecatedSynchronousErrorHandling) {
                throw new Error('bad call');
            }
            try {
                fn.call(this._context, value);
            }
            catch (err) {
                if (config.useDeprecatedSynchronousErrorHandling) {
                    parent.syncErrorValue = err;
                    parent.syncErrorThrown = true;
                    return true;
                }
                else {
                    hostReportError(err);
                    return true;
                }
            }
            return false;
        };
        SafeSubscriber.prototype._unsubscribe = function () {
            var _parentSubscriber = this._parentSubscriber;
            this._context = null;
            this._parentSubscriber = null;
            _parentSubscriber.unsubscribe();
        };
        return SafeSubscriber;
    }(Subscriber));

    function canReportError(observer) {
        while (observer) {
            var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
            if (closed_1 || isStopped) {
                return false;
            }
            else if (destination && destination instanceof Subscriber) {
                observer = destination;
            }
            else {
                observer = null;
            }
        }
        return true;
    }

    function toSubscriber(nextOrObserver, error, complete) {
        if (nextOrObserver) {
            if (nextOrObserver instanceof Subscriber) {
                return nextOrObserver;
            }
            if (nextOrObserver[rxSubscriber]) {
                return nextOrObserver[rxSubscriber]();
            }
        }
        if (!nextOrObserver && !error && !complete) {
            return new Subscriber(empty$1);
        }
        return new Subscriber(nextOrObserver, error, complete);
    }

    var observable =  (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();

    function identity$1(x) {
        return x;
    }

    function pipeFromArray(fns) {
        if (fns.length === 0) {
            return identity$1;
        }
        if (fns.length === 1) {
            return fns[0];
        }
        return function piped(input) {
            return fns.reduce(function (prev, fn) { return fn(prev); }, input);
        };
    }

    var Observable =  (function () {
        function Observable(subscribe) {
            this._isScalar = false;
            if (subscribe) {
                this._subscribe = subscribe;
            }
        }
        Observable.prototype.lift = function (operator) {
            var observable = new Observable();
            observable.source = this;
            observable.operator = operator;
            return observable;
        };
        Observable.prototype.subscribe = function (observerOrNext, error, complete) {
            var operator = this.operator;
            var sink = toSubscriber(observerOrNext, error, complete);
            if (operator) {
                sink.add(operator.call(sink, this.source));
            }
            else {
                sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
                    this._subscribe(sink) :
                    this._trySubscribe(sink));
            }
            if (config.useDeprecatedSynchronousErrorHandling) {
                if (sink.syncErrorThrowable) {
                    sink.syncErrorThrowable = false;
                    if (sink.syncErrorThrown) {
                        throw sink.syncErrorValue;
                    }
                }
            }
            return sink;
        };
        Observable.prototype._trySubscribe = function (sink) {
            try {
                return this._subscribe(sink);
            }
            catch (err) {
                if (config.useDeprecatedSynchronousErrorHandling) {
                    sink.syncErrorThrown = true;
                    sink.syncErrorValue = err;
                }
                if (canReportError(sink)) {
                    sink.error(err);
                }
                else {
                    console.warn(err);
                }
            }
        };
        Observable.prototype.forEach = function (next, promiseCtor) {
            var _this = this;
            promiseCtor = getPromiseCtor(promiseCtor);
            return new promiseCtor(function (resolve, reject) {
                var subscription;
                subscription = _this.subscribe(function (value) {
                    try {
                        next(value);
                    }
                    catch (err) {
                        reject(err);
                        if (subscription) {
                            subscription.unsubscribe();
                        }
                    }
                }, reject, resolve);
            });
        };
        Observable.prototype._subscribe = function (subscriber) {
            var source = this.source;
            return source && source.subscribe(subscriber);
        };
        Observable.prototype[observable] = function () {
            return this;
        };
        Observable.prototype.pipe = function () {
            var operations = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                operations[_i] = arguments[_i];
            }
            if (operations.length === 0) {
                return this;
            }
            return pipeFromArray(operations)(this);
        };
        Observable.prototype.toPromise = function (promiseCtor) {
            var _this = this;
            promiseCtor = getPromiseCtor(promiseCtor);
            return new promiseCtor(function (resolve, reject) {
                var value;
                _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
            });
        };
        Observable.create = function (subscribe) {
            return new Observable(subscribe);
        };
        return Observable;
    }());
    function getPromiseCtor(promiseCtor) {
        if (!promiseCtor) {
            promiseCtor = config.Promise || Promise;
        }
        if (!promiseCtor) {
            throw new Error('no Promise impl found');
        }
        return promiseCtor;
    }

    var ObjectUnsubscribedErrorImpl =  (function () {
        function ObjectUnsubscribedErrorImpl() {
            Error.call(this);
            this.message = 'object unsubscribed';
            this.name = 'ObjectUnsubscribedError';
            return this;
        }
        ObjectUnsubscribedErrorImpl.prototype =  Object.create(Error.prototype);
        return ObjectUnsubscribedErrorImpl;
    })();
    var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;

    var SubjectSubscription =  (function (_super) {
        __extends$d(SubjectSubscription, _super);
        function SubjectSubscription(subject, subscriber) {
            var _this = _super.call(this) || this;
            _this.subject = subject;
            _this.subscriber = subscriber;
            _this.closed = false;
            return _this;
        }
        SubjectSubscription.prototype.unsubscribe = function () {
            if (this.closed) {
                return;
            }
            this.closed = true;
            var subject = this.subject;
            var observers = subject.observers;
            this.subject = null;
            if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
                return;
            }
            var subscriberIndex = observers.indexOf(this.subscriber);
            if (subscriberIndex !== -1) {
                observers.splice(subscriberIndex, 1);
            }
        };
        return SubjectSubscription;
    }(Subscription));

    var SubjectSubscriber =  (function (_super) {
        __extends$d(SubjectSubscriber, _super);
        function SubjectSubscriber(destination) {
            var _this = _super.call(this, destination) || this;
            _this.destination = destination;
            return _this;
        }
        return SubjectSubscriber;
    }(Subscriber));
    var Subject =  (function (_super) {
        __extends$d(Subject, _super);
        function Subject() {
            var _this = _super.call(this) || this;
            _this.observers = [];
            _this.closed = false;
            _this.isStopped = false;
            _this.hasError = false;
            _this.thrownError = null;
            return _this;
        }
        Subject.prototype[rxSubscriber] = function () {
            return new SubjectSubscriber(this);
        };
        Subject.prototype.lift = function (operator) {
            var subject = new AnonymousSubject(this, this);
            subject.operator = operator;
            return subject;
        };
        Subject.prototype.next = function (value) {
            if (this.closed) {
                throw new ObjectUnsubscribedError();
            }
            if (!this.isStopped) {
                var observers = this.observers;
                var len = observers.length;
                var copy = observers.slice();
                for (var i = 0; i < len; i++) {
                    copy[i].next(value);
                }
            }
        };
        Subject.prototype.error = function (err) {
            if (this.closed) {
                throw new ObjectUnsubscribedError();
            }
            this.hasError = true;
            this.thrownError = err;
            this.isStopped = true;
            var observers = this.observers;
            var len = observers.length;
            var copy = observers.slice();
            for (var i = 0; i < len; i++) {
                copy[i].error(err);
            }
            this.observers.length = 0;
        };
        Subject.prototype.complete = function () {
            if (this.closed) {
                throw new ObjectUnsubscribedError();
            }
            this.isStopped = true;
            var observers = this.observers;
            var len = observers.length;
            var copy = observers.slice();
            for (var i = 0; i < len; i++) {
                copy[i].complete();
            }
            this.observers.length = 0;
        };
        Subject.prototype.unsubscribe = function () {
            this.isStopped = true;
            this.closed = true;
            this.observers = null;
        };
        Subject.prototype._trySubscribe = function (subscriber) {
            if (this.closed) {
                throw new ObjectUnsubscribedError();
            }
            else {
                return _super.prototype._trySubscribe.call(this, subscriber);
            }
        };
        Subject.prototype._subscribe = function (subscriber) {
            if (this.closed) {
                throw new ObjectUnsubscribedError();
            }
            else if (this.hasError) {
                subscriber.error(this.thrownError);
                return Subscription.EMPTY;
            }
            else if (this.isStopped) {
                subscriber.complete();
                return Subscription.EMPTY;
            }
            else {
                this.observers.push(subscriber);
                return new SubjectSubscription(this, subscriber);
            }
        };
        Subject.prototype.asObservable = function () {
            var observable = new Observable();
            observable.source = this;
            return observable;
        };
        Subject.create = function (destination, source) {
            return new AnonymousSubject(destination, source);
        };
        return Subject;
    }(Observable));
    var AnonymousSubject =  (function (_super) {
        __extends$d(AnonymousSubject, _super);
        function AnonymousSubject(destination, source) {
            var _this = _super.call(this) || this;
            _this.destination = destination;
            _this.source = source;
            return _this;
        }
        AnonymousSubject.prototype.next = function (value) {
            var destination = this.destination;
            if (destination && destination.next) {
                destination.next(value);
            }
        };
        AnonymousSubject.prototype.error = function (err) {
            var destination = this.destination;
            if (destination && destination.error) {
                this.destination.error(err);
            }
        };
        AnonymousSubject.prototype.complete = function () {
            var destination = this.destination;
            if (destination && destination.complete) {
                this.destination.complete();
            }
        };
        AnonymousSubject.prototype._subscribe = function (subscriber) {
            var source = this.source;
            if (source) {
                return this.source.subscribe(subscriber);
            }
            else {
                return Subscription.EMPTY;
            }
        };
        return AnonymousSubject;
    }(Subject));

    function refCount() {
        return function refCountOperatorFunction(source) {
            return source.lift(new RefCountOperator(source));
        };
    }
    var RefCountOperator =  (function () {
        function RefCountOperator(connectable) {
            this.connectable = connectable;
        }
        RefCountOperator.prototype.call = function (subscriber, source) {
            var connectable = this.connectable;
            connectable._refCount++;
            var refCounter = new RefCountSubscriber(subscriber, connectable);
            var subscription = source.subscribe(refCounter);
            if (!refCounter.closed) {
                refCounter.connection = connectable.connect();
            }
            return subscription;
        };
        return RefCountOperator;
    }());
    var RefCountSubscriber =  (function (_super) {
        __extends$d(RefCountSubscriber, _super);
        function RefCountSubscriber(destination, connectable) {
            var _this = _super.call(this, destination) || this;
            _this.connectable = connectable;
            return _this;
        }
        RefCountSubscriber.prototype._unsubscribe = function () {
            var connectable = this.connectable;
            if (!connectable) {
                this.connection = null;
                return;
            }
            this.connectable = null;
            var refCount = connectable._refCount;
            if (refCount <= 0) {
                this.connection = null;
                return;
            }
            connectable._refCount = refCount - 1;
            if (refCount > 1) {
                this.connection = null;
                return;
            }
            var connection = this.connection;
            var sharedConnection = connectable._connection;
            this.connection = null;
            if (sharedConnection && (!connection || sharedConnection === connection)) {
                sharedConnection.unsubscribe();
            }
        };
        return RefCountSubscriber;
    }(Subscriber));

    var ConnectableObservable =  (function (_super) {
        __extends$d(ConnectableObservable, _super);
        function ConnectableObservable(source, subjectFactory) {
            var _this = _super.call(this) || this;
            _this.source = source;
            _this.subjectFactory = subjectFactory;
            _this._refCount = 0;
            _this._isComplete = false;
            return _this;
        }
        ConnectableObservable.prototype._subscribe = function (subscriber) {
            return this.getSubject().subscribe(subscriber);
        };
        ConnectableObservable.prototype.getSubject = function () {
            var subject = this._subject;
            if (!subject || subject.isStopped) {
                this._subject = this.subjectFactory();
            }
            return this._subject;
        };
        ConnectableObservable.prototype.connect = function () {
            var connection = this._connection;
            if (!connection) {
                this._isComplete = false;
                connection = this._connection = new Subscription();
                connection.add(this.source
                    .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
                if (connection.closed) {
                    this._connection = null;
                    connection = Subscription.EMPTY;
                }
            }
            return connection;
        };
        ConnectableObservable.prototype.refCount = function () {
            return refCount()(this);
        };
        return ConnectableObservable;
    }(Observable));
    var connectableObservableDescriptor =  (function () {
        var connectableProto = ConnectableObservable.prototype;
        return {
            operator: { value: null },
            _refCount: { value: 0, writable: true },
            _subject: { value: null, writable: true },
            _connection: { value: null, writable: true },
            _subscribe: { value: connectableProto._subscribe },
            _isComplete: { value: connectableProto._isComplete, writable: true },
            getSubject: { value: connectableProto.getSubject },
            connect: { value: connectableProto.connect },
            refCount: { value: connectableProto.refCount }
        };
    })();
    var ConnectableSubscriber =  (function (_super) {
        __extends$d(ConnectableSubscriber, _super);
        function ConnectableSubscriber(destination, connectable) {
            var _this = _super.call(this, destination) || this;
            _this.connectable = connectable;
            return _this;
        }
        ConnectableSubscriber.prototype._error = function (err) {
            this._unsubscribe();
            _super.prototype._error.call(this, err);
        };
        ConnectableSubscriber.prototype._complete = function () {
            this.connectable._isComplete = true;
            this._unsubscribe();
            _super.prototype._complete.call(this);
        };
        ConnectableSubscriber.prototype._unsubscribe = function () {
            var connectable = this.connectable;
            if (connectable) {
                this.connectable = null;
                var connection = connectable._connection;
                connectable._refCount = 0;
                connectable._subject = null;
                connectable._connection = null;
                if (connection) {
                    connection.unsubscribe();
                }
            }
        };
        return ConnectableSubscriber;
    }(SubjectSubscriber));
    ((function (_super) {
        __extends$d(RefCountSubscriber, _super);
        function RefCountSubscriber(destination, connectable) {
            var _this = _super.call(this, destination) || this;
            _this.connectable = connectable;
            return _this;
        }
        RefCountSubscriber.prototype._unsubscribe = function () {
            var connectable = this.connectable;
            if (!connectable) {
                this.connection = null;
                return;
            }
            this.connectable = null;
            var refCount = connectable._refCount;
            if (refCount <= 0) {
                this.connection = null;
                return;
            }
            connectable._refCount = refCount - 1;
            if (refCount > 1) {
                this.connection = null;
                return;
            }
            var connection = this.connection;
            var sharedConnection = connectable._connection;
            this.connection = null;
            if (sharedConnection && (!connection || sharedConnection === connection)) {
                sharedConnection.unsubscribe();
            }
        };
        return RefCountSubscriber;
    })(Subscriber));

    var BehaviorSubject =  (function (_super) {
        __extends$d(BehaviorSubject, _super);
        function BehaviorSubject(_value) {
            var _this = _super.call(this) || this;
            _this._value = _value;
            return _this;
        }
        Object.defineProperty(BehaviorSubject.prototype, "value", {
            get: function () {
                return this.getValue();
            },
            enumerable: true,
            configurable: true
        });
        BehaviorSubject.prototype._subscribe = function (subscriber) {
            var subscription = _super.prototype._subscribe.call(this, subscriber);
            if (subscription && !subscription.closed) {
                subscriber.next(this._value);
            }
            return subscription;
        };
        BehaviorSubject.prototype.getValue = function () {
            if (this.hasError) {
                throw this.thrownError;
            }
            else if (this.closed) {
                throw new ObjectUnsubscribedError();
            }
            else {
                return this._value;
            }
        };
        BehaviorSubject.prototype.next = function (value) {
            _super.prototype.next.call(this, this._value = value);
        };
        return BehaviorSubject;
    }(Subject));

    var Action =  (function (_super) {
        __extends$d(Action, _super);
        function Action(scheduler, work) {
            return _super.call(this) || this;
        }
        Action.prototype.schedule = function (state, delay) {
            return this;
        };
        return Action;
    }(Subscription));

    var AsyncAction =  (function (_super) {
        __extends$d(AsyncAction, _super);
        function AsyncAction(scheduler, work) {
            var _this = _super.call(this, scheduler, work) || this;
            _this.scheduler = scheduler;
            _this.work = work;
            _this.pending = false;
            return _this;
        }
        AsyncAction.prototype.schedule = function (state, delay) {
            if (delay === void 0) {
                delay = 0;
            }
            if (this.closed) {
                return this;
            }
            this.state = state;
            var id = this.id;
            var scheduler = this.scheduler;
            if (id != null) {
                this.id = this.recycleAsyncId(scheduler, id, delay);
            }
            this.pending = true;
            this.delay = delay;
            this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
            return this;
        };
        AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
            if (delay === void 0) {
                delay = 0;
            }
            return setInterval(scheduler.flush.bind(scheduler, this), delay);
        };
        AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
            if (delay === void 0) {
                delay = 0;
            }
            if (delay !== null && this.delay === delay && this.pending === false) {
                return id;
            }
            clearInterval(id);
            return undefined;
        };
        AsyncAction.prototype.execute = function (state, delay) {
            if (this.closed) {
                return new Error('executing a cancelled action');
            }
            this.pending = false;
            var error = this._execute(state, delay);
            if (error) {
                return error;
            }
            else if (this.pending === false && this.id != null) {
                this.id = this.recycleAsyncId(this.scheduler, this.id, null);
            }
        };
        AsyncAction.prototype._execute = function (state, delay) {
            var errored = false;
            var errorValue = undefined;
            try {
                this.work(state);
            }
            catch (e) {
                errored = true;
                errorValue = !!e && e || new Error(e);
            }
            if (errored) {
                this.unsubscribe();
                return errorValue;
            }
        };
        AsyncAction.prototype._unsubscribe = function () {
            var id = this.id;
            var scheduler = this.scheduler;
            var actions = scheduler.actions;
            var index = actions.indexOf(this);
            this.work = null;
            this.state = null;
            this.pending = false;
            this.scheduler = null;
            if (index !== -1) {
                actions.splice(index, 1);
            }
            if (id != null) {
                this.id = this.recycleAsyncId(scheduler, id, null);
            }
            this.delay = null;
        };
        return AsyncAction;
    }(Action));

    var QueueAction =  (function (_super) {
        __extends$d(QueueAction, _super);
        function QueueAction(scheduler, work) {
            var _this = _super.call(this, scheduler, work) || this;
            _this.scheduler = scheduler;
            _this.work = work;
            return _this;
        }
        QueueAction.prototype.schedule = function (state, delay) {
            if (delay === void 0) {
                delay = 0;
            }
            if (delay > 0) {
                return _super.prototype.schedule.call(this, state, delay);
            }
            this.delay = delay;
            this.state = state;
            this.scheduler.flush(this);
            return this;
        };
        QueueAction.prototype.execute = function (state, delay) {
            return (delay > 0 || this.closed) ?
                _super.prototype.execute.call(this, state, delay) :
                this._execute(state, delay);
        };
        QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
            if (delay === void 0) {
                delay = 0;
            }
            if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
                return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
            }
            return scheduler.flush(this);
        };
        return QueueAction;
    }(AsyncAction));

    var Scheduler =  (function () {
        function Scheduler(SchedulerAction, now) {
            if (now === void 0) {
                now = Scheduler.now;
            }
            this.SchedulerAction = SchedulerAction;
            this.now = now;
        }
        Scheduler.prototype.schedule = function (work, delay, state) {
            if (delay === void 0) {
                delay = 0;
            }
            return new this.SchedulerAction(this, work).schedule(state, delay);
        };
        Scheduler.now = function () { return Date.now(); };
        return Scheduler;
    }());

    var AsyncScheduler =  (function (_super) {
        __extends$d(AsyncScheduler, _super);
        function AsyncScheduler(SchedulerAction, now) {
            if (now === void 0) {
                now = Scheduler.now;
            }
            var _this = _super.call(this, SchedulerAction, function () {
                if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
                    return AsyncScheduler.delegate.now();
                }
                else {
                    return now();
                }
            }) || this;
            _this.actions = [];
            _this.active = false;
            _this.scheduled = undefined;
            return _this;
        }
        AsyncScheduler.prototype.schedule = function (work, delay, state) {
            if (delay === void 0) {
                delay = 0;
            }
            if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
                return AsyncScheduler.delegate.schedule(work, delay, state);
            }
            else {
                return _super.prototype.schedule.call(this, work, delay, state);
            }
        };
        AsyncScheduler.prototype.flush = function (action) {
            var actions = this.actions;
            if (this.active) {
                actions.push(action);
                return;
            }
            var error;
            this.active = true;
            do {
                if (error = action.execute(action.state, action.delay)) {
                    break;
                }
            } while (action = actions.shift());
            this.active = false;
            if (error) {
                while (action = actions.shift()) {
                    action.unsubscribe();
                }
                throw error;
            }
        };
        return AsyncScheduler;
    }(Scheduler));

    var QueueScheduler =  (function (_super) {
        __extends$d(QueueScheduler, _super);
        function QueueScheduler() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        return QueueScheduler;
    }(AsyncScheduler));

    var queueScheduler =  new QueueScheduler(QueueAction);
    var queue = queueScheduler;

    var EMPTY =  new Observable(function (subscriber) { return subscriber.complete(); });
    function empty(scheduler) {
        return scheduler ? emptyScheduled(scheduler) : EMPTY;
    }
    function emptyScheduled(scheduler) {
        return new Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
    }

    function isScheduler(value) {
        return value && typeof value.schedule === 'function';
    }

    var subscribeToArray = function (array) {
        return function (subscriber) {
            for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
                subscriber.next(array[i]);
            }
            subscriber.complete();
        };
    };

    function scheduleArray(input, scheduler) {
        return new Observable(function (subscriber) {
            var sub = new Subscription();
            var i = 0;
            sub.add(scheduler.schedule(function () {
                if (i === input.length) {
                    subscriber.complete();
                    return;
                }
                subscriber.next(input[i++]);
                if (!subscriber.closed) {
                    sub.add(this.schedule());
                }
            }));
            return sub;
        });
    }

    function fromArray(input, scheduler) {
        if (!scheduler) {
            return new Observable(subscribeToArray(input));
        }
        else {
            return scheduleArray(input, scheduler);
        }
    }

    function of() {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        var scheduler = args[args.length - 1];
        if (isScheduler(scheduler)) {
            args.pop();
            return scheduleArray(args, scheduler);
        }
        else {
            return fromArray(args);
        }
    }

    function throwError(error, scheduler) {
        if (!scheduler) {
            return new Observable(function (subscriber) { return subscriber.error(error); });
        }
        else {
            return new Observable(function (subscriber) { return scheduler.schedule(dispatch$1, 0, { error: error, subscriber: subscriber }); });
        }
    }
    function dispatch$1(_a) {
        var error = _a.error, subscriber = _a.subscriber;
        subscriber.error(error);
    }

    var NotificationKind;
     (function (NotificationKind) {
        NotificationKind["NEXT"] = "N";
        NotificationKind["ERROR"] = "E";
        NotificationKind["COMPLETE"] = "C";
    })(NotificationKind || (NotificationKind = {}));
    var Notification =  (function () {
        function Notification(kind, value, error) {
            this.kind = kind;
            this.value = value;
            this.error = error;
            this.hasValue = kind === 'N';
        }
        Notification.prototype.observe = function (observer) {
            switch (this.kind) {
                case 'N':
                    return observer.next && observer.next(this.value);
                case 'E':
                    return observer.error && observer.error(this.error);
                case 'C':
                    return observer.complete && observer.complete();
            }
        };
        Notification.prototype.do = function (next, error, complete) {
            var kind = this.kind;
            switch (kind) {
                case 'N':
                    return next && next(this.value);
                case 'E':
                    return error && error(this.error);
                case 'C':
                    return complete && complete();
            }
        };
        Notification.prototype.accept = function (nextOrObserver, error, complete) {
            if (nextOrObserver && typeof nextOrObserver.next === 'function') {
                return this.observe(nextOrObserver);
            }
            else {
                return this.do(nextOrObserver, error, complete);
            }
        };
        Notification.prototype.toObservable = function () {
            var kind = this.kind;
            switch (kind) {
                case 'N':
                    return of(this.value);
                case 'E':
                    return throwError(this.error);
                case 'C':
                    return empty();
            }
            throw new Error('unexpected notification kind value');
        };
        Notification.createNext = function (value) {
            if (typeof value !== 'undefined') {
                return new Notification('N', value);
            }
            return Notification.undefinedValueNotification;
        };
        Notification.createError = function (err) {
            return new Notification('E', undefined, err);
        };
        Notification.createComplete = function () {
            return Notification.completeNotification;
        };
        Notification.completeNotification = new Notification('C');
        Notification.undefinedValueNotification = new Notification('N', undefined);
        return Notification;
    }());

    var ObserveOnSubscriber =  (function (_super) {
        __extends$d(ObserveOnSubscriber, _super);
        function ObserveOnSubscriber(destination, scheduler, delay) {
            if (delay === void 0) {
                delay = 0;
            }
            var _this = _super.call(this, destination) || this;
            _this.scheduler = scheduler;
            _this.delay = delay;
            return _this;
        }
        ObserveOnSubscriber.dispatch = function (arg) {
            var notification = arg.notification, destination = arg.destination;
            notification.observe(destination);
            this.unsubscribe();
        };
        ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
            var destination = this.destination;
            destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
        };
        ObserveOnSubscriber.prototype._next = function (value) {
            this.scheduleMessage(Notification.createNext(value));
        };
        ObserveOnSubscriber.prototype._error = function (err) {
            this.scheduleMessage(Notification.createError(err));
            this.unsubscribe();
        };
        ObserveOnSubscriber.prototype._complete = function () {
            this.scheduleMessage(Notification.createComplete());
            this.unsubscribe();
        };
        return ObserveOnSubscriber;
    }(Subscriber));
    var ObserveOnMessage =  (function () {
        function ObserveOnMessage(notification, destination) {
            this.notification = notification;
            this.destination = destination;
        }
        return ObserveOnMessage;
    }());

    var ReplaySubject =  (function (_super) {
        __extends$d(ReplaySubject, _super);
        function ReplaySubject(bufferSize, windowTime, scheduler) {
            if (bufferSize === void 0) {
                bufferSize = Number.POSITIVE_INFINITY;
            }
            if (windowTime === void 0) {
                windowTime = Number.POSITIVE_INFINITY;
            }
            var _this = _super.call(this) || this;
            _this.scheduler = scheduler;
            _this._events = [];
            _this._infiniteTimeWindow = false;
            _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
            _this._windowTime = windowTime < 1 ? 1 : windowTime;
            if (windowTime === Number.POSITIVE_INFINITY) {
                _this._infiniteTimeWindow = true;
                _this.next = _this.nextInfiniteTimeWindow;
            }
            else {
                _this.next = _this.nextTimeWindow;
            }
            return _this;
        }
        ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
            if (!this.isStopped) {
                var _events = this._events;
                _events.push(value);
                if (_events.length > this._bufferSize) {
                    _events.shift();
                }
            }
            _super.prototype.next.call(this, value);
        };
        ReplaySubject.prototype.nextTimeWindow = function (value) {
            if (!this.isStopped) {
                this._events.push(new ReplayEvent(this._getNow(), value));
                this._trimBufferThenGetEvents();
            }
            _super.prototype.next.call(this, value);
        };
        ReplaySubject.prototype._subscribe = function (subscriber) {
            var _infiniteTimeWindow = this._infiniteTimeWindow;
            var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
            var scheduler = this.scheduler;
            var len = _events.length;
            var subscription;
            if (this.closed) {
                throw new ObjectUnsubscribedError();
            }
            else if (this.isStopped || this.hasError) {
                subscription = Subscription.EMPTY;
            }
            else {
                this.observers.push(subscriber);
                subscription = new SubjectSubscription(this, subscriber);
            }
            if (scheduler) {
                subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));
            }
            if (_infiniteTimeWindow) {
                for (var i = 0; i < len && !subscriber.closed; i++) {
                    subscriber.next(_events[i]);
                }
            }
            else {
                for (var i = 0; i < len && !subscriber.closed; i++) {
                    subscriber.next(_events[i].value);
                }
            }
            if (this.hasError) {
                subscriber.error(this.thrownError);
            }
            else if (this.isStopped) {
                subscriber.complete();
            }
            return subscription;
        };
        ReplaySubject.prototype._getNow = function () {
            return (this.scheduler || queue).now();
        };
        ReplaySubject.prototype._trimBufferThenGetEvents = function () {
            var now = this._getNow();
            var _bufferSize = this._bufferSize;
            var _windowTime = this._windowTime;
            var _events = this._events;
            var eventsCount = _events.length;
            var spliceCount = 0;
            while (spliceCount < eventsCount) {
                if ((now - _events[spliceCount].time) < _windowTime) {
                    break;
                }
                spliceCount++;
            }
            if (eventsCount > _bufferSize) {
                spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
            }
            if (spliceCount > 0) {
                _events.splice(0, spliceCount);
            }
            return _events;
        };
        return ReplaySubject;
    }(Subject));
    var ReplayEvent =  (function () {
        function ReplayEvent(time, value) {
            this.time = time;
            this.value = value;
        }
        return ReplayEvent;
    }());

    var asyncScheduler =  new AsyncScheduler(AsyncAction);
    var async = asyncScheduler;

    function noop$1() { }

    var ArgumentOutOfRangeErrorImpl =  (function () {
        function ArgumentOutOfRangeErrorImpl() {
            Error.call(this);
            this.message = 'argument out of range';
            this.name = 'ArgumentOutOfRangeError';
            return this;
        }
        ArgumentOutOfRangeErrorImpl.prototype =  Object.create(Error.prototype);
        return ArgumentOutOfRangeErrorImpl;
    })();
    var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;

    var EmptyErrorImpl =  (function () {
        function EmptyErrorImpl() {
            Error.call(this);
            this.message = 'no elements in sequence';
            this.name = 'EmptyError';
            return this;
        }
        EmptyErrorImpl.prototype =  Object.create(Error.prototype);
        return EmptyErrorImpl;
    })();
    var EmptyError = EmptyErrorImpl;

    var TimeoutErrorImpl =  (function () {
        function TimeoutErrorImpl() {
            Error.call(this);
            this.message = 'Timeout has occurred';
            this.name = 'TimeoutError';
            return this;
        }
        TimeoutErrorImpl.prototype =  Object.create(Error.prototype);
        return TimeoutErrorImpl;
    })();
    var TimeoutError = TimeoutErrorImpl;

    function map(project, thisArg) {
        return function mapOperation(source) {
            if (typeof project !== 'function') {
                throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
            }
            return source.lift(new MapOperator(project, thisArg));
        };
    }
    var MapOperator =  (function () {
        function MapOperator(project, thisArg) {
            this.project = project;
            this.thisArg = thisArg;
        }
        MapOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
        };
        return MapOperator;
    }());
    var MapSubscriber =  (function (_super) {
        __extends$d(MapSubscriber, _super);
        function MapSubscriber(destination, project, thisArg) {
            var _this = _super.call(this, destination) || this;
            _this.project = project;
            _this.count = 0;
            _this.thisArg = thisArg || _this;
            return _this;
        }
        MapSubscriber.prototype._next = function (value) {
            var result;
            try {
                result = this.project.call(this.thisArg, value, this.count++);
            }
            catch (err) {
                this.destination.error(err);
                return;
            }
            this.destination.next(result);
        };
        return MapSubscriber;
    }(Subscriber));

    var OuterSubscriber =  (function (_super) {
        __extends$d(OuterSubscriber, _super);
        function OuterSubscriber() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
            this.destination.next(innerValue);
        };
        OuterSubscriber.prototype.notifyError = function (error, innerSub) {
            this.destination.error(error);
        };
        OuterSubscriber.prototype.notifyComplete = function (innerSub) {
            this.destination.complete();
        };
        return OuterSubscriber;
    }(Subscriber));

    var InnerSubscriber =  (function (_super) {
        __extends$d(InnerSubscriber, _super);
        function InnerSubscriber(parent, outerValue, outerIndex) {
            var _this = _super.call(this) || this;
            _this.parent = parent;
            _this.outerValue = outerValue;
            _this.outerIndex = outerIndex;
            _this.index = 0;
            return _this;
        }
        InnerSubscriber.prototype._next = function (value) {
            this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
        };
        InnerSubscriber.prototype._error = function (error) {
            this.parent.notifyError(error, this);
            this.unsubscribe();
        };
        InnerSubscriber.prototype._complete = function () {
            this.parent.notifyComplete(this);
            this.unsubscribe();
        };
        return InnerSubscriber;
    }(Subscriber));

    var subscribeToPromise = function (promise) {
        return function (subscriber) {
            promise.then(function (value) {
                if (!subscriber.closed) {
                    subscriber.next(value);
                    subscriber.complete();
                }
            }, function (err) { return subscriber.error(err); })
                .then(null, hostReportError);
            return subscriber;
        };
    };

    function getSymbolIterator() {
        if (typeof Symbol !== 'function' || !Symbol.iterator) {
            return '@@iterator';
        }
        return Symbol.iterator;
    }
    var iterator =  getSymbolIterator();

    var subscribeToIterable = function (iterable) {
        return function (subscriber) {
            var iterator$1 = iterable[iterator]();
            do {
                var item = void 0;
                try {
                    item = iterator$1.next();
                }
                catch (err) {
                    subscriber.error(err);
                    return subscriber;
                }
                if (item.done) {
                    subscriber.complete();
                    break;
                }
                subscriber.next(item.value);
                if (subscriber.closed) {
                    break;
                }
            } while (true);
            if (typeof iterator$1.return === 'function') {
                subscriber.add(function () {
                    if (iterator$1.return) {
                        iterator$1.return();
                    }
                });
            }
            return subscriber;
        };
    };

    var subscribeToObservable = function (obj) {
        return function (subscriber) {
            var obs = obj[observable]();
            if (typeof obs.subscribe !== 'function') {
                throw new TypeError('Provided object does not correctly implement Symbol.observable');
            }
            else {
                return obs.subscribe(subscriber);
            }
        };
    };

    var isArrayLike$1 = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });

    function isPromise(value) {
        return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
    }

    var subscribeTo = function (result) {
        if (!!result && typeof result[observable] === 'function') {
            return subscribeToObservable(result);
        }
        else if (isArrayLike$1(result)) {
            return subscribeToArray(result);
        }
        else if (isPromise(result)) {
            return subscribeToPromise(result);
        }
        else if (!!result && typeof result[iterator] === 'function') {
            return subscribeToIterable(result);
        }
        else {
            var value = isObject$1(result) ? 'an invalid object' : "'" + result + "'";
            var msg = "You provided " + value + " where a stream was expected."
                + ' You can provide an Observable, Promise, Array, or Iterable.';
            throw new TypeError(msg);
        }
    };

    function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, innerSubscriber) {
        if (innerSubscriber === void 0) {
            innerSubscriber = new InnerSubscriber(outerSubscriber, outerValue, outerIndex);
        }
        if (innerSubscriber.closed) {
            return undefined;
        }
        if (result instanceof Observable) {
            return result.subscribe(innerSubscriber);
        }
        return subscribeTo(result)(innerSubscriber);
    }

    var NONE = {};
    function combineLatest() {
        var observables = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            observables[_i] = arguments[_i];
        }
        var resultSelector = undefined;
        var scheduler = undefined;
        if (isScheduler(observables[observables.length - 1])) {
            scheduler = observables.pop();
        }
        if (typeof observables[observables.length - 1] === 'function') {
            resultSelector = observables.pop();
        }
        if (observables.length === 1 && isArray$2(observables[0])) {
            observables = observables[0];
        }
        return fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
    }
    var CombineLatestOperator =  (function () {
        function CombineLatestOperator(resultSelector) {
            this.resultSelector = resultSelector;
        }
        CombineLatestOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
        };
        return CombineLatestOperator;
    }());
    var CombineLatestSubscriber =  (function (_super) {
        __extends$d(CombineLatestSubscriber, _super);
        function CombineLatestSubscriber(destination, resultSelector) {
            var _this = _super.call(this, destination) || this;
            _this.resultSelector = resultSelector;
            _this.active = 0;
            _this.values = [];
            _this.observables = [];
            return _this;
        }
        CombineLatestSubscriber.prototype._next = function (observable) {
            this.values.push(NONE);
            this.observables.push(observable);
        };
        CombineLatestSubscriber.prototype._complete = function () {
            var observables = this.observables;
            var len = observables.length;
            if (len === 0) {
                this.destination.complete();
            }
            else {
                this.active = len;
                this.toRespond = len;
                for (var i = 0; i < len; i++) {
                    var observable = observables[i];
                    this.add(subscribeToResult(this, observable, undefined, i));
                }
            }
        };
        CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
            if ((this.active -= 1) === 0) {
                this.destination.complete();
            }
        };
        CombineLatestSubscriber.prototype.notifyNext = function (_outerValue, innerValue, outerIndex) {
            var values = this.values;
            var oldVal = values[outerIndex];
            var toRespond = !this.toRespond
                ? 0
                : oldVal === NONE ? --this.toRespond : this.toRespond;
            values[outerIndex] = innerValue;
            if (toRespond === 0) {
                if (this.resultSelector) {
                    this._tryResultSelector(values);
                }
                else {
                    this.destination.next(values.slice());
                }
            }
        };
        CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
            var result;
            try {
                result = this.resultSelector.apply(this, values);
            }
            catch (err) {
                this.destination.error(err);
                return;
            }
            this.destination.next(result);
        };
        return CombineLatestSubscriber;
    }(OuterSubscriber));

    function scheduleObservable(input, scheduler) {
        return new Observable(function (subscriber) {
            var sub = new Subscription();
            sub.add(scheduler.schedule(function () {
                var observable$1 = input[observable]();
                sub.add(observable$1.subscribe({
                    next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
                    error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
                    complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
                }));
            }));
            return sub;
        });
    }

    function schedulePromise(input, scheduler) {
        return new Observable(function (subscriber) {
            var sub = new Subscription();
            sub.add(scheduler.schedule(function () {
                return input.then(function (value) {
                    sub.add(scheduler.schedule(function () {
                        subscriber.next(value);
                        sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
                    }));
                }, function (err) {
                    sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
                });
            }));
            return sub;
        });
    }

    function scheduleIterable(input, scheduler) {
        if (!input) {
            throw new Error('Iterable cannot be null');
        }
        return new Observable(function (subscriber) {
            var sub = new Subscription();
            var iterator$1;
            sub.add(function () {
                if (iterator$1 && typeof iterator$1.return === 'function') {
                    iterator$1.return();
                }
            });
            sub.add(scheduler.schedule(function () {
                iterator$1 = input[iterator]();
                sub.add(scheduler.schedule(function () {
                    if (subscriber.closed) {
                        return;
                    }
                    var value;
                    var done;
                    try {
                        var result = iterator$1.next();
                        value = result.value;
                        done = result.done;
                    }
                    catch (err) {
                        subscriber.error(err);
                        return;
                    }
                    if (done) {
                        subscriber.complete();
                    }
                    else {
                        subscriber.next(value);
                        this.schedule();
                    }
                }));
            }));
            return sub;
        });
    }

    function isInteropObservable(input) {
        return input && typeof input[observable] === 'function';
    }

    function isIterable(input) {
        return input && typeof input[iterator] === 'function';
    }

    function scheduled(input, scheduler) {
        if (input != null) {
            if (isInteropObservable(input)) {
                return scheduleObservable(input, scheduler);
            }
            else if (isPromise(input)) {
                return schedulePromise(input, scheduler);
            }
            else if (isArrayLike$1(input)) {
                return scheduleArray(input, scheduler);
            }
            else if (isIterable(input) || typeof input === 'string') {
                return scheduleIterable(input, scheduler);
            }
        }
        throw new TypeError((input !== null && typeof input || input) + ' is not observable');
    }

    function from(input, scheduler) {
        if (!scheduler) {
            if (input instanceof Observable) {
                return input;
            }
            return new Observable(subscribeTo(input));
        }
        else {
            return scheduled(input, scheduler);
        }
    }

    var SimpleInnerSubscriber =  (function (_super) {
        __extends$d(SimpleInnerSubscriber, _super);
        function SimpleInnerSubscriber(parent) {
            var _this = _super.call(this) || this;
            _this.parent = parent;
            return _this;
        }
        SimpleInnerSubscriber.prototype._next = function (value) {
            this.parent.notifyNext(value);
        };
        SimpleInnerSubscriber.prototype._error = function (error) {
            this.parent.notifyError(error);
            this.unsubscribe();
        };
        SimpleInnerSubscriber.prototype._complete = function () {
            this.parent.notifyComplete();
            this.unsubscribe();
        };
        return SimpleInnerSubscriber;
    }(Subscriber));
    ((function (_super) {
        __extends$d(ComplexInnerSubscriber, _super);
        function ComplexInnerSubscriber(parent, outerValue, outerIndex) {
            var _this = _super.call(this) || this;
            _this.parent = parent;
            _this.outerValue = outerValue;
            _this.outerIndex = outerIndex;
            return _this;
        }
        ComplexInnerSubscriber.prototype._next = function (value) {
            this.parent.notifyNext(this.outerValue, value, this.outerIndex, this);
        };
        ComplexInnerSubscriber.prototype._error = function (error) {
            this.parent.notifyError(error);
            this.unsubscribe();
        };
        ComplexInnerSubscriber.prototype._complete = function () {
            this.parent.notifyComplete(this);
            this.unsubscribe();
        };
        return ComplexInnerSubscriber;
    })(Subscriber));
    var SimpleOuterSubscriber =  (function (_super) {
        __extends$d(SimpleOuterSubscriber, _super);
        function SimpleOuterSubscriber() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        SimpleOuterSubscriber.prototype.notifyNext = function (innerValue) {
            this.destination.next(innerValue);
        };
        SimpleOuterSubscriber.prototype.notifyError = function (err) {
            this.destination.error(err);
        };
        SimpleOuterSubscriber.prototype.notifyComplete = function () {
            this.destination.complete();
        };
        return SimpleOuterSubscriber;
    }(Subscriber));
    ((function (_super) {
        __extends$d(ComplexOuterSubscriber, _super);
        function ComplexOuterSubscriber() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        ComplexOuterSubscriber.prototype.notifyNext = function (_outerValue, innerValue, _outerIndex, _innerSub) {
            this.destination.next(innerValue);
        };
        ComplexOuterSubscriber.prototype.notifyError = function (error) {
            this.destination.error(error);
        };
        ComplexOuterSubscriber.prototype.notifyComplete = function (_innerSub) {
            this.destination.complete();
        };
        return ComplexOuterSubscriber;
    })(Subscriber));
    function innerSubscribe(result, innerSubscriber) {
        if (innerSubscriber.closed) {
            return undefined;
        }
        if (result instanceof Observable) {
            return result.subscribe(innerSubscriber);
        }
        var subscription;
        try {
            subscription = subscribeTo(result)(innerSubscriber);
        }
        catch (error) {
            innerSubscriber.error(error);
        }
        return subscription;
    }

    function mergeMap(project, resultSelector, concurrent) {
        if (concurrent === void 0) {
            concurrent = Number.POSITIVE_INFINITY;
        }
        if (typeof resultSelector === 'function') {
            return function (source) { return source.pipe(mergeMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };
        }
        else if (typeof resultSelector === 'number') {
            concurrent = resultSelector;
        }
        return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
    }
    var MergeMapOperator =  (function () {
        function MergeMapOperator(project, concurrent) {
            if (concurrent === void 0) {
                concurrent = Number.POSITIVE_INFINITY;
            }
            this.project = project;
            this.concurrent = concurrent;
        }
        MergeMapOperator.prototype.call = function (observer, source) {
            return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
        };
        return MergeMapOperator;
    }());
    var MergeMapSubscriber =  (function (_super) {
        __extends$d(MergeMapSubscriber, _super);
        function MergeMapSubscriber(destination, project, concurrent) {
            if (concurrent === void 0) {
                concurrent = Number.POSITIVE_INFINITY;
            }
            var _this = _super.call(this, destination) || this;
            _this.project = project;
            _this.concurrent = concurrent;
            _this.hasCompleted = false;
            _this.buffer = [];
            _this.active = 0;
            _this.index = 0;
            return _this;
        }
        MergeMapSubscriber.prototype._next = function (value) {
            if (this.active < this.concurrent) {
                this._tryNext(value);
            }
            else {
                this.buffer.push(value);
            }
        };
        MergeMapSubscriber.prototype._tryNext = function (value) {
            var result;
            var index = this.index++;
            try {
                result = this.project(value, index);
            }
            catch (err) {
                this.destination.error(err);
                return;
            }
            this.active++;
            this._innerSub(result);
        };
        MergeMapSubscriber.prototype._innerSub = function (ish) {
            var innerSubscriber = new SimpleInnerSubscriber(this);
            var destination = this.destination;
            destination.add(innerSubscriber);
            var innerSubscription = innerSubscribe(ish, innerSubscriber);
            if (innerSubscription !== innerSubscriber) {
                destination.add(innerSubscription);
            }
        };
        MergeMapSubscriber.prototype._complete = function () {
            this.hasCompleted = true;
            if (this.active === 0 && this.buffer.length === 0) {
                this.destination.complete();
            }
            this.unsubscribe();
        };
        MergeMapSubscriber.prototype.notifyNext = function (innerValue) {
            this.destination.next(innerValue);
        };
        MergeMapSubscriber.prototype.notifyComplete = function () {
            var buffer = this.buffer;
            this.active--;
            if (buffer.length > 0) {
                this._next(buffer.shift());
            }
            else if (this.active === 0 && this.hasCompleted) {
                this.destination.complete();
            }
        };
        return MergeMapSubscriber;
    }(SimpleOuterSubscriber));

    function mergeAll(concurrent) {
        if (concurrent === void 0) {
            concurrent = Number.POSITIVE_INFINITY;
        }
        return mergeMap(identity$1, concurrent);
    }

    function defer(observableFactory) {
        return new Observable(function (subscriber) {
            var input;
            try {
                input = observableFactory();
            }
            catch (err) {
                subscriber.error(err);
                return undefined;
            }
            var source = input ? from(input) : empty();
            return source.subscribe(subscriber);
        });
    }

    function fromEvent(target, eventName, options, resultSelector) {
        if (isFunction$1(options)) {
            resultSelector = options;
            options = undefined;
        }
        if (resultSelector) {
            return fromEvent(target, eventName, options).pipe(map(function (args) { return isArray$2(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
        }
        return new Observable(function (subscriber) {
            function handler(e) {
                if (arguments.length > 1) {
                    subscriber.next(Array.prototype.slice.call(arguments));
                }
                else {
                    subscriber.next(e);
                }
            }
            setupSubscription(target, eventName, handler, subscriber, options);
        });
    }
    function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
        var unsubscribe;
        if (isEventTarget(sourceObj)) {
            var source_1 = sourceObj;
            sourceObj.addEventListener(eventName, handler, options);
            unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
        }
        else if (isJQueryStyleEventEmitter(sourceObj)) {
            var source_2 = sourceObj;
            sourceObj.on(eventName, handler);
            unsubscribe = function () { return source_2.off(eventName, handler); };
        }
        else if (isNodeStyleEventEmitter(sourceObj)) {
            var source_3 = sourceObj;
            sourceObj.addListener(eventName, handler);
            unsubscribe = function () { return source_3.removeListener(eventName, handler); };
        }
        else if (sourceObj && sourceObj.length) {
            for (var i = 0, len = sourceObj.length; i < len; i++) {
                setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
            }
        }
        else {
            throw new TypeError('Invalid event target');
        }
        subscriber.add(unsubscribe);
    }
    function isNodeStyleEventEmitter(sourceObj) {
        return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
    }
    function isJQueryStyleEventEmitter(sourceObj) {
        return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
    }
    function isEventTarget(sourceObj) {
        return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
    }

    function isNumeric(val) {
        return !isArray$2(val) && (val - parseFloat(val) + 1) >= 0;
    }

    function interval(period, scheduler) {
        if (period === void 0) {
            period = 0;
        }
        if (scheduler === void 0) {
            scheduler = async;
        }
        if (!isNumeric(period) || period < 0) {
            period = 0;
        }
        if (!scheduler || typeof scheduler.schedule !== 'function') {
            scheduler = async;
        }
        return new Observable(function (subscriber) {
            subscriber.add(scheduler.schedule(dispatch, period, { subscriber: subscriber, counter: 0, period: period }));
            return subscriber;
        });
    }
    function dispatch(state) {
        var subscriber = state.subscriber, counter = state.counter, period = state.period;
        subscriber.next(counter);
        this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
    }

    function merge() {
        var observables = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            observables[_i] = arguments[_i];
        }
        var concurrent = Number.POSITIVE_INFINITY;
        var scheduler = null;
        var last = observables[observables.length - 1];
        if (isScheduler(last)) {
            scheduler = observables.pop();
            if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
                concurrent = observables.pop();
            }
        }
        else if (typeof last === 'number') {
            concurrent = observables.pop();
        }
        if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) {
            return observables[0];
        }
        return mergeAll(concurrent)(fromArray(observables, scheduler));
    }

    function not(pred, thisArg) {
        function notPred() {
            return !(notPred.pred.apply(notPred.thisArg, arguments));
        }
        notPred.pred = pred;
        notPred.thisArg = thisArg;
        return notPred;
    }

    function filter(predicate, thisArg) {
        return function filterOperatorFunction(source) {
            return source.lift(new FilterOperator(predicate, thisArg));
        };
    }
    var FilterOperator =  (function () {
        function FilterOperator(predicate, thisArg) {
            this.predicate = predicate;
            this.thisArg = thisArg;
        }
        FilterOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
        };
        return FilterOperator;
    }());
    var FilterSubscriber =  (function (_super) {
        __extends$d(FilterSubscriber, _super);
        function FilterSubscriber(destination, predicate, thisArg) {
            var _this = _super.call(this, destination) || this;
            _this.predicate = predicate;
            _this.thisArg = thisArg;
            _this.count = 0;
            return _this;
        }
        FilterSubscriber.prototype._next = function (value) {
            var result;
            try {
                result = this.predicate.call(this.thisArg, value, this.count++);
            }
            catch (err) {
                this.destination.error(err);
                return;
            }
            if (result) {
                this.destination.next(value);
            }
        };
        return FilterSubscriber;
    }(Subscriber));

    function partition(source, predicate, thisArg) {
        return [
            filter(predicate, thisArg)(new Observable(subscribeTo(source))),
            filter(not(predicate, thisArg))(new Observable(subscribeTo(source)))
        ];
    }

    var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

    function unwrapExports (x) {
    	return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
    }

    function createCommonjsModule(fn, basedir, module) {
    	return module = {
    	  path: basedir,
    	  exports: {},
    	  require: function (path, base) {
          return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
        }
    	}, fn(module, module.exports), module.exports;
    }

    function commonjsRequire () {
    	throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
    }

    var s = 1000;
    var m = s * 60;
    var h = m * 60;
    var d = h * 24;
    var w = d * 7;
    var y = d * 365.25;
    var ms = function(val, options) {
      options = options || {};
      var type = typeof val;
      if (type === 'string' && val.length > 0) {
        return parse$1(val);
      } else if (type === 'number' && isFinite(val)) {
        return options.long ? fmtLong(val) : fmtShort(val);
      }
      throw new Error(
        'val is not a non-empty string or a valid number. val=' +
          JSON.stringify(val)
      );
    };
    function parse$1(str) {
      str = String(str);
      if (str.length > 100) {
        return;
      }
      var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
        str
      );
      if (!match) {
        return;
      }
      var n = parseFloat(match[1]);
      var type = (match[2] || 'ms').toLowerCase();
      switch (type) {
        case 'years':
        case 'year':
        case 'yrs':
        case 'yr':
        case 'y':
          return n * y;
        case 'weeks':
        case 'week':
        case 'w':
          return n * w;
        case 'days':
        case 'day':
        case 'd':
          return n * d;
        case 'hours':
        case 'hour':
        case 'hrs':
        case 'hr':
        case 'h':
          return n * h;
        case 'minutes':
        case 'minute':
        case 'mins':
        case 'min':
        case 'm':
          return n * m;
        case 'seconds':
        case 'second':
        case 'secs':
        case 'sec':
        case 's':
          return n * s;
        case 'milliseconds':
        case 'millisecond':
        case 'msecs':
        case 'msec':
        case 'ms':
          return n;
        default:
          return undefined;
      }
    }
    function fmtShort(ms) {
      var msAbs = Math.abs(ms);
      if (msAbs >= d) {
        return Math.round(ms / d) + 'd';
      }
      if (msAbs >= h) {
        return Math.round(ms / h) + 'h';
      }
      if (msAbs >= m) {
        return Math.round(ms / m) + 'm';
      }
      if (msAbs >= s) {
        return Math.round(ms / s) + 's';
      }
      return ms + 'ms';
    }
    function fmtLong(ms) {
      var msAbs = Math.abs(ms);
      if (msAbs >= d) {
        return plural(ms, msAbs, d, 'day');
      }
      if (msAbs >= h) {
        return plural(ms, msAbs, h, 'hour');
      }
      if (msAbs >= m) {
        return plural(ms, msAbs, m, 'minute');
      }
      if (msAbs >= s) {
        return plural(ms, msAbs, s, 'second');
      }
      return ms + ' ms';
    }
    function plural(ms, msAbs, n, name) {
      var isPlural = msAbs >= n * 1.5;
      return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
    }

    function setup(env) {
    	createDebug.debug = createDebug;
    	createDebug.default = createDebug;
    	createDebug.coerce = coerce;
    	createDebug.disable = disable;
    	createDebug.enable = enable;
    	createDebug.enabled = enabled;
    	createDebug.humanize = ms;
    	createDebug.destroy = destroy;
    	Object.keys(env).forEach(key => {
    		createDebug[key] = env[key];
    	});
    	createDebug.names = [];
    	createDebug.skips = [];
    	createDebug.formatters = {};
    	function selectColor(namespace) {
    		let hash = 0;
    		for (let i = 0; i < namespace.length; i++) {
    			hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
    			hash |= 0;
    		}
    		return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
    	}
    	createDebug.selectColor = selectColor;
    	function createDebug(namespace) {
    		let prevTime;
    		let enableOverride = null;
    		let namespacesCache;
    		let enabledCache;
    		function debug(...args) {
    			if (!debug.enabled) {
    				return;
    			}
    			const self = debug;
    			const curr = Number(new Date());
    			const ms = curr - (prevTime || curr);
    			self.diff = ms;
    			self.prev = prevTime;
    			self.curr = curr;
    			prevTime = curr;
    			args[0] = createDebug.coerce(args[0]);
    			if (typeof args[0] !== 'string') {
    				args.unshift('%O');
    			}
    			let index = 0;
    			args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
    				if (match === '%%') {
    					return '%';
    				}
    				index++;
    				const formatter = createDebug.formatters[format];
    				if (typeof formatter === 'function') {
    					const val = args[index];
    					match = formatter.call(self, val);
    					args.splice(index, 1);
    					index--;
    				}
    				return match;
    			});
    			createDebug.formatArgs.call(self, args);
    			const logFn = self.log || createDebug.log;
    			logFn.apply(self, args);
    		}
    		debug.namespace = namespace;
    		debug.useColors = createDebug.useColors();
    		debug.color = createDebug.selectColor(namespace);
    		debug.extend = extend;
    		debug.destroy = createDebug.destroy;
    		Object.defineProperty(debug, 'enabled', {
    			enumerable: true,
    			configurable: false,
    			get: () => {
    				if (enableOverride !== null) {
    					return enableOverride;
    				}
    				if (namespacesCache !== createDebug.namespaces) {
    					namespacesCache = createDebug.namespaces;
    					enabledCache = createDebug.enabled(namespace);
    				}
    				return enabledCache;
    			},
    			set: v => {
    				enableOverride = v;
    			}
    		});
    		if (typeof createDebug.init === 'function') {
    			createDebug.init(debug);
    		}
    		return debug;
    	}
    	function extend(namespace, delimiter) {
    		const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
    		newDebug.log = this.log;
    		return newDebug;
    	}
    	function enable(namespaces) {
    		createDebug.save(namespaces);
    		createDebug.namespaces = namespaces;
    		createDebug.names = [];
    		createDebug.skips = [];
    		let i;
    		const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
    		const len = split.length;
    		for (i = 0; i < len; i++) {
    			if (!split[i]) {
    				continue;
    			}
    			namespaces = split[i].replace(/\*/g, '.*?');
    			if (namespaces[0] === '-') {
    				createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
    			} else {
    				createDebug.names.push(new RegExp('^' + namespaces + '$'));
    			}
    		}
    	}
    	function disable() {
    		const namespaces = [
    			...createDebug.names.map(toNamespace),
    			...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
    		].join(',');
    		createDebug.enable('');
    		return namespaces;
    	}
    	function enabled(name) {
    		if (name[name.length - 1] === '*') {
    			return true;
    		}
    		let i;
    		let len;
    		for (i = 0, len = createDebug.skips.length; i < len; i++) {
    			if (createDebug.skips[i].test(name)) {
    				return false;
    			}
    		}
    		for (i = 0, len = createDebug.names.length; i < len; i++) {
    			if (createDebug.names[i].test(name)) {
    				return true;
    			}
    		}
    		return false;
    	}
    	function toNamespace(regexp) {
    		return regexp.toString()
    			.substring(2, regexp.toString().length - 2)
    			.replace(/\.\*\?$/, '*');
    	}
    	function coerce(val) {
    		if (val instanceof Error) {
    			return val.stack || val.message;
    		}
    		return val;
    	}
    	function destroy() {
    		console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
    	}
    	createDebug.enable(createDebug.load());
    	return createDebug;
    }
    var common = setup;

    var browser$1 = createCommonjsModule(function (module, exports) {
    exports.formatArgs = formatArgs;
    exports.save = save;
    exports.load = load;
    exports.useColors = useColors;
    exports.storage = localstorage();
    exports.destroy = (() => {
    	let warned = false;
    	return () => {
    		if (!warned) {
    			warned = true;
    			console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
    		}
    	};
    })();
    exports.colors = [
    	'#0000CC',
    	'#0000FF',
    	'#0033CC',
    	'#0033FF',
    	'#0066CC',
    	'#0066FF',
    	'#0099CC',
    	'#0099FF',
    	'#00CC00',
    	'#00CC33',
    	'#00CC66',
    	'#00CC99',
    	'#00CCCC',
    	'#00CCFF',
    	'#3300CC',
    	'#3300FF',
    	'#3333CC',
    	'#3333FF',
    	'#3366CC',
    	'#3366FF',
    	'#3399CC',
    	'#3399FF',
    	'#33CC00',
    	'#33CC33',
    	'#33CC66',
    	'#33CC99',
    	'#33CCCC',
    	'#33CCFF',
    	'#6600CC',
    	'#6600FF',
    	'#6633CC',
    	'#6633FF',
    	'#66CC00',
    	'#66CC33',
    	'#9900CC',
    	'#9900FF',
    	'#9933CC',
    	'#9933FF',
    	'#99CC00',
    	'#99CC33',
    	'#CC0000',
    	'#CC0033',
    	'#CC0066',
    	'#CC0099',
    	'#CC00CC',
    	'#CC00FF',
    	'#CC3300',
    	'#CC3333',
    	'#CC3366',
    	'#CC3399',
    	'#CC33CC',
    	'#CC33FF',
    	'#CC6600',
    	'#CC6633',
    	'#CC9900',
    	'#CC9933',
    	'#CCCC00',
    	'#CCCC33',
    	'#FF0000',
    	'#FF0033',
    	'#FF0066',
    	'#FF0099',
    	'#FF00CC',
    	'#FF00FF',
    	'#FF3300',
    	'#FF3333',
    	'#FF3366',
    	'#FF3399',
    	'#FF33CC',
    	'#FF33FF',
    	'#FF6600',
    	'#FF6633',
    	'#FF9900',
    	'#FF9933',
    	'#FFCC00',
    	'#FFCC33'
    ];
    function useColors() {
    	if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
    		return true;
    	}
    	if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
    		return false;
    	}
    	return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
    		(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
    		(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
    		(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
    }
    function formatArgs(args) {
    	args[0] = (this.useColors ? '%c' : '') +
    		this.namespace +
    		(this.useColors ? ' %c' : ' ') +
    		args[0] +
    		(this.useColors ? '%c ' : ' ') +
    		'+' + module.exports.humanize(this.diff);
    	if (!this.useColors) {
    		return;
    	}
    	const c = 'color: ' + this.color;
    	args.splice(1, 0, c, 'color: inherit');
    	let index = 0;
    	let lastC = 0;
    	args[0].replace(/%[a-zA-Z%]/g, match => {
    		if (match === '%%') {
    			return;
    		}
    		index++;
    		if (match === '%c') {
    			lastC = index;
    		}
    	});
    	args.splice(lastC, 0, c);
    }
    exports.log = console.debug || console.log || (() => {});
    function save(namespaces) {
    	try {
    		if (namespaces) {
    			exports.storage.setItem('debug', namespaces);
    		} else {
    			exports.storage.removeItem('debug');
    		}
    	} catch (error) {
    	}
    }
    function load() {
    	let r;
    	try {
    		r = exports.storage.getItem('debug');
    	} catch (error) {
    	}
    	if (!r && typeof process !== 'undefined' && 'env' in process) {
    		r = process.env.DEBUG;
    	}
    	return r;
    }
    function localstorage() {
    	try {
    		return localStorage;
    	} catch (error) {
    	}
    }
    module.exports = common(exports);
    const {formatters} = module.exports;
    formatters.j = function (v) {
    	try {
    		return JSON.stringify(v);
    	} catch (error) {
    		return '[UnexpectedJSONParseError]: ' + error.message;
    	}
    };
    });
    var debug = browser$1;
    browser$1.formatArgs;
    browser$1.save;
    browser$1.load;
    browser$1.useColors;
    browser$1.storage;
    browser$1.destroy;
    browser$1.colors;
    browser$1.log;

    var LogLevel;
    (function (LogLevel) {
        LogLevel[LogLevel["Verbose"] = 1] = "Verbose";
        LogLevel[LogLevel["Debug"] = 2] = "Debug";
        LogLevel[LogLevel["Info"] = 3] = "Info";
        LogLevel[LogLevel["Warn"] = 4] = "Warn";
        LogLevel[LogLevel["Error"] = 5] = "Error";
        LogLevel[LogLevel["Fatal"] = 6] = "Fatal";
        LogLevel[LogLevel["None"] = 7] = "None";
    })(LogLevel || (LogLevel = {}));
    var LogConfig =  (function () {
        function LogConfig(options, prefix) {
            this.enabled = true;
            this.prefix = "WebAPIclient";
            this.objectToJson = false;
            this.instanceIdLogged = false;
            this.logLevel = LogLevel.Debug;
            this.timestamp = true;
            if (!options)
                return;
            loadConfig(prefix, LogConfig.CHECK_OPTIONS, this, options);
        }
        LogConfig.CHECK_OPTIONS = {
            mandatory: {},
            optional: {
                enabled: booleanCheck,
                prefix: stringCheck,
                objectToJson: booleanCheck,
                instanceIdLogged: booleanCheck,
                timestamp: booleanCheck,
                logLevel: function (logLevel) {
                    if (logLevel && logLevel >= LogLevel.Verbose && logLevel <= LogLevel.None) {
                        return logLevel;
                    }
                    else {
                        return undefined;
                    }
                },
            },
        };
        return LogConfig;
    }());

    var __extends$b = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var pkg = {
        version: "22.0.0",
    };
    debug.formatters.j = function (obj) {
        try {
            return undefined === obj ? "" : JSON.stringify(obj, MapOrSet_toJSON);
        }
        catch (error) {
            return "[UnexpectedJSONParseError]: " + error.message;
        }
    };
    var LogConfigurator =  (function () {
        function LogConfigurator() {
        }
        return LogConfigurator;
    }());
    var DefaultLogConfigurator =  (function (_super) {
        __extends$b(DefaultLogConfigurator, _super);
        function DefaultLogConfigurator(
        conf) {
            var _this = _super.call(this) || this;
            _this.conf = conf;
            return _this;
        }
        Object.defineProperty(DefaultLogConfigurator.prototype, "objectToJson", {
            get: function () {
                var _a;
                return (_a = this.conf.objectToJson) !== null && _a !== void 0 ? _a : DefaultLogConfigInstance.objectToJson;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(DefaultLogConfigurator.prototype, "instanceIdLogged", {
            get: function () {
                var _a;
                return (_a = this.conf.instanceIdLogged) !== null && _a !== void 0 ? _a : DefaultLogConfigInstance.instanceIdLogged;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(DefaultLogConfigurator.prototype, "logLevel", {
            get: function () {
                var _a;
                return (_a = this.conf.logLevel) !== null && _a !== void 0 ? _a : DefaultLogConfigInstance.logLevel;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(DefaultLogConfigurator.prototype, "prefix", {
            get: function () {
                var _a;
                return (_a = this.conf.prefix) !== null && _a !== void 0 ? _a : DefaultLogConfigInstance.prefix;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(DefaultLogConfigurator.prototype, "timestamp", {
            get: function () {
                var _a;
                return (_a = this.conf.timestamp) !== null && _a !== void 0 ? _a : DefaultLogConfigInstance.timestamp;
            },
            enumerable: false,
            configurable: true
        });
        return DefaultLogConfigurator;
    }(LogConfigurator));
    var DefaultLogConfigInstance = new LogConfig();
    var DefaultLogConfiguratorInstance = new DefaultLogConfigurator(DefaultLogConfigInstance);
    var Log$1 =  (function () {
        function Log(
        _pkg,
        _instanceId,
        _config) {
            var _this = this;
            this._pkg = _pkg;
            this._instanceId = _instanceId;
            this._config = _config;
            this.debugMethods = new Map();
            this.verbose = function () {
                var args = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    args[_i] = arguments[_i];
                }
                return _this._log(LogLevel.Verbose, null, args);
            };
            this.debug = function () {
                var args = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    args[_i] = arguments[_i];
                }
                return _this._log(LogLevel.Debug, null, args);
            };
            this.info = function () {
                var args = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    args[_i] = arguments[_i];
                }
                return _this._log(LogLevel.Info, null, args);
            };
            this.warn = function () {
                var args = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    args[_i] = arguments[_i];
                }
                return _this._log(LogLevel.Warn, null, args);
            };
            this.error = function () {
                var args = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    args[_i] = arguments[_i];
                }
                return _this._log(LogLevel.Error, null, args);
            };
            this.fatal = function () {
                var args = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    args[_i] = arguments[_i];
                }
                return _this._log(LogLevel.Fatal, null, args);
            };
            if (!_instanceId) {
                this._instanceId = "";
            }
            if (!_config) {
                this._config = DefaultLogConfiguratorInstance;
            }
        }
        Log.of = function (pkg, client) {
            var logger = Log.create(pkg);
            logger.client = client;
            return logger;
        };
        Log.create = function (pkg, instanceId, config) {
            return new Log(pkg, instanceId, config);
        };
        Log.getPrefixTimestamp = function (timestamp) {
            return format("{0}-{1}-{2} {3}:{4}:{5}.{6}", [timestamp.getFullYear(), zeroLeftPad(timestamp.getMonth() + 1), zeroLeftPad(timestamp.getDate()), zeroLeftPad(timestamp.getHours()), zeroLeftPad(timestamp.getMinutes()), zeroLeftPad(timestamp.getSeconds()), zeroLeftPad(timestamp.getMilliseconds(), 3)]);
        };
        Object.defineProperty(Log.prototype, "client", {
            set: function (client) {
                if (client) {
                    this.instanceId = client.instanceId;
                    this.config = client.logConfigurator;
                }
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Log.prototype, "config", {
            get: function () {
                return this._config;
            },
            set: function (config) {
                if (config) {
                    this._config = config;
                }
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Log.prototype, "instanceId", {
            get: function () {
                return this._instanceId;
            },
            set: function (instanceId) {
                this._instanceId = instanceId || "";
            },
            enumerable: false,
            configurable: true
        });
        Log.prototype.getDebugMethod = function (level) {
            var packageName = "" + this._config.prefix + (this._config.instanceIdLogged ? "_" + this._instanceId : "") + (this._pkg ? ":" + this._pkg : "");
            switch (level) {
                case LogLevel.Verbose:
                    packageName += ":VERBOSE";
                    break;
                case LogLevel.Debug:
                    packageName += ":DEBUG";
                    break;
                case LogLevel.Info:
                    packageName += ":INFO";
                    break;
                case LogLevel.Warn:
                    packageName += ":WARN";
                    break;
                case LogLevel.Error:
                    packageName += ":ERROR";
                    break;
                case LogLevel.Fatal:
                    packageName += ":FATAL";
                    break;
            }
            var debugMethod = this.debugMethods.get(packageName);
            if (!debugMethod) {
                debugMethod = debug(packageName);
                this.debugMethods.set(packageName, debugMethod);
            }
            return debugMethod;
        };
        Log.prototype._log = function (level, timestamp) {
            var args = [];
            for (var _i = 2; _i < arguments.length; _i++) {
                args[_i - 2] = arguments[_i];
            }
            if (level && level < LogLevel.None && level >= this._config.logLevel) {
                var args0 = [this._config.timestamp ? Log.getPrefixTimestamp(timestamp !== null && timestamp !== void 0 ? timestamp : new Date()) : ""];
                if (args && args.length) {
                    if (typeof args[0] !== "string") {
                        args = [].slice.call(args[0]);
                    }
                    var strArg0 = "" + args[0];
                    if (strArg0.length) {
                        args0.push(strArg0);
                    }
                    args[0] = args0.join("");
                }
                else {
                    args = args0;
                }
                if (this._config.objectToJson) {
                    args[0] += (args[0].length ? " " : "") + "%j";
                }
                this.getDebugMethod(level).apply(debug, args);
            }
        };
        Log.prototype.log = function (level) {
            var args = [];
            for (var _i = 1; _i < arguments.length; _i++) {
                args[_i - 1] = arguments[_i];
            }
            this._log(level, null, args);
        };
        Log.prototype.logWithTimestamp = function (level, timestamp) {
            var args = [];
            for (var _i = 2; _i < arguments.length; _i++) {
                args[_i - 2] = arguments[_i];
            }
            this._log(level, timestamp, args);
        };
        return Log;
    }());
    var zeroLeftPad = function (value, len) {
        if (len === void 0) { len = 2; }
        var val = value.toString();
        try {
            return val.padStart(len, "0");
        }
        catch (e) {
            return val.length < len ? "0" + val : val;
        }
    };
    var format = function (format, args) {
        return format.replace(/{(\d+)}/g, function (match, number) {
            if (args[number] != null) {
                return args[number];
            }
            return match;
        });
    };

    function catchError(selector) {
        return function catchErrorOperatorFunction(source) {
            var operator = new CatchOperator(selector);
            var caught = source.lift(operator);
            return (operator.caught = caught);
        };
    }
    var CatchOperator =  (function () {
        function CatchOperator(selector) {
            this.selector = selector;
        }
        CatchOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
        };
        return CatchOperator;
    }());
    var CatchSubscriber =  (function (_super) {
        __extends$d(CatchSubscriber, _super);
        function CatchSubscriber(destination, selector, caught) {
            var _this = _super.call(this, destination) || this;
            _this.selector = selector;
            _this.caught = caught;
            return _this;
        }
        CatchSubscriber.prototype.error = function (err) {
            if (!this.isStopped) {
                var result = void 0;
                try {
                    result = this.selector(err, this.caught);
                }
                catch (err2) {
                    _super.prototype.error.call(this, err2);
                    return;
                }
                this._unsubscribeAndRecycle();
                var innerSubscriber = new SimpleInnerSubscriber(this);
                this.add(innerSubscriber);
                var innerSubscription = innerSubscribe(result, innerSubscriber);
                if (innerSubscription !== innerSubscriber) {
                    this.add(innerSubscription);
                }
            }
        };
        return CatchSubscriber;
    }(SimpleOuterSubscriber));

    function concatMap(project, resultSelector) {
        return mergeMap(project, resultSelector, 1);
    }

    function debounceTime(dueTime, scheduler) {
        if (scheduler === void 0) {
            scheduler = async;
        }
        return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
    }
    var DebounceTimeOperator =  (function () {
        function DebounceTimeOperator(dueTime, scheduler) {
            this.dueTime = dueTime;
            this.scheduler = scheduler;
        }
        DebounceTimeOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
        };
        return DebounceTimeOperator;
    }());
    var DebounceTimeSubscriber =  (function (_super) {
        __extends$d(DebounceTimeSubscriber, _super);
        function DebounceTimeSubscriber(destination, dueTime, scheduler) {
            var _this = _super.call(this, destination) || this;
            _this.dueTime = dueTime;
            _this.scheduler = scheduler;
            _this.debouncedSubscription = null;
            _this.lastValue = null;
            _this.hasValue = false;
            return _this;
        }
        DebounceTimeSubscriber.prototype._next = function (value) {
            this.clearDebounce();
            this.lastValue = value;
            this.hasValue = true;
            this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext$1, this.dueTime, this));
        };
        DebounceTimeSubscriber.prototype._complete = function () {
            this.debouncedNext();
            this.destination.complete();
        };
        DebounceTimeSubscriber.prototype.debouncedNext = function () {
            this.clearDebounce();
            if (this.hasValue) {
                var lastValue = this.lastValue;
                this.lastValue = null;
                this.hasValue = false;
                this.destination.next(lastValue);
            }
        };
        DebounceTimeSubscriber.prototype.clearDebounce = function () {
            var debouncedSubscription = this.debouncedSubscription;
            if (debouncedSubscription !== null) {
                this.remove(debouncedSubscription);
                debouncedSubscription.unsubscribe();
                this.debouncedSubscription = null;
            }
        };
        return DebounceTimeSubscriber;
    }(Subscriber));
    function dispatchNext$1(subscriber) {
        subscriber.debouncedNext();
    }

    function defaultIfEmpty(defaultValue) {
        if (defaultValue === void 0) {
            defaultValue = null;
        }
        return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
    }
    var DefaultIfEmptyOperator =  (function () {
        function DefaultIfEmptyOperator(defaultValue) {
            this.defaultValue = defaultValue;
        }
        DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
        };
        return DefaultIfEmptyOperator;
    }());
    var DefaultIfEmptySubscriber =  (function (_super) {
        __extends$d(DefaultIfEmptySubscriber, _super);
        function DefaultIfEmptySubscriber(destination, defaultValue) {
            var _this = _super.call(this, destination) || this;
            _this.defaultValue = defaultValue;
            _this.isEmpty = true;
            return _this;
        }
        DefaultIfEmptySubscriber.prototype._next = function (value) {
            this.isEmpty = false;
            this.destination.next(value);
        };
        DefaultIfEmptySubscriber.prototype._complete = function () {
            if (this.isEmpty) {
                this.destination.next(this.defaultValue);
            }
            this.destination.complete();
        };
        return DefaultIfEmptySubscriber;
    }(Subscriber));

    function isDate(value) {
        return value instanceof Date && !isNaN(+value);
    }

    function delay(delay, scheduler) {
        if (scheduler === void 0) {
            scheduler = async;
        }
        var absoluteDelay = isDate(delay);
        var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
        return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
    }
    var DelayOperator =  (function () {
        function DelayOperator(delay, scheduler) {
            this.delay = delay;
            this.scheduler = scheduler;
        }
        DelayOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
        };
        return DelayOperator;
    }());
    var DelaySubscriber =  (function (_super) {
        __extends$d(DelaySubscriber, _super);
        function DelaySubscriber(destination, delay, scheduler) {
            var _this = _super.call(this, destination) || this;
            _this.delay = delay;
            _this.scheduler = scheduler;
            _this.queue = [];
            _this.active = false;
            _this.errored = false;
            return _this;
        }
        DelaySubscriber.dispatch = function (state) {
            var source = state.source;
            var queue = source.queue;
            var scheduler = state.scheduler;
            var destination = state.destination;
            while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
                queue.shift().notification.observe(destination);
            }
            if (queue.length > 0) {
                var delay_1 = Math.max(0, queue[0].time - scheduler.now());
                this.schedule(state, delay_1);
            }
            else {
                this.unsubscribe();
                source.active = false;
            }
        };
        DelaySubscriber.prototype._schedule = function (scheduler) {
            this.active = true;
            var destination = this.destination;
            destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
                source: this, destination: this.destination, scheduler: scheduler
            }));
        };
        DelaySubscriber.prototype.scheduleNotification = function (notification) {
            if (this.errored === true) {
                return;
            }
            var scheduler = this.scheduler;
            var message = new DelayMessage(scheduler.now() + this.delay, notification);
            this.queue.push(message);
            if (this.active === false) {
                this._schedule(scheduler);
            }
        };
        DelaySubscriber.prototype._next = function (value) {
            this.scheduleNotification(Notification.createNext(value));
        };
        DelaySubscriber.prototype._error = function (err) {
            this.errored = true;
            this.queue = [];
            this.destination.error(err);
            this.unsubscribe();
        };
        DelaySubscriber.prototype._complete = function () {
            this.scheduleNotification(Notification.createComplete());
            this.unsubscribe();
        };
        return DelaySubscriber;
    }(Subscriber));
    var DelayMessage =  (function () {
        function DelayMessage(time, notification) {
            this.time = time;
            this.notification = notification;
        }
        return DelayMessage;
    }());

    function distinctUntilChanged(compare, keySelector) {
        return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
    }
    var DistinctUntilChangedOperator =  (function () {
        function DistinctUntilChangedOperator(compare, keySelector) {
            this.compare = compare;
            this.keySelector = keySelector;
        }
        DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
        };
        return DistinctUntilChangedOperator;
    }());
    var DistinctUntilChangedSubscriber =  (function (_super) {
        __extends$d(DistinctUntilChangedSubscriber, _super);
        function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
            var _this = _super.call(this, destination) || this;
            _this.keySelector = keySelector;
            _this.hasKey = false;
            if (typeof compare === 'function') {
                _this.compare = compare;
            }
            return _this;
        }
        DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
            return x === y;
        };
        DistinctUntilChangedSubscriber.prototype._next = function (value) {
            var key;
            try {
                var keySelector = this.keySelector;
                key = keySelector ? keySelector(value) : value;
            }
            catch (err) {
                return this.destination.error(err);
            }
            var result = false;
            if (this.hasKey) {
                try {
                    var compare = this.compare;
                    result = compare(this.key, key);
                }
                catch (err) {
                    return this.destination.error(err);
                }
            }
            else {
                this.hasKey = true;
            }
            if (!result) {
                this.key = key;
                this.destination.next(value);
            }
        };
        return DistinctUntilChangedSubscriber;
    }(Subscriber));

    function throwIfEmpty(errorFactory) {
        if (errorFactory === void 0) {
            errorFactory = defaultErrorFactory;
        }
        return function (source) {
            return source.lift(new ThrowIfEmptyOperator(errorFactory));
        };
    }
    var ThrowIfEmptyOperator =  (function () {
        function ThrowIfEmptyOperator(errorFactory) {
            this.errorFactory = errorFactory;
        }
        ThrowIfEmptyOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new ThrowIfEmptySubscriber(subscriber, this.errorFactory));
        };
        return ThrowIfEmptyOperator;
    }());
    var ThrowIfEmptySubscriber =  (function (_super) {
        __extends$d(ThrowIfEmptySubscriber, _super);
        function ThrowIfEmptySubscriber(destination, errorFactory) {
            var _this = _super.call(this, destination) || this;
            _this.errorFactory = errorFactory;
            _this.hasValue = false;
            return _this;
        }
        ThrowIfEmptySubscriber.prototype._next = function (value) {
            this.hasValue = true;
            this.destination.next(value);
        };
        ThrowIfEmptySubscriber.prototype._complete = function () {
            if (!this.hasValue) {
                var err = void 0;
                try {
                    err = this.errorFactory();
                }
                catch (e) {
                    err = e;
                }
                this.destination.error(err);
            }
            else {
                return this.destination.complete();
            }
        };
        return ThrowIfEmptySubscriber;
    }(Subscriber));
    function defaultErrorFactory() {
        return new EmptyError();
    }

    function take(count) {
        return function (source) {
            if (count === 0) {
                return empty();
            }
            else {
                return source.lift(new TakeOperator(count));
            }
        };
    }
    var TakeOperator =  (function () {
        function TakeOperator(total) {
            this.total = total;
            if (this.total < 0) {
                throw new ArgumentOutOfRangeError;
            }
        }
        TakeOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new TakeSubscriber(subscriber, this.total));
        };
        return TakeOperator;
    }());
    var TakeSubscriber =  (function (_super) {
        __extends$d(TakeSubscriber, _super);
        function TakeSubscriber(destination, total) {
            var _this = _super.call(this, destination) || this;
            _this.total = total;
            _this.count = 0;
            return _this;
        }
        TakeSubscriber.prototype._next = function (value) {
            var total = this.total;
            var count = ++this.count;
            if (count <= total) {
                this.destination.next(value);
                if (count === total) {
                    this.destination.complete();
                    this.unsubscribe();
                }
            }
        };
        return TakeSubscriber;
    }(Subscriber));

    function finalize(callback) {
        return function (source) { return source.lift(new FinallyOperator(callback)); };
    }
    var FinallyOperator =  (function () {
        function FinallyOperator(callback) {
            this.callback = callback;
        }
        FinallyOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new FinallySubscriber(subscriber, this.callback));
        };
        return FinallyOperator;
    }());
    var FinallySubscriber =  (function (_super) {
        __extends$d(FinallySubscriber, _super);
        function FinallySubscriber(destination, callback) {
            var _this = _super.call(this, destination) || this;
            _this.add(new Subscription(callback));
            return _this;
        }
        return FinallySubscriber;
    }(Subscriber));

    function first(predicate, defaultValue) {
        var hasDefaultValue = arguments.length >= 2;
        return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity$1, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
    }

    function takeLast(count) {
        return function takeLastOperatorFunction(source) {
            if (count === 0) {
                return empty();
            }
            else {
                return source.lift(new TakeLastOperator(count));
            }
        };
    }
    var TakeLastOperator =  (function () {
        function TakeLastOperator(total) {
            this.total = total;
            if (this.total < 0) {
                throw new ArgumentOutOfRangeError;
            }
        }
        TakeLastOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
        };
        return TakeLastOperator;
    }());
    var TakeLastSubscriber =  (function (_super) {
        __extends$d(TakeLastSubscriber, _super);
        function TakeLastSubscriber(destination, total) {
            var _this = _super.call(this, destination) || this;
            _this.total = total;
            _this.ring = new Array();
            _this.count = 0;
            return _this;
        }
        TakeLastSubscriber.prototype._next = function (value) {
            var ring = this.ring;
            var total = this.total;
            var count = this.count++;
            if (ring.length < total) {
                ring.push(value);
            }
            else {
                var index = count % total;
                ring[index] = value;
            }
        };
        TakeLastSubscriber.prototype._complete = function () {
            var destination = this.destination;
            var count = this.count;
            if (count > 0) {
                var total = this.count >= this.total ? this.total : this.count;
                var ring = this.ring;
                for (var i = 0; i < total; i++) {
                    var idx = (count++) % total;
                    destination.next(ring[idx]);
                }
            }
            destination.complete();
        };
        return TakeLastSubscriber;
    }(Subscriber));

    function last(predicate, defaultValue) {
        var hasDefaultValue = arguments.length >= 2;
        return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity$1, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
    }

    function multicast(subjectOrSubjectFactory, selector) {
        return function multicastOperatorFunction(source) {
            var subjectFactory;
            if (typeof subjectOrSubjectFactory === 'function') {
                subjectFactory = subjectOrSubjectFactory;
            }
            else {
                subjectFactory = function subjectFactory() {
                    return subjectOrSubjectFactory;
                };
            }
            if (typeof selector === 'function') {
                return source.lift(new MulticastOperator(subjectFactory, selector));
            }
            var connectable = Object.create(source, connectableObservableDescriptor);
            connectable.source = source;
            connectable.subjectFactory = subjectFactory;
            return connectable;
        };
    }
    var MulticastOperator =  (function () {
        function MulticastOperator(subjectFactory, selector) {
            this.subjectFactory = subjectFactory;
            this.selector = selector;
        }
        MulticastOperator.prototype.call = function (subscriber, source) {
            var selector = this.selector;
            var subject = this.subjectFactory();
            var subscription = selector(subject).subscribe(subscriber);
            subscription.add(source.subscribe(subject));
            return subscription;
        };
        return MulticastOperator;
    }());

    function shareSubjectFactory() {
        return new Subject();
    }
    function share() {
        return function (source) { return refCount()(multicast(shareSubjectFactory)(source)); };
    }

    function shareReplay(configOrBufferSize, windowTime, scheduler) {
        var config;
        if (configOrBufferSize && typeof configOrBufferSize === 'object') {
            config = configOrBufferSize;
        }
        else {
            config = {
                bufferSize: configOrBufferSize,
                windowTime: windowTime,
                refCount: false,
                scheduler: scheduler,
            };
        }
        return function (source) { return source.lift(shareReplayOperator(config)); };
    }
    function shareReplayOperator(_a) {
        var _b = _a.bufferSize, bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, _c = _a.windowTime, windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, useRefCount = _a.refCount, scheduler = _a.scheduler;
        var subject;
        var refCount = 0;
        var subscription;
        var hasError = false;
        var isComplete = false;
        return function shareReplayOperation(source) {
            refCount++;
            var innerSub;
            if (!subject || hasError) {
                hasError = false;
                subject = new ReplaySubject(bufferSize, windowTime, scheduler);
                innerSub = subject.subscribe(this);
                subscription = source.subscribe({
                    next: function (value) {
                        subject.next(value);
                    },
                    error: function (err) {
                        hasError = true;
                        subject.error(err);
                    },
                    complete: function () {
                        isComplete = true;
                        subscription = undefined;
                        subject.complete();
                    },
                });
                if (isComplete) {
                    subscription = undefined;
                }
            }
            else {
                innerSub = subject.subscribe(this);
            }
            this.add(function () {
                refCount--;
                innerSub.unsubscribe();
                innerSub = undefined;
                if (subscription && !isComplete && useRefCount && refCount === 0) {
                    subscription.unsubscribe();
                    subscription = undefined;
                    subject = undefined;
                }
            });
        };
    }

    function skip(count) {
        return function (source) { return source.lift(new SkipOperator(count)); };
    }
    var SkipOperator =  (function () {
        function SkipOperator(total) {
            this.total = total;
        }
        SkipOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new SkipSubscriber(subscriber, this.total));
        };
        return SkipOperator;
    }());
    var SkipSubscriber =  (function (_super) {
        __extends$d(SkipSubscriber, _super);
        function SkipSubscriber(destination, total) {
            var _this = _super.call(this, destination) || this;
            _this.total = total;
            _this.count = 0;
            return _this;
        }
        SkipSubscriber.prototype._next = function (x) {
            if (++this.count > this.total) {
                this.destination.next(x);
            }
        };
        return SkipSubscriber;
    }(Subscriber));

    function switchMap(project, resultSelector) {
        if (typeof resultSelector === 'function') {
            return function (source) { return source.pipe(switchMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
        }
        return function (source) { return source.lift(new SwitchMapOperator(project)); };
    }
    var SwitchMapOperator =  (function () {
        function SwitchMapOperator(project) {
            this.project = project;
        }
        SwitchMapOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
        };
        return SwitchMapOperator;
    }());
    var SwitchMapSubscriber =  (function (_super) {
        __extends$d(SwitchMapSubscriber, _super);
        function SwitchMapSubscriber(destination, project) {
            var _this = _super.call(this, destination) || this;
            _this.project = project;
            _this.index = 0;
            return _this;
        }
        SwitchMapSubscriber.prototype._next = function (value) {
            var result;
            var index = this.index++;
            try {
                result = this.project(value, index);
            }
            catch (error) {
                this.destination.error(error);
                return;
            }
            this._innerSub(result);
        };
        SwitchMapSubscriber.prototype._innerSub = function (result) {
            var innerSubscription = this.innerSubscription;
            if (innerSubscription) {
                innerSubscription.unsubscribe();
            }
            var innerSubscriber = new SimpleInnerSubscriber(this);
            var destination = this.destination;
            destination.add(innerSubscriber);
            this.innerSubscription = innerSubscribe(result, innerSubscriber);
            if (this.innerSubscription !== innerSubscriber) {
                destination.add(this.innerSubscription);
            }
        };
        SwitchMapSubscriber.prototype._complete = function () {
            var innerSubscription = this.innerSubscription;
            if (!innerSubscription || innerSubscription.closed) {
                _super.prototype._complete.call(this);
            }
            this.unsubscribe();
        };
        SwitchMapSubscriber.prototype._unsubscribe = function () {
            this.innerSubscription = undefined;
        };
        SwitchMapSubscriber.prototype.notifyComplete = function () {
            this.innerSubscription = undefined;
            if (this.isStopped) {
                _super.prototype._complete.call(this);
            }
        };
        SwitchMapSubscriber.prototype.notifyNext = function (innerValue) {
            this.destination.next(innerValue);
        };
        return SwitchMapSubscriber;
    }(SimpleOuterSubscriber));

    function tap(nextOrObserver, error, complete) {
        return function tapOperatorFunction(source) {
            return source.lift(new DoOperator(nextOrObserver, error, complete));
        };
    }
    var DoOperator =  (function () {
        function DoOperator(nextOrObserver, error, complete) {
            this.nextOrObserver = nextOrObserver;
            this.error = error;
            this.complete = complete;
        }
        DoOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
        };
        return DoOperator;
    }());
    var TapSubscriber =  (function (_super) {
        __extends$d(TapSubscriber, _super);
        function TapSubscriber(destination, observerOrNext, error, complete) {
            var _this = _super.call(this, destination) || this;
            _this._tapNext = noop$1;
            _this._tapError = noop$1;
            _this._tapComplete = noop$1;
            _this._tapError = error || noop$1;
            _this._tapComplete = complete || noop$1;
            if (isFunction$1(observerOrNext)) {
                _this._context = _this;
                _this._tapNext = observerOrNext;
            }
            else if (observerOrNext) {
                _this._context = observerOrNext;
                _this._tapNext = observerOrNext.next || noop$1;
                _this._tapError = observerOrNext.error || noop$1;
                _this._tapComplete = observerOrNext.complete || noop$1;
            }
            return _this;
        }
        TapSubscriber.prototype._next = function (value) {
            try {
                this._tapNext.call(this._context, value);
            }
            catch (err) {
                this.destination.error(err);
                return;
            }
            this.destination.next(value);
        };
        TapSubscriber.prototype._error = function (err) {
            try {
                this._tapError.call(this._context, err);
            }
            catch (err) {
                this.destination.error(err);
                return;
            }
            this.destination.error(err);
        };
        TapSubscriber.prototype._complete = function () {
            try {
                this._tapComplete.call(this._context);
            }
            catch (err) {
                this.destination.error(err);
                return;
            }
            return this.destination.complete();
        };
        return TapSubscriber;
    }(Subscriber));

    var defaultThrottleConfig = {
        leading: true,
        trailing: false
    };
    function throttle(durationSelector, config) {
        if (config === void 0) {
            config = defaultThrottleConfig;
        }
        return function (source) { return source.lift(new ThrottleOperator(durationSelector, !!config.leading, !!config.trailing)); };
    }
    var ThrottleOperator =  (function () {
        function ThrottleOperator(durationSelector, leading, trailing) {
            this.durationSelector = durationSelector;
            this.leading = leading;
            this.trailing = trailing;
        }
        ThrottleOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
        };
        return ThrottleOperator;
    }());
    var ThrottleSubscriber =  (function (_super) {
        __extends$d(ThrottleSubscriber, _super);
        function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
            var _this = _super.call(this, destination) || this;
            _this.destination = destination;
            _this.durationSelector = durationSelector;
            _this._leading = _leading;
            _this._trailing = _trailing;
            _this._hasValue = false;
            return _this;
        }
        ThrottleSubscriber.prototype._next = function (value) {
            this._hasValue = true;
            this._sendValue = value;
            if (!this._throttled) {
                if (this._leading) {
                    this.send();
                }
                else {
                    this.throttle(value);
                }
            }
        };
        ThrottleSubscriber.prototype.send = function () {
            var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
            if (_hasValue) {
                this.destination.next(_sendValue);
                this.throttle(_sendValue);
            }
            this._hasValue = false;
            this._sendValue = undefined;
        };
        ThrottleSubscriber.prototype.throttle = function (value) {
            var duration = this.tryDurationSelector(value);
            if (!!duration) {
                this.add(this._throttled = innerSubscribe(duration, new SimpleInnerSubscriber(this)));
            }
        };
        ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
            try {
                return this.durationSelector(value);
            }
            catch (err) {
                this.destination.error(err);
                return null;
            }
        };
        ThrottleSubscriber.prototype.throttlingDone = function () {
            var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
            if (_throttled) {
                _throttled.unsubscribe();
            }
            this._throttled = undefined;
            if (_trailing) {
                this.send();
            }
        };
        ThrottleSubscriber.prototype.notifyNext = function () {
            this.throttlingDone();
        };
        ThrottleSubscriber.prototype.notifyComplete = function () {
            this.throttlingDone();
        };
        return ThrottleSubscriber;
    }(SimpleOuterSubscriber));

    function throttleTime(duration, scheduler, config) {
        if (scheduler === void 0) {
            scheduler = async;
        }
        if (config === void 0) {
            config = defaultThrottleConfig;
        }
        return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
    }
    var ThrottleTimeOperator =  (function () {
        function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
            this.duration = duration;
            this.scheduler = scheduler;
            this.leading = leading;
            this.trailing = trailing;
        }
        ThrottleTimeOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
        };
        return ThrottleTimeOperator;
    }());
    var ThrottleTimeSubscriber =  (function (_super) {
        __extends$d(ThrottleTimeSubscriber, _super);
        function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
            var _this = _super.call(this, destination) || this;
            _this.duration = duration;
            _this.scheduler = scheduler;
            _this.leading = leading;
            _this.trailing = trailing;
            _this._hasTrailingValue = false;
            _this._trailingValue = null;
            return _this;
        }
        ThrottleTimeSubscriber.prototype._next = function (value) {
            if (this.throttled) {
                if (this.trailing) {
                    this._trailingValue = value;
                    this._hasTrailingValue = true;
                }
            }
            else {
                this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, { subscriber: this }));
                if (this.leading) {
                    this.destination.next(value);
                }
                else if (this.trailing) {
                    this._trailingValue = value;
                    this._hasTrailingValue = true;
                }
            }
        };
        ThrottleTimeSubscriber.prototype._complete = function () {
            if (this._hasTrailingValue) {
                this.destination.next(this._trailingValue);
                this.destination.complete();
            }
            else {
                this.destination.complete();
            }
        };
        ThrottleTimeSubscriber.prototype.clearThrottle = function () {
            var throttled = this.throttled;
            if (throttled) {
                if (this.trailing && this._hasTrailingValue) {
                    this.destination.next(this._trailingValue);
                    this._trailingValue = null;
                    this._hasTrailingValue = false;
                }
                throttled.unsubscribe();
                this.remove(throttled);
                this.throttled = null;
            }
        };
        return ThrottleTimeSubscriber;
    }(Subscriber));
    function dispatchNext(arg) {
        var subscriber = arg.subscriber;
        subscriber.clearThrottle();
    }

    function timeoutWith(due, withObservable, scheduler) {
        if (scheduler === void 0) {
            scheduler = async;
        }
        return function (source) {
            var absoluteTimeout = isDate(due);
            var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
            return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
        };
    }
    var TimeoutWithOperator =  (function () {
        function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
            this.waitFor = waitFor;
            this.absoluteTimeout = absoluteTimeout;
            this.withObservable = withObservable;
            this.scheduler = scheduler;
        }
        TimeoutWithOperator.prototype.call = function (subscriber, source) {
            return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
        };
        return TimeoutWithOperator;
    }());
    var TimeoutWithSubscriber =  (function (_super) {
        __extends$d(TimeoutWithSubscriber, _super);
        function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
            var _this = _super.call(this, destination) || this;
            _this.absoluteTimeout = absoluteTimeout;
            _this.waitFor = waitFor;
            _this.withObservable = withObservable;
            _this.scheduler = scheduler;
            _this.scheduleTimeout();
            return _this;
        }
        TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
            var withObservable = subscriber.withObservable;
            subscriber._unsubscribeAndRecycle();
            subscriber.add(innerSubscribe(withObservable, new SimpleInnerSubscriber(subscriber)));
        };
        TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
            var action = this.action;
            if (action) {
                this.action = action.schedule(this, this.waitFor);
            }
            else {
                this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
            }
        };
        TimeoutWithSubscriber.prototype._next = function (value) {
            if (!this.absoluteTimeout) {
                this.scheduleTimeout();
            }
            _super.prototype._next.call(this, value);
        };
        TimeoutWithSubscriber.prototype._unsubscribe = function () {
            this.action = undefined;
            this.scheduler = null;
            this.withObservable = null;
        };
        return TimeoutWithSubscriber;
    }(SimpleOuterSubscriber));

    function timeout(due, scheduler) {
        if (scheduler === void 0) {
            scheduler = async;
        }
        return timeoutWith(due, throwError(new TimeoutError()), scheduler);
    }

    var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
    var freeGlobal$1 = freeGlobal;

    var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
    var root = freeGlobal$1 || freeSelf || Function('return this')();
    var root$1 = root;

    var Symbol$1 = root$1.Symbol;
    var Symbol$2 = Symbol$1;

    var objectProto$5 = Object.prototype;
    var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
    var nativeObjectToString$1 = objectProto$5.toString;
    var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
    function getRawTag(value) {
      var isOwn = hasOwnProperty$4.call(value, symToStringTag$1),
          tag = value[symToStringTag$1];
      try {
        value[symToStringTag$1] = undefined;
        var unmasked = true;
      } catch (e) {}
      var result = nativeObjectToString$1.call(value);
      if (unmasked) {
        if (isOwn) {
          value[symToStringTag$1] = tag;
        } else {
          delete value[symToStringTag$1];
        }
      }
      return result;
    }

    var objectProto$4 = Object.prototype;
    var nativeObjectToString = objectProto$4.toString;
    function objectToString(value) {
      return nativeObjectToString.call(value);
    }

    var nullTag = '[object Null]',
        undefinedTag = '[object Undefined]';
    var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : undefined;
    function baseGetTag(value) {
      if (value == null) {
        return value === undefined ? undefinedTag : nullTag;
      }
      return (symToStringTag && symToStringTag in Object(value))
        ? getRawTag(value)
        : objectToString(value);
    }

    function isObjectLike(value) {
      return value != null && typeof value == 'object';
    }

    var symbolTag = '[object Symbol]';
    function isSymbol(value) {
      return typeof value == 'symbol' ||
        (isObjectLike(value) && baseGetTag(value) == symbolTag);
    }

    var isArray = Array.isArray;
    var isArray$1 = isArray;

    var reWhitespace = /\s/;
    function trimmedEndIndex(string) {
      var index = string.length;
      while (index-- && reWhitespace.test(string.charAt(index))) {}
      return index;
    }

    var reTrimStart = /^\s+/;
    function baseTrim(string) {
      return string
        ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
        : string;
    }

    function isObject(value) {
      var type = typeof value;
      return value != null && (type == 'object' || type == 'function');
    }

    var NAN = 0 / 0;
    var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
    var reIsBinary = /^0b[01]+$/i;
    var reIsOctal = /^0o[0-7]+$/i;
    var freeParseInt = parseInt;
    function toNumber(value) {
      if (typeof value == 'number') {
        return value;
      }
      if (isSymbol(value)) {
        return NAN;
      }
      if (isObject(value)) {
        var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
        value = isObject(other) ? (other + '') : other;
      }
      if (typeof value != 'string') {
        return value === 0 ? value : +value;
      }
      value = baseTrim(value);
      var isBinary = reIsBinary.test(value);
      return (isBinary || reIsOctal.test(value))
        ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
        : (reIsBadHex.test(value) ? NAN : +value);
    }

    function identity(value) {
      return value;
    }

    var asyncTag = '[object AsyncFunction]',
        funcTag = '[object Function]',
        genTag = '[object GeneratorFunction]',
        proxyTag = '[object Proxy]';
    function isFunction(value) {
      if (!isObject(value)) {
        return false;
      }
      var tag = baseGetTag(value);
      return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
    }

    var coreJsData = root$1['__core-js_shared__'];
    var coreJsData$1 = coreJsData;

    var maskSrcKey = (function() {
      var uid = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || '');
      return uid ? ('Symbol(src)_1.' + uid) : '';
    }());
    function isMasked(func) {
      return !!maskSrcKey && (maskSrcKey in func);
    }

    var funcProto$1 = Function.prototype;
    var funcToString$1 = funcProto$1.toString;
    function toSource(func) {
      if (func != null) {
        try {
          return funcToString$1.call(func);
        } catch (e) {}
        try {
          return (func + '');
        } catch (e) {}
      }
      return '';
    }

    var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
    var reIsHostCtor = /^\[object .+?Constructor\]$/;
    var funcProto = Function.prototype,
        objectProto$3 = Object.prototype;
    var funcToString = funcProto.toString;
    var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
    var reIsNative = RegExp('^' +
      funcToString.call(hasOwnProperty$3).replace(reRegExpChar, '\\$&')
      .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
    );
    function baseIsNative(value) {
      if (!isObject(value) || isMasked(value)) {
        return false;
      }
      var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
      return pattern.test(toSource(value));
    }

    function getValue(object, key) {
      return object == null ? undefined : object[key];
    }

    function getNative(object, key) {
      var value = getValue(object, key);
      return baseIsNative(value) ? value : undefined;
    }

    function apply(func, thisArg, args) {
      switch (args.length) {
        case 0: return func.call(thisArg);
        case 1: return func.call(thisArg, args[0]);
        case 2: return func.call(thisArg, args[0], args[1]);
        case 3: return func.call(thisArg, args[0], args[1], args[2]);
      }
      return func.apply(thisArg, args);
    }

    function noop() {
    }

    var HOT_COUNT = 800,
        HOT_SPAN = 16;
    var nativeNow = Date.now;
    function shortOut(func) {
      var count = 0,
          lastCalled = 0;
      return function() {
        var stamp = nativeNow(),
            remaining = HOT_SPAN - (stamp - lastCalled);
        lastCalled = stamp;
        if (remaining > 0) {
          if (++count >= HOT_COUNT) {
            return arguments[0];
          }
        } else {
          count = 0;
        }
        return func.apply(undefined, arguments);
      };
    }

    function constant(value) {
      return function() {
        return value;
      };
    }

    var defineProperty = (function() {
      try {
        var func = getNative(Object, 'defineProperty');
        func({}, '', {});
        return func;
      } catch (e) {}
    }());
    var defineProperty$1 = defineProperty;

    var baseSetToString = !defineProperty$1 ? identity : function(func, string) {
      return defineProperty$1(func, 'toString', {
        'configurable': true,
        'enumerable': false,
        'value': constant(string),
        'writable': true
      });
    };
    var baseSetToString$1 = baseSetToString;

    var setToString = shortOut(baseSetToString$1);
    var setToString$1 = setToString;

    function baseFindIndex(array, predicate, fromIndex, fromRight) {
      var length = array.length,
          index = fromIndex + (fromRight ? 1 : -1);
      while ((fromRight ? index-- : ++index < length)) {
        if (predicate(array[index], index, array)) {
          return index;
        }
      }
      return -1;
    }

    function baseIsNaN(value) {
      return value !== value;
    }

    function strictIndexOf(array, value, fromIndex) {
      var index = fromIndex - 1,
          length = array.length;
      while (++index < length) {
        if (array[index] === value) {
          return index;
        }
      }
      return -1;
    }

    function baseIndexOf(array, value, fromIndex) {
      return value === value
        ? strictIndexOf(array, value, fromIndex)
        : baseFindIndex(array, baseIsNaN, fromIndex);
    }

    function arrayIncludes(array, value) {
      var length = array == null ? 0 : array.length;
      return !!length && baseIndexOf(array, value, 0) > -1;
    }

    function eq(value, other) {
      return value === other || (value !== value && other !== other);
    }

    var nativeMax$1 = Math.max;
    function overRest(func, start, transform) {
      start = nativeMax$1(start === undefined ? (func.length - 1) : start, 0);
      return function() {
        var args = arguments,
            index = -1,
            length = nativeMax$1(args.length - start, 0),
            array = Array(length);
        while (++index < length) {
          array[index] = args[start + index];
        }
        index = -1;
        var otherArgs = Array(start + 1);
        while (++index < start) {
          otherArgs[index] = args[index];
        }
        otherArgs[start] = transform(array);
        return apply(func, this, otherArgs);
      };
    }

    function baseRest(func, start) {
      return setToString$1(overRest(func, start, identity), func + '');
    }

    var MAX_SAFE_INTEGER = 9007199254740991;
    function isLength(value) {
      return typeof value == 'number' &&
        value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
    }

    function isArrayLike(value) {
      return value != null && isLength(value.length) && !isFunction(value);
    }

    var argsTag = '[object Arguments]';
    function baseIsArguments(value) {
      return isObjectLike(value) && baseGetTag(value) == argsTag;
    }

    var objectProto$2 = Object.prototype;
    var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
    var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
    var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
      return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&
        !propertyIsEnumerable.call(value, 'callee');
    };
    var isArguments$1 = isArguments;

    var nativeCreate = getNative(Object, 'create');
    var nativeCreate$1 = nativeCreate;

    function hashClear() {
      this.__data__ = nativeCreate$1 ? nativeCreate$1(null) : {};
      this.size = 0;
    }

    function hashDelete(key) {
      var result = this.has(key) && delete this.__data__[key];
      this.size -= result ? 1 : 0;
      return result;
    }

    var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
    var objectProto$1 = Object.prototype;
    var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
    function hashGet(key) {
      var data = this.__data__;
      if (nativeCreate$1) {
        var result = data[key];
        return result === HASH_UNDEFINED$2 ? undefined : result;
      }
      return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
    }

    var objectProto = Object.prototype;
    var hasOwnProperty = objectProto.hasOwnProperty;
    function hashHas(key) {
      var data = this.__data__;
      return nativeCreate$1 ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
    }

    var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
    function hashSet(key, value) {
      var data = this.__data__;
      this.size += this.has(key) ? 0 : 1;
      data[key] = (nativeCreate$1 && value === undefined) ? HASH_UNDEFINED$1 : value;
      return this;
    }

    function Hash(entries) {
      var index = -1,
          length = entries == null ? 0 : entries.length;
      this.clear();
      while (++index < length) {
        var entry = entries[index];
        this.set(entry[0], entry[1]);
      }
    }
    Hash.prototype.clear = hashClear;
    Hash.prototype['delete'] = hashDelete;
    Hash.prototype.get = hashGet;
    Hash.prototype.has = hashHas;
    Hash.prototype.set = hashSet;

    function listCacheClear() {
      this.__data__ = [];
      this.size = 0;
    }

    function assocIndexOf(array, key) {
      var length = array.length;
      while (length--) {
        if (eq(array[length][0], key)) {
          return length;
        }
      }
      return -1;
    }

    var arrayProto = Array.prototype;
    var splice = arrayProto.splice;
    function listCacheDelete(key) {
      var data = this.__data__,
          index = assocIndexOf(data, key);
      if (index < 0) {
        return false;
      }
      var lastIndex = data.length - 1;
      if (index == lastIndex) {
        data.pop();
      } else {
        splice.call(data, index, 1);
      }
      --this.size;
      return true;
    }

    function listCacheGet(key) {
      var data = this.__data__,
          index = assocIndexOf(data, key);
      return index < 0 ? undefined : data[index][1];
    }

    function listCacheHas(key) {
      return assocIndexOf(this.__data__, key) > -1;
    }

    function listCacheSet(key, value) {
      var data = this.__data__,
          index = assocIndexOf(data, key);
      if (index < 0) {
        ++this.size;
        data.push([key, value]);
      } else {
        data[index][1] = value;
      }
      return this;
    }

    function ListCache(entries) {
      var index = -1,
          length = entries == null ? 0 : entries.length;
      this.clear();
      while (++index < length) {
        var entry = entries[index];
        this.set(entry[0], entry[1]);
      }
    }
    ListCache.prototype.clear = listCacheClear;
    ListCache.prototype['delete'] = listCacheDelete;
    ListCache.prototype.get = listCacheGet;
    ListCache.prototype.has = listCacheHas;
    ListCache.prototype.set = listCacheSet;

    var Map$1 = getNative(root$1, 'Map');
    var Map$2 = Map$1;

    function mapCacheClear() {
      this.size = 0;
      this.__data__ = {
        'hash': new Hash,
        'map': new (Map$2 || ListCache),
        'string': new Hash
      };
    }

    function isKeyable(value) {
      var type = typeof value;
      return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
        ? (value !== '__proto__')
        : (value === null);
    }

    function getMapData(map, key) {
      var data = map.__data__;
      return isKeyable(key)
        ? data[typeof key == 'string' ? 'string' : 'hash']
        : data.map;
    }

    function mapCacheDelete(key) {
      var result = getMapData(this, key)['delete'](key);
      this.size -= result ? 1 : 0;
      return result;
    }

    function mapCacheGet(key) {
      return getMapData(this, key).get(key);
    }

    function mapCacheHas(key) {
      return getMapData(this, key).has(key);
    }

    function mapCacheSet(key, value) {
      var data = getMapData(this, key),
          size = data.size;
      data.set(key, value);
      this.size += data.size == size ? 0 : 1;
      return this;
    }

    function MapCache(entries) {
      var index = -1,
          length = entries == null ? 0 : entries.length;
      this.clear();
      while (++index < length) {
        var entry = entries[index];
        this.set(entry[0], entry[1]);
      }
    }
    MapCache.prototype.clear = mapCacheClear;
    MapCache.prototype['delete'] = mapCacheDelete;
    MapCache.prototype.get = mapCacheGet;
    MapCache.prototype.has = mapCacheHas;
    MapCache.prototype.set = mapCacheSet;

    function arrayPush(array, values) {
      var index = -1,
          length = values.length,
          offset = array.length;
      while (++index < length) {
        array[offset + index] = values[index];
      }
      return array;
    }

    var spreadableSymbol = Symbol$2 ? Symbol$2.isConcatSpreadable : undefined;
    function isFlattenable(value) {
      return isArray$1(value) || isArguments$1(value) ||
        !!(spreadableSymbol && value && value[spreadableSymbol]);
    }

    function baseFlatten(array, depth, predicate, isStrict, result) {
      var index = -1,
          length = array.length;
      predicate || (predicate = isFlattenable);
      result || (result = []);
      while (++index < length) {
        var value = array[index];
        if (depth > 0 && predicate(value)) {
          if (depth > 1) {
            baseFlatten(value, depth - 1, predicate, isStrict, result);
          } else {
            arrayPush(result, value);
          }
        } else if (!isStrict) {
          result[result.length] = value;
        }
      }
      return result;
    }

    var Set$1 = getNative(root$1, 'Set');
    var Set$2 = Set$1;

    var HASH_UNDEFINED = '__lodash_hash_undefined__';
    function setCacheAdd(value) {
      this.__data__.set(value, HASH_UNDEFINED);
      return this;
    }

    function setCacheHas(value) {
      return this.__data__.has(value);
    }

    function SetCache(values) {
      var index = -1,
          length = values == null ? 0 : values.length;
      this.__data__ = new MapCache;
      while (++index < length) {
        this.add(values[index]);
      }
    }
    SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
    SetCache.prototype.has = setCacheHas;

    function cacheHas(cache, key) {
      return cache.has(key);
    }

    function setToArray(set) {
      var index = -1,
          result = Array(set.size);
      set.forEach(function(value) {
        result[++index] = value;
      });
      return result;
    }

    var now = function() {
      return root$1.Date.now();
    };
    var now$1 = now;

    var FUNC_ERROR_TEXT = 'Expected a function';
    var nativeMax = Math.max,
        nativeMin = Math.min;
    function debounce(func, wait, options) {
      var lastArgs,
          lastThis,
          maxWait,
          result,
          timerId,
          lastCallTime,
          lastInvokeTime = 0,
          leading = false,
          maxing = false,
          trailing = true;
      if (typeof func != 'function') {
        throw new TypeError(FUNC_ERROR_TEXT);
      }
      wait = toNumber(wait) || 0;
      if (isObject(options)) {
        leading = !!options.leading;
        maxing = 'maxWait' in options;
        maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
        trailing = 'trailing' in options ? !!options.trailing : trailing;
      }
      function invokeFunc(time) {
        var args = lastArgs,
            thisArg = lastThis;
        lastArgs = lastThis = undefined;
        lastInvokeTime = time;
        result = func.apply(thisArg, args);
        return result;
      }
      function leadingEdge(time) {
        lastInvokeTime = time;
        timerId = setTimeout(timerExpired, wait);
        return leading ? invokeFunc(time) : result;
      }
      function remainingWait(time) {
        var timeSinceLastCall = time - lastCallTime,
            timeSinceLastInvoke = time - lastInvokeTime,
            timeWaiting = wait - timeSinceLastCall;
        return maxing
          ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
          : timeWaiting;
      }
      function shouldInvoke(time) {
        var timeSinceLastCall = time - lastCallTime,
            timeSinceLastInvoke = time - lastInvokeTime;
        return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
          (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
      }
      function timerExpired() {
        var time = now$1();
        if (shouldInvoke(time)) {
          return trailingEdge(time);
        }
        timerId = setTimeout(timerExpired, remainingWait(time));
      }
      function trailingEdge(time) {
        timerId = undefined;
        if (trailing && lastArgs) {
          return invokeFunc(time);
        }
        lastArgs = lastThis = undefined;
        return result;
      }
      function cancel() {
        if (timerId !== undefined) {
          clearTimeout(timerId);
        }
        lastInvokeTime = 0;
        lastArgs = lastCallTime = lastThis = timerId = undefined;
      }
      function flush() {
        return timerId === undefined ? result : trailingEdge(now$1());
      }
      function debounced() {
        var time = now$1(),
            isInvoking = shouldInvoke(time);
        lastArgs = arguments;
        lastThis = this;
        lastCallTime = time;
        if (isInvoking) {
          if (timerId === undefined) {
            return leadingEdge(lastCallTime);
          }
          if (maxing) {
            clearTimeout(timerId);
            timerId = setTimeout(timerExpired, wait);
            return invokeFunc(lastCallTime);
          }
        }
        if (timerId === undefined) {
          timerId = setTimeout(timerExpired, wait);
        }
        return result;
      }
      debounced.cancel = cancel;
      debounced.flush = flush;
      return debounced;
    }

    function isArrayLikeObject(value) {
      return isObjectLike(value) && isArrayLike(value);
    }

    function arrayIncludesWith(array, value, comparator) {
      var index = -1,
          length = array == null ? 0 : array.length;
      while (++index < length) {
        if (comparator(value, array[index])) {
          return true;
        }
      }
      return false;
    }

    var INFINITY = 1 / 0;
    var createSet = !(Set$2 && (1 / setToArray(new Set$2([,-0]))[1]) == INFINITY) ? noop : function(values) {
      return new Set$2(values);
    };
    var createSet$1 = createSet;

    var LARGE_ARRAY_SIZE = 200;
    function baseUniq(array, iteratee, comparator) {
      var index = -1,
          includes = arrayIncludes,
          length = array.length,
          isCommon = true,
          result = [],
          seen = result;
      if (comparator) {
        isCommon = false;
        includes = arrayIncludesWith;
      }
      else if (length >= LARGE_ARRAY_SIZE) {
        var set = iteratee ? null : createSet$1(array);
        if (set) {
          return setToArray(set);
        }
        isCommon = false;
        includes = cacheHas;
        seen = new SetCache;
      }
      else {
        seen = iteratee ? [] : result;
      }
      outer:
      while (++index < length) {
        var value = array[index],
            computed = iteratee ? iteratee(value) : value;
        value = (comparator || value !== 0) ? value : 0;
        if (isCommon && computed === computed) {
          var seenIndex = seen.length;
          while (seenIndex--) {
            if (seen[seenIndex] === computed) {
              continue outer;
            }
          }
          if (iteratee) {
            seen.push(computed);
          }
          result.push(value);
        }
        else if (!includes(seen, computed, comparator)) {
          if (seen !== result) {
            seen.push(computed);
          }
          result.push(value);
        }
      }
      return result;
    }

    var union = baseRest(function(arrays) {
      return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
    });
    var union$1 = union;

    var __extends$a = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var __awaiter$b = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$a = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    ((function (_super) {
        __extends$a(ObservablePromise, _super);
        function ObservablePromise() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        return ObservablePromise;
    })(Observable));
    var DialParams =  (function () {
        function DialParams(params) {
            this.params = {
                fromDeviceType: null,
                fromDevice: null,
                media: {},
                accessCode: null,
                contact: null,
                privateCall: false,
                calldata: null,
                channelId: ChannelType.PhoneCall,
                serviceCode: null,
                note1: null,
                note2: null,
                abandonedCallId: null,
                callbackRequestId: null,
            };
            if (params && isObject(params)) {
                for (var key in this.params) {
                    if (params.hasOwnProperty(key)) {
                        this.params[key] = params[key];
                    }
                }
            }
            if (!this.params.media) {
                this.params.media = {};
            }
        }
        DialParams.prototype.equals = function (builder) {
            if (!builder) {
                return false;
            }
            for (var key in builder.params) {
                if (builder.params[key] !== this.params[key]) {
                    return false;
                }
            }
            return true;
        };
        DialParams.prototype.isForApp = function () {
            var _a;
            return (_a = this.params.fromDevice) === null || _a === void 0 ? void 0 : _a.startsWith("_app_");
        };
        DialParams.prototype.toRequest = function () {
            return [this.params.fromDeviceType, this.params.fromDevice, buildCallMedia(this.params.media), this.params.accessCode, this.params.contact ? this.params.contact.value : null, this.params.privateCall, this.params.calldata, channelTypeToId(this.params.channelId || ChannelType.PhoneCall), null, this.params.serviceCode, this.params.note1, this.params.note2, this.params.abandonedCallId, this.params.contact, this.params.callbackRequestId];
        };
        return DialParams;
    }());
    var Methods =  (function () {
        function Methods(client) {
            this.client = client;
            this.log = Log$1.of("methods", client);
            this.transport = client.transport;
        }
        Methods.prototype.requestPromise = function (method, params, requestTimeout) {
            return this.requestObservable(method, params, requestTimeout).pipe(take(1));
        };
        Methods.prototype.requestObservable = function (method, params, requestTimeout) {
            return this.requestInternal(method, params, requestTimeout, false, false).response.result;
        };
        Methods.prototype.requestChunked = function (method, params, requestTimeout) {
            return this.requestInternal(method, params, requestTimeout, true, false).response.result;
        };
        Methods.prototype.requestPromiseUpdate = function (method, params, requestTimeout) {
            var request = this.requestObservableUpdate(method, params, requestTimeout);
            request.response.result = request.response.result.pipe(take(1));
            request.response.resultSync = request.response.resultSync.pipe(map(function (result) { return result.pipe(take(1)); }));
            return {
                response: request.response,
                toLiveResult: function () {
                    var liveResult = request.toLiveResult();
                    return {
                        result: liveResult.result.toPromise(),
                        notification: liveResult.notification,
                        resultSync: liveResult.resultSync.pipe(map(function (result) { return result.pipe(take(1)).toPromise(); })),
                        stopResult: liveResult.stopResult,
                        stopNotification: liveResult.stopNotification,
                    };
                },
            };
        };
        Methods.prototype.requestObservableUpdate = function (method, params, requestTimeout) {
            return this.requestInternal(method, params, requestTimeout, false, true);
        };
        Methods.prototype.requestChunkedUpdate = function (method, params, requestTimeout) {
            return this.requestInternal(method, params, requestTimeout, true, true);
        };
        Methods.prototype.requestInternal = function (method, params, requestTimeout, responseIsChunked, activateNotification) {
            try {
                this.loadTransport();
            }
            catch (error) {
                return this.transport.emitError(error, activateNotification);
            }
            this.log.info("Call method: " + method, params);
            return this.transport.request(method, params, requestTimeout, responseIsChunked, activateNotification);
        };
        Methods.prototype.loadTransport = function () {
            if (!this.transport.loading && !this.transport.connected && (!this.transport.getCrossStorage() || this.transport.getCrossStorage().getLevel() == Storagelevel.master)) {
                this.transport.load();
            }
        };
        Methods.prototype.restartSessionId = function (requestTimeout) {
            return this.requestPromise("restartSessionId", [], requestTimeout);
        };
        return Methods;
    }());
    var NotificationManager =  (function () {
        function NotificationManager(client, notificationId, request, result, modifyNotification) {
            this.client = client;
            this.request = request;
            this.result = result;
            this.modifyNotification = modifyNotification;
            this.log = Log$1.of("NotificationManager:" + notificationId, client);
        }
        NotificationManager.prototype.start = function () {
            return __awaiter$b(this, void 0, void 0, function () {
                var stopResult, result_1, notify;
                var _this = this;
                return __generator$a(this, function (_a) {
                    switch (_a.label) {
                        case 0: return [4 , this.stop()];
                        case 1:
                            stopResult = _a.sent();
                            if (stopResult) {
                                result_1 = this.request();
                                this.stopNotification = result_1.toLiveResult().stopNotification;
                                notify = new Promise(function (resolve, reject) {
                                    result_1.response.resultSync.pipe(concatMap(function (response) { return response; })).subscribe(resolve, reject);
                                });
                                result_1.response.notification
                                    .pipe(map(function (data) { return _this.modifyNotification(data); }), catchError(function (e) {
                                    _this.log.warn("Error on modifyNotification", e);
                                    return of(null);
                                }))
                                    .subscribe(function (data) {
                                    if (data) {
                                        try {
                                            _this.result.next(data);
                                        }
                                        catch (e) {
                                            _this.log.error("Error on handle notification", e);
                                        }
                                    }
                                });
                                return [2 , notify];
                            }
                            else {
                                return [2 , stopResult];
                            }
                    }
                });
            });
        };
        NotificationManager.prototype.stop = function () {
            return __awaiter$b(this, void 0, void 0, function () {
                var result;
                return __generator$a(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.stopNotification) return [3 , 2];
                            return [4 , this.stopNotification()];
                        case 1:
                            result = _a.sent();
                            if (result) {
                                this.stopNotification = null;
                            }
                            return [2 , result];
                        case 2: return [2 , true];
                    }
                });
            });
        };
        return NotificationManager;
    }());

    var __extends$9 = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var ExtenUsedBy =  (function (_super) {
        __extends$9(ExtenUsedBy, _super);
        function ExtenUsedBy(data) {
            var _this = _super.call(this, data) || this;
            _this.exten = data.exten;
            _this.extenType = data.extenType;
            _this.usedBy = data.usedBy;
            _this.nameUsedBy = data.nameUsedBy;
            return _this;
        }
        return ExtenUsedBy;
    }(WebAPI));
    var InternalErrorWebAPI =  (function (_super) {
        __extends$9(InternalErrorWebAPI, _super);
        function InternalErrorWebAPI(data) {
            return _super.call(this, data) || this;
        }
        return InternalErrorWebAPI;
    }(WebAPI));
    var FeatureNotSupported =  (function (_super) {
        __extends$9(FeatureNotSupported, _super);
        function FeatureNotSupported(data) {
            return _super.call(this, data) || this;
        }
        return FeatureNotSupported;
    }(WebAPI));
    var FeatureNotAllowed =  (function (_super) {
        __extends$9(FeatureNotAllowed, _super);
        function FeatureNotAllowed(data) {
            return _super.call(this, data) || this;
        }
        return FeatureNotAllowed;
    }(WebAPI));
    var InvalidDateRange =  (function (_super) {
        __extends$9(InvalidDateRange, _super);
        function InvalidDateRange(data) {
            return _super.call(this, data) || this;
        }
        return InvalidDateRange;
    }(WebAPI));
    var MobileAccessNotSupported =  (function (_super) {
        __extends$9(MobileAccessNotSupported, _super);
        function MobileAccessNotSupported(data) {
            return _super.call(this, data) || this;
        }
        return MobileAccessNotSupported;
    }(WebAPI));
    var NRUserExcedeed =  (function (_super) {
        __extends$9(NRUserExcedeed, _super);
        function NRUserExcedeed(data) {
            return _super.call(this, data) || this;
        }
        return NRUserExcedeed;
    }(WebAPI));

    var Errors = /*#__PURE__*/Object.freeze({
        __proto__: null,
        ExtenUsedBy: ExtenUsedBy,
        InternalErrorWebAPI: InternalErrorWebAPI,
        FeatureNotSupported: FeatureNotSupported,
        FeatureNotAllowed: FeatureNotAllowed,
        InvalidDateRange: InvalidDateRange,
        MobileAccessNotSupported: MobileAccessNotSupported,
        NRUserExcedeed: NRUserExcedeed,
        WebAPI: WebAPI,
        GenericObject: GenericObject,
        NoRouteToHost: NoRouteToHost,
        ReconnectingInProgress: ReconnectingInProgress,
        SocketClosed: SocketClosed,
        StopOpenSocket: StopOpenSocket,
        AuthorizationRequired: AuthorizationRequired,
        PasswordExpired: PasswordExpired,
        UserNotEnabledOnMcs: UserNotEnabledOnMcs,
        UserNotEnabled: UserNotEnabled,
        CallInProgress: CallInProgress,
        TimeoutResponse: TimeoutResponse,
        CacheLimitSizeExceeded: CacheLimitSizeExceeded,
        GenericObjectExists: GenericObjectExists,
        GenericObjectFormat: GenericObjectFormat,
        GenericObjectIsInUse: GenericObjectIsInUse,
        GenericObjectMinSize: GenericObjectMinSize,
        GenericObjectMaxSize: GenericObjectMaxSize,
        GenericObjectRangeValue: GenericObjectRangeValue,
        GenericObjectMaxValue: GenericObjectMaxValue,
        GenericObjectMinValue: GenericObjectMinValue,
        GenericObjectRequiredDigitValue: GenericObjectRequiredDigitValue,
        GenericObjectRequiredNumberValue: GenericObjectRequiredNumberValue,
        GenericObjectSameSize: GenericObjectSameSize,
        GenericObjectUnchangeable: GenericObjectUnchangeable,
        LogoutNotEnable: LogoutNotEnable,
        UseOfAgExternalNotEnableCauseNoMobilePhone: UseOfAgExternalNotEnableCauseNoMobilePhone,
        GenericObjectWasNotFound: GenericObjectWasNotFound,
        InvalidArgument: InvalidArgument,
        InvalidAction: InvalidAction,
        InvalidLicence: InvalidLicence,
        LicenceExceeded: LicenceExceeded,
        MaxRetryExceeded: MaxRetryExceeded,
        NoFileOnCache: NoFileOnCache,
        OperationIsNotAllowedToUser: OperationIsNotAllowedToUser,
        WriteOperationIsNotAllowedToUser: WriteOperationIsNotAllowedToUser,
        WrongSessionId: WrongSessionId,
        WrongVersion: WrongVersion,
        ConvertFile: ConvertFile,
        GenericObjectRequired: GenericObjectRequired,
        DeviceRequestFailed: DeviceRequestFailed,
        DeviceClosed: DeviceClosed,
        DeviceTimeout: DeviceTimeout,
        TTS: TTS,
        WidgetFormUpdate: WidgetFormUpdate,
        ConfigurationError: ConfigurationError
    });

    var parse_1 = parse;
    var serialize_1 = serialize;
    var decode = decodeURIComponent;
    var encode$1 = encodeURIComponent;
    var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
    function parse(str, options) {
      if (typeof str !== 'string') {
        throw new TypeError('argument str must be a string');
      }
      var obj = {};
      var opt = options || {};
      var pairs = str.split(';');
      var dec = opt.decode || decode;
      for (var i = 0; i < pairs.length; i++) {
        var pair = pairs[i];
        var index = pair.indexOf('=');
        if (index < 0) {
          continue;
        }
        var key = pair.substring(0, index).trim();
        if (undefined == obj[key]) {
          var val = pair.substring(index + 1, pair.length).trim();
          if (val[0] === '"') {
            val = val.slice(1, -1);
          }
          obj[key] = tryDecode(val, dec);
        }
      }
      return obj;
    }
    function serialize(name, val, options) {
      var opt = options || {};
      var enc = opt.encode || encode$1;
      if (typeof enc !== 'function') {
        throw new TypeError('option encode is invalid');
      }
      if (!fieldContentRegExp.test(name)) {
        throw new TypeError('argument name is invalid');
      }
      var value = enc(val);
      if (value && !fieldContentRegExp.test(value)) {
        throw new TypeError('argument val is invalid');
      }
      var str = name + '=' + value;
      if (null != opt.maxAge) {
        var maxAge = opt.maxAge - 0;
        if (isNaN(maxAge) || !isFinite(maxAge)) {
          throw new TypeError('option maxAge is invalid')
        }
        str += '; Max-Age=' + Math.floor(maxAge);
      }
      if (opt.domain) {
        if (!fieldContentRegExp.test(opt.domain)) {
          throw new TypeError('option domain is invalid');
        }
        str += '; Domain=' + opt.domain;
      }
      if (opt.path) {
        if (!fieldContentRegExp.test(opt.path)) {
          throw new TypeError('option path is invalid');
        }
        str += '; Path=' + opt.path;
      }
      if (opt.expires) {
        if (typeof opt.expires.toUTCString !== 'function') {
          throw new TypeError('option expires is invalid');
        }
        str += '; Expires=' + opt.expires.toUTCString();
      }
      if (opt.httpOnly) {
        str += '; HttpOnly';
      }
      if (opt.secure) {
        str += '; Secure';
      }
      if (opt.sameSite) {
        var sameSite = typeof opt.sameSite === 'string'
          ? opt.sameSite.toLowerCase() : opt.sameSite;
        switch (sameSite) {
          case true:
            str += '; SameSite=Strict';
            break;
          case 'lax':
            str += '; SameSite=Lax';
            break;
          case 'strict':
            str += '; SameSite=Strict';
            break;
          case 'none':
            str += '; SameSite=None';
            break;
          default:
            throw new TypeError('option sameSite is invalid');
        }
      }
      return str;
    }
    function tryDecode(str, decode) {
      try {
        return decode(str);
      } catch (e) {
        return str;
      }
    }

    var RetryOptions =  (function () {
        function RetryOptions(retry, prefix) {
            this.retries = null;
            this.factor = 2;
            this.minTimeout = 1000;
            this.maxTimeout = 10000;
            this.randomize = false;
            this.forever = true;
            if (!retry)
                return;
            loadConfig(prefix, RetryOptions.CHECK_OPTIONS, this, retry);
        }
        RetryOptions.CHECK_OPTIONS = {
            mandatory: {},
            optional: {
                retries: numberCheck,
                factor: numberCheck,
                minTimeout: numberCheck,
                maxTimeout: numberCheck,
                randomize: booleanCheck,
                forever: booleanCheck,
            },
        };
        return RetryOptions;
    }());

    var __extends$8 = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var WebapiConfig =  (function () {
        function WebapiConfig(config, prefix) {
            this.url = null;
            this.sessionParams = null;
            this.logConfig = new WebapiClientLogConfig();
            this.storageUrl = null;
            this.storageTimeout = 5000;
            this.retryOptions = new RetryOptions({ randomize: true });
            this.heartbeatInterval = 5000;
            this.rememberMe = true;
            this.selfManagedLogin = true;
            this.requestEnableUntilReconnect = false;
            this.requestTimeout = 15000;
            this.loginTimeout = 60000;
            this.cookie_path = null;
            this.multisession = false;
            this.remoteControl = true;
            this.remoteCommandHandler = null;
            if (!config)
                return;
            loadConfig(prefix, WebapiConfig.CHECK_OPTIONS, this, config);
        }
        WebapiConfig.CHECK_OPTIONS = {
            mandatory: {
                url: function (url) {
                    var url = stringCheck(url);
                    if (isEmpty(url)) {
                        return undefined;
                    }
                    url = url.replace(/^(http:|https:|ws:|wss:)\/\//i, "http://");
                    if (!/^http:\/\//i.test(url)) {
                        url = "http://" + url;
                    }
                    try {
                        if (/^https:/i.test(document.location.protocol)) {
                            url = url.replace(/^http:\/\//i, "https://");
                        }
                    }
                    catch (e) { }
                    return url;
                },
            },
            optional: {
                sessionParams: function (value) {
                    var objectValue = typeof value == "object" ? value : undefined;
                    if (!!objectValue) {
                        delete value["force"];
                        delete value["access_token"];
                        delete value["deviceid"];
                        delete value["jsessionid"];
                    }
                    return objectValue;
                },
                storageUrl: function (url) { return WebapiConfig.CHECK_OPTIONS.mandatory.url(url); },
                retryOptions: function (retry, destination, prefix) {
                    var value = objectCheck(retry);
                    return value ? new RetryOptions(value, arrayConcat(prefix, ["retryOptions"])) : value;
                },
                heartbeatInterval: numberCheck,
                rememberMe: booleanCheck,
                selfManagedLogin: booleanCheck,
                requestEnableUntilReconnect: booleanCheck,
                multisession: booleanCheck,
                remoteControl: booleanCheck,
                remoteCommandHandler: functionCheck,
                requestTimeout: numberCheck,
                loginTimeout: numberCheck,
                cookie_path: stringCheck,
                logConfig: function (retry, destination, prefix) {
                    var value = objectCheck(retry);
                    return value ? new WebapiClientLogConfig(value, arrayConcat(prefix, ["logConfig"])) : value;
                },
            },
        };
        return WebapiConfig;
    }());
    var WebapiClientLogConfig =  (function (_super) {
        __extends$8(WebapiClientLogConfig, _super);
        function WebapiClientLogConfig(options, prefix) {
            return _super.call(this, options, prefix) || this;
        }
        return WebapiClientLogConfig;
    }(LogConfig));

    var dtmfValidator = /^[0-9#\*abcdABCD]+$/;

    var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
        if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
            if (ar || !(i in from)) {
                if (!ar) ar = Array.prototype.slice.call(from, 0, i);
                ar[i] = from[i];
            }
        }
        return to.concat(ar || Array.prototype.slice.call(from));
    };
    var BrowserInfo =  (function () {
        function BrowserInfo(name, version, os) {
            this.name = name;
            this.version = version;
            this.os = os;
            this.type = 'browser';
        }
        return BrowserInfo;
    }());
    var NodeInfo =  (function () {
        function NodeInfo(version) {
            this.version = version;
            this.type = 'node';
            this.name = 'node';
            this.os = process.platform;
        }
        return NodeInfo;
    }());
    var SearchBotDeviceInfo =  (function () {
        function SearchBotDeviceInfo(name, version, os, bot) {
            this.name = name;
            this.version = version;
            this.os = os;
            this.bot = bot;
            this.type = 'bot-device';
        }
        return SearchBotDeviceInfo;
    }());
    var BotInfo =  (function () {
        function BotInfo() {
            this.type = 'bot';
            this.bot = true;
            this.name = 'bot';
            this.version = null;
            this.os = null;
        }
        return BotInfo;
    }());
    var ReactNativeInfo =  (function () {
        function ReactNativeInfo() {
            this.type = 'react-native';
            this.name = 'react-native';
            this.version = null;
            this.os = null;
        }
        return ReactNativeInfo;
    }());
    var SEARCHBOX_UA_REGEX = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/;
    var SEARCHBOT_OS_REGEX = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/;
    var REQUIRED_VERSION_PARTS = 3;
    var userAgentRules = [
        ['aol', /AOLShield\/([0-9\._]+)/],
        ['edge', /Edge\/([0-9\._]+)/],
        ['edge-ios', /EdgiOS\/([0-9\._]+)/],
        ['yandexbrowser', /YaBrowser\/([0-9\._]+)/],
        ['kakaotalk', /KAKAOTALK\s([0-9\.]+)/],
        ['samsung', /SamsungBrowser\/([0-9\.]+)/],
        ['silk', /\bSilk\/([0-9._-]+)\b/],
        ['miui', /MiuiBrowser\/([0-9\.]+)$/],
        ['beaker', /BeakerBrowser\/([0-9\.]+)/],
        ['edge-chromium', /EdgA?\/([0-9\.]+)/],
        [
            'chromium-webview',
            /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/,
        ],
        ['chrome', /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],
        ['phantomjs', /PhantomJS\/([0-9\.]+)(:?\s|$)/],
        ['crios', /CriOS\/([0-9\.]+)(:?\s|$)/],
        ['firefox', /Firefox\/([0-9\.]+)(?:\s|$)/],
        ['fxios', /FxiOS\/([0-9\.]+)/],
        ['opera-mini', /Opera Mini.*Version\/([0-9\.]+)/],
        ['opera', /Opera\/([0-9\.]+)(?:\s|$)/],
        ['opera', /OPR\/([0-9\.]+)(:?\s|$)/],
        ['pie', /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],
        ['pie', /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],
        ['netfront', /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],
        ['ie', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],
        ['ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],
        ['ie', /MSIE\s(7\.0)/],
        ['bb10', /BB10;\sTouch.*Version\/([0-9\.]+)/],
        ['android', /Android\s([0-9\.]+)/],
        ['ios', /Version\/([0-9\._]+).*Mobile.*Safari.*/],
        ['safari', /Version\/([0-9\._]+).*Safari/],
        ['facebook', /FB[AS]V\/([0-9\.]+)/],
        ['instagram', /Instagram\s([0-9\.]+)/],
        ['ios-webview', /AppleWebKit\/([0-9\.]+).*Mobile/],
        ['ios-webview', /AppleWebKit\/([0-9\.]+).*Gecko\)$/],
        ['curl', /^curl\/([0-9\.]+)$/],
        ['searchbot', SEARCHBOX_UA_REGEX],
    ];
    var operatingSystemRules = [
        ['iOS', /iP(hone|od|ad)/],
        ['Android OS', /Android/],
        ['BlackBerry OS', /BlackBerry|BB10/],
        ['Windows Mobile', /IEMobile/],
        ['Amazon OS', /Kindle/],
        ['Windows 3.11', /Win16/],
        ['Windows 95', /(Windows 95)|(Win95)|(Windows_95)/],
        ['Windows 98', /(Windows 98)|(Win98)/],
        ['Windows 2000', /(Windows NT 5.0)|(Windows 2000)/],
        ['Windows XP', /(Windows NT 5.1)|(Windows XP)/],
        ['Windows Server 2003', /(Windows NT 5.2)/],
        ['Windows Vista', /(Windows NT 6.0)/],
        ['Windows 7', /(Windows NT 6.1)/],
        ['Windows 8', /(Windows NT 6.2)/],
        ['Windows 8.1', /(Windows NT 6.3)/],
        ['Windows 10', /(Windows NT 10.0)/],
        ['Windows ME', /Windows ME/],
        ['Windows CE', /Windows CE|WinCE|Microsoft Pocket Internet Explorer/],
        ['Open BSD', /OpenBSD/],
        ['Sun OS', /SunOS/],
        ['Chrome OS', /CrOS/],
        ['Linux', /(Linux)|(X11)/],
        ['Mac OS', /(Mac_PowerPC)|(Macintosh)/],
        ['QNX', /QNX/],
        ['BeOS', /BeOS/],
        ['OS/2', /OS\/2/],
    ];
    function detect(userAgent) {
        if (!!userAgent) {
            return parseUserAgent(userAgent);
        }
        if (typeof document === 'undefined' &&
            typeof navigator !== 'undefined' &&
            navigator.product === 'ReactNative') {
            return new ReactNativeInfo();
        }
        if (typeof navigator !== 'undefined') {
            return parseUserAgent(navigator.userAgent);
        }
        return getNodeVersion();
    }
    function matchUserAgent(ua) {
        return (ua !== '' &&
            userAgentRules.reduce(function (matched, _a) {
                var browser = _a[0], regex = _a[1];
                if (matched) {
                    return matched;
                }
                var uaMatch = regex.exec(ua);
                return !!uaMatch && [browser, uaMatch];
            }, false));
    }
    function parseUserAgent(ua) {
        var matchedRule = matchUserAgent(ua);
        if (!matchedRule) {
            return null;
        }
        var name = matchedRule[0], match = matchedRule[1];
        if (name === 'searchbot') {
            return new BotInfo();
        }
        var versionParts = match[1] && match[1].split('.').join('_').split('_').slice(0, 3);
        if (versionParts) {
            if (versionParts.length < REQUIRED_VERSION_PARTS) {
                versionParts = __spreadArray(__spreadArray([], versionParts, true), createVersionParts(REQUIRED_VERSION_PARTS - versionParts.length), true);
            }
        }
        else {
            versionParts = [];
        }
        var version = versionParts.join('.');
        var os = detectOS(ua);
        var searchBotMatch = SEARCHBOT_OS_REGEX.exec(ua);
        if (searchBotMatch && searchBotMatch[1]) {
            return new SearchBotDeviceInfo(name, version, os, searchBotMatch[1]);
        }
        return new BrowserInfo(name, version, os);
    }
    function detectOS(ua) {
        for (var ii = 0, count = operatingSystemRules.length; ii < count; ii++) {
            var _a = operatingSystemRules[ii], os = _a[0], regex = _a[1];
            var match = regex.exec(ua);
            if (match) {
                return os;
            }
        }
        return null;
    }
    function getNodeVersion() {
        var isNode = typeof process !== 'undefined' && process.version;
        return isNode ? new NodeInfo(process.version.slice(1)) : null;
    }
    function createVersionParts(count) {
        var output = [];
        for (var ii = 0; ii < count; ii++) {
            output.push('0');
        }
        return output;
    }

    var __assign$3 = (undefined && undefined.__assign) || function () {
        __assign$3 = Object.assign || function(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                    t[p] = s[p];
            }
            return t;
        };
        return __assign$3.apply(this, arguments);
    };
    var browser = detect();
    var isChomeMajorThan72 = browser && browser.name === "chrome" && parseInt((browser.version || "72.0").split(".")[0]) > 72;
    function phoneCallCanSwitchToVideoCall() {
        return (browser && browser.name !== "chrome") || !isChomeMajorThan72;
    }
    function buildWebrtcControlMessageFromChannelEvent(channelEvent, fromServer, override) {
        return __assign$3(__assign$3({ _isFromServer: fromServer, _channelType: channelEvent.channel, _realChannelType: channelEvent.channel }, (override !== null && override !== void 0 ? override : {})), channelEvent.callInfo);
    }
    function buildCallInfoFromWebrtcControlMessage(webrtcControlMessage) {
        var result = Object.assign({}, webrtcControlMessage);
        if (webrtcControlMessage._realChannelType) {
            result.channelid = channelTypeToId(webrtcControlMessage._realChannelType);
        }
        result.deviceType = ExtenType.WEBRTC;
        delete result._isFromServer;
        delete result._channelType;
        delete result._realChannelType;
        return result;
    }
    function adjustCallInfoWithMediaInfo(data, webrtcManager) {
        var callInfo = data.callInfo;
        if (callInfo && callInfo.deviceType === ExtenType.WEBRTC && webrtcManager) {
            if (!callInfo.remote_media_status) {
                callInfo.remote_media_status = callInfo.media || null;
            }
            if (!callInfo.media_feature) {
                callInfo.media_feature = {};
                if (callInfo.local_media_features) {
                    if (!phoneCallCanSwitchToVideoCall() && callInfo.local_media_features.video && callInfo.state !== CallState.NEW_INBOUND && callInfo.state !== CallState.NEW_OUTBOUND) {
                        var indexOfVideoStartStop = callInfo.local_media_features.video.indexOf(CallMediaFeature.START);
                        if (indexOfVideoStartStop === -1) {
                            indexOfVideoStartStop = callInfo.local_media_features.video.indexOf(CallMediaFeature.STOP);
                        }
                        if (indexOfVideoStartStop > -1) {
                            callInfo.local_media_features.video.splice(indexOfVideoStartStop, 1);
                            if (callInfo.local_media_features.video.length === 0) {
                                delete callInfo.local_media_features.video;
                            }
                        }
                    }
                    callInfo.media_feature.local = callInfo.local_media_features;
                }
                else if (data.channel === ChannelType.Video && webrtcManager) {
                    callInfo.media_feature.local = null;
                    switch (callInfo.state) {
                        case CallState.NEW_INBOUND:
                            if (!callInfo.remote_media_status) {
                                callInfo.remote_media_status = { audio: [CallMediaLinkStatus.UNMUTE], video: [CallMediaLinkStatus.UNMUTE] };
                            }
                            callInfo.media_feature.local = {};
                            if (webrtcManager.device.callMediaNotified.audio) {
                                callInfo.media_feature.local.audio = [CallMediaFeature.START];
                            }
                            if (webrtcManager.device.callMediaNotified.video) {
                                callInfo.media_feature.local.video = [CallMediaFeature.START];
                            }
                            break;
                        case CallState.CONNECTED:
                            var call = webrtcManager.retriveCall(callInfo.callId);
                            if (call) {
                                if (!callInfo.remote_media_status) {
                                    callInfo.remote_media_status = {};
                                    var remoteAudioStatus = call.audioRemoteLinkStatus;
                                    if (remoteAudioStatus) {
                                        callInfo.remote_media_status.audio = [remoteAudioStatus];
                                    }
                                    var remoteVideoStatus = call.videoRemoteLinkStatus;
                                    if (remoteVideoStatus) {
                                        callInfo.remote_media_status.video = [remoteVideoStatus];
                                    }
                                }
                                callInfo.media_feature.local = {};
                                if (webrtcManager.device.callMediaNotified.audio) {
                                    callInfo.media_feature.local.audio = [];
                                    var status_1 = call.audioLinkStatus;
                                    if (status_1) {
                                        callInfo.media_feature.local.audio.push(status_1 === CallMediaLinkStatus.MUTE ? CallMediaFeature.UNMUTE : CallMediaFeature.MUTE);
                                    }
                                    else {
                                        callInfo.media_feature.local.audio.push(CallMediaFeature.START);
                                    }
                                }
                                if (webrtcManager.device.callMediaNotified.video) {
                                    callInfo.media_feature.local.video = [];
                                    var status_2 = call.videoLinkStatus;
                                    if (status_2) {
                                        callInfo.media_feature.local.video.push(status_2 === CallMediaLinkStatus.MUTE ? CallMediaFeature.UNMUTE : CallMediaFeature.MUTE);
                                    }
                                    else {
                                        callInfo.media_feature.local.video.push(CallMediaFeature.START);
                                    }
                                }
                            }
                            break;
                    }
                    if (callInfo.media_feature.local) {
                        callInfo.local_media_features = callInfo.media_feature.local;
                    }
                    if (!callInfo.media && callInfo.remote_media_status) {
                        callInfo.media = callInfo.remote_media_status;
                    }
                }
            }
            if (!callInfo.media_feature.remote) {
                callInfo.media_feature.remote = {};
                if (callInfo.remote_media_status && (callInfo.remote_media_status.audio || callInfo.remote_media_status.video) && webrtcManager) {
                    var call = webrtcManager.retriveCall(callInfo.callId);
                    if (callInfo.remote_media_status.audio) {
                        callInfo.media_feature.remote.audio = [call ? (call.audioRemoteLinkStatus === CallMediaLinkStatus.MUTE ? CallMediaFeature.UNMUTE : CallMediaFeature.MUTE) : callInfo.remote_media_status.audio.indexOf(CallMediaLinkStatus.MUTE) > -1 ? CallMediaFeature.UNMUTE : CallMediaFeature.MUTE];
                    }
                    if (callInfo.remote_media_status.video) {
                        callInfo.media_feature.remote.video = [call ? (call.videoRemoteLinkStatus === CallMediaLinkStatus.MUTE ? CallMediaFeature.UNMUTE : CallMediaFeature.MUTE) : callInfo.remote_media_status.video.indexOf(CallMediaLinkStatus.MUTE) > -1 ? CallMediaFeature.UNMUTE : CallMediaFeature.MUTE];
                    }
                }
            }
        }
        return data;
    }
    var LoginType;
    (function (LoginType) {
        LoginType[LoginType["Credential"] = 0] = "Credential";
        LoginType[LoginType["AccessToken"] = 1] = "AccessToken";
        LoginType[LoginType["Custom"] = 2] = "Custom";
    })(LoginType || (LoginType = {}));

    var __extends$7 = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var __awaiter$a = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$9 = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    var WebapiClientMethods =  (function (_super) {
        __extends$7(WebapiClientMethods, _super);
        function WebapiClientMethods(
        client,
        channelNotification,
        commandNotification,
        disconnectOtherSocket,
        loginRequest,
        remeberMe,
        exitAfterLogout) {
            var _this = _super.call(this, client) || this;
            _this.disconnectOtherSocket = disconnectOtherSocket;
            _this.loginRequest = loginRequest;
            _this.remeberMe = remeberMe;
            _this.exitAfterLogout = exitAfterLogout;
            _this.callInfoNotification = new NotificationManager(client, "callInfo", function () { return _this.requestObservableUpdate("startCallNotify", []); }, channelNotification, function (callInfo) {
                return { channel: channelIdToChannelType(callInfo.channelid), callInfo: callInfo };
            });
            _this.commandNotification = new NotificationManager(client, "clientCommand", function () { return _this.requestObservableUpdate("startClientCommandNotify", []); }, commandNotification, function (clientCommand) { return clientCommand; });
            return _this;
        }
        WebapiClientMethods.prototype.refreshToken = function (username, accessToken) {
            return this.requestPromise("refreshToken", [username, accessToken]).toPromise();
        };
        WebapiClientMethods.prototype.resumeChatToken = function () {
            return this.requestPromise("resumeChatToken", []).toPromise();
        };
        WebapiClientMethods.prototype.getRefreshToken = function () {
            return this.requestPromise("getRefreshToken", []).toPromise();
        };
        WebapiClientMethods.prototype.searchUsers = function (name, number, company, customFields, addressbookType, site, categories, pageNumber, pageSize, exclusive) {
            return this.requestChunkedUpdate("searchUsers", [name, number, company, customFields, addressbookType, site, categories, pageNumber, pageSize, exclusive]).toLiveResult();
        };
        WebapiClientMethods.prototype.searchUsersExtended = function (addressbookType, fields, exclusive, pageNumber, pageSize, timeout) {
            return this.requestChunkedUpdate("searchUsersExtended", [addressbookType, fields, exclusive, pageNumber, pageSize], timeout).toLiveResult();
        };
        WebapiClientMethods.prototype.searchUsersExtendedByBackend = function (addressbookType, fields, exclusive, backendsConfigName, pageNumber, pageSize, timeout) {
            return this.requestChunkedUpdate("searchUsersExtendedByBackend", [addressbookType, fields, exclusive, backendsConfigName, pageNumber, pageSize], timeout).toLiveResult();
        };
        WebapiClientMethods.prototype.getListOfCompany = function (name, backend, pageNumber, pageSize) {
            return this.requestChunked("getListOfCompany", [name, backend, pageNumber, pageSize]);
        };
        WebapiClientMethods.prototype.exportAddressBook = function (addressBookConfigName) {
            return this.requestPromise("exportAddressBook", [addressBookConfigName], 3600000).toPromise();
        };
        WebapiClientMethods.prototype.importAddressBook = function (fileName, addressBookConfigName, doClean) {
            return this.requestPromise("importAddressBook", [fileName, addressBookConfigName, doClean], 300000).toPromise();
        };
        WebapiClientMethods.prototype.monitorImportAddressBook = function () {
            return this.requestPromiseUpdate("monitorImportAddressBook", []).response;
        };
        WebapiClientMethods.prototype.getAllCategories = function (addressbookType) {
            return this.requestPromiseUpdate("getAllCategories", [addressbookType]).response;
        };
        WebapiClientMethods.prototype.getUserSites = function () {
            return this.requestPromise("getUserSites", []).toPromise();
        };
        WebapiClientMethods.prototype.getUnreadChat = function () {
            return this.requestChunked("getUnreadChat", []);
        };
        WebapiClientMethods.prototype.isValidSession = function () {
            return this.requestPromise("isValidSession", []).toPromise();
        };
        WebapiClientMethods.prototype.logout = function (reason, note) {
            if (reason === void 0) { reason = null; }
            if (note === void 0) { note = null; }
            return this.requestPromise("logout", [reason, note]).toPromise();
        };
        WebapiClientMethods.prototype.logoutAndExit = function (reason, note) {
            return this.exitAfterLogout(this.logout(reason, note));
        };
        WebapiClientMethods.prototype.isGrantedAccess = function () {
            return this.requestPromise("isGrantedAccess", []).toPromise();
        };
        WebapiClientMethods.prototype.getMaxPageSize = function () {
            return this.requestPromise("getMaxPageSize", []).toPromise();
        };
        WebapiClientMethods.prototype.getSessionProfile = function () {
            return this.requestPromise("getSessionProfile", []).toPromise();
        };
        WebapiClientMethods.prototype.loginForce = function () {
            return __awaiter$a(this, void 0, void 0, function () {
                return __generator$9(this, function (_a) {
                    this.disconnectOtherSocket();
                    return [2 , this.loadTransport()];
                });
            });
        };
        WebapiClientMethods.prototype.loginCustom = function (customData, rememberMe, timeout) {
            return __awaiter$a(this, void 0, void 0, function () {
                var _this = this;
                return __generator$9(this, function (_a) {
                    this.remeberMe(rememberMe);
                    return [2 , this.loginRequest(timeout, LoginType.Custom, customData)
                            .pipe(tap(function (loginResult) {
                            if (loginResult.sessionId) {
                                try {
                                    _this.loadTransport();
                                }
                                catch (error) {
                                    _this.transport.emitError(error, false);
                                }
                            }
                        }))
                            .toPromise()];
                });
            });
        };
        WebapiClientMethods.prototype.loginByAccessToken = function (accessToken, rememberMe, timeout) {
            return __awaiter$a(this, void 0, void 0, function () {
                var _this = this;
                return __generator$9(this, function (_a) {
                    this.remeberMe(rememberMe);
                    return [2 , this.loginRequest(timeout, LoginType.AccessToken, accessToken)
                            .pipe(tap(function (loginResult) {
                            if (loginResult.sessionId) {
                                try {
                                    _this.loadTransport();
                                }
                                catch (error) {
                                    _this.transport.emitError(error, false);
                                }
                            }
                        }))
                            .toPromise()];
                });
            });
        };
        WebapiClientMethods.prototype.login = function (username, password, rememberMe, timeout) {
            return __awaiter$a(this, void 0, void 0, function () {
                var _this = this;
                return __generator$9(this, function (_a) {
                    this.remeberMe(rememberMe);
                    return [2 , this.loginRequest(timeout, LoginType.Credential, username, password)
                            .pipe(tap(function (loginResult) {
                            if (loginResult.sessionId) {
                                try {
                                    _this.loadTransport();
                                }
                                catch (error) {
                                    _this.transport.emitError(error, false);
                                }
                            }
                        }))
                            .toPromise()];
                });
            });
        };
        WebapiClientMethods.prototype.getVersion = function () {
            return this.requestPromise("getVersion", []).toPromise();
        };
        WebapiClientMethods.prototype.uploadFile = function (file) {
            return this.requestPromise("uploadFile", [file]).toPromise();
        };
        WebapiClientMethods.prototype.getUploadFile = function (fileName, withBody) {
            return this.requestPromise("getUploadFile", [fileName, withBody]).toPromise();
        };
        WebapiClientMethods.prototype.removeUploadFile = function (fileName) {
            return this.requestPromise("removeUploadFile", [fileName]).toPromise();
        };
        WebapiClientMethods.prototype.chunkedRequest = function (chunk) {
            return this.requestPromise("chunkedRequest", [chunk]).toPromise();
        };
        WebapiClientMethods.prototype.resetChunkedRequest = function (requestId) {
            return this.requestPromise("resetChunkedRequest", [requestId]).toPromise();
        };
        WebapiClientMethods.prototype.runChunkedRequest = function (requestId, fileName) {
            return this.requestPromise("runChunkedRequestFile", [requestId, fileName]).toPromise();
        };
        WebapiClientMethods.prototype.getUserDetail = function (timeout) {
            return this.requestPromiseUpdate("getUserDetail", [], timeout ? timeout : this.transport.getRequestTimeout() < 30000 ? 30000 : null).response;
        };
        WebapiClientMethods.prototype.useProfile = function (id, type, device, force, reason, note, requestTimeout) {
            if (force === void 0) { force = false; }
            if (reason === void 0) { reason = null; }
            if (note === void 0) { note = null; }
            if (requestTimeout === void 0) { requestTimeout = 30000; }
            return this.requestPromiseUpdate("useProfile", [id, type, device, force, reason, note], requestTimeout).response;
        };
        WebapiClientMethods.prototype.useDevice = function (type, exten, force) {
            return this.requestPromise("useDevice", [type, exten, force]).toPromise();
        };
        WebapiClientMethods.prototype.startConference = function () {
            return this.requestPromise("startConference", []).toPromise();
        };
        WebapiClientMethods.prototype.getCurrentCalls = function () {
            return this.requestPromise("getCurrentCalls", []).toPromise();
        };
        WebapiClientMethods.prototype.startCallNotify = function () {
            return __awaiter$a(this, void 0, void 0, function () {
                return __generator$9(this, function (_a) {
                    return [2 , this.callInfoNotification.start()];
                });
            });
        };
        WebapiClientMethods.prototype.isInternalNumber = function (number) {
            return this.requestPromise("isInternalNumber", [number]).toPromise();
        };
        WebapiClientMethods.prototype.getAllServiceCode = function () {
            return this.requestPromise("getAllServiceCode", []).toPromise();
        };
        WebapiClientMethods.prototype.stopCallNotify = function () {
            return __awaiter$a(this, void 0, void 0, function () {
                return __generator$9(this, function (_a) {
                    return [2 , this.callInfoNotification.stop()];
                });
            });
        };
        WebapiClientMethods.prototype.startVideoEchoTest = function (audio, video, videoContainer, mediaConfiguration) {
            var _a;
            return (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.startVideoEchoTest(audio, video, videoContainer, mediaConfiguration).toPromise();
        };
        WebapiClientMethods.prototype.dial = function (dialParam, videoContainer, mediaConfiguration, userInteractionAction) {
            var _a;
            return __awaiter$a(this, void 0, void 0, function () {
                var dialParams, result;
                return __generator$9(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            dialParams = new DialParams(dialParam);
                            result = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.dial(dialParams, videoContainer, mediaConfiguration, userInteractionAction);
                            if (!result) return [3 , 1];
                            return [2 , result.toPromise()];
                        case 1: return [4 , this.requestPromise("dial", dialParams.toRequest()).toPromise()];
                        case 2:
                            if (_b.sent()) {
                                return [2 , "true"];
                            }
                            else {
                                return [2 , null];
                            }
                        case 3: return [2 ];
                    }
                });
            });
        };
        WebapiClientMethods.prototype.getUserContactStatus = function (username) {
            return this.requestPromiseUpdate("getUserContactStatus", [username]).response;
        };
        WebapiClientMethods.prototype.getAddressBookContact = function (uid, type) {
            return this.requestPromise("getAddressBookContact", [uid, type]).toPromise();
        };
        WebapiClientMethods.prototype.getAddressBookContactByUuid = function (uid) {
            return this.requestPromise("getAddressBookContactByUuid", [uid]).toPromise();
        };
        WebapiClientMethods.prototype.inboundCallExtension = function (type, device, enable, force) {
            return this.requestPromise("inboundCallExtension", [type, device, enable, force]).toPromise();
        };
        WebapiClientMethods.prototype.answerOnChannel = function (channelType, callId, media, videoContainer, mediaConfiguration) {
            var _a;
            var result = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.answer(channelType, callId, media, videoContainer, mediaConfiguration);
            return result ? result.toPromise() : this.requestPromise("answer", [callId, null]).toPromise();
        };
        WebapiClientMethods.prototype.cancel = function (callId) {
            var _a;
            var result = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.cancel(callId, true, true);
            return result ? result.toPromise() : this.requestPromise("cancel", [callId]).toPromise();
        };
        WebapiClientMethods.prototype.hold = function (callId) {
            var _a;
            return __awaiter$a(this, void 0, void 0, function () {
                return __generator$9(this, function (_b) {
                    switch (_b.label) {
                        case 0: return [4 , ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.hold(callId))];
                        case 1:
                            _b.sent();
                            return [2 , this.requestPromise("hold", [callId]).toPromise()];
                    }
                });
            });
        };
        WebapiClientMethods.prototype.unhold = function (callId) {
            var _a;
            return __awaiter$a(this, void 0, void 0, function () {
                return __generator$9(this, function (_b) {
                    switch (_b.label) {
                        case 0: return [4 , ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.unhold(callId))];
                        case 1:
                            _b.sent();
                            return [2 , this.requestPromise("unhold", [callId]).toPromise()];
                    }
                });
            });
        };
        WebapiClientMethods.prototype.attendedTransfer = function (callId, heldCallId, media, fields) {
            var _a;
            var result = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.attendedTransfer(callId, heldCallId, media, fields);
            return result ? result.toPromise() : this.requestPromise("attendedTransfer", [callId, heldCallId, ["audio"], fields]).toPromise();
        };
        WebapiClientMethods.prototype.blindTransfer = function (callId, accessCode, number, data) {
            var _a;
            var result = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.blindTransfer(callId, accessCode, number, data);
            return result ? result.toPromise() : this.requestPromise("blindTransfer", [callId, accessCode, number, data]).toPromise();
        };
        WebapiClientMethods.prototype.blindTransferMultiChannelToUser = function (callId, username, channelId) {
            return this.requestPromise("blindTransferMultiChannelToUser", [callId, username, channelId]).toPromise();
        };
        WebapiClientMethods.prototype.setCallData = function (callId, data) {
            return this.requestPromise("setCallData", [callId, data]).toPromise();
        };
        WebapiClientMethods.prototype.sendDTMF = function (callId, dtmf, playTone, dtmfDuration, dtmfInterToneGap) {
            var _a;
            dtmf = (dtmf || "").split("").reduce(function (d1, d2) { return (dtmfValidator.test(d2) ? d1 + d2 : d1); }, "");
            if (dtmf) {
                var result = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.sendDTMF(callId, dtmf, playTone, dtmfDuration, dtmfInterToneGap);
                return result ? result.toPromise() : this.requestPromise("sendDTMF", [callId, dtmf]).toPromise();
            }
            else {
                return Promise.reject("Invalid DTMF");
            }
        };
        WebapiClientMethods.prototype.stopRecord = function (callId) {
            return this.requestPromise("stopRecord", [callId]).toPromise();
        };
        WebapiClientMethods.prototype.startRecord = function (callId) {
            return this.requestPromise("startRecord", [callId]).toPromise();
        };
        WebapiClientMethods.prototype.updateCallRecordingNote = function (tableName, id, note, additionalData) {
            return this.requestPromise("updateCallRecordingNote", [tableName, id, note, additionalData]).toPromise();
        };
        WebapiClientMethods.prototype.chanSpyUser = function (fromDeviceType, fromDevice, usernameToSpy, whisper, beep) {
            return this.requestPromise("chanSpyUser", [fromDeviceType, fromDevice, usernameToSpy, whisper, beep]).toPromise();
        };
        WebapiClientMethods.prototype.getFavouriteContacts = function (requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 30000; }
            return this.requestChunkedUpdate("getFavouriteContacts", [], requestTimeout).response;
        };
        WebapiClientMethods.prototype.addFavouriteItemGroup = function (name, position) {
            return this.requestPromise("addFavouriteItemGroup", [name, position]).toPromise();
        };
        WebapiClientMethods.prototype.setFavouriteItemGroup = function (id, name, expanded, position) {
            return this.requestPromise("setFavouriteItemGroup", [id, name, expanded, position]).toPromise();
        };
        WebapiClientMethods.prototype.setFavouriteItemGroups = function (groups) {
            return this.requestPromise("setFavouriteItemGroups", [groups]).toPromise();
        };
        WebapiClientMethods.prototype.delFavouriteItemGroup = function (id) {
            return this.requestPromise("delFavouriteItemGroup", [id]).toPromise();
        };
        WebapiClientMethods.prototype.setFavouriteItemContact = function (uid, type, groupId, position) {
            return this.requestPromise("setFavouriteItemContact", [uid, type, groupId, position]).toPromise();
        };
        WebapiClientMethods.prototype.addFavouriteItemContact = function (uid, type, groupId, position) {
            return this.requestPromise("addFavouriteItemContact", [uid, type, groupId, position]).toPromise();
        };
        WebapiClientMethods.prototype.delFavouriteItemContactFromGroup = function (uid, type, groupId) {
            return this.requestPromise("delFavouriteItemContactFromGroup", [uid, type, groupId]).toPromise();
        };
        WebapiClientMethods.prototype.getFavouriteUserGroups = function () {
            return this.requestChunked("getFavouriteUserGroups", []);
        };
        WebapiClientMethods.prototype.delFavouriteItemContactFromGroups = function (uid, type, groupIds) {
            return this.requestPromise("delFavouriteItemContactFromGroups", [uid, type, groupIds]).toPromise();
        };
        WebapiClientMethods.prototype.addFavouriteItemContactToGroups = function (uid, type, groupIds) {
            return this.requestPromise("addFavouriteItemContactToGroups", [uid, type, groupIds]).toPromise();
        };
        WebapiClientMethods.prototype.getServicesCallQueue = function () {
            return this.requestChunkedUpdate("getServicesCallQueue", []).response;
        };
        WebapiClientMethods.prototype.getSkillsetsCallQueue = function () {
            return this.requestChunkedUpdate("getSkillsetsCallQueue", []).response;
        };
        WebapiClientMethods.prototype.getClientConfig = function () {
            return this.requestPromise("getClientConfig", []).toPromise();
        };
        WebapiClientMethods.prototype.setClientConfig = function (value) {
            return this.requestPromise("setClientConfig", [value]).toPromise();
        };
        WebapiClientMethods.prototype.setUserStatusReady = function (channelId) {
            return this.requestPromise("setUserStatusReady", [channelId]).toPromise();
        };
        WebapiClientMethods.prototype.setUserStatusNotReady = function (channelId) {
            return this.requestPromise("setUserStatusNotReady", [channelId]).toPromise();
        };
        WebapiClientMethods.prototype.setUserStatusWorkNotReady = function (channelId) {
            return this.requestPromise("setUserStatusWorkNotReady", [channelId]).toPromise();
        };
        WebapiClientMethods.prototype.setActivityCode = function (action) {
            return this.requestPromise("setActivityCode", [action]).toPromise();
        };
        WebapiClientMethods.prototype.enterOnConferenceRoom = function (fromDeviceType, fromDevice) {
            return this.requestPromise("enterOnConferenceRoom", [fromDeviceType, fromDevice]).toPromise();
        };
        WebapiClientMethods.prototype.transferToConferenceRoom = function (callId) {
            return this.requestPromise("transferToConferenceRoom", [callId]).toPromise();
        };
        WebapiClientMethods.prototype.kickOffAllFromConferenceRoom = function () {
            return this.requestPromise("kickOffAllFromConferenceRoom", []).toPromise();
        };
        WebapiClientMethods.prototype.getAddressBooks = function () {
            return this.requestPromise("getAddressBooks", []).toPromise();
        };
        WebapiClientMethods.prototype.addAddressBookContact = function (backendConfigName, contact) {
            return this.requestPromise("addAddressBookContact", [backendConfigName, contact]).toPromise();
        };
        WebapiClientMethods.prototype.setAddressBookContact = function (contact) {
            return this.requestPromise("setAddressBookContact", [contact]).toPromise();
        };
        WebapiClientMethods.prototype.setAgentNoteOnAddressBookContact = function (uuid, agentNote) {
            return this.requestPromise("setAgentNoteOnAddressBookContact", [uuid, agentNote]).toPromise();
        };
        WebapiClientMethods.prototype.mergeAddressBookContact = function (originUid, contactDestination) {
            return this.requestPromise("mergeAddressBookContact", [originUid, contactDestination]).toPromise();
        };
        WebapiClientMethods.prototype.forgetAddressBookContact = function (originUid, force) {
            return this.requestPromise("forgetAddressBookContact", [originUid, force]).toPromise();
        };
        WebapiClientMethods.prototype.delAddressBookContact = function (contactId) {
            return this.requestPromise("delAddressBookContact", [contactId]).toPromise();
        };
        WebapiClientMethods.prototype.acquireWebRTCSession = function (force) {
            return this.requestPromise("acquireWebRTCSession", [force]).toPromise();
        };
        WebapiClientMethods.prototype.freeWebRTCSession = function () {
            return this.requestPromise("freeWebRTCSession", []).toPromise();
        };
        WebapiClientMethods.prototype.mute = function (callId, media) {
            var _a, _b;
            var result = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.mute(callId, media);
            return result ? result.toPromise() : (_b = this.client.webrtc) === null || _b === void 0 ? void 0 : _b.methods.notifyMute(callId, media, null).toPromise();
        };
        WebapiClientMethods.prototype.unmute = function (callId, media) {
            var _a, _b;
            var result = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.unmute(callId, media);
            return result ? result.toPromise() : (_b = this.client.webrtc) === null || _b === void 0 ? void 0 : _b.methods.notifyUnmute(callId, media, null).toPromise();
        };
        WebapiClientMethods.prototype.conferenceAttendeeMute = function (callId) {
            return this.requestPromise("conferenceAttendeeMute", [callId]).toPromise();
        };
        WebapiClientMethods.prototype.conferenceAttendeeUnmute = function (callId) {
            return this.requestPromise("conferenceAttendeeUnmute", [callId]).toPromise();
        };
        WebapiClientMethods.prototype.getInternalFieldConfigs = function () {
            return this.requestPromise("getInternalFieldConfigs", []).toPromise();
        };
        WebapiClientMethods.prototype.getExternalFieldConfigs = function () {
            return this.requestPromise("getExternalFieldConfigs", []).toPromise();
        };
        WebapiClientMethods.prototype.getPersonalFieldConfigs = function () {
            return this.requestPromise("getPersonalFieldConfigs", []).toPromise();
        };
        WebapiClientMethods.prototype.searchUserCallHistoryItems = function (fields, notFields, startGreaterThan, updateGreaterThan, read, services, callContact, callContactId, callContactNumber, pageNumber, pageSize) {
            return this.requestChunked("searchUserCallHistoryItems",
            [fields, notFields, startGreaterThan, updateGreaterThan, read, services, callContact, callContactId, callContactNumber, pageNumber, pageSize]);
        };
        WebapiClientMethods.prototype.setUserCallHistoryItem = function (ids, read) {
            return this.requestPromise("setUserCallHistoryItem", [ids, read]).toPromise();
        };
        WebapiClientMethods.prototype.delUserCallHistoryItem = function (ids) {
            return this.requestPromise("delUserCallHistoryItem", [ids]).toPromise();
        };
        WebapiClientMethods.prototype.resetUserCallHistoryItemsByContact = function (contact) {
            return this.requestPromise("resetUserCallHistoryItemsByContact", [contact]).toPromise();
        };
        WebapiClientMethods.prototype.resetUserCallHistoryItems = function (transportType) {
            return this.requestPromise("resetUserCallHistoryItems", [transportType]).toPromise();
        };
        WebapiClientMethods.prototype.searchUserChatHistoryItems = function (contactUsername, insertGreaterThan, pageNumber, pageSize) {
            return this.requestChunked("searchUserChatHistoryItems",
            [contactUsername, insertGreaterThan, pageNumber, pageSize]);
        };
        WebapiClientMethods.prototype.getClassConfigurationPermission = function () {
            return this.requestPromiseUpdate("getClassConfigurationPermission", []).toLiveResult();
        };
        WebapiClientMethods.prototype.getConfiguration = function () {
            return this.requestPromiseUpdate("getConfiguration", []).toLiveResult();
        };
        WebapiClientMethods.prototype.resetPassword = function (password) {
            return this.requestPromise("resetPassword", [password]).toPromise();
        };
        WebapiClientMethods.prototype.resetPin = function (pin) {
            return this.requestPromise("resetPin", [pin]).toPromise();
        };
        WebapiClientMethods.prototype.setDirectoryFields = function (directoryFields) {
            return this.requestPromise("setDirectoryFields", [directoryFields]).toPromise();
        };
        WebapiClientMethods.prototype.setName = function (name) {
            return this.requestPromise("setName", [name]).toPromise();
        };
        WebapiClientMethods.prototype.setSurname = function (surname) {
            return this.requestPromise("setSurname", [surname]).toPromise();
        };
        WebapiClientMethods.prototype.setCallFowardSettings = function (callFowardSettings) {
            return this.requestPromise("setCallFowardSettings", [callFowardSettings]).toPromise();
        };
        WebapiClientMethods.prototype.setVoicemailSettings = function (voicemail) {
            return this.requestPromise("setVoicemailSettings", [voicemail]).toPromise();
        };
        WebapiClientMethods.prototype.setConferenceSettings = function (conference) {
            return this.requestPromise("setConferenceSettings", [conference]).toPromise();
        };
        WebapiClientMethods.prototype.getServiceForCallFoward = function () {
            return this.requestPromise("getServiceForCallFoward", []).toPromise();
        };
        WebapiClientMethods.prototype.searchFaxDocument = function (faxBoxIds, usernames, clid, dnis, status, type, startTimeFrom, startTimeTo, read, pageNumber, pageSize) {
            return this.requestChunkedUpdate("searchFaxDocument", [faxBoxIds, usernames, clid, dnis, status, type, startTimeFrom, startTimeTo, read, pageNumber, pageSize]).toLiveResult();
        };
        WebapiClientMethods.prototype.getQueuedFaxDocument = function () {
            return this.requestChunkedUpdate("getQueuedFaxDocument", []).toLiveResult();
        };
        WebapiClientMethods.prototype.sendFaxDocument = function (faxBoxId, numbers, emailToNotify, priority, fileNames) {
            return this.requestPromise("sendFaxDocument", [faxBoxId, numbers, emailToNotify, priority, fileNames]).toPromise();
        };
        WebapiClientMethods.prototype.sendSms = function (number, message, contact, account) {
            return this.requestPromise("sendSms", [number, message, contact, account]).toPromise();
        };
        WebapiClientMethods.prototype.stopEnqueuedFaxDocument = function (id) {
            return this.requestPromise("stopEnqueuedFaxDocument", [id]).toPromise();
        };
        WebapiClientMethods.prototype.deleteFaxDocument = function (id) {
            return this.requestPromise("deleteFaxDocument", [id]).toPromise();
        };
        WebapiClientMethods.prototype.deleteFaxDocumentFromFileSystem = function (faxDoc) {
            return this.requestPromise("deleteFaxDocumentFromFileSystem", [faxDoc]).toPromise();
        };
        WebapiClientMethods.prototype.updateFaxDocument = function (id, read, note) {
            return this.requestPromise("updateFaxDocument", [id, read, note]).toPromise();
        };
        WebapiClientMethods.prototype.setCallResult = function (action) {
            return this.requestPromise("setCallResult", [action]).toPromise();
        };
        WebapiClientMethods.prototype.getUserInteractions = function () {
            return this.requestChunkedUpdate("getUserInteractions", []).toLiveResult();
        };
        WebapiClientMethods.prototype.setServiceStatusVisible = function (service, visible) {
            return this.requestPromise("setServiceStatusVisible", [service, visible]).toPromise();
        };
        WebapiClientMethods.prototype.getWebClientVersion = function () {
            return this.requestPromiseUpdate("getWebClientVersion", []).toLiveResult();
        };
        WebapiClientMethods.prototype.getClientParams = function () {
            return this.requestPromiseUpdate("getClientParams", []).toLiveResult();
        };
        WebapiClientMethods.prototype.setClientParam = function (values) {
            return this.requestPromise("setClientParam", [values]).toPromise();
        };
        WebapiClientMethods.prototype.getGeneralParams = function (params) {
            return this.requestPromise("getGeneralParams", [params]).toPromise();
        };
        WebapiClientMethods.prototype.updateUserInteraction = function (id, setReadAllRecords, status, action, lastUpdateActivityTime) {
            if (setReadAllRecords === void 0) { setReadAllRecords = false; }
            if (status === void 0) { status = UserInteractionStatus.CLOSED; }
            if (action === void 0) { action = null; }
            if (lastUpdateActivityTime === void 0) { lastUpdateActivityTime = null; }
            return this.requestPromise("updateUserInteraction", [id, setReadAllRecords, status, action, lastUpdateActivityTime]).toPromise();
        };
        WebapiClientMethods.prototype.createUserInteraction = function (createUserInteraction) {
            var _a;
            var result = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.createUserInteraction(createUserInteraction);
            return result ? result.toPromise() : this.requestPromise("createUserInteraction", [createUserInteraction]).toPromise();
        };
        WebapiClientMethods.prototype.setPinnedUserInteraction = function (action) {
            return this.requestPromise("setPinnedUserInteraction", [action]).toPromise();
        };
        WebapiClientMethods.prototype.cleanUserInteractions = function (interactionsToExclude) {
            return this.requestPromise("cleanUserInteractions", interactionsToExclude == undefined ? [] : [interactionsToExclude]).toPromise();
        };
        WebapiClientMethods.prototype.getCurrentUserInteractions = function () {
            return this.requestPromise("getCurrentUserInteractions", []).toPromise();
        };
        WebapiClientMethods.prototype.removeCallFromUserInteraction = function (callId) {
            var _a;
            var result = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.methods.removeCallFromUserInteraction(callId);
            return result ? result.toPromise() : this.requestPromise("removeCallFromUserInteraction", [callId]).toPromise();
        };
        WebapiClientMethods.prototype.getAllActivityCode = function () {
            return this.requestPromise("getAllActivityCode", []).toPromise();
        };
        WebapiClientMethods.prototype.getRoomDeskConfig = function (roomId) {
            return this.requestChunkedUpdate("getRoomDeskConfig", [roomId]).toLiveResult();
        };
        WebapiClientMethods.prototype.getActiveServiceCalls = function (profileId) {
            return this.requestChunkedUpdate("getActiveServiceCalls", [profileId]).toLiveResult();
        };
        WebapiClientMethods.prototype.servicePickup = function (fromDeviceType, fromDevice, callId, skillset, mcId) {
            if (mcId === void 0) { mcId = "0"; }
            return this.requestPromise("servicePickup", [fromDeviceType, fromDevice, callId, skillset, mcId]).toPromise();
        };
        WebapiClientMethods.prototype.servicePickupPrivateParkedCall = function (fromDeviceType, fromDevice, callId) {
            return this.requestPromise("servicePickupPrivateParkedCall", [fromDeviceType, fromDevice, callId]).toPromise();
        };
        WebapiClientMethods.prototype.updateWorkingSessionsNote = function (id, note) {
            return this.requestPromise("updateWorkingSessionsNote", [id, note]).toPromise();
        };
        WebapiClientMethods.prototype.setDND = function (active) {
            return this.requestPromise("setDND", [active]).toPromise();
        };
        WebapiClientMethods.prototype.tqmParkPrivate = function (callId, fromDeviceType, fromDevice, service, cli, data) {
            return this.requestPromise("tqmParkPrivate", [callId, fromDeviceType, fromDevice, service, cli, data]).toPromise();
        };
        WebapiClientMethods.prototype.tqmParkPublic = function (fromDeviceType, fromDevice, number) {
            return this.requestPromise("tqmParkPublic", [fromDeviceType, fromDevice, number]).toPromise();
        };
        WebapiClientMethods.prototype.freeDevice = function (type, device) {
            return this.requestPromise("freeDevice", [type, device]).toPromise();
        };
        WebapiClientMethods.prototype.isCallTaggable = function (number) {
            return this.requestPromise("isCallTaggable", [number]).toPromise();
        };
        WebapiClientMethods.prototype.getIntranetSections = function () {
            return this.requestChunked("getIntranetSections", []);
        };
        WebapiClientMethods.prototype.getIntranetPages = function () {
            return this.requestChunked("getIntranetPages", []);
        };
        WebapiClientMethods.prototype.getIntranetPage = function (id) {
            return this.requestPromise("getIntranetPage", [id]).toPromise();
        };
        WebapiClientMethods.prototype.getIntranetSection = function (id) {
            return this.requestPromise("getIntranetSection", [id]).toPromise();
        };
        WebapiClientMethods.prototype.monitorContact = function (contactId) {
            return this.requestPromiseUpdate("monitorContact", []).toLiveResult();
        };
        WebapiClientMethods.prototype.addIntranetSection = function (name, position) {
            return this.requestPromise("addIntranetSection", [name, position]).toPromise();
        };
        WebapiClientMethods.prototype.setIntranetSection = function (id, name, position) {
            return this.requestPromise("setIntranetSection", [id, name, position]).toPromise();
        };
        WebapiClientMethods.prototype.resetIntranetSectionPosition = function (sectionIdList) {
            return this.requestPromise("resetIntranetSectionPosition", [sectionIdList]).toPromise();
        };
        WebapiClientMethods.prototype.delIntranetSection = function (id) {
            return this.requestPromise("delIntranetSection", [id]).toPromise();
        };
        WebapiClientMethods.prototype.getIntranetItemsOnSection = function (sectionId) {
            return this.requestChunked("getIntranetItemsOnSection", [sectionId]);
        };
        WebapiClientMethods.prototype.addIntranetItemToSection = function (sectionId, description, url, image, position) {
            return this.requestPromise("addIntranetItemToSection", [sectionId, description, url, image, position]).toPromise();
        };
        WebapiClientMethods.prototype.setIntranetItemPosition = function (uid, sectionId, position) {
            return this.requestPromise("setIntranetItemPosition", [uid, sectionId, position]).toPromise();
        };
        WebapiClientMethods.prototype.setIntranetItem = function (uid, sectionId, description, url, image, position) {
            return this.requestPromise("setIntranetItem", [uid, sectionId, description, url, image, position]).toPromise();
        };
        WebapiClientMethods.prototype.delIntranetItem = function (uid) {
            return this.requestPromise("delIntranetItem", [uid]).toPromise();
        };
        WebapiClientMethods.prototype.resetIntranetItemPosition = function (itemIdList) {
            return this.requestPromise("resetIntranetItemPosition", [itemIdList]).toPromise();
        };
        WebapiClientMethods.prototype.noteSearch = function (searchCriteria) {
            return this.requestChunked("noteSearch", [searchCriteria]);
        };
        WebapiClientMethods.prototype.noteGet = function (noteUid) {
            return this.requestPromise("noteGet", [noteUid]).toPromise();
        };
        WebapiClientMethods.prototype.noteAdd = function (note) {
            return this.requestPromise("noteAdd", [note]).toPromise();
        };
        WebapiClientMethods.prototype.noteSet = function (note) {
            return this.requestPromise("noteSet", [note]).toPromise();
        };
        WebapiClientMethods.prototype.noteContactSet = function (noteUid, noteContacts) {
            return this.requestPromise("noteContactSet", [noteUid, noteContacts]).toPromise();
        };
        WebapiClientMethods.prototype.noteTagAdd = function (noteUid, tag) {
            return this.requestPromise("noteTagAdd", [noteUid, tag]).toPromise();
        };
        WebapiClientMethods.prototype.noteTagDel = function (noteUid, tag) {
            return this.requestPromise("noteTagDel", [noteUid, tag]).toPromise();
        };
        WebapiClientMethods.prototype.noteTagGet = function () {
            return this.requestChunked("noteTagGet", []);
        };
        WebapiClientMethods.prototype.noteSetArchived = function (noteUid, archived) {
            return this.requestPromise("noteSetArchived", [noteUid, archived]).toPromise();
        };
        WebapiClientMethods.prototype.noteSetDeleted = function (noteUid, deleted) {
            return this.requestPromise("noteSetDeleted", [noteUid, deleted]).toPromise();
        };
        WebapiClientMethods.prototype.startNoteCounterTotalNotify = function () {
            return this.requestPromiseUpdate("startNoteCounterTotalNotify", []).response;
        };
        WebapiClientMethods.prototype.startOmnideskCounterTotalNotify = function () {
            return this.requestPromiseUpdate("startOmnideskCounterTotalNotify", []).response;
        };
        WebapiClientMethods.prototype.startNoteUpdateNotify = function () {
            return this.requestPromiseUpdate("startNoteUpdateNotify", []).response;
        };
        WebapiClientMethods.prototype.contactNoteExpiredNotify = function () {
            return this.requestPromiseUpdate("contactNoteExpiredNotify", []).response;
        };
        WebapiClientMethods.prototype.contactNoteReminderNotify = function () {
            return this.requestPromiseUpdate("contactNoteReminderNotify", []).response;
        };
        WebapiClientMethods.prototype.omnideskScheduledMeetingNotify = function () {
            return this.requestPromiseUpdate("omnideskScheduledMeetingNotify", []).response;
        };
        WebapiClientMethods.prototype.isSecurePasswordEnabled = function () {
            return this.requestPromise("isSecurePasswordEnabled", []).toPromise();
        };
        WebapiClientMethods.prototype.abandonedCallsSearchClosed = function (searchCriteria) {
            return this.requestChunked("abandonedCallsSearchClosed", [searchCriteria]);
        };
        WebapiClientMethods.prototype.abandonedCallsSearchOpened = function (searchCriteria) {
            return this.requestChunkedUpdate("abandonedCallsSearchOpened", [searchCriteria]).toLiveResult();
        };
        WebapiClientMethods.prototype.abandonedCallsSearchOpenedPaged = function (searchCriteria, page, size, order) {
            return this.requestChunked("abandonedCallsSearchOpenedPaged", [searchCriteria, page, size, order]);
        };
        WebapiClientMethods.prototype.abandonedCallClose = function (id) {
            return this.requestPromise("abandonedCallClose", [id]).toPromise();
        };
        WebapiClientMethods.prototype.abandonedCallDelete = function (id) {
            return this.requestPromise("abandonedCallDelete", [id]).toPromise();
        };
        WebapiClientMethods.prototype.abandonedCallRetryExceeded = function (id) {
            return this.requestPromise("abandonedCallRetryExceeded", [id]).toPromise();
        };
        WebapiClientMethods.prototype.abandonedCallUnlock = function (id, force) {
            return this.requestPromise("abandonedCallUnlock", [id, force]).toPromise();
        };
        WebapiClientMethods.prototype.abandonedCallLock = function (id) {
            return this.requestPromise("abandonedCallLock", [id]).toPromise();
        };
        WebapiClientMethods.prototype.abandonedCallUpdateNote = function (id, startTime, note) {
            return this.requestPromise("abandonedCallUpdateNote", [id, startTime, note]).toPromise();
        };
        WebapiClientMethods.prototype.getAgentsOnServices = function (serviceCodes) {
            return this.requestChunked("getAgentsOnServices", [serviceCodes]);
        };
        WebapiClientMethods.prototype.getAgentsOnServicesCheckMc1002 = function (serviceCodes, checkMc1002Sync, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 60000; }
            return this.requestChunked("getAgentsOnServicesCheckMc1002", [serviceCodes, checkMc1002Sync], requestTimeout);
        };
        WebapiClientMethods.prototype.getServicesByCode = function (serviceCodes) {
            return this.requestChunked("getServicesByCode", [serviceCodes]);
        };
        WebapiClientMethods.prototype.getServices = function () {
            return this.requestChunked("getServices", []);
        };
        WebapiClientMethods.prototype.setWinWebVersion = function (version) {
            return this.requestPromise("setWinWebVersion", [version]).toPromise();
        };
        WebapiClientMethods.prototype.setClientDetail = function (id, platform, so, release, clientVersion) {
            return this.requestPromise("setClientDetail", [id, platform, so, release, clientVersion]).toPromise();
        };
        WebapiClientMethods.prototype.setAppDetail = function (action) {
            return this.requestPromise("setAppDetail", [action]).toPromise();
        };
        WebapiClientMethods.prototype.ackCallMessage = function (callId, counter) {
            return this.requestPromise("ackCallMessage", [callId, counter]).toPromise();
        };
        WebapiClientMethods.prototype.ticketSearch = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestChunkedUpdate("ticketSearch", [action], requestTimeout).toLiveResult();
        };
        WebapiClientMethods.prototype.ticketEscalatedSearch = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestChunkedUpdate("ticketEscalatedSearch", [action], requestTimeout).toLiveResult();
        };
        WebapiClientMethods.prototype.ticketSearchForMerge = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestChunkedUpdate("ticketSearchForMerge", [action], requestTimeout).toLiveResult();
        };
        WebapiClientMethods.prototype.ticketSearchForLink = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestChunkedUpdate("ticketSearchForLink", [action], requestTimeout).toLiveResult();
        };
        WebapiClientMethods.prototype.ticketGet = function (ticketId, withUpdatePolicy, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromiseUpdate("ticketGet", [ticketId, withUpdatePolicy], requestTimeout).toLiveResult();
        };
        WebapiClientMethods.prototype.ticketGetPreview = function (ticketId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketGetPreview", [ticketId], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketGetArticles = function (ticketId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestChunkedUpdate("ticketGetArticles", [ticketId], requestTimeout).toLiveResult();
        };
        WebapiClientMethods.prototype.ticketGetArticlesLight = function (ticketId, articleIds, serviceCode, callLink, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestChunkedUpdate("ticketGetArticlesLight", [ticketId, articleIds, serviceCode, callLink], requestTimeout).toLiveResult();
        };
        WebapiClientMethods.prototype.ticketGetArticlesPreview = function (ticketId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestChunked("ticketGetArticlesPreview", [ticketId], requestTimeout);
        };
        WebapiClientMethods.prototype.ticketGetArticlesPreviewByArticleId = function (firstArticleId, lastArticleId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestChunked("ticketGetArticlesPreviewByArticleId", [firstArticleId, lastArticleId], requestTimeout);
        };
        WebapiClientMethods.prototype.ticketGetHistory = function (ticketId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestChunkedUpdate("ticketGetHistory", [ticketId], requestTimeout).toLiveResult();
        };
        WebapiClientMethods.prototype.ticketGetLinks = function (ticketId, serviceCodes, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestChunkedUpdate("ticketGetLinks", [ticketId, serviceCodes], requestTimeout).toLiveResult();
        };
        WebapiClientMethods.prototype.ticketAddLinks = function (ticketTargetId, ticketSourceNumber, linkType, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketAddLinks", [ticketTargetId, ticketSourceNumber, linkType], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketDeleteLinks = function (ticketTargetId, ticketSourceId, linkType, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketDeleteLinks", [ticketTargetId, ticketSourceId, linkType], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketAdd = function (ticket, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketAdd", [ticket], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketAddWithAttachments = function (ticket, attachments, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketAddWithAttachments", [ticket, attachments], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketMerge = function (ticketMaster, ticketSlaveId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketMerge", [ticketMaster, ticketSlaveId], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketUpdate = function (ticket, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketUpdate", [ticket], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketMultipleUpdate = function (ticketIdList, field, value, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketMultipleUpdate", [ticketIdList, field, value], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketSetViewByOwner = function (ticket, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketSetViewByOwner", [ticket], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketAddArticle = function (ticket, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketAddArticle", [ticket], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketAddArticleWithAttachments = function (article, attachments, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketAddArticleWithAttachments", [article, attachments], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketSignatureGet = function (serviceCode, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketSignatureGet", [serviceCode], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketGetEmailAddresses = function (requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketGetEmailAddresses", [], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketSetRead = function (ticketId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketSetRead", [ticketId], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketGetFieldConfigs = function (requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketGetFieldConfigs", [], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketGetInboundEmailAddressOnService = function (serviceCode, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketGetInboundEmailAddressOnService", [serviceCode], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketGetSettings = function (requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketGetSettings", [], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketStartSession = function (ticketId, interactionId, action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketStartSession", [ticketId, interactionId, action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketStopSession = function (ticketId, interactionId, action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketStopSession", [ticketId, interactionId, action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketIsAcdOnAgentBar = function (ticketId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("ticketIsAcdOnAgentBar", [ticketId], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.customerPortalIsCustomerRegistered = function (customerEmail, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("customerPortalIsCustomerRegistered", [customerEmail], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.customerPortalGetCustomerSettings = function (t4youUid, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("customerPortalGetCustomerSettings", [t4youUid], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.customerPortalSetCustomerSettings = function (cps, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("customerPortalSetCustomerSettings", [cps], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.customerPortalRestoreCustomerPassword = function (cps, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 15000; }
            return this.requestPromise("customerPortalRestoreCustomerPassword", [cps], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.getWebrtcConfiguration = function () {
            return this.requestPromise("getWebrtcConfiguration", []).toPromise();
        };
        WebapiClientMethods.prototype.lookupSearch = function (value) {
            return this.requestChunked("lookupSearch", [value]);
        };
        WebapiClientMethods.prototype.callLookupSearch = function (value) {
            return this.requestChunked("callLookupSearch", [value]);
        };
        WebapiClientMethods.prototype.startChatSessionNotify = function () {
            return this.requestPromiseUpdate("startChatSessionNotify", []).toLiveResult();
        };
        WebapiClientMethods.prototype.sendChatEventMessage = function (chatId, message) {
            return this.requestPromise("sendChatEventMessage", [chatId, message]).toPromise();
        };
        WebapiClientMethods.prototype.searchChatMessageChannel = function (action) {
            return this.requestChunkedUpdate("searchChatMessageChannel", [action]).toLiveResult();
        };
        WebapiClientMethods.prototype.chatAgentReceivedMessage = function (action) {
            return this.requestPromise("chatAgentReceivedMessage", [action]).toPromise();
        };
        WebapiClientMethods.prototype.chatAgentReadMessage = function (action) {
            return this.requestPromise("chatAgentReadMessage", [action]).toPromise();
        };
        WebapiClientMethods.prototype.channelInfoHistoryItemSearch = function (action) {
            return this.requestChunked("channelInfoHistoryItemSearch",
            [action]);
        };
        WebapiClientMethods.prototype.chatUpdateFile = function (file) {
            return this.requestPromise("chatUpdateFile", [file]).toPromise();
        };
        WebapiClientMethods.prototype.channelInfoHistoryFileSearch = function (action) {
            return this.requestChunked("channelInfoHistoryFileSearch",
            [action]);
        };
        WebapiClientMethods.prototype.widgetJourneySearch = function (action) {
            return this.requestChunkedUpdate("widgetJourneySearch", [action]).toLiveResult();
        };
        WebapiClientMethods.prototype.moveInteractionToContact = function (moveInteraction) {
            return this.requestPromise("moveInteractionToContact", [moveInteraction]).toPromise();
        };
        WebapiClientMethods.prototype._internalTest_updateContactOnInteraction = function (moveInteraction) {
            return this.requestPromise("_internalTest_updateContactOnInteraction", [moveInteraction]).toPromise();
        };
        WebapiClientMethods.prototype.getServicesByChannel = function (action) {
            return this.requestChunked("getServicesByChannel", [action]);
        };
        WebapiClientMethods.prototype.transferChannelToService = function (callId, serviceCode) {
            return this.requestPromise("transferChannelToService", [callId, serviceCode]).toPromise();
        };
        WebapiClientMethods.prototype.setOutboundCallBlocked = function (active) {
            return this.requestPromise("setOutboundCallBlocked", [active]).toPromise();
        };
        WebapiClientMethods.prototype.chatSendRecapOfSession = function (action) {
            return this.requestPromise("chatSendRecapOfSession", [action]).toPromise();
        };
        WebapiClientMethods.prototype.callbackRequestSearchClosed = function (searchAction) {
            return this.requestChunked("callbackRequestSearchClosed", [searchAction]);
        };
        WebapiClientMethods.prototype.callbackRequestSearchOpen = function (searchAction) {
            return this.requestChunkedUpdate("callbackRequestSearchOpen", [searchAction]).toLiveResult();
        };
        WebapiClientMethods.prototype.callbackRequestsSearchOpenPaginated = function (searchAction, page, size, order) {
            return this.requestChunked("callbackRequestsSearchOpenPaginated", [searchAction, page, size, order]);
        };
        WebapiClientMethods.prototype.callbackRequestClose = function (id) {
            return this.requestPromise("callbackRequestClose", [id]).toPromise();
        };
        WebapiClientMethods.prototype.callbackRequestDelete = function (id) {
            return this.requestPromise("callbackRequestDelete", [id]).toPromise();
        };
        WebapiClientMethods.prototype.callbackRequestUnlock = function (id, force) {
            return this.requestPromise("callbackRequestUnlock", [id, force]).toPromise();
        };
        WebapiClientMethods.prototype.callbackRequestLock = function (id) {
            return this.requestPromise("callbackRequestLock", [id]).toPromise();
        };
        WebapiClientMethods.prototype.callbackRequestUpdateNote = function (id, startTime, note) {
            return this.requestPromise("callbackRequestUpdateNote", [id, startTime, note]).toPromise();
        };
        WebapiClientMethods.prototype.getInsightUrl = function () {
            return this.requestPromise("getInsightUrl", []).toPromise();
        };
        WebapiClientMethods.prototype.searchADSAlarmHistory = function () {
            return this.requestChunked("searchADSAlarmHistory", []);
        };
        WebapiClientMethods.prototype.startDelayedTaskNotify = function () {
            return this.requestPromiseUpdate("startDelayedTaskNotify", []).response;
        };
        WebapiClientMethods.prototype.startADSAlarmNotify = function () {
            return this.requestPromiseUpdate("startADSAlarmNotify", []).response;
        };
        WebapiClientMethods.prototype.validateAddressBookContactField = function (uid, field, position) {
            return this.requestPromise("validateAddressBookContactField", [uid, field, position]).toPromise();
        };
        WebapiClientMethods.prototype.setCensusResult = function (userInteractionId, result, backend, number) {
            if (backend === void 0) { backend = null; }
            if (number === void 0) { number = null; }
            return this.requestPromise("setCensusResult", backend == null ? [userInteractionId, result] : [userInteractionId, result, backend, number]).toPromise();
        };
        WebapiClientMethods.prototype.getCustomerJourney = function (uidContact, page, size, agentFilter) {
            return this.requestChunked("getCustomerJourney", [uidContact, page, size, agentFilter]);
        };
        WebapiClientMethods.prototype.getCustomerJourneyInteractionAmounts = function (uidContact, agentFilter) {
            return this.requestPromise("getCustomerJourneyInteractionAmounts", [uidContact, agentFilter]).toPromise();
        };
        WebapiClientMethods.prototype.searchLoggedProfileByChannel = function (action) {
            return this.requestChunked("searchLoggedProfileByChannel", [action]);
        };
        WebapiClientMethods.prototype.usersThatWaitToSetNR = function () {
            return this.requestChunkedUpdate("usersThatWaitToSetNR", []).toLiveResult();
        };
        WebapiClientMethods.prototype.acceptRequestToSetNR = function (username) {
            return this.requestPromise("acceptRequestToSetNR", [username]).toPromise();
        };
        WebapiClientMethods.prototype.denyRequestToSetNR = function (username) {
            return this.requestPromise("denyRequestToSetNR", [username]).toPromise();
        };
        WebapiClientMethods.prototype.setUserStatusNotReadyAskingToSupervisor = function () {
            return this.requestPromise("setUserStatusNotReadyAskingToSupervisor", []).toPromise();
        };
        WebapiClientMethods.prototype.resetRequestNRToSupervisor = function () {
            return this.requestPromise("resetRequestNRToSupervisor", []).toPromise();
        };
        WebapiClientMethods.prototype.getActiveLicense = function () {
            return this.requestPromise("getActiveLicense", []).toPromise();
        };
        WebapiClientMethods.prototype.getListOfNumbersWithInternationalPrefix = function (number) {
            return this.requestPromise("getListOfNumbersWithInternationalPrefix", [number]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterGetFieldByScope = function (scope) {
            return this.requestPromise("searchFilterGetFieldByScope", [scope]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterSearch = function (scopeApplication, stringToSearch) {
            return this.requestPromise("searchFilterSearch", [scopeApplication, stringToSearch]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterGetById = function (searchFilterId) {
            return this.requestPromise("searchFilterGetById", [searchFilterId]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterGetByIdList = function (searchFilterIdList) {
            return this.requestPromise("searchFilterGetByIdList", [searchFilterIdList]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterAdd = function (searchFilter) {
            return this.requestPromise("searchFilterAdd", [searchFilter]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterUpdate = function (searchFilter) {
            return this.requestPromise("searchFilterUpdate", [searchFilter]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterDelete = function (searchFilterId) {
            return this.requestPromise("searchFilterDelete", [searchFilterId]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterOnUserByApplication = function (scopeApplication) {
            return this.requestPromise("searchFilterOnUserByApplication", [scopeApplication]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterAddOnUserByApplication = function (searchFilterId, scopeApplication) {
            return this.requestPromise("searchFilterAddOnUserByApplication", [searchFilterId, scopeApplication]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterDeleteOnUserByApplication = function (searchFilterId, scopeApplication) {
            return this.requestPromise("searchFilterDeleteOnUserByApplication", [searchFilterId, scopeApplication]).toPromise();
        };
        WebapiClientMethods.prototype.sendCommandResponse = function (commandResult) {
            return this.requestPromise("sendCommandResponse", [commandResult]).toPromise();
        };
        WebapiClientMethods.prototype.publishNewIncomingCall = function (callEvent) {
            return this.requestPromise("publishNewIncomingCall", [callEvent]).toPromise();
        };
        WebapiClientMethods.prototype.publishNewOutgoingCall = function (callEvent) {
            return this.requestPromise("publishNewOutgoingCall", [callEvent]).toPromise();
        };
        WebapiClientMethods.prototype.publishEvent = function (event) {
            return this.requestPromise("publishEvent", [event]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterEnable = function (searchFilterId) {
            return this.requestPromise("searchFilterEnable", [searchFilterId]).toPromise();
        };
        WebapiClientMethods.prototype.searchFilterDisable = function (searchFilterId) {
            return this.requestPromise("searchFilterDisable", [searchFilterId]).toPromise();
        };
        WebapiClientMethods.prototype.searchCampaign = function (action) {
            return this.requestChunked("searchCampaign", [action]);
        };
        WebapiClientMethods.prototype.startCampaign = function (action) {
            return this.requestPromise("startCampaign", [action]).toPromise();
        };
        WebapiClientMethods.prototype.stopCampaign = function (action) {
            return this.requestPromise("stopCampaign", [action]).toPromise();
        };
        WebapiClientMethods.prototype.getCampaignStatus = function () {
            return this.requestChunkedUpdate("getCampaignStatus", []).toLiveResult();
        };
        WebapiClientMethods.prototype.searchCampaignProcessedByRunId = function (action) {
            return this.requestChunked("searchCampaignProcessedByRunId", [action]);
        };
        WebapiClientMethods.prototype.exportCampaignRunIdDetail = function (runEndtime, runId, type) {
            return this.requestPromise("exportCampaignRunIdDetail", [runEndtime, runId, type]).toPromise();
        };
        WebapiClientMethods.prototype.createCampaign = function (action) {
            return this.requestPromise("createCampaign", [action]).toPromise();
        };
        WebapiClientMethods.prototype.setCampaign = function (campaign) {
            return this.requestPromise("setCampaign", [campaign]).toPromise();
        };
        WebapiClientMethods.prototype.getCampaign = function (id) {
            return this.requestPromise("getCampaign", [id]).toPromise();
        };
        WebapiClientMethods.prototype.updateImgProfile = function (img, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 30000; }
            return this.requestPromise("updateImgProfile", [img], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketGetArticlesTimeAccounting = function (ticketId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("ticketGetArticlesTimeAccounting", [ticketId], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketGetMergedArticlesTimeAccounting = function (ticketArticleIdList, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("ticketGetMergedArticlesTimeAccounting", [ticketArticleIdList], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.ticketGetArticleTimeAccounting = function (ticketId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("ticketGetArticleTimeAccounting", [ticketId], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.knowledgeBaseSearch = function (knowledgeBaseId, categoryId, query) {
            return this.requestPromise("knowledgeBaseSearch", [knowledgeBaseId, categoryId, query]).toPromise();
        };
        WebapiClientMethods.prototype.knowledgeBaseSetAnswerOnCall = function (interactionId, callId, answerId, answerUrl) {
            return this.requestPromise("knowledgeBaseSetAnswerOnCall", [interactionId, callId, answerId, answerUrl]).toPromise();
        };
        WebapiClientMethods.prototype.knowledgeBaseSetNotFoundAnswerOnCall = function (interactionId, callId) {
            return this.requestPromise("knowledgeBaseSetNotFoundAnswerOnCall", [interactionId, callId]).toPromise();
        };
        WebapiClientMethods.prototype.knowledgeBaseSetNoAnswerOnCall = function (interactionId, callId) {
            return this.requestPromise("knowledgeBaseSetNoAnswerOnCall", [interactionId, callId]).toPromise();
        };
        WebapiClientMethods.prototype.knowledgeBaseSetAnswerOnTicket = function (ticketId, answerId, answerUrl) {
            return this.requestPromise("knowledgeBaseSetAnswerOnTicket", [ticketId, answerId, answerUrl]).toPromise();
        };
        WebapiClientMethods.prototype.knowledgeBaseSetNoAnswerOnTicket = function (ticketId) {
            return this.requestPromise("knowledgeBaseSetNoAnswerOnTicket", [ticketId]).toPromise();
        };
        WebapiClientMethods.prototype.knowledgeBaseSetCategoryOnTicket = function (ticketId, categoryId, categoryUrl) {
            return this.requestPromise("knowledgeBaseSetCategoryOnTicket", [ticketId, categoryId, categoryUrl]);
        };
        WebapiClientMethods.prototype.knowledgeBaseGetAnswerHits = function (answerId) {
            return this.requestPromise("knowledgeBaseGetAnswerHits", [answerId]);
        };
        WebapiClientMethods.prototype.ticketAddArticleByCopy = function (originalArticle, destinationTicketId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("ticketAddArticleByCopy", [originalArticle, destinationTicketId], requestTimeout);
        };
        WebapiClientMethods.prototype.omnideskCreateMeeting = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskCreateMeeting", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskCreateScheduledMeeting = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskCreateScheduledMeeting", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskSetScheduledMeeting = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskSetScheduledMeeting", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskUpdateScheduleMeeting = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskUpdateScheduleMeeting", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskCreateChatGroupForMeeting = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskCreateChatGroupForMeeting", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskDeleteScheduledMeetingEvent = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskDeleteScheduledMeetingEvent", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskGetMeeting = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskGetMeeting", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskSearchMeeting = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 30000; }
            return this.requestChunked("omnideskSearchMeeting", [action], requestTimeout);
        };
        WebapiClientMethods.prototype.omnideskGetParticipantToken = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskGetParticipantToken", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskGetJwt = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskGetJwt", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskAddParticipantToMeeting = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskAddParticipantToMeeting", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskResetParticipantToken = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskResetParticipantToken", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskLeaveMeeting = function (meetingParticipantId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskLeaveMeeting", [meetingParticipantId], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskCloseMeeting = function (meetingId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskCloseMeeting", [meetingId], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskGenerateLinkToMeeting = function (meetingId, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskGenerateLinkToMeeting", [meetingId], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskRemoveParticipantFromMeeting = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskRemoveParticipantFromMeeting", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskResumeMeeting = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskResumeMeeting", [action], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.omnideskResetLostMeetingOnContact = function (contact, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("omnideskResetLostMeetingOnContact", [contact], requestTimeout).toPromise();
        };
        WebapiClientMethods.prototype.startClientCommandNotify = function () {
            return __awaiter$a(this, void 0, void 0, function () {
                return __generator$9(this, function (_a) {
                    return [2 , this.commandNotification.start()];
                });
            });
        };
        WebapiClientMethods.prototype.stopClientCommandNotify = function () {
            return __awaiter$a(this, void 0, void 0, function () {
                return __generator$9(this, function (_a) {
                    return [2 , this.commandNotification.stop()];
                });
            });
        };
        WebapiClientMethods.prototype.sendClientCommandResponse = function (commandResult) {
            return __awaiter$a(this, void 0, void 0, function () {
                return __generator$9(this, function (_a) {
                    return [2 , this.requestPromise("sendClientCommandResponse", [commandResult]).toPromise()];
                });
            });
        };
        WebapiClientMethods.prototype.getUserDetailLight = function () {
            return this.requestPromise("getUserDetailLight", []);
        };
        WebapiClientMethods.prototype.sendFeedback = function (action, requestTimeout) {
            if (requestTimeout === void 0) { requestTimeout = 120000; }
            return this.requestPromise("sendFeedback", [action], requestTimeout).toPromise();
        };
        return WebapiClientMethods;
    }(Methods));

    function exceptionInitializer$1(exception, availableError) {
        return exceptionInstantiator(exception && exception.exceptionName ? exception.exceptionName.replace("com.telenia.webapi.tvox.webclient.exception.", "").replace("com.telenia.webapi.exception.", "").replace("telenia.tvox.webapi.services.exceptions.", "").replace("Exception", "") : null, exception, availableError);
    }
    function exceptionInstantiator(exceptionName, exception, availableError) {
        if (exception instanceof Error) {
            return exception;
        }
        else if (exceptionName && availableError && availableError[exceptionName]) {
            if (exception && exception instanceof availableError[exceptionName]) {
                return exception;
            }
            else {
                return new availableError[exceptionName](exception);
            }
        }
        else {
            if (exception && exception instanceof WebAPI) {
                return exception;
            }
            else {
                return new WebAPI(exception);
            }
        }
    }

    function exceptionInitializer(exception) {
        try {
            return exceptionInitializer$1(exception, Errors);
        }
        catch (e) {
            return e;
        }
    }
    var ErrorResolver =  (function () {
        function ErrorResolver() {
        }
        ErrorResolver.login = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.logout = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getUserDetail = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.useProfile = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.useDevice = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.inboundCallExtension = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchUsers = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getListOfCompany = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchUsersExtended = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchUsersExtendedByBackend = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getUserSites = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getUnreadChat = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getUserContactStatus = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getAddressBookContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getAddressBookContactByUuid = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getFavouriteContacts = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.addFavouriteItemGroup = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setFavouriteItemGroup = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setFavouriteItemGroups = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.delFavouriteItemGroup = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setFavouriteItemContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.addFavouriteItemContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.delFavouriteItemContactFromGroup = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startCallNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.isInternalNumber = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getAllServiceCode = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.stopCallNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startVideoSessionNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.stopVideoSessionNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.dial = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.dialCallTagging = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.answer = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.cancel = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.hold = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.unhold = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.attendedTransfer = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.blindTransfer = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.blindTransferMultiChannelToUser = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setCallData = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.sendDTMF = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.stopRecord = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startRecord = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.updateCallRecordingNoted = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.chanSpyUser = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getFavouriteUserGroups = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.delFavouriteItemContactFromGroups = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.addFavouriteItemContactToGroups = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getServicesCallQueue = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getSkillsetsCallQueue = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getClientConfig = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setClientConfig = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setUserStatusReady = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setUserStatusNotReady = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setUserStatusWorkNotReady = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setActivityCode = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.enterOnConferenceRoom = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.transferToConferenceRoom = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.kickOffAllFromConferenceRoom = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.updateWebRTCFields = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getAddressBooks = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.addAddressBookContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setAddressBookContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.mergeAddressBookContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setAgentNoteOnAddressBookContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.delAddressBookContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.acquireWebRTCSession = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.freeWebRTCSession = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.mute = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.unmute = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startVideoOnCall = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.stopVideoOnCall = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getExternalCustomFieldConfigs = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getInternalCustomFieldConfigs = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchUserCallHistoryItems = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchUserChatHistoryItems = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setUserCallHistoryItem = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.delUserCallHistoryItem = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.resetUserCallHistoryItems = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.resetUserCallHistoryItemsByContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getClassConfigurationPermission = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getConfiguration = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.resetPassword = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.resetPin = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setDirectoryFields = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setName = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setSurname = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setCallFowardSettings = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setVoicemailSettings = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setConferenceSettings = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getServiceForCallFoward = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFaxDocument = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getQueuedFaxDocument = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.sendFaxDocument = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.sendSms = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.stopEnqueuedFaxDocument = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.deleteFaxDocument = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.deleteFaxDocumentFromFileSystem = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.updateFaxDocument = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.restartSessionId = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setCallResult = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getUserInteractions = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.closeUserInteraction = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startUserInteraction = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.removeCallFromUserInteraction = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.updateUserInteraction = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setPinnedUserInteraction = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.delUserInteractions = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getCurrentCalls = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setServiceStatusVisible = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getClientParams = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setClientParam = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getGeneralParams = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.exportAddressBook = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.importAddressBook = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getAllCategories = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getWorkingSessions = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.closeWorkingSessions = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startWorkingSession = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getCurrentWorkingSessions = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startAnonymousWorkingSession = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getAllActivityCode = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getRoomDeskConfig = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getActiveServiceCalls = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.servicePickup = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.servicePickupPrivateParkedCall = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.updateWorkingSessions = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.createUserInteraction = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setDND = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.tqmParkPrivate = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.tqmParkPublic = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.freeDevice = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.abandonedCallsSearchClosed = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.abandonedCallsSearchOpened = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.abandonedCallClose = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.abandonedCallDelete = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.abandonedCallRetryExceeded = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.abandonedCallUnlock = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.abandonedCallLock = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.abandonedCallUpdateNote = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getAgentsOnServices = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getAgentsOnServicesCheckMc1002 = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getServicesByCode = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getServices = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getWebrtcConfiguration = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setWinWebVersion = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setClientDetail = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketSearch = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketEscalatedSearch = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketSearchForMerge = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketSearchForLink = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGet = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetPreview = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetArticles = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetArticlesLight = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetArticlesPreviewByArticleId = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetArticlesPreview = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetHistory = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetLinks = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketAddLinks = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.prototype.ticketDeleteLinks = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketAdd = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketAddWithAttachments = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketMerge = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketUpdate = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketMultipleUpdate = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketSetViewByOwner = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketAddArticle = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketAddArticleWithAttachments = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketSignatureGet = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetEmailAddresses = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketSetRead = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetFieldConfigs = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetInboundEmailAddressOnServiceerror = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetSettings = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketStartSession = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketStopSession = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketIsAcdOnAgentBar = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.customerPortalIsCustomerRegistered = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.customerPortalSetCustomerSettings = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.customerPortalGetCustomerSettings = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.customerPortalRestoreCustomerPassword = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.lookupSearch = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.callLookupSearch = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startChatSessionNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.sendChatEventMessage = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.moveInteractionToContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.widgetJourneySearch = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver._internalTest_updateContactOnInteraction = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getServicesByChannel = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.transferChannelToService = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchChatMessageChannel = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.chatAgentReceivedMessage = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.chatAgentReadMessage = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setOutboundCallBlocked = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setOutboundCchatSendRecapOfSessionallBlocked = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.callbackRequestSearchClosed = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.callbackRequestSearchOpen = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.callbackRequestsSearchOpenPaginated = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.callbackRequestClose = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.callbackRequestDelete = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.callbackRequestUnlock = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.callbackRequestLock = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.callbackRequestUpdateNote = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getInsightUrl = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchADSAlarmHistory = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.validateAddressBookContactField = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setCensusResult = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getCustomerJourney = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getCustomerJourneyInteractionsInfo = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchLoggedProfileByChannel = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.usersThatWaitToSetNR = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.acceptRequestToSetNR = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.denyRequestToSetNR = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setUserStatusNotReadyAskingToSupervisor = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.resetRequestNRToSupervisor = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getActiveLicense = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getListOfNumbersWithInternationalPrefix = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterGetFieldByScope = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterSearch = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterGetById = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterAdd = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterUpdate = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterDelete = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterOnUserByApplication = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterAddOnUserByApplication = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterDeleteOnUserByApplication = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.sendCommandResponse = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.publishNewIncomingCall = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.publishNewOutgoingCall = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.publishEvent = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterEnable = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterDisable = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchFilterGetByIdList = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchCampaign = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startCampaign = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.stopCampaign = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getCampaignStatus = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.searchCampaignProcessedByRunId = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.exportCampaignRunIdDetail = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.createCampaign = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.setCampaign = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getCampaign = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.updateImgProfile = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.updateImgPticketGetArticlesTimeAccountingrofile = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.updateImgPticketGetArticleTimeAccountingrofile = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.knowledgeBaseSearch = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.knowledgeBaseSetAnswerOnCall = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.knowledgeBaseSetNoAnswerOnCall = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.knowledgeBaseSetNotFoundAnswerOnCall = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.knowledgeBaseSetAnswerOnTicket = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.knowledgeBaseSetNoAnswerOnTicket = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.knowledgeBaseSetCategoryOnTicket = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.knowledgeBaseGetAnswerHits = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.channelInfoHistoryItemSearch = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketAddArticleByCopy = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.ticketGetMergedArticlesTimeAccounting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.cleanUserInteractions = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.channelInfoHistoryFileSearch = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.chatUpdateFile = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.monitorContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getIntranetPages = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getIntranetPage = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startNoteCounterTotalNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startOmnideskCounterTotalNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startNoteUpdateNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.getOmnideskUriAccess = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.resumeChatToken = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskCreateMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskAddParticipantToMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskGetParticipantToken = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskResetParticipantToken = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskCloseMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskLeaveMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskGenerateLinkToMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskGetJwt = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskRemoveParticipantFromMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskResumeMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskUpdateScheduleMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskCreateChatGroupForMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startClientCommandNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.contactNoteExpiredNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.contactNoteReminderNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskScheduledMeetingNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.sendClientCommandResponse = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.forgetAddressBookContact = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskCreateScheduledMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskSetScheduledMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskDeleteScheduledMeetingEvent = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskGetMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskSearchMeeting = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.sendFeedback = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startADSAlarmNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.startDelayedTaskNotify = function (error) {
            return exceptionInitializer(error);
        };
        ErrorResolver.omnideskResetLostMeetingOnContact = function (error) {
            return exceptionInitializer(error);
        };
        return ErrorResolver;
    }());

    var LocalStoreManager =  (function () {
        function LocalStoreManager() {
            var _this = this;
            this.syncKeys = [];
            this._dbEvent = new Subject();
            this.reservedKeys = ["sync_keys", "addToSyncKeys", "removeFromSyncKeys", "getSessionStorage", "setSessionStorage", "addToSessionStorage", "removeFromSessionStorage", "clearAllSessionsStorage", "raiseDBEvent"];
            this.sessionStorageTransferHandler = function (event) {
                if (!event.newValue)
                    return;
                if (event.key == "getSessionStorage") {
                    if (sessionStorage.length) {
                        localStorage.setItem("setSessionStorage", JSON.stringify(sessionStorage, MapOrSet_toJSON));
                        localStorage.removeItem("setSessionStorage");
                    }
                }
                else if (event.key == "setSessionStorage") {
                    if (!_this.syncKeys.length)
                        _this.loadSyncKeys();
                    var data = JSON.parse(event.newValue);
                    for (var key in data) {
                        if (_this.syncKeysContains(key))
                            sessionStorage.setItem(key, data[key]);
                    }
                }
                else if (event.key == "addToSessionStorage") {
                    var data = JSON.parse(event.newValue);
                    _this.addToSessionStorageHelper(data["data"], data["key"]);
                }
                else if (event.key == "removeFromSessionStorage") {
                    _this.removeFromSessionStorageHelper(event.newValue);
                }
                else if (event.key == "clearAllSessionsStorage" && sessionStorage.length) {
                    _this.clearInstanceSessionStorage();
                }
                else if (event.key == "addToSyncKeys") {
                    _this.addToSyncKeysHelper(event.newValue);
                }
                else if (event.key == "removeFromSyncKeys") {
                    _this.removeFromSyncKeysHelper(event.newValue);
                }
                else if (event.key == "raiseDBEvent") {
                    _this.raiseDBEventHelper(event.newValue);
                }
            };
        }
        LocalStoreManager.prototype.initialiseStorageSyncListener = function () {
            if (LocalStoreManager.syncListenerInitialised == true)
                return;
            LocalStoreManager.syncListenerInitialised = true;
            window.addEventListener("storage", this.sessionStorageTransferHandler, false);
            this.syncSessionStorage();
        };
        LocalStoreManager.prototype.deinitialiseStorageSyncListener = function () {
            window.removeEventListener("storage", this.sessionStorageTransferHandler, false);
            LocalStoreManager.syncListenerInitialised = false;
        };
        LocalStoreManager.prototype.syncSessionStorage = function () {
            localStorage.setItem("getSessionStorage", "_dummy");
            localStorage.removeItem("getSessionStorage");
        };
        LocalStoreManager.prototype.clearAllStorage = function () {
            this.clearAllSessionsStorage();
            this.clearLocalStorage();
        };
        LocalStoreManager.prototype.clearAllSessionsStorage = function () {
            this.clearInstanceSessionStorage();
            localStorage.removeItem(LocalStoreManager.DBKEY_SYNC_KEYS);
            localStorage.setItem("clearAllSessionsStorage", "_dummy");
            localStorage.removeItem("clearAllSessionsStorage");
        };
        LocalStoreManager.prototype.clearInstanceSessionStorage = function () {
            sessionStorage.clear();
            this.syncKeys = [];
        };
        LocalStoreManager.prototype.clearLocalStorage = function () {
            localStorage.clear();
        };
        LocalStoreManager.prototype.addToSessionStorage = function (data, key) {
            this.addToSessionStorageHelper(data, key);
            this.addToSyncKeysBackup(key);
            localStorage.setItem("addToSessionStorage", JSON.stringify({ key: key, data: data }, MapOrSet_toJSON));
            localStorage.removeItem("addToSessionStorage");
        };
        LocalStoreManager.prototype.addToSessionStorageHelper = function (data, key) {
            this.addToSyncKeysHelper(key);
            sessionStorage.setItem(key, data);
        };
        LocalStoreManager.prototype.removeFromSessionStorage = function (keyToRemove) {
            this.removeFromSessionStorageHelper(keyToRemove);
            this.removeFromSyncKeysBackup(keyToRemove);
            localStorage.setItem("removeFromSessionStorage", keyToRemove);
            localStorage.removeItem("removeFromSessionStorage");
        };
        LocalStoreManager.prototype.removeFromSessionStorageHelper = function (keyToRemove) {
            sessionStorage.removeItem(keyToRemove);
            this.removeFromSyncKeysHelper(keyToRemove);
        };
        LocalStoreManager.prototype.testForInvalidKeys = function (key) {
            if (!key)
                throw new Error("key cannot be empty");
            if (this.reservedKeys.some(function (x) { return x == key; }))
                throw new Error("The storage key \"" + key + "\" is reserved and cannot be used. Please use a different key");
        };
        LocalStoreManager.prototype.syncKeysContains = function (key) {
            return this.syncKeys.some(function (x) { return x == key; });
        };
        LocalStoreManager.prototype.loadSyncKeys = function () {
            if (this.syncKeys.length)
                return;
            this.syncKeys = this.getSyncKeysFromStorage();
        };
        LocalStoreManager.prototype.getSyncKeysFromStorage = function (defaultValue) {
            if (defaultValue === void 0) { defaultValue = []; }
            var data = localStorage.getItem(LocalStoreManager.DBKEY_SYNC_KEYS);
            if (data == null)
                return defaultValue;
            else
                return JSON.parse(data);
        };
        LocalStoreManager.prototype.addToSyncKeys = function (key) {
            this.addToSyncKeysHelper(key);
            this.addToSyncKeysBackup(key);
            localStorage.setItem("addToSyncKeys", key);
            localStorage.removeItem("addToSyncKeys");
        };
        LocalStoreManager.prototype.addToSyncKeysBackup = function (key) {
            var storedSyncKeys = this.getSyncKeysFromStorage();
            if (!storedSyncKeys.some(function (x) { return x == key; })) {
                storedSyncKeys.push(key);
                localStorage.setItem(LocalStoreManager.DBKEY_SYNC_KEYS, JSON.stringify(storedSyncKeys, MapOrSet_toJSON));
            }
        };
        LocalStoreManager.prototype.removeFromSyncKeysBackup = function (key) {
            var storedSyncKeys = this.getSyncKeysFromStorage();
            var index = storedSyncKeys.indexOf(key);
            if (index > -1) {
                storedSyncKeys.splice(index, 1);
                localStorage.setItem(LocalStoreManager.DBKEY_SYNC_KEYS, JSON.stringify(storedSyncKeys, MapOrSet_toJSON));
            }
        };
        LocalStoreManager.prototype.addToSyncKeysHelper = function (key) {
            if (!this.syncKeysContains(key))
                this.syncKeys.push(key);
        };
        LocalStoreManager.prototype.removeFromSyncKeys = function (key) {
            this.removeFromSyncKeysHelper(key);
            this.removeFromSyncKeysBackup(key);
            localStorage.setItem("removeFromSyncKeys", key);
            localStorage.removeItem("removeFromSyncKeys");
        };
        LocalStoreManager.prototype.removeFromSyncKeysHelper = function (key) {
            var index = this.syncKeys.indexOf(key);
            if (index > -1) {
                this.syncKeys.splice(index, 1);
            }
        };
        LocalStoreManager.prototype.saveSessionData = function (data, key) {
            if (key === void 0) { key = LocalStoreManager.DBKEY_USER_DATA; }
            this.testForInvalidKeys(key);
            this.removeFromSyncKeys(key);
            localStorage.removeItem(key);
            sessionStorage.setItem(key, data);
        };
        LocalStoreManager.prototype.saveSyncedSessionData = function (data, key) {
            if (key === void 0) { key = LocalStoreManager.DBKEY_USER_DATA; }
            this.testForInvalidKeys(key);
            localStorage.removeItem(key);
            this.addToSessionStorage(data, key);
        };
        LocalStoreManager.prototype.savePermanentData = function (data, key) {
            if (key === void 0) { key = LocalStoreManager.DBKEY_USER_DATA; }
            this.testForInvalidKeys(key);
            this.removeFromSessionStorage(key);
            localStorage.setItem(key, data);
        };
        LocalStoreManager.prototype.moveDataToSessionStorage = function (key) {
            if (key === void 0) { key = LocalStoreManager.DBKEY_USER_DATA; }
            this.testForInvalidKeys(key);
            var data = this.getData(key);
            if (data == null)
                return;
            this.saveSessionData(data, key);
        };
        LocalStoreManager.prototype.moveDataToSyncedSessionStorage = function (key) {
            if (key === void 0) { key = LocalStoreManager.DBKEY_USER_DATA; }
            this.testForInvalidKeys(key);
            var data = this.getData(key);
            if (data == null)
                return;
            this.saveSyncedSessionData(data, key);
        };
        LocalStoreManager.prototype.moveDataToPermanentStorage = function (key) {
            if (key === void 0) { key = LocalStoreManager.DBKEY_USER_DATA; }
            this.testForInvalidKeys(key);
            var data = this.getData(key);
            if (data == null)
                return;
            this.savePermanentData(data, key);
        };
        LocalStoreManager.prototype.getData = function (key) {
            if (key === void 0) { key = LocalStoreManager.DBKEY_USER_DATA; }
            this.testForInvalidKeys(key);
            var data = sessionStorage.getItem(key);
            if (data == null)
                data = localStorage.getItem(key);
            return data;
        };
        LocalStoreManager.prototype.getDataObject = function (key) {
            if (key === void 0) { key = LocalStoreManager.DBKEY_USER_DATA; }
            var data = this.getData(key);
            if (data != null)
                return JSON.parse(data);
            else
                return null;
        };
        LocalStoreManager.prototype.deleteData = function (key) {
            if (key === void 0) { key = LocalStoreManager.DBKEY_USER_DATA; }
            this.testForInvalidKeys(key);
            this.removeFromSessionStorage(key);
            localStorage.removeItem(key);
        };
        LocalStoreManager.prototype.raiseDBEvent = function (event) {
            this.raiseDBEventHelper(event);
            localStorage.setItem("raiseDBEvent", event);
            localStorage.removeItem("raiseDBEvent");
        };
        LocalStoreManager.prototype.raiseDBEventHelper = function (event) {
            this._dbEvent.next(event);
        };
        LocalStoreManager.prototype.getDBEventListener = function () {
            return this._dbEvent.asObservable();
        };
        LocalStoreManager.syncListenerInitialised = false;
        LocalStoreManager.DBKEY_USER_DATA = "user_data";
        LocalStoreManager.DBKEY_SYNC_KEYS = "sync_keys";
        return LocalStoreManager;
    }());

    function RetryOperation(timeouts, options) {
      if (typeof options === 'boolean') {
        options = { forever: options };
      }
      this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
      this._timeouts = timeouts;
      this._options = options || {};
      this._maxRetryTime = options && options.maxRetryTime || Infinity;
      this._fn = null;
      this._errors = [];
      this._attempts = 1;
      this._operationTimeout = null;
      this._operationTimeoutCb = null;
      this._timeout = null;
      this._operationStart = null;
      if (this._options.forever) {
        this._cachedTimeouts = this._timeouts.slice(0);
      }
    }
    var retry_operation = RetryOperation;
    RetryOperation.prototype.reset = function() {
      this._attempts = 1;
      this._timeouts = this._originalTimeouts;
    };
    RetryOperation.prototype.stop = function() {
      if (this._timeout) {
        clearTimeout(this._timeout);
      }
      this._timeouts       = [];
      this._cachedTimeouts = null;
    };
    RetryOperation.prototype.retry = function(err) {
      if (this._timeout) {
        clearTimeout(this._timeout);
      }
      if (!err) {
        return false;
      }
      var currentTime = new Date().getTime();
      if (err && currentTime - this._operationStart >= this._maxRetryTime) {
        this._errors.unshift(new Error('RetryOperation timeout occurred'));
        return false;
      }
      this._errors.push(err);
      var timeout = this._timeouts.shift();
      if (timeout === undefined) {
        if (this._cachedTimeouts) {
          this._errors.splice(this._errors.length - 1, this._errors.length);
          this._timeouts = this._cachedTimeouts.slice(0);
          timeout = this._timeouts.shift();
        } else {
          return false;
        }
      }
      var self = this;
      var timer = setTimeout(function() {
        self._attempts++;
        if (self._operationTimeoutCb) {
          self._timeout = setTimeout(function() {
            self._operationTimeoutCb(self._attempts);
          }, self._operationTimeout);
          if (self._options.unref) {
              self._timeout.unref();
          }
        }
        self._fn(self._attempts);
      }, timeout);
      if (this._options.unref) {
          timer.unref();
      }
      return true;
    };
    RetryOperation.prototype.attempt = function(fn, timeoutOps) {
      this._fn = fn;
      if (timeoutOps) {
        if (timeoutOps.timeout) {
          this._operationTimeout = timeoutOps.timeout;
        }
        if (timeoutOps.cb) {
          this._operationTimeoutCb = timeoutOps.cb;
        }
      }
      var self = this;
      if (this._operationTimeoutCb) {
        this._timeout = setTimeout(function() {
          self._operationTimeoutCb();
        }, self._operationTimeout);
      }
      this._operationStart = new Date().getTime();
      this._fn(this._attempts);
    };
    RetryOperation.prototype.try = function(fn) {
      console.log('Using RetryOperation.try() is deprecated');
      this.attempt(fn);
    };
    RetryOperation.prototype.start = function(fn) {
      console.log('Using RetryOperation.start() is deprecated');
      this.attempt(fn);
    };
    RetryOperation.prototype.start = RetryOperation.prototype.try;
    RetryOperation.prototype.errors = function() {
      return this._errors;
    };
    RetryOperation.prototype.attempts = function() {
      return this._attempts;
    };
    RetryOperation.prototype.mainError = function() {
      if (this._errors.length === 0) {
        return null;
      }
      var counts = {};
      var mainError = null;
      var mainErrorCount = 0;
      for (var i = 0; i < this._errors.length; i++) {
        var error = this._errors[i];
        var message = error.message;
        var count = (counts[message] || 0) + 1;
        counts[message] = count;
        if (count >= mainErrorCount) {
          mainError = error;
          mainErrorCount = count;
        }
      }
      return mainError;
    };

    var retry$1 = createCommonjsModule(function (module, exports) {
    exports.operation = function(options) {
      var timeouts = exports.timeouts(options);
      return new retry_operation(timeouts, {
          forever: options && options.forever,
          unref: options && options.unref,
          maxRetryTime: options && options.maxRetryTime
      });
    };
    exports.timeouts = function(options) {
      if (options instanceof Array) {
        return [].concat(options);
      }
      var opts = {
        retries: 10,
        factor: 2,
        minTimeout: 1 * 1000,
        maxTimeout: Infinity,
        randomize: false
      };
      for (var key in options) {
        opts[key] = options[key];
      }
      if (opts.minTimeout > opts.maxTimeout) {
        throw new Error('minTimeout is greater than maxTimeout');
      }
      var timeouts = [];
      for (var i = 0; i < opts.retries; i++) {
        timeouts.push(this.createTimeout(i, opts));
      }
      if (options && options.forever && !timeouts.length) {
        timeouts.push(this.createTimeout(i, opts));
      }
      timeouts.sort(function(a,b) {
        return a - b;
      });
      return timeouts;
    };
    exports.createTimeout = function(attempt, opts) {
      var random = (opts.randomize)
        ? (Math.random() + 1)
        : 1;
      var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
      timeout = Math.min(timeout, opts.maxTimeout);
      return timeout;
    };
    exports.wrap = function(obj, options, methods) {
      if (options instanceof Array) {
        methods = options;
        options = null;
      }
      if (!methods) {
        methods = [];
        for (var key in obj) {
          if (typeof obj[key] === 'function') {
            methods.push(key);
          }
        }
      }
      for (var i = 0; i < methods.length; i++) {
        var method   = methods[i];
        var original = obj[method];
        obj[method] = function retryWrapper(original) {
          var op       = exports.operation(options);
          var args     = Array.prototype.slice.call(arguments, 1);
          var callback = args.pop();
          args.push(function(err) {
            if (op.retry(err)) {
              return;
            }
            if (err) {
              arguments[0] = op.mainError();
            }
            callback.apply(this, arguments);
          });
          op.attempt(function() {
            original.apply(obj, args);
          });
        }.bind(obj, original);
        obj[method].options = options;
      }
    };
    });
    retry$1.operation;
    retry$1.timeouts;
    retry$1.createTimeout;
    retry$1.wrap;

    var retry = retry$1;

    var DEFAULT_WEBSOCKET_CONFIG = {
        url: '',
        deserializer: function (e) { return JSON.parse(e.data); },
        serializer: function (value) { return JSON.stringify(value); },
    };
    var WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = 'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }';
    var WebSocketSubject =  (function (_super) {
        __extends$d(WebSocketSubject, _super);
        function WebSocketSubject(urlConfigOrSource, destination) {
            var _this = _super.call(this) || this;
            if (urlConfigOrSource instanceof Observable) {
                _this.destination = destination;
                _this.source = urlConfigOrSource;
            }
            else {
                var config = _this._config = __assign$4({}, DEFAULT_WEBSOCKET_CONFIG);
                _this._output = new Subject();
                if (typeof urlConfigOrSource === 'string') {
                    config.url = urlConfigOrSource;
                }
                else {
                    for (var key in urlConfigOrSource) {
                        if (urlConfigOrSource.hasOwnProperty(key)) {
                            config[key] = urlConfigOrSource[key];
                        }
                    }
                }
                if (!config.WebSocketCtor && WebSocket) {
                    config.WebSocketCtor = WebSocket;
                }
                else if (!config.WebSocketCtor) {
                    throw new Error('no WebSocket constructor can be found');
                }
                _this.destination = new ReplaySubject();
            }
            return _this;
        }
        WebSocketSubject.prototype.lift = function (operator) {
            var sock = new WebSocketSubject(this._config, this.destination);
            sock.operator = operator;
            sock.source = this;
            return sock;
        };
        WebSocketSubject.prototype._resetState = function () {
            this._socket = null;
            if (!this.source) {
                this.destination = new ReplaySubject();
            }
            this._output = new Subject();
        };
        WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) {
            var self = this;
            return new Observable(function (observer) {
                try {
                    self.next(subMsg());
                }
                catch (err) {
                    observer.error(err);
                }
                var subscription = self.subscribe(function (x) {
                    try {
                        if (messageFilter(x)) {
                            observer.next(x);
                        }
                    }
                    catch (err) {
                        observer.error(err);
                    }
                }, function (err) { return observer.error(err); }, function () { return observer.complete(); });
                return function () {
                    try {
                        self.next(unsubMsg());
                    }
                    catch (err) {
                        observer.error(err);
                    }
                    subscription.unsubscribe();
                };
            });
        };
        WebSocketSubject.prototype._connectSocket = function () {
            var _this = this;
            var _a = this._config, WebSocketCtor = _a.WebSocketCtor, protocol = _a.protocol, url = _a.url, binaryType = _a.binaryType;
            var observer = this._output;
            var socket = null;
            try {
                socket = protocol ?
                    new WebSocketCtor(url, protocol) :
                    new WebSocketCtor(url);
                this._socket = socket;
                if (binaryType) {
                    this._socket.binaryType = binaryType;
                }
            }
            catch (e) {
                observer.error(e);
                return;
            }
            var subscription = new Subscription(function () {
                _this._socket = null;
                if (socket && socket.readyState === 1) {
                    socket.close();
                }
            });
            socket.onopen = function (e) {
                var _socket = _this._socket;
                if (!_socket) {
                    socket.close();
                    _this._resetState();
                    return;
                }
                var openObserver = _this._config.openObserver;
                if (openObserver) {
                    openObserver.next(e);
                }
                var queue = _this.destination;
                _this.destination = Subscriber.create(function (x) {
                    if (socket.readyState === 1) {
                        try {
                            var serializer = _this._config.serializer;
                            socket.send(serializer(x));
                        }
                        catch (e) {
                            _this.destination.error(e);
                        }
                    }
                }, function (e) {
                    var closingObserver = _this._config.closingObserver;
                    if (closingObserver) {
                        closingObserver.next(undefined);
                    }
                    if (e && e.code) {
                        socket.close(e.code, e.reason);
                    }
                    else {
                        observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
                    }
                    _this._resetState();
                }, function () {
                    var closingObserver = _this._config.closingObserver;
                    if (closingObserver) {
                        closingObserver.next(undefined);
                    }
                    socket.close();
                    _this._resetState();
                });
                if (queue && queue instanceof ReplaySubject) {
                    subscription.add(queue.subscribe(_this.destination));
                }
            };
            socket.onerror = function (e) {
                _this._resetState();
                observer.error(e);
            };
            socket.onclose = function (e) {
                _this._resetState();
                var closeObserver = _this._config.closeObserver;
                if (closeObserver) {
                    closeObserver.next(e);
                }
                if (e.wasClean) {
                    observer.complete();
                }
                else {
                    observer.error(e);
                }
            };
            socket.onmessage = function (e) {
                try {
                    var deserializer = _this._config.deserializer;
                    observer.next(deserializer(e));
                }
                catch (err) {
                    observer.error(err);
                }
            };
        };
        WebSocketSubject.prototype._subscribe = function (subscriber) {
            var _this = this;
            var source = this.source;
            if (source) {
                return source.subscribe(subscriber);
            }
            if (!this._socket) {
                this._connectSocket();
            }
            this._output.subscribe(subscriber);
            subscriber.add(function () {
                var _socket = _this._socket;
                if (_this._output.observers.length === 0) {
                    if (_socket && _socket.readyState === 1) {
                        _socket.close();
                    }
                    _this._resetState();
                }
            });
            return subscriber;
        };
        WebSocketSubject.prototype.unsubscribe = function () {
            var _socket = this._socket;
            if (_socket && _socket.readyState === 1) {
                _socket.close();
            }
            this._resetState();
            _super.prototype.unsubscribe.call(this);
        };
        return WebSocketSubject;
    }(AnonymousSubject));

    var __extends$6 = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var __awaiter$9 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$8 = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    var RxWebsocketSubject =  (function (_super) {
        __extends$6(RxWebsocketSubject, _super);
        function RxWebsocketSubject(
        client,
        retryOptions,
        retryWait,
        urlGenerator,
        webSocketSubjectConfig,
        deserializer,
        serializer) {
            var _this = _super.call(this) || this;
            _this.retryOptions = retryOptions;
            _this.retryWait = retryWait;
            _this.urlGenerator = urlGenerator;
            _this.webSocketSubjectConfig = webSocketSubjectConfig;
            _this.deserializer = deserializer;
            _this.serializer = serializer;
            _this.log = Log$1.of("transport:socket", client);
            _this.connectionStatus = new Observable(function (observer) {
                _this.connectionObserver = observer;
            }).pipe(share(), distinctUntilChanged());
            if (!deserializer) {
                _this.deserializer = function (e) {
                    return JSON.parse(e.data);
                };
            }
            if (!_this.serializer) {
                _this.serializer = function (data) {
                    return JSON.stringify(data, MapOrSet_toJSON);
                };
            }
            _this.wsSubjectConfig = {
                url: null,
                closingObserver: webSocketSubjectConfig.closingObserver,
                closeObserver: {
                    next: function (e) {
                        _this.closeEvent = e;
                        _this.internalDisconnect();
                        _this.socket = null;
                        _this.webSocketSubjectConfig.closeObserver.next(e);
                        if (_this.operation && !_this.operation.retry({ name: String(e.code), message: e.reason })) {
                            _this.log.info("End reconnecting operation, no more attempt, call connect() to reconnect");
                            _this.operation = null;
                            _this.reconnecting = false;
                        }
                        else {
                            _this.reconnecting = !!_this.operation;
                        }
                        _this.connectionObserver.next(false);
                    },
                },
                openObserver: {
                    next: function (e) {
                        _this.closeEvent = null;
                        _this.connectionObserver.next(true);
                        _this.webSocketSubjectConfig.openObserver.next(e);
                    },
                },
                deserializer: _this.deserializer,
                serializer: _this.serializer,
            };
            _this.connect();
            return _this;
        }
        RxWebsocketSubject.prototype.protocolReady = function () {
            if (this.operation) {
                this.operation.reset();
                this.reconnecting = false;
            }
        };
        RxWebsocketSubject.prototype.disconnect = function () {
            this.log.info("Disconnet from ws");
            this.operation.stop();
            this.operation = null;
            this.reconnecting = false;
            this.internalDisconnect();
        };
        RxWebsocketSubject.prototype.connect = function () {
            if (!this.operation) {
                this.log.info("Connect to ws");
                this.operation = retry.operation(this.retryOptions);
                this.operation.attempt(this.internalConnect.bind(this));
            }
        };
        RxWebsocketSubject.prototype.internalDisconnect = function () {
            if (this.socket) {
                this.socket.unsubscribe();
            }
        };
        RxWebsocketSubject.prototype.internalConnect = function (currentAttempt) {
            var _a;
            return __awaiter$9(this, void 0, void 0, function () {
                var e_1;
                var _this = this;
                return __generator$8(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            this.log.info("Attempt " + currentAttempt + " to connect to ws");
                            this.wsSubjectConfig.url = this.webSocketSubjectConfig.url || this.urlGenerator();
                            this.internalDisconnect();
                            _b.label = 1;
                        case 1:
                            _b.trys.push([1, 3, , 4]);
                            return [4 , this.retryWait(this.closeEvent, currentAttempt)];
                        case 2:
                            if (!(_b.sent())) {
                                this.log.info("retryWait return false, stop reconnecting");
                                this.operation.stop();
                                this.operation = null;
                                this.reconnecting = false;
                                return [2 ];
                            }
                            return [3 , 4];
                        case 3:
                            e_1 = _b.sent();
                            (_a = this.operation) === null || _a === void 0 ? void 0 : _a.retry({ name: String(e_1.code), message: e_1.reason });
                            return [2 ];
                        case 4:
                            this.socket = new WebSocketSubject(this.wsSubjectConfig);
                            this.socket.subscribe(function (message) {
                                try {
                                    _this.next(message);
                                }
                                catch (err) {
                                    _this.log.error("Unhandled error", err);
                                }
                            }, function (err) {
                                _this.log.error("Socket error", err);
                            });
                            return [2 ];
                    }
                });
            });
        };
        RxWebsocketSubject.prototype.send = function (message) {
            if (this.socket) {
                this.socket.next(message);
            }
            else {
                this.log.error("Unable to send, socket is not connected");
            }
            return this;
        };
        return RxWebsocketSubject;
    }(Subject));

    var client = createCommonjsModule(function (module, exports) {
     (function (root) {
      function CrossStorageClient(url, opts) {
        opts = opts || {};
        this._id = CrossStorageClient._generateUUID();
        this._promise = opts.promise || Promise;
        this._frameId = opts.frameId || 'CrossStorageClient-' + this._id;
        this._origin = CrossStorageClient._getOrigin(url);
        this._requests = {};
        this._connected = false;
        this._closed = false;
        this._count = 0;
        this._timeout = opts.timeout || 5000;
        this._listener = null;
        this._storageEventListeners = {};
        this._storageEventListenerCount = 0;
        this._installListener();
        var frame;
        if (opts.frameId) {
          frame = document.getElementById(opts.frameId);
        }
        if (frame) {
          this._poll();
        }
        frame = frame || this._createFrame(url);
        this._hub = frame.contentWindow;
      }
      CrossStorageClient.frameStyle = {
        display: 'none',
        position: 'absolute',
        top: '-999px',
        left: '-999px'
      };
      CrossStorageClient._getOrigin = function (url) {
        var uri, protocol, origin;
        uri = document.createElement('a');
        uri.href = url;
        if (!uri.host) {
          uri = window.location;
        }
        if (!uri.protocol || uri.protocol === ':') {
          protocol = window.location.protocol;
        } else {
          protocol = uri.protocol;
        }
        origin = protocol + '//' + uri.host;
        origin = origin.replace(/:80$|:443$/, '');
        return origin;
      };
      CrossStorageClient._generateUUID = function () {
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
          var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
          return v.toString(16);
        });
      };
      CrossStorageClient.prototype.onConnect = function () {
        var client = this;
        if (this._connected) {
          return this._promise.resolve();
        } else if (this._closed) {
          return this._promise.reject(new Error('CrossStorageClient has closed'));
        }
        if (!this._requests.connect) {
          this._requests.connect = [];
        }
        return new this._promise(function (resolve, reject) {
          var timeout = setTimeout(function () {
            reject(new Error('CrossStorageClient could not connect'));
          }, client._timeout);
          client._requests.connect.push(function (err) {
            clearTimeout(timeout);
            if (err) return reject(err);
            resolve();
          });
        });
      };
      CrossStorageClient.prototype.set = function (key, value) {
        return this._request('set', {
          key: key,
          value: value
        });
      };
      CrossStorageClient.prototype.get = function (key) {
        var args = Array.prototype.slice.call(arguments);
        return this._request('get', { keys: args });
      };
      CrossStorageClient.prototype.listen = function (callback) {
        this._storageEventListenerCount++;
        var eventKey = this._id + ":" + this._storageEventListenerCount;
        this._storageEventListeners[eventKey] = callback;
        return this._request('listen', { eventKey: eventKey }).then(function () {
          return eventKey
        });
      };
      CrossStorageClient.prototype.unlisten = function (eventKey) {
        delete this._storageEventListeners[eventKey];
        return this._request('unlisten', { eventKey: eventKey });
      };
      CrossStorageClient.prototype.del = function () {
        var args = Array.prototype.slice.call(arguments);
        return this._request('del', { keys: args });
      };
      CrossStorageClient.prototype.clear = function () {
        return this._request('clear');
      };
      CrossStorageClient.prototype.getKeys = function () {
        return this._request('getKeys');
      };
      CrossStorageClient.prototype.close = function () {
        var frame = document.getElementById(this._frameId);
        if (frame) {
          frame.parentNode.removeChild(frame);
        }
        if (window.removeEventListener) {
          window.removeEventListener('message', this._listener, false);
        } else {
          window.detachEvent('onmessage', this._listener);
        }
        this._connected = false;
        this._closed = true;
      };
      CrossStorageClient.prototype._installListener = function () {
        var client = this;
        this._listener = function (message) {
          var i, origin, error, response;
          if (client._closed || !message.data || typeof message.data !== 'string') {
            return;
          }
          origin = (message.origin === 'null') ? 'file://' : message.origin;
          if (origin !== client._origin) return;
          if (message.data === 'cross-storage:unavailable') {
            if (!client._closed) client.close();
            if (!client._requests.connect) return;
            error = new Error('Closing client. Could not access localStorage in hub.');
            for (i = 0; i < client._requests.connect.length; i++) {
              client._requests.connect[i](error);
            }
            return;
          }
          if (message.data.indexOf('cross-storage:') !== -1 && !client._connected) {
            client._connected = true;
            if (!client._requests.connect) return;
            for (i = 0; i < client._requests.connect.length; i++) {
              client._requests.connect[i](error);
            }
            delete client._requests.connect;
          }
          if (message.data === 'cross-storage:ready') return;
          try {
            response = JSON.parse(message.data);
          } catch (e) {
            return;
          }
          if (response.type === 'event') {
            if (response.eventKey in client._storageEventListeners) {
              client._storageEventListeners[response.eventKey](response.eventData);
            }
            return;
          }
          if (!response.id) return;
          if (client._requests[response.id]) {
            client._requests[response.id](response.error, response.result);
          }
        };
        if (window.addEventListener) {
          window.addEventListener('message', this._listener, false);
        } else {
          window.attachEvent('onmessage', this._listener);
        }
      };
      CrossStorageClient.prototype._poll = function () {
        var client, interval, targetOrigin;
        client = this;
        targetOrigin = (client._origin === 'file://') ? '*' : client._origin;
        interval = setInterval(function () {
          if (client._connected) return clearInterval(interval);
          if (!client._hub) return;
          client._hub.postMessage('cross-storage:poll', targetOrigin);
        }, 1000);
      };
      CrossStorageClient.prototype._createFrame = function (url) {
        var frame, key;
        frame = window.document.createElement('iframe');
        frame.id = this._frameId;
        for (key in CrossStorageClient.frameStyle) {
          if (CrossStorageClient.frameStyle.hasOwnProperty(key)) {
            frame.style[key] = CrossStorageClient.frameStyle[key];
          }
        }
        window.document.body.appendChild(frame);
        frame.src = url;
        return frame;
      };
      CrossStorageClient.prototype._request = function (method, params) {
        var req, client;
        if (this._closed) {
          return this._promise.reject(new Error('CrossStorageClient has closed'));
        }
        client = this;
        client._count++;
        req = {
          id: this._id + ':' + client._count,
          method: 'cross-storage:' + method,
          params: params
        };
        return new this._promise(function (resolve, reject) {
          var timeout, originalToJSON, targetOrigin;
          timeout = setTimeout(function () {
            if (!client._requests[req.id]) return;
            delete client._requests[req.id];
            reject(new Error('Timeout: could not perform ' + req.method));
          }, client._timeout);
          client._requests[req.id] = function (err, result) {
            clearTimeout(timeout);
            delete client._requests[req.id];
            if (err) return reject(new Error(err));
            resolve(result);
          };
          if (Array.prototype.toJSON) {
            originalToJSON = Array.prototype.toJSON;
            Array.prototype.toJSON = null;
          }
          targetOrigin = (client._origin === 'file://') ? '*' : client._origin;
          client._hub.postMessage(JSON.stringify(req), targetOrigin);
          if (originalToJSON) {
            Array.prototype.toJSON = originalToJSON;
          }
        });
      };
      if (module.exports) {
        module.exports = CrossStorageClient;
      } else {
        exports.CrossStorageClient = CrossStorageClient;
      }
    }());
    });
    client.CrossStorageClient;

    var hub = createCommonjsModule(function (module, exports) {
     (function (root) {
      var CrossStorageHub = {};
      CrossStorageHub.init = function (permissions) {
        var available = true;
        try {
          if (!window.localStorage) available = false;
        } catch (e) {
          available = false;
        }
        if (!available) {
          try {
            return window.parent.postMessage('cross-storage:unavailable', '*');
          } catch (e) {
            return;
          }
        }
        CrossStorageHub._permissions = permissions || [];
        CrossStorageHub._eventListeners = {};
        CrossStorageHub._installListener();
        window.parent.postMessage('cross-storage:ready', '*');
      };
      CrossStorageHub._installListener = function () {
        var listener = CrossStorageHub._listener;
        if (window.addEventListener) {
          window.addEventListener('message', listener, false);
        } else {
          window.attachEvent('onmessage', listener);
        }
      };
      CrossStorageHub._listener = function (message) {
        var origin, targetOrigin, request, method, error, result, response;
        origin = (message.origin === 'null') ? 'file://' : message.origin;
        if (message.data === 'cross-storage:poll') {
          return window.parent.postMessage('cross-storage:ready', message.origin);
        }
        if (message.data === 'cross-storage:ready') return;
        try {
          request = JSON.parse(message.data);
        } catch (err) {
          return;
        }
        if (!request || typeof request.method !== 'string') {
          return;
        }
        method = request.method.split('cross-storage:')[1];
        if (!method) {
          return;
        } else if (!CrossStorageHub._permitted(origin, method)) {
          error = 'Invalid permissions for ' + method;
        } else {
          try {
            result = CrossStorageHub['_' + method](request.params);
          } catch (err) {
            error = err.message;
          }
        }
        response = JSON.stringify({
          id: request.id,
          error: error,
          result: result
        });
        targetOrigin = (origin === 'file://') ? '*' : origin;
        window.parent.postMessage(response, targetOrigin);
      };
      CrossStorageHub._permitted = function (origin, method) {
        var available, i, entry, match;
        if (method === 'unlisten') method = 'listen';
        available = ['get', 'set', 'listen', 'del', 'clear', 'getKeys'];
        if (!CrossStorageHub._inArray(method, available)) {
          return false;
        }
        for (i = 0; i < CrossStorageHub._permissions.length; i++) {
          entry = CrossStorageHub._permissions[i];
          if (!(entry.origin instanceof RegExp) || !(entry.allow instanceof Array)) {
            continue;
          }
          match = entry.origin.test(origin);
          if (match && CrossStorageHub._inArray(method, entry.allow)) {
            return true;
          }
        }
        return false;
      };
      CrossStorageHub._set = function (params) {
        window.localStorage.setItem(params.key, params.value);
      };
      CrossStorageHub._get = function (params) {
        var storage, result, i, value;
        storage = window.localStorage;
        result = [];
        for (i = 0; i < params.keys.length; i++) {
          try {
            value = storage.getItem(params.keys[i]);
          } catch (e) {
            value = null;
          }
          result.push(value);
        }
        return (result.length > 1) ? result : result[0];
      };
      CrossStorageHub._listen = function (params) {
        if (params.eventKey in CrossStorageHub._eventListeners) {
          throw new Error("Can't reuse eventKeys")
        }
        var handler = function (event) {
          if (event.storageArea != window.localStorage) return;
          var data = {
            type: 'event',
            eventKey: params.eventKey,
            eventData: {
              key: event.key,
              newValue: event.newValue,
              oldValue: event.oldValue,
              url: event.url
            }
          };
          window.parent.postMessage(JSON.stringify(data), '*');
        };
        if (window.addEventListener) {
          window.addEventListener('storage', handler, false);
        } else {
          window.attachEvent('onstorage', handler);
        }
        CrossStorageHub._eventListeners[params.eventKey] = handler;
      };
      CrossStorageHub._unlisten = function (params) {
        var handler = CrossStorageHub._eventListeners[params.eventKey];
        if (window.removeEventListener) {
          window.removeEventListener('storage', handler, false);
        } else {
          window.detachEvent('onstorage', handler);
        }
        CrossStorageHub._eventListeners[params.eventKey] = null;
      };
      CrossStorageHub._del = function (params) {
        for (var i = 0; i < params.keys.length; i++) {
          window.localStorage.removeItem(params.keys[i]);
        }
      };
      CrossStorageHub._clear = function () {
        window.localStorage.clear();
      };
      CrossStorageHub._getKeys = function (params) {
        var i, length, keys;
        keys = [];
        length = window.localStorage.length;
        for (i = 0; i < length; i++) {
          keys.push(window.localStorage.key(i));
        }
        return keys;
      };
      CrossStorageHub._inArray = function (value, array) {
        for (var i = 0; i < array.length; i++) {
          if (value === array[i]) return true;
        }
        return false;
      };
      CrossStorageHub._now = function () {
        if (typeof Date.now === 'function') {
          return Date.now();
        }
        return new Date().getTime();
      };
      if (module.exports) {
        module.exports = CrossStorageHub;
      } else {
        exports.CrossStorageHub = CrossStorageHub;
      }
    }());
    });
    hub.CrossStorageHub;

    var lib = {
      CrossStorageClient: client,
      CrossStorageHub:    hub
    };
    var lib_1 = lib.CrossStorageClient;

    var __extends$5 = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var __awaiter$8 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$7 = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
        for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
        for (var r = Array(s), k = 0, i = 0; i < il; i++)
            for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
                r[k] = a[j];
        return r;
    };
    var Heartbeat =  (function () {
        function Heartbeat(
        heartbeatInterval) {
            this.heartbeatInterval = heartbeatInterval;
            this.heartbeatCheckId = null;
            this.connected = false;
            this.transportSocket = null;
        }
        Heartbeat.prototype.setConnected = function (connected) {
            this.connected = connected;
        };
        Heartbeat.prototype.setTransportSocket = function (transportSocket) {
            this.transportSocket = transportSocket;
        };
        Heartbeat.prototype.heartbeat = function () {
            var _this = this;
            if (this.heartbeatCheckId)
                clearTimeout(this.heartbeatCheckId);
            this.heartbeatCheckId = setTimeout(function () {
                if (_this.connected && _this.transportSocket) {
                    _this.transportSocket.send("ping");
                    _this.heartbeat();
                }
            }, this.heartbeatInterval);
        };
        return Heartbeat;
    }());
    var AbstractJsonRpcWebsocket =  (function () {
        function AbstractJsonRpcWebsocket(client, connectionEventSubject, retryOptions, heartbeatInterval, crossStorageUrl) {
            this.client = client;
            this.connectionEventSubject = connectionEventSubject;
            this.retryOptions = retryOptions;
            this.heartbeatInterval = heartbeatInterval;
            this.crossStorageUrl = crossStorageUrl;
            this.loading = false;
            this.connected = false;
            this.socketMessage = new Subject();
            this.currentIdRequest = 1;
            this.firstConnect = true;
            this.crossStorageEnabled = false;
            this.requestExecuted = new Map();
            this.stopActiveRequest = new Subject();
            this.log = Log$1.of("transport", client);
            this.logRequest = Log$1.of("transport:request", client);
            this.logResponse = Log$1.of("transport:response", client);
            this.heartbeatService = new Heartbeat(this.heartbeatInterval);
            this.socketMessage.pipe(tap(this.handleResponseMessage.bind(this)), debounceTime(200)).subscribe(this.heartbeatService.heartbeat);
            if (this.crossStorageUrl) {
                this.initCrossStorage();
            }
        }
        AbstractJsonRpcWebsocket.prototype.retryWait = function (event, retries) {
            return __awaiter$8(this, void 0, void 0, function () {
                return __generator$7(this, function (_a) {
                    return [2 , true];
                });
            });
        };
        AbstractJsonRpcWebsocket.prototype.getCrossStorage = function () {
            return this.crossStorage;
        };
        AbstractJsonRpcWebsocket.prototype.initCrossStorage = function () {
            return __awaiter$8(this, void 0, void 0, function () {
                var result;
                var _this = this;
                return __generator$7(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            this.crossStorage = new CrossStorageManager(this.client, this, this.crossStorageUrl, function () { return _this.crossStorageEnabled; }, function (idRequest) { return _this.getResponseOf(idRequest); }, function () { return _this.getNewIdRequest(); }, function () { return _this.webSocketConnect(); }, function () { return _this.webSocketDisconnect(); }, function (response) { return _this.socketMessage.next(response); }, function (message) { return _this.transportSocket.send(message); }, this.connectionEventSubject);
                            return [4 , this.crossStorage.connect()];
                        case 1:
                            _a.sent();
                            if (!(this.crossStorage.getLevel() === Storagelevel.slave)) return [3 , 3];
                            return [4 , this.crossStorage.getStorage().get(ConnectionKey.commonMethodsMessage)];
                        case 2:
                            result = _a.sent();
                            if (result) {
                                this.crossStorage.commonMethodsRequestMap.fromJSON(JSON.parse(result));
                            }
                            this.connectionEventSubject.next({ connected: true });
                            _a.label = 3;
                        case 3: return [2 ];
                    }
                });
            });
        };
        AbstractJsonRpcWebsocket.prototype.disconnect = function () {
            if (this.crossStorage) {
                this.crossStorageEnabled = false;
                this.crossStorage.disconnect();
            }
            else {
                this.webSocketDisconnect();
            }
        };
        AbstractJsonRpcWebsocket.prototype.connect = function () {
            if (this.crossStorageUrl) {
                this.crossStorageEnabled = true;
            }
            else {
                this.webSocketConnect();
            }
        };
        AbstractJsonRpcWebsocket.prototype.getResponseOf = function (idRequest) {
            var requestData = this.requestExecuted.get(idRequest);
            if (!requestData) {
                requestData = new RequestData(null, null, null, null, null);
                requestData.identifier = new RequestIdentifier(idRequest);
                this.requestExecuted.set(idRequest, requestData);
            }
            return requestData.response;
        };
        AbstractJsonRpcWebsocket.prototype.handleResponseMessage = function (response) {
            if (response.hasOwnProperty("id")) {
                var request = this.requestExecuted.get(Math.abs(response.id));
                if (request) {
                    try {
                        request.response.next(response);
                    }
                    catch (e) {
                        this.log.warn("Client error on handle message", e);
                    }
                }
            }
        };
        AbstractJsonRpcWebsocket.prototype.webSocketConnect = function () {
            var _this = this;
            if (this.transportSocket && this.transportSocket.reconnecting) {
                this.log.debug("connection ws not available, reconnection is in progress");
                if (this.client.isRequestEnableUntilReconnect()) {
                    return;
                }
                else {
                    throw new ReconnectingInProgress({
                        clazz: null,
                        code: -8,
                        message: "Recconnecting is in progress, please retry after connection is complete",
                    });
                }
            }
            if (this.transportSocket && !this.connected) {
                this.transportSocket.connect();
                return;
            }
            var url = this.client.generateWsUrl();
            this.log.debug("connection ws to '" + url + "'");
            this.webSocketDisconnect();
            this.transportSocket = new RxWebsocketSubject(this.client, this.retryOptions, this.retryWait.bind(this), function () { return _this.client.generateWsUrl(); }, {
                url: null,
                closeObserver: {
                    next: function (e) {
                        _this.log.debug("ws closed, code " + e.code);
                        _this.onClose(e);
                    },
                },
                openObserver: {
                    next: function () {
                        _this.log.debug("ws open");
                        _this.onOpen();
                    },
                },
            }, function (message) {
                try {
                    var response = JSON.parse(message.data);
                    _this.logResponse.debug(" <-- ", response);
                    return response && response.id ? response : { id: "unknow", result: message };
                }
                catch (e) {
                    return { id: "service", result: message };
                }
            }, function (request) {
                var webSocketMessage;
                if (request instanceof RequestData) {
                    var jsonRpcMessage = { id: request.identifier.idRequest, method: request.method, params: request.params };
                    _this.logRequest.debug(" --> ", jsonRpcMessage, { requestTimeout: request.requestTimeout });
                    webSocketMessage = JSON.stringify(jsonRpcMessage, MapOrSet_toJSON);
                }
                else {
                    webSocketMessage = request;
                }
                return webSocketMessage;
            });
            this.transportSocket.subscribe(function (data) { return _this.socketMessage.next(data); });
            this.transportSocket.connectionStatus.subscribe(function (isConnected) {
                _this.connected = isConnected;
                _this.heartbeatService.setConnected(isConnected);
                _this.connectionEventSubject.next({ connected: isConnected });
                if (isConnected) {
                    _this.heartbeatService.heartbeat();
                }
            });
            this.heartbeatService.setTransportSocket(this.transportSocket);
            this.heartbeatService.heartbeat();
        };
        AbstractJsonRpcWebsocket.prototype.webSocketDisconnect = function () {
            if (this.transportSocket && this.connected) {
                this.log.debug("force disconnect previous socket");
                this.transportSocket.disconnect();
                this.transportSocket.unsubscribe();
                this.transportSocket = null;
            }
        };
        AbstractJsonRpcWebsocket.prototype.errorTimeoutToWebapiException = function (request) {
            var _this = this;
            return function (e) {
                if (e instanceof TimeoutError) {
                    _this.log.error("Timeout occurred, startTime " + (request.requestTime ? Log$1.getPrefixTimestamp(request.requestTime) : null) + " - timeout " + request.requestTimeout + " ms - id " + request.identifier.idRequest + " - method " + request.method);
                    throw new TimeoutResponse();
                }
                else {
                    throw e;
                }
            };
        };
        AbstractJsonRpcWebsocket.prototype.waitSendRequest = function (requestData) {
            return __awaiter$8(this, void 0, void 0, function () { return __generator$7(this, function (_a) {
                return [2 ];
            }); });
        };
        AbstractJsonRpcWebsocket.prototype.getNewIdRequest = function () {
            return __awaiter$8(this, void 0, void 0, function () {
                return __generator$7(this, function (_a) {
                    if (this.currentIdRequest === Number.MAX_SAFE_INTEGER) {
                        this.log.info("Reached Number.MAX_SAFE_INTEGER for idRequest, reset to 1000");
                        this.currentIdRequest = 999;
                    }
                    return [2 , new RequestIdentifier(++this.currentIdRequest)];
                });
            });
        };
        AbstractJsonRpcWebsocket.prototype.stopCurrentRequestWithException = function (exception) {
            this.stopActiveRequest.next(exception);
        };
        AbstractJsonRpcWebsocket.prototype.generateSyncFromRequest = function (request) {
            var _this = this;
            var response = merge(request.response.result,
            this.stopActiveRequest.asObservable().pipe(switchMap(function (exception) { return throwError(exception); }))).pipe(timeout(request.requestTimeout),
            catchError(this.errorTimeoutToWebapiException(request)));
            var result;
            if (request.responseIsChunked) {
                result = new Observable(function (chunckedResponse) {
                    var subscription = response.subscribe({
                        next: function (_data) {
                            var data = _data;
                            if (data.cRes) {
                                var pos_1 = data.i - data.cRes.length;
                                data.cRes.forEach(function (d) { return chunckedResponse.next({ tot: data.tot, i: ++pos_1, data: d }); });
                            }
                            if (data.part === "END") {
                                chunckedResponse.complete();
                                subscription.unsubscribe();
                            }
                        },
                        error: function (err) {
                            setTimeout(function () {
                                try {
                                    chunckedResponse.error(err);
                                }
                                catch (e) {
                                    if (e === err) {
                                        _this.log.error("Error received but not handled ", request.identifier.idRequest, ", method ", request.method);
                                    }
                                    else {
                                        throw e;
                                    }
                                }
                            });
                        },
                    });
                    return function () { return subscription.unsubscribe(); };
                });
            }
            else {
                result = response.pipe(take(1));
            }
            return result.pipe(finalize(function () { return _this.emitEventComplete(request, false); }));
        };
        AbstractJsonRpcWebsocket.prototype.requestInternal = function (method, params, requestTimeout, responseIsChunked, activateNotification) {
            var _this = this;
            var timeoutparsed = parseInt("" + requestTimeout);
            var requestTimeoutValue = isNaN(timeoutparsed) || timeoutparsed <= 0 ? this.getRequestTimeout() : timeoutparsed;
            var stopResult;
            var stopNotification;
            var resultSyncSubscription = Subscription.EMPTY;
            var request = new RequestData(method, params, requestTimeoutValue, activateNotification, responseIsChunked);
            var resultSync = request.response.resultSync.asObservable().pipe(tap(function () {
                _this.log.debug("resultSync - emit", request.compact());
            }), finalize(function () {
                _this.log.debug("resultSync - complete", request.compact());
            }), share());
            var responseData = {
                result: new Observable(function (observer) {
                    var firstResponseComplete;
                    resultSyncSubscription = resultSync
                        .pipe(finalize(function () {
                        firstResponseComplete = undefined;
                    }), concatMap(function (response) {
                        if (observer.closed) {
                            _this.log.warn("resultSync - result is lost due to previous result complete at '" + firstResponseComplete + "', subscribe to resultSync to handle all result", request.compact());
                            return response;
                        }
                        else {
                            var sharedResponse = response.pipe(finalize(function () {
                                firstResponseComplete = new Date();
                            }), share());
                            sharedResponse.subscribe(observer);
                            return sharedResponse;
                        }
                    }))
                        .subscribe();
                }),
                notification: null,
                resultSync: resultSync,
            };
            var createRequestData = new Observable(function (observer) {
                from(_this.waitSendRequest(request)).subscribe(observer);
            }).pipe(concatMap(function () { return __awaiter$8(_this, void 0, void 0, function () {
                var _a;
                return __generator$7(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            _a = request;
                            return [4 , this.getNewIdRequest()];
                        case 1:
                            _a.identifier = _b.sent();
                            return [2 ];
                    }
                });
            }); }));
            if (activateNotification) {
                createRequestData = createRequestData.pipe(shareReplay(1));
                var resultNotificationSubscription_1 = Subscription.EMPTY;
                var stopNotificationIsRequest_1 = false;
                var stopNotificationAction_1 = null;
                stopNotification = function () { return __awaiter$8(_this, void 0, void 0, function () {
                    var result;
                    return __generator$7(this, function (_a) {
                        switch (_a.label) {
                            case 0:
                                stopNotificationIsRequest_1 = true;
                                result = true;
                                if (!stopNotificationAction_1) return [3 , 2];
                                return [4 , stopNotificationAction_1()];
                            case 1:
                                result = _a.sent();
                                if (result) {
                                    stopNotificationAction_1 = null;
                                    resultNotificationSubscription_1.unsubscribe();
                                    this.completeRequestExecution(request);
                                }
                                return [3 , 3];
                            case 2:
                                this.completeRequestExecution(request);
                                _a.label = 3;
                            case 3: return [2 , result];
                        }
                    });
                }); };
                responseData.notification = createRequestData.pipe(switchMap(function () {
                    if (stopNotificationIsRequest_1) {
                        _this.log.debug("Stop notification of method '" + method + "' was called before subscribe, return EMPTY observable");
                        return EMPTY;
                    }
                    else {
                        return new Observable(function (observer) {
                            stopNotificationAction_1 = function () { return __awaiter$8(_this, void 0, void 0, function () {
                                var response, err_1;
                                return __generator$7(this, function (_a) {
                                    switch (_a.label) {
                                        case 0:
                                            this.log.debug("Stop notification " + request.identifier.idRequest + ", method " + method);
                                            _a.label = 1;
                                        case 1:
                                            _a.trys.push([1, 3, , 4]);
                                            return [4 , this.requestInternal("stopNotification", [request.identifier.idRequest], requestTimeout, false, false).response.result.toPromise()];
                                        case 2:
                                            response = _a.sent();
                                            this.log.debug("Notification " + request.identifier.idRequest + " " + (response ? "correctly" : "not") + " stopped");
                                            this.emitEventComplete(request, true);
                                            return [2 , response];
                                        case 3:
                                            err_1 = _a.sent();
                                            this.log.error("Notification " + request.identifier.idRequest + " failed stopped", err_1);
                                            return [2 , false];
                                        case 4: return [2 ];
                                    }
                                });
                            }); };
                            (function () { return __awaiter$8(_this, void 0, void 0, function () {
                                var err_2;
                                return __generator$7(this, function (_a) {
                                    switch (_a.label) {
                                        case 0:
                                            resultNotificationSubscription_1.unsubscribe();
                                            _a.label = 1;
                                        case 1:
                                            _a.trys.push([1, 3, , 4]);
                                            resultNotificationSubscription_1 = request.response.notification.subscribe(observer);
                                            return [4 , this.execRequest(request)];
                                        case 2:
                                            _a.sent();
                                            return [3 , 4];
                                        case 3:
                                            err_2 = _a.sent();
                                            this.log.error("Error on activate result notification", err_2);
                                            observer.error(err_2);
                                            stopNotification();
                                            return [3 , 4];
                                        case 4: return [2 ];
                                    }
                                });
                            }); })();
                            return function () { return stopNotification(); };
                        });
                    }
                }));
            }
            var resultSubscription = Subscription.EMPTY;
            stopResult = function () { return __awaiter$8(_this, void 0, void 0, function () {
                return __generator$7(this, function (_a) {
                    resultSubscription.unsubscribe();
                    if (!activateNotification) {
                        resultSyncSubscription.unsubscribe();
                    }
                    return [2 , true];
                });
            }); };
            request.buildResponse = function (forceSend) {
                var result = {
                    response: undefined,
                    sent: undefined,
                };
                result.sent = new Promise(function (sentDone, sentError) {
                    result.response = createRequestData.pipe(switchMap(function () {
                        return new Observable(function (observer) {
                            (function () { return __awaiter$8(_this, void 0, void 0, function () {
                                var err_3;
                                var _this = this;
                                return __generator$7(this, function (_a) {
                                    switch (_a.label) {
                                        case 0:
                                            resultSubscription.unsubscribe();
                                            _a.label = 1;
                                        case 1:
                                            _a.trys.push([1, 3, , 4]);
                                            resultSubscription = this.generateSyncFromRequest(request)
                                                .pipe(finalize(function () { return (!request.withNotification ? _this.completeRequestExecution(request) : null); }))
                                                .subscribe(observer);
                                            return [4 , this.execRequest(request, forceSend)];
                                        case 2:
                                            _a.sent();
                                            sentDone();
                                            return [3 , 4];
                                        case 3:
                                            err_3 = _a.sent();
                                            sentError(err_3);
                                            this.log.error("Error on activate result", err_3);
                                            observer.error(err_3);
                                            stopResult();
                                            return [3 , 4];
                                        case 4: return [2 ];
                                    }
                                });
                            }); })();
                            return function () { return stopResult(); };
                        }).pipe(catchError(function (error) {
                            stopNotification === null || stopNotification === void 0 ? void 0 : stopNotification();
                            throw error;
                        }), finalize(function () { return stopResult(); }));
                    }));
                });
                return result;
            };
            request.newResponse();
            return {
                response: responseData,
                toLiveResult: function () {
                    return {
                        result: responseData.result,
                        notification: responseData.notification,
                        resultSync: responseData.resultSync,
                        stopResult: function () { return __awaiter$8(_this, void 0, void 0, function () { return __generator$7(this, function (_a) {
                            return [2 , stopResult === null || stopResult === void 0 ? void 0 : stopResult()];
                        }); }); },
                        stopNotification: function () { return __awaiter$8(_this, void 0, void 0, function () { return __generator$7(this, function (_a) {
                            return [2 , stopNotification === null || stopNotification === void 0 ? void 0 : stopNotification()];
                        }); }); },
                    };
                },
            };
        };
        AbstractJsonRpcWebsocket.prototype.execRequest = function (request, force) {
            return __awaiter$8(this, void 0, void 0, function () {
                var requestIdentifier;
                return __generator$7(this, function (_a) {
                    if (!request.identifier)
                        throw new Error("Error on send " + request.method + ", identifier is unset");
                    requestIdentifier = this.requestExecuted.get(request.identifier.idRequest);
                    if (!requestIdentifier) {
                        this.requestExecuted.set(request.identifier.idRequest, request);
                        force = force || !(this.crossStorage && this.crossStorage.execRequest(request));
                    }
                    if (force) {
                        request.requestTime = new Date();
                        this.transportSocket.send(request);
                    }
                    return [2 ];
                });
            });
        };
        AbstractJsonRpcWebsocket.prototype.completeRequestExecution = function (request) {
            if (request.executed && request.identifier) {
                var requestData = this.requestExecuted.get(request.identifier.idRequest);
                if (requestData) {
                    this.requestExecuted.delete(request.identifier.idRequest);
                    requestData.complete();
                }
            }
        };
        AbstractJsonRpcWebsocket.prototype.emitEventComplete = function (request, isNotification) {
            if (this.crossStorage && request.identifier) {
                this.crossStorage.emitEventComplete(request.identifier, isNotification);
            }
        };
        AbstractJsonRpcWebsocket.prototype.emitErrorInternal = function (error, activateNotification) {
            var _this = this;
            var response = {
                result: throwError(error),
                notification: activateNotification ? throwError(error) : null,
                resultSync: throwError(error),
            };
            return {
                response: response,
                toLiveResult: function () {
                    return {
                        result: response.result,
                        notification: response.notification,
                        resultSync: response.resultSync,
                        stopResult: function () { return __awaiter$8(_this, void 0, void 0, function () { return __generator$7(this, function (_a) {
                            return [2 , false];
                        }); }); },
                        stopNotification: function () { return __awaiter$8(_this, void 0, void 0, function () { return __generator$7(this, function (_a) {
                            return [2 , false];
                        }); }); },
                    };
                },
            };
        };
        AbstractJsonRpcWebsocket.prototype.resendActiveNotification = function () {
            return __awaiter$8(this, void 0, void 0, function () {
                var _this = this;
                return __generator$7(this, function (_a) {
                    return [2 , from(Array.from(this.requestExecuted.values()))
                            .pipe(filter(function (request) { return request.method && request.executed && request.withNotification; }), concatMap(function (request) { return __awaiter$8(_this, void 0, void 0, function () {
                            var err_4;
                            return __generator$7(this, function (_a) {
                                switch (_a.label) {
                                    case 0:
                                        _a.trys.push([0, 2, , 3]);
                                        return [4 , request.newResponse(true)];
                                    case 1:
                                        _a.sent();
                                        return [3 , 3];
                                    case 2:
                                        err_4 = _a.sent();
                                        this.log.error("Error on resend active notification - " + JSON.stringify(request.compact(), MapOrSet_toJSON), err_4);
                                        return [3 , 3];
                                    case 3: return [2 ];
                                }
                            });
                        }); }), last())
                            .toPromise()];
                });
            });
        };
        AbstractJsonRpcWebsocket.prototype.request = function (method, params, requestTimeout, responseIsChunked, activateNotification) {
            return this.requestInternal(method, params, requestTimeout, responseIsChunked, activateNotification);
        };
        AbstractJsonRpcWebsocket.prototype.emitError = function (error, activateNotification) {
            return this.emitErrorInternal(error, activateNotification);
        };
        return AbstractJsonRpcWebsocket;
    }());
    var CrossStorageMessage =  (function () {
        function CrossStorageMessage(manager, eventHandler) {
            this.manager = manager;
            this.eventHandler = eventHandler;
        }
        CrossStorageMessage.prototype.notify = function (key, message) {
            return __awaiter$8(this, void 0, void 0, function () {
                return __generator$7(this, function (_a) {
                    switch (_a.label) {
                        case 0: return [4 , this.manager.getStorage().set(key, JSON.stringify(message, MapOrSet_toJSON))];
                        case 1:
                            _a.sent();
                            return [2 , message];
                    }
                });
            });
        };
        CrossStorageMessage.prototype.retrive = function (connectionKey) {
            return this.manager.getStorage().get(connectionKey);
        };
        CrossStorageMessage.prototype.ping = function (message) {
            return __awaiter$8(this, void 0, void 0, function () {
                return __generator$7(this, function (_a) {
                    switch (_a.label) {
                        case 0: return [4 , this.notify(ConnectionKey.pingToMaster, new StorageMessage(this.manager.getStorage()._id, message))];
                        case 1: return [2 , (_a.sent()).message];
                    }
                });
            });
        };
        CrossStorageMessage.prototype.pong = function (message) {
            return __awaiter$8(this, void 0, void 0, function () {
                return __generator$7(this, function (_a) {
                    switch (_a.label) {
                        case 0: return [4 , this.notify(ConnectionKey.pongToSlave, new StorageMessage(this.manager.getStorage()._id, message))];
                        case 1: return [2 , (_a.sent()).message];
                    }
                });
            });
        };
        CrossStorageMessage.prototype.notifyHierarchy = function (message) {
            return __awaiter$8(this, void 0, void 0, function () {
                var _a, _b, _c, _d;
                return __generator$7(this, function (_e) {
                    switch (_e.label) {
                        case 0:
                            _a = this.notify;
                            _b = [ConnectionKey.hierarchy];
                            _c = StorageMessage.bind;
                            _d = [void 0, this.manager.getStorage()._id];
                            return [4 , this.eventHandler.hierarchy(message)];
                        case 1: return [4 , _a.apply(this, _b.concat([new (_c.apply(StorageMessage, _d.concat([_e.sent()])))()]))];
                        case 2: return [2 , (_e.sent()).message];
                    }
                });
            });
        };
        CrossStorageMessage.prototype.notifyCommonMethodsMap = function (message) {
            return this.notify(ConnectionKey.commonMethodsMessage, message);
        };
        CrossStorageMessage.prototype.decodePing = function (message) {
            return message ? StorageMessage.fromStringMessage(message).message : null;
        };
        CrossStorageMessage.prototype.decodePong = function (message) {
            return message ? StorageMessage.fromStringMessage(message).message : null;
        };
        CrossStorageMessage.prototype.decodeHierarchy = function (message) {
            return message ? StorageMessage.fromStringMessage(message).message : null;
        };
        CrossStorageMessage.prototype.notifyWsResponse = function (message) {
            return __awaiter$8(this, void 0, void 0, function () {
                var _a, _b;
                return __generator$7(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            _a = this.notify;
                            _b = [ConnectionKey.fromWsResponse];
                            return [4 , this.eventHandler.fromWsResponse(this.decodeWsResponse(JSON.stringify(message, MapOrSet_toJSON)))];
                        case 1: return [2 , _a.apply(this, _b.concat([_c.sent()]))];
                    }
                });
            });
        };
        CrossStorageMessage.prototype.decodeWsResponse = function (message) {
            var _a, _b, _c, _d, _e, _f;
            var response = message ? FromWsMessage.fromStringMessage(message) : null;
            if ((_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.identifier) === null || _c === void 0 ? void 0 : _c.request) {
                response.data.message.identifier.request = new RequestIdentifier(response.data.message.identifier.request.idRequest);
            }
            if ((_f = (_e = (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.message) === null || _e === void 0 ? void 0 : _e.identifier) === null || _f === void 0 ? void 0 : _f.request) {
                response.data.message.identifier.realRequest = new RequestIdentifier(response.data.message.identifier.realRequest.idRequest);
            }
            return response;
        };
        CrossStorageMessage.prototype.notifyWsRequestId = function (message) {
            return __awaiter$8(this, void 0, void 0, function () {
                var _a, _b;
                return __generator$7(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            _a = this.notify;
                            _b = [ConnectionKey.fromWsRequestId];
                            return [4 , this.eventHandler.fromWsRequestId(this.decodeWsRequestId(JSON.stringify(message, MapOrSet_toJSON)))];
                        case 1: return [2 , _a.apply(this, _b.concat([_c.sent()]))];
                    }
                });
            });
        };
        CrossStorageMessage.prototype.notifyWsRequestIdUpdate = function (message) {
            return __awaiter$8(this, void 0, void 0, function () {
                var _a, _b;
                return __generator$7(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            _a = this.notify;
                            _b = [ConnectionKey.fromWsRequestIdUpdate];
                            return [4 , this.eventHandler.fromWsRequestIdUpdate(JSON.parse(JSON.stringify(message, MapOrSet_toJSON)))];
                        case 1: return [2 , _a.apply(this, _b.concat([_c.sent()]))];
                    }
                });
            });
        };
        CrossStorageMessage.prototype.decodeWsRequestId = function (message) {
            var _a, _b, _c, _d;
            var request = message ? FromWsMessage.fromStringMessage(message) : null;
            if ((_b = (_a = request === null || request === void 0 ? void 0 : request.data) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.request) {
                request.data.message.request = new RequestIdentifier(request.data.message.request.idRequest);
            }
            if ((_d = (_c = request === null || request === void 0 ? void 0 : request.data) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.realRequest) {
                request.data.message.realRequest = new RequestIdentifier(request.data.message.realRequest.idRequest);
            }
            return request;
        };
        CrossStorageMessage.prototype.notifyWsRequestComplete = function (message) {
            return __awaiter$8(this, void 0, void 0, function () {
                var _a, _b;
                return __generator$7(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            _a = this.notify;
                            _b = [ConnectionKey.toWsRequestComplete];
                            return [4 , this.eventHandler.toWsRequestComplete(this.decodeWsRequestComplete(JSON.stringify(message, MapOrSet_toJSON)))];
                        case 1: return [2 , _a.apply(this, _b.concat([_c.sent()]))];
                    }
                });
            });
        };
        CrossStorageMessage.prototype.decodeWsRequestComplete = function (message) {
            var _a, _b, _c, _d;
            var request = message ? ToWsMessage.fromStringMessage(message) : null;
            if ((_b = (_a = request === null || request === void 0 ? void 0 : request.data) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.identifier) {
                request.data.message.identifier = new RequestIdentifier((_d = (_c = request === null || request === void 0 ? void 0 : request.data) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.identifier.idRequest);
            }
            return request;
        };
        CrossStorageMessage.prototype.notifyWsRequest = function (message) {
            return __awaiter$8(this, void 0, void 0, function () {
                var _a, _b;
                return __generator$7(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            _a = this.notify;
                            _b = [ConnectionKey.toWsRequest];
                            return [4 , this.eventHandler.toWsRequest(this.decodeWsRequest(JSON.stringify(message, MapOrSet_toJSON)))];
                        case 1: return [2 , _a.apply(this, _b.concat([_c.sent()]))];
                    }
                });
            });
        };
        CrossStorageMessage.prototype.decodeWsRequest = function (message) {
            var _a;
            var request = message ? ToWsMessage.fromStringMessage(message) : null;
            if ((_a = request === null || request === void 0 ? void 0 : request.data) === null || _a === void 0 ? void 0 : _a.message) {
                request.data.message = RequestData.fromRequestData(request.data.message);
            }
            return request;
        };
        CrossStorageMessage.prototype.decodeCommonMethodsMap = function (message) {
            return message ? JSON.parse(message) : null;
        };
        return CrossStorageMessage;
    }());
    var CrossStorageHeartBeat =  (function () {
        function CrossStorageHeartBeat(client, manger, onHeartBeatEnd, onHeartBeatOk, pongTimeout, pingInterval) {
            if (pongTimeout === void 0) { pongTimeout = 500; }
            if (pingInterval === void 0) { pingInterval = 5000; }
            this.manger = manger;
            this.onHeartBeatEnd = onHeartBeatEnd;
            this.onHeartBeatOk = onHeartBeatOk;
            this.pongTimeout = pongTimeout;
            this.pingInterval = pingInterval;
            this.errorCounter = 0;
            this.pongSubscription = Subscription.EMPTY;
            this.checkSubscription = Subscription.EMPTY;
            this.started = false;
            this.log = Log$1.of("transport:CrossStorageHeartBeat", client);
        }
        CrossStorageHeartBeat.prototype.stop = function () {
            this.pongSubscription.unsubscribe();
            this.started = false;
        };
        CrossStorageHeartBeat.prototype.stopCheck = function () {
            this.checkSubscription.unsubscribe();
        };
        CrossStorageHeartBeat.prototype.start = function () {
            var _this = this;
            if (this.manger.getLevel() != Storagelevel.master) {
                this.started = true;
                this.log.info("PING");
                var idPing_1 = new Date().toISOString();
                this.pongSubscription.unsubscribe();
                this.pongSubscription = this.manger
                    .getPongObserver()
                    .pipe(filter(function (pong) { return pong.id_pong === idPing_1; }), timeout(this.pongTimeout), take(1))
                    .subscribe(function () {
                    _this.log.info("PONG");
                    _this.errorCounter = 0;
                    setTimeout(function () { return _this.start(); }, _this.pingInterval);
                }, function (err) {
                    _this.errorCounter++;
                    _this.log.warn("PONG lost");
                    if (_this.errorCounter < 3) {
                        setTimeout(function () { return _this.start(); }, 200);
                    }
                    else {
                        _this.onHeartBeatEnd(err);
                        _this.log.error("no PONG response");
                    }
                });
                this.manger.ping({ id_ping: idPing_1 });
            }
            else {
                this.stop();
            }
        };
        CrossStorageHeartBeat.prototype.check = function () {
            var _this = this;
            this.log.info("PING check master");
            var idPing = new Date().toISOString();
            this.checkSubscription.unsubscribe();
            this.checkSubscription = this.manger
                .getPongObserver()
                .pipe(filter(function (pong) { return pong.id_pong === idPing; }), timeout(this.pongTimeout), take(1))
                .subscribe(function () {
                _this.onHeartBeatOk(true);
                _this.log.info("PONG check master");
            }, function () {
                _this.errorCounter++;
                if (_this.errorCounter < 3) {
                    _this.log.warn("PONG check master lost");
                    _this.check();
                }
                else {
                    _this.onHeartBeatOk(false);
                    _this.log.error("no PONG master response");
                }
            });
            this.manger.ping({ id_ping: idPing });
        };
        CrossStorageHeartBeat.prototype.getStarted = function () {
            return this.started;
        };
        return CrossStorageHeartBeat;
    }());
    var CrossStorageManager =  (function () {
        function CrossStorageManager(client,
        transport,
        crossStorageUrl,
        isCrossStorageEnabled,
        getResponseOf,
        getNewIdRequest,
        webSocketConnect,
        webSocketDisconnect,
        onResponse,
        sendToSocket,
        connectionEventSubject) {
            var _this = this;
            this.transport = transport;
            this.crossStorageUrl = crossStorageUrl;
            this.isCrossStorageEnabled = isCrossStorageEnabled;
            this.getResponseOf = getResponseOf;
            this.getNewIdRequest = getNewIdRequest;
            this.webSocketConnect = webSocketConnect;
            this.webSocketDisconnect = webSocketDisconnect;
            this.onResponse = onResponse;
            this.sendToSocket = sendToSocket;
            this.connectionEventSubject = connectionEventSubject;
            this.pongSubject = new Subject();
            this.storageRequestMap = new Map();
            this.masterRequestMap = new Map();
            this.slaveRequestMap = new Map();
            this.commonMethodsRequestMap = new StringKeyMap();
            this.slaveChecked = new Subject();
            this.masterChecked = new Subject();
            this.methodsToMergeAndProxy = ["isChannelEnabled", "multiChannelServiceMonitor", "callChannelServiceMonitor", "videoChannelServiceMonitor", "chatChannelServiceMonitor", "mailChannelServiceMonitor", "callbackChannelServiceMonitor", "omnideskChannelServiceMonitor"];
            this.notCommonMethods = ["chatSendMessage", "widgetVisitUri", "chatChannelSessionNew", "chatChannelSessionMonitor", "chatChannelEventMonitor", "chatChannelSessionClose", "stopNotification", "chatReceivedMessage", "chatReadMessage", "chatSendRecapOfSession", "mailChannelSessionNew", "callbackChannelSessionNew", "videoChannelSessionNew", "callChannelSessionNew", "callChannelSessionClose", "echoTestSessionNew", "echoTestSessionStop"];
            this.serviceMonitormethods = ["multiChannelServiceMonitor", "callChannelServiceMonitor", "videoChannelServiceMonitor", "chatChannelServiceMonitor", "mailChannelServiceMonitor", "callbackChannelServiceMonitor", "omnideskChannelServiceMonitor"];
            this.decodeEventHandler = {
                pingToMaster: function (event) { return _this.message.decodePing(event.newValue); },
                pongToSlave: function (event) { return _this.message.decodePong(event.newValue); },
                hierarchy: function (event) { return _this.message.decodeHierarchy(event.newValue); },
                fromWsResponse: function (event) { return _this.message.decodeWsResponse(event.newValue); },
                fromWsRequestId: function (event) { return _this.message.decodeWsRequestId(event.newValue); },
                fromWsRequestIdUpdate: function (event) { return _this.message.decodeWsRequestId(event.newValue); },
                toWsRequestComplete: function (event) { return _this.message.decodeWsRequestComplete(event.newValue); },
                toWsRequest: function (event) { return _this.message.decodeWsRequest(event.newValue); },
                CommonMethodsMessage: function (event) { return _this.message.decodeCommonMethodsMap(event.newValue); },
            };
            this.eventHandler = {
                pingToMaster: function (ping) {
                    if (_this.storageLevel === Storagelevel.master) {
                        _this.message.pong({
                            id_pong: ping.id_ping,
                            to_id: ping.from_id,
                        });
                    }
                    return Promise.resolve(ping);
                },
                pongToSlave: function (pong) {
                    if (pong.to_id === _this.crossStorage._id) {
                        _this.pongSubject.next(pong);
                    }
                    return Promise.resolve(pong);
                },
                hierarchy: function (hierarchy) {
                    return _this.updateHierarchy(hierarchy);
                },
                fromWsResponse: function (fromWsMessage) { return __awaiter$8(_this, void 0, void 0, function () {
                    var requestIdentifier, jsonRpcResponse;
                    return __generator$7(this, function (_a) {
                        if (fromWsMessage.to_ids.indexOf(this.crossStorage._id) > -1) {
                            requestIdentifier = this.slaveRequestMap.get(fromWsMessage.data.message.identifier.request.idRequest);
                            if (requestIdentifier) {
                                jsonRpcResponse = fromWsMessage.data.message.data;
                                jsonRpcResponse.id = fromWsMessage.data.message.isNotification ? requestIdentifier.idNotification : requestIdentifier.idRequest;
                                this.onResponse(jsonRpcResponse);
                            }
                        }
                        return [2 , fromWsMessage];
                    });
                }); },
                fromWsRequestId: function (toWsIdMessage) { return __awaiter$8(_this, void 0, void 0, function () {
                    var storagemsg;
                    return __generator$7(this, function (_a) {
                        if (toWsIdMessage.to_ids.indexOf(this.crossStorage._id) > -1) {
                            storagemsg = toWsIdMessage.data.message;
                            this.slaveRequestMap.set(storagemsg.realRequest.idRequest, storagemsg.request);
                            this.masterRequestMap.set(storagemsg.request.idRequest, storagemsg.realRequest);
                            if (storagemsg.activateNotification) {
                                this.masterRequestMap.set(storagemsg.request.idNotification, storagemsg.realRequest);
                                this.slaveRequestMap.set(storagemsg.realRequest.idNotification, storagemsg.request);
                            }
                        }
                        return [2 , toWsIdMessage];
                    });
                }); },
                fromWsRequestIdUpdate: function (toWsIdMessageUpdate) { return __awaiter$8(_this, void 0, void 0, function () {
                    var _this = this;
                    return __generator$7(this, function (_a) {
                        if (toWsIdMessageUpdate.to_ids.indexOf(this.crossStorage._id) > -1) {
                            [
                                {
                                    oldId: toWsIdMessageUpdate.data.message.request.idRequest,
                                    newId: toWsIdMessageUpdate.data.message.realRequest.idRequest,
                                    isNotification: false,
                                },
                                {
                                    oldId: toWsIdMessageUpdate.data.message.request.idNotification,
                                    newId: toWsIdMessageUpdate.data.message.realRequest.idNotification,
                                    isNotification: true,
                                },
                            ].forEach(function (masterIdentification) {
                                var slaveRequestIdentification = _this.slaveRequestMap.get(masterIdentification.oldId);
                                if (slaveRequestIdentification) {
                                    _this.slaveRequestMap.set(masterIdentification.newId, slaveRequestIdentification);
                                    _this.slaveRequestMap.delete(masterIdentification.oldId);
                                    var prevMasterIdentifier = _this.masterRequestMap.get(masterIdentification.isNotification ? slaveRequestIdentification.idNotification : slaveRequestIdentification.idRequest);
                                    if (prevMasterIdentifier && masterIdentification.isNotification) {
                                        prevMasterIdentifier.idNotification = masterIdentification.newId;
                                    }
                                    else if (prevMasterIdentifier) {
                                        prevMasterIdentifier.idRequest = masterIdentification.newId;
                                    }
                                }
                            });
                        }
                        return [2 , toWsIdMessageUpdate];
                    });
                }); },
                toWsRequestComplete: function (toWsCompleteMessage) { return __awaiter$8(_this, void 0, void 0, function () {
                    var idToRemove;
                    return __generator$7(this, function (_a) {
                        if (this.storageLevel === Storagelevel.master) {
                            if (toWsCompleteMessage) {
                                idToRemove = toWsCompleteMessage.data.message.isNotification ? toWsCompleteMessage.data.message.identifier.idNotification : toWsCompleteMessage.data.message.identifier.idRequest;
                                if (this.storageRequestMap.has(idToRemove)) {
                                    this.storageRequestMap.get(idToRemove).unsubscribe();
                                    this.storageRequestMap.delete(idToRemove);
                                }
                            }
                        }
                        return [2 , toWsCompleteMessage];
                    });
                }); },
                toWsRequest: function (toWsMessage) { return __awaiter$8(_this, void 0, void 0, function () {
                    var storage_request, registerResult, realRequestIdentifier, data, registerRequest, requestIdentifierNotication, response, responseHandler_1, notificationResponseHandler_1, error_1;
                    return __generator$7(this, function (_a) {
                        switch (_a.label) {
                            case 0:
                                if (!(this.storageLevel === Storagelevel.master)) return [3 , 9];
                                storage_request = toWsMessage.data.message;
                                _a.label = 1;
                            case 1:
                                _a.trys.push([1, 8, , 9]);
                                return [4 , this.registerRequest(toWsMessage.from_id, storage_request)];
                            case 2:
                                registerResult = _a.sent();
                                realRequestIdentifier = registerResult.identifier;
                                data = null;
                                if (registerResult.isNew) {
                                    data = {
                                        registerRequest: this.commonMethodsRequestMap.get(storage_request.method) ? this.commonMethodsRequestMap.get(storage_request.method) : null,
                                        requestIdentifierNotication: {
                                            request: storage_request.identifier,
                                            realRequest: realRequestIdentifier,
                                            activateNotification: storage_request.withNotification,
                                        },
                                    };
                                }
                                else {
                                    throw stop;
                                }
                                registerRequest = data.registerRequest;
                                requestIdentifierNotication = data.requestIdentifierNotication;
                                if (!registerRequest) return [3 , 4];
                                return [4 , this.message.notifyWsRequestIdUpdate(new FromWsMessage(this.commonMethodsRequestMap.get(storage_request.method).id_slaves, new StorageMessage(this.crossStorage._id, requestIdentifierNotication)))];
                            case 3:
                                _a.sent();
                                registerRequest.id_slaves.push(toWsMessage.from_id);
                                this.commonMethodsRequestMap.set(storage_request.method, new RegisterRequestObj(registerRequest.id_slaves, storage_request, requestIdentifierNotication));
                                this.notifyCommonMethodsMap();
                                return [3 , 5];
                            case 4:
                                if (this.notCommonMethods.indexOf(storage_request.method) < 0) {
                                    this.commonMethodsRequestMap.set(storage_request.method, new RegisterRequestObj([toWsMessage.from_id], storage_request, requestIdentifierNotication));
                                    this.notifyCommonMethodsMap();
                                }
                                _a.label = 5;
                            case 5: return [4 , this.message.notifyWsRequestId(new FromWsMessage([toWsMessage.from_id], new StorageMessage(this.crossStorage._id, requestIdentifierNotication)))];
                            case 6:
                                _a.sent();
                                response = this.getResponseOf(requestIdentifierNotication.realRequest.idRequest).asObservable();
                                responseHandler_1 = this.notifyCrossStorageResponse(toWsMessage.from_id, false, storage_request.method, requestIdentifierNotication);
                                this.storageRequestMap.set(requestIdentifierNotication.realRequest.idRequest, response
                                    .pipe(filter(function (response) { return !responseIsNotification(response); }), concatMap(function (response) { return responseHandler_1(response); }))
                                    .subscribe());
                                if (storage_request.withNotification) {
                                    notificationResponseHandler_1 = this.notifyCrossStorageResponse(toWsMessage.from_id, true, storage_request.method, requestIdentifierNotication);
                                    this.storageRequestMap.set(requestIdentifierNotication.realRequest.idNotification, response
                                        .pipe(filter(function (response) { return responseIsNotification(response); }), concatMap(function (response) { return notificationResponseHandler_1(response); }))
                                        .subscribe());
                                }
                                storage_request.identifier.idRequest = requestIdentifierNotication.realRequest.idRequest;
                                return [4 , this.sendToSocket(storage_request)];
                            case 7:
                                _a.sent();
                                return [3 , 9];
                            case 8:
                                error_1 = _a.sent();
                                if (error_1 && error_1.stop) ;
                                else {
                                    console.log(error_1);
                                }
                                return [3 , 9];
                            case 9: return [2 , toWsMessage];
                        }
                    });
                }); },
                CommonMethodsMessage: function (commonMethodsMessage) { return __awaiter$8(_this, void 0, void 0, function () {
                    return __generator$7(this, function (_a) {
                        this.commonMethodsRequestMap.fromJSON(commonMethodsMessage);
                        return [2 , this.commonMethodsRequestMap];
                    });
                }); },
            };
            this.log = Log$1.of("transport:storage", client);
            this.message = new CrossStorageMessage(this, this.eventHandler);
            this.methodAnalizer = new CrossStorageMethodAnalizer();
            this.heartBeat = new CrossStorageHeartBeat(client, this, function () {
                _this.masterReconnect();
            }, function (res) {
                _this.masterChecked.next(res);
            });
        }
        CrossStorageManager.prototype.getPongObserver = function () {
            return this.pongSubject.asObservable();
        };
        CrossStorageManager.prototype.getMessage = function () {
            return this.message;
        };
        CrossStorageManager.prototype.getStorage = function () {
            return this.crossStorage;
        };
        CrossStorageManager.prototype.getLevel = function () {
            return this.storageLevel;
        };
        CrossStorageManager.prototype.setString = function (key, value) {
            return this.crossStorage.set(key, value);
        };
        CrossStorageManager.prototype.setValue = function (key, value) {
            return this.crossStorage.set(key, JSON.stringify(value, MapOrSet_toJSON));
        };
        CrossStorageManager.prototype.getValue = function (key) {
            return this.crossStorage.get(key);
        };
        CrossStorageManager.prototype.disconnect = function () {
            if (this.storageLevel === Storagelevel.master) {
                this.hierarchy.connectionMaster = null;
                if (this.hierarchy.connectionSlave.length > 0) {
                    this.hierarchy.connectionFutureMaster = this.hierarchy.connectionSlave[0];
                    this.hierarchy.connectionSlave.splice(0, 1);
                    this.notifyHierarchy();
                }
                else {
                    this.clear();
                }
                this.webSocketDisconnect();
            }
            else if (this.storageLevel === Storagelevel.slave) {
                var index = this.hierarchy.connectionSlave.indexOf(this.crossStorage._id);
                if (index > -1) {
                    this.hierarchy.connectionSlave.splice(index, 1);
                    this.notifyHierarchy();
                }
                this.connectionEventSubject.next({ connected: false });
            }
        };
        CrossStorageManager.prototype.connect = function () {
            return __awaiter$8(this, void 0, void 0, function () {
                var hierarchy, _a, _b;
                var _this = this;
                return __generator$7(this, function (_c) {
                    switch (_c.label) {
                        case 0:
                            this.log.debug("connect with cross-Storage");
                            this.crossStorage = new lib_1(this.crossStorageUrl, { timeout: 30000 });
                            this.hierarchy = new HierarchyMessage(null, []);
                            return [4 , this.crossStorage.onConnect()];
                        case 1:
                            _c.sent();
                            this.crossStorage.listen(function (event) { return _this.storageEventHandler(event); });
                            _b = (_a = this.message).decodeHierarchy;
                            return [4 , this.message.retrive(ConnectionKey.hierarchy)];
                        case 2: return [4 , _b.apply(_a, [_c.sent()])];
                        case 3:
                            hierarchy = _c.sent();
                            this.hierarchy = hierarchy ? hierarchy : this.hierarchy;
                            return [4 , new Promise(function (resolve) {
                                    if (_this.hierarchy.connectionMaster) {
                                        _this.log.debug("There is a master");
                                        _this.masterChecked.subscribe(function (res) { return __awaiter$8(_this, void 0, void 0, function () {
                                            return __generator$7(this, function (_a) {
                                                switch (_a.label) {
                                                    case 0:
                                                        if (!res) return [3 , 1];
                                                        this.log.debug("connecting as slave");
                                                        this.storageLevel = Storagelevel.slave;
                                                        this.hierarchy.connectionSlave.push(this.crossStorage._id);
                                                        this.heartBeat.start();
                                                        resolve(true);
                                                        return [3 , 3];
                                                    case 1: return [4 , this.masterReconnect()];
                                                    case 2:
                                                        _a.sent();
                                                        resolve(false);
                                                        _a.label = 3;
                                                    case 3: return [2 ];
                                                }
                                            });
                                        }); }, function () { return __awaiter$8(_this, void 0, void 0, function () {
                                            return __generator$7(this, function (_a) {
                                                switch (_a.label) {
                                                    case 0: return [4 , this.masterReconnect()];
                                                    case 1:
                                                        _a.sent();
                                                        resolve(false);
                                                        return [2 ];
                                                }
                                            });
                                        }); });
                                        _this.heartBeat.check();
                                    }
                                    else {
                                        _this.log.debug("There isn't a master");
                                        _this.masterConnect();
                                        resolve(true);
                                    }
                                })];
                        case 4:
                            _c.sent();
                            return [2 , this.notifyHierarchy()];
                    }
                });
            });
        };
        CrossStorageManager.prototype.masterConnect = function () {
            this.log.debug("Connecting as master");
            if (!this.transport.loading) {
                this.webSocketConnect();
            }
            this.storageLevel = Storagelevel.master;
            this.hierarchy.connectionMaster = this.crossStorage._id;
            this.hierarchy.connectionSlave = [];
        };
        CrossStorageManager.prototype.slaveConnect = function () {
            return __awaiter$8(this, void 0, void 0, function () {
                return __generator$7(this, function (_a) {
                    this.log.debug("connecting as slave");
                    this.storageLevel = Storagelevel.slave;
                    this.hierarchy.connectionSlave.push(this.crossStorage._id);
                    this.heartBeat.start();
                    return [2 , this.notifyHierarchy()];
                });
            });
        };
        CrossStorageManager.prototype.masterReconnect = function () {
            var _this = this;
            this.log.debug("Check if there are slaves alive");
            return new Promise(function (resolve) {
                _this.slaveChecked.pipe(timeout(1000)).subscribe(function () { return __awaiter$8(_this, void 0, void 0, function () {
                    var _this = this;
                    return __generator$7(this, function (_a) {
                        switch (_a.label) {
                            case 0:
                                if (this.slavesCheck.length) {
                                    this.slavesCheck.forEach(function (slave) {
                                        _this.hierarchy.connectionSlave.splice(_this.slavesCheck.indexOf(slave), 1);
                                    });
                                }
                                return [4 , this.reconnect()];
                            case 1:
                                _a.sent();
                                resolve(this.hierarchy);
                                return [2 ];
                        }
                    });
                }); }, function () { return __awaiter$8(_this, void 0, void 0, function () {
                    return __generator$7(this, function (_a) {
                        switch (_a.label) {
                            case 0:
                                this.hierarchy.connectionSlave = [];
                                return [4 , this.reconnect()];
                            case 1:
                                _a.sent();
                                resolve(this.hierarchy);
                                return [2 ];
                        }
                    });
                }); });
            });
        };
        CrossStorageManager.prototype.reconnect = function () {
            var _this = this;
            return new Promise(function (resolve) {
                if (!_this.transport.loading) {
                    _this.webSocketConnect();
                }
                _this.storageLevel = Storagelevel.master;
                _this.hierarchy.connectionMaster = _this.crossStorage._id;
                if (_this.commonMethodsRequestMap && _this.commonMethodsRequestMap.getSize() > 0) {
                    _this.commonMethodsRequestMap.getMap().forEach(function (value, key) {
                        var requestData = value.request;
                        _this.commonMethodsRequestMap.get(key).request = null;
                        _this.eventHandler.toWsRequest(new ToWsMessage(_this.crossStorage._id, new StorageMessage(_this.crossStorage._id, RequestData.fromRequestData(requestData))));
                    });
                }
                resolve(true);
            });
        };
        CrossStorageManager.prototype.clear = function () {
            for (var key in ConnectionKey) {
                this.crossStorage.del(ConnectionKey[key]);
            }
        };
        CrossStorageManager.prototype.storageEventHandler = function (event) {
            this.log.debug("Event received -- ", event);
            if (event.newValue != null) {
                if (this.eventHandler[event.key]) {
                    this.eventHandler[event.key](this.decodeEventHandler[event.key](event));
                }
            }
        };
        CrossStorageManager.prototype.notifyCrossStorageResponse = function (from_id, isNotification, method, identifier) {
            var _this = this;
            var storagetMessageData = {
                identifier: identifier,
                isNotification: isNotification,
                data: null,
            };
            var to_ids = this.commonMethodsRequestMap.get(method) ? this.commonMethodsRequestMap.get(method).id_slaves : [from_id];
            var result = new FromWsMessage(to_ids, new StorageMessage(this.crossStorage._id, storagetMessageData));
            return function (response) {
                var _a;
                storagetMessageData.data = response;
                if (_this.commonMethodsRequestMap.get(method)) {
                    var last_responses = _this.commonMethodsRequestMap.get(method).lastResponse || null;
                    if (_this.serviceMonitormethods.indexOf(method) !== -1 && last_responses && last_responses.length > 0 && isNotification) {
                        var serviceMonitorResponse_1 = response.result;
                        if (last_responses) {
                            last_responses.forEach(function (last_response) {
                                last_response.result.cRes.forEach(function (serviceStatus) {
                                    if (serviceStatus.service === serviceMonitorResponse_1.service) {
                                        serviceStatus.status = serviceMonitorResponse_1.status;
                                    }
                                });
                            });
                        }
                    }
                    else {
                        if (((_a = response.result) === null || _a === void 0 ? void 0 : _a.i) && response.result.i > 1) {
                            _this.commonMethodsRequestMap.get(method).lastResponse.push(response);
                        }
                        else {
                            _this.commonMethodsRequestMap.get(method).lastResponse = [response];
                        }
                    }
                }
                return _this.message.notifyWsResponse(result);
            };
        };
        CrossStorageManager.prototype.updateHierarchy = function (newHierarchy) {
            return __awaiter$8(this, void 0, void 0, function () {
                return __generator$7(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!newHierarchy) {
                                this.hierarchy.connectionFutureMaster = null;
                                this.hierarchy.connectionMaster = null;
                                this.hierarchy.connectionSlave = [];
                            }
                            else {
                                this.hierarchy = newHierarchy;
                            }
                            if (this.storageLevel === Storagelevel.slave && !this.heartBeat.getStarted) {
                                this.heartBeat.start();
                            }
                            if (!!this.hierarchy.connectionMaster) return [3 , 3];
                            this.connectionEventSubject.next({ connected: false });
                            if (!this.hierarchy.connectionFutureMaster) return [3 , 3];
                            this.heartBeat.stop();
                            if (!(this.hierarchy.connectionFutureMaster == this.crossStorage._id)) return [3 , 3];
                            this.log.debug("I'm new master");
                            this.storageLevel = Storagelevel.futureMaster;
                            this.hierarchy.connectionFutureMaster = null;
                            return [4 , this.reconnect()];
                        case 1:
                            _a.sent();
                            return [4 , this.notifyHierarchy()];
                        case 2:
                            _a.sent();
                            _a.label = 3;
                        case 3: return [2 , newHierarchy];
                    }
                });
            });
        };
        CrossStorageManager.prototype.notifyHierarchy = function () {
            return this.message.notifyHierarchy(this.hierarchy);
        };
        CrossStorageManager.prototype.notifyCommonMethodsMap = function () {
            return this.message.notifyCommonMethodsMap(this.commonMethodsRequestMap);
        };
        CrossStorageManager.prototype.ping = function (message) {
            return this.message.ping({
                id_ping: message.id_ping,
                from_id: this.crossStorage._id,
            });
        };
        CrossStorageManager.prototype.emitEventComplete = function (request, isNotification) {
            return __awaiter$8(this, void 0, void 0, function () {
                var result, idToRemove, masterIdentifier;
                return __generator$7(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            result = null;
                            if (!(this.isCrossStorageEnabled() && this.storageLevel === Storagelevel.slave)) return [3 , 2];
                            idToRemove = isNotification ? request.idNotification : request.idRequest;
                            masterIdentifier = this.masterRequestMap.get(idToRemove);
                            if (!masterIdentifier) return [3 , 2];
                            return [4 , this.message.notifyWsRequestComplete(new ToWsMessage(this.crossStorage._id, new StorageMessage(this.crossStorage._id, { isNotification: isNotification, identifier: masterIdentifier })))];
                        case 1:
                            result = _a.sent();
                            this.masterRequestMap.delete(idToRemove);
                            this.slaveRequestMap.delete(isNotification ? masterIdentifier.idRequest : masterIdentifier.idNotification);
                            _a.label = 2;
                        case 2: return [2 , result];
                    }
                });
            });
        };
        CrossStorageManager.prototype.execRequest = function (request) {
            return __awaiter$8(this, void 0, void 0, function () {
                return __generator$7(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.isCrossStorageEnabled()  ) return [3 , 2];
                            return [4 , this.message.notifyWsRequest(new ToWsMessage(this.crossStorage._id, new StorageMessage(this.crossStorage._id, request)))];
                        case 1:
                            _a.sent();
                            return [2 , true];
                        case 2: return [2 , false];
                    }
                });
            });
        };
        CrossStorageManager.prototype.registerRequest = function (from_id, request) {
            return __awaiter$8(this, void 0, void 0, function () {
                var needSocketRequest, requestRegistered, currentParam, newParams, notifyWsRequestId, requestIdentifierNotication, notifyWsResponseArray_1, err_5;
                var _a;
                var _this = this;
                return __generator$7(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            needSocketRequest = true;
                            requestRegistered = this.commonMethodsRequestMap.get(request.method) ? this.commonMethodsRequestMap.get(request.method) : null;
                            if (!(this.methodsToMergeAndProxy.indexOf(request.method) > -1 && requestRegistered != null)) return [3 , 8];
                            currentParam = __spreadArrays(request.params);
                            return [4 , (this.methodAnalizer[request.method] && requestRegistered.request ? this.methodAnalizer[request.method](currentParam, requestRegistered.request.params) : currentParam)];
                        case 1:
                            newParams = _b.sent();
                            notifyWsRequestId = false;
                            if (!newParams) return [3 , 2];
                            request.params.length = 0;
                            request.params.push.apply(request.params, newParams);
                            notifyWsRequestId = true;
                            return [3 , 4];
                        case 2:
                            this.commonMethodsRequestMap.get(request.method).id_slaves.push(from_id);
                            requestIdentifierNotication = {
                                request: request.identifier,
                                realRequest: requestRegistered.requestIdentifierNotification.request,
                                activateNotification: requestRegistered.requestIdentifierNotification.activateNotification,
                            };
                            return [4 , this.message.notifyWsRequestId(new FromWsMessage([from_id], new StorageMessage(this.crossStorage._id, requestIdentifierNotication)))];
                        case 3:
                            _b.sent();
                            _b.label = 4;
                        case 4:
                            notifyWsResponseArray_1 = new Array();
                            if (!!notifyWsRequestId) return [3 , 8];
                            requestRegistered.lastResponse.forEach(function (response) {
                                var result = new FromWsMessage([from_id], new StorageMessage(_this.crossStorage._id, {
                                    identifier: requestRegistered.requestIdentifierNotification,
                                    isNotification: responseIsNotification(response),
                                    data: response,
                                }));
                                notifyWsResponseArray_1.push(_this.message.notifyWsResponse(result));
                            });
                            _b.label = 5;
                        case 5:
                            _b.trys.push([5, 7, , 8]);
                            return [4 , Promise.all(notifyWsResponseArray_1)];
                        case 6:
                            _b.sent();
                            needSocketRequest = false;
                            return [3 , 8];
                        case 7:
                            _b.sent();
                            return [3 , 8];
                        case 8:
                            _b.trys.push([8, 12, , 13]);
                            if (!needSocketRequest) return [3 , 10];
                            _a = {
                                isNew: needSocketRequest
                            };
                            return [4 , this.getNewIdRequest()];
                        case 9: return [2 , (_a.identifier = _b.sent(),
                                _a)];
                        case 10: return [2 , {
                                isNew: false,
                                identifier: null,
                            }];
                        case 11: return [3 , 13];
                        case 12:
                            err_5 = _b.sent();
                            this.log.error("Error on handle request joiner", err_5);
                            throw err_5;
                        case 13: return [2 ];
                    }
                });
            });
        };
        CrossStorageManager.prototype.resendRequest = function () {
            return Promise.resolve(true);
        };
        return CrossStorageManager;
    }());
    var CrossStorageMethodAnalizer =  (function () {
        function CrossStorageMethodAnalizer() {
        }
        CrossStorageMethodAnalizer.prototype.isChannelEnabled = function (newParams, oldParams) {
            if (oldParams) {
                var comparedParams = this.compareRequestParams(newParams[0], oldParams[0]);
                switch (comparedParams) {
                    case 0:
                        newParams = null;
                        break;
                    case -1:
                        newParams = union$1(newParams, oldParams);
                        oldParams = newParams;
                        break;
                }
            }
            else {
                oldParams = newParams;
            }
            return Promise.resolve(newParams);
        };
        CrossStorageMethodAnalizer.prototype.multiChannelServiceMonitor = function (newParams, oldParams) {
            if (oldParams) {
                if (newParams[0].type === oldParams[0].type) {
                    var comparedParams = this.compareRequestParams(newParams[0].services, oldParams[0].services);
                    switch (comparedParams) {
                        case 0:
                            newParams = null;
                            break;
                        case -1:
                            newParams[0].services = union$1(newParams[0].services, oldParams[0].services);
                            oldParams = newParams;
                            break;
                    }
                }
                else {
                    newParams = null;
                }
            }
            else {
                oldParams = newParams;
            }
            return Promise.resolve(newParams);
        };
        CrossStorageMethodAnalizer.prototype.videoChannelServiceMonitor = function (newParams, oldParams) {
            if (oldParams) {
                var comparedParams = this.compareRequestParams(newParams[0].services, oldParams[0].services);
                switch (comparedParams) {
                    case 0:
                        newParams = null;
                        break;
                    case -1:
                        newParams[0].services = union$1(newParams[0].services, oldParams[0].services);
                        oldParams = newParams;
                        break;
                }
            }
            else {
                oldParams = newParams;
            }
            return Promise.resolve(newParams);
        };
        CrossStorageMethodAnalizer.prototype.callChannelServiceMonitor = function (newParams, oldParams) {
            if (oldParams) {
                var comparedParams = this.compareRequestParams(newParams[0].services, oldParams[0].services);
                if (comparedParams === 0) {
                    newParams = null;
                }
                else if (comparedParams === -1) {
                    newParams[0].services = union$1(newParams[0].services, oldParams[0].services);
                    oldParams = newParams;
                }
            }
            else {
                oldParams = newParams;
            }
            return Promise.resolve(newParams);
        };
        CrossStorageMethodAnalizer.prototype.chatChannelServiceMonitor = function (newParams, oldParams) {
            if (oldParams) {
                var comparedParams = this.compareRequestParams(newParams[0].services, oldParams[0].services);
                switch (comparedParams) {
                    case 0:
                        newParams = null;
                        break;
                    case -1:
                        newParams[0].services = union$1(newParams[0].services, oldParams[0].services);
                        oldParams = newParams;
                        break;
                }
            }
            else {
                oldParams = newParams;
            }
            return Promise.resolve(newParams);
        };
        CrossStorageMethodAnalizer.prototype.omnideskChannelServiceMonitor = function (newParams, oldParams) {
            if (oldParams) {
                var comparedParams = this.compareRequestParams(newParams[0].services, oldParams[0].services);
                switch (comparedParams) {
                    case 0:
                        newParams = null;
                        break;
                    case -1:
                        newParams[0].services = union$1(newParams[0].services, oldParams[0].services);
                        oldParams = newParams;
                        break;
                }
            }
            else {
                oldParams = newParams;
            }
            return Promise.resolve(newParams);
        };
        CrossStorageMethodAnalizer.prototype.callbackChannelServiceMonitor = function (newParams, oldParams) {
            if (oldParams) {
                var comparedParams = this.compareRequestParams(newParams[0].services, oldParams[0].services);
                switch (comparedParams) {
                    case 0:
                        newParams = null;
                        break;
                    case -1:
                        newParams[0].services = union$1(newParams[0].services, oldParams[0].services);
                        oldParams = newParams;
                        break;
                }
            }
            else {
                oldParams = newParams;
            }
            return Promise.resolve(newParams);
        };
        CrossStorageMethodAnalizer.prototype.mailChannelServiceMonitor = function (newParams, oldParams) {
            if (oldParams) {
                var comparedParams = this.compareRequestParams(newParams[0].services, oldParams[0].services);
                switch (comparedParams) {
                    case 0:
                        newParams = null;
                        break;
                    case -1:
                        newParams[0].services = union$1(newParams[0].services, oldParams[0].services);
                        oldParams = newParams;
                        break;
                }
            }
            else {
                oldParams = newParams;
            }
            return Promise.resolve(newParams);
        };
        CrossStorageMethodAnalizer.prototype.whatsappChannelServiceMonitor = function (newParams, oldParams) {
            if (oldParams) {
                var comparedParams = this.compareRequestParams(newParams[0].services, oldParams[0].services);
                switch (comparedParams) {
                    case 0:
                        newParams = null;
                        break;
                    case -1:
                        newParams[0].services = union$1(newParams[0].services, oldParams[0].services);
                        oldParams = newParams;
                        break;
                }
            }
            else {
                oldParams = newParams;
            }
            return Promise.resolve(newParams);
        };
        CrossStorageMethodAnalizer.prototype.compareRequestParams = function (request_1, request_2) {
            if (request_1.length === request_2.length) {
                for (var index = 0; index < request_1.length; index++) {
                    if (request_2.indexOf(request_1[index]) < 0) {
                        return -1;
                    }
                }
                return 0;
            }
            else if (request_1.length < request_2.length) {
                for (var index = 0; index < request_1.length; index++) {
                    if (request_2.indexOf(request_1[index]) < 0) {
                        return -1;
                    }
                }
                return 0;
            }
            else if (request_1.length > request_2.length) {
                for (var index = 0; index < request_2.length; index++) {
                    if (request_1.indexOf(request_2[index]) < 0) {
                        return -1;
                    }
                }
                return 1;
            }
            else {
                return -1;
            }
        };
        return CrossStorageMethodAnalizer;
    }());
    var MyMap =  (function () {
        function MyMap() {
            this.data = new Map();
        }
        MyMap.prototype.get = function (key) {
            return this.data.get(key);
        };
        MyMap.prototype.set = function (key, value) {
            this.data.set(key, value);
        };
        MyMap.prototype.getSize = function () {
            return this.data.size;
        };
        MyMap.prototype.getMap = function () {
            return this.data;
        };
        MyMap.prototype.toJSON = function () {
            var obj = Object.create(null);
            this.data.forEach(function (value, key) {
                obj[key] = value;
            });
            return obj;
        };
        MyMap.prototype.delete = function (key) {
            this.data.delete(key);
        };
        MyMap.prototype.fromJSON = function (obj) {
            if (obj) {
                for (var key in obj) {
                    this.data.set(this.keyTransform(key), this.valueTransform(obj[key]));
                }
            }
        };
        return MyMap;
    }());
    var StringKeyMap =  (function (_super) {
        __extends$5(StringKeyMap, _super);
        function StringKeyMap() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        StringKeyMap.prototype.valueTransform = function (value) {
            return value;
        };
        StringKeyMap.prototype.keyTransform = function (key) {
            return key;
        };
        return StringKeyMap;
    }(MyMap));
    var RequestData =  (function () {
        function RequestData(method, params, requestTimeout, withNotification, responseIsChunked) {
            this.method = method;
            this.params = params;
            this.requestTimeout = requestTimeout;
            this.withNotification = withNotification;
            this.responseIsChunked = responseIsChunked;
            this.response = new ResponseData();
        }
        RequestData.prototype.newResponse = function (forceSend) {
            var _a;
            return __awaiter$8(this, void 0, void 0, function () {
                var responseData, response;
                return __generator$7(this, function (_b) {
                    responseData = (_a = this.buildResponse) === null || _a === void 0 ? void 0 : _a.call(this, forceSend);
                    if (responseData) {
                        response = responseData.response.pipe(share());
                        this.response.resultSync.next(response);
                        return [2 , Promise.all([responseData.sent, response.pipe(take(1)).toPromise()]).then(function () {
                                return;
                            })];
                    }
                    return [2 ];
                });
            });
        };
        RequestData.prototype.complete = function () {
            this.buildResponse = undefined;
            this.response.complete();
        };
        Object.defineProperty(RequestData.prototype, "executed", {
            get: function () {
                return !!this.requestTime;
            },
            enumerable: false,
            configurable: true
        });
        RequestData.prototype.compact = function () {
            var _a;
            return {
                id: (_a = this.identifier) === null || _a === void 0 ? void 0 : _a.idRequest,
                method: this.method,
                options: {
                    timeout: this.requestTimeout,
                    notification: this.withNotification,
                    chunked: this.responseIsChunked,
                },
            };
        };
        RequestData.prototype.toJSON = function () {
            return {
                method: this.method,
                params: this.params,
                requestTimeout: this.requestTimeout,
                withNotification: this.withNotification,
                responseIsChunked: this.responseIsChunked,
                identifier: this.identifier,
            };
        };
        RequestData.fromRequestData = function (requestData) {
            if (requestData) {
                if (requestData instanceof RequestData) {
                    return requestData;
                }
                else {
                    var requestDataInstance = new RequestData(requestData.method, requestData.params, requestData.requestTimeout, requestData.withNotification, requestData.responseIsChunked);
                    requestDataInstance.identifier = new RequestIdentifier(requestData.identifier.idRequest);
                    return requestDataInstance;
                }
            }
            else {
                return requestData;
            }
        };
        return RequestData;
    }());
    var ResponseData =  (function (_super) {
        __extends$5(ResponseData, _super);
        function ResponseData() {
            var _a;
            var _this = _super.call(this) || this;
            _this.resultSync = new BehaviorSubject(null);
            _a = partition(_this.asObservable(), function (response) { return responseIsNotification(response); }).map(function (jsonRpcResponse) { return jsonRpcResponse.pipe(map(function (response) { return extractDataFromResponse(response); })); }), _this.notification = _a[0], _this.result = _a[1];
            return _this;
        }
        ResponseData.prototype.complete = function () {
            _super.prototype.complete.call(this);
            this.resultSync.complete();
        };
        return ResponseData;
    }(Subject));
    var RequestIdentifier =  (function () {
        function RequestIdentifier(idRequest) {
            this.idRequest = idRequest;
        }
        Object.defineProperty(RequestIdentifier.prototype, "idRequest", {
            get: function () {
                return this._idRequest;
            },
            set: function (idRequest) {
                this._idRequest = idRequest;
                if (idRequest && idRequest > 0) {
                    this._idNotification = -1 * idRequest;
                }
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(RequestIdentifier.prototype, "idNotification", {
            get: function () {
                return this._idNotification;
            },
            set: function (idNotification) {
                this._idNotification = idNotification;
            },
            enumerable: false,
            configurable: true
        });
        RequestIdentifier.prototype.toJSON = function () {
            return {
                idRequest: this.idRequest,
                idNotification: this.idNotification,
            };
        };
        return RequestIdentifier;
    }());
    function responseIsNotification(response) {
        return response.id < 0;
    }
    function extractDataFromResponse(response) {
        if (response.error) {
            throw response.error.data;
        }
        else {
            return response.result;
        }
    }

    var __extends$4 = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var __assign$2 = (undefined && undefined.__assign) || function () {
        __assign$2 = Object.assign || function(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                    t[p] = s[p];
            }
            return t;
        };
        return __assign$2.apply(this, arguments);
    };
    var __awaiter$7 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$6 = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    var JsonRpcWebsocket =  (function (_super) {
        __extends$4(JsonRpcWebsocket, _super);
        function JsonRpcWebsocket(
        client,
        loginRequest, connectionEventSubject, retryOptions, heartbeatInterval, storageUrl) {
            var _this = _super.call(this, client, connectionEventSubject, retryOptions, heartbeatInterval, storageUrl) || this;
            _this.client = client;
            _this.loginRequest = loginRequest;
            _this.stopOpenSocket = false;
            _this.onOpenSubscription = Subscription.EMPTY;
            _this.restoreSession = new JsonRpcWebsocketRestoreSession(function () {
                var revivalSessionTimeout = 90000;
                try {
                    var requestWithNotificationExecuted = Array.from(_this.requestExecuted.values()).filter(function (request) { return request.method && request.executed && request.withNotification; });
                    var requestWithNotificationAverageTimeout = requestWithNotificationExecuted.length ? requestWithNotificationExecuted.reduce(function (totalTimeout, request) { return totalTimeout + request.requestTimeout; }, 0) / requestWithNotificationExecuted.length : 0;
                    revivalSessionTimeout = Math.ceil(Math.max(revivalSessionTimeout, requestWithNotificationAverageTimeout * 4));
                }
                catch (e) { }
                _this.log.info("set revival session timeout to " + revivalSessionTimeout + " ms");
                return revivalSessionTimeout;
            });
            return _this;
        }
        JsonRpcWebsocket.prototype.waitSendRequest = function (requestData) {
            return __awaiter$7(this, void 0, void 0, function () {
                return __generator$6(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!(this.restoreSession.inProgress && requestData.method !== "restartSessionId")) return [3 , 2];
                            this.log.debug("Method '" + requestData.method + "' will be called after restore connection complete");
                            return [4 , this.restoreSession.waitEnd()];
                        case 1:
                            _a.sent();
                            _a.label = 2;
                        case 2: return [2 ];
                    }
                });
            });
        };
        JsonRpcWebsocket.prototype.load = function () {
            return __awaiter$7(this, void 0, void 0, function () {
                return __generator$6(this, function (_a) {
                    if (this.stopOpenSocket) {
                        throw new StopOpenSocket({
                            code: -10,
                            message: "Socket is blocked by other tab, use loginForce to force use this",
                            clazz: null,
                        });
                    }
                    else {
                        this.connect();
                    }
                    return [2 ];
                });
            });
        };
        JsonRpcWebsocket.prototype.getRequestTimeout = function () {
            return this.client.options.requestTimeout;
        };
        JsonRpcWebsocket.prototype.webSocketConnect = function () {
            var _a;
            if (!this.firstConnect && ((_a = this.transportSocket) === null || _a === void 0 ? void 0 : _a.reconnecting)) {
                this.restoreSession.start();
            }
            _super.prototype.webSocketConnect.call(this);
        };
        JsonRpcWebsocket.prototype.retryWait = function (event, retries) {
            return __awaiter$7(this, void 0, void 0, function () {
                var err_1;
                return __generator$6(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!((event === null || event === void 0 ? void 0 : event.code) === 1006)) return [3 , 4];
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 3, , 4]);
                            return [4 , this.loginRequest(30000).toPromise()];
                        case 2:
                            if (_a.sent()) {
                                this.log.info("revival accessToken complete, try to connect socket");
                            }
                            else {
                                throw new AuthorizationRequired({ clazz: null });
                            }
                            return [3 , 4];
                        case 3:
                            err_1 = _a.sent();
                            if (!(err_1 instanceof NoRouteToHost)) {
                                this.log.warn("error on login [code: " + err_1.code + ", message: " + err_1.message + "]", err_1);
                            }
                            if (err_1 instanceof AuthorizationRequired || err_1 instanceof PasswordExpired || err_1 instanceof UserNotEnabledOnMcs || err_1 instanceof UserNotEnabled) {
                                switch (err_1 === null || err_1 === void 0 ? void 0 : err_1.code) {
                                    case AuthorizationRequired.CODE:
                                    case PasswordExpired.CODE:
                                    case UserNotEnabledOnMcs.CODE:
                                    case UserNotEnabled.CODE:
                                        this.onClose(__assign$2(__assign$2({}, event), { code: 4000 + (err_1 === null || err_1 === void 0 ? void 0 : err_1.code) }));
                                        return [2 , false];
                                }
                            }
                            throw err_1;
                        case 4: return [2 , true];
                    }
                });
            });
        };
        JsonRpcWebsocket.prototype.onClose = function (event) {
            var _a;
            return __awaiter$7(this, void 0, void 0, function () {
                var resetSocket, stopOpenSocket, loginProfileStatus;
                return __generator$6(this, function (_b) {
                    this.log.debug("ws onClose");
                    resetSocket = true;
                    stopOpenSocket = true;
                    loginProfileStatus = null;
                    switch (event.code - (event.code >= 4400 && event.code < 4500 ? 4000 : 0)) {
                        case AuthorizationRequired.CODE:
                            this.log.debug("ws closed because notlogged");
                            stopOpenSocket = false;
                            loginProfileStatus = LoginProfileStatus.SOCKET_NOTLOGGED;
                            break;
                        case PasswordExpired.CODE:
                            this.log.debug("ws closed because password expired");
                            stopOpenSocket = false;
                            (_a = this.transportSocket) === null || _a === void 0 ? void 0 : _a.disconnect();
                            loginProfileStatus = LoginProfileStatus.PASSWORD_EXPIRED;
                            break;
                        case 409:
                            this.log.debug("ws closed because other socket is open");
                            loginProfileStatus = LoginProfileStatus.SOCKET_CLOSED_REQUEST_FORCE;
                            break;
                        case 499:
                            this.log.debug("ws closed because user force login on other socket");
                            loginProfileStatus = LoginProfileStatus.SOCKET_CLOSED_BY_USER;
                            break;
                        case UserNotEnabledOnMcs.CODE:
                            this.log.debug("ws closed because user not enabled on mcs");
                            loginProfileStatus = LoginProfileStatus.SOCKET_CLOSED_USER_NOT_ENABLED_MCS;
                            break;
                        case UserNotEnabled.CODE:
                            this.log.debug("ws closed because user not enabled");
                            loginProfileStatus = LoginProfileStatus.SOCKET_CLOSED_USER_NOT_ENABLED;
                            break;
                        default:
                            resetSocket = false;
                            stopOpenSocket = false;
                            this.firstConnect = false;
                            break;
                    }
                    if (stopOpenSocket) {
                        this.stopOpenSocket = true;
                    }
                    if (resetSocket) {
                        this.resetSocket();
                    }
                    if (loginProfileStatus) {
                        this.socketMessage.next({
                            id: -1,
                            result: { status: loginProfileStatus, logged: false, username: this.client.username },
                        });
                    }
                    return [2 ];
                });
            });
        };
        JsonRpcWebsocket.prototype.onOpen = function () {
            return __awaiter$7(this, void 0, void 0, function () {
                var _this = this;
                return __generator$6(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            this.log.debug("ws onOpen");
                            if (!!this.firstConnect) return [3 , 2];
                            this.restoreSession.start();
                            this.onOpenSubscription.unsubscribe();
                            return [4 , asyncTimeout(200)];
                        case 1:
                            _a.sent();
                            this.log.debug("Is not first connection, so try login and restartSessionId (restore connection)");
                            if (this.connected) {
                                this.onOpenSubscription.unsubscribe();
                                this.onOpenSubscription = new Observable(function (observer) {
                                    var onOpenSubscribed = true;
                                    (function () { return __awaiter$7(_this, void 0, void 0, function () {
                                        var retry, loginOk, timeout_1, loginResponse, err_2, err_3, lastRequestId, lastRequest, err_4;
                                        return __generator$6(this, function (_a) {
                                            switch (_a.label) {
                                                case 0:
                                                    retry = 0;
                                                    loginOk = false;
                                                    _a.label = 1;
                                                case 1:
                                                    _a.trys.push([1, 9, , 10]);
                                                    _a.label = 2;
                                                case 2:
                                                    if (!(retry > 0)) return [3 , 4];
                                                    timeout_1 = retry * 200;
                                                    this.log.info("wait " + timeout_1 + "ms before request login: retry " + retry);
                                                    return [4 , asyncTimeout(timeout_1)];
                                                case 3:
                                                    _a.sent();
                                                    _a.label = 4;
                                                case 4:
                                                    _a.trys.push([4, 6, , 7]);
                                                    this.log.info("request login");
                                                    return [4 , this.loginRequest(30000).toPromise()];
                                                case 5:
                                                    loginResponse = _a.sent();
                                                    loginOk = !!loginResponse;
                                                    return [3 , 7];
                                                case 6:
                                                    err_2 = _a.sent();
                                                    if (onOpenSubscribed) {
                                                        if (err_2 instanceof AuthorizationRequired) {
                                                            this.log.warn("Unamnaged error on login [code: " + err_2.code + ", message: " + err_2.message + "]", err_2);
                                                        }
                                                        else {
                                                            throw err_2;
                                                        }
                                                    }
                                                    else {
                                                        loginOk = true;
                                                    }
                                                    return [3 , 7];
                                                case 7:
                                                    if (!loginOk && ++retry < 5) return [3 , 2];
                                                    _a.label = 8;
                                                case 8: return [3 , 10];
                                                case 9:
                                                    err_3 = _a.sent();
                                                    this.log.error("Error on login", err_3);
                                                    throw err_3;
                                                case 10:
                                                    if (!onOpenSubscribed) return [3 , 19];
                                                    if (!loginOk) return [3 , 18];
                                                    _a.label = 11;
                                                case 11:
                                                    _a.trys.push([11, 16, , 17]);
                                                    return [4 , this.client.methods.restartSessionId().toPromise()];
                                                case 12:
                                                    lastRequestId = _a.sent();
                                                    if (!onOpenSubscribed) return [3 , 15];
                                                    lastRequest = parseInt(lastRequestId);
                                                    if (!(!isNaN(lastRequest) && lastRequest)) return [3 , 13];
                                                    this.currentIdRequest = lastRequest;
                                                    return [3 , 15];
                                                case 13:
                                                    if (!onOpenSubscribed) return [3 , 15];
                                                    return [4 , this.resendActiveNotification()];
                                                case 14:
                                                    _a.sent();
                                                    _a.label = 15;
                                                case 15: return [3 , 17];
                                                case 16:
                                                    err_4 = _a.sent();
                                                    this.log.error("Error on restartSessionId", err_4);
                                                    return [3 , 17];
                                                case 17: return [3 , 19];
                                                case 18:
                                                    this.log.info("Login failed, force close socket");
                                                    this.resetSocket();
                                                    this.socketMessage.next({
                                                        id: -1,
                                                        result: { status: LoginProfileStatus.SOCKET_NOTLOGGED, logged: false, username: this.client.username },
                                                    });
                                                    _a.label = 19;
                                                case 19: return [2 ];
                                            }
                                        });
                                    }); })()
                                        .then(function () {
                                        if (onOpenSubscribed)
                                            observer.complete();
                                    })
                                        .catch(function (err) {
                                        if (onOpenSubscribed)
                                            observer.error(err);
                                    });
                                    return function () {
                                        _this.log.info("restore connection ended");
                                        onOpenSubscribed = false;
                                        _this.onOpenSubscription = Subscription.EMPTY;
                                    };
                                }).subscribe({
                                    error: function (err) {
                                        _this.log.error("restore connection error", err);
                                        _this.restoreSession.error(err);
                                    },
                                    complete: function () {
                                        var _a;
                                        _this.log.info("restore connection complete");
                                        _this.restoreSession.complete();
                                        (_a = _this.transportSocket) === null || _a === void 0 ? void 0 : _a.protocolReady();
                                    },
                                });
                            }
                            _a.label = 2;
                        case 2: return [2 ];
                    }
                });
            });
        };
        JsonRpcWebsocket.prototype.resetSocket = function () {
            var _a;
            this.stopCurrentRequestWithException(new SocketClosed({ code: -80, message: "Socket is closed, response is unavailable", clazz: null }));
            (_a = this.transportSocket) === null || _a === void 0 ? void 0 : _a.disconnect();
            this.firstConnect = true;
            this.currentIdRequest = 1;
        };
        return JsonRpcWebsocket;
    }(AbstractJsonRpcWebsocket));
    var JsonRpcWebsocketRestoreSession =  (function () {
        function JsonRpcWebsocketRestoreSession( revivalTimeout) {
            this.revivalTimeout = revivalTimeout;
        }
        JsonRpcWebsocketRestoreSession.prototype.start = function () {
            var _this = this;
            if (!this.onOpenRevival) {
                this.onOpenRevival = from(new Promise(function (onComplete, onError) {
                    _this.onComplete = onComplete;
                    _this.onError = onError;
                }))
                    .pipe(timeout(this.revivalTimeout()), finalize(function () {
                    _this.onOpenRevival = null;
                    _this.onComplete = null;
                    _this.onError = null;
                }), catchError(function (e) {
                    if (e instanceof TimeoutError) {
                        throw TimeoutResponse.newInstance("Timeout has occurred on wait restore connection complete");
                    }
                    else {
                        throw e;
                    }
                }))
                    .toPromise();
            }
        };
        Object.defineProperty(JsonRpcWebsocketRestoreSession.prototype, "inProgress", {
            get: function () {
                return !!this.onOpenRevival;
            },
            enumerable: false,
            configurable: true
        });
        JsonRpcWebsocketRestoreSession.prototype.waitEnd = function () {
            return __awaiter$7(this, void 0, void 0, function () {
                return __generator$6(this, function (_a) {
                    if (this.inProgress) {
                        return [2 , this.onOpenRevival];
                    }
                    return [2 ];
                });
            });
        };
        JsonRpcWebsocketRestoreSession.prototype.complete = function () {
            if (this.inProgress) {
                this.onComplete();
            }
        };
        JsonRpcWebsocketRestoreSession.prototype.error = function (err) {
            if (this.inProgress) {
                this.onError(err);
            }
        };
        return JsonRpcWebsocketRestoreSession;
    }());

    var b64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    ((function (bin) {
        var t = {};
        for (var i = 0, l = bin.length; i < l; i++)
            t[bin.charAt(i)] = i;
        return t;
    }))(b64chars);
    function cb_utob(c) {
        if (c.length < 2) {
            var cc = c.charCodeAt(0);
            return cc < 0x80 ? c : cc < 0x800 ? String.fromCharCode(0xc0 | (cc >>> 6)) + String.fromCharCode(0x80 | (cc & 0x3f)) : String.fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) + String.fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) + String.fromCharCode(0x80 | (cc & 0x3f));
        }
        else {
            var cc = 0x10000 + (c.charCodeAt(0) - 0xd800) * 0x400 + (c.charCodeAt(1) - 0xdc00);
            return String.fromCharCode(0xf0 | ((cc >>> 18) & 0x07)) + String.fromCharCode(0x80 | ((cc >>> 12) & 0x3f)) + String.fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) + String.fromCharCode(0x80 | (cc & 0x3f));
        }
    }
    var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
    function utob(u) {
        return u.replace(re_utob, cb_utob);
    }
    function cb_encode(ccc) {
        var padlen = [0, 2, 1][ccc.length % 3], ord = (ccc.charCodeAt(0) << 16) | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) | (ccc.length > 2 ? ccc.charCodeAt(2) : 0), chars = [b64chars.charAt(ord >>> 18), b64chars.charAt((ord >>> 12) & 63), padlen >= 2 ? "=" : b64chars.charAt((ord >>> 6) & 63), padlen >= 1 ? "=" : b64chars.charAt(ord & 63)];
        return chars.join("");
    }
    var _btoa = btoa
        ? btoa
        : function (b) {
            return b.replace(/[\s\S]{1,3}/g, cb_encode);
        };
    function _encode(u) {
        var isUint8Array = Object.prototype.toString.call(u) === "[object Uint8Array]";
        return isUint8Array ? u.toString("base64") : _btoa(utob(String(u)));
    }
    function encode(u, urisafe) {
        return urisafe
            ? _encode(String(u))
                .replace(/[+\/]/g, function (m0) {
                return m0 == "+" ? "-" : "_";
            })
                .replace(/=/g, "")
            : _encode(u);
    }

    function buildResponse(command, result, resultMessage) {
        return { command: command.command, commandId: command.id, result: result, resultMessage: resultMessage };
    }
    function isClientDialCommand(clientCommand) {
        return clientCommand.command === ClientCommandRequest.DIAL;
    }

    var external_api_min = createCommonjsModule(function (module, exports) {
    !function(e,t){module.exports=t();}(self,(function(){return (()=>{var e={754:(e,t,n)=>{n.d(t,{default:()=>I});var i=n(620),r=n.n(i);class s extends i{constructor(){var e,t;super(...arguments),t={},(e="_storage")in this?Object.defineProperty(this,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):this[e]=t;}clear(){this._storage={};}get length(){return Object.keys(this._storage).length}getItem(e){return this._storage[e]}setItem(e,t){this._storage[e]=t;}removeItem(e){delete this._storage[e];}key(e){const t=Object.keys(this._storage);if(!(t.length<=e))return t[e]}serialize(){return JSON.stringify(this._storage)}}const o=new class extends i{constructor(){super();try{this._storage=window.localStorage,this._localStorageDisabled=!1;}catch(e){}this._storage||(console.warn("Local storage is disabled."),this._storage=new s,this._localStorageDisabled=!0);}isLocalStorageDisabled(){return this._localStorageDisabled}clear(){this._storage.clear(),this.emit("changed");}get length(){return this._storage.length}getItem(e){return this._storage.getItem(e)}setItem(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this._storage.setItem(e,t),n||this.emit("changed");}removeItem(e){this._storage.removeItem(e),this.emit("changed");}key(e){return this._storage.key(e)}serialize(){if(this.isLocalStorageDisabled())return this._storage.serialize();const e=this._storage.length,t={};for(let n=0;n<e;n++){const e=this._storage.key(n);t[e]=this._storage.getItem(e);}return JSON.stringify(t)}};var a=n(571);function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";console.error(t,e),window.onerror&&window.onerror(t,null,null,null,e);}n(415);const l=["__proto__","constructor","prototype"];function d(e){const t=new RegExp("^([a-z][a-z0-9\\.\\+-]*:)+","gi"),n=t.exec(e);if(n){let i=n[n.length-1].toLowerCase();"http:"!==i&&"https:"!==i&&(i="https:"),(e=e.substring(t.lastIndex)).startsWith("//")&&(e=i+e);}return e}function h(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=[];for(const n in e)try{t.push(`${n}=${encodeURIComponent(JSON.stringify(e[n]))}`);}catch(e){console.warn(`Error encoding ${n}: ${e}`);}return t}function u(e){const t={toString:p};let n,i,r;if(e=e.replace(/\s/g,""),n=new RegExp("^([a-z][a-z0-9\\.\\+-]*:)","gi"),i=n.exec(e),i&&(t.protocol=i[1].toLowerCase(),e=e.substring(n.lastIndex)),n=new RegExp("^(//[^/?#]+)","gi"),i=n.exec(e),i){let r=i[1].substring(2);e=e.substring(n.lastIndex);const s=r.indexOf("@");-1!==s&&(r=r.substring(s+1)),t.host=r;const o=r.lastIndexOf(":");-1!==o&&(t.port=r.substring(o+1),r=r.substring(0,o)),t.hostname=r;}if(n=new RegExp("^([^?#]*)","gi"),i=n.exec(e),i&&(r=i[1],e=e.substring(n.lastIndex)),r?r.startsWith("/")||(r=`/${r}`):r="/",t.pathname=r,e.startsWith("?")){let n=e.indexOf("#",1);-1===n&&(n=e.length),t.search=e.substring(0,n),e=e.substring(n);}else t.search="";return t.hash=e.startsWith("#")?e:"",t}function p(e){const{hash:t,host:n,pathname:i,protocol:r,search:s}=e||this;let o="";return r&&(o+=r),n&&(o+=`//${n}`),o+=i||"/",s&&(o+=s),t&&(o+=t),o}function g(e){let t;t=e.serverURL&&e.room?new URL(e.room,e.serverURL).toString():e.room?e.room:e.url||"";const n=u(d(t));if(!n.protocol){let t=e.protocol||e.scheme;t&&(t.endsWith(":")||(t+=":"),n.protocol=t);}let{pathname:i}=n;if(!n.host){const t=e.domain||e.host||e.hostname;if(t){const{host:e,hostname:r,pathname:s,port:o}=u(d(`org.jitsi.meet://${t}`));e&&(n.host=e,n.hostname=r,n.port=o),"/"===i&&"/"!==s&&(i=s);}}const r=e.roomName||e.room;!r||!n.pathname.endsWith("/")&&n.pathname.endsWith(`/${r}`)||(i.endsWith("/")||(i+="/"),i+=r),n.pathname=i;const{jwt:s}=e;if(s){let{search:e}=n;-1===e.indexOf("?jwt=")&&-1===e.indexOf("&jwt=")&&(e.startsWith("?")||(e=`?${e}`),1===e.length||(e+="&"),e+=`jwt=${s}`,n.search=e);}let{hash:o}=n;for(const t of ["config","interfaceConfig","devices","userInfo","appData"]){const n=h(e[`${t}Overwrite`]||e[t]||e[`${t}Override`]);if(n.length){let e=`${t}.${n.join(`&${t}.`)}`;o.length?e=`&${e}`:o="#",o+=e;}}return n.hash=o,n.toString()||void 0}const f={window:window.opener||window.parent},m="message";class v{constructor(){let{postisOptions:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.postis=function(e){var t,n=e.scope,i=e.window,r=e.windowForEventListening||window,s=e.allowedOrigin,o={},a=[],c={},l=!1,d="__ready__",h=function(e){var t;try{t=JSON.parse(e.data);}catch(e){return}if((!s||e.origin===s)&&t&&t.postis&&t.scope===n){var i=o[t.method];if(i)for(var r=0;r<i.length;r++)i[r].call(null,t.params);else c[t.method]=c[t.method]||[],c[t.method].push(t.params);}};r.addEventListener("message",h,!1);var u={listen:function(e,t){o[e]=o[e]||[],o[e].push(t);var n=c[e];if(n)for(var i=o[e],r=0;r<i.length;r++)for(var s=0;s<n.length;s++)i[r].call(null,n[s]);delete c[e];},send:function(e){var t=e.method;(l||e.method===d)&&i&&"function"==typeof i.postMessage?i.postMessage(JSON.stringify({postis:!0,scope:n,method:t,params:e.params}),"*"):a.push(e);},ready:function(e){l?e():setTimeout((function(){u.ready(e);}),50);},destroy:function(e){clearInterval(t),l=!1,r&&"function"==typeof r.removeEventListener&&r.removeEventListener("message",h),e&&e();}},p=+new Date+Math.random()+"";return t=setInterval((function(){u.send({method:d,params:p});}),50),u.listen(d,(function(e){if(e===p){clearInterval(t),l=!0;for(var n=0;n<a.length;n++)u.send(a[n]);a=[];}else u.send({method:d,params:e});})),u}({...f,...e}),this._receiveCallback=()=>{},this.postis.listen(m,(e=>this._receiveCallback(e)));}dispose(){this.postis.destroy();}send(e){this.postis.send({method:m,params:e});}setReceiveCallback(e){this._receiveCallback=e;}}const y="request",_="response";class b{constructor(){let{backend:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._listeners=new Map,this._requestID=0,this._responseHandlers=new Map,this._unprocessedMessages=new Set,this.addListener=this.on,e&&this.setBackend(e);}_disposeBackend(){this._backend&&(this._backend.dispose(),this._backend=null);}_onMessageReceived(e){if(e.type===_){const t=this._responseHandlers.get(e.id);t&&(t(e),this._responseHandlers.delete(e.id));}else e.type===y?this.emit("request",e.data,((t,n)=>{this._backend.send({type:_,error:n,id:e.id,result:t});})):this.emit("event",e.data);}dispose(){this._responseHandlers.clear(),this._unprocessedMessages.clear(),this.removeAllListeners(),this._disposeBackend();}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];const r=this._listeners.get(e);let s=!1;return r&&r.size&&r.forEach((e=>{s=e(...n)||s;})),s||this._unprocessedMessages.add(n),s}on(e,t){let n=this._listeners.get(e);return n||(n=new Set,this._listeners.set(e,n)),n.add(t),this._unprocessedMessages.forEach((e=>{t(...e)&&this._unprocessedMessages.delete(e);})),this}removeAllListeners(e){return e?this._listeners.delete(e):this._listeners.clear(),this}removeListener(e,t){const n=this._listeners.get(e);return n&&n.delete(t),this}sendEvent(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._backend&&this._backend.send({type:"event",data:e});}sendRequest(e){if(!this._backend)return Promise.reject(new Error("No transport backend defined!"));this._requestID++;const t=this._requestID;return new Promise(((n,i)=>{this._responseHandlers.set(t,(e=>{let{error:t,result:r}=e;void 0!==r?n(r):i(void 0!==t?t:new Error("Unexpected response format!"));})),this._backend.send({type:y,data:e,id:t});}))}setBackend(e){this._disposeBackend(),this._backend=e,this._backend.setReceiveCallback(this._onMessageReceived.bind(this));}}(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"hash";const i="search"===n?e.search:e.hash,r={},s=i&&i.substr(1).split("&")||[];if("hash"===n&&1===s.length){const e=s[0];if(e.startsWith("/")&&1===e.split("&").length)return r}return s.forEach((e=>{const n=e.split("="),i=n[0];if(!i||i.split(".").some((e=>l.includes(e))))return;let s;try{if(s=n[1],!t){const e=decodeURIComponent(s).replace(/\\&/,"&");s="undefined"===e?void 0:a.parse(e);}}catch(e){return void c(e,`Failed to parse URL parameter value: ${String(s)}`)}r[i]=s;})),r})(window.location).jitsi_meet_external_api_id;(window.JitsiMeetJS||(window.JitsiMeetJS={}),window.JitsiMeetJS.app||(window.JitsiMeetJS.app={}),window.JitsiMeetJS.app).setExternalTransportBackend=e=>undefined.setBackend(e);var w=n(481);const L=n.n(w)().getLogger("modules/API/external/functions.js");function C(e,t){return e.sendRequest({type:"devices",name:"setDevice",device:t})}const x=["css/all.css","libs/alwaysontop.min.js"],E={answerKnockingParticipant:"answer-knocking-participant",approveVideo:"approve-video",askToUnmute:"ask-to-unmute",avatarUrl:"avatar-url",cancelPrivateChat:"cancel-private-chat",displayName:"display-name",e2eeKey:"e2ee-key",email:"email",toggleLobby:"toggle-lobby",hangup:"video-hangup",initiatePrivateChat:"initiate-private-chat",kickParticipant:"kick-participant",muteEveryone:"mute-everyone",overwriteConfig:"overwrite-config",password:"password",pinParticipant:"pin-participant",rejectParticipant:"reject-participant",resizeLargeVideo:"resize-large-video",sendChatMessage:"send-chat-message",sendEndpointTextMessage:"send-endpoint-text-message",sendTones:"send-tones",setFollowMe:"set-follow-me",setLargeVideoParticipant:"set-large-video-participant",setParticipantVolume:"set-participant-volume",setTileView:"set-tile-view",setVideoQuality:"set-video-quality",startRecording:"start-recording",startShareVideo:"start-share-video",stopRecording:"stop-recording",stopShareVideo:"stop-share-video",subject:"subject",submitFeedback:"submit-feedback",toggleAudio:"toggle-audio",toggleCamera:"toggle-camera",toggleCameraMirror:"toggle-camera-mirror",toggleChat:"toggle-chat",toggleFilmStrip:"toggle-film-strip",toggleModeration:"toggle-moderation",toggleRaiseHand:"toggle-raise-hand",toggleShareAudio:"toggle-share-audio",toggleShareScreen:"toggle-share-screen",toggleTileView:"toggle-tile-view",toggleVirtualBackgroundDialog:"toggle-virtual-background",toggleVideo:"toggle-video"},k={"avatar-changed":"avatarChanged","audio-availability-changed":"audioAvailabilityChanged","audio-mute-status-changed":"audioMuteStatusChanged","browser-support":"browserSupport","camera-error":"cameraError","chat-updated":"chatUpdated","content-sharing-participants-changed":"contentSharingParticipantsChanged","data-channel-opened":"dataChannelOpened","device-list-changed":"deviceListChanged","display-name-change":"displayNameChange","email-change":"emailChange","error-occurred":"errorOccurred","endpoint-text-message-received":"endpointTextMessageReceived","feedback-submitted":"feedbackSubmitted","feedback-prompt-displayed":"feedbackPromptDisplayed","filmstrip-display-changed":"filmstripDisplayChanged","incoming-message":"incomingMessage","knocking-participant":"knockingParticipant",log:"log","mic-error":"micError","moderation-participant-approved":"moderationParticipantApproved","moderation-participant-rejected":"moderationParticipantRejected","moderation-status-changed":"moderationStatusChanged","mouse-enter":"mouseEnter","mouse-leave":"mouseLeave","mouse-move":"mouseMove","outgoing-message":"outgoingMessage","participant-joined":"participantJoined","participant-kicked-out":"participantKickedOut","participant-left":"participantLeft","participant-role-changed":"participantRoleChanged","password-required":"passwordRequired","proxy-connection-event":"proxyConnectionEvent","raise-hand-updated":"raiseHandUpdated","recording-link-available":"recordingLinkAvailable","recording-status-changed":"recordingStatusChanged","video-ready-to-close":"readyToClose","video-conference-joined":"videoConferenceJoined","video-conference-left":"videoConferenceLeft","video-availability-changed":"videoAvailabilityChanged","video-mute-status-changed":"videoMuteStatusChanged","video-quality-changed":"videoQualityChanged","screen-sharing-status-changed":"screenSharingStatusChanged","dominant-speaker-changed":"dominantSpeakerChanged","subject-change":"subjectChange","suspend-detected":"suspendDetected","tile-view-changed":"tileViewChanged","toolbar-button-clicked":"toolbarButtonClicked"};let O=0;function R(e,t){e._numberOfParticipants+=t;}function S(e){let t;return "string"==typeof e&&null!==String(e).match(/([0-9]*\.?[0-9]+)(em|pt|px|%)$/)?t=e:"number"==typeof e&&(t=`${e}px`),t}class I extends(r()){constructor(e){super();for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];const{roomName:r="",width:s="100%",height:a="100%",parentNode:c=document.body,configOverwrite:l={},interfaceConfigOverwrite:d={},jwt:h,onload:u,invitees:p,devices:f,userInfo:m,e2eeKey:y}=function(e){if(!e.length)return {};switch(typeof e[0]){case"string":case"undefined":{const[t,n,i,r,s,o,a,c]=e;return {roomName:t,width:n,height:i,parentNode:r,configOverwrite:s,interfaceConfigOverwrite:o,jwt:a,onload:c}}case"object":return e[0];default:throw new Error("Can't parse the arguments!")}}(n),_=o.getItem("jitsiLocalStorage");this._parentNode=c,this._url=function(e){return g({...arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},url:`https://${e}/#jitsi_meet_external_api_id=${O}`})}(e,{configOverwrite:l,interfaceConfigOverwrite:d,jwt:h,roomName:r,devices:f,userInfo:m,appData:{localStorageContent:_}}),this._createIFrame(a,s,u),this._transport=new b({backend:new v({postisOptions:{allowedOrigin:new URL(this._url).origin,scope:`jitsi_meet_external_api_${O}`,window:this._frame.contentWindow}})}),Array.isArray(p)&&p.length>0&&this.invite(p),this._tmpE2EEKey=y,this._isLargeVideoVisible=!0,this._numberOfParticipants=0,this._participants={},this._myUserID=void 0,this._onStageParticipant=void 0,this._setupListeners(),O++;}_createIFrame(e,t,n){const i=`jitsiConferenceFrame${O}`;this._frame=document.createElement("iframe"),this._frame.allow="camera; microphone; display-capture; autoplay; clipboard-write",this._frame.src=this._url,this._frame.name=i,this._frame.id=i,this._setSize(e,t),this._frame.setAttribute("allowFullScreen","true"),this._frame.style.border=0,n&&(this._frame.onload=n),this._frame=this._parentNode.appendChild(this._frame);}_getAlwaysOnTopResources(){const e=this._frame.contentWindow,t=e.document;let n="";const i=t.querySelector("base");if(i&&i.href)n=i.href;else {const{protocol:t,host:i}=e.location;n=`${t}//${i}`;}return x.map((e=>new URL(e,n).href))}_getFormattedDisplayName(e){const{formattedDisplayName:t}=this._participants[e]||{};return t}_getOnStageParticipant(){return this._onStageParticipant}_getLargeVideo(){const e=this.getIFrame();if(this._isLargeVideoVisible&&e&&e.contentWindow&&e.contentWindow.document)return e.contentWindow.document.getElementById("largeVideo")}_getParticipantVideo(e){const t=this.getIFrame();if(t&&t.contentWindow&&t.contentWindow.document)return void 0===e||e===this._myUserID?t.contentWindow.document.getElementById("localVideo_container"):t.contentWindow.document.querySelector(`#participant_${e} video`)}_setSize(e,t){const n=S(e),i=S(t);void 0!==n&&(this._height=e,this._frame.style.height=n),void 0!==i&&(this._width=t,this._frame.style.width=i);}_setupListeners(){this._transport.on("event",(e=>{let{name:t,...n}=e;const i=n.id;switch(t){case"video-conference-joined":void 0!==this._tmpE2EEKey&&(this.executeCommand(E.e2eeKey,this._tmpE2EEKey),this._tmpE2EEKey=void 0),this._myUserID=i,this._participants[i]={avatarURL:n.avatarURL};case"participant-joined":this._participants[i]=this._participants[i]||{},this._participants[i].displayName=n.displayName,this._participants[i].formattedDisplayName=n.formattedDisplayName,R(this,1);break;case"participant-left":R(this,-1),delete this._participants[i];break;case"display-name-change":{const e=this._participants[i];e&&(e.displayName=n.displayname,e.formattedDisplayName=n.formattedDisplayName);break}case"email-change":{const e=this._participants[i];e&&(e.email=n.email);break}case"avatar-changed":{const e=this._participants[i];e&&(e.avatarURL=n.avatarURL);break}case"on-stage-participant-changed":this._onStageParticipant=i,this.emit("largeVideoChanged");break;case"large-video-visibility-changed":this._isLargeVideoVisible=n.isVisible,this.emit("largeVideoChanged");break;case"video-conference-left":R(this,-1),delete this._participants[this._myUserID];break;case"video-quality-changed":this._videoQuality=n.videoQuality;break;case"local-storage-changed":return o.setItem("jitsiLocalStorage",n.localStorageContent),!0}const r=k[t];return !!r&&(this.emit(r,n),!0)}));}addEventListener(e,t){this.on(e,t);}addEventListeners(e){for(const t in e)this.addEventListener(t,e[t]);}captureLargeVideoScreenshot(){return this._transport.sendRequest({name:"capture-largevideo-screenshot"})}dispose(){this.emit("_willDispose"),this._transport.dispose(),this.removeAllListeners(),this._frame&&this._frame.parentNode&&this._frame.parentNode.removeChild(this._frame);}executeCommand(e){if(e in E){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this._transport.sendEvent({data:n,name:E[e]});}else console.error("Not supported command name.");}executeCommands(e){for(const t in e)this.executeCommand(t,e[t]);}getAvailableDevices(){return function(e){return e.sendRequest({type:"devices",name:"getAvailableDevices"}).catch((e=>(L.error(e),{})))}(this._transport)}getContentSharingParticipants(){return this._transport.sendRequest({name:"get-content-sharing-participants"})}getCurrentDevices(){return function(e){return e.sendRequest({type:"devices",name:"getCurrentDevices"}).catch((e=>(L.error(e),{})))}(this._transport)}getCustomAvatarBackgrounds(){return this._transport.sendRequest({name:"get-custom-avatar-backgrounds"})}getLivestreamUrl(){return this._transport.sendRequest({name:"get-livestream-url"})}getParticipantsInfo(){const e=Object.keys(this._participants),t=Object.values(this._participants);return t.forEach(((t,n)=>{t.participantId=e[n];})),t}getVideoQuality(){return this._videoQuality}isAudioAvailable(){return this._transport.sendRequest({name:"is-audio-available"})}isDeviceChangeAvailable(e){return function(e,t){return e.sendRequest({deviceType:t,type:"devices",name:"isDeviceChangeAvailable"})}(this._transport,e)}isDeviceListAvailable(){return function(e){return e.sendRequest({type:"devices",name:"isDeviceListAvailable"})}(this._transport)}isMultipleAudioInputSupported(){return function(e){return e.sendRequest({type:"devices",name:"isMultipleAudioInputSupported"})}(this._transport)}invite(e){return Array.isArray(e)&&0!==e.length?this._transport.sendRequest({name:"invite",invitees:e}):Promise.reject(new TypeError("Invalid Argument"))}isAudioMuted(){return this._transport.sendRequest({name:"is-audio-muted"})}isModerationOn(e){return this._transport.sendRequest({name:"is-moderation-on",mediaType:e})}isParticipantForceMuted(e,t){return this._transport.sendRequest({name:"is-participant-force-muted",participantId:e,mediaType:t})}isSharingScreen(){return this._transport.sendRequest({name:"is-sharing-screen"})}getAvatarURL(e){const{avatarURL:t}=this._participants[e]||{};return t}getDeploymentInfo(){return this._transport.sendRequest({name:"deployment-info"})}getDisplayName(e){const{displayName:t}=this._participants[e]||{};return t}getEmail(e){const{email:t}=this._participants[e]||{};return t}getIFrame(){return this._frame}getNumberOfParticipants(){return this._numberOfParticipants}isVideoAvailable(){return this._transport.sendRequest({name:"is-video-available"})}isVideoMuted(){return this._transport.sendRequest({name:"is-video-muted"})}pinParticipant(e){this.executeCommand("pinParticipant",e);}removeEventListener(e){this.removeAllListeners(e);}removeEventListeners(e){e.forEach((e=>this.removeEventListener(e)));}resizeLargeVideo(e,t){e<=this._width&&t<=this._height&&this.executeCommand("resizeLargeVideo",e,t);}sendProxyConnectionEvent(e){this._transport.sendEvent({data:[e],name:"proxy-connection-event"});}setAudioInputDevice(e,t){return function(e,t,n){return C(e,{id:n,kind:"audioinput",label:t})}(this._transport,e,t)}setAudioOutputDevice(e,t){return function(e,t,n){return C(e,{id:n,kind:"audiooutput",label:t})}(this._transport,e,t)}setLargeVideoParticipant(e){this.executeCommand("setLargeVideoParticipant",e);}setVideoInputDevice(e,t){return function(e,t,n){return C(e,{id:n,kind:"videoinput",label:t})}(this._transport,e,t)}startRecording(e){this.executeCommand("startRecording",e);}stopRecording(e){this.executeCommand("startRecording",e);}}},872:(e,t,n)=>{e.exports=n(754).default;},571:(e,t)=>{const n=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*\:/;t.parse=function(e){const i="object"==typeof(arguments.length<=1?void 0:arguments[1])&&(arguments.length<=1?void 0:arguments[1]),r=(arguments.length<=1?0:arguments.length-1)>1||!i?arguments.length<=1?void 0:arguments[1]:void 0,s=(arguments.length<=1?0:arguments.length-1)>1&&(arguments.length<=2?void 0:arguments[2])||i||{},o=JSON.parse(e,r);return "ignore"===s.protoAction?o:o&&"object"==typeof o&&e.match(n)?(t.scan(o,s),o):o},t.scan=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[e];for(;n.length;){const e=n;n=[];for(const i of e){if(Object.prototype.hasOwnProperty.call(i,"__proto__")){if("remove"!==t.protoAction)throw new SyntaxError("Object contains forbidden prototype property");delete i.__proto__;}for(const e in i){const t=i[e];t&&"object"==typeof t&&n.push(i[e]);}}}},t.safeParse=function(e,n){try{return t.parse(e,n)}catch(e){return null}};},415:e=>{function t(){return new DOMException("The request is not allowed","NotAllowedError")}e.exports=async function(e){try{await async function(e){if(!navigator.clipboard)throw t();return navigator.clipboard.writeText(e)}(e);}catch(n){try{await async function(e){const n=document.createElement("span");n.textContent=e,n.style.whiteSpace="pre",n.style.webkitUserSelect="auto",n.style.userSelect="all",document.body.appendChild(n);const i=window.getSelection(),r=window.document.createRange();i.removeAllRanges(),r.selectNode(n),i.addRange(r);let s=!1;try{s=window.document.execCommand("copy");}finally{i.removeAllRanges(),window.document.body.removeChild(n);}if(!s)throw t()}(e);}catch(e){throw e||n||t()}}};},620:e=>{var t,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this);}e.exports=s,e.exports.once=function(e,t){return new Promise((function(n,i){function r(n){e.removeListener(t,s),i(n);}function s(){"function"==typeof e.removeListener&&e.removeListener("error",r),n([].slice.call(arguments));}f(e,t,s,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&f(e,"error",t,{once:!0});}(e,r);}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function l(e,t,n,i){var r,s,o,l;if(a(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),void 0===o)o=s[t]=n,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(r=c(e))>0&&o.length>r&&!o.warned){o.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=o.length,l=d,console&&console.warn&&console.warn(l);}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=d.bind(i);return r.listener=n,i.wrapFn=r,r}function u(e,t,n){var i=e._events;if(void 0===i)return [];var r=i[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(r):g(r,r.length)}function p(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function g(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function f(e,t,n,i){if("function"==typeof e.on)i.once?e.once(t,n):e.on(t,n);else {if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function r(s){i.once&&e.removeEventListener(t,r),n(s);}));}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e;}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0;},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||r(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,s=this._events;if(void 0!==s)r=r&&void 0===s.error;else if(!r)return !1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(void 0===c)return !1;if("function"==typeof c)i(c,this,t);else {var l=c.length,d=g(c,l);for(n=0;n<l;++n)i(d[n],this,t);}return !0},s.prototype.addListener=function(e,t){return l(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return l(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,i,r,s,o;if(a(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(r=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,r=s;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop();}(n,r),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t);}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var r,s=Object.keys(n);for(i=0;i<s.length;++i)"removeListener"!==(r=s[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return u(this,e,!0)},s.prototype.rawListeners=function(e){return u(this,e,!1)},s.listenerCount=function(e,t){return "function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},s.prototype.listenerCount=p,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};},691:(e,t,n)=>{var i=n(719);function r(e,t){this.logStorage=e,this.stringifyObjects=!(!t||!t.stringifyObjects)&&t.stringifyObjects,this.storeInterval=t&&t.storeInterval?t.storeInterval:3e4,this.maxEntryLength=t&&t.maxEntryLength?t.maxEntryLength:1e4,Object.keys(i.levels).forEach(function(e){this[i.levels[e]]=function(){this._log.apply(this,arguments);}.bind(this,e);}.bind(this)),this.storeLogsIntervalID=null,this.queue=[],this.totalLen=0,this.outputCache=[];}r.prototype.stringify=function(e){try{return JSON.stringify(e)}catch(e){return "[object with circular refs?]"}},r.prototype.formatLogMessage=function(e){for(var t="",n=1,r=arguments.length;n<r;n++){var s=arguments[n];!this.stringifyObjects&&e!==i.levels.ERROR||"object"!=typeof s||(s=this.stringify(s)),t+=s,n!==r-1&&(t+=" ");}return t.length?t:null},r.prototype._log=function(){var e=arguments[1],t=this.formatLogMessage.apply(this,arguments);if(t){var n=this.queue[this.queue.length-1],i=n&&n.text;i===t?n.count+=1:(this.queue.push({text:t,timestamp:e,count:1}),this.totalLen+=t.length);}this.totalLen>=this.maxEntryLength&&this._flush(!0,!0);},r.prototype.start=function(){this._reschedulePublishInterval();},r.prototype._reschedulePublishInterval=function(){this.storeLogsIntervalID&&(window.clearTimeout(this.storeLogsIntervalID),this.storeLogsIntervalID=null),this.storeLogsIntervalID=window.setTimeout(this._flush.bind(this,!1,!0),this.storeInterval);},r.prototype.flush=function(){this._flush(!1,!0);},r.prototype._flush=function(e,t){this.totalLen>0&&(this.logStorage.isReady()||e)&&(this.logStorage.isReady()?(this.outputCache.length&&(this.outputCache.forEach(function(e){this.logStorage.storeLogs(e);}.bind(this)),this.outputCache=[]),this.logStorage.storeLogs(this.queue)):this.outputCache.push(this.queue),this.queue=[],this.totalLen=0),t&&this._reschedulePublishInterval();},r.prototype.stop=function(){this._flush(!1,!1);},e.exports=r;},719:e=>{var t={trace:0,debug:1,info:2,log:3,warn:4,error:5};o.consoleTransport=console;var n=[o.consoleTransport];o.addGlobalTransport=function(e){-1===n.indexOf(e)&&n.push(e);},o.removeGlobalTransport=function(e){var t=n.indexOf(e);-1!==t&&n.splice(t,1);};var i={};function r(){var e={methodName:"",fileLocation:"",line:null,column:null},t=new Error,n=t.stack?t.stack.split("\n"):[];if(!n||n.length<3)return e;var i=null;return n[3]&&(i=n[3].match(/\s*at\s*(.+?)\s*\((\S*)\s*:(\d*)\s*:(\d*)\)/)),!i||i.length<=4?(0===n[2].indexOf("log@")?e.methodName=n[3].substr(0,n[3].indexOf("@")):e.methodName=n[2].substr(0,n[2].indexOf("@")),e):(e.methodName=i[1],e.fileLocation=i[2],e.line=i[3],e.column=i[4],e)}function s(){var e=arguments[0],s=arguments[1],o=Array.prototype.slice.call(arguments,2);if(!(t[s]<e.level))for(var a=!(e.options.disableCallerInfo||i.disableCallerInfo)&&r(),c=n.concat(e.transports),l=0;l<c.length;l++){var d=c[l],h=d[s];if(h&&"function"==typeof h){var u=[];u.push((new Date).toISOString()),e.id&&u.push("["+e.id+"]"),a&&a.methodName.length>1&&u.push("<"+a.methodName+">: ");var p=u.concat(o);h.bind(d).apply(d,p);}}}function o(e,n,i,r){this.id=n,this.options=r||{},this.transports=i,this.transports||(this.transports=[]),this.level=t[e];for(var o=Object.keys(t),a=0;a<o.length;a++)this[o[a]]=s.bind(null,this,o[a]);}o.setGlobalOptions=function(e){i=e||{};},o.prototype.setLevel=function(e){this.level=t[e];},e.exports=o,o.levels={TRACE:"trace",DEBUG:"debug",INFO:"info",LOG:"log",WARN:"warn",ERROR:"error"};},481:(e,t,n)=>{var i=n(719),r=n(691),s={},o=[],a=i.levels.TRACE;e.exports={addGlobalTransport:function(e){i.addGlobalTransport(e);},removeGlobalTransport:function(e){i.removeGlobalTransport(e);},setGlobalOptions:function(e){i.setGlobalOptions(e);},getLogger:function(e,t,n){var r=new i(a,e,t,n);return e?(s[e]=s[e]||[],s[e].push(r)):o.push(r),r},setLogLevelById:function(e,t){for(var n=t?s[t]||[]:o,i=0;i<n.length;i++)n[i].setLevel(e);},setLogLevel:function(e){a=e;for(var t=0;t<o.length;t++)o[t].setLevel(e);for(var n in s){var i=s[n]||[];for(t=0;t<i.length;t++)i[t].setLevel(e);}},levels:i.levels,LogCollector:r};}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]});},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(872)})()}));
    });
    unwrapExports(external_api_min);
    external_api_min.JitsiMeetExternalAPI;

    var JitsiMeetAPI_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.JitsiMeetExternalAPI = void 0;
    exports.JitsiMeetExternalAPI = external_api_min;
    });
    unwrapExports(JitsiMeetAPI_1);
    var JitsiMeetAPI_2 = JitsiMeetAPI_1.JitsiMeetExternalAPI;

    var Omnidesk =  (function () {
        function Omnidesk() {
            this.methods = null;
        }
        Omnidesk.prototype.initJitsi = function (url, options) {
            this.methods = new JitsiMeetAPI_2(url, options);
        };
        Omnidesk.prototype.setDisplayName = function (name) {
            this.methods.executeCommand("displayName", name);
        };
        Omnidesk.prototype.setPassword = function (password) {
            this.methods.executeCommand("password", password);
        };
        Omnidesk.prototype.toggleLobby = function (enable) {
            this.methods.executeCommand("toggleLobby", enable);
        };
        Omnidesk.prototype.sendTones = function (tones, duration, pause) {
            this.methods.executeCommand("sendTones", { tones: tones, duration: duration, pause: pause });
        };
        Omnidesk.prototype.subject = function (subject) {
            this.methods.executeCommand("subject", subject);
        };
        Omnidesk.prototype.toggleAudio = function () {
            this.methods.executeCommand("toggleAudio");
        };
        Omnidesk.prototype.toggleVideo = function () {
            this.methods.executeCommand("toggleVideo");
        };
        Omnidesk.prototype.toggleFilmStrip = function () {
            this.methods.executeCommand("toggleFilmStrip");
        };
        Omnidesk.prototype.toggleChat = function () {
            this.methods.executeCommand("toggleChat");
        };
        Omnidesk.prototype.toggleShareScreen = function () {
            this.methods.executeCommand("toggleShareScreen");
        };
        Omnidesk.prototype.toggleTileView = function () {
            this.methods.executeCommand("toggleTileView");
        };
        Omnidesk.prototype.hangUp = function () {
            this.methods.executeCommand("hangup");
        };
        Omnidesk.prototype.setEmail = function (email) {
            this.methods.executeCommand("email", email);
        };
        Omnidesk.prototype.setAvatar = function (avatarUrl) {
            this.methods.executeCommand("avatarUrl", avatarUrl);
        };
        Omnidesk.prototype.sendEndpointTextMessage = function (receiverParticipantId, text) {
            this.methods.executeCommand("sendEndpointTextMessage", receiverParticipantId, text);
        };
        Omnidesk.prototype.setLargeVideoParticipant = function (participantId) {
            this.methods.executeCommand("setLargeVideoParticipant", participantId);
        };
        Omnidesk.prototype.setVideoQuality = function (resolution) {
            this.methods.executeCommand("setVideoQuality", resolution);
        };
        Omnidesk.prototype.muteEveryone = function () {
            this.methods.executeCommand("muteEveryone");
        };
        Omnidesk.prototype.startRecording = function (recordingOptions) {
            this.methods.executeCommand("startRecording", recordingOptions);
        };
        Omnidesk.prototype.stopRecording = function (mode) {
            this.methods.executeCommand("stopRecording", mode);
        };
        Omnidesk.prototype.initiatePrivateChat = function (participantID) {
            this.methods.executeCommand("initiatePrivateChat", participantID);
        };
        Omnidesk.prototype.cancelPrivateChat = function () {
            this.methods.executeCommand("cancelPrivateChat");
        };
        Omnidesk.prototype.getContentSharingParticipants = function () {
            return this.methods.executeCommand("getContentSharingParticipants");
        };
        Omnidesk.prototype.kickParticipant = function (participantId) {
            this.methods.executeCommand("kickParticipant", participantId);
        };
        Omnidesk.prototype.overwriteConfig = function (config) {
            this.methods.executeCommand("overwriteConfig", config);
        };
        Omnidesk.prototype.setTileView = function (enabled) {
            this.methods.executeCommand("setTileView", enabled);
        };
        Omnidesk.prototype.toggleCamera = function () {
            this.methods.executeCommand("toggleCamera");
        };
        Omnidesk.prototype.toggleCameraMirror = function () {
            this.methods.executeCommand("toggleCameraMirror");
        };
        Omnidesk.prototype.toggleRaisedHand = function () {
            this.methods.executeCommand("toggleRaiseHand");
        };
        Omnidesk.prototype.toggleVirtualBackgroundDialog = function () {
            this.methods.executeCommand("toggleVirtualBackgroundDialog");
        };
        Omnidesk.prototype.setParticipantVolume = function (participantId, volume) {
            this.methods.executeCommand("setParticipantVolume", participantId, volume);
        };
        Omnidesk.prototype.askToUnmute = function (participantId) {
            this.methods.executeCommand("askToUnmute", participantId);
        };
        Omnidesk.prototype.captureLargeVideoScreenshot = function () {
            return this.methods.captureLargeVideoScreenshot();
        };
        Omnidesk.prototype.getAvailableDevices = function () {
            return this.methods.getAvailableDevices();
        };
        Omnidesk.prototype.getCurrentDevices = function () {
            return this.methods.getCurrentDevices();
        };
        Omnidesk.prototype.getLivestreamUrl = function () {
            return this.methods.getLivestreamUrl();
        };
        Omnidesk.prototype.getParticipantsInfo = function () {
            return this.methods.getParticipantsInfo();
        };
        Omnidesk.prototype.getVideoQuality = function () {
            return this.methods.getVideoQuality();
        };
        Omnidesk.prototype.isDeviceChangeAvailable = function (deviceType) {
            return this.methods.isDeviceChangeAvailable(deviceType);
        };
        Omnidesk.prototype.isDeviceListAvailable = function () {
            return this.methods.isDeviceListAvailable();
        };
        Omnidesk.prototype.isMultipleAudioInputSupported = function () {
            return this.methods.isMultipleAudioInputSupported();
        };
        Omnidesk.prototype.pinParticipant = function (participantId) {
            this.methods.pinParticipant(participantId);
        };
        Omnidesk.prototype.resizeLargeVideo = function (width, height) {
            this.methods.resizeLargeVideo(width, height);
        };
        Omnidesk.prototype.setAudioInputDevice = function (deviceLabel, deviceId) {
            this.methods.setAudioInputDevice(deviceLabel, deviceId);
        };
        Omnidesk.prototype.setAudioOutputDevice = function (deviceLabel, deviceId) {
            this.methods.setAudioOutputDevice(deviceLabel, deviceId);
        };
        Omnidesk.prototype.setVideoInputDevice = function (deviceLabel, deviceId) {
            this.methods.setVideoInputDevice(deviceLabel, deviceId);
        };
        Omnidesk.prototype.getNumberOfParticipants = function () {
            return this.methods.getNumberOfParticipants();
        };
        Omnidesk.prototype.getAvatarURL = function (participantId) {
            return this.methods.getAvatarURL(participantId);
        };
        Omnidesk.prototype.getDisplayName = function (participantId) {
            return this.methods.getDisplayName(participantId);
        };
        Omnidesk.prototype.getEmail = function (participantId) {
            return this.methods.getEmail(participantId);
        };
        Omnidesk.prototype.getIframe = function () {
            return this.methods.getIFrame();
        };
        Omnidesk.prototype.isAudioMuted = function () {
            return this.methods.isAudioMuted();
        };
        Omnidesk.prototype.isVideoMuted = function () {
            return this.methods.isVideoMuted();
        };
        Omnidesk.prototype.isAudioAvailable = function () {
            return this.methods.isAudioAvailable();
        };
        Omnidesk.prototype.isVideoAvailable = function () {
            return this.methods.isVideoAvailable();
        };
        Omnidesk.prototype.dispose = function () {
            this.methods.dispose();
        };
        Omnidesk.prototype.cameraErrorEvent = function (callback) {
            this.methods.addEventListener("cameraError", callback);
        };
        Omnidesk.prototype.avatarChangedEvent = function (callback) {
            this.methods.addEventListener("avatarChanged", callback);
        };
        Omnidesk.prototype.audioAvailabilityChangedEvent = function (callback) {
            this.methods.addEventListener("audioAvailabilityChanged", callback);
        };
        Omnidesk.prototype.audioMuteStatusChangedEvent = function (callback) {
            this.methods.addEventListener("audioMuteStatusChanged", callback);
        };
        Omnidesk.prototype.contentSharingParticipantsChangedEvent = function (callback) {
            this.methods.addEventListener("contentSharingParticipantsChanged", callback);
        };
        Omnidesk.prototype.endpointTextMessageReceivedEvent = function (callback) {
            this.methods.addEventListener("endpointTextMessageReceived", callback);
        };
        Omnidesk.prototype.largeVideoChangedEvent = function (callback) {
            this.methods.addEventListener("largeVideoChanged", callback);
        };
        Omnidesk.prototype.logEvent = function (callback) {
            this.methods.addEventListener("log", callback);
        };
        Omnidesk.prototype.micErrorEvent = function (callback) {
            this.methods.addEventListener("micError", callback);
        };
        Omnidesk.prototype.screenSharingStatusChangedEvent = function (callback) {
            this.methods.addEventListener("screenSharingStatusChanged", callback);
        };
        Omnidesk.prototype.dominantSpeakerChangedEvent = function (callback) {
            this.methods.addEventListener("dominantSpeakerChanged", callback);
        };
        Omnidesk.prototype.raiseHandUpdatedEvent = function (callback) {
            this.methods.addEventListener("raiseHandUpdated", callback);
        };
        Omnidesk.prototype.tileViewChangedEvent = function (callback) {
            this.methods.addEventListener("tileViewChanged", callback);
        };
        Omnidesk.prototype.chatUpdatedEvent = function (callback) {
            this.methods.addEventListener("chatUpdated", callback);
        };
        Omnidesk.prototype.incomingMessageEvent = function (callback) {
            this.methods.addEventListener("incomingMessage", callback);
        };
        Omnidesk.prototype.outgoingMessageEvent = function (callback) {
            this.methods.addEventListener("outgoingMessage", callback);
        };
        Omnidesk.prototype.displayNameChangeEvent = function (callback) {
            this.methods.addEventListener("displayNameChange", callback);
        };
        Omnidesk.prototype.deviceListChangedEvent = function (callback) {
            this.methods.addEventListener("deviceListChanged", callback);
        };
        Omnidesk.prototype.emailChangeEvent = function (callback) {
            this.methods.addEventListener("emailChange", callback);
        };
        Omnidesk.prototype.feedbackSubmittedEvent = function (callback) {
            this.methods.addEventListener("feedbackSubmitted", callback);
        };
        Omnidesk.prototype.filmstripDisplayChangedEvent = function (callback) {
            this.methods.addEventListener("filmstripDisplayChanged", callback);
        };
        Omnidesk.prototype.participantJoinedEvent = function (callback) {
            this.methods.addEventListener("participantJoined", callback);
        };
        Omnidesk.prototype.participantKickedOutEvent = function (callback) {
            this.methods.addEventListener("participantKickedOut", callback);
        };
        Omnidesk.prototype.participantLeftEvent = function (callback) {
            this.methods.addEventListener("participantLeft", callback);
        };
        Omnidesk.prototype.participantRoleChangedEvent = function (callback) {
            this.methods.addEventListener("participantRoleChanged", callback);
        };
        Omnidesk.prototype.passwordRequiredEvent = function (callback) {
            this.methods.addEventListener("passwordRequired", callback);
        };
        Omnidesk.prototype.videoConferenceJoinedEvent = function (callback) {
            this.methods.addEventListener("videoConferenceJoined", callback);
        };
        Omnidesk.prototype.videoConferenceLeftEvent = function (callback) {
            this.methods.addEventListener("videoConferenceLeft", callback);
        };
        Omnidesk.prototype.videoAvailabilityChangedEvent = function (callback) {
            this.methods.addEventListener("videoAvailabilityChanged", callback);
        };
        Omnidesk.prototype.videoMuteStatusChangedEvent = function (callback) {
            this.methods.addEventListener("videoMuteStatusChanged", callback);
        };
        Omnidesk.prototype.videoQualityChangedEvent = function (callback) {
            this.methods.addEventListener("videoQualityChanged", callback);
        };
        Omnidesk.prototype.readyToCloseEvent = function (callback) {
            this.methods.addEventListener("readyToClose", callback);
        };
        Omnidesk.prototype.subjectChangeEvent = function (callback) {
            this.methods.addEventListener("subjectChange", callback);
        };
        Omnidesk.prototype.suspendDetectedEvent = function (callback) {
            this.methods.addEventListener("suspendDetected", callback);
        };
        Omnidesk.prototype.recordingStatusChangedEvent = function (callback) {
            this.methods.addEventListener("recordingStatusChanged", callback);
        };
        return Omnidesk;
    }());

    var __extends$3 = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var __assign$1 = (undefined && undefined.__assign) || function () {
        __assign$1 = Object.assign || function(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                    t[p] = s[p];
            }
            return t;
        };
        return __assign$1.apply(this, arguments);
    };
    var __awaiter$6 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$5 = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    var WebapiClient =  (function () {
        function WebapiClient(options) {
            this._username = null;
            this._localStoreManager = new LocalStoreManager();
            this._loginProfileSubject = new BehaviorSubject({ status: LoginProfileStatus.UNKNOWN, logged: false });
            this._connectionEventSubject = new BehaviorSubject({ connected: false });
            this._webrtcControlMessageNotifier = new Subject();
            this._omnidesk = new Omnidesk();
            if (options === undefined) {
                throw new TypeError("WebapiClient - Not enough arguments on constructor");
            }
            this._instanceId = Array.from({ length: 10 }, function () { return Math.random().toString(36)[3]; }).join("");
            this._log = Log$1.create("", this.instanceId, new DefaultLogConfigurator(new WebapiClientLogConfig(options.logConfig)));
            this._log.info("Initialize new Client, configuration: ", options);
            try {
                this._options = new WebapiConfig(options);
            }
            catch (e) {
                this._log.fatal("Error in configuration", e);
                throw e;
            }
            this._log.info("Configuration used: ", this.options);
            this._logConfigImpl = new WebapiClientLogConfigurator(this);
            this._log.client = this;
            this._initializeClient();
        }
        Object.defineProperty(WebapiClient.prototype, "omnidesk", {
            get: function () {
                return this._omnidesk;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "webrtc", {
            get: function () {
                return this._webrtc;
            },
            set: function (webrtc) {
                if (webrtc) {
                    if (!webrtc.client) {
                        this._log.debug("Attach WebRTCManager to client");
                    }
                    this._webrtc = webrtc;
                    this._webrtc.attachToClient(this);
                    this._webrtc.initFromClient(this._webrtcControlMessageNotifier);
                }
                else {
                    if (this._webrtc) {
                        this._log.debug("Disable and unlink WebRTCManager to client");
                        this._webrtc.stop();
                        this._webrtc = webrtc;
                    }
                }
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "instanceId", {
            get: function () {
                return this._instanceId;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "logConfigurator", {
            get: function () {
                return this._logConfigImpl;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "options", {
            get: function () {
                return this._options;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "transport", {
            get: function () {
                return this._transport;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "methods", {
            get: function () {
                return this._methods;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "loginProfile", {
            get: function () {
                return this._loginProfileSubject.asObservable();
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "loginProfileLoggedOnNewSession", {
            get: function () {
                return this._loginProfileLoggedOnNewSession;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "connectionEvent", {
            get: function () {
                return this._connectionEventSubject.asObservable();
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "callNotification", {
            get: function () {
                return this._channelNotification.pipe(map(function (data) { return data.callInfo; }));
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "sessionId", {
            get: function () {
                return this._sessionId;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "deviceId", {
            get: function () {
                return this._deviceId;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "username", {
            get: function () {
                return this._username;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClient.prototype, "accessToken", {
            get: function () {
                return this._getAccessToken(false);
            },
            enumerable: false,
            configurable: true
        });
        WebapiClient.prototype._initializeClient = function () {
            var _this = this;
            var sessionAccessToken = this._getAccessToken(true);
            if (!this.options.rememberMe) {
                this.cleanAllCredential(false);
            }
            if (this.options.url.startsWith("ws")) {
                this.options.url = this.options.url.replace(new RegExp("^ws"), "http");
            }
            this._loginProfileSubject.pipe(skip(1)).subscribe(function (statusEvent) {
                _this._log.debug("Login profile status changed", statusEvent);
            });
            this._connectionEventSubject.subscribe(function (event) {
                if (event.connected) {
                    _this._forceOpenSocket = false;
                }
            });
            this._transport = new JsonRpcWebsocket(this, function (timeout) {
                var accessToken = _this._getAccessToken();
                return accessToken
                    ? _this._loginRequest(timeout, LoginType.AccessToken, accessToken)
                    : of({
                        accessToken: accessToken,
                        deviceId: _this.deviceId,
                        sessionId: _this.sessionId,
                        username: _this.username,
                    });
            }, this._connectionEventSubject, this.options.retryOptions, this.options.heartbeatInterval, this.options.storageUrl);
            this.transport.loading = false;
            this._methods = new WebapiClientMethods(this, this.handleChannelNotification(new Subject()), this.handleClientCommandNotification(new Subject()), function () {
                _this._forceOpenSocket = true;
                _this._transport.stopOpenSocket = false;
            }, function (timeout, loginType, usernameOrAccessToken, password) { return _this._loginRequest(timeout, loginType, usernameOrAccessToken, password); }, function (rememberMe) {
                _this.options.rememberMe = rememberMe ? true : false;
                if (!_this.options.rememberMe) {
                    _this._cleanAccessToken(false);
                }
            }, function (logoutResponse) { return __awaiter$6(_this, void 0, void 0, function () {
                var response;
                return __generator$5(this, function (_a) {
                    switch (_a.label) {
                        case 0: return [4 , logoutResponse];
                        case 1:
                            response = _a.sent();
                            if (response) {
                                this.cleanAllCredential(true);
                                this.disconnect();
                            }
                            return [2 , response];
                    }
                });
            }); });
            var loginProfileResult = this.transport.getResponseOf(1 );
            var loginProfileEvent = merge(loginProfileResult.result, loginProfileResult.notification).pipe(share());
            var loggedLoginProfile = loginProfileEvent.pipe(filter(function (event) { return event.logged; }));
            this._loginProfileLoggedOnNewSession = loggedLoginProfile.pipe(distinctUntilChanged(function (prev, curr) {
                if (prev.sessionId === curr.sessionId) {
                    _this._log.verbose("SessionId not changed, " + curr.sessionId);
                    return true;
                }
                else {
                    _this._log.info("SessionId changed - previous " + prev.sessionId + ", current " + curr.sessionId);
                    return false;
                }
            }), share());
            loginProfileEvent.subscribe(function (loginProfile) { return _this._handleLoginProfileEvent(loginProfile); });
            this._updateLoginProfileSubject(loggedLoginProfile.pipe(take(1)))
                .pipe(concatMap(function (data) { return __awaiter$6(_this, void 0, void 0, function () {
                var err_1;
                return __generator$5(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this._options.remoteControl) return [3 , 4];
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 3, , 4]);
                            return [4 , this.methods.startClientCommandNotify()];
                        case 2:
                            _a.sent();
                            return [3 , 4];
                        case 3:
                            err_1 = _a.sent();
                            this._log.error("error on startClientCommandNotify", err_1);
                            return [3 , 4];
                        case 4: return [2 , data];
                    }
                });
            }); }))
                .subscribe({
                error: function (err) {
                    _this._log.error("Error on update loginProfile", err);
                },
            });
            var currentAccessToken = sessionAccessToken || this._getAccessToken();
            if (currentAccessToken) {
                if (this.options.selfManagedLogin) {
                    this._log.info("Find stored accessToken " + currentAccessToken + " and options.selfManagedLogin is true, try login");
                    setTimeout(function () {
                        _this.oneTimeLoginByAccessToken(currentAccessToken);
                    });
                }
                else {
                    this.cleanAllCredential(true);
                    this._log.info("Find stored accessToken " + currentAccessToken + " but options.selfManagedLogin is false, nothing to do");
                }
            }
            else {
                this._updateLoginProfileSubject(throwError(null)).subscribe({
                    error: function () {
                        _this._log.info("Credential requested, wait login");
                    },
                });
            }
        };
        WebapiClient.prototype.handleChannelNotification = function (channelNotification) {
            var _this = this;
            this._channelNotification = merge(channelNotification, this._webrtcControlMessageNotifier.pipe(filter(function (webrtcControlMessage) { return !webrtcControlMessage._isFromServer; }), map(function (webrtcControlMessage) {
                return {
                    channel: webrtcControlMessage._realChannelType,
                    callInfo: buildCallInfoFromWebrtcControlMessage(webrtcControlMessage),
                    webrtcControlMessage: webrtcControlMessage,
                };
            }))).pipe(map(function (callInfo) { return adjustCallInfoWithMediaInfo(callInfo, _this.webrtc); }), share());
            this._channelNotification
                .pipe(filter(function (channelEvent) {
                if (!!(channelEvent && channelEvent.callInfo) && (channelEvent && channelEvent.webrtcControlMessage ? channelEvent.webrtcControlMessage._isFromServer : true)) {
                    switch (channelEvent.channel) {
                        case ChannelType.PhoneCall:
                            var callInfo = channelEvent.callInfo;
                            return callInfo.deviceType === ExtenType.WEBRTC && callInfo.device && !!_this.webrtc ;
                        case ChannelType.Video:
                        case ChannelType.Omnidesk:
                            return true;
                        default:
                            return false;
                    }
                }
                else {
                    return false;
                }
            }), map(function (channelEvent) {
                return buildWebrtcControlMessageFromChannelEvent(channelEvent,
                channelEvent.webrtcControlMessage ? channelEvent.webrtcControlMessage._isFromServer : true,
                channelEvent.channel === ChannelType.Video ? { direction: CallDirection.inbound } : null);
            }))
                .subscribe(this._webrtcControlMessageNotifier);
            return channelNotification;
        };
        WebapiClient.prototype.handleClientCommandNotification = function (commandNotification) {
            var _this = this;
            commandNotification
                .asObservable()
                .pipe(tap(function (command) {
                _this._log.debug("HandleClientCommand - Receiving message " + command.id, command);
            }), concatMap(function (command) { return __awaiter$6(_this, void 0, void 0, function () {
                return __generator$5(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            _a.trys.push([0, 2, , 3]);
                            return [4 , this.methods.sendClientCommandResponse(buildResponse(command, ClientCommandResult.RECEIVED))];
                        case 1:
                            if (_a.sent()) {
                                this._log.debug("HandleClientCommand - server confirm RECEIVED " + command.id + " - " + command.command);
                            }
                            else {
                                this._log.debug("HandleClientCommand - server not confirm RECEIVED " + command.id + " - " + command.command);
                            }
                            return [3 , 3];
                        case 2:
                            _a.sent();
                            this._log.warn("HandleClientCommand - error on send command RECEIVED " + command.id + " - " + command.command);
                            return [3 , 3];
                        case 3: return [2 , command];
                    }
                });
            }); }), concatMap(function (command) {
                _this._log.debug("HandleClientCommand - Start manage message " + command.id + " - " + command.command);
                return _this.clientCommandHandler(command).catch(function (err) {
                    var _a;
                    _this._log.error("HandleClientCommand - Error on manage message " + ((_a = err === null || err === void 0 ? void 0 : err.controlMessage) === null || _a === void 0 ? void 0 : _a.internalId) + " " + command.id + " - " + command.command, err);
                    return err.command;
                });
            }))
                .subscribe(function (command) {
                _this._log.debug("HandleClientCommand - End manage message " + command.id + " - " + command.command);
            });
            return commandNotification;
        };
        WebapiClient.prototype.clientCommandHandler = function (command) {
            var _a;
            return __awaiter$6(this, void 0, void 0, function () {
                var channelId, media, result, e_2, e_3;
                return __generator$5(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            _b.trys.push([0, 8, , 9]);
                            if (!isClientDialCommand(command)) return [3 , 1];
                            try {
                                channelId = channelIdToChannelType(command.channelId);
                                media = (_a = command.media) === null || _a === void 0 ? void 0 : _a.reduce(function (mediaParam, callMedia) {
                                    if (callMedia) {
                                        mediaParam[callMedia.trim().toLowerCase()] = true;
                                    }
                                    return mediaParam;
                                }, {});
                                this.methods.sendClientCommandResponse(buildResponse(command, ClientCommandResult.OK));
                                this.methods.dial(__assign$1(__assign$1({}, command), { channelId: channelId, media: media }));
                            }
                            catch (e) {
                                this.methods.sendClientCommandResponse(buildResponse(command, ClientCommandResult.FAILED, "error on execute dial - " + e));
                                this._log.error("Error on handle DialCommandCommandNotification", e);
                                throw e;
                            }
                            return [3 , 7];
                        case 1:
                            if (!this.options.remoteCommandHandler) return [3 , 6];
                            _b.label = 2;
                        case 2:
                            _b.trys.push([2, 4, , 5]);
                            return [4 , this.options.remoteCommandHandler(command)];
                        case 3:
                            result = _b.sent();
                            this.methods.sendClientCommandResponse(buildResponse(command, result ? result.result : ClientCommandResult.FAILED, result ? result.resultMessage : "Unknow result"));
                            return [3 , 5];
                        case 4:
                            e_2 = _b.sent();
                            this.methods.sendClientCommandResponse(buildResponse(command, ClientCommandResult.FAILED, "error on remoteControlCommandHandler for command " + command.command.toLowerCase() + " - " + e_2));
                            this._log.error("Error on remoteControlCommandHandler", e_2);
                            throw e_2;
                        case 5: return [3 , 7];
                        case 6:
                            this.methods.sendClientCommandResponse(buildResponse(command, ClientCommandResult.FAILED, "Not implemented"));
                            _b.label = 7;
                        case 7: return [3 , 9];
                        case 8:
                            e_3 = _b.sent();
                            e_3.command = command;
                            throw e_3;
                        case 9: return [2 , command];
                    }
                });
            });
        };
        WebapiClient.prototype._handleLoginProfileEvent = function (loginProfile) {
            if (loginProfile && (this.username == null || this.username === loginProfile.username)) {
                if (this.username === null && loginProfile.username) {
                    this._username = loginProfile.username;
                }
                switch (loginProfile.status) {
                    case LoginProfileStatus.REFRESH:
                        if (loginProfile.sessionId && loginProfile.sessionId !== this.sessionId) {
                            this._sessionId = loginProfile.sessionId;
                        }
                        if (loginProfile.accessToken && loginProfile.accessToken !== this._getAccessToken()) {
                            this._saveAccessToken(loginProfile.accessToken);
                            var lastStatus = this._loginProfileSubject.value;
                            this._loginProfileSubject.next(loginProfile);
                            this._loginProfileSubject.next(lastStatus);
                        }
                        break;
                    case LoginProfileStatus.NOTLOGGED:
                        this.transport.disconnect();
                        this._loginProfileSubject.next(loginProfile);
                        break;
                    case LoginProfileStatus.SOCKET_NOTLOGGED:
                    case LoginProfileStatus.SOCKET_CLOSED_REQUEST_FORCE:
                    case LoginProfileStatus.SOCKET_CLOSED_BY_USER:
                        this.cleanAllCredential(false);
                        this._loginProfileSubject.next(loginProfile);
                        break;
                    case LoginProfileStatus.SOCKET_CLOSED_USER_NOT_ENABLED_MCS:
                    case LoginProfileStatus.SOCKET_CLOSED_USER_NOT_ENABLED:
                        this._loginProfileSubject.next(loginProfile);
                        break;
                    case LoginProfileStatus.PASSWORD_EXPIRED:
                        this.cleanAllCredential(true);
                        loginProfile.username = loginProfile.username || this.username || null;
                        this._loginProfileSubject.next(loginProfile);
                        break;
                    default:
                        if (loginProfile.sessionId && loginProfile.sessionId !== this.sessionId) {
                            this._sessionId = loginProfile.sessionId;
                        }
                        if (loginProfile.accessToken && loginProfile.accessToken !== this._getAccessToken()) {
                            this._saveAccessToken(loginProfile.accessToken);
                        }
                        var accessToken = this._getAccessToken();
                        if (loginProfile.status !== LoginProfileStatus.LOGGED && accessToken) {
                            this._methods.loginByAccessToken(accessToken, this.options.rememberMe);
                        }
                        else {
                            this._loginProfileSubject.next(loginProfile);
                        }
                        break;
                }
            }
        };
        WebapiClient.prototype._loginRequest = function (requestTimeout, loginType, usernameOrAccessToken, password) {
            var _this = this;
            var result = from(fetch(this.generateWsUrl(loginType === LoginType.Custom ? "/login_custom" : "/login", true, loginType === LoginType.Credential).replace(new RegExp("^ws"), "http"), {
                mode: "cors",
                credentials: "include",
                cache: "no-cache",
                method: "GET",
                headers: {
                    Authorization: loginType === LoginType.Credential ? "Basic " + encode(usernameOrAccessToken + ":" + password) : "Bearer " + usernameOrAccessToken,
                },
            }));
            if (requestTimeout) {
                result = result.pipe(timeout(requestTimeout));
            }
            return result.pipe(catchError(function (err) {
                if (err instanceof TimeoutError) {
                    throw err;
                }
                else {
                    throw new NoRouteToHost({
                        clazz: null,
                        code: -3,
                        message: err.message,
                    });
                }
            }), switchMap(function (fetchResponse) {
                return defer(function () { return __awaiter$6(_this, void 0, void 0, function () {
                    var loginResponse, response;
                    return __generator$5(this, function (_a) {
                        switch (_a.label) {
                            case 0:
                                if (!fetchResponse.ok) return [3 , 2];
                                return [4 , fetchResponse.text()];
                            case 1:
                                loginResponse = _a.sent();
                                if (loginResponse) {
                                    try {
                                        response = JSON.parse(loginResponse);
                                        this._saveAccessToken(response.accessToken);
                                        this._localStoreManager.deleteData("teleniaWebApiDeviceId");
                                        this._deviceId = response.deviceId;
                                        this._sessionId = response.sessionId;
                                        this._username = response.username;
                                        return [2 , response];
                                    }
                                    catch (e) {
                                        throw new WebAPI({
                                            clazz: null,
                                            code: -1,
                                            message: "Login response is invalid",
                                        });
                                    }
                                }
                                else {
                                    throw new WebAPI({
                                        clazz: null,
                                        code: -2,
                                        message: "Login response without accessToken",
                                    });
                                }
                                return [3 , 3];
                            case 2:
                                switch (fetchResponse.status) {
                                    case 403:
                                        throw PasswordExpired.newInstance(fetchResponse.headers.get("TeleniaUser"), "true" === fetchResponse.headers.get("TeleniaCheckSecurityEnabled"));
                                    case 497:
                                        throw UserNotEnabledOnMcs.newInstance(fetchResponse.headers.get("TeleniaUser"));
                                    case 498:
                                        throw UserNotEnabled.newInstance(fetchResponse.headers.get("TeleniaUser"));
                                    default:
                                        throw new AuthorizationRequired({
                                            clazz: null,
                                            sessionId: this.sessionId,
                                            code: fetchResponse.status,
                                            message: fetchResponse.statusText,
                                        });
                                }
                                _a.label = 3;
                            case 3: return [2 ];
                        }
                    });
                }); });
            }));
        };
        WebapiClient.prototype._updateLoginProfileSubject = function (loginPromise) {
            var _this = this;
            return loginPromise.pipe(tap(function (response) {
                setTimeout(function () {
                    if (response) {
                        if (response.accessToken && response.accessToken !== _this._getAccessToken()) {
                            _this._saveAccessToken(response.accessToken);
                        }
                        _this._loginProfileSubject.next(response);
                    }
                });
            }), catchError(function (err) {
                if (!(err instanceof SocketClosed)) {
                    var newStatus_1 = LoginProfileStatus.RETRY;
                    if (err instanceof StopOpenSocket) {
                        newStatus_1 = LoginProfileStatus.SOCKET_CLOSED_REQUEST_FORCE;
                    }
                    setTimeout(function () { return _this._loginProfileSubject.next({ status: newStatus_1, logged: false }); });
                }
                throw err;
            }));
        };
        WebapiClient.prototype._cleanAccessToken = function (clearCookie) {
            try {
                if (this._intervalShortCookies) {
                    clearInterval(this._intervalShortCookies);
                    this._intervalShortCookies = null;
                }
                this._localStoreManager.deleteData("teleniaWebApiAccessToken");
                if (clearCookie) {
                    this._log.info("Removing access token teleniaWebApiAccessToken");
                    this._saveAccessToken(null);
                }
            }
            catch (e) { }
        };
        WebapiClient.prototype._getAccessToken = function (sessionOnly) {
            var cookieAccessToken = null;
            if (!this._accessToken) {
                var sessionAccessToken = this._localStoreManager.getData(this._getSessionStorageAccessTokenKey("teleniaWebApiAccessToken"));
                if (sessionAccessToken) {
                    cookieAccessToken = sessionAccessToken;
                }
                else if (!sessionOnly) {
                    if (navigator.cookieEnabled) {
                        var currentCookie = parse_1(document.cookie);
                        if (currentCookie && currentCookie.teleniaWebApiAccessToken) {
                            cookieAccessToken = currentCookie.teleniaWebApiAccessToken;
                        }
                    }
                }
            }
            return this._accessToken ? this._accessToken : cookieAccessToken;
        };
        WebapiClient.prototype._getSessionStorageAccessTokenKey = function (prefix) {
            return prefix + (this.options.cookie_path ? ("/" + this.options.cookie_path.trim()).replace("//", ".").replace("/", ".") : "") || "";
        };
        WebapiClient.prototype._saveAccessToken = function (accessToken) {
            var _this = this;
            this._accessToken = accessToken;
            this._localStoreManager.saveSessionData(accessToken || "", this._getSessionStorageAccessTokenKey("teleniaWebApiAccessToken"));
            if (navigator.cookieEnabled) {
                var cookieOpt = {};
                if (this.options.cookie_path) {
                    cookieOpt.path = this.options.cookie_path;
                }
                if (accessToken) {
                    if (this.options.selfManagedLogin && this.options.rememberMe) {
                        cookieOpt.expires = new Date(new Date().getTime() + 2592000000);
                    }
                    else {
                        if (this.options.selfManagedLogin) {
                            cookieOpt.expires = new Date(new Date().getTime() + 60000);
                            if (!this._intervalShortCookies) {
                                this._intervalShortCookies = setInterval(function () {
                                    var currentAccessToken = _this._getAccessToken();
                                    if (currentAccessToken) {
                                        _this._saveAccessToken(currentAccessToken);
                                    }
                                }, 50000);
                            }
                        }
                        else {
                            cookieOpt.expires = new Date(0);
                        }
                    }
                }
                else {
                    cookieOpt.expires = new Date(0);
                }
                if (accessToken) {
                    if (this.options.rememberMe) {
                        this._log.debug("Save accessToken to teleniaWebApiAccessToken", cookieOpt);
                    }
                }
                else {
                    this._log.debug("Clear accessToken from teleniaWebApiAccessToken", cookieOpt);
                }
                document.cookie = serialize_1("teleniaWebApiAccessToken", accessToken || "", cookieOpt);
            }
        };
        WebapiClient.prototype.isRequestEnableUntilReconnect = function () {
            return !!this.options.requestEnableUntilReconnect;
        };
        WebapiClient.prototype.generateWsUrl = function (path, ignoreAccessToken, ignoreSessionId) {
            var _a, _b;
            var sessionId = this.sessionId;
            var accessToken = this._getAccessToken();
            var deviceId = this.deviceId;
            var multisession = this.options.multisession;
            var wsurl = this.options.url.replace(new RegExp("^http"), "ws") + (path !== null && path !== void 0 ? path : "/ws/endpoint");
            var sessionParam = [];
            var sessionParams = (_a = this.options.sessionParams) !== null && _a !== void 0 ? _a : {};
            for (var key in sessionParams) {
                if ((key !== null && key !== void 0 ? key : false) && ((_b = sessionParams[key]) !== null && _b !== void 0 ? _b : false)) {
                    sessionParam.push(key.trim() + "=" + sessionParams[key].trim());
                }
            }
            if (this._forceOpenSocket) {
                sessionParam.push("force=true");
            }
            if (multisession) {
                sessionParam.push("multisession=true");
            }
            if (accessToken && !ignoreAccessToken) {
                sessionParam.push("access_token=" + accessToken);
            }
            if (deviceId) {
                sessionParam.push("deviceid=" + deviceId);
            }
            if (sessionId && !ignoreSessionId) {
                sessionParam.push("jsessionid=" + sessionId);
            }
            if (sessionParam.length > 0) {
                wsurl += ";" + sessionParam.join(";");
            }
            return wsurl;
        };
        WebapiClient.prototype.disconnect = function () {
            var notLoggedEvent = __assign$1({}, this._loginProfileSubject.value);
            notLoggedEvent.status = LoginProfileStatus.NOTLOGGED;
            notLoggedEvent.logged = false;
            this._handleLoginProfileEvent(notLoggedEvent);
        };
        WebapiClient.prototype.cleanAllCredential = function (clearPermanentData) {
            this._sessionId = null;
            this._cleanAccessToken(clearPermanentData);
        };
        WebapiClient.prototype.oneTimeLoginByAccessToken = function (accessToken) {
            return __awaiter$6(this, void 0, void 0, function () {
                var errorLoginProfile, error;
                return __generator$5(this, function (_a) {
                    if (this.oneTimeLoginByAccessTokenDone) {
                        this._log.warn("oneTimeLoginByAccessToken was just called at " + this.oneTimeLoginByAccessTokenDone.toISOString() + ", nothing to do");
                        return [2 , false];
                    }
                    this.oneTimeLoginByAccessTokenDone = new Date();
                    try {
                        return [2 , this._methods.loginByAccessToken(accessToken, this.options.rememberMe)];
                    }
                    catch (err) {
                        this._log.error("Unable to login", err);
                        errorLoginProfile = { status: LoginProfileStatus.RETRY, logged: false, username: this.username };
                        error = ErrorResolver.login(err);
                        if (error instanceof PasswordExpired) {
                            errorLoginProfile.status = LoginProfileStatus.PASSWORD_EXPIRED;
                            errorLoginProfile.username = error.username || errorLoginProfile.username;
                        }
                        this._log.error("Notify new status", errorLoginProfile);
                        this._loginProfileSubject.next(errorLoginProfile);
                        throw err;
                    }
                    return [2 ];
                });
            });
        };
        WebapiClient.version = pkg.version;
        return WebapiClient;
    }());
    var WebapiClientLogConfigurator =  (function (_super) {
        __extends$3(WebapiClientLogConfigurator, _super);
        function WebapiClientLogConfigurator(
        client) {
            var _this = _super.call(this) || this;
            _this.client = client;
            var enableValue = _this.client.options.logConfig.prefix ? _this.client.options.logConfig.prefix + "*" : "*";
            var enabled = WebapiClientLogConfigurator.disableNamespace();
            if (enabled) {
                if (enabled !== "*" && _this.client.options.logConfig.prefix && enabled.indexOf(_this.client.options.logConfig.prefix) < 0) {
                    enabled += "," + enableValue;
                }
            }
            else {
                enabled = enableValue;
            }
            WebapiClientLogConfigurator.enableNamespace(enabled);
            return _this;
        }
        Object.defineProperty(WebapiClientLogConfigurator.prototype, "enabled", {
            get: function () {
                return this.client.options.logConfig.enabled;
            },
            set: function (enabled) {
                this.client.options.logConfig.enabled = enabled;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClientLogConfigurator.prototype, "objectToJson", {
            get: function () {
                return this.client.options.logConfig.objectToJson;
            },
            set: function (objectToJson) {
                this.client.options.logConfig.objectToJson = !!objectToJson;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClientLogConfigurator.prototype, "instanceIdLogged", {
            get: function () {
                return this.client.options.logConfig.instanceIdLogged;
            },
            set: function (instanceIdLogged) {
                this.client.options.logConfig.instanceIdLogged = !!instanceIdLogged;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClientLogConfigurator.prototype, "logLevel", {
            get: function () {
                return this.enabled ? this.client.options.logConfig.logLevel : LogLevel.None;
            },
            set: function (logLevel) {
                if (logLevel && logLevel >= LogLevel.Verbose && logLevel <= LogLevel.None) {
                    this.client.options.logConfig.logLevel = logLevel;
                }
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClientLogConfigurator.prototype, "prefix", {
            get: function () {
                return this.client.options.logConfig.prefix;
            },
            set: function (prefix) {
                this.client.options.logConfig.prefix = prefix;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebapiClientLogConfigurator.prototype, "timestamp", {
            get: function () {
                return this.client.options.logConfig.timestamp;
            },
            set: function (timestamp) {
                this.client.options.logConfig.timestamp = !!timestamp;
            },
            enumerable: false,
            configurable: true
        });
        WebapiClientLogConfigurator.enableNamespace = function (namespace) {
            debug.enable(namespace);
        };
        WebapiClientLogConfigurator.disableNamespace = function () {
            return debug.disable();
        };
        return WebapiClientLogConfigurator;
    }(LogConfigurator));
    console.info("WebAPIclient loaded version " + pkg.version + " - Browser " + JSON.stringify(browser));

    var fm_icelink = createCommonjsModule(function (module, exports) {
    (function(name, dependencies, global, definition) {
        {
            for(var i = 0; i < dependencies.length; i++) {
                commonjsRequire('./' + dependencies[i]);
            }
            module.exports = definition.call(global);
        }
    }('fm.icelink', [], commonjsGlobal, function() {
    if (typeof commonjsGlobal !== 'undefined' && !commonjsGlobal.window) { commonjsGlobal.window = commonjsGlobal; commonjsGlobal.document = { cookie: '' }; }
    if (typeof commonjsGlobal !== 'undefined' && !commonjsGlobal.navigator) { commonjsGlobal.navigator = { userAgent: ' ' }; }
    var fm = this['fm'] = this['fm'] || { };
    (function (fm) {
        (function (icelink) {
            var ArrayExtensions =  (function () {
                function ArrayExtensions() {
                }
                ArrayExtensions.prototype.getTypeString = function () {
                    return '[fm.icelink.ArrayExtensions]';
                };
                ArrayExtensions.getCount = function (array) {
                    return array.length;
                };
                ArrayExtensions.add = function (array, value) {
                    array.push(value);
                };
                ArrayExtensions.remove = function (array, value) {
                    for (var i = 0; i < array.length; i++) {
                        var obj = array[i];
                        if (obj === value) {
                            array.splice(i, 1);
                            return true;
                        }
                    }
                    return false;
                };
                ArrayExtensions.removeAt = function (array, index) {
                    array.splice(index, 1);
                };
                ArrayExtensions.insert = function (array, index, value) {
                    array.splice(index, 0, value);
                };
                ArrayExtensions.toArray = function (array) {
                    return this.clone(array);
                };
                ArrayExtensions.clear = function (array) {
                    array.splice(0, array.length);
                };
                ArrayExtensions.addRange = function (array, values) {
                    for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
                        var v = values_1[_i];
                        array.push(v);
                    }
                };
                ArrayExtensions.getRange = function (array, index, count) {
                    var newArray = new Array(count);
                    for (var i = 0; i < newArray.length; i++) {
                        newArray[i] = array[i + index];
                    }
                    return newArray;
                };
                ArrayExtensions.contains = function (array, value) {
                    for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
                        var obj = array_1[_i];
                        if (obj === value) {
                            return true;
                        }
                    }
                    return false;
                };
                ArrayExtensions.newArray = function (values) {
                    return this.clone(values);
                };
                ArrayExtensions.clone = function (array) {
                    var newArray = new Array(array.length);
                    for (var i = 0; i < newArray.length; i++) {
                        newArray[i] = array[i];
                    }
                    return newArray;
                };
                ArrayExtensions.map = function (array, callback) {
                    var newArray = new Array(array.length);
                    for (var i = 0; i < newArray.length; i++) {
                        newArray[i] = callback(array[i], i, array);
                    }
                    return newArray;
                };
                return ArrayExtensions;
            }());
            icelink.ArrayExtensions = ArrayExtensions;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AsyncLoggerBase =  (function () {
                function AsyncLoggerBase(tag) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var tag_1 = __arguments[0];
                        if ((fm.icelink.Global.equals(tag_1, null))) {
                            throw new fm.icelink.Exception("The tag parameter cannot be null.");
                        }
                        this.setTag(tag_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                AsyncLoggerBase.prototype.getTypeString = function () {
                    return '[fm.icelink.AsyncLoggerBase]';
                };
                AsyncLoggerBase.processLogEvent = function (logEvent) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.LogConfiguration.getHasProviders() && (fm.icelink.LogConfiguration.getTagLogLevel(logEvent.getTag()) <= logEvent.getLevel()))) {
                            for (var _i = 0, _a = fm.icelink.LogConfiguration.getLogProviders(); _i < _a.length; _i++) {
                                var provider = _a[_i];
                                provider.log(logEvent);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.debug = function () {
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        this.doLog(fm.icelink.LogLevel.Debug, null, message, null);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isError(arguments[1]))) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Debug, null, message, ex);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isString(arguments[1]))) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Debug, scope, message, null);
                    }
                    else if (arguments.length == 3) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        var ex = arguments[2];
                        this.doLog(fm.icelink.LogLevel.Debug, scope, message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.doLog = function (level, scope, message, exception) {
                    if (arguments.length == 4) {
                        this.doQueueLogEvent(new fm.icelink.LogEvent(fm.icelink.DateTime.getUtcNow(), this.getTag(), scope, level, message, exception, fm.icelink.ManagedThread.getCurrentThreadId()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.error = function () {
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        this.doLog(fm.icelink.LogLevel.Error, null, message, null);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isError(arguments[1]))) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Error, null, message, ex);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isString(arguments[1]))) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Error, scope, message, null);
                    }
                    else if (arguments.length == 3) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        var ex = arguments[2];
                        this.doLog(fm.icelink.LogLevel.Error, scope, message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.fatal = function () {
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        this.doLog(fm.icelink.LogLevel.Fatal, null, message, null);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isError(arguments[1]))) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Fatal, null, message, ex);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isString(arguments[1]))) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Fatal, scope, message, null);
                    }
                    else if (arguments.length == 3) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        var ex = arguments[2];
                        this.doLog(fm.icelink.LogLevel.Fatal, scope, message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.getIsDebugEnabled = function () {
                    if (arguments.length == 0) {
                        return this.isLogEnabled(fm.icelink.LogLevel.Debug);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.getIsErrorEnabled = function () {
                    if (arguments.length == 0) {
                        return this.isLogEnabled(fm.icelink.LogLevel.Error);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.getIsFatalEnabled = function () {
                    if (arguments.length == 0) {
                        return this.isLogEnabled(fm.icelink.LogLevel.Fatal);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.getIsInfoEnabled = function () {
                    if (arguments.length == 0) {
                        return this.isLogEnabled(fm.icelink.LogLevel.Info);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.getIsVerboseEnabled = function () {
                    if (arguments.length == 0) {
                        return this.isLogEnabled(fm.icelink.LogLevel.Verbose);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.getIsWarnEnabled = function () {
                    if (arguments.length == 0) {
                        return this.isLogEnabled(fm.icelink.LogLevel.Warn);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.info = function () {
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        this.doLog(fm.icelink.LogLevel.Info, null, message, null);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isError(arguments[1]))) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Info, null, message, ex);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isString(arguments[1]))) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Info, scope, message, null);
                    }
                    else if (arguments.length == 3) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        var ex = arguments[2];
                        this.doLog(fm.icelink.LogLevel.Info, scope, message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.isLogEnabled = function (level) {
                    if (arguments.length == 1) {
                        return (fm.icelink.LogConfiguration.getTagLogLevel(this.getTag()) <= level);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.log = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.LogEvent]'))) {
                        var logEvent = arguments[0];
                        this.doQueueLogEvent(logEvent);
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var message = arguments[0];
                        this.doLog(fm.icelink.LogLevel.Info, null, message, null);
                    }
                    else if (arguments.length == 2) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Info, scope, message, null);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.verbose = function () {
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        this.doLog(fm.icelink.LogLevel.Verbose, null, message, null);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isError(arguments[1]))) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Verbose, null, message, ex);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isString(arguments[1]))) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Verbose, scope, message, null);
                    }
                    else if (arguments.length == 3) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        var ex = arguments[2];
                        this.doLog(fm.icelink.LogLevel.Verbose, scope, message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AsyncLoggerBase.prototype.warn = function () {
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        this.doLog(fm.icelink.LogLevel.Warn, null, message, null);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isError(arguments[1]))) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Warn, null, message, ex);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isString(arguments[1]))) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        this.doLog(fm.icelink.LogLevel.Warn, scope, message, null);
                    }
                    else if (arguments.length == 3) {
                        var scope = arguments[0];
                        var message = arguments[1];
                        var ex = arguments[2];
                        this.doLog(fm.icelink.LogLevel.Warn, scope, message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return AsyncLoggerBase;
            }());
            icelink.AsyncLoggerBase = AsyncLoggerBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    var __extends = (this && this.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    (function (fm) {
        (function (icelink) {
            var AsyncLogger =  (function (_super) {
                __extends(AsyncLogger, _super);
                function AsyncLogger(tag) {
                    return _super.call(this, tag) || this;
                }
                AsyncLogger.prototype.getTypeString = function () {
                    return '[fm.icelink.AsyncLogger]';
                };
                AsyncLogger.prototype.doQueueLogEvent = function (logEvent) {
                    window.setTimeout(function () {
                        fm.icelink.AsyncLoggerBase.processLogEvent(logEvent);
                    }, 1);
                };
                AsyncLogger.prototype.flush = function () { };
                return AsyncLogger;
            }(fm.icelink.AsyncLoggerBase));
            icelink.AsyncLogger = AsyncLogger;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AtomicInteger =  (function () {
                function AtomicInteger(startValue) {
                    if (arguments.length == 0) {
                        this._value = 0;
                    }
                    else {
                        this._value = startValue;
                    }
                }
                AtomicInteger.prototype.compareAndSwap = function (expected, newValue) {
                    var oldValue = this._value;
                    if (this._value == expected) {
                        this._value = newValue;
                    }
                    return oldValue;
                };
                AtomicInteger.prototype.getValue = function () {
                    return this._value;
                };
                AtomicInteger.prototype.add = function (value) {
                    this._value = this._value + value;
                    return this._value;
                };
                AtomicInteger.prototype.subtract = function (value) {
                    this._value = this._value - value;
                    return this._value;
                };
                AtomicInteger.prototype.increment = function () {
                    this._value = this._value + 1;
                    return this._value;
                };
                AtomicInteger.prototype.decrement = function () {
                    this._value = this._value - 1;
                    return this._value;
                };
                return AtomicInteger;
            }());
            icelink.AtomicInteger = AtomicInteger;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AtomicLong =  (function () {
                function AtomicLong(startValue) {
                    if (arguments.length == 0) {
                        this._value = 0;
                    }
                    else {
                        this._value = startValue;
                    }
                }
                AtomicLong.prototype.compareAndSwap = function (expected, newValue) {
                    var oldValue = this._value;
                    if (this._value == expected) {
                        this._value = newValue;
                    }
                    return oldValue;
                };
                AtomicLong.prototype.getValue = function () {
                    return this._value;
                };
                AtomicLong.prototype.add = function (value) {
                    this._value = this._value + value;
                    return this._value;
                };
                AtomicLong.prototype.subtract = function (value) {
                    this._value = this._value - value;
                    return this._value;
                };
                AtomicLong.prototype.increment = function () {
                    this._value = this._value + 1;
                    return this._value;
                };
                AtomicLong.prototype.decrement = function () {
                    this._value = this._value - 1;
                    return this._value;
                };
                return AtomicLong;
            }());
            icelink.AtomicLong = AtomicLong;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Base64 =  (function () {
                function Base64() {
                }
                Base64.prototype.getTypeString = function () {
                    return '[fm.icelink.Base64]';
                };
                Base64.encode = function (b) {
                    if (!b) {
                        return null;
                    }
                    return this.encodeIt(b, 0, b.length);
                };
                Base64.encodeBuffer = function (buffer) {
                    if (!buffer) {
                        return null;
                    }
                    return this.encodeIt(buffer.getData(), buffer.getIndex(), buffer.getLength());
                };
                Base64.decode = function (s) {
                    if (!s) {
                        return null;
                    }
                    if (!Base64._base64Regex.test(s)) {
                        return null;
                    }
                    return this.decodeIt(s);
                };
                Base64.tryEncode = function (b, result) {
                    try {
                        var encoded = Base64.encode(b);
                        result.setValue(encoded);
                        if (!encoded) {
                            return false;
                        }
                        return true;
                    }
                    catch (error) {
                        result.setValue(null);
                        return false;
                    }
                };
                Base64.tryEncodeBuffer = function (buffer, result) {
                    try {
                        var encoded = Base64.encodeBuffer(buffer);
                        result.setValue(encoded);
                        if (!encoded) {
                            return false;
                        }
                        return true;
                    }
                    catch (error) {
                        result.setValue(null);
                        return false;
                    }
                };
                Base64.tryDecode = function (s, result) {
                    try {
                        var decoded = Base64.decode(s);
                        result.setValue(decoded);
                        if (!decoded) {
                            return false;
                        }
                        return true;
                    }
                    catch (error) {
                        result.setValue(null);
                        return false;
                    }
                };
                Base64.b64ToUint6 = function (cc) {
                    if (cc > 64 && cc < 91) {
                        return cc - 65;
                    }
                    else if (cc > 96 && cc < 123) {
                        return cc - 71;
                    }
                    else if (cc > 47 && cc < 58) {
                        return cc + 4;
                    }
                    else if (cc === 43) {
                        return 62;
                    }
                    else if (cc === 47) {
                        return 63;
                    }
                    else {
                        return 0;
                    }
                };
                Base64.decodeIt = function (str64, blocksSize) {
                    if (typeof Uint8Array === 'undefined') {
                        return null;
                    }
                    var str = str64.replace(/[^A-Za-z0-9\+\/]/g, '');
                    var slen = str.length;
                    var blen = blocksSize ? Math.ceil((slen * 3 + 1 >> 2) / blocksSize) * blocksSize : slen * 3 + 1 >> 2;
                    var bytes = new Uint8Array(blen);
                    var n = 0;
                    var bi = 0;
                    for (var si = 0; si < slen; si++) {
                        var mod4 = si & 3;
                        n |= Base64.b64ToUint6(str.charCodeAt(si)) << 18 - 6 * mod4;
                        if (mod4 === 3 || slen - si === 1) {
                            var mod3 = 0;
                            while ((mod3 < 3) && (bi < blen)) {
                                bytes[bi] = n >>> (16 >>> mod3 & 24) & 255;
                                mod3++;
                                bi++;
                            }
                            n = 0;
                        }
                    }
                    return bytes;
                };
                Base64.uint6ToB64 = function (b) {
                    if (b < 26) {
                        return b + 65;
                    }
                    else if (b < 52) {
                        return b + 71;
                    }
                    else if (b < 62) {
                        return b - 4;
                    }
                    else if (b === 62) {
                        return 43;
                    }
                    else if (b === 63) {
                        return 47;
                    }
                    else {
                        return 65;
                    }
                };
                Base64.encodeIt = function (bytes, index, length) {
                    if (typeof Uint8Array === 'undefined') {
                        return null;
                    }
                    var str = '';
                    var blen = length;
                    var n = 0;
                    for (var bi = 0; bi < blen; bi++) {
                        var mod3 = bi % 3;
                        n |= bytes[index + bi] << (16 >>> mod3 & 24);
                        if (mod3 === 2 || length - bi === 1) {
                            str += String.fromCharCode(Base64.uint6ToB64(n >>> 18 & 63), Base64.uint6ToB64(n >>> 12 & 63), Base64.uint6ToB64(n >>> 6 & 63), Base64.uint6ToB64(n & 63));
                            n = 0;
                        }
                    }
                    return str.replace(/A(?=A$|$)/g, '=');
                };
                Base64._base64Regex = /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]*)?$/;
                return Base64;
            }());
            icelink.Base64 = Base64;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var BitAssistant =  (function () {
                function BitAssistant() {
                }
                BitAssistant.prototype.getTypeString = function () {
                    return '[fm.icelink.BitAssistant]';
                };
                BitAssistant.castByte = function (value) {
                    return value;
                };
                BitAssistant.castInteger = function (value) {
                    return value;
                };
                BitAssistant.castLong = function (value) {
                    return value;
                };
                BitAssistant.leftShift = function (value, count) {
                    return (value << count);
                };
                BitAssistant.leftShiftShort = function (value, count) {
                    return (value << count);
                };
                BitAssistant.leftShiftInteger = function (value, count) {
                    return (value << count);
                };
                BitAssistant.leftShiftLong = function (value, count) {
                    return (value << count);
                };
                BitAssistant.rightShift = function (value, count) {
                    return (value >> count);
                };
                BitAssistant.rightShiftShort = function (value, count) {
                    return (value >> count);
                };
                BitAssistant.rightShiftInteger = function (value, count) {
                    return (value >> count);
                };
                BitAssistant.rightShiftLong = function (value, count) {
                    return (value >> count);
                };
                BitAssistant.sequencesAreEqual = function () {
                    if (arguments.length == 2) {
                        var array1 = arguments[0];
                        var array2 = arguments[1];
                        if (array1 == null && array2 == null) {
                            return true;
                        }
                        if (array1 == null || array2 == null) {
                            return false;
                        }
                        if (array1.length != array2.length) {
                            return false;
                        }
                        for (var i = 0; i < array1.length; i++) {
                            if (array1[i] != array2[i]) {
                                return false;
                            }
                        }
                        return true;
                    }
                    else {
                        var array1 = arguments[0];
                        var offset1 = arguments[1];
                        var array2 = arguments[2];
                        var offset2 = arguments[3];
                        var length_1 = arguments[4];
                        if (array1 == null && array2 == null) {
                            return true;
                        }
                        if (array1 == null || array2 == null) {
                            return false;
                        }
                        if (array1.length < offset1 + length_1 || array2.length < offset2 + length_1) {
                            return false;
                        }
                        for (var i = 0; i < length_1; i++) {
                            if (array1[offset1 + i] != array2[offset2 + i]) {
                                return false;
                            }
                        }
                        return true;
                    }
                };
                BitAssistant.sequencesAreEqualConstantTime = function () {
                    if (arguments.length == 2) {
                        var array1 = arguments[0];
                        var array2 = arguments[1];
                        if (array1 == null && array2 == null) {
                            return true;
                        }
                        if (array1 == null || array2 == null) {
                            return false;
                        }
                        if (array1.length != array2.length) {
                            return false;
                        }
                        var areEqual = true;
                        for (var i = 0; i < array1.length; i++) {
                            if (array1[i] != array2[i]) {
                                areEqual = false;
                            }
                        }
                        return areEqual;
                    }
                    else {
                        var array1 = arguments[0];
                        var offset1 = arguments[1];
                        var array2 = arguments[2];
                        var offset2 = arguments[3];
                        var length_2 = arguments[4];
                        if (array1 == null && array2 == null) {
                            return true;
                        }
                        if (array1 == null || array2 == null) {
                            return false;
                        }
                        if (array1.length < offset1 + length_2 || array2.length < offset2 + length_2) {
                            return false;
                        }
                        var areEqual = true;
                        for (var i = 0; i < length_2; i++) {
                            if (array1[offset1 + i] != array2[offset2 + i]) {
                                areEqual = false;
                            }
                        }
                        return areEqual;
                    }
                };
                BitAssistant.subArray = function (array, offset, count) {
                    if (typeof count === 'undefined') {
                        return BitAssistant.subArray(array, offset, array.length - offset);
                    }
                    else {
                        var subarray = new Uint8Array(count);
                        BitAssistant.copy(array, offset, subarray, 0, count);
                        return subarray;
                    }
                };
                BitAssistant.reverse = function (array) {
                    array.reverse();
                };
                BitAssistant.copy = function (source, sourceIndex, destination, destinationIndex, length) {
                    destination.set(source.subarray(sourceIndex, sourceIndex + length), destinationIndex);
                };
                BitAssistant.set = function (array, index, length, value) {
                    array.fill(value, index, index + length);
                };
                BitAssistant.getHexString = function () {
                    if (arguments.length == 1) {
                        var array = arguments[0];
                        return BitAssistant.getHexString(array, 0, array.length);
                    }
                    else {
                        var array = arguments[0];
                        var offset = arguments[1];
                        var length_3 = arguments[2];
                        var s = '';
                        for (var i = offset; i < offset + length_3; i++) {
                            var hex = (array[i] & 0xff).toString(16);
                            hex = (hex.length === 1) ? '0' + hex : hex;
                            s += hex;
                        }
                        return s;
                    }
                };
                BitAssistant.getHexBytes = function (s) {
                    var a = [];
                    for (var i = 0; i < s.length; i += 2) {
                        a.push(parseInt(s.substr(i, 2), 16));
                    }
                    return new Uint8Array(a);
                };
                return BitAssistant;
            }());
            icelink.BitAssistant = BitAssistant;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var BooleanExtensions =  (function () {
                function BooleanExtensions() {
                }
                BooleanExtensions.prototype.getTypeString = function () {
                    return '[fm.icelink.BooleanExtensions]';
                };
                BooleanExtensions.toString = function (value, format) {
                    return value.toString();
                };
                return BooleanExtensions;
            }());
            icelink.BooleanExtensions = BooleanExtensions;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ByteCollection =  (function () {
                function ByteCollection(buffer) {
                    if (buffer) {
                        this._buffer = new Uint8Array(buffer);
                    }
                    else {
                        this._buffer = new Uint8Array(0);
                    }
                }
                ByteCollection.prototype.getTypeString = function () {
                    return '[fm.icelink.ByteCollection]';
                };
                ByteCollection.prototype.count = function () {
                    return this._buffer.length;
                };
                ByteCollection.prototype.add = function (b) {
                    var bufferA = this._buffer;
                    var newBuffer = new Uint8Array(bufferA.length + 1);
                    newBuffer.set(bufferA);
                    newBuffer[bufferA.length] = b;
                    this._buffer = newBuffer;
                };
                ByteCollection.prototype.addRange = function (buffer) {
                    var byteCollection = fm.icelink.Global.tryCast(buffer, ByteCollection);
                    if (byteCollection) {
                        buffer = byteCollection._buffer;
                    }
                    var bufferA = this._buffer;
                    var bufferB = buffer;
                    var newBuffer = new Uint8Array(bufferA.length + bufferB.length);
                    newBuffer.set(bufferA);
                    newBuffer.set(bufferB, bufferA.length);
                    this._buffer = newBuffer;
                };
                ByteCollection.prototype.removeRange = function (index, count) {
                    var bufferA = this._buffer.subarray(0, index);
                    var bufferB = this._buffer.subarray(index + count);
                    var newBuffer = new Uint8Array(bufferA.length + bufferB.length);
                    newBuffer.set(bufferA);
                    newBuffer.set(bufferB, bufferA.length);
                    this._buffer = newBuffer;
                };
                ByteCollection.prototype.insertRange = function (index, buffer) {
                    var byteCollection = fm.icelink.Global.tryCast(buffer, ByteCollection);
                    if (byteCollection) {
                        buffer = byteCollection._buffer;
                    }
                    var bufferA = this._buffer.subarray(0, index);
                    var bufferB = buffer;
                    var bufferC = this._buffer.subarray(index);
                    var newBuffer = new Uint8Array(bufferA.length + bufferB.length + bufferC.length);
                    newBuffer.set(bufferA);
                    newBuffer.set(bufferB, bufferA.length);
                    newBuffer.set(bufferC, bufferA.length + bufferB.length);
                    this._buffer = newBuffer;
                };
                ByteCollection.prototype.getRange = function (index, count) {
                    var buffer = new Uint8Array(count);
                    buffer.set(this._buffer.subarray(index, index + count));
                    return buffer;
                };
                ByteCollection.prototype.get = function (index) {
                    return this._buffer[index];
                };
                ByteCollection.prototype.toArray = function () {
                    return new Uint8Array(this._buffer);
                };
                return ByteCollection;
            }());
            icelink.ByteCollection = ByteCollection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LogProvider =  (function () {
                function LogProvider() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkLogProviderInit();
                        this.setLevel(fm.icelink.LogLevel.Info);
                        this.setProcessId(fm.icelink.Platform.getInstance().getProcessId());
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LogProvider.prototype.getTypeString = function () {
                    return '[fm.icelink.LogProvider]';
                };
                LogProvider.prototype.fmicelinkLogProviderInit = function () {
                    this._processId = 0;
                };
                LogProvider.getLogLevelString = function (level) {
                    if (arguments.length == 1) {
                        var _var0 = level;
                        do {
                            if (_var0 == fm.icelink.LogLevel.Verbose) {
                                return "VERBOSE";
                            }
                            else if (_var0 == fm.icelink.LogLevel.Debug) {
                                return "DEBUG  ";
                            }
                            else if (_var0 == fm.icelink.LogLevel.Info) {
                                return "INFO   ";
                            }
                            else if (_var0 == fm.icelink.LogLevel.Warn) {
                                return "WARN   ";
                            }
                            else if (_var0 == fm.icelink.LogLevel.Error) {
                                return "ERROR  ";
                            }
                            else if (_var0 == fm.icelink.LogLevel.Fatal) {
                                return "FATAL  ";
                            }
                        } while (false);
                        return "NONE   ";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.getPrefixTimestamp = function (timestamp) {
                    if (arguments.length == 1) {
                        return fm.icelink.Iso8601Timestamp.dateTimeToIso8601(timestamp);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.getProduct = function () {
                    if (arguments.length == 0) {
                        return "IceLink";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.prototype.generateLogLine = function (logEvent) {
                    if (arguments.length == 1) {
                        var product = fm.icelink.LogProvider.getProduct();
                        var str2 = fm.icelink.StringExtensions.format("[{0}][{1}][{2}] {3} [{4}][{5}] {6} {7}", [product, fm.icelink.NumberExtensions.toString(this.getProcessId()), fm.icelink.NumberExtensions.toString(logEvent.getThreadId()), fm.icelink.LogProvider.getLogLevelString(logEvent.getLevel()), ((fm.icelink.Global.equals(logEvent.getTag(), null)) ? "-" : logEvent.getTag()), ((fm.icelink.Global.equals(logEvent.getScope(), null)) ? "-" : logEvent.getScope()), fm.icelink.LogProvider.getPrefixTimestamp(logEvent.getTimestamp()), logEvent.getMessage()]);
                        if ((!fm.icelink.Global.equals(logEvent.getException(), null))) {
                            str2 = fm.icelink.StringExtensions.concat(str2, fm.icelink.StringExtensions.format("\n{0}", logEvent.getException().toString()));
                        }
                        return str2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.prototype.getFilter = function () {
                    if (arguments.length == 0) {
                        return this._filter;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.prototype.getLevel = function () {
                    if (arguments.length == 0) {
                        return this._level;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.prototype.getPrefix = function (level, includeTimestamp) {
                    if (arguments.length == 2) {
                        var logLevelString = fm.icelink.LogProvider.getLogLevelString(level);
                        if (includeTimestamp) {
                            logLevelString = fm.icelink.StringExtensions.format("{0} {1}", logLevelString, fm.icelink.LogProvider.getPrefixTimestamp(fm.icelink.DateTime.getUtcNow()));
                        }
                        return logLevelString;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.prototype.getProcessId = function () {
                    if (arguments.length == 0) {
                        return this._processId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.prototype.log = function (logEvent) {
                    if (arguments.length == 1) {
                        if ((logEvent.getLevel() >= this.getLevel())) {
                            try {
                                var flag = true;
                                if ((!fm.icelink.Global.equals(this.getFilter(), null))) {
                                    flag = this.getFilter()(logEvent);
                                }
                                if (flag) {
                                    this.doLog(logEvent);
                                }
                            }
                            catch (obj1) {
                            }
                            finally {
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.prototype.setFilter = function (value) {
                    if (arguments.length == 1) {
                        this._filter = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.prototype.setLevel = function (value) {
                    if (arguments.length == 1) {
                        this._level = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogProvider.prototype.setProcessId = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._processId = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LogProvider;
            }());
            icelink.LogProvider = LogProvider;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ConsoleLogProvider =  (function (_super) {
                __extends(ConsoleLogProvider, _super);
                function ConsoleLogProvider(level) {
                    var _this = _super.call(this) || this;
                    if (typeof level === 'undefined') {
                        level = fm.icelink.LogLevel.Warn;
                    }
                    _this.setLevel(level);
                    return _this;
                }
                ConsoleLogProvider.prototype.getTypeString = function () {
                    return '[fm.icelink.ConsoleLogProvider]' + ',' + _super.prototype.getTypeString.call(this);
                };
                ConsoleLogProvider.prototype.writeLine = function (text) {
                    if (window.console && window.console.log) {
                        window.console.log(text);
                    }
                };
                ConsoleLogProvider.prototype.doLog = function (logItem) {
                    if (window.console) {
                        var text = _super.prototype.generateLogLine.call(this, logItem);
                        switch (logItem.getLevel()) {
                            case fm.icelink.LogLevel.Fatal:
                            case fm.icelink.LogLevel.Error:
                                if (window.console.error) {
                                    window.console.error(text);
                                    return;
                                }
                                break;
                            case fm.icelink.LogLevel.Warn:
                                if (window.console.warn) {
                                    window.console.warn(text);
                                    return;
                                }
                                break;
                            case fm.icelink.LogLevel.Info:
                                if (window.console.info) {
                                    window.console.info(text);
                                    return;
                                }
                                break;
                            case fm.icelink.LogLevel.Debug:
                            case fm.icelink.LogLevel.Verbose:
                                if (window.console.debug) {
                                    window.console.debug(text);
                                    return;
                                }
                                break;
                        }
                        window.console.log(text);
                    }
                };
                return ConsoleLogProvider;
            }(fm.icelink.LogProvider));
            icelink.ConsoleLogProvider = ConsoleLogProvider;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Convert =  (function () {
                function Convert() {
                }
                Convert.prototype.getTypeString = function () {
                    return '[fm.icelink.Convert]';
                };
                Convert.toInt32 = function (s, base) {
                    return parseInt(s, base);
                };
                return Convert;
            }());
            icelink.Convert = Convert;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CultureInfo =  (function () {
                function CultureInfo() {
                }
                CultureInfo.getInvariantCulture = function () {
                    return new CultureInfo();
                };
                CultureInfo.getCurrentCulture = function () {
                    return new CultureInfo();
                };
                return CultureInfo;
            }());
            icelink.CultureInfo = CultureInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DateTime =  (function () {
                function DateTime() {
                    if (arguments.length == 1) {
                        if (fm.icelink.Util.isDate(arguments[0])) {
                            this._date = arguments[0];
                        }
                        else {
                            var ticks = arguments[0];
                            this._date = new Date((ticks - 621355968000000000) / fm.icelink.Constants.getTicksPerMillisecond());
                        }
                    }
                    else if (arguments.length >= 6) {
                        var year = arguments[0];
                        var month = arguments[1];
                        var day = arguments[2];
                        var hour = arguments[3];
                        var minute = arguments[4];
                        var second = arguments[5];
                        var millisecond = 0;
                        if (arguments.length >= 7) {
                            millisecond = arguments[6];
                        }
                        this._date = new Date(Date.UTC(year, month - 1, day, hour, minute, second, millisecond));
                    }
                }
                DateTime.prototype.getTypeString = function () {
                    return '[fm.icelink.DateTime]';
                };
                DateTime.getNow = function () {
                    return new DateTime(new Date());
                };
                DateTime.getUtcNow = function () {
                    return new DateTime(new Date());
                };
                DateTime.prototype.getDate = function () {
                    return this._date;
                };
                DateTime.prototype.getTicks = function () {
                    return 621355968000000000 + this._date.getTime() * fm.icelink.Constants.getTicksPerMillisecond();
                };
                DateTime.prototype.toUniversalTime = function () {
                    return new DateTime(this._date);
                };
                DateTime.prototype.getYear = function () {
                    return this._date.getUTCFullYear();
                };
                DateTime.prototype.getMonth = function () {
                    return this._date.getUTCMonth() + 1;
                };
                DateTime.prototype.getDay = function () {
                    return this._date.getUTCDate();
                };
                DateTime.prototype.getHour = function () {
                    return this._date.getUTCHours();
                };
                DateTime.prototype.getMinute = function () {
                    return this._date.getUTCMinutes();
                };
                DateTime.prototype.getSecond = function () {
                    return this._date.getUTCSeconds();
                };
                DateTime.prototype.getMillisecond = function () {
                    return this._date.getUTCMilliseconds();
                };
                DateTime.prototype.addHours = function (hours) {
                    return new DateTime(this.getTicks() + (hours * fm.icelink.Constants.getTicksPerHour()));
                };
                DateTime.prototype.addMinutes = function (minutes) {
                    return new DateTime(this.getTicks() + (minutes * fm.icelink.Constants.getTicksPerMinute()));
                };
                DateTime.prototype.addSeconds = function (seconds) {
                    return new DateTime(this.getTicks() + (seconds * fm.icelink.Constants.getTicksPerSecond()));
                };
                DateTime.prototype.addMilliseconds = function (milliseconds) {
                    return new DateTime(this.getTicks() + (milliseconds * fm.icelink.Constants.getTicksPerMillisecond()));
                };
                return DateTime;
            }());
            icelink.DateTime = DateTime;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DateTimeFormatInfo =  (function () {
                function DateTimeFormatInfo() {
                }
                DateTimeFormatInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.DateTimeFormatInfo]';
                };
                DateTimeFormatInfo.getInvariantInfo = function () {
                    return new DateTimeFormatInfo();
                };
                return DateTimeFormatInfo;
            }());
            icelink.DateTimeFormatInfo = DateTimeFormatInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (DateTimeStyles) {
                DateTimeStyles[DateTimeStyles["AssumeUniversal"] = 1] = "AssumeUniversal";
                DateTimeStyles[DateTimeStyles["AdjustToUniversal"] = 2] = "AdjustToUniversal";
            })(icelink.DateTimeStyles || (icelink.DateTimeStyles = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DispatchQueue =  (function () {
                function DispatchQueue(action) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        this._action = action;
                        this._count = new fm.icelink.AtomicLong();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                DispatchQueue.prototype.getTypeString = function () {
                    return '[fm.icelink.DispatchQueue]';
                };
                DispatchQueue.prototype.getQueueCount = function () {
                    return this._count.getValue();
                };
                DispatchQueue.prototype.destroy = function () { };
                DispatchQueue.prototype.enqueue = function (item) {
                    var action = this._action;
                    var atomic = this._count;
                    atomic.increment();
                    window.setTimeout(function () {
                        try {
                            action(item);
                        }
                        finally {
                            atomic.decrement();
                        }
                    }, 1);
                };
                return DispatchQueue;
            }());
            icelink.DispatchQueue = DispatchQueue;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DomLogProvider =  (function (_super) {
                __extends(DomLogProvider, _super);
                function DomLogProvider(container, level) {
                    var _this = _super.call(this) || this;
                    _this._container = container;
                    if (typeof level === 'undefined') {
                        level = fm.icelink.LogLevel.Warn;
                    }
                    _this.setLevel(level);
                    return _this;
                }
                DomLogProvider.prototype.getTypeString = function () {
                    return '[fm.icelink.DomLogProvider]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DomLogProvider.prototype.writeLine = function (text) {
                    var div = document.createElement('div');
                    div.innerHTML = text.replace(/\n/g, '<br />');
                    this._container.appendChild(div);
                };
                DomLogProvider.prototype.doLog = function (logItem) {
                    var text = _super.prototype.generateLogLine.call(this, logItem);
                    this.writeLine(text);
                };
                return DomLogProvider;
            }(fm.icelink.LogProvider));
            icelink.DomLogProvider = DomLogProvider;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Encoding =  (function () {
                function Encoding() {
                }
                Encoding.prototype.getTypeString = function () {
                    return '[fm.icelink.Encoding]';
                };
                Encoding.getAscii = function () {
                    return new Encoding();
                };
                Encoding.getUtf8 = function () {
                    return new Encoding();
                };
                Encoding.prototype.getString = function (bytes, index, count) {
                    if (typeof index === 'undefined') {
                        index = 0;
                    }
                    if (typeof count === 'undefined') {
                        count = bytes.length;
                    }
                    var str = '';
                    var i = index;
                    while (i < (index + count)) {
                        var c = void 0;
                        if (bytes[i] <= 0x7f) {
                            c = bytes[i];
                        }
                        else {
                            if ((bytes[i] >> 5) === 0x6) {
                                c = ((bytes[i] & 0x1f) << 6) | (bytes[++i] & 0x3f);
                            }
                            else if ((bytes[i] >> 4) === 0xe) {
                                c = ((bytes[i] & 0xf) << 12) | ((bytes[++i] & 0x3f) << 6) | (bytes[++i] & 0x3f);
                            }
                            else {
                                var s = 1;
                                while (bytes[i] & (0x20 >>> s)) {
                                    s++;
                                }
                                c = bytes[i] & (0x1f >>> s);
                                while (s-- >= 0) {
                                    c = (c << 6) ^ (bytes[++i] & 0x3f);
                                }
                            }
                        }
                        str += String.fromCharCode(c);
                        i++;
                    }
                    return str;
                };
                Encoding.prototype.getBytes = function (str) {
                    if (!str) {
                        return null;
                    }
                    var n = str.length;
                    var idx = 0;
                    var utf8 = new Uint8Array(new ArrayBuffer(n * 4));
                    var i = 0;
                    while (i < n) {
                        var c = str.charCodeAt(i);
                        if (c <= 0x7F) {
                            utf8[idx++] = c;
                        }
                        else if (c <= 0x7FF) {
                            utf8[idx++] = 0xC0 | (c >>> 6);
                            utf8[idx++] = 0x80 | (c & 0x3F);
                        }
                        else if (c <= 0xFFFF) {
                            utf8[idx++] = 0xE0 | (c >>> 12);
                            utf8[idx++] = 0x80 | ((c >>> 6) & 0x3F);
                            utf8[idx++] = 0x80 | (c & 0x3F);
                        }
                        else {
                            var j = 4;
                            while (c >> (6 * j)) {
                                j++;
                            }
                            utf8[idx++] = ((0xFF00 >>> j) & 0xFF) | (c >>> (6 * --j));
                            while (j--) {
                                utf8[idx++] = 0x80 | ((c >>> (6 * j)) & 0x3F);
                            }
                        }
                        i++;
                    }
                    return utf8.subarray(0, idx);
                };
                Encoding.prototype.getByteCount = function (str) {
                    return this.getBytes(str).length;
                };
                return Encoding;
            }());
            icelink.Encoding = Encoding;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    var fmicelinkGlobalError =  (function (_super) {
        __extends(fmicelinkGlobalError, _super);
        function fmicelinkGlobalError() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        return fmicelinkGlobalError;
    }(Error));
    (function (fm) {
        (function (icelink) {
            var Exception =  (function (_super) {
                __extends(Exception, _super);
                function Exception(message) {
                    var _this = _super.call(this, message) || this;
                    _this.message = message;
                    _this.name = 'Exception';
                    return _this;
                }
                return Exception;
            }(fmicelinkGlobalError));
            icelink.Exception = Exception;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var FutureBase =  (function () {
                function FutureBase() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                FutureBase.prototype.getTypeString = function () {
                    return '[fm.icelink.FutureBase]';
                };
                FutureBase.prototype.getException = function () {
                    if (arguments.length == 0) {
                        return this._exception;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FutureBase.prototype.getResult = function () {
                    if (arguments.length == 0) {
                        return this._result;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FutureBase.prototype.getState = function () {
                    if (arguments.length == 0) {
                        return this._state;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FutureBase.prototype.setException = function (value) {
                    if (arguments.length == 1) {
                        this._exception = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FutureBase.prototype.setResult = function (value) {
                    if (arguments.length == 1) {
                        this._result = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FutureBase.prototype.setState = function (value) {
                    if (arguments.length == 1) {
                        this._state = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return FutureBase;
            }());
            icelink.FutureBase = FutureBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Future =  (function (_super) {
                __extends(Future, _super);
                function Future() {
                    return _super !== null && _super.apply(this, arguments) || this;
                }
                Future.prototype.getTypeString = function () {
                    return '[fm.icelink.Future]';
                };
                return Future;
            }(fm.icelink.FutureBase));
            icelink.Future = Future;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Global =  (function () {
                function Global() {
                }
                Global.prototype.getTypeString = function () {
                    return '[fm.icelink.Global]';
                };
                Global.tryCast = function (x, t) {
                    if (!x || x instanceof t) {
                        return x;
                    }
                    return null;
                };
                Global.tryCastArray = function (x) {
                    if (!x || x instanceof Array) {
                        return x;
                    }
                    return null;
                };
                Global.tryCastObject = function (x) {
                    if (!x || x instanceof Object) {
                        return x;
                    }
                    return null;
                };
                Global.tryCastString = function (x) {
                    if (!x || typeof x === "string") {
                        return x;
                    }
                    return null;
                };
                Global.tryCastInt = function (x) {
                    if (!x || !isNaN(parseInt(x))) {
                        return x;
                    }
                    return null;
                };
                Global.tryCastFloat = function (x) {
                    if (!x || !isNaN(parseFloat(x))) {
                        return x;
                    }
                    return null;
                };
                Global.toInt = function (x) {
                    return x < 0 ? Math.ceil(x) : Math.floor(x);
                };
                Global.xor = function (x, y) {
                    return x !== y;
                };
                Global.equals = function (x1, x2) {
                    if (x1 === null || typeof x1 === 'undefined') {
                        return x2 === null || typeof x2 === 'undefined';
                    }
                    if (x2 === null || typeof x2 === 'undefined') {
                        return x1 === null || typeof x1 === 'undefined';
                    }
                    return x1 === x2;
                };
                return Global;
            }());
            icelink.Global = Global;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Guid =  (function () {
                function Guid(guidString) {
                    if (typeof guidString === 'undefined') {
                        this._guidString = '00000000-0000-0000-0000-000000000000';
                    }
                    else {
                        this._guidString = guidString;
                    }
                }
                Guid.prototype.getTypeString = function () {
                    return '[fm.icelink.Guid]';
                };
                Guid.prototype.equals = function (guid) {
                    return (guid.toString() === this._guidString);
                };
                Guid.prototype.toString = function () {
                    return this._guidString;
                };
                Guid.newGuid = function () {
                    return new Guid('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
                        var r = Math.random() * 16 | 0;
                        var v = (c === 'x' ? r : r & 0x3 | 0x8);
                        return v.toString(16);
                    }));
                };
                Guid.equals = function (guid1, guid2) {
                    if (guid1 === null || typeof guid1 === 'undefined') {
                        return guid2 === null || typeof guid2 === 'undefined';
                    }
                    if (guid2 === null || typeof guid2 === 'undefined') {
                        return guid1 === null || typeof guid1 === 'undefined';
                    }
                    return guid1.equals(guid2);
                };
                Guid.empty = new Guid();
                return Guid;
            }());
            icelink.Guid = Guid;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HashContextBase =  (function () {
                function HashContextBase(type) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var type_1 = __arguments[0];
                        this.setType(type_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                HashContextBase.prototype.getTypeString = function () {
                    return '[fm.icelink.HashContextBase]';
                };
                HashContextBase.compute = function () {
                    if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isObjectType(arguments[1], '[fm.icelink.DataBuffer]'))) {
                        var type = arguments[0];
                        var input = arguments[1];
                        var context = new fm.icelink.HashContext(type);
                        var buffer = context.compute(input);
                        context.destroy();
                        return buffer;
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isString(arguments[1]))) {
                        var type = arguments[0];
                        var inputString = arguments[1];
                        var context = new fm.icelink.HashContext(type);
                        var buffer = context.compute(inputString);
                        context.destroy();
                        return buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HashContextBase.prototype.compute = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataBuffer]'))) {
                        var input = arguments[0];
                        return this.doCompute(input);
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var inputString = arguments[0];
                        return this.doCompute(fm.icelink.DataBuffer.wrap(fm.icelink.Utf8.encode(inputString)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HashContextBase.prototype.destroy = function () {
                    if (arguments.length == 0) {
                        this.doDestroy();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HashContextBase.prototype.getType = function () {
                    if (arguments.length == 0) {
                        return this._type;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HashContextBase.prototype.setType = function (value) {
                    if (arguments.length == 1) {
                        this._type = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HashContextBase;
            }());
            icelink.HashContextBase = HashContextBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HashContext =  (function (_super) {
                __extends(HashContext, _super);
                function HashContext(type) {
                    return _super.call(this, type) || this;
                }
                HashContext.prototype.getTypeString = function () {
                    return '[fm.icelink.HashContext]';
                };
                HashContext.prototype.doCompute = function (input) {
                    if (this.getType() == fm.icelink.HashType.Md5) {
                        return null;
                    }
                    else if (this.getType() == fm.icelink.HashType.Sha1) {
                        return null;
                    }
                    else if (this.getType() == fm.icelink.HashType.Sha256) {
                        var hash = new fm.icelink.Sha256();
                        hash.update(input.getData());
                        var digest = hash.digest();
                        hash.clean();
                        return fm.icelink.DataBuffer.wrap(digest);
                    }
                    throw new fm.icelink.Exception('Unknown hash type.');
                };
                HashContext.prototype.doDestroy = function () { };
                return HashContext;
            }(fm.icelink.HashContextBase));
            icelink.HashContext = HashContext;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HashExtensions =  (function () {
                function HashExtensions() {
                }
                HashExtensions.prototype.getTypeString = function () {
                    return '[fm.icelink.HashExtensions]';
                };
                HashExtensions.getCount = function (obj) {
                    var i = 0;
                    for (var key in obj) {
                        i++;
                    }
                    return i;
                };
                HashExtensions.getKeys = function (obj) {
                    var keys = [];
                    for (var key in obj) {
                        keys.push(key);
                    }
                    return keys;
                };
                HashExtensions.getValues = function (obj) {
                    var values = [];
                    for (var key in obj) {
                        values.push(obj[key]);
                    }
                    return values;
                };
                HashExtensions.tryGetValue = function (obj, key, holder) {
                    if (HashExtensions.containsKey(obj, key)) {
                        holder.setValue(obj[key]);
                        return true;
                    }
                    return false;
                };
                HashExtensions.containsKey = function (obj, key) {
                    if (key in obj) {
                        return true;
                    }
                    else {
                        return false;
                    }
                };
                HashExtensions.containsValue = function (obj, value) {
                    for (var key in obj) {
                        if (obj[key] === value) {
                            return true;
                        }
                    }
                    return false;
                };
                HashExtensions.add = function (obj, key, value) {
                    obj[key] = value;
                    return value;
                };
                HashExtensions.remove = function (obj, key) {
                    if (HashExtensions.containsKey(obj, key)) {
                        delete obj[key];
                        return true;
                    }
                    return false;
                };
                HashExtensions.clear = function (obj) {
                    for (var key in obj) {
                        delete obj[key];
                    }
                };
                return HashExtensions;
            }());
            icelink.HashExtensions = HashExtensions;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HmacSha256 =  (function () {
                function HmacSha256(key) {
                    this.inner = new fm.icelink.Sha256();
                    this.outer = new fm.icelink.Sha256();
                    this.blockSize = this.inner.blockSize;
                    this.digestLength = this.inner.digestLength;
                    var pad = new Uint8Array(this.blockSize);
                    if (key.length > this.blockSize) {
                        (new fm.icelink.Sha256()).update(key).finish(pad).clean();
                    }
                    else {
                        for (var i = 0; i < key.length; i++) {
                            pad[i] = key[i];
                        }
                    }
                    for (var i = 0; i < pad.length; i++) {
                        pad[i] ^= 0x36;
                    }
                    this.inner.update(pad);
                    for (var i = 0; i < pad.length; i++) {
                        pad[i] ^= 0x36 ^ 0x5c;
                    }
                    this.outer.update(pad);
                    this.istate = new Uint32Array(8);
                    this.ostate = new Uint32Array(8);
                    this.inner._saveState(this.istate);
                    this.outer._saveState(this.ostate);
                    for (var i = 0; i < pad.length; i++) {
                        pad[i] = 0;
                    }
                }
                HmacSha256.prototype.reset = function () {
                    this.inner._restoreState(this.istate, this.inner.blockSize);
                    this.outer._restoreState(this.ostate, this.outer.blockSize);
                    return this;
                };
                HmacSha256.prototype.clean = function () {
                    for (var i = 0; i < this.istate.length; i++) {
                        this.ostate[i] = this.istate[i] = 0;
                    }
                    this.inner.clean();
                    this.outer.clean();
                };
                HmacSha256.prototype.update = function (data) {
                    this.inner.update(data);
                    return this;
                };
                HmacSha256.prototype.finish = function (out) {
                    if (this.outer.finished) {
                        this.outer.finish(out);
                    }
                    else {
                        this.inner.finish(out);
                        this.outer.update(out, this.digestLength).finish(out);
                    }
                    return this;
                };
                HmacSha256.prototype.digest = function () {
                    var out = new Uint8Array(this.digestLength);
                    this.finish(out);
                    return out;
                };
                return HmacSha256;
            }());
            icelink.HmacSha256 = HmacSha256;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Holder =  (function () {
                function Holder(value) {
                    this._value = value;
                }
                Holder.prototype.getTypeString = function () {
                    return '[fm.icelink.Holder]';
                };
                Holder.prototype.getValue = function () {
                    return this._value;
                };
                Holder.prototype.setValue = function (value) {
                    this._value = value;
                };
                return Holder;
            }());
            icelink.Holder = Holder;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpTransfer =  (function () {
                function HttpTransfer() {
                    fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                HttpTransfer.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpTransfer]';
                };
                HttpTransfer.addOnSendFinish = function (value) {
                    fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___onSendFinish, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.addOnSendStart = function (value) {
                    fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___onSendStart, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.addQueryToUrl = function () {
                    fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
                    if (arguments.length == 2) {
                        var url = arguments[0];
                        var key = arguments[1];
                        return fm.icelink.HttpTransfer.addQueryToUrl(url, key, null);
                    }
                    else if (arguments.length == 3) {
                        var url = arguments[0];
                        var key = arguments[1];
                        var value = arguments[2];
                        if (fm.icelink.StringExtensions.isNullOrEmpty(key)) {
                            return url;
                        }
                        if ((fm.icelink.Global.equals(value, null))) {
                            value = fm.icelink.StringExtensions.empty;
                        }
                        key = fm.icelink.Uri.escapeDataString(key);
                        value = fm.icelink.Uri.escapeDataString(value);
                        return fm.icelink.StringExtensions.concat([url, ((fm.icelink.Global.equals(fm.icelink.StringExtensions.indexOf(url, "?", fm.icelink.StringComparison.OrdinalIgnoreCase), -1)) ? "?" : "&"), key, "=", value]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.getRandomWildcardCharacter = function () {
                    fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
                    if (arguments.length == 0) {
                        var wildcardCharacters = fm.icelink.HttpTransfer.getWildcardCharacters();
                        var startIndex = new fm.icelink.Randomizer().next(fm.icelink.StringExtensions.getLength(wildcardCharacters));
                        return fm.icelink.StringExtensions.substring(wildcardCharacters, startIndex, 1);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.getWildcardCharacters = function () {
                    fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___wildcardCharacters;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.removeOnSendFinish = function (value) {
                    fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___onSendFinish, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.removeOnSendStart = function (value) {
                    fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___onSendStart, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.replaceWildcards = function (url) {
                    fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.StringExtensions.replace(url, "*", fm.icelink.HttpTransfer.getRandomWildcardCharacter());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.setWildcardCharacters = function (value) {
                    fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
                    if (arguments.length == 1) {
                        fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___wildcardCharacters = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.prototype.doSend = function (requestArgs) {
                    if (arguments.length == 1) {
                        var args = void 0;
                        this.startRequest(requestArgs);
                        try {
                            if ((!fm.icelink.Global.equals(requestArgs.getBinaryContent(), null))) {
                                args = this.sendBinary(requestArgs);
                            }
                            else {
                                args = this.sendText(requestArgs);
                            }
                        }
                        catch (exception) {
                            var args2 = new fm.icelink.HttpResponseArgs(requestArgs);
                            args2.setException(exception);
                            args = args2;
                        }
                        finally {
                        }
                        this.finishRequest(args);
                        return args;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.prototype.doSendAsync = function (requestArgs, callback, attempt, retryLogScope) {
                    var _this = this;
                    if (arguments.length == 4) {
                        attempt = fm.icelink.Global.toInt(arguments[2]);
                        var action = null;
                        var action2 = null;
                        this.startRequest(requestArgs);
                        try {
                            if ((!fm.icelink.Global.equals(requestArgs.getBinaryContent(), null))) {
                                if ((fm.icelink.Global.equals(action, null))) {
                                    action = function (responseArgs) {
                                        _this.finishRequest(responseArgs);
                                        _this.sendAsyncCallback(requestArgs, responseArgs, callback, attempt, retryLogScope);
                                    };
                                }
                                this.sendBinaryAsync(requestArgs, action);
                            }
                            else {
                                if ((fm.icelink.Global.equals(action2, null))) {
                                    action2 = function (responseArgs) {
                                        _this.finishRequest(responseArgs);
                                        _this.sendAsyncCallback(requestArgs, responseArgs, callback, attempt, retryLogScope);
                                    };
                                }
                                this.sendTextAsync(requestArgs, action2);
                            }
                        }
                        catch (exception) {
                            var args = new fm.icelink.HttpResponseArgs(requestArgs);
                            args.setException(exception);
                            this.sendAsyncCallback(requestArgs, args, callback, attempt, retryLogScope);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.prototype.finishRequest = function (responseArgs) {
                    if (arguments.length == 1) {
                        this.raiseOnSendFinish(responseArgs);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.prototype.raiseOnSendFinish = function (responseArgs) {
                    if (arguments.length == 1) {
                        var onSendFinish = fm.icelink.HttpTransfer.fm_icelink_HttpTransfer__onSendFinish;
                        if ((!fm.icelink.Global.equals(onSendFinish, null))) {
                            var p = new fm.icelink.HttpSendFinishArgs();
                            p.setSender(responseArgs.getRequestArgs().getSender());
                            p.setRequestBinaryContent(responseArgs.getRequestArgs().getBinaryContent());
                            p.setRequestTextContent(responseArgs.getRequestArgs().getTextContent());
                            p.setResponseBinaryContent(responseArgs.getBinaryContent());
                            p.setResponseTextContent(responseArgs.getTextContent());
                            p.setResponseHeaders(responseArgs.getHeaders());
                            onSendFinish(p);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.prototype.raiseOnSendStart = function (requestArgs) {
                    if (arguments.length == 1) {
                        var onSendStart = fm.icelink.HttpTransfer.fm_icelink_HttpTransfer__onSendStart;
                        if ((!fm.icelink.Global.equals(onSendStart, null))) {
                            var p = new fm.icelink.HttpSendStartArgs();
                            p.setSender(requestArgs.getSender());
                            p.setRequestBinaryContent(requestArgs.getBinaryContent());
                            p.setRequestTextContent(requestArgs.getTextContent());
                            onSendStart(p);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.prototype.send = function (requestArgs) {
                    if (arguments.length == 1) {
                        var num = 0;
                        var scope = null;
                        var args = this.doSend(requestArgs);
                        while (((!fm.icelink.Global.equals(args.getException(), null)) && (num < requestArgs.getMaxRetries()))) {
                            num++;
                            scope = fm.icelink.StringExtensions.replace(fm.icelink.Guid.newGuid().toString(), "-", "");
                            fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___log.warn(scope, fm.icelink.StringExtensions.format("Synchronous HTTP request failed, but retrying... (attempt #{0}).", fm.icelink.NumberExtensions.toString(num)), args.getException());
                            args = this.doSend(requestArgs);
                        }
                        if (((!fm.icelink.Global.equals(args.getException(), null)) && (!fm.icelink.Global.equals(scope, null)))) {
                            args.setRetries(num);
                            fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___log.warn(scope, "Synchronous HTTP request failed, and retries exhausted.", args.getException());
                        }
                        return args;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.prototype.sendAsync = function (requestArgs, callback) {
                    if (arguments.length == 2) {
                        this.doSendAsync(requestArgs, callback, 0, null);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.prototype.sendAsyncCallback = function (requestArgs, responseArgs, callback, attempt, retryLogScope) {
                    if (arguments.length == 5) {
                        attempt = fm.icelink.Global.toInt(arguments[3]);
                        if (((!fm.icelink.Global.equals(responseArgs.getException(), null)) && (attempt < requestArgs.getMaxRetries()))) {
                            attempt++;
                            retryLogScope = fm.icelink.StringExtensions.replace(fm.icelink.Guid.newGuid().toString(), "-", "");
                            fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___log.warn(retryLogScope, fm.icelink.StringExtensions.format("Asynchronous HTTP request failed, but retrying... (attempt #{0}).", fm.icelink.NumberExtensions.toString(attempt)), responseArgs.getException());
                            this.doSendAsync(requestArgs, callback, attempt, retryLogScope);
                        }
                        else {
                            if (((!fm.icelink.Global.equals(responseArgs.getException(), null)) && (!fm.icelink.Global.equals(retryLogScope, null)))) {
                                responseArgs.setRetries(attempt);
                                fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___log.warn(retryLogScope, "Asynchronous HTTP request failed, and retries exhausted.", responseArgs.getException());
                            }
                            callback(responseArgs);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.prototype.startRequest = function (requestArgs) {
                    if (arguments.length == 1) {
                        this.raiseOnSendStart(requestArgs);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransfer.fmicelinkHttpTransferInitialize = function () {
                    if (!fm.icelink.HttpTransfer.__fmicelinkHttpTransferInitialized && !fm.icelink.HttpTransfer.__fmicelinkHttpTransferInitializing) {
                        fm.icelink.HttpTransfer.__fmicelinkHttpTransferInitializing = true;
                        HttpTransfer.fm_icelink_HttpTransfer___onSendFinish = [];
                        HttpTransfer.fm_icelink_HttpTransfer___onSendStart = [];
                        HttpTransfer.fm_icelink_HttpTransfer__onSendFinish = function (p0) { for (var _i = 0, _a = fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___onSendFinish; _i < _a.length; _i++) {
                            var action = _a[_i];
                            action(p0);
                        } };
                        HttpTransfer.fm_icelink_HttpTransfer__onSendStart = function (p0) { for (var _i = 0, _a = fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___onSendStart; _i < _a.length; _i++) {
                            var action = _a[_i];
                            action(p0);
                        } };
                        fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___log = fm.icelink.Log.getLogger(new fm.icelink.Type('[fm.icelink.HttpTransfer]'));
                        fm.icelink.HttpTransfer.fm_icelink_HttpTransfer___wildcardCharacters = "abcdefghijklmnopqrstuvwxyz";
                        fm.icelink.HttpTransfer.__fmicelinkHttpTransferInitialized = true;
                        fm.icelink.HttpTransfer.__fmicelinkHttpTransferInitializing = false;
                    }
                };
                HttpTransfer.__fmicelinkHttpTransferInitialized = false;
                HttpTransfer.__fmicelinkHttpTransferInitializing = false;
                return HttpTransfer;
            }());
            icelink.HttpTransfer = HttpTransfer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    var fmicelinkGlobalIsError = function (obj) {
        return (obj instanceof Error);
    };
    (function (fm) {
        (function (icelink) {
            var Util =  (function () {
                function Util() {
                }
                Util.prototype.getTypeString = function () {
                    return '[fm.icelink.Util]';
                };
                Util.isNumber = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object Number]';
                };
                Util.isString = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object String]';
                };
                Util.isBoolean = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object Boolean]';
                };
                Util.isNull = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object Null]';
                };
                Util.isUndefined = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object Undefined]';
                };
                Util.isNullOrUndefined = function (obj) {
                    return Util.isNull(obj) || Util.isUndefined(obj);
                };
                Util.isFunction = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object Function]';
                };
                Util.isArray = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object Array]';
                };
                Util.isUint8Array = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object Uint8Array]';
                };
                Util.isDate = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object Date]';
                };
                Util.isRegExp = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object RegExp]';
                };
                Util.isError = function (obj) {
                    try {
                        if (fmicelinkGlobalIsError(obj)) {
                            return true;
                        }
                    }
                    catch (_a) { }
                    try {
                        var objName = Object.prototype.toString.call(obj);
                        return /\[object .*(Error|Exception)\]/.test(objName);
                    }
                    catch (_b) { }
                    return false;
                };
                Util.isObject = function (obj) {
                    return Object.prototype.toString.call(obj) === '[object Object]';
                };
                Util.isObjectType = function (obj, typeString) {
                    return (Util.isObject(obj) && Util.isFunction(obj.getTypeString) && obj.getTypeString().indexOf(typeString) > -1);
                };
                Util.isArrayType = function (obj, typeString) {
                    return (Util.isArray(obj) && (obj.length == 0 || (Util.isNullOrUndefined(obj[0]) || Util.isObjectType(obj[0], typeString))));
                };
                Util.isPlainObject = function (obj) {
                    if (!obj || Object.prototype.toString.call(obj) !== '[object Object]' || obj.nodeType || obj === obj.window) {
                        return false;
                    }
                    try {
                        if (obj.constructor && !Object.prototype.hasOwnProperty.call(obj, "constructor") && !Object.prototype.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf")) {
                            return false;
                        }
                    }
                    catch (error) {
                        return false;
                    }
                    var key;
                    for (key in obj) { }
                    return (key === void 0 || Object.prototype.hasOwnProperty.call(obj, key));
                };
                Util.canAttachProperties = function (instance, obj) {
                    for (var key in obj) {
                        obj[key];
                        var setterName = 'set' + key.charAt(0).toUpperCase() + key.substring(1);
                        var setter = instance[setterName];
                        if (!setter || Object.prototype.toString.call(setter) !== '[object Function]') {
                            return false;
                        }
                    }
                    return true;
                };
                Util.attachProperties = function (instance, obj) {
                    for (var key in obj) {
                        var value = obj[key];
                        var setterName = 'set' + key.charAt(0).toUpperCase() + key.substring(1);
                        var setter = instance[setterName];
                        if (setter && Object.prototype.toString.call(setter) === '[object Function]') {
                            setter.call(instance, value);
                        }
                        else {
                            setter = instance['setExtensionValue'];
                            if (setter && Object.prototype.toString.call(setter) === '[object Function]') {
                                if (Object.prototype.toString.call(value) === '[object Function]') {
                                    fm.icelink.Log.warn('Property "' + key + '" did not match any known setter and has a function as its value. Please verify your callback names are correct.');
                                }
                                else {
                                    setter.call(instance, key, value);
                                    fm.icelink.Log.debug('Property "' + key + '" did not match any known setter and is assumed to be an extension value.');
                                }
                            }
                            else {
                                fm.icelink.Log.debug('Property "' + key + '" did not match any known setter and was ignored.');
                            }
                        }
                    }
                    return instance;
                };
                Util.isIE = function () {
                    return !!document.protocol;
                };
                Util.isIE6 = function () {
                    return Util.isIE() && !window.XMLHttpRequest;
                };
                Util.isIE7 = function () {
                    return Util.isIE() && window.XMLHttpRequest && !document.implementation;
                };
                Util.isIE8 = function () {
                    return Util.isIE() && document.implementation && document.implementation.hasFeature && !document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1");
                };
                Util.isIE9 = function () {
                    return Util.isIE() && document.implementation && document.implementation.hasFeature && document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1");
                };
                Util.isEdge = function () {
                    return navigator.userAgent.match(/edge\//i) != null;
                };
                Util.isChrome = function () {
                    return navigator.userAgent.match(/chrome/i) != null;
                };
                Util.isFirefox = function () {
                    return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
                };
                Util.isSafari9 = function () {
                    return Util.isSafari() && navigator.userAgent.match(/version\/9\.\d(\.\d+)*(mobile\/[a-zA-Z0-9]+)? safari/i) != null;
                };
                Util.isSafari10 = function () {
                    return Util.isSafari() && navigator.userAgent.match(/version\/10\.\d(\.\d+)*(mobile\/[a-zA-Z0-9]+)? safari/i) != null;
                };
                Util.isSafari11 = function () {
                    return Util.isSafari() && navigator.userAgent.match(/version\/11\.\d(\.\d+)*(mobile\/[a-zA-Z0-9]+)? safari/i) != null;
                };
                Util.isSafari12 = function () {
                    return Util.isSafari() && navigator.userAgent.match(/version\/12\.\d(\.\d+)*(mobile\/[a-zA-Z0-9]+)? safari/i) != null;
                };
                Util.isSafari12_1 = function () {
                    return Util.isSafari() && navigator.userAgent.match(/version\/12\.1(\.\d+)*(mobile\/[a-zA-Z0-9]+)? safari/i) != null;
                };
                Util.isSafari = function () {
                    if (Util.isChrome() || Util.isEdge()) {
                        return false;
                    }
                    return navigator.userAgent.match(/version\/[^\s]+( mobile\/[^\s]+)? safari\/[^\s]+/i) != null;
                };
                Util.isOpera = function () {
                    return navigator.userAgent.match(/Opera Mini/i) != null;
                };
                Util.isWindows = function () {
                    return navigator.userAgent.match(/IEMobile/i) != null;
                };
                Util.isAndroid = function () {
                    return navigator.userAgent.match(/Android/i) != null;
                };
                Util.isBlackBerry = function () {
                    return navigator.userAgent.match(/BlackBerry/i) != null;
                };
                Util.isiOS = function () {
                    return navigator.userAgent.match(/iPhone|iPad|iPod/i) != null
                        || (navigator.maxTouchPoints != 0 && Util.isSafari());
                };
                Util.isMobile = function () {
                    return Util.isAndroid() || Util.isBlackBerry() || Util.isiOS() || Util.isOpera() || Util.isWindows();
                };
                Util.hasActiveX = function (checkFiltering) {
                    var hasActiveX = window.ActiveXObject !== void 0;
                    if (checkFiltering && hasActiveX && typeof window.external.msActiveXFilteringEnabled !== 'undefined' && window.external.msActiveXFilteringEnabled()) {
                        hasActiveX = false;
                        fm.icelink.Log.debug('ActiveX is filtered and cannot be used.');
                    }
                    return hasActiveX;
                };
                Util.hasJava = function () {
                    return (Util.getJavaVersion() != null);
                };
                Util.getJavaVersion = function () {
                    if (Util.isIE() && Util.hasActiveX()) {
                        if (Util.isJavaWebStartInstalledActiveX('1.9.0')) {
                            return '1.9.0';
                        }
                        if (Util.isJavaWebStartInstalledActiveX('1.8.0')) {
                            return '1.8.0';
                        }
                        if (Util.isJavaWebStartInstalledActiveX('1.7.0')) {
                            return '1.7.0';
                        }
                        if (Util.isJavaWebStartInstalledActiveX('1.6.0')) {
                            return '1.6.0';
                        }
                        if (Util.isJavaWebStartInstalledActiveX('1.5.0')) {
                            return '1.5.0';
                        }
                        if (Util.isJavaWebStartInstalledActiveX('1.4.2')) {
                            return '1.4.2';
                        }
                        return null;
                    }
                    else {
                        var version = null;
                        var mimes = window.navigator.mimeTypes;
                        if (mimes) {
                            for (var i = 0; i < mimes.length; i++) {
                                var mime = mimes[i];
                                var t = mime.type;
                                if (t.indexOf('java') > 0 && t.indexOf('jpi') > 0 && t.indexOf('applet') > 0) {
                                    var parts = t.split('=');
                                    version = parts[parts.length - 1];
                                }
                            }
                        }
                        return version;
                    }
                };
                Util.isJavaWebStartInstalledActiveX = function (version) {
                    try {
                        return Util.hasActiveX() && (new ActiveXObject('JavaWebStart.isInstalled.' + version + '.0') !== null);
                    }
                    catch (error) {
                        return false;
                    }
                };
                Util.isXD = function (url1, url2) {
                    try {
                        if (typeof url2 !== 'undefined') {
                            var host1 = Util.getHost(url1);
                            var host2 = Util.getHost(url2);
                            return Util.compareHost(host1, host2);
                        }
                        else {
                            if (!Util._xdCache[url1]) {
                                var handlerHost = Util.getHost(url1);
                                var thisHost = Util.getHost();
                                Util._xdCache[url1] = Util.compareHost(handlerHost, thisHost) ? 'y' : 'n';
                            }
                            return Util._xdCache[url1] === 'y';
                        }
                    }
                    catch (error) {
                        return false;
                    }
                };
                Util.getHost = function (url) {
                    if (!url) {
                        return Util.getCurrentHost();
                    }
                    var parsed = Util.parseUrl(url);
                    if (!parsed.protocol) {
                        return Util.getCurrentHost();
                    }
                    return parsed;
                };
                Util.compareHost = function (host1, host2) {
                    return host1.server !== host2.server || ((host1.port || host2.port) && host1.port !== host2.port);
                };
                Util.getCurrentHost = function () {
                    var l = document.location;
                    return {
                        protocol: l.protocol,
                        server: l.hostname,
                        port: l.port
                    };
                };
                Util.parseUrl = function (url) {
                    var parts = /(((http|ws)s?:)\/\/)?([\-\w\.\*]+)+(:(\d+))?(\/([^\?]*(\?\S+)?)?)?/i.exec(url);
                    if (parts.length < 6) {
                        throw new fm.icelink.Exception('Invalid URL (' + url + ').');
                    }
                    return {
                        prefix: parts[1],
                        protocol: parts[2],
                        server: parts[4],
                        postfix: parts[5],
                        port: parts[6],
                        path: parts[7]
                    };
                };
                Util.absolutizeUrl = function (url) {
                    if (!url) {
                        return url;
                    }
                    var parsed = Util.parseUrl(url);
                    if (parsed.protocol) {
                        if (parsed.server.indexOf('*') === -1) {
                            return url;
                        }
                        url = parsed.prefix + Util.wildcard(parsed.server);
                        if (parsed.postfix) {
                            url += parsed.postfix;
                        }
                        if (parsed.path) {
                            url += parsed.path;
                        }
                        return url;
                    }
                    var l = document.location;
                    var base = l.protocol + '//' + l.host;
                    if (url.charAt(0) === '/') {
                        return base + url;
                    }
                    else {
                        return base + l.pathname.substring(0, l.pathname.lastIndexOf('/') + 1) + url;
                    }
                };
                Util.wildcard = function (str) {
                    return str.replace('*', Util.getWildcard());
                };
                Util.getWildcard = function () {
                    if (Util._wildcard === null) {
                        Util._wildcard = Util.randomChar(Util._chars);
                    }
                    return Util._wildcard;
                };
                Util.randomChar = function (str) {
                    if (!str) {
                        return str;
                    }
                    return str.charAt(Math.floor(Math.random() * str.length));
                };
                Util.observe = function (element, event, handler) {
                    if (element.addEventListener) {
                        element.addEventListener(event, handler, false);
                    }
                    else if (element.attachEvent) {
                        element.attachEvent('on' + event, handler);
                    }
                    else {
                        element['on' + event] = handler;
                    }
                };
                Util.unobserve = function (element, event, handler) {
                    if (element.removeEventListener) {
                        element.removeEventListener(event, handler, false);
                    }
                    else {
                        element.detachEvent('on' + event, handler);
                    }
                };
                Util.observeAttr = function (element, handler) {
                    var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
                    var isDOMAttrModifiedSupported = function () {
                        var p = document.createElement('p');
                        var flag = false;
                        if (p.addEventListener) {
                            p.addEventListener('DOMAttrModified', function () {
                                return flag = true;
                            }, false);
                        }
                        else if (p.attachEvent) {
                            p.attachEvent('onDOMAttrModified', function () {
                                return flag = true;
                            });
                        }
                        else {
                            return false;
                        }
                        p.setAttribute('id', 'target');
                        return flag;
                    };
                    if (MutationObserver) {
                        var options = {
                            subtree: false,
                            attributes: true
                        };
                        var observer = new MutationObserver(function (mutations, observer) {
                            for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
                                var mutation = mutations_1[_i];
                                handler.call(mutation.target, mutation.attributeName);
                            }
                        });
                        observer.observe(element, options);
                    }
                    else if (isDOMAttrModifiedSupported()) {
                        Util.observe(element, 'DOMAttrModified', function (e) {
                            handler.call(element, e.attrName);
                        });
                    }
                    else if ('onpropertychange' in document.body) {
                        Util.observe(element, 'propertychange', function (e) {
                            handler.call(element, window.event.propertyName);
                        });
                    }
                };
                Util.construct = function (func, args) {
                    return (function (func, args, ctor) {
                        ctor.prototype = func.prototype;
                        var child = new ctor, result = func.apply(child, args);
                        return Object(result) === result ? result : child;
                    })(func, args, function () { });
                };
                Util.extend = function (dest, src) {
                    for (var key in src) {
                        dest[key] = src[key];
                    }
                    return dest;
                };
                Util.addOnLoad = function (fn) {
                    if (Util._readyRun) {
                        window.setTimeout(fn, 1);
                    }
                    else {
                        Util._loadFunctions.push(fn);
                    }
                };
                Util.ready = function () {
                    if (Util._readyRun) {
                        return;
                    }
                    Util._readyRun = true;
                    window.setTimeout(function () {
                        for (var _i = 0, _a = Util._loadFunctions; _i < _a.length; _i++) {
                            var loadFunction = _a[_i];
                            loadFunction();
                        }
                    }, 1);
                };
                Util.bindReady = function () {
                    if (Util._readyBound) {
                        return;
                    }
                    Util._readyBound = true;
                    if (document.readyState === 'complete') {
                        window.setTimeout(function () {
                            Util.ready();
                        }, 1);
                    }
                    else if (document.addEventListener) {
                        var loaded = function () {
                            document.removeEventListener("DOMContentLoaded", loaded, false);
                            Util.ready();
                        };
                        document.addEventListener("DOMContentLoaded", loaded, false);
                        var load = function () {
                            window.removeEventListener("load", load, false);
                            Util.ready();
                        };
                        window.addEventListener("load", load, false);
                    }
                    else if (document.attachEvent) {
                        var readyStateChange = function () {
                            if (document.readyState === "complete") {
                                document.detachEvent("onreadystatechange", readyStateChange);
                                Util.ready();
                            }
                        };
                        document.attachEvent("onreadystatechange", readyStateChange);
                        var topLevel = void 0;
                        try {
                            topLevel = window.frameElement === null;
                        }
                        catch (undefined$1) { }
                        if (document.documentElement.doScroll && topLevel) {
                            var checkReady = function () {
                                if (Util._loaded) {
                                    return;
                                }
                                try {
                                    document.documentElement.doScroll("left");
                                }
                                catch (error) {
                                    window.setTimeout(checkReady, 0);
                                    return;
                                }
                                Util.ready();
                            };
                            checkReady();
                        }
                    }
                    else {
                        Util.ready();
                    }
                };
                Util.initialize = function () {
                    if (!Util.__initialized) {
                        if (!Util._loaded) {
                            Util.addOnLoad(function () {
                                Util._loaded = true;
                            });
                        }
                        Util.bindReady();
                    }
                    Util.__initialized = true;
                };
                Util._xdCache = {};
                Util._chars = 'abcdefghijklmnopqrstuvwxyz';
                Util._loadFunctions = [];
                Util._wildcard = null;
                Util._readyRun = false;
                Util._readyBound = false;
                Util._loaded = false;
                Util.__initialized = false;
                return Util;
            }());
            icelink.Util = Util;
            Util.initialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpWebRequestTransfer =  (function (_super) {
                __extends(HttpWebRequestTransfer, _super);
                function HttpWebRequestTransfer() {
                    return _super.call(this) || this;
                }
                HttpWebRequestTransfer.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpWebRequestTransfer]' + ',' + _super.prototype.getTypeString.call(this);
                };
                HttpWebRequestTransfer.setDisableCors = function (disableCors) {
                    HttpWebRequestTransfer._disableCors = disableCors;
                };
                HttpWebRequestTransfer.getDisableCors = function () {
                    return HttpWebRequestTransfer._disableCors || false;
                };
                HttpWebRequestTransfer.setDisablePostMessage = function (disablePostMessage) {
                    HttpWebRequestTransfer._disablePostMessage = disablePostMessage;
                };
                HttpWebRequestTransfer.getDisablePostMessage = function () {
                    return HttpWebRequestTransfer._disablePostMessage || false;
                };
                HttpWebRequestTransfer.setDisableJsonp = function (disableJsonp) {
                    HttpWebRequestTransfer._disableJsonp = disableJsonp;
                };
                HttpWebRequestTransfer.getDisableJsonp = function () {
                    return HttpWebRequestTransfer._disableJsonp || false;
                };
                HttpWebRequestTransfer.setForceJsonp = function (forceJsonp) {
                    HttpWebRequestTransfer._forceJsonp = forceJsonp;
                };
                HttpWebRequestTransfer.getForceJsonp = function () {
                    return HttpWebRequestTransfer._forceJsonp || false;
                };
                HttpWebRequestTransfer.canCors = function () {
                    return window.XMLHttpRequest && ('withCredentials' in new XMLHttpRequest());
                };
                HttpWebRequestTransfer.canPostMessage = function () {
                    if (fm.icelink.Util.isIE6() || fm.icelink.Util.isIE7()) {
                        return false;
                    }
                    if (window.postMessage) {
                        return true;
                    }
                    else {
                        return false;
                    }
                };
                HttpWebRequestTransfer.prototype.sendTextAsync = function (requestArgs, callback) {
                    var _this = this;
                    return fm.icelink.Util.addOnLoad(function () {
                        return _this.process(requestArgs, callback);
                    });
                };
                HttpWebRequestTransfer.prototype.sendText = function (requestArgs) {
                    return this.process(requestArgs, null);
                };
                HttpWebRequestTransfer.prototype.sendBinaryAsync = function (requestArgs, callback) {
                    var _this = this;
                    return fm.icelink.Util.addOnLoad(function () {
                        return _this.process(requestArgs, callback);
                    });
                };
                HttpWebRequestTransfer.prototype.sendBinary = function (requestArgs) {
                    return this.process(requestArgs, null);
                };
                HttpWebRequestTransfer.prototype.process = function (requestArgs, callback) {
                    var hwrt = HttpWebRequestTransfer;
                    var url = requestArgs.getUrl();
                    if (!requestArgs._processed) {
                        url = fm.icelink.Util.absolutizeUrl(url);
                        requestArgs.setUrl(url);
                        requestArgs._processed = true;
                    }
                    var sender = requestArgs.getSender();
                    var disableCors = hwrt.getDisableCors() || (sender ? sender.getDisableCors() : false);
                    var disablePostMessage = hwrt.getDisablePostMessage() || (sender ? sender.getDisablePostMessage() : false);
                    var disableJsonp = hwrt.getDisableJsonp() || (sender ? sender.getDisableJsonp() : false);
                    var forceJsonp = hwrt.getForceJsonp() || (sender ? sender.getForceJsonp() : false);
                    var fn = fm.icelink.Xhr.send;
                    var cors = false;
                    var pm = false;
                    if (fm.icelink.Util.isXD(url)) {
                        if (!disableCors && hwrt.canCors() && !hwrt._corsFailCache[url]) {
                            cors = true;
                        }
                        else if (!disablePostMessage && hwrt.canPostMessage() && !hwrt._pmFailCache[url]) {
                            pm = true;
                            fn = fm.icelink.PostMessage.send;
                        }
                        else {
                            fn = fm.icelink.Jsonp.send;
                        }
                        if (disableJsonp && fn === fm.icelink.Jsonp.send) {
                            var responseArgs = new fm.icelink.HttpResponseArgs(requestArgs);
                            responseArgs.setException(new fm.icelink.Exception('Could not send HTTP request. All transports failed.'));
                            if (callback) {
                                callback(responseArgs);
                            }
                            return responseArgs;
                        }
                    }
                    if (forceJsonp) {
                        fn = fm.icelink.Jsonp.send;
                    }
                    return this.sendInternal(fn, cors, pm, requestArgs, callback);
                };
                HttpWebRequestTransfer.prototype.sendInternal = function (fn, cors, pm, requestArgs, callback) {
                    var _this = this;
                    var responseArgs = new fm.icelink.HttpResponseArgs(requestArgs);
                    responseArgs.setException(new fm.icelink.Exception('Environment does not support synchronous requests.'));
                    var url = requestArgs.getUrl();
                    var frameUrl = requestArgs.getDynamicProperties()['frameUrl'];
                    if (frameUrl && !requestArgs._processedFrame) {
                        frameUrl = fm.icelink.Util.absolutizeUrl(frameUrl);
                        requestArgs.getDynamicProperties()['frameUrl'] = frameUrl;
                        requestArgs._processedFrame = true;
                    }
                    frameUrl = frameUrl || url;
                    var method = 'GET';
                    switch (requestArgs.getMethod()) {
                        case fm.icelink.HttpMethod.Head:
                            method = 'HEAD';
                            break;
                        case fm.icelink.HttpMethod.Post:
                            method = 'POST';
                            break;
                        case fm.icelink.HttpMethod.Put:
                            method = 'PUT';
                            break;
                        case fm.icelink.HttpMethod.Patch:
                            method = 'PATCH';
                            break;
                        case fm.icelink.HttpMethod.Delete:
                            method = 'DELETE';
                    }
                    var options = {
                        sync: (callback ? false : true),
                        url: url,
                        frameUrl: frameUrl,
                        method: method,
                        content: requestArgs.getTextContent(),
                        contentBinary: requestArgs.getBinaryContent(),
                        headers: requestArgs.getHeaders().toHash(),
                        timeout: requestArgs.getTimeout(),
                        robustResponse: true
                    };
                    options.onRequestCreated = function (request) {
                        var onRequestCreated = requestArgs.getOnRequestCreated();
                        if (onRequestCreated) {
                            var args = new fm.icelink.HttpRequestCreatedArgs();
                            args.setRequestArgs(requestArgs);
                            args.setSender(requestArgs.getSender());
                            args.setRequest(request);
                            onRequestCreated(args);
                            options.content = requestArgs.getTextContent();
                            options.contentBinary = requestArgs.getBinaryContent();
                            options.headers = requestArgs.getHeaders().toHash();
                            options.timeout = requestArgs.getTimeout();
                        }
                        return options;
                    };
                    options.onResponseReceived = function (response) {
                        var onResponseReceived = requestArgs.getOnResponseReceived();
                        if (onResponseReceived) {
                            var args = new fm.icelink.HttpResponseReceivedArgs();
                            args.setRequestArgs(requestArgs);
                            args.setSender(requestArgs.getSender());
                            args.setResponse(response);
                            onResponseReceived(args);
                        }
                    };
                    options.onSuccess = function (e) {
                        if (e.statusCode === 0 && cors) {
                            if (!HttpWebRequestTransfer._corsSuccessCache[url]) {
                                HttpWebRequestTransfer._corsFailCache[url] = true;
                            }
                            if (callback) {
                                _this.sendTextAsync(requestArgs, callback);
                            }
                            else {
                                responseArgs = _this.sendText(requestArgs);
                            }
                            return;
                        }
                        else if (cors) {
                            HttpWebRequestTransfer._corsSuccessCache[url] = true;
                            delete HttpWebRequestTransfer._corsFailCache[url];
                        }
                        else if (pm) {
                            HttpWebRequestTransfer._pmSuccessCache[url] = true;
                            delete HttpWebRequestTransfer._pmFailCache[url];
                        }
                        responseArgs.setException(null);
                        responseArgs.setTextContent(e.content);
                        if (e.hasOwnProperty('contentBinary')) {
                            responseArgs.setBinaryContent(e.contentBinary);
                        }
                        responseArgs.setStatusCode(e.statusCode);
                        var headers = responseArgs.getHeaders();
                        for (var headerName in e.headers) {
                            headers.set(headerName, e.headers[headerName]);
                        }
                        if (callback) {
                            callback(responseArgs);
                        }
                    };
                    options.onFailure = function (e) {
                        if (cors && !HttpWebRequestTransfer._corsSuccessCache[url]) {
                            HttpWebRequestTransfer._corsFailCache[url] = true;
                            if (callback) {
                                _this.sendTextAsync(requestArgs, callback);
                            }
                            else {
                                responseArgs = _this.sendText(requestArgs);
                            }
                            return;
                        }
                        else if (pm && (e.local || !HttpWebRequestTransfer._pmSuccessCache[url])) {
                            HttpWebRequestTransfer._pmFailCache[url] = true;
                            if (callback) {
                                _this.sendTextAsync(requestArgs, callback);
                            }
                            else {
                                responseArgs = _this.sendText(requestArgs);
                            }
                            return;
                        }
                        var exception = new fm.icelink.Exception(e.message);
                        responseArgs.setException(exception);
                        if (callback) {
                            callback(responseArgs);
                        }
                    };
                    fn(options);
                    return responseArgs;
                };
                HttpWebRequestTransfer.prototype.shutdown = function () { };
                HttpWebRequestTransfer._corsFailCache = {};
                HttpWebRequestTransfer._corsSuccessCache = {};
                HttpWebRequestTransfer._pmFailCache = {};
                HttpWebRequestTransfer._pmSuccessCache = {};
                HttpWebRequestTransfer._disableCors = false;
                HttpWebRequestTransfer._disablePostMessage = false;
                HttpWebRequestTransfer._disableJsonp = false;
                HttpWebRequestTransfer._forceJsonp = false;
                HttpWebRequestTransfer.getPlatformCode = function () {
                    return 'js';
                };
                return HttpWebRequestTransfer;
            }(fm.icelink.HttpTransfer));
            icelink.HttpWebRequestTransfer = HttpWebRequestTransfer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var InternalConcurrentDictionary =  (function () {
                function InternalConcurrentDictionary(hashCallback) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var hashCallback_1 = __arguments[0];
                        this.__hashFunction = hashCallback_1;
                        this.__dict = {};
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                InternalConcurrentDictionary.prototype.getTypeString = function () {
                    return '[fm.icelink.InternalConcurrentDictionary]';
                };
                InternalConcurrentDictionary.prototype.getIsEmpty = function () {
                    return this.getCount() == 0;
                };
                InternalConcurrentDictionary.prototype.getKeys = function () {
                    var array = [];
                    var pairs = fm.icelink.HashExtensions.getValues(this.__dict);
                    for (var pair in pairs) {
                        array.push(pairs[pair].getItem1());
                    }
                    return array;
                };
                InternalConcurrentDictionary.prototype.getValues = function () {
                    var array = [];
                    var pairs = fm.icelink.HashExtensions.getValues(this.__dict);
                    for (var pair in pairs) {
                        array.push(pairs[pair].getItem2());
                    }
                    return array;
                };
                InternalConcurrentDictionary.prototype.getCount = function () {
                    return fm.icelink.HashExtensions.getCount(this.__dict);
                };
                InternalConcurrentDictionary.prototype.containsKey = function (key) {
                    var hash = this.__hashFunction(key);
                    return fm.icelink.HashExtensions.containsKey(this.__dict, hash);
                };
                InternalConcurrentDictionary.prototype.getOrAdd = function (key, valueFactory) {
                    var hash = this.__hashFunction(key);
                    var holder = new fm.icelink.Holder(null);
                    if (fm.icelink.HashExtensions.tryGetValue(this.__dict, hash, holder)) {
                        return holder.getValue().getItem2();
                    }
                    else {
                        var pair = new fm.icelink.MutablePair(key, valueFactory(key));
                        fm.icelink.HashExtensions.add(this.__dict, hash, pair);
                        return pair.getItem2();
                    }
                };
                InternalConcurrentDictionary.prototype.addOrUpdate = function (key, addValue, updateValueFactory) {
                    var hash = this.__hashFunction(key);
                    var holder = new fm.icelink.Holder(null);
                    if (fm.icelink.HashExtensions.tryGetValue(this.__dict, hash, holder)) {
                        var pair = holder.getValue();
                        pair.setItem2(updateValueFactory(key, pair.getItem2()));
                        return pair.getItem2();
                    }
                    else {
                        var pair = new fm.icelink.MutablePair(key, addValue);
                        fm.icelink.HashExtensions.add(this.__dict, hash, pair);
                        return addValue;
                    }
                };
                InternalConcurrentDictionary.prototype.tryAdd = function (key, value) {
                    if (arguments.length == 2) {
                        var hash = this.__hashFunction(key);
                        if (fm.icelink.HashExtensions.containsKey(this.__dict, hash)) {
                            return false;
                        }
                        var pair = new fm.icelink.MutablePair(key, value);
                        fm.icelink.HashExtensions.add(this.__dict, hash, pair);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentDictionary.prototype.tryGetValue = function (key, holder) {
                    var hash = this.__hashFunction(key);
                    var innerHolder = new fm.icelink.Holder(null);
                    if (fm.icelink.HashExtensions.tryGetValue(this.__dict, hash, innerHolder)) {
                        holder.setValue(innerHolder.getValue().getItem2());
                        return true;
                    }
                    else {
                        return false;
                    }
                };
                InternalConcurrentDictionary.prototype.tryRemove = function (key, value) {
                    if (arguments.length == 2) {
                        var hash = this.__hashFunction(key);
                        var holder = new fm.icelink.Holder(null);
                        if (fm.icelink.HashExtensions.tryGetValue(this.__dict, hash, holder)) {
                            value.setValue(holder.getValue().getItem2());
                            fm.icelink.HashExtensions.remove(this.__dict, hash);
                            return true;
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentDictionary.prototype.tryUpdate = function (key, newValue, comparisonValue) {
                    var hash = this.__hashFunction(key);
                    var holder = new fm.icelink.Holder(null);
                    if (fm.icelink.HashExtensions.tryGetValue(this.__dict, hash, holder)) {
                        var pair = holder.getValue();
                        if (pair.getItem2() === comparisonValue) {
                            pair.setItem2(newValue);
                            return true;
                        }
                    }
                    return false;
                };
                InternalConcurrentDictionary.prototype.clear = function () {
                    fm.icelink.HashExtensions.clear(this.__dict);
                };
                return InternalConcurrentDictionary;
            }());
            icelink.InternalConcurrentDictionary = InternalConcurrentDictionary;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Json =  (function () {
                function Json() {
                }
                Json.prototype.getTypeString = function () {
                    return '[fm.icelink.Json]';
                };
                Json._reviver = function (key, value) {
                    if (value && typeof value === 'string' && Json._dateRegex.test(value)) {
                        var ticksAndZone = value.match(Json._dateRegex)[1];
                        var delim = ticksAndZone.indexOf('-') > -1 ? '-' : '+';
                        var parts = ticksAndZone.split(delim);
                        var ticks = parseInt(parts[0], 10);
                        return new Date(ticks);
                    }
                    return value;
                };
                Json._buildReviver = function (reviver) {
                    var _this = this;
                    if (this.useMicrosoftDateFormat) {
                        if (reviver != null) {
                            return function (key, value) {
                                return reviver(key, _this._reviver(key, value));
                            };
                        }
                        else {
                            return this._reviver;
                        }
                    }
                    else {
                        return reviver;
                    }
                };
                Json.deserialize = function () {
                    var args = Array.prototype.slice.call(arguments);
                    if (args.length === 0 || args[0] === null || args[0] === '') {
                        return null;
                    }
                    args[1] = Json._buildReviver(args[1]);
                    return JSON.parse.apply(Json, args);
                };
                Json.serialize = function () {
                    if (Json.useMicrosoftDateFormat) {
                        var dateToJSON = Date.prototype.toJSON;
                        Date.prototype.toJSON = function (key) {
                            if (isFinite(this.valueOf())) {
                                return '/Date(' + this.getTime() + '-0000)/';
                            }
                            else {
                                return null;
                            }
                        };
                        try {
                            var j = JSON.stringify.apply(Json, arguments);
                            if (j === 'undefined') {
                                throw new fm.icelink.Exception('Cannot serialize undefined to JSON. Try using null instead.');
                            }
                            return j.replace(/\//g, '\\/');
                        }
                        finally {
                            Date.prototype.toJSON = dateToJSON;
                        }
                    }
                    return JSON.stringify.apply(Json, arguments);
                };
                Json.useMicrosoftDateFormat = true;
                Json._dateRegex = /^\/Date\((\d+[\-|\+]?\d{0,4})\)\/$/;
                return Json;
            }());
            icelink.Json = Json;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Jsonp =  (function () {
                function Jsonp() {
                }
                Jsonp.prototype.getTypeString = function () {
                    return '[fm.icelink.Jsonp]';
                };
                Jsonp.getNextCallback = function (options) {
                    var name = 'cb' + (Jsonp._callbackCount++);
                    var namespace = 'fm.icelink.Jsonp._cb.';
                    Jsonp._cb[name] = function (response) {
                        try {
                            if (options.onResponseReceived) {
                                options.onResponseReceived(null);
                            }
                            if (options.onSuccess) {
                                if (options.robustResponse) {
                                    var content = response[options.contentParameterName];
                                    if (!content) {
                                        content = '';
                                    }
                                    else if (typeof content !== 'string') {
                                        content = fm.icelink.Json.serialize(content);
                                    }
                                    options.onSuccess({
                                        content: content,
                                        contentBinary: null,
                                        statusCode: response[options.statusCodeParameterName] || 200,
                                        headers: response[options.headersParameterName] || {}
                                    });
                                }
                                else {
                                    var content = response;
                                    if (!content) {
                                        content = '';
                                    }
                                    else if (typeof content !== 'string') {
                                        content = fm.icelink.Json.serialize(content);
                                    }
                                    options.onSuccess({
                                        content: content,
                                        contentBinary: null,
                                        statusCode: 200,
                                        headers: {}
                                    });
                                }
                            }
                        }
                        catch (error) {
                            throw error;
                        }
                        finally {
                            Jsonp.cleanup((options.useFrame ? 'parent.' : '') + namespace + name, options.useFrame);
                        }
                    };
                    return (options.useFrame ? 'parent.' : '') + namespace + name;
                };
                Jsonp.failureHandler = function (options, callbackName, message) {
                    if (options.onFailure) {
                        options.onFailure({
                            message: message,
                            local: false
                        });
                    }
                    Jsonp.cleanup(callbackName, options.useFrame);
                };
                Jsonp.send = function (options) {
                    options = fm.icelink.Util.extend({
                        url: '',
                        method: 'POST',
                        content: null,
                        headers: {},
                        timeout: 15000,
                        canSegmentJsonArray: false,
                        robustResponse: false,
                        callbackParameterName: 'jsonp',
                        contentParameterName: 'content',
                        methodParameterName: 'method',
                        headersParameterName: 'headers',
                        statusCodeParameterName: 'statusCode',
                        cacheBusterParameterName: '_cb',
                        onRequestCreated: null,
                        onResponseReceived: null,
                        onFailure: null,
                        onSuccess: null
                    }, options || {});
                    options.useFrame = true;
                    var callbackName = Jsonp.getNextCallback(options);
                    try {
                        if (options.useFrame) {
                            if (!Jsonp._scriptFrameDestroyer) {
                                Jsonp._scriptFrameDestroyer = window.setInterval(function () {
                                    if (Jsonp._scriptFrame !== null) {
                                        Jsonp._pastScriptFrames.push(Jsonp._scriptFrame);
                                        Jsonp._scriptFrame = null;
                                        Jsonp._scriptFrameLoaded = false;
                                        if (Jsonp._pastScriptFrames.length === 2) {
                                            var pastScriptFrame = Jsonp._pastScriptFrames[0];
                                            for (var prop in pastScriptFrame) {
                                                delete pastScriptFrame[prop];
                                            }
                                            document.body.removeChild(pastScriptFrame);
                                            Jsonp._pastScriptFrames.splice(0, 1);
                                        }
                                    }
                                }, 300000);
                            }
                        }
                        var container = document.getElementsByTagName('head')[0];
                        var script_1;
                        if (options.useFrame) {
                            if (!Jsonp._scriptFrame) {
                                Jsonp._scriptFrame = document.createElement('iframe');
                                Jsonp._scriptFrame.style.display = 'none';
                                Jsonp._scriptFrame.src = 'PLEASE_IGNORE_THIS_404.htm';
                                document.body.appendChild(Jsonp._scriptFrame);
                            }
                            var doc = Jsonp._scriptFrame.contentWindow.document;
                            if (!doc) {
                                throw 'Could not create script frame.';
                            }
                            script_1 = doc.createElement('script');
                        }
                        else {
                            script_1 = document.createElement('script');
                        }
                        script_1.type = 'text/javascript';
                        script_1.charset = 'utf-8';
                        script_1.id = callbackName;
                        var url = options.url;
                        url = fm.icelink.HttpTransfer.addQueryToUrl(url, options.methodParameterName, options.method);
                        url = fm.icelink.HttpTransfer.addQueryToUrl(url, options.headersParameterName, fm.icelink.Json.serialize(options.headers));
                        url = fm.icelink.HttpTransfer.addQueryToUrl(url, options.callbackParameterName, callbackName);
                        url = fm.icelink.HttpTransfer.addQueryToUrl(url, options.cacheBusterParameterName, (new Date()).getTime().toString());
                        url = fm.icelink.HttpTransfer.addQueryToUrl(url, options.contentParameterName, options.content);
                        if (url.length > Jsonp.maxUrlLength) {
                            alert('URL length ' + url.length + ' exceeds maximum for JSON-P (' + Jsonp.maxUrlLength + ').');
                        }
                        script_1.src = url;
                        if (options.onRequestCreated) {
                            options.onRequestCreated(null);
                        }
                        window.setTimeout(function () {
                            if (Jsonp.callbackExists(callbackName)) {
                                Jsonp.failureHandler(options, callbackName, 'JSON-P request timed out.');
                            }
                        }, options.timeout);
                        if (options.useFrame) {
                            if (!Jsonp._scriptFrameLoaded) {
                                fm.icelink.Util.observe(Jsonp._scriptFrame, 'load', function () {
                                    window.setTimeout(function () {
                                        try {
                                            var container_1 = Jsonp._scriptFrame.contentWindow.document.body;
                                            container_1.appendChild(script_1);
                                        }
                                        catch (error) {
                                            Jsonp.failureHandler(options, callbackName, 'JSON-P request failed. Could not access script frame.');
                                        }
                                    }, 10);
                                    Jsonp._scriptFrameLoaded = true;
                                });
                            }
                            else {
                                try {
                                    var container_2 = Jsonp._scriptFrame.contentWindow.document.body;
                                    container_2.appendChild(script_1);
                                }
                                catch (error) {
                                    Jsonp.failureHandler(options, callbackName, 'JSON-P request failed. Could not access script frame.');
                                }
                            }
                        }
                        else {
                            container.appendChild(script_1);
                        }
                    }
                    catch (error) {
                        Jsonp.failureHandler(options, callbackName, 'JSON-P request failed. ' + (error.message || error.error || error.description || error));
                    }
                };
                Jsonp.cleanup = function (callbackName, useFrame) {
                    var parts = callbackName.split('.');
                    var name = parts[parts.length - 1];
                    Jsonp._cb[name] = null;
                    delete Jsonp._cb[name];
                    try {
                        var script = void 0;
                        if (useFrame) {
                            var scriptFrames = Jsonp._pastScriptFrames.concat([]);
                            if (Jsonp._scriptFrame !== null) {
                                scriptFrames.push(Jsonp._scriptFrame);
                            }
                            var doc = void 0;
                            for (var i = scriptFrames.length - 1; i >= 0; i--) {
                                doc = scriptFrames[i].contentWindow.document;
                                if (doc) {
                                    script = doc.getElementById(callbackName);
                                }
                                if (script) {
                                    break;
                                }
                            }
                            if (script) {
                                doc.body.removeChild(script);
                            }
                        }
                        else {
                            script = document.getElementById(callbackName);
                            if (script) {
                                document.getElementsByTagName('head')[0].removeChild(script);
                            }
                        }
                    }
                    catch (error) {
                        fm.icelink.Log.error('Could not remove script element.', error);
                    }
                };
                Jsonp.callbackExists = function (callbackName) {
                    var parts = callbackName.split('.');
                    var name = parts[parts.length - 1];
                    return fm.icelink.HashExtensions.containsKey(Jsonp._cb, name);
                };
                Jsonp.maxUrlLength = 2048;
                Jsonp._scriptFrame = null;
                Jsonp._scriptFrameLoaded = false;
                Jsonp._callbackCount = 0;
                Jsonp._cb = {};
                Jsonp._pastScriptFrames = [];
                Jsonp._scriptFrameDestroyer = 0;
                return Jsonp;
            }());
            icelink.Jsonp = Jsonp;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MacContextBase =  (function () {
                function MacContextBase(type) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var type_2 = __arguments[0];
                        this.setType(type_2);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                MacContextBase.prototype.getTypeString = function () {
                    return '[fm.icelink.MacContextBase]';
                };
                MacContextBase.compute = function (type, key, input) {
                    if (arguments.length == 3) {
                        var context = new fm.icelink.MacContext(type, key);
                        var buffer = context.compute(input);
                        context.destroy();
                        return buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MacContextBase.prototype.compute = function (input) {
                    if (arguments.length == 1) {
                        return this.doCompute(input);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MacContextBase.prototype.destroy = function () {
                    if (arguments.length == 0) {
                        this.doDestroy();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MacContextBase.prototype.getType = function () {
                    if (arguments.length == 0) {
                        return this._type;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MacContextBase.prototype.setType = function (value) {
                    if (arguments.length == 1) {
                        this._type = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MacContextBase;
            }());
            icelink.MacContextBase = MacContextBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MacContext =  (function (_super) {
                __extends(MacContext, _super);
                function MacContext(type, key) {
                    var _this = _super.call(this, type) || this;
                    _this._key = key;
                    return _this;
                }
                MacContext.prototype.getTypeString = function () {
                    return '[fm.icelink.MacContext]';
                };
                MacContext.prototype.doCompute = function (input) {
                    if (this.getType() == fm.icelink.MacType.HmacMd5) {
                        return null;
                    }
                    else if (this.getType() == fm.icelink.MacType.HmacSha1) {
                        return null;
                    }
                    else if (this.getType() == fm.icelink.MacType.HmacSha256) {
                        var hmac = new fm.icelink.HmacSha256(this._key.getData());
                        hmac.update(input.getData());
                        var digest = hmac.digest();
                        hmac.clean();
                        return fm.icelink.DataBuffer.wrap(digest);
                    }
                    throw new fm.icelink.Exception('Unknown MAC type.');
                };
                MacContext.prototype.doDestroy = function () { };
                return MacContext;
            }(fm.icelink.MacContextBase));
            icelink.MacContext = MacContext;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ManagedStopwatch =  (function () {
                function ManagedStopwatch() {
                    this.startTime = 0;
                    this.stopTime = 0;
                }
                ManagedStopwatch.prototype.getTypeString = function () {
                    return '[fm.icelink.ManagedStopwatch]';
                };
                ManagedStopwatch.dispatch = function (action) {
                    window.setTimeout(function () {
                        action();
                    }, 1);
                };
                ManagedStopwatch.getTimestamp = function () {
                    return (new Date().getTime()) * fm.icelink.Constants.getTicksPerMillisecond();
                };
                ManagedStopwatch.prototype.getElapsedTicks = function () {
                    return this.getElapsedMilliseconds() * fm.icelink.Constants.getTicksPerMillisecond();
                };
                ManagedStopwatch.prototype.getElapsedMilliseconds = function () {
                    if (this.startTime == 0) {
                        return 0;
                    }
                    if (this.stopTime == 0) {
                        return ((new Date().getTime()) - this.startTime);
                    }
                    return (this.stopTime - this.startTime);
                };
                ManagedStopwatch.prototype.start = function () {
                    this.startTime = (new Date().getTime());
                    this.stopTime = 0;
                };
                ManagedStopwatch.prototype.stop = function () {
                    this.stopTime = (new Date().getTime());
                };
                ManagedStopwatch.prototype.restart = function () {
                    this.start();
                };
                return ManagedStopwatch;
            }());
            icelink.ManagedStopwatch = ManagedStopwatch;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ManagedThread =  (function () {
                function ManagedThread() {
                }
                ManagedThread.prototype.getTypeString = function () {
                    return '[fm.icelink.ManagedThread]';
                };
                ManagedThread.getCurrentThreadId = function () {
                    return 1;
                };
                ManagedThread.dispatch = function (action) {
                    window.setTimeout(function () {
                        action();
                    }, 1);
                };
                return ManagedThread;
            }());
            icelink.ManagedThread = ManagedThread;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MathAssistant =  (function () {
                function MathAssistant() {
                }
                MathAssistant.prototype.getTypeString = function () {
                    return '[fm.icelink.MathAssistant]';
                };
                MathAssistant.getPi = function () {
                    return Math.PI;
                };
                MathAssistant.getE = function () {
                    return Math.E;
                };
                MathAssistant.abs = function (val) {
                    return Math.abs(val);
                };
                MathAssistant.acos = function (val) {
                    return Math.acos(val);
                };
                MathAssistant.asin = function (val) {
                    return Math.asin(val);
                };
                MathAssistant.atan = function (val) {
                    return Math.atan(val);
                };
                MathAssistant.atan2 = function (y, x) {
                    return Math.atan2(y, x);
                };
                MathAssistant.ceil = function (val) {
                    return Math.ceil(val);
                };
                MathAssistant.cos = function (val) {
                    return Math.cos(val);
                };
                MathAssistant.cosh = function (val) {
                    return (Math.exp(val) + Math.exp(-val)) / 2;
                };
                MathAssistant.exp = function (val) {
                    return Math.exp(val);
                };
                MathAssistant.floor = function (val) {
                    return Math.floor(val);
                };
                MathAssistant.log = function (val) {
                    return Math.log(val);
                };
                MathAssistant.log10 = function (val) {
                    return Math.log(val) / Math.LN10;
                };
                MathAssistant.max = function (val1, val2) {
                    return Math.max(val1, val2);
                };
                MathAssistant.min = function (val1, val2) {
                    return Math.min(val1, val2);
                };
                MathAssistant.pow = function (x, y) {
                    return Math.pow(x, y);
                };
                MathAssistant.round = function (value) {
                    return Math.round(value);
                };
                MathAssistant.sin = function (val) {
                    return Math.sin(val);
                };
                MathAssistant.sinh = function (val) {
                    return (Math.exp(val) - Math.exp(-val)) / 2;
                };
                MathAssistant.sqrt = function (val) {
                    return Math.sqrt(val);
                };
                MathAssistant.tan = function (val) {
                    return Math.tan(val);
                };
                MathAssistant.tanh = function (val) {
                    return (Math.exp(val) - Math.exp(-val)) / (Math.exp(val) + Math.exp(-val));
                };
                return MathAssistant;
            }());
            icelink.MathAssistant = MathAssistant;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var NameValueCollection =  (function () {
                function NameValueCollection(value) {
                    this._value = {};
                    if (typeof value !== 'undefined') {
                        for (var n in value) {
                            this._value[n] = value[n];
                        }
                    }
                }
                NameValueCollection.prototype.getTypeString = function () {
                    return '[fm.icelink.NameValueCollection]';
                };
                NameValueCollection.prototype.source = function () {
                    return this._value;
                };
                NameValueCollection.prototype.get = function (name) {
                    for (var n in this._value) {
                        if (n.toLowerCase() === name.toLowerCase()) {
                            return this._value[n];
                        }
                    }
                    return null;
                };
                NameValueCollection.prototype.set = function (name, value) {
                    for (var n in this._value) {
                        if (n.toLowerCase() === name.toLowerCase()) {
                            this._value[n] = value;
                            return;
                        }
                    }
                    this._value[name] = value;
                };
                NameValueCollection.prototype.getCount = function () {
                    var i = 0;
                    for (var n in this._value) {
                        i++;
                    }
                    return i;
                };
                NameValueCollection.prototype.toHash = function () {
                    return this._value;
                };
                NameValueCollection.prototype.getKeys = function () {
                    return this.getAllKeys();
                };
                NameValueCollection.prototype.getAllKeys = function () {
                    var keys = [];
                    for (var k in this._value) {
                        keys.push(k);
                    }
                    return keys;
                };
                return NameValueCollection;
            }());
            icelink.NameValueCollection = NameValueCollection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var NumberExtensions =  (function () {
                function NumberExtensions() {
                }
                NumberExtensions.prototype.getTypeString = function () {
                    return '[fm.icelink.NumberExtensions]';
                };
                NumberExtensions.toString = function (value, formatOrCultureInfo) {
                    return value.toString();
                };
                return NumberExtensions;
            }());
            icelink.NumberExtensions = NumberExtensions;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ObjectExtensions =  (function () {
                function ObjectExtensions() {
                }
                ObjectExtensions.prototype.getTypeString = function () {
                    return '[fm.icelink.ObjectExtensions]';
                };
                ObjectExtensions.getType = function (obj) {
                    return new fm.icelink.Type(obj.getTypeString());
                };
                ObjectExtensions.getHashCode = function (obj) {
                    if (typeof obj.getHashCode === 'function') {
                        return obj.getHashCode();
                    }
                    else if (fm.icelink.Util.isString(obj)) {
                        return fm.icelink.StringExtensions.getHashCode(obj);
                    }
                    else {
                        return fm.icelink.StringExtensions.getHashCode(JSON.stringify(obj));
                    }
                };
                return ObjectExtensions;
            }());
            icelink.ObjectExtensions = ObjectExtensions;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ParseAssistant =  (function () {
                function ParseAssistant() {
                }
                ParseAssistant.prototype.getTypeString = function () {
                    return '[fm.icelink.ParseAssistant]';
                };
                ParseAssistant.parseByteValue = function (s) {
                    return parseInt(s);
                };
                ParseAssistant.parseShortValue = function (s) {
                    return parseInt(s);
                };
                ParseAssistant.parseIntegerValue = function (s) {
                    return parseInt(s);
                };
                ParseAssistant.parseLongValue = function (s) {
                    return parseInt(s);
                };
                ParseAssistant.parseFloatValue = function (s) {
                    return parseFloat(s);
                };
                ParseAssistant.parseDoubleValue = function (s) {
                    return parseFloat(s);
                };
                ParseAssistant.parseDecimalValue = function (s) {
                    return parseFloat(s);
                };
                ParseAssistant.parseBooleanValue = function (s) {
                    if (s.toLowerCase() === "true" || s.toLowerCase() === "y" || s === "1") {
                        return true;
                    }
                    else {
                        return false;
                    }
                };
                ParseAssistant.parseGuidValue = function (s) {
                    return new fm.icelink.Guid(s);
                };
                ParseAssistant.tryParseByteValue = function (s, h) {
                    if (isNaN(parseInt(s))) {
                        return false;
                    }
                    h.setValue(parseInt(s));
                    return true;
                };
                ParseAssistant.tryParseShortValue = function (s, h) {
                    if (isNaN(parseInt(s))) {
                        return false;
                    }
                    h.setValue(parseInt(s));
                    return true;
                };
                ParseAssistant.tryParseIntegerValue = function (s, h) {
                    if (isNaN(parseInt(s))) {
                        return false;
                    }
                    h.setValue(parseInt(s));
                    return true;
                };
                ParseAssistant.tryParseLongValue = function (s, h) {
                    if (isNaN(parseInt(s))) {
                        return false;
                    }
                    h.setValue(parseInt(s));
                    return true;
                };
                ParseAssistant.tryParseFloatValue = function (s, h) {
                    if (isNaN(parseFloat(s))) {
                        return false;
                    }
                    h.setValue(parseFloat(s));
                    return true;
                };
                ParseAssistant.tryParseDoubleValue = function (s, h) {
                    if (isNaN(parseFloat(s))) {
                        return false;
                    }
                    h.setValue(parseFloat(s));
                    return true;
                };
                ParseAssistant.tryParseDecimalValue = function (s, h) {
                    if (isNaN(parseFloat(s))) {
                        return false;
                    }
                    h.setValue(parseFloat(s));
                    return true;
                };
                ParseAssistant.tryParseBooleanValue = function (s, h) {
                    if (s.toLowerCase() === "true" || s.toLowerCase() === "y" || s === "1") {
                        h.setValue(true);
                    }
                    else {
                        h.setValue(false);
                    }
                    return true;
                };
                ParseAssistant.tryParseGuidValue = function (s, h) {
                    if (!(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i.test(s))) {
                        return false;
                    }
                    h.setValue(new fm.icelink.Guid(s));
                    return true;
                };
                return ParseAssistant;
            }());
            icelink.ParseAssistant = ParseAssistant;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Platform =  (function () {
                function Platform() {
                    this.littleEndianChecked = false;
                    this.isLittleEndian = false;
                    this.isMobile = false;
                    this.useFipsAlgorithms = false;
                    var check = false;
                    (function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4)))
                        check = true; })(navigator.userAgent || navigator.vendor || window.opera);
                    this.isMobile = check;
                }
                Platform.getInstance = function () {
                    return Platform.instance;
                };
                Platform.prototype.getIsMobile = function () {
                    return this.isMobile;
                };
                Platform.prototype.setIsMobile = function (isMobile) {
                    this.isMobile = isMobile;
                };
                Platform.prototype.getIsLittleEndian = function () {
                    if (!this.littleEndianChecked) {
                        this.littleEndianChecked = true;
                        var a = new ArrayBuffer(4);
                        var b = new Uint8Array(a);
                        var c = new Uint32Array(a);
                        b[0] = 0xa1;
                        b[1] = 0xb2;
                        b[2] = 0xc3;
                        b[3] = 0xd4;
                        this.isLittleEndian = (c[0] == 0xd4c3b2a1);
                    }
                    return this.isLittleEndian;
                };
                Platform.prototype.getOperatingSystem = function () {
                    return fm.icelink.OperatingSystem.Unknown;
                };
                Platform.prototype.getOperatingSystemVersion = function () {
                    return null;
                };
                Platform.prototype.getArchitecture = function () {
                    return fm.icelink.Architecture.Unknown;
                };
                Platform.prototype.getSourceLanguage = function () {
                    return fm.icelink.SourceLanguage.TypeScript;
                };
                Platform.prototype.getCoreCount = function () {
                    return navigator.hardwareConcurrency || 0;
                };
                Platform.prototype.getPhysicalMemory = function () {
                    return (navigator.deviceMemory || 0) * 1024 * 1024 * 1024;
                };
                Platform.prototype.getMachineName = function () {
                    return navigator.userAgent;
                };
                Platform.prototype.getDirectorySeparator = function () {
                    return '/';
                };
                Platform.prototype.getProcessId = function () {
                    return 1;
                };
                Platform.prototype.getUseFipsAlgorithms = function () {
                    return false;
                };
                Platform.prototype.setUseFipsAlgorithms = function (useFipsAlgorithms) { };
                Platform.prototype.getCryptoLibrary = function () {
                    return fm.icelink.CryptoLibrary.Default;
                };
                Platform.prototype.setCryptoLibrary = function (cryptoLibrary) { };
                Platform.instance = new Platform();
                return Platform;
            }());
            icelink.Platform = Platform;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Xhr =  (function () {
                function Xhr() {
                }
                Xhr.prototype.getTypeString = function () {
                    return '[fm.icelink.Xhr]';
                };
                Xhr.setDisableBinary = function (disableBinary) {
                    Xhr._disableBinary = disableBinary;
                };
                Xhr.getDisableBinary = function () {
                    if (typeof Uint8Array === 'undefined') {
                        return true;
                    }
                    return Xhr._disableBinary;
                };
                Xhr.setDefaultWithCredentials = function (defaultWithCredentials) {
                    Xhr._defaultWithCredentials = defaultWithCredentials;
                };
                Xhr.getDefaultWithCredentials = function () {
                    return Xhr._defaultWithCredentials;
                };
                Xhr.failureHandler = function (options, message) {
                    if (options.onFailure) {
                        return options.onFailure({
                            message: message,
                            local: false
                        });
                    }
                };
                Xhr.successHandler = function (options, x) {
                    if (options.onSuccess) {
                        var headers = {};
                        var headerString = x.getAllResponseHeaders();
                        if (headerString) {
                            for (var _i = 0, _a = headerString.split(/\r?\n/); _i < _a.length; _i++) {
                                var line = _a[_i];
                                var parts = line.split(':');
                                if (parts.length !== 2) {
                                    continue;
                                }
                                var name_1 = parts[0].replace(/\s+$/, '');
                                var value = parts[1].replace(/^\s+/, '');
                                headers[name_1] = value;
                            }
                        }
                        var content = null;
                        var contentBinary = null;
                        var receivedBinary = false;
                        if (!Xhr.getDisableBinary()) {
                            try {
                                if (x.responseType === 'arraybuffer' && x.response) {
                                    contentBinary = new Uint8Array(x.response);
                                    if (headers['Content-Type'] !== 'application/octet-stream') {
                                        content = fm.icelink.Encoding.getUtf8().getString(contentBinary);
                                    }
                                    receivedBinary = true;
                                }
                            }
                            catch (error) {
                                Xhr.setDisableBinary(true);
                            }
                        }
                        if (!receivedBinary) {
                            content = x.responseText;
                        }
                        return options.onSuccess({
                            content: content,
                            contentBinary: contentBinary,
                            statusCode: x.status,
                            headers: headers
                        });
                    }
                };
                Xhr.handler = function (options, x) {
                    if (x._aborting) {
                        return Xhr.failureHandler(options, 'XHR request timed out.');
                    }
                    else {
                        if (options.onResponseReceived) {
                            options.onResponseReceived(x);
                        }
                        return Xhr.successHandler(options, x);
                    }
                };
                Xhr.send = function (options) {
                    options = fm.icelink.Util.extend({
                        sync: false,
                        url: '',
                        method: 'POST',
                        content: null,
                        contentBinary: null,
                        headers: {},
                        timeout: 15000,
                        abortOnUnload: false,
                        cacheBusterParameterName: '_cb',
                        onRequestCreated: null,
                        onResponseReceived: null,
                        onFailure: null,
                        onSuccess: null
                    }, options || {});
                    try {
                        var x_1;
                        if (window.XMLHttpRequest) {
                            x_1 = new XMLHttpRequest();
                        }
                        else {
                            try {
                                x_1 = new ActiveXObject('MSXML2.XMLHTTP.3.0');
                            }
                            catch (undefined$1) { }
                            if (!x_1) {
                                try {
                                    x_1 = new ActiveXObject('Microsoft.XMLHTTP');
                                }
                                catch (undefined$1) { }
                            }
                        }
                        if (!x_1) {
                            return false;
                        }
                        var url = options.url;
                        if (options.method === 'GET') {
                            url = url + (url.indexOf('?') === -1 ? '?' : '&') + options.cacheBusterParameterName + '=' + (new Date()).getTime();
                        }
                        x_1.open(options.method, url, !options.sync);
                        if (Xhr.getDisableBinary()) {
                            x_1.setRequestHeader('X-FM-DisableBinary', 'true');
                        }
                        if (!Xhr.getDisableBinary() && !options.sync) {
                            try {
                                x_1.responseType = 'arraybuffer';
                            }
                            catch (error) {
                                Xhr.setDisableBinary(true);
                            }
                        }
                        if (options.onRequestCreated) {
                            options = options.onRequestCreated(x_1);
                        }
                        var useDefaultContentType = true;
                        for (var name_2 in options.headers) {
                            var value = options.headers[name_2];
                            if (name_2.toLowerCase() !== 'referer' && name_2.toLowerCase() !== 'origin') {
                                if (name_2.toLowerCase() === 'content-type') {
                                    useDefaultContentType = false;
                                }
                                x_1.setRequestHeader(name_2, value);
                            }
                        }
                        var c_1;
                        if (options.abortOnUnload) {
                            c_1 = ++Xhr._count;
                            Xhr._current[c_1] = x_1;
                        }
                        var xhrTimeout_1;
                        if (!options.sync) {
                            x_1.onreadystatechange = function () {
                                if (x_1.readyState > 3 && !x_1._abortingOnUnload) {
                                    clearTimeout(xhrTimeout_1);
                                    try {
                                        x_1.onreadystatechange = null;
                                    }
                                    catch (error) {
                                        x_1.onreadystatechange = function () { };
                                    }
                                    if (x_1.status > 0) {
                                        Xhr.handler(options, x_1);
                                    }
                                    else {
                                        Xhr.failureHandler(options, 'Invalid XHR response.');
                                    }
                                    if (options.abortOnUnload) {
                                        return delete Xhr._current[c_1];
                                    }
                                }
                            };
                        }
                        var sentBinary = false;
                        if (!Xhr.getDisableBinary() && options.contentBinary) {
                            try {
                                x_1.send(options.contentBinary.buffer);
                                sentBinary = true;
                            }
                            catch (error) {
                                try {
                                    x_1.send(options.contentBinary);
                                    sentBinary = true;
                                }
                                catch (error) {
                                    Xhr.setDisableBinary(true);
                                }
                            }
                        }
                        if (!sentBinary) {
                            if (options.content) {
                                if (useDefaultContentType) {
                                    x_1.setRequestHeader('Content-Type', 'application/json');
                                }
                                x_1.send(options.content);
                            }
                            else {
                                x_1.send();
                            }
                        }
                        xhrTimeout_1 = window.setTimeout(function () {
                            try {
                                x_1._aborting = true;
                                x_1.abort();
                            }
                            catch (undefined$1) { }
                        }, options.timeout);
                        if (options.sync) {
                            Xhr.handler(options, x_1);
                            if (options.abortOnUnload) {
                                delete Xhr._current[c_1];
                            }
                        }
                        return true;
                    }
                    catch (error) {
                        Xhr.failureHandler(options, 'XHR request failed. ' + (error.message || error.error || error.description || error));
                        return false;
                    }
                };
                Xhr.initialize = function () {
                    if (!Xhr.__initialized) {
                        fm.icelink.Util.observe(window, 'unload', function () {
                            for (var c in Xhr._current) {
                                var x = Xhr._current[c];
                                try {
                                    x._abortingOnUnload = true;
                                    x.abort();
                                }
                                catch (undefined$1) { }
                            }
                        });
                    }
                    Xhr.__initialized = true;
                };
                Xhr._count = 0;
                Xhr._current = {};
                Xhr._disableBinary = false;
                Xhr._defaultWithCredentials = true;
                Xhr.__initialized = false;
                return Xhr;
            }());
            icelink.Xhr = Xhr;
            Xhr.initialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PostMessage =  (function () {
                function PostMessage() {
                }
                PostMessage.prototype.getTypeString = function () {
                    return '[fm.icelink.PostMessage]';
                };
                PostMessage.getOrigin = function (url) {
                    return /\w+:\/\/[^\/]+/.exec(url)[0];
                };
                PostMessage.createFrame = function (options, callback) {
                    var record = PostMessage._cache[options.frameUrl];
                    if (!record) {
                        var frame_1 = document.createElement('iframe');
                        frame_1.style.display = 'none';
                        document.body.appendChild(frame_1);
                        var callbacks_1 = [callback];
                        frame_1.loading = true;
                        PostMessage._cache[options.frameUrl] = record = {
                            frame: frame_1,
                            callbacks: callbacks_1
                        };
                        var loadTimeout_1 = window.setTimeout(function () {
                            frame_1.loading = false;
                            frame_1.loaded = false;
                            frame_1.timedOut = true;
                            while (callbacks_1.length > 0) {
                                callbacks_1.shift()(null, 'Frame load timed out.');
                            }
                        }, options.timeout);
                        fm.icelink.Util.observe(frame_1, 'load', function () {
                            if (frame_1.timedOut) {
                                return;
                            }
                            clearTimeout(loadTimeout_1);
                            var receivePong = function (e) {
                                if (e.source === frame_1.contentWindow && e.data === 'pong') {
                                    if (frame_1.timedOut) {
                                        return;
                                    }
                                    clearTimeout(pongTimeout);
                                    frame_1.loading = false;
                                    frame_1.loaded = true;
                                    frame_1.timedOut = false;
                                    PostMessage.listen(options, frame_1);
                                    while (callbacks_1.length > 0) {
                                        callbacks_1.shift()(frame_1, null);
                                    }
                                    return fm.icelink.Util.unobserve(window, 'message', receivePong);
                                }
                            };
                            var pongTimeout = window.setTimeout(function () {
                                frame_1.loading = false;
                                frame_1.loaded = false;
                                frame_1.timedOut = true;
                                while (callbacks_1.length > 0) {
                                    callbacks_1.shift()(null, 'Frame pong timed out.');
                                }
                                if (receivePong) {
                                    return fm.icelink.Util.unobserve(window, 'message', receivePong);
                                }
                            }, 500);
                            fm.icelink.Util.observe(window, 'message', receivePong);
                            frame_1.contentWindow.postMessage('ping', PostMessage.getOrigin(options.url));
                        });
                        frame_1.src = fm.icelink.HttpTransfer.addQueryToUrl(options.frameUrl, 'type', 'pmf');
                    }
                    else {
                        if (record.frame.loading) {
                            record.callbacks.push(callback);
                        }
                        else {
                            window.setTimeout(function () {
                                if (record.frame.loaded) {
                                    callback(record.frame, null);
                                }
                                else {
                                    callback(null, 'Frame not loaded.');
                                }
                            }, 1);
                        }
                    }
                };
                PostMessage.send = function (options) {
                    options = fm.icelink.Util.extend({
                        url: '',
                        onFailure: null,
                        onSuccess: null,
                        onRequestCreated: null,
                        onResponseReceived: null
                    }, options || {});
                    options.contentBinary = null;
                    PostMessage.createFrame(options, function (frame, error) {
                        if (frame) {
                            options.id = ++PostMessage._optionsCounter;
                            PostMessage._optionsCache[options.id] = options;
                            return frame.contentWindow.postMessage(fm.icelink.Json.serialize(options), PostMessage.getOrigin(options.url));
                        }
                        else {
                            if (options.onFailure) {
                                var message = 'Could not initialize postMessage frame.';
                                if (error) {
                                    message += ' ' + error;
                                }
                                return options.onFailure({
                                    message: message,
                                    local: true
                                });
                            }
                        }
                    });
                };
                PostMessage.listen = function (options, frame) {
                    fm.icelink.Util.observe(window, 'message', function (e) {
                        if (e.source === frame.contentWindow) {
                            try {
                                e = fm.icelink.Json.deserialize(e.data);
                            }
                            catch (error) {
                                return;
                            }
                            if (!e.id) {
                                return;
                            }
                            options = PostMessage._optionsCache[e.id];
                            if (!options) {
                                return;
                            }
                            if (e.type === 1 || e.type === 2) {
                                delete PostMessage._optionsCache[e.id];
                            }
                            if (e.type === 1) {
                                if (options.onFailure) {
                                    options.onFailure(e);
                                }
                            }
                            else if (e.type === 2) {
                                if (options.onSuccess) {
                                    options.onSuccess(e);
                                }
                            }
                            else if (e.type === 3) {
                                if (options.onRequestCreated) {
                                    options.onRequestCreated(null);
                                }
                            }
                            else if (e.type === 4) {
                                if (options.onResponseReceived) {
                                    options.onResponseReceived(null);
                                }
                            }
                        }
                    });
                };
                PostMessage._cache = {};
                PostMessage._optionsCounter = 0;
                PostMessage._optionsCache = {};
                return PostMessage;
            }());
            icelink.PostMessage = PostMessage;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PromiseBase =  (function (_super) {
                __extends(PromiseBase, _super);
                function PromiseBase() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.__id = fm.icelink.StringExtensions.replace(fm.icelink.Guid.newGuid().toString(), "-", "");
                        _this.__stateLock = new Object();
                        _this.__pendingPromisesToResolve = new Array();
                        _this.__pendingPromisesToReject = new Array();
                        _this.__pendingResolves = new Array();
                        _this.__pendingRejects = new Array();
                        _super.prototype.setState.call(_this, fm.icelink.FutureState.Pending);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                PromiseBase.prototype.getTypeString = function () {
                    return '[fm.icelink.PromiseBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PromiseBase.all = function (promises) {
                    if (arguments.length == 1) {
                        var promise = new fm.icelink.Promise();
                        if (((fm.icelink.Global.equals(promises, null)) || (fm.icelink.Global.equals(promises.length, 0)))) {
                            promise.resolve(null);
                            return promise;
                        }
                        var counter = new fm.icelink.AtomicInteger(promises.length);
                        promise.doAll(promises, counter);
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.rejectNow = function (ex) {
                    if (arguments.length == 1) {
                        var promise = new fm.icelink.Promise();
                        promise.reject(ex);
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.resolveNow = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.PromiseBase.resolveNow(null);
                    }
                    else if (arguments.length == 1) {
                        var result = arguments[0];
                        var promise = new fm.icelink.Promise();
                        promise.resolve(result);
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.wrapPromise = function (callback) {
                    if (arguments.length == 1) {
                        try {
                            if ((fm.icelink.Global.equals(callback, null))) {
                                throw new fm.icelink.Exception("callback cannot be null.");
                            }
                            return callback();
                        }
                        catch (exception) {
                            return fm.icelink.PromiseBase.rejectNow(exception);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.addReject = function (promise, reject) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(this.__pendingPromisesToReject, null))) {
                            this.__pendingPromisesToReject = new Array();
                        }
                        if ((fm.icelink.Global.equals(this.__pendingRejects, null))) {
                            this.__pendingRejects = new Array();
                        }
                        fm.icelink.ArrayExtensions.add(this.__pendingPromisesToReject, promise);
                        fm.icelink.ArrayExtensions.add(this.__pendingRejects, reject);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.addResolve = function (promise, resolve) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(this.__pendingPromisesToResolve, null))) {
                            this.__pendingPromisesToResolve = new Array();
                        }
                        if ((fm.icelink.Global.equals(this.__pendingResolves, null))) {
                            this.__pendingResolves = new Array();
                        }
                        fm.icelink.ArrayExtensions.add(this.__pendingPromisesToResolve, promise);
                        fm.icelink.ArrayExtensions.add(this.__pendingResolves, resolve);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.castAndResolve = function (result) {
                    if (arguments.length == 1) {
                        return this.resolve(result);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.doAll = function (promises, counter) {
                    var _this = this;
                    if (arguments.length == 2) {
                        var resolveAction = null;
                        var rejectAction = null;
                        for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
                            var future = promises_1[_i];
                            if ((fm.icelink.Global.equals(resolveAction, null))) {
                                resolveAction = function (result) {
                                    if ((fm.icelink.Global.equals(counter.decrement(), 0))) {
                                        _this.resolve(null);
                                    }
                                };
                            }
                            if ((fm.icelink.Global.equals(rejectAction, null))) {
                                rejectAction = function (ex) {
                                    _this.reject(ex);
                                };
                            }
                            future.then(resolveAction, rejectAction);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.doRejectAsync = function (promise, exception) {
                    var _this = this;
                    if (arguments.length == 2) {
                        fm.icelink.ManagedThread.dispatch(function () {
                            if (_this.reject(exception)) {
                                promise.resolve(null);
                            }
                            else {
                                promise.reject(new fm.icelink.Exception("Promise was already fulfilled."));
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.doResolveAsync = function (promise, result) {
                    var _this = this;
                    if (arguments.length == 2) {
                        fm.icelink.ManagedThread.dispatch(function () {
                            if (_this.resolve(result)) {
                                promise.resolve(null);
                            }
                            else {
                                promise.reject(new fm.icelink.Exception("Promise was already fulfilled."));
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this.__id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.process = function (promise, resolve, reject) {
                    if (arguments.length == 3) {
                        if ((fm.icelink.Global.equals(_super.prototype.getState.call(this), fm.icelink.FutureState.Pending))) {
                            this.addResolve(promise, resolve);
                            this.addReject(promise, reject);
                            return;
                        }
                        if ((fm.icelink.Global.equals(_super.prototype.getState.call(this), fm.icelink.FutureState.Resolved))) {
                            this.raiseResolve(resolve, _super.prototype.getResult.call(this), promise);
                        }
                        else {
                            if ((fm.icelink.Global.equals(_super.prototype.getState.call(this), fm.icelink.FutureState.Rejected))) {
                                this.raiseReject(reject, _super.prototype.getException.call(this), promise);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.raiseReject = function (callback, exception, promise) {
                    if (arguments.length == 3) {
                        try {
                            callback(exception);
                        }
                        catch (exception2) {
                            fm.icelink.Log.error("Could not reject promise. Promise rejection callback threw an unhandled exception.", exception2);
                            promise.reject(exception2);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.raiseRejects = function (exception) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.__pendingRejects, null))) {
                            for (var i = 0; (i < fm.icelink.ArrayExtensions.getCount(this.__pendingRejects)); i++) {
                                this.raiseReject(this.__pendingRejects[i], exception, this.__pendingPromisesToReject[i]);
                            }
                        }
                        this.reset();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.raiseResolve = function (callback, result, promise) {
                    if (arguments.length == 3) {
                        try {
                            callback(result);
                        }
                        catch (exception) {
                            fm.icelink.Log.error("Could not resolve promise. Promise resolution callback threw an unhandled exception.", exception);
                            promise.reject(exception);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.raiseResolves = function (result) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.__pendingResolves, null))) {
                            for (var i = 0; (i < fm.icelink.ArrayExtensions.getCount(this.__pendingResolves)); i++) {
                                this.raiseResolve(this.__pendingResolves[i], result, this.__pendingPromisesToResolve[i]);
                            }
                        }
                        this.reset();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.reject = function (exception) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(_super.prototype.getState.call(this), fm.icelink.FutureState.Pending))) {
                            return false;
                        }
                        _super.prototype.setException.call(this, exception);
                        _super.prototype.setState.call(this, fm.icelink.FutureState.Rejected);
                        this.raiseRejects(exception);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.rejectAsync = function (exception) {
                    if (arguments.length == 1) {
                        var promise = new fm.icelink.Promise();
                        this.doRejectAsync(promise, exception);
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.reset = function () {
                    if (arguments.length == 0) {
                        fm.icelink.ArrayExtensions.clear(this.__pendingPromisesToResolve);
                        fm.icelink.ArrayExtensions.clear(this.__pendingPromisesToReject);
                        fm.icelink.ArrayExtensions.clear(this.__pendingResolves);
                        fm.icelink.ArrayExtensions.clear(this.__pendingRejects);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.resolve = function (result) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(_super.prototype.getState.call(this), fm.icelink.FutureState.Pending))) {
                            return false;
                        }
                        _super.prototype.setResult.call(this, result);
                        _super.prototype.setState.call(this, fm.icelink.FutureState.Resolved);
                        this.raiseResolves(result);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PromiseBase.prototype.resolveAsync = function (result) {
                    if (arguments.length == 1) {
                        var promise = new fm.icelink.Promise();
                        this.doResolveAsync(promise, result);
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return PromiseBase;
            }(fm.icelink.Future));
            icelink.PromiseBase = PromiseBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Promise =  (function (_super) {
                __extends(Promise, _super);
                function Promise() {
                    return _super !== null && _super.apply(this, arguments) || this;
                }
                Promise.prototype.getTypeString = function () {
                    return '[fm.icelink.Promise]' + ',' + _super.prototype.getTypeString.call(this);
                };
                Promise.prototype.then = function (resolve, reject) {
                    var promise = new fm.icelink.Promise();
                    this.process(promise, function (result) {
                        if (resolve == null) {
                            promise.resolve(result);
                        }
                        else {
                            var resolveResult = resolve(result);
                            if (fm.icelink.Util.isObjectType(resolveResult, '[fm.icelink.Future]')) {
                                resolveResult.then(function (chainedResult) {
                                    promise.resolve(chainedResult);
                                }, function (exception) {
                                    promise.reject(exception);
                                });
                            }
                            else {
                                promise.resolve(resolveResult);
                            }
                        }
                    }, function (exception) {
                        if (reject != null) {
                            reject(exception);
                        }
                        promise.reject(exception);
                    });
                    return promise;
                };
                Promise.prototype.fail = function (reject) {
                    var promise = new fm.icelink.Promise();
                    this.process(promise, function (result) {
                        promise.resolve(result);
                    }, function (exception) {
                        if (reject != null) {
                            reject(exception);
                        }
                        promise.reject(exception);
                    });
                    return promise;
                };
                Promise.wrap = function (callbackActionOrFunction) {
                    var promise = new fm.icelink.Promise();
                    try {
                        if (callbackActionOrFunction == null) {
                            promise.resolve(null);
                        }
                        else {
                            var result = callbackActionOrFunction();
                            if (result) {
                                promise.resolve(result);
                            }
                            else {
                                promise.resolve(null);
                            }
                        }
                    }
                    catch (ex) {
                        promise.reject(ex);
                    }
                    return promise;
                };
                Promise.wrapAsync = function (callbackActionOrFunction) {
                    var promise = new fm.icelink.Promise();
                    fm.icelink.ManagedThread.dispatch(function () {
                        try {
                            if (callbackActionOrFunction == null) {
                                promise.resolve(null);
                            }
                            else {
                                var result = callbackActionOrFunction();
                                if (result) {
                                    promise.resolve(result);
                                }
                                else {
                                    promise.resolve(null);
                                }
                            }
                        }
                        catch (ex) {
                            promise.reject(ex);
                        }
                    });
                    return promise;
                };
                return Promise;
            }(fm.icelink.PromiseBase));
            icelink.Promise = Promise;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Randomizer =  (function () {
                function Randomizer() {
                }
                Randomizer.prototype.getTypeString = function () {
                    return '[fm.icelink.Randomizer]';
                };
                Randomizer.prototype.next = function () {
                    if (arguments.length == 0) {
                        return this.next(0, 2147483647);
                    }
                    else if (arguments.length == 1) {
                        var maxValue = arguments[0];
                        return this.next(0, maxValue);
                    }
                    else if (arguments.length == 2) {
                        var minValue = arguments[0];
                        var maxValue = arguments[1];
                        return Math.floor(Math.random() * (maxValue - minValue)) + minValue;
                    }
                };
                Randomizer.prototype.nextDouble = function () {
                    return Math.random();
                };
                Randomizer.prototype.nextBytes = function (buffer) {
                    for (var i = 0; i < buffer.length; i++) {
                        buffer[i] = this.next(256);
                    }
                };
                Randomizer.prototype.randomString = function (size) {
                    var s = '';
                    for (var i = 0; i < size; i++) {
                        s += Randomizer._randomCharset.charAt(this.next(Randomizer._randomCharset.length));
                    }
                    return s;
                };
                Randomizer._randomCharset = 'abcdefghijklmnopqrstuvwxyz0123456789';
                return Randomizer;
            }());
            icelink.Randomizer = Randomizer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Regex =  (function () {
                function Regex(pattern) {
                    this.pattern = pattern;
                }
                Regex.prototype.getTypeString = function () {
                    return '[fm.icelink.Regex]';
                };
                Regex.isMatch = function (input, pattern) {
                    return new RegExp(pattern).test(input);
                };
                Regex.prototype.isMatch = function (input) {
                    return new RegExp(this.pattern).test(input);
                };
                return Regex;
            }());
            icelink.Regex = Regex;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var digestLength = 32;
            var blockSize = 64;
            var K = new Uint32Array([
                0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b,
                0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01,
                0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7,
                0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
                0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152,
                0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
                0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
                0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
                0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819,
                0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08,
                0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,
                0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
                0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
            ]);
            function hashBlocks(w, v, p, pos, len) {
                var a, b, c, d, e, f, g, h, u, i, j, t1, t2;
                while (len >= 64) {
                    a = v[0];
                    b = v[1];
                    c = v[2];
                    d = v[3];
                    e = v[4];
                    f = v[5];
                    g = v[6];
                    h = v[7];
                    for (i = 0; i < 16; i++) {
                        j = pos + i * 4;
                        w[i] = (((p[j] & 0xff) << 24) | ((p[j + 1] & 0xff) << 16) |
                            ((p[j + 2] & 0xff) << 8) | (p[j + 3] & 0xff));
                    }
                    for (i = 16; i < 64; i++) {
                        u = w[i - 2];
                        t1 = (u >>> 17 | u << (32 - 17)) ^ (u >>> 19 | u << (32 - 19)) ^ (u >>> 10);
                        u = w[i - 15];
                        t2 = (u >>> 7 | u << (32 - 7)) ^ (u >>> 18 | u << (32 - 18)) ^ (u >>> 3);
                        w[i] = (t1 + w[i - 7] | 0) + (t2 + w[i - 16] | 0);
                    }
                    for (i = 0; i < 64; i++) {
                        t1 = (((((e >>> 6 | e << (32 - 6)) ^ (e >>> 11 | e << (32 - 11)) ^
                            (e >>> 25 | e << (32 - 25))) + ((e & f) ^ (~e & g))) | 0) +
                            ((h + ((K[i] + w[i]) | 0)) | 0)) | 0;
                        t2 = (((a >>> 2 | a << (32 - 2)) ^ (a >>> 13 | a << (32 - 13)) ^
                            (a >>> 22 | a << (32 - 22))) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
                        h = g;
                        g = f;
                        f = e;
                        e = (d + t1) | 0;
                        d = c;
                        c = b;
                        b = a;
                        a = (t1 + t2) | 0;
                    }
                    v[0] += a;
                    v[1] += b;
                    v[2] += c;
                    v[3] += d;
                    v[4] += e;
                    v[5] += f;
                    v[6] += g;
                    v[7] += h;
                    pos += 64;
                    len -= 64;
                }
                return pos;
            }
            var Sha256 =  (function () {
                function Sha256() {
                    this.digestLength = digestLength;
                    this.blockSize = blockSize;
                    this.state = new Int32Array(8);
                    this.temp = new Int32Array(64);
                    this.buffer = new Uint8Array(128);
                    this.bufferLength = 0;
                    this.bytesHashed = 0;
                    this.finished = false;
                    this.reset();
                }
                Sha256.prototype.reset = function () {
                    this.state[0] = 0x6a09e667;
                    this.state[1] = 0xbb67ae85;
                    this.state[2] = 0x3c6ef372;
                    this.state[3] = 0xa54ff53a;
                    this.state[4] = 0x510e527f;
                    this.state[5] = 0x9b05688c;
                    this.state[6] = 0x1f83d9ab;
                    this.state[7] = 0x5be0cd19;
                    this.bufferLength = 0;
                    this.bytesHashed = 0;
                    this.finished = false;
                    return this;
                };
                Sha256.prototype.clean = function () {
                    for (var i = 0; i < this.buffer.length; i++) {
                        this.buffer[i] = 0;
                    }
                    for (var i = 0; i < this.temp.length; i++) {
                        this.temp[i] = 0;
                    }
                    this.reset();
                };
                Sha256.prototype.update = function (data, dataLength) {
                    if (dataLength === void 0) { dataLength = data.length; }
                    if (this.finished) {
                        throw new fm.icelink.Exception("SHA256: can't update because hash was finished.");
                    }
                    var dataPos = 0;
                    this.bytesHashed += dataLength;
                    if (this.bufferLength > 0) {
                        while (this.bufferLength < 64 && dataLength > 0) {
                            this.buffer[this.bufferLength++] = data[dataPos++];
                            dataLength--;
                        }
                        if (this.bufferLength === 64) {
                            hashBlocks(this.temp, this.state, this.buffer, 0, 64);
                            this.bufferLength = 0;
                        }
                    }
                    if (dataLength >= 64) {
                        dataPos = hashBlocks(this.temp, this.state, data, dataPos, dataLength);
                        dataLength %= 64;
                    }
                    while (dataLength > 0) {
                        this.buffer[this.bufferLength++] = data[dataPos++];
                        dataLength--;
                    }
                    return this;
                };
                Sha256.prototype.finish = function (out) {
                    if (!this.finished) {
                        var bytesHashed = this.bytesHashed;
                        var left = this.bufferLength;
                        var bitLenHi = (bytesHashed / 0x20000000) | 0;
                        var bitLenLo = bytesHashed << 3;
                        var padLength = (bytesHashed % 64 < 56) ? 64 : 128;
                        this.buffer[left] = 0x80;
                        for (var i = left + 1; i < padLength - 8; i++) {
                            this.buffer[i] = 0;
                        }
                        this.buffer[padLength - 8] = (bitLenHi >>> 24) & 0xff;
                        this.buffer[padLength - 7] = (bitLenHi >>> 16) & 0xff;
                        this.buffer[padLength - 6] = (bitLenHi >>> 8) & 0xff;
                        this.buffer[padLength - 5] = (bitLenHi >>> 0) & 0xff;
                        this.buffer[padLength - 4] = (bitLenLo >>> 24) & 0xff;
                        this.buffer[padLength - 3] = (bitLenLo >>> 16) & 0xff;
                        this.buffer[padLength - 2] = (bitLenLo >>> 8) & 0xff;
                        this.buffer[padLength - 1] = (bitLenLo >>> 0) & 0xff;
                        hashBlocks(this.temp, this.state, this.buffer, 0, padLength);
                        this.finished = true;
                    }
                    for (var i = 0; i < 8; i++) {
                        out[i * 4 + 0] = (this.state[i] >>> 24) & 0xff;
                        out[i * 4 + 1] = (this.state[i] >>> 16) & 0xff;
                        out[i * 4 + 2] = (this.state[i] >>> 8) & 0xff;
                        out[i * 4 + 3] = (this.state[i] >>> 0) & 0xff;
                    }
                    return this;
                };
                Sha256.prototype.digest = function () {
                    var out = new Uint8Array(this.digestLength);
                    this.finish(out);
                    return out;
                };
                Sha256.prototype._saveState = function (out) {
                    for (var i = 0; i < this.state.length; i++) {
                        out[i] = this.state[i];
                    }
                };
                Sha256.prototype._restoreState = function (from, bytesHashed) {
                    for (var i = 0; i < this.state.length; i++) {
                        this.state[i] = from[i];
                    }
                    this.bytesHashed = bytesHashed;
                    this.finished = false;
                    this.bufferLength = 0;
                };
                return Sha256;
            }());
            icelink.Sha256 = Sha256;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function () {
                fm.icelink.HttpTransfer.addQueryToUrl = function (url, key, value) {
                    if (typeof key === 'undefined' || fm.icelink.StringExtensions.isNullOrEmpty(key)) {
                        return url;
                    }
                    if (typeof value === 'undefined' || value === null) {
                        value = '';
                    }
                    value = encodeURIComponent(value);
                    return fm.icelink.StringExtensions.concat([url, (fm.icelink.StringExtensions.indexOf(url, "?", fm.icelink.StringComparison.OrdinalIgnoreCase) === -1 ? "?" : "&"), key, "=", value]);
                };
            })();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Stack =  (function () {
                function Stack(depth) {
                    this._list = [];
                    if (typeof depth !== 'undefined') {
                        this._depth = depth;
                    }
                    else {
                        this._depth = 0;
                    }
                }
                Stack.prototype.getTypeString = function () {
                    return '[fm.icelink.Stack]';
                };
                Stack.prototype.push = function (o) {
                    if (this._depth !== 0 && this.getCount() === this._depth) {
                        throw new fm.icelink.Exception('Depth of stack would be exceeded by pushing value.');
                    }
                    this._list.push(o);
                };
                Stack.prototype.pop = function () {
                    return this._list.pop();
                };
                Stack.prototype.peek = function () {
                    if (this._list.length === 0) {
                        return null;
                    }
                    return this._list[this._list.length - 1];
                };
                Stack.prototype.getCount = function () {
                    return this._list.length;
                };
                return Stack;
            }());
            icelink.Stack = Stack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StringBuilder =  (function () {
                function StringBuilder(value) {
                    if (typeof value === 'undefined') {
                        this._value = '';
                    }
                    else {
                        this._value = value;
                    }
                }
                StringBuilder.prototype.getTypeString = function () {
                    return '[fm.icelink.StringBuilder]';
                };
                StringBuilder.prototype.append = function (s, startIndex, count) {
                    if (typeof startIndex === 'undefined' && typeof count === 'undefined') {
                        this._value = this._value + s;
                    }
                    else if (typeof count === 'undefined') {
                        this._value = this._value + s.substring(startIndex);
                    }
                    else {
                        this._value = this._value + s.substring(startIndex, startIndex + count);
                    }
                    return this;
                };
                StringBuilder.prototype.toString = function () {
                    return this._value;
                };
                StringBuilder.prototype.getLength = function () {
                    return this._value.length;
                };
                StringBuilder.prototype.remove = function (startIndex, length) {
                    this._value = this._value.substring(0, startIndex) + this._value.substring(startIndex + length);
                    return this;
                };
                return StringBuilder;
            }());
            icelink.StringBuilder = StringBuilder;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (StringComparison) {
                StringComparison[StringComparison["CurrentCulture"] = 0] = "CurrentCulture";
                StringComparison[StringComparison["CurrentCultureIgnoreCase"] = 1] = "CurrentCultureIgnoreCase";
                StringComparison[StringComparison["InvariantCulture"] = 2] = "InvariantCulture";
                StringComparison[StringComparison["InvariantCultureIgnoreCase"] = 3] = "InvariantCultureIgnoreCase";
                StringComparison[StringComparison["Ordinal"] = 4] = "Ordinal";
                StringComparison[StringComparison["OrdinalIgnoreCase"] = 5] = "OrdinalIgnoreCase";
            })(icelink.StringComparison || (icelink.StringComparison = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StringExtensions =  (function () {
                function StringExtensions() {
                }
                StringExtensions.prototype.getTypeString = function () {
                    return '[fm.icelink.StringExtensions]';
                };
                StringExtensions.nullCoalesce = function (value1, value2) {
                    if (value1 || value1 == '') {
                        return value1;
                    }
                    return value2;
                };
                StringExtensions.toString = function (s) {
                    return s;
                };
                StringExtensions.trim = function (s) {
                    if (s === null || s === undefined) {
                        throw new fm.icelink.Exception("trim() received a null argument.");
                    }
                    return s.replace(/^\s+|\s+$/g, '');
                };
                StringExtensions.trimEnd = function (s, chars) {
                    if (s === null || s === undefined) {
                        throw new fm.icelink.Exception("trimEnd() received a null argument.");
                    }
                    var expression = '[';
                    for (var _i = 0, chars_1 = chars; _i < chars_1.length; _i++) {
                        var c = chars_1[_i];
                        expression += String.fromCharCode(c);
                    }
                    expression += ']*$';
                    return s.replace(new RegExp(expression, 'g'), '');
                };
                StringExtensions.trimStart = function (s, chars) {
                    if (s === null || s === undefined) {
                        throw new fm.icelink.Exception("trimStart() received a null argument.");
                    }
                    var expression = '^[';
                    for (var _i = 0, chars_2 = chars; _i < chars_2.length; _i++) {
                        var c = chars_2[_i];
                        expression += String.fromCharCode(c);
                    }
                    expression += ']*';
                    return s.replace(new RegExp(expression, 'g'), '');
                };
                StringExtensions.replace = function (s, search, replace) {
                    if (s === null || s === undefined || search === null || search === undefined) {
                        throw new fm.icelink.Exception("replace() received a null argument.");
                    }
                    return s.replace(new RegExp(search.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"), 'g'), replace);
                };
                StringExtensions.concat = function () {
                    var strings = [];
                    for (var _i = 0; _i < arguments.length; _i++) {
                        strings[_i] = arguments[_i];
                    }
                    if (strings.length == 1 && fm.icelink.Util.isArray(strings[0])) {
                        strings = strings[0];
                    }
                    var s = '';
                    for (var _a = 0, strings_1 = strings; _a < strings_1.length; _a++) {
                        var str = strings_1[_a];
                        s += str;
                    }
                    return s;
                };
                StringExtensions.contains = function (str, s) {
                    if (str === null || str === undefined) {
                        throw new fm.icelink.Exception("contains() received a null argument.");
                    }
                    return (str.indexOf(s) > -1);
                };
                StringExtensions.join = function (separator) {
                    var array = [];
                    for (var _i = 1; _i < arguments.length; _i++) {
                        array[_i - 1] = arguments[_i];
                    }
                    if (array.length == 1 && fm.icelink.Util.isArray(array[0])) {
                        array = array[0];
                    }
                    var sb = new fm.icelink.StringBuilder();
                    for (var i = 0; i < array.length; i++) {
                        if (i > 0) {
                            sb.append(separator);
                        }
                        sb.append(array[i]);
                    }
                    return sb.toString();
                };
                StringExtensions.split = function (s, chars) {
                    if (s === null || s === undefined || chars === null || chars === undefined) {
                        throw new fm.icelink.Exception("split() received a null argument.");
                    }
                    var splits = [];
                    var start = 0;
                    for (var i = 0; i < s.length; i++) {
                        for (var _i = 0, chars_3 = chars; _i < chars_3.length; _i++) {
                            var c = chars_3[_i];
                            if (c == s.charCodeAt(i)) {
                                splits.push(s.substring(start, i));
                                start = i + 1;
                            }
                        }
                    }
                    splits.push(s.substring(start, s.length));
                    return splits;
                };
                StringExtensions.isNullOrEmpty = function (s) {
                    var noe = typeof s === 'undefined' || s === null || s === '';
                    if (!noe) {
                        if (typeof s !== 'string' && !(s instanceof String)) {
                            throw new fm.icelink.Exception('Object is not a string.');
                        }
                    }
                    return noe;
                };
                StringExtensions.isEqual = function (str, s, stringComparison) {
                    if (typeof stringComparison !== 'undefined') {
                        if (stringComparison === fm.icelink.StringComparison.CurrentCultureIgnoreCase || stringComparison === fm.icelink.StringComparison.InvariantCultureIgnoreCase || stringComparison === fm.icelink.StringComparison.OrdinalIgnoreCase) {
                            return str.toLowerCase() === s.toLowerCase();
                        }
                    }
                    return str === s;
                };
                StringExtensions.indexOf = function (str, s, stringComparison) {
                    if (s === null || s === undefined) {
                        throw new fm.icelink.Exception("indexOf() received a null argument.");
                    }
                    if (typeof stringComparison !== 'undefined') {
                        if (stringComparison === fm.icelink.StringComparison.CurrentCultureIgnoreCase || stringComparison === fm.icelink.StringComparison.InvariantCultureIgnoreCase || stringComparison === fm.icelink.StringComparison.OrdinalIgnoreCase) {
                            return str.toLowerCase().indexOf(s.toLowerCase());
                        }
                    }
                    return str.indexOf(s);
                };
                StringExtensions.lastIndexOf = function (str, s, stringComparison) {
                    if (s === null || s === undefined) {
                        throw new fm.icelink.Exception("lastIndexOf() received a null argument.");
                    }
                    if (typeof stringComparison !== 'undefined') {
                        if (stringComparison === fm.icelink.StringComparison.CurrentCultureIgnoreCase || stringComparison === fm.icelink.StringComparison.InvariantCultureIgnoreCase || stringComparison === fm.icelink.StringComparison.OrdinalIgnoreCase) {
                            return str.toLowerCase().lastIndexOf(s.toLowerCase());
                        }
                    }
                    return str.lastIndexOf(s);
                };
                StringExtensions.startsWith = function (str, s, stringComparison) {
                    if (s === null || s === undefined) {
                        throw new fm.icelink.Exception("startsWith() received a null argument.");
                    }
                    if (typeof stringComparison !== 'undefined') {
                        if (stringComparison === fm.icelink.StringComparison.CurrentCultureIgnoreCase || stringComparison === fm.icelink.StringComparison.InvariantCultureIgnoreCase || stringComparison === fm.icelink.StringComparison.OrdinalIgnoreCase) {
                            return str.toLowerCase().indexOf(s.toLowerCase()) === 0;
                        }
                    }
                    return str.indexOf(s) === 0;
                };
                StringExtensions.endsWith = function (str, s, stringComparison) {
                    if (s === null || s === undefined) {
                        throw new fm.icelink.Exception("endsWith() received a null argument.");
                    }
                    if (typeof stringComparison !== 'undefined') {
                        if (stringComparison === fm.icelink.StringComparison.CurrentCultureIgnoreCase || stringComparison === fm.icelink.StringComparison.InvariantCultureIgnoreCase || stringComparison === fm.icelink.StringComparison.OrdinalIgnoreCase) {
                            return str.toLowerCase().indexOf(s.toLowerCase(), str.length - s.length) !== -1;
                        }
                    }
                    return str.indexOf(s, str.length - s.length) !== -1;
                };
                StringExtensions.compareTo = function (s1, s2) {
                    if (s1 === null || s1 === undefined || s2 === null || s2 === undefined) {
                        throw new fm.icelink.Exception("compareTo() received one or more null arguments.");
                    }
                    if (s1.toString() < s2.toString()) {
                        return -1;
                    }
                    if (s1.toString() > s2.toString()) {
                        return 1;
                    }
                    return 0;
                };
                StringExtensions.format = function (format) {
                    var args = [];
                    for (var _i = 1; _i < arguments.length; _i++) {
                        args[_i - 1] = arguments[_i];
                    }
                    if (format === null || format === undefined) {
                        throw new fm.icelink.Exception("format() received a null argument.");
                    }
                    if (args.length == 1 && fm.icelink.Util.isArray(args[0])) {
                        args = args[0];
                    }
                    var formatter = function (match, number) {
                        if (args[number] != null) {
                            return args[number];
                        }
                        return match;
                    };
                    return format.replace(/{(\d+)}/g, formatter);
                };
                StringExtensions.toLower = function (str) {
                    if (str === null || str === undefined) {
                        throw new fm.icelink.Exception("toLower() received a null argument.");
                    }
                    return str.toLowerCase();
                };
                StringExtensions.toUpper = function (str) {
                    if (str === null || str === undefined) {
                        throw new fm.icelink.Exception("toUpper() received a null argument.");
                    }
                    return str.toUpperCase();
                };
                StringExtensions.getLength = function (str) {
                    if (str === null || str === undefined) {
                        throw new fm.icelink.Exception("getLength() received a null argument.");
                    }
                    return str.length;
                };
                StringExtensions.getChars = function (str) {
                    if (str === null || str === undefined) {
                        throw new fm.icelink.Exception("getChars() received a null argument.");
                    }
                    var chars = [];
                    for (var i = 0; i < str.length; i++) {
                        chars.push(str[i]);
                    }
                    return chars;
                };
                StringExtensions.substring = function (str, startIndex, length) {
                    if (str === null || str === undefined) {
                        throw new fm.icelink.Exception("substring() received a null argument.");
                    }
                    return str.substring(startIndex, startIndex + length);
                };
                StringExtensions.getHashCode = function (str) {
                    if (str === null || str === undefined) {
                        throw new fm.icelink.Exception("getHashCode() received a null argument.");
                    }
                    var hash = 0, i = 0, chr = 0;
                    if (str.length == 0) {
                        return hash;
                    }
                    for (i = 0; i < str.length; i++) {
                        chr = str.charCodeAt(i);
                        hash = ((hash << 5) - hash) + chr;
                        hash |= 0;
                    }
                    return hash;
                };
                StringExtensions.empty = '';
                return StringExtensions;
            }());
            icelink.StringExtensions = StringExtensions;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var TimeoutTimer =  (function () {
                function TimeoutTimer(callback, state) {
                    this._timer = 0;
                    this._callback = callback;
                    this._state = state;
                    this._currentTimeout = 0;
                }
                TimeoutTimer.prototype.getTypeString = function () {
                    return '[fm.icelink.TimeoutTimer]';
                };
                TimeoutTimer.prototype.start = function (timeout) {
                    var _this = this;
                    if (this._timer) {
                        throw new fm.icelink.Exception('Timer is currently active.');
                    }
                    this._currentTimeout = timeout;
                    timeout = Math.max(0, timeout);
                    this._timer = setTimeout(function () {
                        if (_this._currentTimeout >= 0 && _this.stop() && _this._callback) {
                            _this._callback(_this._state);
                        }
                    }, timeout);
                };
                TimeoutTimer.prototype.stop = function () {
                    if (!this._timer) {
                        return false;
                    }
                    clearTimeout(this._timer);
                    this._timer = null;
                    return true;
                };
                return TimeoutTimer;
            }());
            icelink.TimeoutTimer = TimeoutTimer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var TimeSpan =  (function () {
                function TimeSpan() {
                    if (arguments.length == 1) {
                        var ticks = arguments[0];
                        var milliseconds = ticks / 10000;
                        this._milliseconds = (milliseconds % 1000);
                        milliseconds -= this._milliseconds;
                        var seconds = milliseconds / 1000;
                        this._seconds = (seconds % 60);
                        seconds -= this._seconds;
                        var minutes = seconds / 60;
                        this._minutes = (minutes % 60);
                        minutes -= this._minutes;
                        var hours = minutes / 60;
                        this._hours = hours;
                    }
                    else {
                        var hours = arguments[0];
                        var minutes = arguments[0];
                        var seconds = arguments[0];
                        this._hours = hours;
                        this._minutes = minutes;
                        this._seconds = seconds;
                    }
                }
                TimeSpan.prototype.getTotalSeconds = function () {
                    return ((this._hours * 3600) + (this._minutes * 60) + this._seconds);
                };
                TimeSpan.prototype.getTotalMilliseconds = function () {
                    return ((this._hours * 3600000) + (this._minutes * 60000) + (this._seconds * 1000) + this._milliseconds);
                };
                return TimeSpan;
            }());
            icelink.TimeSpan = TimeSpan;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Type =  (function () {
                function Type(typeString) {
                    this._typeString = typeString;
                }
                Type.prototype.getTypeString = function () {
                    return '[fm.icelink.Type]';
                };
                Type.prototype.getFullName = function () {
                    return this._typeString.substr(1, this._typeString.indexOf(']') - 1);
                };
                Type.prototype.getBaseType = function () {
                    var typeStrings = fm.icelink.StringExtensions.split(this._typeString, [','.charCodeAt(0)]);
                    if (typeStrings.length == 1) {
                        return new Type('[Object]');
                    }
                    return new Type(typeStrings[1]);
                };
                return Type;
            }());
            icelink.Type = Type;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Uri =  (function () {
                function Uri(uriString) {
                    this._uriString = uriString;
                }
                Uri.prototype.getTypeString = function () {
                    return '[fm.icelink.Uri]';
                };
                Uri.prototype.toString = function () {
                    return this._uriString;
                };
                Uri.escapeDataString = function (s) {
                    return encodeURIComponent(s);
                };
                return Uri;
            }());
            icelink.Uri = Uri;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketBase =  (function () {
                function WebSocketBase() {
                    fm.icelink.WebSocketBase.fmicelinkWebSocketBaseInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                WebSocketBase.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketBase]';
                };
                WebSocketBase.prototype.raiseCloseComplete = function (closeArgs, statusCode, reason) {
                    if (arguments.length == 3) {
                        if (((!fm.icelink.Global.equals(closeArgs, null)) && (!fm.icelink.Global.equals(closeArgs.getOnComplete(), null)))) {
                            var p = new fm.icelink.WebSocketCloseCompleteArgs();
                            p.setCloseArgs(closeArgs);
                            p.setStatusCode(statusCode);
                            p.setReason(reason);
                            closeArgs.getOnComplete()(p);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketBase.prototype.raiseOpenFailure = function (openArgs, statusCode, exception) {
                    if (arguments.length == 3) {
                        if (((!fm.icelink.Global.equals(openArgs, null)) && (!fm.icelink.Global.equals(openArgs.getOnFailure(), null)))) {
                            var p = new fm.icelink.WebSocketOpenFailureArgs();
                            p.setOpenArgs(openArgs);
                            p.setStatusCode(statusCode);
                            p.setException(exception);
                            openArgs.getOnFailure()(p);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketBase.prototype.raiseOpenSuccess = function (openArgs) {
                    if (arguments.length == 1) {
                        if (((!fm.icelink.Global.equals(openArgs, null)) && (!fm.icelink.Global.equals(openArgs.getOnSuccess(), null)))) {
                            var p = new fm.icelink.WebSocketOpenSuccessArgs();
                            p.setOpenArgs(openArgs);
                            openArgs.getOnSuccess()(p);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketBase.prototype.raiseReceive = function (openArgs, textMessage, binaryMessage) {
                    if (arguments.length == 3) {
                        if (((!fm.icelink.Global.equals(openArgs, null)) && (!fm.icelink.Global.equals(openArgs.getOnReceive(), null)))) {
                            var p = new fm.icelink.WebSocketReceiveArgs();
                            p.setOpenArgs(openArgs);
                            p.setTextMessage(textMessage);
                            p.setBinaryMessage(binaryMessage);
                            openArgs.getOnReceive()(p);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketBase.prototype.raiseStreamFailure = function (openArgs, statusCode, exception) {
                    if (arguments.length == 3) {
                        if (((!fm.icelink.Global.equals(openArgs, null)) && (!fm.icelink.Global.equals(openArgs.getOnStreamFailure(), null)))) {
                            var p = new fm.icelink.WebSocketStreamFailureArgs();
                            p.setOpenArgs(openArgs);
                            p.setStatusCode(statusCode);
                            p.setException(exception);
                            openArgs.getOnStreamFailure()(p);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketBase.fmicelinkWebSocketBaseInitialize = function () {
                    if (!fm.icelink.WebSocketBase.__fmicelinkWebSocketBaseInitialized && !fm.icelink.WebSocketBase.__fmicelinkWebSocketBaseInitializing) {
                        fm.icelink.WebSocketBase.__fmicelinkWebSocketBaseInitializing = true;
                        fm.icelink.WebSocketBase.fm_icelink_WebSocketBase___log = fm.icelink.Log.getLogger(new fm.icelink.Type('[fm.icelink.WebSocketBase]'));
                        fm.icelink.WebSocketBase.__fmicelinkWebSocketBaseInitialized = true;
                        fm.icelink.WebSocketBase.__fmicelinkWebSocketBaseInitializing = false;
                    }
                };
                WebSocketBase.__fmicelinkWebSocketBaseInitialized = false;
                WebSocketBase.__fmicelinkWebSocketBaseInitializing = false;
                return WebSocketBase;
            }());
            icelink.WebSocketBase = WebSocketBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocket =  (function (_super) {
                __extends(WebSocket, _super);
                function WebSocket(requestUrl, protocol) {
                    var _this = _super.call(this) || this;
                    _this.onOpen = function (e) {
                        _this.raiseOnResponseReceived();
                        _this._opening = false;
                        _this.raiseOpenSuccess(_this._openArgs);
                    };
                    _this.onError = function (e) {
                        if (_this._opening) {
                            _this._opening = false;
                            if (!_this._raisedOpenFailure) {
                                _this._raisedOpenFailure = true;
                                _this.raiseOpenFailure(_this._openArgs, fm.icelink.WebSocketStatusCode.Abnormal, new fm.icelink.Exception('WebSocket error.'));
                            }
                        }
                        else if (!_this._closing) {
                            if (!_this._raisedStreamFailure) {
                                _this._raisedStreamFailure = true;
                                _this.raiseStreamFailure(_this._openArgs, fm.icelink.WebSocketStatusCode.Abnormal, new fm.icelink.Exception('WebSocket error.'));
                            }
                        }
                    };
                    _this.onClose = function (e) {
                        _this.processOnClose(e.code, e.reason);
                    };
                    _this.onMessage = function (e) {
                        if (_this._timer) {
                            window.clearTimeout(_this._timer);
                        }
                        _this._sendArgs = null;
                        var binaryMessage = null;
                        var textMessage = null;
                        if (!WebSocket.getDisableBinary() && e.data instanceof ArrayBuffer) {
                            binaryMessage = new Uint8Array(e.data);
                        }
                        else {
                            textMessage = e.data;
                        }
                        return _this.raiseReceive(_this._openArgs, textMessage, binaryMessage);
                    };
                    requestUrl = fm.icelink.Util.absolutizeUrl(requestUrl);
                    requestUrl = requestUrl.replace('https://', 'wss://');
                    requestUrl = requestUrl.replace('http://', 'ws://');
                    _this._requestUrl = requestUrl;
                    _this._protocol = protocol || null;
                    _this._webSocket = null;
                    _this._onRequestCreated = null;
                    _this._onResponseReceived = null;
                    _this._opening = false;
                    _this._closing = false;
                    _this._aborting = false;
                    _this._openArgs = null;
                    _this._sendArgs = null;
                    _this._timer = 0;
                    _this._raisedStreamFailure = false;
                    _this._raisedOpenFailure = false;
                    return _this;
                }
                WebSocket.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocket]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebSocket.getExists = function () {
                    return true;
                };
                WebSocket.setDisableBinary = function (disableBinary) {
                    WebSocket._disableBinary = disableBinary;
                };
                WebSocket.getDisableBinary = function () {
                    if (typeof Uint8Array === 'undefined') {
                        return true;
                    }
                    return WebSocket._disableBinary;
                };
                WebSocket.prototype.getSecure = function () {
                    return (this._requestUrl.indexOf('wss://') === 0);
                };
                WebSocket.prototype.getBufferedAmount = function () {
                    if (!this._webSocket) {
                        return 0;
                    }
                    return this._webSocket.bufferedAmount;
                };
                WebSocket.prototype.getIsOpen = function () {
                    if (!this._webSocket) {
                        return false;
                    }
                    return (this._webSocket.readyState === 1);
                };
                WebSocket.prototype.open = function (args) {
                    var url = this._requestUrl;
                    this._openArgs = args;
                    this._onRequestCreated = args.getOnRequestCreated();
                    this._onResponseReceived = args.getOnResponseReceived();
                    this.raiseOnRequestCreated();
                    var headers = args.getHeaders();
                    var headersHash = {};
                    if (headers) {
                        headersHash = headers.toHash();
                    }
                    if (WebSocket.getDisableBinary()) {
                        headersHash['X-FM-DisableBinary'] = 'true';
                    }
                    url = fm.icelink.HttpTransfer.addQueryToUrl(url, 'headers', fm.icelink.Json.serialize(headersHash));
                    if ('WebSocket' in window) {
                        this._webSocket = (this._protocol ? new window.WebSocket(url, this._protocol) : new window.WebSocket(url));
                    }
                    if (!this._webSocket) {
                        this.raiseOpenFailure(args, fm.icelink.WebSocketStatusCode.NoStatus, new fm.icelink.Exception('Could not create WebSocket.'));
                        return;
                    }
                    if (!WebSocket.getDisableBinary()) {
                        try {
                            this._webSocket.binaryType = 'arraybuffer';
                        }
                        catch (error) {
                            WebSocket.setDisableBinary(true);
                        }
                    }
                    this._opening = true;
                    this._closing = false;
                    this._raisedStreamFailure = false;
                    this._raisedOpenFailure = false;
                    this._webSocket.onopen = this.onOpen;
                    this._webSocket.onerror = this.onError;
                    this._webSocket.onclose = this.onClose;
                    this._webSocket.onmessage = this.onMessage;
                };
                WebSocket.prototype.processOnClose = function (code, reason) {
                    var reasonText = '';
                    if (!fm.icelink.StringExtensions.isNullOrEmpty(reason)) {
                        reasonText = ' (' + reason + ')';
                    }
                    if (this._opening) {
                        this._opening = false;
                        if (!this._raisedOpenFailure) {
                            this._raisedOpenFailure = true;
                            this.raiseOpenFailure(this._openArgs, code, new fm.icelink.Exception('Could not open WebSocket.' + reasonText));
                        }
                    }
                    else if (this._aborting) {
                        if (!this._raisedStreamFailure) {
                            this._raisedStreamFailure = true;
                            this.raiseStreamFailure(this._openArgs, code, new fm.icelink.Exception('WebSocket request timed out.' + reasonText));
                        }
                    }
                    else if (!this._closing) {
                        if (!this._raisedStreamFailure) {
                            this._raisedStreamFailure = true;
                            this.raiseStreamFailure(this._openArgs, code, new fm.icelink.Exception('WebSocket closed.' + reasonText));
                        }
                    }
                };
                WebSocket.prototype.send = function (args) {
                    var _this = this;
                    if (!this._webSocket) {
                        return;
                    }
                    this._sendArgs = args;
                    if (this._timer) {
                        window.clearTimeout(this._timer);
                    }
                    var timeout = args.getTimeout();
                    if (timeout > 0) {
                        this._timer = window.setTimeout(function () {
                            if (!_this._webSocket) {
                                return;
                            }
                            _this._aborting = true;
                            _this._webSocket.close();
                            _this.processOnClose(4000, 'Timeout');
                        }, timeout);
                    }
                    var sentBinary = false;
                    var binary = args.getBinaryMessage();
                    if (!WebSocket.getDisableBinary() && binary) {
                        try {
                            this._webSocket.send(binary.buffer);
                            sentBinary = true;
                        }
                        catch (error) {
                            WebSocket.setDisableBinary(true);
                        }
                    }
                    if (!sentBinary) {
                        return this._webSocket.send(args.getTextMessage());
                    }
                };
                WebSocket.prototype.close = function (args) {
                    if (typeof args === 'undefined') {
                        this.close(new fm.icelink.WebSocketCloseArgs());
                        return;
                    }
                    var code = args.getStatusCode() || fm.icelink.WebSocketStatusCode.Normal;
                    var reason = args.getReason() || '';
                    var e = new fm.icelink.WebSocketCloseCompleteArgs();
                    e.setStatusCode(code);
                    e.setReason(reason);
                    window.clearTimeout(this._timer);
                    if (this._webSocket) {
                        this._closing = true;
                        this._webSocket.close(code, reason);
                        this._webSocket = null;
                    }
                    this.raiseCloseComplete(args, code, reason);
                };
                WebSocket.prototype.raiseOnRequestCreated = function () {
                    if (this._onRequestCreated) {
                        var args = new fm.icelink.HttpRequestCreatedArgs();
                        args.setSender(this._openArgs.getSender());
                        args.setRequest(null);
                        this._onRequestCreated(args);
                    }
                };
                WebSocket.prototype.raiseOnResponseReceived = function () {
                    if (this._onResponseReceived) {
                        var args = new fm.icelink.HttpResponseReceivedArgs();
                        args.setSender(this._openArgs.getSender());
                        args.setResponse(null);
                        this._onResponseReceived(args);
                    }
                };
                WebSocket._disableBinary = false;
                return WebSocket;
            }(fm.icelink.WebSocketBase));
            icelink.WebSocket = WebSocket;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (CryptoLibrary) {
                CryptoLibrary[CryptoLibrary["Default"] = 1] = "Default";
            })(icelink.CryptoLibrary || (icelink.CryptoLibrary = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (AddressType) {
                AddressType[AddressType["IPv4"] = 1] = "IPv4";
                AddressType[AddressType["IPv6"] = 2] = "IPv6";
                AddressType[AddressType["Unknown"] = 3] = "Unknown";
            })(icelink.AddressType || (icelink.AddressType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (JsonCheckerMode) {
                JsonCheckerMode[JsonCheckerMode["Array"] = 1] = "Array";
                JsonCheckerMode[JsonCheckerMode["Done"] = 2] = "Done";
                JsonCheckerMode[JsonCheckerMode["Key"] = 3] = "Key";
                JsonCheckerMode[JsonCheckerMode["Object"] = 4] = "Object";
                JsonCheckerMode[JsonCheckerMode["String"] = 5] = "String";
            })(icelink.JsonCheckerMode || (icelink.JsonCheckerMode = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (OperatingSystem) {
                OperatingSystem[OperatingSystem["Unknown"] = 1] = "Unknown";
                OperatingSystem[OperatingSystem["Windows"] = 2] = "Windows";
                OperatingSystem[OperatingSystem["Android"] = 3] = "Android";
                OperatingSystem[OperatingSystem["MacOS"] = 4] = "MacOS";
                OperatingSystem[OperatingSystem["IOS"] = 5] = "IOS";
                OperatingSystem[OperatingSystem["Linux"] = 6] = "Linux";
                OperatingSystem[OperatingSystem["TvOS"] = 7] = "TvOS";
                OperatingSystem[OperatingSystem["WatchOS"] = 8] = "WatchOS";
            })(icelink.OperatingSystem || (icelink.OperatingSystem = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (Architecture) {
                Architecture[Architecture["Unknown"] = 1] = "Unknown";
                Architecture[Architecture["X86"] = 2] = "X86";
                Architecture[Architecture["X64"] = 3] = "X64";
                Architecture[Architecture["Armv7"] = 4] = "Armv7";
                Architecture[Architecture["Armv8"] = 5] = "Armv8";
                Architecture[Architecture["Arm64"] = 6] = "Arm64";
                Architecture[Architecture["Mips"] = 7] = "Mips";
                Architecture[Architecture["Mips64"] = 8] = "Mips64";
            })(icelink.Architecture || (icelink.Architecture = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (ProtocolType) {
                ProtocolType[ProtocolType["Udp"] = 1] = "Udp";
                ProtocolType[ProtocolType["Tcp"] = 2] = "Tcp";
                ProtocolType[ProtocolType["Tls"] = 3] = "Tls";
                ProtocolType[ProtocolType["Unknown"] = 4] = "Unknown";
            })(icelink.ProtocolType || (icelink.ProtocolType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (SourceLanguage) {
                SourceLanguage[SourceLanguage["CSharp"] = 1] = "CSharp";
                SourceLanguage[SourceLanguage["Java"] = 2] = "Java";
                SourceLanguage[SourceLanguage["ObjectiveC"] = 3] = "ObjectiveC";
                SourceLanguage[SourceLanguage["TypeScript"] = 4] = "TypeScript";
            })(icelink.SourceLanguage || (icelink.SourceLanguage = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (StringType) {
                StringType[StringType["None"] = 1] = "None";
                StringType[StringType["Single"] = 2] = "Single";
                StringType[StringType["Double"] = 3] = "Double";
            })(icelink.StringType || (icelink.StringType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (CompareResult) {
                CompareResult[CompareResult["Equal"] = 1] = "Equal";
                CompareResult[CompareResult["Negative"] = 2] = "Negative";
                CompareResult[CompareResult["Positive"] = 3] = "Positive";
            })(icelink.CompareResult || (icelink.CompareResult = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (HashType) {
                HashType[HashType["Md5"] = 1] = "Md5";
                HashType[HashType["Sha1"] = 2] = "Sha1";
                HashType[HashType["Sha256"] = 3] = "Sha256";
            })(icelink.HashType || (icelink.HashType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (MacType) {
                MacType[MacType["HmacMd5"] = 1] = "HmacMd5";
                MacType[MacType["HmacSha1"] = 2] = "HmacSha1";
                MacType[MacType["HmacSha256"] = 3] = "HmacSha256";
            })(icelink.MacType || (icelink.MacType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (ErrorCode) {
                ErrorCode[ErrorCode["SocketSendError"] = 100000] = "SocketSendError";
                ErrorCode[ErrorCode["SocketReceiveError"] = 100001] = "SocketReceiveError";
                ErrorCode[ErrorCode["SocketClosed"] = 100002] = "SocketClosed";
                ErrorCode[ErrorCode["SocketSendBufferFull"] = 100003] = "SocketSendBufferFull";
                ErrorCode[ErrorCode["IPProtocolMismatch"] = 100004] = "IPProtocolMismatch";
                ErrorCode[ErrorCode["PacketTooLarge"] = 100005] = "PacketTooLarge";
                ErrorCode[ErrorCode["NetworkUnreachable"] = 100006] = "NetworkUnreachable";
                ErrorCode[ErrorCode["StunTryAlternate"] = 114000] = "StunTryAlternate";
                ErrorCode[ErrorCode["StunBadRequest"] = 114001] = "StunBadRequest";
                ErrorCode[ErrorCode["StunUnauthorized"] = 114002] = "StunUnauthorized";
                ErrorCode[ErrorCode["StunTurnForbidden"] = 114003] = "StunTurnForbidden";
                ErrorCode[ErrorCode["StunTurnMobilityForbidden"] = 114004] = "StunTurnMobilityForbidden";
                ErrorCode[ErrorCode["StunUnknownAttribute"] = 114005] = "StunUnknownAttribute";
                ErrorCode[ErrorCode["StunStaleCredentials"] = 114006] = "StunStaleCredentials";
                ErrorCode[ErrorCode["StunIntegrityCheckFailure"] = 114007] = "StunIntegrityCheckFailure";
                ErrorCode[ErrorCode["StunMissingUsername"] = 114008] = "StunMissingUsername";
                ErrorCode[ErrorCode["StunTurnAllocationMismatch"] = 114009] = "StunTurnAllocationMismatch";
                ErrorCode[ErrorCode["StunStaleNonce"] = 114010] = "StunStaleNonce";
                ErrorCode[ErrorCode["StunAddressFamilyNotSupported"] = 114011] = "StunAddressFamilyNotSupported";
                ErrorCode[ErrorCode["StunTurnWrongCredentials"] = 114012] = "StunTurnWrongCredentials";
                ErrorCode[ErrorCode["StunTurnUnsupportedTransportProtocol"] = 114013] = "StunTurnUnsupportedTransportProtocol";
                ErrorCode[ErrorCode["StunTurnPeerAddressFamilyMismatch"] = 114014] = "StunTurnPeerAddressFamilyMismatch";
                ErrorCode[ErrorCode["StunTurnConnectionAlreadyExists"] = 114015] = "StunTurnConnectionAlreadyExists";
                ErrorCode[ErrorCode["StunTurnConnectionTimeoutOrFailure"] = 114016] = "StunTurnConnectionTimeoutOrFailure";
                ErrorCode[ErrorCode["StunTurnAllocationQuotaReached"] = 114017] = "StunTurnAllocationQuotaReached";
                ErrorCode[ErrorCode["StunIceRoleConflict"] = 114018] = "StunIceRoleConflict";
                ErrorCode[ErrorCode["StunServerError"] = 114019] = "StunServerError";
                ErrorCode[ErrorCode["StunTurnInsufficientCapacity"] = 114020] = "StunTurnInsufficientCapacity";
                ErrorCode[ErrorCode["StunInvalidResponseType"] = 114021] = "StunInvalidResponseType";
                ErrorCode[ErrorCode["StunInvalidErrorCode"] = 114022] = "StunInvalidErrorCode";
                ErrorCode[ErrorCode["StunInvalidTransactionId"] = 114023] = "StunInvalidTransactionId";
                ErrorCode[ErrorCode["StunUnknownStunErrorCode"] = 114024] = "StunUnknownStunErrorCode";
                ErrorCode[ErrorCode["StunInvalidMessageIntegrity"] = 114025] = "StunInvalidMessageIntegrity";
                ErrorCode[ErrorCode["SocketIPError"] = 115001] = "SocketIPError";
                ErrorCode[ErrorCode["IceLocalRelayedDatagramCandidateError"] = 101000] = "IceLocalRelayedDatagramCandidateError";
                ErrorCode[ErrorCode["IceLocalServerReflexiveCandidateError"] = 101001] = "IceLocalServerReflexiveCandidateError";
                ErrorCode[ErrorCode["SocketManagerInvalidState"] = 101002] = "SocketManagerInvalidState";
                ErrorCode[ErrorCode["IceStartError"] = 102000] = "IceStartError";
                ErrorCode[ErrorCode["IceUnsuitableSocketAssignment"] = 102001] = "IceUnsuitableSocketAssignment";
                ErrorCode[ErrorCode["IceAllPortsInUse"] = 102002] = "IceAllPortsInUse";
                ErrorCode[ErrorCode["IceLocalAddressUnavailable"] = 102003] = "IceLocalAddressUnavailable";
                ErrorCode[ErrorCode["IceGenericGathererError"] = 102004] = "IceGenericGathererError";
                ErrorCode[ErrorCode["IceRefreshTimeout"] = 103000] = "IceRefreshTimeout";
                ErrorCode[ErrorCode["IceRefreshError"] = 103001] = "IceRefreshError";
                ErrorCode[ErrorCode["IceCreatePermissionTimeout"] = 104000] = "IceCreatePermissionTimeout";
                ErrorCode[ErrorCode["IceCreatePermissionError"] = 104001] = "IceCreatePermissionError";
                ErrorCode[ErrorCode["IceConnectivityCheckFailed"] = 104002] = "IceConnectivityCheckFailed";
                ErrorCode[ErrorCode["IceSendError"] = 105000] = "IceSendError";
                ErrorCode[ErrorCode["IcePeerReflexiveError"] = 105001] = "IcePeerReflexiveError";
                ErrorCode[ErrorCode["IncompatibleIceSetup"] = 105002] = "IncompatibleIceSetup";
                ErrorCode[ErrorCode["DtlsInternalError"] = 106000] = "DtlsInternalError";
                ErrorCode[ErrorCode["DtlsKeyExchangeFailed"] = 106001] = "DtlsKeyExchangeFailed";
                ErrorCode[ErrorCode["DtlsNotReady"] = 106002] = "DtlsNotReady";
                ErrorCode[ErrorCode["SctpNoPayloadData"] = 107000] = "SctpNoPayloadData";
                ErrorCode[ErrorCode["SctpUnsupportedStream"] = 107001] = "SctpUnsupportedStream";
                ErrorCode[ErrorCode["SctpInvalidState"] = 107002] = "SctpInvalidState";
                ErrorCode[ErrorCode["SctpInternalError"] = 107003] = "SctpInternalError";
                ErrorCode[ErrorCode["MediaTransportFailed"] = 108000] = "MediaTransportFailed";
                ErrorCode[ErrorCode["ReliableDataChannelOpenError"] = 109000] = "ReliableDataChannelOpenError";
                ErrorCode[ErrorCode["ReliableDataChannelSendError"] = 109001] = "ReliableDataChannelSendError";
                ErrorCode[ErrorCode["ConnectionInvalidArchitecture"] = 110000] = "ConnectionInvalidArchitecture";
                ErrorCode[ErrorCode["ConnectionInternalError"] = 110001] = "ConnectionInternalError";
                ErrorCode[ErrorCode["ConnectionTransportStartError"] = 110002] = "ConnectionTransportStartError";
                ErrorCode[ErrorCode["ConnectionTransportClosed"] = 110003] = "ConnectionTransportClosed";
                ErrorCode[ErrorCode["ConnectionDeadStream"] = 110004] = "ConnectionDeadStream";
                ErrorCode[ErrorCode["ConnectionNotEstablished"] = 110005] = "ConnectionNotEstablished";
                ErrorCode[ErrorCode["ConnectionRemoteFailure"] = 110006] = "ConnectionRemoteFailure";
                ErrorCode[ErrorCode["ConnectionSimulcastNotSupported"] = 110007] = "ConnectionSimulcastNotSupported";
                ErrorCode[ErrorCode["StreamDisabled"] = 111000] = "StreamDisabled";
                ErrorCode[ErrorCode["StreamEncryptionMismatch"] = 111001] = "StreamEncryptionMismatch";
                ErrorCode[ErrorCode["StreamDirectionMismatch"] = 111002] = "StreamDirectionMismatch";
                ErrorCode[ErrorCode["DataStreamDirectionCannotBeChanged"] = 111003] = "DataStreamDirectionCannotBeChanged";
                ErrorCode[ErrorCode["InvalidStreamDirectionChange"] = 111004] = "InvalidStreamDirectionChange";
                ErrorCode[ErrorCode["LocalDescriptionError"] = 112000] = "LocalDescriptionError";
                ErrorCode[ErrorCode["RemoteDescriptionError"] = 112001] = "RemoteDescriptionError";
                ErrorCode[ErrorCode["IceLocalRelayedStreamCandidateError"] = 113000] = "IceLocalRelayedStreamCandidateError";
                ErrorCode[ErrorCode["IceInvalidServerAssignmentError"] = 113001] = "IceInvalidServerAssignmentError";
            })(icelink.ErrorCode || (icelink.ErrorCode = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (HttpMethod) {
                HttpMethod[HttpMethod["Get"] = 1] = "Get";
                HttpMethod[HttpMethod["Head"] = 2] = "Head";
                HttpMethod[HttpMethod["Post"] = 3] = "Post";
                HttpMethod[HttpMethod["Put"] = 4] = "Put";
                HttpMethod[HttpMethod["Patch"] = 5] = "Patch";
                HttpMethod[HttpMethod["Delete"] = 6] = "Delete";
            })(icelink.HttpMethod || (icelink.HttpMethod = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (LogLevel) {
                LogLevel[LogLevel["Verbose"] = 1] = "Verbose";
                LogLevel[LogLevel["Debug"] = 2] = "Debug";
                LogLevel[LogLevel["Info"] = 3] = "Info";
                LogLevel[LogLevel["Warn"] = 4] = "Warn";
                LogLevel[LogLevel["Error"] = 5] = "Error";
                LogLevel[LogLevel["Fatal"] = 6] = "Fatal";
                LogLevel[LogLevel["None"] = 7] = "None";
            })(icelink.LogLevel || (icelink.LogLevel = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (FutureState) {
                FutureState[FutureState["Pending"] = 1] = "Pending";
                FutureState[FutureState["Resolved"] = 2] = "Resolved";
                FutureState[FutureState["Rejected"] = 3] = "Rejected";
            })(icelink.FutureState || (icelink.FutureState = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (WebSocketStatusCode) {
                WebSocketStatusCode[WebSocketStatusCode["Normal"] = 1000] = "Normal";
                WebSocketStatusCode[WebSocketStatusCode["GoingAway"] = 1001] = "GoingAway";
                WebSocketStatusCode[WebSocketStatusCode["ProtocolError"] = 1002] = "ProtocolError";
                WebSocketStatusCode[WebSocketStatusCode["InvalidType"] = 1003] = "InvalidType";
                WebSocketStatusCode[WebSocketStatusCode["NoStatus"] = 1005] = "NoStatus";
                WebSocketStatusCode[WebSocketStatusCode["Abnormal"] = 1006] = "Abnormal";
                WebSocketStatusCode[WebSocketStatusCode["InvalidData"] = 1007] = "InvalidData";
                WebSocketStatusCode[WebSocketStatusCode["PolicyViolation"] = 1008] = "PolicyViolation";
                WebSocketStatusCode[WebSocketStatusCode["MessageTooLarge"] = 1009] = "MessageTooLarge";
                WebSocketStatusCode[WebSocketStatusCode["UnsupportedExtension"] = 1010] = "UnsupportedExtension";
                WebSocketStatusCode[WebSocketStatusCode["UnexpectedCondition"] = 1011] = "UnexpectedCondition";
                WebSocketStatusCode[WebSocketStatusCode["SecureHandshakeFailure"] = 1015] = "SecureHandshakeFailure";
            })(icelink.WebSocketStatusCode || (icelink.WebSocketStatusCode = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (CcmTmmbnPolicy) {
                CcmTmmbnPolicy[CcmTmmbnPolicy["Disabled"] = 1] = "Disabled";
                CcmTmmbnPolicy[CcmTmmbnPolicy["Negotiated"] = 2] = "Negotiated";
            })(icelink.CcmTmmbnPolicy || (icelink.CcmTmmbnPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (CcmTmmbrPolicy) {
                CcmTmmbrPolicy[CcmTmmbrPolicy["Disabled"] = 1] = "Disabled";
                CcmTmmbrPolicy[CcmTmmbrPolicy["Negotiated"] = 2] = "Negotiated";
            })(icelink.CcmTmmbrPolicy || (icelink.CcmTmmbrPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (VideoType) {
                VideoType[VideoType["Unknown"] = 1] = "Unknown";
                VideoType[VideoType["Camera"] = 2] = "Camera";
                VideoType[VideoType["Screen"] = 3] = "Screen";
            })(icelink.VideoType || (icelink.VideoType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (VideoDegradationPreference) {
                VideoDegradationPreference[VideoDegradationPreference["Automatic"] = 1] = "Automatic";
                VideoDegradationPreference[VideoDegradationPreference["Balanced"] = 2] = "Balanced";
                VideoDegradationPreference[VideoDegradationPreference["FrameRate"] = 3] = "FrameRate";
                VideoDegradationPreference[VideoDegradationPreference["Resolution"] = 4] = "Resolution";
            })(icelink.VideoDegradationPreference || (icelink.VideoDegradationPreference = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (CcmLrrPolicy) {
                CcmLrrPolicy[CcmLrrPolicy["Disabled"] = 1] = "Disabled";
                CcmLrrPolicy[CcmLrrPolicy["Negotiated"] = 2] = "Negotiated";
            })(icelink.CcmLrrPolicy || (icelink.CcmLrrPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (CcmFirPolicy) {
                CcmFirPolicy[CcmFirPolicy["Disabled"] = 1] = "Disabled";
                CcmFirPolicy[CcmFirPolicy["Negotiated"] = 2] = "Negotiated";
            })(icelink.CcmFirPolicy || (icelink.CcmFirPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (NackPliPolicy) {
                NackPliPolicy[NackPliPolicy["Disabled"] = 1] = "Disabled";
                NackPliPolicy[NackPliPolicy["Negotiated"] = 2] = "Negotiated";
            })(icelink.NackPliPolicy || (icelink.NackPliPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (SimulcastMode) {
                SimulcastMode[SimulcastMode["Disabled"] = 1] = "Disabled";
                SimulcastMode[SimulcastMode["RtpStreamId"] = 3] = "RtpStreamId";
            })(icelink.SimulcastMode || (icelink.SimulcastMode = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (BundlePolicy) {
                BundlePolicy[BundlePolicy["Balanced"] = 1] = "Balanced";
                BundlePolicy[BundlePolicy["MaxCompatibility"] = 2] = "MaxCompatibility";
                BundlePolicy[BundlePolicy["MaxBundle"] = 3] = "MaxBundle";
                BundlePolicy[BundlePolicy["Disabled"] = 4] = "Disabled";
            })(icelink.BundlePolicy || (icelink.BundlePolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (EncryptionPolicy) {
                EncryptionPolicy[EncryptionPolicy["Required"] = 1] = "Required";
                EncryptionPolicy[EncryptionPolicy["Negotiated"] = 2] = "Negotiated";
                EncryptionPolicy[EncryptionPolicy["Disabled"] = 3] = "Disabled";
            })(icelink.EncryptionPolicy || (icelink.EncryptionPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (IceConnectionState) {
                IceConnectionState[IceConnectionState["New"] = 1] = "New";
                IceConnectionState[IceConnectionState["Checking"] = 2] = "Checking";
                IceConnectionState[IceConnectionState["Connected"] = 3] = "Connected";
                IceConnectionState[IceConnectionState["Completed"] = 4] = "Completed";
                IceConnectionState[IceConnectionState["Failed"] = 5] = "Failed";
                IceConnectionState[IceConnectionState["Disconnected"] = 6] = "Disconnected";
                IceConnectionState[IceConnectionState["Closed"] = 7] = "Closed";
            })(icelink.IceConnectionState || (icelink.IceConnectionState = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (IceGatheringState) {
                IceGatheringState[IceGatheringState["New"] = 1] = "New";
                IceGatheringState[IceGatheringState["Gathering"] = 2] = "Gathering";
                IceGatheringState[IceGatheringState["Complete"] = 3] = "Complete";
                IceGatheringState[IceGatheringState["Closing"] = 4] = "Closing";
                IceGatheringState[IceGatheringState["Closed"] = 5] = "Closed";
                IceGatheringState[IceGatheringState["Failed"] = 6] = "Failed";
            })(icelink.IceGatheringState || (icelink.IceGatheringState = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (IceGatherPolicy) {
                IceGatherPolicy[IceGatherPolicy["All"] = 1] = "All";
                IceGatherPolicy[IceGatherPolicy["NoHost"] = 2] = "NoHost";
                IceGatherPolicy[IceGatherPolicy["Relay"] = 3] = "Relay";
            })(icelink.IceGatherPolicy || (icelink.IceGatherPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (LayoutAlignment) {
                LayoutAlignment[LayoutAlignment["TopLeft"] = 1] = "TopLeft";
                LayoutAlignment[LayoutAlignment["Top"] = 2] = "Top";
                LayoutAlignment[LayoutAlignment["TopRight"] = 3] = "TopRight";
                LayoutAlignment[LayoutAlignment["Left"] = 4] = "Left";
                LayoutAlignment[LayoutAlignment["Center"] = 5] = "Center";
                LayoutAlignment[LayoutAlignment["Right"] = 6] = "Right";
                LayoutAlignment[LayoutAlignment["BottomLeft"] = 7] = "BottomLeft";
                LayoutAlignment[LayoutAlignment["Bottom"] = 8] = "Bottom";
                LayoutAlignment[LayoutAlignment["BottomRight"] = 9] = "BottomRight";
            })(icelink.LayoutAlignment || (icelink.LayoutAlignment = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (LayoutDirection) {
                LayoutDirection[LayoutDirection["Horizontal"] = 1] = "Horizontal";
                LayoutDirection[LayoutDirection["Vertical"] = 2] = "Vertical";
            })(icelink.LayoutDirection || (icelink.LayoutDirection = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (LayoutMode) {
                LayoutMode[LayoutMode["FloatLocal"] = 1] = "FloatLocal";
                LayoutMode[LayoutMode["FloatRemote"] = 2] = "FloatRemote";
                LayoutMode[LayoutMode["Block"] = 3] = "Block";
                LayoutMode[LayoutMode["Inline"] = 4] = "Inline";
                LayoutMode[LayoutMode["InlineOverflow"] = 5] = "InlineOverflow";
            })(icelink.LayoutMode || (icelink.LayoutMode = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (LayoutOrigin) {
                LayoutOrigin[LayoutOrigin["TopLeft"] = 1] = "TopLeft";
                LayoutOrigin[LayoutOrigin["TopRight"] = 2] = "TopRight";
                LayoutOrigin[LayoutOrigin["BottomRight"] = 3] = "BottomRight";
                LayoutOrigin[LayoutOrigin["BottomLeft"] = 4] = "BottomLeft";
            })(icelink.LayoutOrigin || (icelink.LayoutOrigin = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (LocalMediaState) {
                LocalMediaState[LocalMediaState["New"] = 1] = "New";
                LocalMediaState[LocalMediaState["Starting"] = 2] = "Starting";
                LocalMediaState[LocalMediaState["Started"] = 3] = "Started";
                LocalMediaState[LocalMediaState["Stopping"] = 4] = "Stopping";
                LocalMediaState[LocalMediaState["Stopped"] = 5] = "Stopped";
                LocalMediaState[LocalMediaState["Destroying"] = 6] = "Destroying";
                LocalMediaState[LocalMediaState["Destroyed"] = 7] = "Destroyed";
            })(icelink.LocalMediaState || (icelink.LocalMediaState = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (NackPolicy) {
                NackPolicy[NackPolicy["Disabled"] = 1] = "Disabled";
                NackPolicy[NackPolicy["Negotiated"] = 2] = "Negotiated";
            })(icelink.NackPolicy || (icelink.NackPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (RedFecPolicy) {
                RedFecPolicy[RedFecPolicy["Disabled"] = 1] = "Disabled";
                RedFecPolicy[RedFecPolicy["Negotiated"] = 2] = "Negotiated";
            })(icelink.RedFecPolicy || (icelink.RedFecPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (RembPolicy) {
                RembPolicy[RembPolicy["Disabled"] = 1] = "Disabled";
                RembPolicy[RembPolicy["Negotiated"] = 2] = "Negotiated";
            })(icelink.RembPolicy || (icelink.RembPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (rtp) {
                (function (HeaderExtensionForm) {
                    HeaderExtensionForm[HeaderExtensionForm["OneByte"] = 1] = "OneByte";
                    HeaderExtensionForm[HeaderExtensionForm["TwoByte"] = 2] = "TwoByte";
                })(rtp.HeaderExtensionForm || (rtp.HeaderExtensionForm = {}));
            })(icelink.rtp || (icelink.rtp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (SdesPolicy) {
                SdesPolicy[SdesPolicy["Negotiated"] = 2] = "Negotiated";
                SdesPolicy[SdesPolicy["Disabled"] = 3] = "Disabled";
            })(icelink.SdesPolicy || (icelink.SdesPolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (SignallingState) {
                SignallingState[SignallingState["New"] = 1] = "New";
                SignallingState[SignallingState["HaveLocalOffer"] = 2] = "HaveLocalOffer";
                SignallingState[SignallingState["HaveRemoteOffer"] = 3] = "HaveRemoteOffer";
                SignallingState[SignallingState["Stable"] = 4] = "Stable";
            })(icelink.SignallingState || (icelink.SignallingState = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (TransportType) {
                TransportType[TransportType["Gatherer"] = 1] = "Gatherer";
                TransportType[TransportType["IceTransport"] = 2] = "IceTransport";
                TransportType[TransportType["DtlsTransport"] = 3] = "DtlsTransport";
                TransportType[TransportType["SctpTransport"] = 4] = "SctpTransport";
                TransportType[TransportType["ReliableDataTransport"] = 5] = "ReliableDataTransport";
                TransportType[TransportType["SrtpTransport"] = 6] = "SrtpTransport";
                TransportType[TransportType["Unset"] = 7] = "Unset";
                TransportType[TransportType["MediaTransport"] = 8] = "MediaTransport";
            })(icelink.TransportType || (icelink.TransportType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (TrickleIcePolicy) {
                TrickleIcePolicy[TrickleIcePolicy["NotSupported"] = 1] = "NotSupported";
                TrickleIcePolicy[TrickleIcePolicy["FullTrickle"] = 2] = "FullTrickle";
                TrickleIcePolicy[TrickleIcePolicy["HalfTrickle"] = 3] = "HalfTrickle";
            })(icelink.TrickleIcePolicy || (icelink.TrickleIcePolicy = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (CandidatePairState) {
                CandidatePairState[CandidatePairState["New"] = 1] = "New";
                CandidatePairState[CandidatePairState["Waiting"] = 2] = "Waiting";
                CandidatePairState[CandidatePairState["InProgress"] = 3] = "InProgress";
                CandidatePairState[CandidatePairState["Succeeded"] = 4] = "Succeeded";
                CandidatePairState[CandidatePairState["Failed"] = 5] = "Failed";
                CandidatePairState[CandidatePairState["Closed"] = 6] = "Closed";
                CandidatePairState[CandidatePairState["ConnectivityLost"] = 7] = "ConnectivityLost";
            })(icelink.CandidatePairState || (icelink.CandidatePairState = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (CandidateType) {
                CandidateType[CandidateType["Host"] = 1] = "Host";
                CandidateType[CandidateType["ServerReflexive"] = 2] = "ServerReflexive";
                CandidateType[CandidateType["Relayed"] = 3] = "Relayed";
                CandidateType[CandidateType["PeerReflexive"] = 4] = "PeerReflexive";
                CandidateType[CandidateType["Unknown"] = 5] = "Unknown";
            })(icelink.CandidateType || (icelink.CandidateType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (CodecType) {
                CodecType[CodecType["Encode"] = 1] = "Encode";
                CodecType[CodecType["Decode"] = 2] = "Decode";
            })(icelink.CodecType || (icelink.CodecType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (ConnectionState) {
                ConnectionState[ConnectionState["New"] = 1] = "New";
                ConnectionState[ConnectionState["Initializing"] = 2] = "Initializing";
                ConnectionState[ConnectionState["Connecting"] = 3] = "Connecting";
                ConnectionState[ConnectionState["Connected"] = 4] = "Connected";
                ConnectionState[ConnectionState["Failing"] = 5] = "Failing";
                ConnectionState[ConnectionState["Failed"] = 6] = "Failed";
                ConnectionState[ConnectionState["Closing"] = 7] = "Closing";
                ConnectionState[ConnectionState["Closed"] = 8] = "Closed";
            })(icelink.ConnectionState || (icelink.ConnectionState = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (DataChannelState) {
                DataChannelState[DataChannelState["New"] = 1] = "New";
                DataChannelState[DataChannelState["Connecting"] = 2] = "Connecting";
                DataChannelState[DataChannelState["Connected"] = 3] = "Connected";
                DataChannelState[DataChannelState["Closing"] = 4] = "Closing";
                DataChannelState[DataChannelState["Closed"] = 5] = "Closed";
                DataChannelState[DataChannelState["Failed"] = 6] = "Failed";
            })(icelink.DataChannelState || (icelink.DataChannelState = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (EncryptionMode) {
                EncryptionMode[EncryptionMode["Null"] = 1] = "Null";
                EncryptionMode[EncryptionMode["Aes128Strong"] = 2] = "Aes128Strong";
                EncryptionMode[EncryptionMode["Aes128Weak"] = 3] = "Aes128Weak";
                EncryptionMode[EncryptionMode["NullStrong"] = 4] = "NullStrong";
                EncryptionMode[EncryptionMode["NullWeak"] = 5] = "NullWeak";
            })(icelink.EncryptionMode || (icelink.EncryptionMode = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (LayoutScale) {
                LayoutScale[LayoutScale["Contain"] = 1] = "Contain";
                LayoutScale[LayoutScale["Cover"] = 2] = "Cover";
                LayoutScale[LayoutScale["Stretch"] = 3] = "Stretch";
            })(icelink.LayoutScale || (icelink.LayoutScale = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (AttributeCategory) {
                    AttributeCategory[AttributeCategory["Normal"] = 1] = "Normal";
                    AttributeCategory[AttributeCategory["Caution"] = 2] = "Caution";
                    AttributeCategory[AttributeCategory["Identical"] = 3] = "Identical";
                    AttributeCategory[AttributeCategory["Sum"] = 4] = "Sum";
                    AttributeCategory[AttributeCategory["Transport"] = 5] = "Transport";
                    AttributeCategory[AttributeCategory["Inherit"] = 6] = "Inherit";
                    AttributeCategory[AttributeCategory["IdenticalPerPT"] = 7] = "IdenticalPerPT";
                    AttributeCategory[AttributeCategory["Special"] = 8] = "Special";
                })(sdp.AttributeCategory || (sdp.AttributeCategory = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (AttributeType) {
                    AttributeType[AttributeType["UnknownAttribute"] = 999666] = "UnknownAttribute";
                    AttributeType[AttributeType["DirectionAttribute"] = 1] = "DirectionAttribute";
                    AttributeType[AttributeType["CategoryAttribute"] = 2] = "CategoryAttribute";
                    AttributeType[AttributeType["CharacterSetAttribute"] = 3] = "CharacterSetAttribute";
                    AttributeType[AttributeType["ConferenceTypeAttribute"] = 4] = "ConferenceTypeAttribute";
                    AttributeType[AttributeType["CryptoAttribute"] = 5] = "CryptoAttribute";
                    AttributeType[AttributeType["FormatParametersAttribute"] = 6] = "FormatParametersAttribute";
                    AttributeType[AttributeType["FrameRateAttribute"] = 7] = "FrameRateAttribute";
                    AttributeType[AttributeType["KeywordsAttribute"] = 8] = "KeywordsAttribute";
                    AttributeType[AttributeType["LanguageAttribute"] = 9] = "LanguageAttribute";
                    AttributeType[AttributeType["MaxPacketTimeAttribute"] = 10] = "MaxPacketTimeAttribute";
                    AttributeType[AttributeType["OrientationAttribute"] = 11] = "OrientationAttribute";
                    AttributeType[AttributeType["PacketTimeAttribute"] = 12] = "PacketTimeAttribute";
                    AttributeType[AttributeType["QualityAttribute"] = 13] = "QualityAttribute";
                    AttributeType[AttributeType["SdpLanguageAttribute"] = 14] = "SdpLanguageAttribute";
                    AttributeType[AttributeType["SetupAttribute"] = 15] = "SetupAttribute";
                    AttributeType[AttributeType["ToolAttribute"] = 16] = "ToolAttribute";
                    AttributeType[AttributeType["MediaStreamIdSemanticAttribute"] = 17] = "MediaStreamIdSemanticAttribute";
                    AttributeType[AttributeType["MediaStreamIdAttribute"] = 18] = "MediaStreamIdAttribute";
                    AttributeType[AttributeType["BundleOnlyAttribute"] = 40] = "BundleOnlyAttribute";
                    AttributeType[AttributeType["IceCandidateAttribute"] = 19] = "IceCandidateAttribute";
                    AttributeType[AttributeType["IceFingerprintAttribute"] = 20] = "IceFingerprintAttribute";
                    AttributeType[AttributeType["IceLiteAttribute"] = 21] = "IceLiteAttribute";
                    AttributeType[AttributeType["IceMismatchAttribute"] = 22] = "IceMismatchAttribute";
                    AttributeType[AttributeType["IceOptionsAttribute"] = 23] = "IceOptionsAttribute";
                    AttributeType[AttributeType["IcePasswordAttribute"] = 24] = "IcePasswordAttribute";
                    AttributeType[AttributeType["IceUfragAttribute"] = 25] = "IceUfragAttribute";
                    AttributeType[AttributeType["IceRemoteCandidatesAttribute"] = 26] = "IceRemoteCandidatesAttribute";
                    AttributeType[AttributeType["RtpMapAttribute"] = 27] = "RtpMapAttribute";
                    AttributeType[AttributeType["RtpSsrcAttribute"] = 28] = "RtpSsrcAttribute";
                    AttributeType[AttributeType["RtpExtMapAttribute"] = 29] = "RtpExtMapAttribute";
                    AttributeType[AttributeType["RtcpAttribute"] = 30] = "RtcpAttribute";
                    AttributeType[AttributeType["RtcpFeedbackAttribute"] = 31] = "RtcpFeedbackAttribute";
                    AttributeType[AttributeType["RtcpMuxAttribute"] = 32] = "RtcpMuxAttribute";
                    AttributeType[AttributeType["SctpPortAttribute"] = 33] = "SctpPortAttribute";
                    AttributeType[AttributeType["SctpMapAttribute"] = 34] = "SctpMapAttribute";
                    AttributeType[AttributeType["SctpMaxMessageSizeAttribute"] = 35] = "SctpMaxMessageSizeAttribute";
                    AttributeType[AttributeType["GroupAttribute"] = 36] = "GroupAttribute";
                    AttributeType[AttributeType["RtpRidAttribute"] = 37] = "RtpRidAttribute";
                    AttributeType[AttributeType["SimulcastAttribute"] = 38] = "SimulcastAttribute";
                    AttributeType[AttributeType["RtpSsrcGroupAttribute"] = 39] = "RtpSsrcGroupAttribute";
                    AttributeType[AttributeType["MutedAttribute"] = 41] = "MutedAttribute";
                })(sdp.AttributeType || (sdp.AttributeType = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (GroupSemanticsType) {
                    GroupSemanticsType[GroupSemanticsType["LipSynchronization"] = 1] = "LipSynchronization";
                    GroupSemanticsType[GroupSemanticsType["FlowIdentification"] = 2] = "FlowIdentification";
                    GroupSemanticsType[GroupSemanticsType["Bundling"] = 3] = "Bundling";
                    GroupSemanticsType[GroupSemanticsType["Unknown"] = 4] = "Unknown";
                })(sdp.GroupSemanticsType || (sdp.GroupSemanticsType = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    (function (OptionTagType) {
                        OptionTagType[OptionTagType["Unknown"] = 1] = "Unknown";
                        OptionTagType[OptionTagType["Trickle"] = 2] = "Trickle";
                    })(ice.OptionTagType || (ice.OptionTagType = {}));
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (MediaStreamIdSemanticToken) {
                    MediaStreamIdSemanticToken[MediaStreamIdSemanticToken["Wms"] = 1] = "Wms";
                })(sdp.MediaStreamIdSemanticToken || (sdp.MediaStreamIdSemanticToken = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (SessionDescriptionType) {
                SessionDescriptionType[SessionDescriptionType["Offer"] = 1] = "Offer";
                SessionDescriptionType[SessionDescriptionType["Answer"] = 2] = "Answer";
            })(icelink.SessionDescriptionType || (icelink.SessionDescriptionType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (StreamDirection) {
                StreamDirection[StreamDirection["SendReceive"] = 1] = "SendReceive";
                StreamDirection[StreamDirection["SendOnly"] = 2] = "SendOnly";
                StreamDirection[StreamDirection["ReceiveOnly"] = 3] = "ReceiveOnly";
                StreamDirection[StreamDirection["Inactive"] = 4] = "Inactive";
                StreamDirection[StreamDirection["Unset"] = 5] = "Unset";
            })(icelink.StreamDirection || (icelink.StreamDirection = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (StreamState) {
                StreamState[StreamState["New"] = 1] = "New";
                StreamState[StreamState["Initializing"] = 2] = "Initializing";
                StreamState[StreamState["Connecting"] = 3] = "Connecting";
                StreamState[StreamState["Connected"] = 4] = "Connected";
                StreamState[StreamState["Failing"] = 5] = "Failing";
                StreamState[StreamState["Failed"] = 6] = "Failed";
                StreamState[StreamState["Closing"] = 7] = "Closing";
                StreamState[StreamState["Closed"] = 8] = "Closed";
            })(icelink.StreamState || (icelink.StreamState = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (StreamType) {
                StreamType[StreamType["Audio"] = 1] = "Audio";
                StreamType[StreamType["Video"] = 2] = "Video";
                StreamType[StreamType["Application"] = 3] = "Application";
                StreamType[StreamType["Message"] = 4] = "Message";
                StreamType[StreamType["Text"] = 5] = "Text";
            })(icelink.StreamType || (icelink.StreamType = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CryptoLibraryWrapper =  (function () {
                function CryptoLibraryWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_1 = __arguments[0];
                        this._value = value_1;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CryptoLibraryWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.CryptoLibraryWrapper]';
                };
                CryptoLibraryWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.CryptoLibrary.Default)
                            return 'Default';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CryptoLibraryWrapper;
            }());
            icelink.CryptoLibraryWrapper = CryptoLibraryWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataBufferPoolTracer =  (function () {
                function DataBufferPoolTracer(tag, pool) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var tag_2 = __arguments[0];
                        var pool_1 = __arguments[1];
                        if ((fm.icelink.Global.equals(tag_2, null))) {
                            throw new fm.icelink.Exception("Tag cannot be null.");
                        }
                        if ((fm.icelink.Global.equals(pool_1, null))) {
                            throw new fm.icelink.Exception("Pool cannot be null.");
                        }
                        this.setTag(tag_2);
                        this.setPool(pool_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                DataBufferPoolTracer.prototype.getTypeString = function () {
                    return '[fm.icelink.DataBufferPoolTracer]';
                };
                DataBufferPoolTracer.prototype.getPool = function () {
                    if (arguments.length == 0) {
                        return this._pool;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPoolTracer.prototype.getStatistics = function () {
                    if (arguments.length == 0) {
                        return this.getPool().getOrAddTraceStatistics(this.getTag());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPoolTracer.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPoolTracer.prototype.setPool = function (value) {
                    if (arguments.length == 1) {
                        this._pool = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPoolTracer.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPoolTracer.prototype.take = function () {
                    if (arguments.length == 1) {
                        var size = fm.icelink.Global.toInt(arguments[0]);
                        return this.getPool().traceTake(size, this.getTag());
                    }
                    else if (arguments.length == 2) {
                        var size = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        return this.getPool().traceTake(size, littleEndian, this.getTag());
                    }
                    else if (arguments.length == 3) {
                        var size = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var clearBytes = arguments[2];
                        return this.getPool().traceTake(size, littleEndian, clearBytes, this.getTag());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataBufferPoolTracer;
            }());
            icelink.DataBufferPoolTracer = DataBufferPoolTracer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PendingPromise =  (function () {
                function PendingPromise(promise, result) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var promise_1 = __arguments[0];
                        var result_1 = __arguments[1];
                        this.__promise = promise_1;
                        this.__result = result_1;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                PendingPromise.prototype.getTypeString = function () {
                    return '[fm.icelink.PendingPromise]';
                };
                PendingPromise.prototype.reject = function (ex) {
                    if (arguments.length == 1) {
                        this.__promise.reject(ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PendingPromise.prototype.resolve = function () {
                    if (arguments.length == 0) {
                        this.__promise.castAndResolve(this.__result);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return PendingPromise;
            }());
            icelink.PendingPromise = PendingPromise;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SystemClock =  (function () {
                function SystemClock() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SystemClock.prototype.getTypeString = function () {
                    return '[fm.icelink.SystemClock]';
                };
                SystemClock.prototype.getTimestamp = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ManagedStopwatch.getTimestamp();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SystemClock;
            }());
            icelink.SystemClock = SystemClock;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AddressTypeWrapper =  (function () {
                function AddressTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_2 = __arguments[0];
                        this._value = value_2;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                AddressTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.AddressTypeWrapper]';
                };
                AddressTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.AddressType.IPv4)
                            return 'IPv4';
                        if (this._value == fm.icelink.AddressType.IPv6)
                            return 'IPv6';
                        if (this._value == fm.icelink.AddressType.Unknown)
                            return 'Unknown';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return AddressTypeWrapper;
            }());
            icelink.AddressTypeWrapper = AddressTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Ascii =  (function () {
                function Ascii() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Ascii.prototype.getTypeString = function () {
                    return '[fm.icelink.Ascii]';
                };
                Ascii.decode = function () {
                    if (arguments.length == 1) {
                        var input = arguments[0];
                        return fm.icelink.Ascii.decode(input, 0, input.length);
                    }
                    else if (arguments.length == 3) {
                        var input = arguments[0];
                        var index = fm.icelink.Global.toInt(arguments[1]);
                        var length_4 = fm.icelink.Global.toInt(arguments[2]);
                        return fm.icelink.Encoding.getAscii().getString(input, index, length_4);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Ascii.encode = function (input) {
                    if (arguments.length == 1) {
                        return fm.icelink.Encoding.getAscii().getBytes(input);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Ascii.getByteCount = function (input) {
                    if (arguments.length == 1) {
                        return fm.icelink.Encoding.getAscii().getByteCount(input);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Ascii;
            }());
            icelink.Ascii = Ascii;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AtomicMutex =  (function () {
                function AtomicMutex() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.__lock = new fm.icelink.AtomicInteger(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                AtomicMutex.prototype.getTypeString = function () {
                    return '[fm.icelink.AtomicMutex]';
                };
                AtomicMutex.prototype.getIsLocked = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.Global.equals(this.__lock.getValue(), 1));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AtomicMutex.prototype.release = function () {
                    if (arguments.length == 0) {
                        this.__lock.compareAndSwap(1, 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AtomicMutex.prototype.tryLock = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.Global.equals(this.__lock.compareAndSwap(0, 1), 0));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return AtomicMutex;
            }());
            icelink.AtomicMutex = AtomicMutex;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Binary =  (function () {
                function Binary() {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Binary.prototype.getTypeString = function () {
                    return '[fm.icelink.Binary]';
                };
                Binary.bitStringToBytes = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 1) {
                        var bitString = arguments[0];
                        var numberOfUnusedBits = 0;
                        var _var0 = new fm.icelink.Holder(numberOfUnusedBits);
                        var _var1 = fm.icelink.Binary.bitStringToBytes(bitString, _var0);
                        numberOfUnusedBits = _var0.getValue();
                        return _var1;
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isObjectType(arguments[1], '[fm.icelink.Holder<number>]'))) {
                        var bitString = arguments[0];
                        var numberOfUnusedBits = arguments[1];
                        var _var0 = fm.icelink.Binary.bitStringToBytes(bitString, false, numberOfUnusedBits);
                        return _var0;
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isBoolean(arguments[1]))) {
                        var bitString = arguments[0];
                        var padLeft = arguments[1];
                        var numberOfUnusedBits = 0;
                        var _var0 = new fm.icelink.Holder(numberOfUnusedBits);
                        var _var1 = fm.icelink.Binary.bitStringToBytes(bitString, padLeft, _var0);
                        numberOfUnusedBits = _var0.getValue();
                        return _var1;
                    }
                    else if (arguments.length == 3) {
                        var bitString = arguments[0];
                        var padLeft = arguments[1];
                        var numberOfUnusedBits = arguments[2];
                        var num = (fm.icelink.StringExtensions.getLength(bitString) % 8);
                        numberOfUnusedBits.setValue(0);
                        if ((num > 0)) {
                            numberOfUnusedBits.setValue((8 - num));
                            for (var j = 0; (j < numberOfUnusedBits.getValue()); j++) {
                                if (padLeft) {
                                    bitString = fm.icelink.StringExtensions.concat("0", bitString);
                                }
                                else {
                                    bitString = fm.icelink.StringExtensions.concat(bitString, "0");
                                }
                            }
                        }
                        var buffer = new Uint8Array(fm.icelink.MathAssistant.floor(fm.icelink.StringExtensions.getLength(bitString) / 8));
                        var index = 0;
                        for (var i = 0; (index < buffer.length); i = (i + 8)) {
                            var flag = (!fm.icelink.Global.equals(bitString.charCodeAt(i), 48));
                            var flag2 = (!fm.icelink.Global.equals(bitString.charCodeAt((i + 1)), 48));
                            var flag3 = (!fm.icelink.Global.equals(bitString.charCodeAt((i + 2)), 48));
                            var flag4 = (!fm.icelink.Global.equals(bitString.charCodeAt((i + 3)), 48));
                            var flag5 = (!fm.icelink.Global.equals(bitString.charCodeAt((i + 4)), 48));
                            var flag6 = (!fm.icelink.Global.equals(bitString.charCodeAt((i + 5)), 48));
                            var flag7 = (!fm.icelink.Global.equals(bitString.charCodeAt((i + 6)), 48));
                            var flag8 = (!fm.icelink.Global.equals(bitString.charCodeAt((i + 7)), 48));
                            var num5 = 0;
                            if (flag) {
                                num5 = (num5 + 128);
                            }
                            if (flag2) {
                                num5 = (num5 + 64);
                            }
                            if (flag3) {
                                num5 = (num5 + 32);
                            }
                            if (flag4) {
                                num5 = (num5 + 16);
                            }
                            if (flag5) {
                                num5 = (num5 + 8);
                            }
                            if (flag6) {
                                num5 = (num5 + 4);
                            }
                            if (flag7) {
                                num5 = (num5 + 2);
                            }
                            if (flag8) {
                                num5++;
                            }
                            buffer[index] = fm.icelink.BitAssistant.castByte(num5);
                            index++;
                        }
                        return buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.bytesToBitString = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 1) {
                        var bytes = arguments[0];
                        return fm.icelink.Binary.bytesToBitString(bytes, 0, bytes.length);
                    }
                    else if (arguments.length == 3) {
                        var bytes = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var length_5 = fm.icelink.Global.toInt(arguments[2]);
                        return fm.icelink.Binary.bytesToBitString(bytes, offset, length_5, 0);
                    }
                    else if (arguments.length == 4) {
                        var bytes = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var length_6 = fm.icelink.Global.toInt(arguments[2]);
                        var numberOfUnusedBits = fm.icelink.Global.toInt(arguments[3]);
                        return fm.icelink.Binary.bytesToBitString(bytes, offset, length_6, numberOfUnusedBits, false);
                    }
                    else if (arguments.length == 5) {
                        var bytes = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var length_7 = fm.icelink.Global.toInt(arguments[2]);
                        var numberOfUnusedBits = fm.icelink.Global.toInt(arguments[3]);
                        var trimLeft = arguments[4];
                        var str = "";
                        for (var i = offset; (i < (offset + length_7)); i++) {
                            var num2 = bytes[i];
                            var flag = (fm.icelink.Global.equals((num2 & 128), 128));
                            var flag2 = (fm.icelink.Global.equals((num2 & 64), 64));
                            var flag3 = (fm.icelink.Global.equals((num2 & 32), 32));
                            var flag4 = (fm.icelink.Global.equals((num2 & 16), 16));
                            var flag5 = (fm.icelink.Global.equals((num2 & 8), 8));
                            var flag6 = (fm.icelink.Global.equals((num2 & 4), 4));
                            var flag7 = (fm.icelink.Global.equals((num2 & 2), 2));
                            var flag8 = (fm.icelink.Global.equals((num2 & 1), 1));
                            str = fm.icelink.StringExtensions.concat(str, fm.icelink.StringExtensions.format("{0}{1}{2}{3}{4}{5}{6}{7}", [(flag ? "1" : "0"), (flag2 ? "1" : "0"), (flag3 ? "1" : "0"), (flag4 ? "1" : "0"), (flag5 ? "1" : "0"), (flag6 ? "1" : "0"), (flag7 ? "1" : "0"), (flag8 ? "1" : "0")]));
                        }
                        if (trimLeft) {
                            return fm.icelink.StringExtensions.substring(str, numberOfUnusedBits, (fm.icelink.StringExtensions.getLength(str) - numberOfUnusedBits));
                        }
                        return fm.icelink.StringExtensions.substring(str, 0, (fm.icelink.StringExtensions.getLength(str) - numberOfUnusedBits));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.deinterleave = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        fm.icelink.Binary.deinterleave(inputFrame, outputFrame, 0, inputFrame.length, false);
                    }
                    else if (arguments.length == 4) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var start = fm.icelink.Global.toInt(arguments[2]);
                        var length_8 = fm.icelink.Global.toInt(arguments[3]);
                        fm.icelink.Binary.deinterleave(inputFrame, outputFrame, start, length_8, false);
                    }
                    else if (arguments.length == 5) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var start = fm.icelink.Global.toInt(arguments[2]);
                        var length_9 = fm.icelink.Global.toInt(arguments[3]);
                        var reversePlanes = arguments[4];
                        var num = (start + length_9);
                        var num2 = fm.icelink.MathAssistant.floor(length_9 / 2);
                        if ((num > outputFrame.length)) {
                            fm.icelink.Log.error("start + length greater than outputFrame length");
                        }
                        else {
                            var num3 = void 0;
                            var num4 = void 0;
                            if (reversePlanes) {
                                num3 = (start + num2);
                                num4 = start;
                            }
                            else {
                                num3 = start;
                                num4 = (start + num2);
                            }
                            for (var i = start; (i < num); i = (i + 2)) {
                                outputFrame[num3++] = inputFrame[i];
                                outputFrame[num4++] = inputFrame[(i + 1)];
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.deinterleaveTransform = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 6) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var width = fm.icelink.Global.toInt(arguments[2]);
                        var height = fm.icelink.Global.toInt(arguments[3]);
                        var stride = fm.icelink.Global.toInt(arguments[4]);
                        var rotation = fm.icelink.Global.toInt(arguments[5]);
                        fm.icelink.Binary.deinterleaveTransform(inputFrame, outputFrame, width, height, stride, rotation, 0, false);
                    }
                    else if (arguments.length == 7) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var width = fm.icelink.Global.toInt(arguments[2]);
                        var height = fm.icelink.Global.toInt(arguments[3]);
                        var stride = fm.icelink.Global.toInt(arguments[4]);
                        var rotation = fm.icelink.Global.toInt(arguments[5]);
                        var start = fm.icelink.Global.toInt(arguments[6]);
                        fm.icelink.Binary.deinterleaveTransform(inputFrame, outputFrame, width, height, stride, rotation, start, false);
                    }
                    else if (arguments.length == 8) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var width = fm.icelink.Global.toInt(arguments[2]);
                        var height = fm.icelink.Global.toInt(arguments[3]);
                        var stride = fm.icelink.Global.toInt(arguments[4]);
                        var rotation = fm.icelink.Global.toInt(arguments[5]);
                        var start = fm.icelink.Global.toInt(arguments[6]);
                        var reversePlanes = arguments[7];
                        var num = (width * height);
                        var length_10 = (num * 2);
                        var num3 = (stride - width);
                        var num4 = (start + length_10);
                        if ((num4 > outputFrame.length)) {
                            fm.icelink.Log.error("start + length greater than outputFrame length");
                        }
                        else {
                            var num5 = void 0;
                            var num6 = void 0;
                            var num9 = void 0;
                            var num10 = void 0;
                            if (reversePlanes) {
                                num5 = (start + num);
                                num6 = start;
                            }
                            else {
                                num5 = start;
                                num6 = (start + num);
                            }
                            var num7 = (height + 1);
                            var numArray = new Array(num7);
                            var num8 = (width * 2);
                            for (num9 = 0; (num9 < num7); num9++) {
                                numArray[num9] = ((num8 * num9) + start);
                                if ((num9 > 1)) {
                                    numArray[num9] = (numArray[num9] + (num3 * (num9 - 1)));
                                }
                            }
                            if ((fm.icelink.Global.equals(rotation, 270))) {
                                for (num9 = 1; (num9 <= num8); num9 = (num9 + 2)) {
                                    num10 = 1;
                                    while ((num10 < num7)) {
                                        outputFrame[num5++] = inputFrame[(numArray[num10] - (num9 + 1))];
                                        outputFrame[num6++] = inputFrame[(numArray[num10] - num9)];
                                        num10++;
                                    }
                                }
                            }
                            else {
                                if ((fm.icelink.Global.equals(rotation, 90))) {
                                    for (num9 = 0; (num9 < num8); num9 = (num9 + 2)) {
                                        for (num10 = (num7 - 2); (num10 >= 0); num10--) {
                                            outputFrame[num5++] = inputFrame[(numArray[num10] + num9)];
                                            outputFrame[num6++] = inputFrame[(numArray[num10] + (num9 + 1))];
                                        }
                                    }
                                }
                                else {
                                    if ((fm.icelink.Global.equals(rotation, 180))) {
                                        for (num9 = ((start + length_10) - 1); (num9 >= start); num9 = (num9 - 2)) {
                                            outputFrame[num5++] = inputFrame[(num9 - 1)];
                                            outputFrame[num6++] = inputFrame[num9];
                                        }
                                    }
                                    else {
                                        fm.icelink.Binary.deinterleave(inputFrame, outputFrame, start, length_10, reversePlanes);
                                    }
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes1 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        return (fm.icelink.Global.equals((fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes8(input, inputIndex), (7 - bitOffset)) & 1), 1));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes10 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 7)) {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (14 - bitOffset)) & 1023);
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes16(input, inputIndex, false), (6 - bitOffset)) & 1023);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 10 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes11 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 6)) {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (13 - bitOffset)) & 2047);
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes16(input, inputIndex, false), (5 - bitOffset)) & 2047);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 11 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes12 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 5)) {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (12 - bitOffset)) & 4095);
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes16(input, inputIndex, false), (4 - bitOffset)) & 4095);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 12 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes13 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 4)) {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (11 - bitOffset)) & 8191);
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes16(input, inputIndex, false), (3 - bitOffset)) & 8191);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 13 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes14 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 3)) {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (10 - bitOffset)) & 16383);
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes16(input, inputIndex, false), (2 - bitOffset)) & 16383);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 14 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes15 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 2)) {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (9 - bitOffset)) & 32767);
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes16(input, inputIndex, false), (1 - bitOffset)) & 32767);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 15 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes16 = function (input, inputIndex, littleEndian) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        var num = 0;
                        if (littleEndian) {
                            num = (num | fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex++]), 0));
                            return (num | fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex++]), 8));
                        }
                        num = (num | fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex++]), 8));
                        return (num | fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex++]), 0));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes17 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (7 - bitOffset)) & 131071);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes18 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 7)) {
                            if (((inputIndex + 3) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftLong(fm.icelink.Binary.fromBytes32(input, inputIndex, false), (14 - bitOffset)) & 262143);
                            }
                        }
                        else {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (6 - bitOffset)) & 262143);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 18 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes19 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 6)) {
                            if (((inputIndex + 3) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftLong(fm.icelink.Binary.fromBytes32(input, inputIndex, false), (13 - bitOffset)) & 524287);
                            }
                        }
                        else {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (5 - bitOffset)) & 524287);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 19 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes2 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes8(input, inputIndex), (6 - bitOffset)) & 3);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes20 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 5)) {
                            if (((inputIndex + 3) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftLong(fm.icelink.Binary.fromBytes32(input, inputIndex, false), (12 - bitOffset)) & 1048575);
                            }
                        }
                        else {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (4 - bitOffset)) & 1048575);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 20 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes21 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 4)) {
                            if (((inputIndex + 3) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftLong(fm.icelink.Binary.fromBytes32(input, inputIndex, false), (11 - bitOffset)) & 2097151);
                            }
                        }
                        else {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (3 - bitOffset)) & 2097151);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 21 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes22 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 3)) {
                            if (((inputIndex + 3) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftLong(fm.icelink.Binary.fromBytes32(input, inputIndex, false), (10 - bitOffset)) & 4194303);
                            }
                        }
                        else {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (2 - bitOffset)) & 4194303);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 22 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes23 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if ((bitOffset >= 2)) {
                            if (((inputIndex + 3) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftLong(fm.icelink.Binary.fromBytes32(input, inputIndex, false), (9 - bitOffset)) & 8388607);
                            }
                        }
                        else {
                            if (((inputIndex + 2) < input.length)) {
                                return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes24(input, inputIndex, false), (1 - bitOffset)) & 8388607);
                            }
                        }
                        throw new fm.icelink.Exception("Input data is not large enough to read 23 bits.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes24 = function (input, inputIndex, littleEndian) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        var num = 0;
                        if (littleEndian) {
                            num = (num | fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex++]), 0));
                            num = (num | fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex++]), 8));
                            return (num | fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex++]), 16));
                        }
                        num = (num | fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex++]), 16));
                        num = (num | fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex++]), 8));
                        return (num | fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex++]), 0));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes3 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes8(input, inputIndex), (5 - bitOffset)) & 7);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes32 = function (input, inputIndex, littleEndian) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        var num = 0;
                        if (littleEndian) {
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 0));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 8));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 16));
                            return (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 24));
                        }
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 24));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 16));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 8));
                        return (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 0));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes4 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes8(input, inputIndex), (4 - bitOffset)) & 15);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes40 = function (input, inputIndex, littleEndian) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        var num = 0;
                        if (littleEndian) {
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 0));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 8));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 16));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 24));
                            return (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 32));
                        }
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 32));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 24));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 16));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 8));
                        return (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 0));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes48 = function (input, inputIndex, littleEndian) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        var num = 0;
                        if (littleEndian) {
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 0));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 8));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 16));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 24));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 32));
                            return (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 40));
                        }
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 40));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 32));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 24));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 16));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 8));
                        return (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 0));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes5 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes8(input, inputIndex), (3 - bitOffset)) & 31);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes56 = function (input, inputIndex, littleEndian) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        var num = 0;
                        if (littleEndian) {
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 0));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 8));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 16));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 24));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 32));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 40));
                            return (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 48));
                        }
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 48));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 40));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 32));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 24));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 16));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 8));
                        return (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 0));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes6 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes8(input, inputIndex), (2 - bitOffset)) & 63);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes64 = function (input, inputIndex, littleEndian) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        var num = 0;
                        if (littleEndian) {
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 0));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 8));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 16));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 24));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 32));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 40));
                            num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 48));
                            return (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 56));
                        }
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 56));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 48));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 40));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 32));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 24));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 16));
                        num = (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 8));
                        return (num | fm.icelink.BitAssistant.leftShiftLong(fm.icelink.BitAssistant.castLong(input[inputIndex++]), 0));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes7 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes8(input, inputIndex), (1 - bitOffset)) & 127);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes8 = function (input, inputIndex) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.BitAssistant.leftShiftInteger(fm.icelink.BitAssistant.castInteger(input[inputIndex]), 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fromBytes9 = function (input, inputIndex, bitOffset) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            inputIndex++;
                        }
                        if (((inputIndex + 1) >= input.length)) {
                            throw new fm.icelink.Exception("Input data is not large enough to read 9 bits.");
                        }
                        return (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fromBytes16(input, inputIndex, false), (7 - bitOffset)) & 511);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.interleave = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        fm.icelink.Binary.interleave(inputFrame, outputFrame, 0, inputFrame.length, false);
                    }
                    else if (arguments.length == 4) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var start = fm.icelink.Global.toInt(arguments[2]);
                        var length_11 = fm.icelink.Global.toInt(arguments[3]);
                        fm.icelink.Binary.interleave(inputFrame, outputFrame, start, length_11, false);
                    }
                    else if (arguments.length == 5) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var start = fm.icelink.Global.toInt(arguments[2]);
                        var length_12 = fm.icelink.Global.toInt(arguments[3]);
                        var reversePlanes = arguments[4];
                        var num = (start + length_12);
                        var num2 = fm.icelink.MathAssistant.floor(length_12 / 2);
                        if ((num > outputFrame.length)) {
                            fm.icelink.Log.error("start + length greater than outputFrame length");
                        }
                        else {
                            var num3 = void 0;
                            var num4 = void 0;
                            if (reversePlanes) {
                                num3 = (start + num2);
                                num4 = start;
                            }
                            else {
                                num3 = start;
                                num4 = (start + num2);
                            }
                            var num5 = 0;
                            for (var i = 0; (i < num2); i++) {
                                outputFrame[num5++] = inputFrame[(num3 + i)];
                                outputFrame[num5++] = inputFrame[(num4 + i)];
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.interleaveTransform = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 6) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var width = fm.icelink.Global.toInt(arguments[2]);
                        var height = fm.icelink.Global.toInt(arguments[3]);
                        var stride = fm.icelink.Global.toInt(arguments[4]);
                        var rotation = fm.icelink.Global.toInt(arguments[5]);
                        fm.icelink.Binary.interleaveTransform(inputFrame, outputFrame, width, height, stride, rotation, 0, false);
                    }
                    else if (arguments.length == 7) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var width = fm.icelink.Global.toInt(arguments[2]);
                        var height = fm.icelink.Global.toInt(arguments[3]);
                        var stride = fm.icelink.Global.toInt(arguments[4]);
                        var rotation = fm.icelink.Global.toInt(arguments[5]);
                        var start = fm.icelink.Global.toInt(arguments[6]);
                        fm.icelink.Binary.interleaveTransform(inputFrame, outputFrame, width, height, stride, rotation, start, false);
                    }
                    else if (arguments.length == 8) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var width = fm.icelink.Global.toInt(arguments[2]);
                        var height = fm.icelink.Global.toInt(arguments[3]);
                        var stride = fm.icelink.Global.toInt(arguments[4]);
                        var rotation = fm.icelink.Global.toInt(arguments[5]);
                        var start = fm.icelink.Global.toInt(arguments[6]);
                        var reversePlanes = arguments[7];
                        var num = ((stride > 0) ? (stride * height) : (width * height));
                        var num2 = ((width * height) * 2);
                        var num3 = ((stride > 0) ? (stride - width) : width);
                        var num4 = (start + num2);
                        if ((num4 > outputFrame.length)) {
                            fm.icelink.Log.error("start + length greater than outputFrame length");
                        }
                        else {
                            var num5 = void 0;
                            var num6 = void 0;
                            var num9 = void 0;
                            var num11 = void 0;
                            if (reversePlanes) {
                                num5 = (start + num);
                                num6 = start;
                            }
                            else {
                                num5 = start;
                                num6 = (start + num);
                            }
                            var num7 = (height + 1);
                            var numArray = new Array(num7);
                            var num8 = width;
                            for (num9 = 0; (num9 < num7); num9++) {
                                numArray[num9] = (((num8 * num9) + start) + (num3 * (num9 - 1)));
                            }
                            var num10 = 0;
                            if ((fm.icelink.Global.equals(rotation, 270))) {
                                for (num9 = 1; (num9 <= num8); num9++) {
                                    num11 = 1;
                                    while ((num11 < num7)) {
                                        outputFrame[num10++] = inputFrame[((num5 + numArray[num11]) - num9)];
                                        outputFrame[num10++] = inputFrame[((num6 + numArray[num11]) - num9)];
                                        num11++;
                                    }
                                }
                            }
                            else {
                                if ((fm.icelink.Global.equals(rotation, 90))) {
                                    for (num9 = 0; (num9 < num8); num9++) {
                                        for (num11 = (num7 - 2); (num11 >= 0); num11--) {
                                            outputFrame[num10++] = inputFrame[(((num5 + numArray[num11]) + num9) + num3)];
                                            outputFrame[num10++] = inputFrame[(((num6 + numArray[num11]) + num9) + num3)];
                                        }
                                    }
                                }
                                else {
                                    if ((fm.icelink.Global.equals(rotation, 180))) {
                                        for (num9 = (num - 1); (num9 >= 0); num9--) {
                                            outputFrame[num10++] = inputFrame[(num5 + num9)];
                                            outputFrame[num10++] = inputFrame[(num6 + num9)];
                                        }
                                    }
                                    else {
                                        fm.icelink.Binary.interleave(inputFrame, outputFrame, start, (num * 2), reversePlanes);
                                    }
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.roundUp = function (value, multiple) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        multiple = fm.icelink.Global.toInt(arguments[1]);
                        if ((fm.icelink.Global.equals(multiple, 0))) {
                            return value;
                        }
                        var num = (value % multiple);
                        if ((fm.icelink.Global.equals(num, 0))) {
                            return value;
                        }
                        return ((value + multiple) - num);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes = function (value, bitOffset, littleEndian, output, outputIndex, bitCount) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 6) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        bitCount = fm.icelink.Global.toInt(arguments[5]);
                        var num4 = void 0;
                        var num5 = void 0;
                        if ((bitOffset >= 8)) {
                            return fm.icelink.Binary.toBytes(value, (bitOffset % 8), littleEndian, output, (outputIndex + fm.icelink.MathAssistant.floor(bitOffset / 8)), bitCount);
                        }
                        var num = fm.icelink.Binary.roundUp((bitCount + bitOffset), 8);
                        var num2 = fm.icelink.MathAssistant.floor(num / 8);
                        if (((outputIndex + num2) > output.length)) {
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Output data is not large enough to write {0} bits.", fm.icelink.NumberExtensions.toString(bitCount)));
                        }
                        if (littleEndian) {
                            throw new fm.icelink.Exception("Little-endian bit-level serialization is not supported.");
                        }
                        var num3 = fm.icelink.BitAssistant.leftShiftInteger(value, ((num - bitCount) - bitOffset));
                        if ((num2 > 0)) {
                            num4 = (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fm_icelink_Binary___bitmasks[(bitCount - 1)][0], bitOffset) & 255);
                            num5 = (num - 8);
                            output[outputIndex] = ((output[outputIndex] & num4) | fm.icelink.BitAssistant.rightShiftInteger((num3 & fm.icelink.BitAssistant.leftShiftInteger(~num4, num5)), num5));
                            outputIndex++;
                        }
                        if ((num2 > 1)) {
                            num4 = (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fm_icelink_Binary___bitmasks[(bitCount - 1)][1], bitOffset) & 255);
                            num5 = (num - 16);
                            output[outputIndex] = ((output[outputIndex] & num4) | fm.icelink.BitAssistant.rightShiftInteger((num3 & fm.icelink.BitAssistant.leftShiftInteger(~num4, num5)), num5));
                            outputIndex++;
                        }
                        if ((num2 > 2)) {
                            num4 = (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fm_icelink_Binary___bitmasks[(bitCount - 1)][2], bitOffset) & 255);
                            num5 = (num - 24);
                            output[outputIndex] = ((output[outputIndex] & num4) | fm.icelink.BitAssistant.rightShiftInteger((num3 & fm.icelink.BitAssistant.leftShiftInteger(~num4, num5)), num5));
                            outputIndex++;
                        }
                        if ((num2 > 3)) {
                            num4 = (fm.icelink.BitAssistant.rightShiftInteger(fm.icelink.Binary.fm_icelink_Binary___bitmasks[(bitCount - 1)][3], bitOffset) & 255);
                            num5 = (num - 32);
                            output[outputIndex] = ((output[outputIndex] & num4) | fm.icelink.BitAssistant.rightShiftInteger((num3 & fm.icelink.BitAssistant.leftShiftInteger(~num4, num5)), num5));
                            outputIndex++;
                        }
                        return output;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes1 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = arguments[0];
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = 1;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        return fm.icelink.Binary.toBytes1(value, bitOffset, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 4) {
                        var value = arguments[0];
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes((value ? 1 : 0), bitOffset, false, output, outputIndex, 1);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes10 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 2;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 7)) {
                            return fm.icelink.Binary.toBytes10(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes10(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 10);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes11 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 2;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 6)) {
                            return fm.icelink.Binary.toBytes11(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes11(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 11);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes12 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 2;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 5)) {
                            return fm.icelink.Binary.toBytes12(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes12(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 12);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes13 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 2;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 4)) {
                            return fm.icelink.Binary.toBytes13(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes13(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 13);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes14 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 2;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 3)) {
                            return fm.icelink.Binary.toBytes14(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes14(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 14);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes15 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 2;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 2)) {
                            return fm.icelink.Binary.toBytes15(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes15(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 15);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes16 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        return fm.icelink.Binary.toBytes16(value, littleEndian, new Uint8Array(2), 0);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        if (((outputIndex + 1) < output.length)) {
                            if (littleEndian) {
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftInteger((value & 255), 0);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftInteger((value & 65280), 8);
                                return output;
                            }
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftInteger((value & 65280), 8);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftInteger((value & 255), 0);
                            return output;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes17 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 3;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        return fm.icelink.Binary.toBytes17(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 17);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes18 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 3;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 7)) {
                            return fm.icelink.Binary.toBytes18(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes18(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 18);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes19 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 3;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 6)) {
                            return fm.icelink.Binary.toBytes19(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes19(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 19);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes2 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = 1;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 7)) {
                            return fm.icelink.Binary.toBytes2(value, bitOffset, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes2(value, bitOffset, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, false, output, outputIndex, 2);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes20 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 3;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 5)) {
                            return fm.icelink.Binary.toBytes20(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes20(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 20);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes21 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 3;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 4)) {
                            return fm.icelink.Binary.toBytes21(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes21(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 21);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes22 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 3;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 3)) {
                            return fm.icelink.Binary.toBytes22(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes22(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, false, output, outputIndex, 22);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes23 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 3;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 2)) {
                            return fm.icelink.Binary.toBytes23(value, bitOffset, littleEndian, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes23(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 23);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes24 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        return fm.icelink.Binary.toBytes24(value, littleEndian, new Uint8Array(3), 0);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        if (((outputIndex + 2) < output.length)) {
                            if (littleEndian) {
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftInteger((value & 255), 0);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftInteger((value & 65280), 8);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftInteger((value & 16711680), 16);
                                return output;
                            }
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftInteger((value & 16711680), 16);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftInteger((value & 65280), 8);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftInteger((value & 255), 0);
                            return output;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes3 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = 1;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 6)) {
                            return fm.icelink.Binary.toBytes3(value, bitOffset, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes3(value, bitOffset, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, false, output, outputIndex, 3);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes32 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        return fm.icelink.Binary.toBytes32(value, littleEndian, new Uint8Array(4), 0);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        if (((outputIndex + 3) < output.length)) {
                            if (littleEndian) {
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 255), 0);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 65280), 8);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 16711680), 16);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 4278190080), 24);
                                return output;
                            }
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 4278190080), 24);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 16711680), 16);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 65280), 8);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 255), 0);
                            return output;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes4 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = 1;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 5)) {
                            return fm.icelink.Binary.toBytes4(value, bitOffset, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes4(value, bitOffset, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, false, output, outputIndex, 4);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes40 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        return fm.icelink.Binary.toBytes40(value, littleEndian, new Uint8Array(5), 0);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        if (((outputIndex + 4) < output.length)) {
                            if (littleEndian) {
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 255), 0);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 65280), 8);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 16711680), 16);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 4278190080), 24);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 1095216660480), 32);
                                return output;
                            }
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 1095216660480), 32);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 4278190080), 24);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 16711680), 16);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 65280), 8);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 255), 0);
                            return output;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes48 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        return fm.icelink.Binary.toBytes48(value, littleEndian, new Uint8Array(6), 0);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        if (((outputIndex + 5) < output.length)) {
                            if (littleEndian) {
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 255), 0);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 65280), 8);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 16711680), 16);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 4278190080), 24);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 1095216660480), 32);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 280375465082880), 40);
                                return output;
                            }
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 280375465082880), 40);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 1095216660480), 32);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 4278190080), 24);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 16711680), 16);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 65280), 8);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 255), 0);
                            return output;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes5 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = 1;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 4)) {
                            return fm.icelink.Binary.toBytes5(value, bitOffset, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes5(value, bitOffset, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, false, output, outputIndex, 5);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes56 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        return fm.icelink.Binary.toBytes56(value, littleEndian, new Uint8Array(7), 0);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        if (((outputIndex + 6) < output.length)) {
                            if (littleEndian) {
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 255), 0);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 65280), 8);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 16711680), 16);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 4278190080), 24);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 1095216660480), 32);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 280375465082880), 40);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 71776119061217280), 48);
                                return output;
                            }
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 71776119061217280), 48);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 280375465082880), 40);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 1095216660480), 32);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 4278190080), 24);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 16711680), 16);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 65280), 8);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 255), 0);
                            return output;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes6 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = 1;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 3)) {
                            return fm.icelink.Binary.toBytes6(value, bitOffset, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes6(value, bitOffset, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, false, output, outputIndex, 6);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes64 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        return fm.icelink.Binary.toBytes64(value, littleEndian, new Uint8Array(8), 0);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        if (((outputIndex + 7) < output.length)) {
                            if (littleEndian) {
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong(value, 0);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 65280), 8);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 16711680), 16);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 4278190080), 24);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 1095216660480), 32);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 280375465082880), 40);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 71776119061217280), 48);
                                output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong(value, 56);
                                return output;
                            }
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong(value, 56);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 71776119061217280), 48);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 280375465082880), 40);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 1095216660480), 32);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 4278190080), 24);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 16711680), 16);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 65280), 8);
                            output[outputIndex++] = fm.icelink.BitAssistant.rightShiftLong((value & 255), 0);
                            return output;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes7 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = 1;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        if ((bitOffset >= 2)) {
                            return fm.icelink.Binary.toBytes7(value, bitOffset, new Uint8Array((num + 1)), outputIndex);
                        }
                        return fm.icelink.Binary.toBytes7(value, bitOffset, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 4) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var output = arguments[2];
                        var outputIndex = fm.icelink.Global.toInt(arguments[3]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, false, output, outputIndex, 7);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes8 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 1) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.Binary.toBytes8(value, new Uint8Array(1), 0);
                    }
                    else if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var output = arguments[1];
                        var outputIndex = fm.icelink.Global.toInt(arguments[2]);
                        if ((outputIndex >= output.length)) {
                            throw new fm.icelink.Exception("Output data is not large enough to write 8 bits.");
                        }
                        output[outputIndex] = fm.icelink.BitAssistant.rightShiftInteger((value & 255), 0);
                        return output;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.toBytes9 = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var num = 2;
                        var outputIndex = 0;
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                            num++;
                        }
                        return fm.icelink.Binary.toBytes9(value, bitOffset, littleEndian, new Uint8Array(num), outputIndex);
                    }
                    else if (arguments.length == 5) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        var output = arguments[3];
                        var outputIndex = fm.icelink.Global.toInt(arguments[4]);
                        while ((bitOffset >= 8)) {
                            bitOffset = (bitOffset - 8);
                            outputIndex++;
                        }
                        return fm.icelink.Binary.toBytes(value, bitOffset, littleEndian, output, outputIndex, 9);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.transform = function () {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 6) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var width = fm.icelink.Global.toInt(arguments[2]);
                        var height = fm.icelink.Global.toInt(arguments[3]);
                        var stride = fm.icelink.Global.toInt(arguments[4]);
                        var rotation = fm.icelink.Global.toInt(arguments[5]);
                        fm.icelink.Binary.transform(inputFrame, outputFrame, width, height, stride, rotation, 0, 0);
                    }
                    else if (arguments.length == 8) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var width = fm.icelink.Global.toInt(arguments[2]);
                        var height = fm.icelink.Global.toInt(arguments[3]);
                        var stride = fm.icelink.Global.toInt(arguments[4]);
                        var rotation = fm.icelink.Global.toInt(arguments[5]);
                        var inputStart = fm.icelink.Global.toInt(arguments[6]);
                        var outputStart = fm.icelink.Global.toInt(arguments[7]);
                        fm.icelink.Binary.transform(inputFrame, outputFrame, width, height, stride, rotation, inputStart, outputStart, 1);
                    }
                    else if (arguments.length == 9) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var width = fm.icelink.Global.toInt(arguments[2]);
                        var height = fm.icelink.Global.toInt(arguments[3]);
                        var stride = fm.icelink.Global.toInt(arguments[4]);
                        var rotation = fm.icelink.Global.toInt(arguments[5]);
                        var inputStart = fm.icelink.Global.toInt(arguments[6]);
                        var outputStart = fm.icelink.Global.toInt(arguments[7]);
                        var chunkLength = fm.icelink.Global.toInt(arguments[8]);
                        var num = ((width * height) * chunkLength);
                        var length_13 = ((stride > 0) ? ((stride * height) * chunkLength) : num);
                        var num3 = ((outputStart > 0) ? outputStart : inputStart);
                        var num4 = ((stride > 0) ? ((stride - width) * chunkLength) : 0);
                        var num5 = (outputStart + num);
                        if ((num5 > outputFrame.length)) {
                            fm.icelink.Log.error("otuputStart + calculated output plane length is greater than outputFrame length");
                        }
                        else {
                            var num8 = void 0;
                            var num9 = void 0;
                            var num10 = void 0;
                            var num6 = (height + 1);
                            var numArray = new Array(num6);
                            var num7 = (width * chunkLength);
                            for (num8 = 0; (num8 < num6); num8++) {
                                numArray[num8] = (((num7 * num8) + inputStart) + (num4 * (num8 - 1)));
                            }
                            if ((fm.icelink.Global.equals(rotation, 270))) {
                                for (num8 = 1; (num8 <= num7); num8 = (num8 + chunkLength)) {
                                    num9 = 1;
                                    while ((num9 < num6)) {
                                        num10 = (chunkLength - 1);
                                        while ((num10 >= 0)) {
                                            outputFrame[num3++] = inputFrame[((numArray[num9] - num8) - num10)];
                                            num10--;
                                        }
                                        num9++;
                                    }
                                }
                            }
                            else {
                                if ((fm.icelink.Global.equals(rotation, 90))) {
                                    for (num8 = 0; (num8 < num7); num8 = (num8 + chunkLength)) {
                                        for (num9 = (num6 - 2); (num9 >= 0); num9--) {
                                            num10 = 0;
                                            while ((num10 < chunkLength)) {
                                                outputFrame[num3++] = inputFrame[(((numArray[num9] + num4) + num8) + num10)];
                                                num10++;
                                            }
                                        }
                                    }
                                }
                                else {
                                    if ((fm.icelink.Global.equals(rotation, 180))) {
                                        var num11 = 0;
                                        for (num8 = (((inputStart + length_13) - num4) - 1); (num8 >= inputStart); num8 = (num8 - chunkLength)) {
                                            if ((((fm.icelink.Global.equals(num4, 0)) || (fm.icelink.Global.equals(num11, 0))) || (!fm.icelink.Global.equals((num11 % num7), 0)))) {
                                                for (num10 = (chunkLength - 1); (num10 >= 0); num10--) {
                                                    outputFrame[num3++] = inputFrame[(num8 - num10)];
                                                    num11++;
                                                }
                                            }
                                            else {
                                                num8 = (num8 - (num4 - chunkLength));
                                                num11 = 0;
                                            }
                                        }
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(num4, 0))) {
                                            fm.icelink.BitAssistant.copy(inputFrame, inputStart, outputFrame, outputStart, length_13);
                                        }
                                        else {
                                            for (num8 = 0; (num8 < height); num8++) {
                                                fm.icelink.BitAssistant.copy(inputFrame, (inputStart + ((stride * chunkLength) * num8)), outputFrame, (outputStart + ((width * chunkLength) * num8)), (width * chunkLength));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (arguments.length == 7) {
                        var inputFrame = arguments[0];
                        var outputFrame = arguments[1];
                        var width = fm.icelink.Global.toInt(arguments[2]);
                        var height = fm.icelink.Global.toInt(arguments[3]);
                        var stride = fm.icelink.Global.toInt(arguments[4]);
                        var rotation = fm.icelink.Global.toInt(arguments[5]);
                        var start = fm.icelink.Global.toInt(arguments[6]);
                        fm.icelink.Binary.transform(inputFrame, outputFrame, width, height, stride, rotation, start, start);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes1 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes1(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(false);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes10 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((bitOffset >= 7)) {
                            if (((inputIndex + 2) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes10(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes10(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes11 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((bitOffset >= 6)) {
                            if (((inputIndex + 2) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes11(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes11(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes12 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((bitOffset >= 5)) {
                            if (((inputIndex + 2) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes12(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes12(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes13 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((bitOffset >= 4)) {
                            if (((inputIndex + 2) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes13(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes13(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes14 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((bitOffset >= 3)) {
                            if (((inputIndex + 2) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes14(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes14(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes15 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((bitOffset >= 2)) {
                            if (((inputIndex + 2) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes15(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        else {
                            if (((inputIndex + 1) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes15(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes16 = function (input, inputIndex, littleEndian, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        if (((inputIndex + 1) < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes16(input, inputIndex, littleEndian));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes17 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes17(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes18 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((bitOffset >= 7)) {
                            if (((inputIndex + 3) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes18(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        else {
                            if (((inputIndex + 2) < input.length)) {
                                value.setValue(fm.icelink.Binary.fromBytes18(input, inputIndex, bitOffset));
                                return true;
                            }
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes19 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes19(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes2 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes2(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes20 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes20(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes21 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes21(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes22 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes22(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes23 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes23(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes24 = function (input, inputIndex, littleEndian, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        if (((inputIndex + 2) < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes24(input, inputIndex, littleEndian));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes3 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes3(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes32 = function (input, inputIndex, littleEndian, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        if (((inputIndex + 3) < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes32(input, inputIndex, littleEndian));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes4 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes4(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes40 = function (input, inputIndex, littleEndian, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        if (((inputIndex + 4) < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes40(input, inputIndex, littleEndian));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes48 = function (input, inputIndex, littleEndian, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        if (((inputIndex + 5) < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes48(input, inputIndex, littleEndian));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes5 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes5(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes56 = function (input, inputIndex, littleEndian, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        if (((inputIndex + 6) < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes56(input, inputIndex, littleEndian));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes6 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes6(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes64 = function (input, inputIndex, littleEndian, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        if (((inputIndex + 7) < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes64(input, inputIndex, littleEndian));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes7 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes7(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes8 = function (input, inputIndex, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 3) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        if ((inputIndex < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes8(input, inputIndex));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.tryFromBytes9 = function (input, inputIndex, bitOffset, value) {
                    fm.icelink.Binary.fmicelinkBinaryInitialize();
                    if (arguments.length == 4) {
                        inputIndex = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        if (((inputIndex + 1) < input.length)) {
                            value.setValue(fm.icelink.Binary.fromBytes9(input, inputIndex, bitOffset));
                            return true;
                        }
                        value.setValue(0);
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Binary.fmicelinkBinaryInitialize = function () {
                    if (!fm.icelink.Binary.__fmicelinkBinaryInitialized && !fm.icelink.Binary.__fmicelinkBinaryInitializing) {
                        fm.icelink.Binary.__fmicelinkBinaryInitializing = true;
                        var numArray = new Array(24);
                        numArray[0] = [65407, 32767];
                        numArray[1] = [65343, 16383];
                        numArray[2] = [65311, 8191];
                        numArray[3] = [65295, 4095];
                        numArray[4] = [65287, 2047];
                        numArray[5] = [65283, 1023];
                        numArray[6] = [65281, 511];
                        numArray[7] = [65280, 255];
                        numArray[8] = [65280, 127, 32767];
                        numArray[9] = [65280, 63, 16383];
                        numArray[10] = [65280, 31, 8191];
                        numArray[11] = [65280, 15, 4095];
                        numArray[12] = [65280, 7, 2047];
                        numArray[13] = [65280, 3, 1023];
                        numArray[14] = [65280, 1, 511];
                        var numArray2 = new Array(3);
                        numArray2[0] = 65280;
                        numArray2[2] = 255;
                        numArray[15] = numArray2;
                        numArray[16] = [65280, 0, 127, 32767];
                        numArray[17] = [65280, 0, 63, 16383];
                        numArray[18] = [65280, 0, 31, 8191];
                        numArray[19] = [65280, 0, 15, 4095];
                        numArray[20] = [65280, 0, 7, 2047];
                        numArray[21] = [65280, 0, 3, 1023];
                        numArray[22] = [65280, 0, 1, 511];
                        numArray2 = new Array(4);
                        numArray2[0] = 65280;
                        numArray2[3] = 255;
                        numArray[23] = numArray2;
                        fm.icelink.Binary.fm_icelink_Binary___bitmasks = numArray;
                        fm.icelink.Binary.__fmicelinkBinaryInitialized = true;
                        fm.icelink.Binary.__fmicelinkBinaryInitializing = false;
                    }
                };
                Binary.__fmicelinkBinaryInitialized = false;
                Binary.__fmicelinkBinaryInitializing = false;
                return Binary;
            }());
            icelink.Binary = Binary;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var BooleanHolder =  (function () {
                function BooleanHolder() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkBooleanHolderInit();
                    }
                    else if (__arguments.length == 1) {
                        var value = __arguments[0];
                        this.fmicelinkBooleanHolderInit();
                        this.setValue(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                BooleanHolder.prototype.getTypeString = function () {
                    return '[fm.icelink.BooleanHolder]';
                };
                BooleanHolder.prototype.fmicelinkBooleanHolderInit = function () {
                    this._value = false;
                };
                BooleanHolder.prototype.getValue = function () {
                    if (arguments.length == 0) {
                        return this._value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BooleanHolder.prototype.setValue = function (value) {
                    if (arguments.length == 1) {
                        this._value = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return BooleanHolder;
            }());
            icelink.BooleanHolder = BooleanHolder;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Build =  (function () {
                function Build() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Build.prototype.getTypeString = function () {
                    return '[fm.icelink.Build]';
                };
                Build.getDate = function () {
                    if (arguments.length == 0) {
                        if ((((fm.icelink.Global.equals(fm.icelink.Build.getYear(), 0)) && (fm.icelink.Global.equals(fm.icelink.Build.getMonth(), 0))) && (fm.icelink.Global.equals(fm.icelink.Build.getDay(), 0)))) {
                            return new fm.icelink.DateTime(1970, 1, 1, 0, 0, 0);
                        }
                        return new fm.icelink.DateTime(fm.icelink.Build.getYear(), fm.icelink.Build.getMonth(), fm.icelink.Build.getDay(), 0, 0, 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Build.getDay = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring("2021-03-16", 8, 2));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Build.getMajorVersion = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.split("3.12.2.44189", [46])[0]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Build.getMinorVersion = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.split("3.12.2.44189", [46])[1]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Build.getMonth = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring("2021-03-16", 5, 2));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Build.getPatchVersion = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.split("3.12.2.44189", [46])[2]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Build.getRevisionVersion = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.split("3.12.2.44189", [46])[3]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Build.getVersion = function () {
                    if (arguments.length == 0) {
                        return "3.12.2.44189";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Build.getYear = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring("2021-03-16", 0, 4));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Build.VersionConstant = "3.12.2.44189";
                return Build;
            }());
            icelink.Build = Build;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ByteHolder =  (function () {
                function ByteHolder() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkByteHolderInit();
                    }
                    else if (__arguments.length == 1) {
                        var value = __arguments[0];
                        this.fmicelinkByteHolderInit();
                        this.setValue(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                ByteHolder.prototype.getTypeString = function () {
                    return '[fm.icelink.ByteHolder]';
                };
                ByteHolder.prototype.fmicelinkByteHolderInit = function () {
                    this._value = 0;
                };
                ByteHolder.prototype.getValue = function () {
                    if (arguments.length == 0) {
                        return this._value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ByteHolder.prototype.setValue = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._value = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ByteHolder;
            }());
            icelink.ByteHolder = ByteHolder;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CharacterHolder =  (function () {
                function CharacterHolder() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkCharacterHolderInit();
                    }
                    else if (__arguments.length == 1) {
                        var value = __arguments[0];
                        this.fmicelinkCharacterHolderInit();
                        this.setValue(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CharacterHolder.prototype.getTypeString = function () {
                    return '[fm.icelink.CharacterHolder]';
                };
                CharacterHolder.prototype.fmicelinkCharacterHolderInit = function () {
                    this._value = 0;
                };
                CharacterHolder.prototype.getValue = function () {
                    if (arguments.length == 0) {
                        return this._value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CharacterHolder.prototype.setValue = function (value) {
                    if (arguments.length == 1) {
                        this._value = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CharacterHolder;
            }());
            icelink.CharacterHolder = CharacterHolder;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CircularBuffer =  (function () {
                function CircularBuffer() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var length_14 = __arguments[0];
                        var latency = __arguments[1];
                        __arguments = new Array(3);
                        __arguments[0] = length_14;
                        __arguments[1] = latency;
                        __arguments[2] = false;
                        {
                            var length_15 = __arguments[0];
                            var latency_1 = __arguments[1];
                            var littleEndian = __arguments[2];
                            this.fmicelinkCircularBufferInit();
                            this.__allowRead = false;
                            if ((length_15 <= 0)) {
                                throw new fm.icelink.Exception("Cannot create a circular buffer with no length.");
                            }
                            this.__buffer = fm.icelink.DataBuffer.allocate(length_15, littleEndian);
                            this.setReadOffset(0);
                            this.setWriteOffset(this.getLatency());
                            this.setLatency(latency_1);
                            this.setLittleEndian(littleEndian);
                        }
                    }
                    else if (__arguments.length == 3) {
                        var length_16 = __arguments[0];
                        var latency = __arguments[1];
                        var littleEndian = __arguments[2];
                        this.fmicelinkCircularBufferInit();
                        this.__allowRead = false;
                        if ((length_16 <= 0)) {
                            throw new fm.icelink.Exception("Cannot create a circular buffer with no length.");
                        }
                        this.__buffer = fm.icelink.DataBuffer.allocate(length_16, littleEndian);
                        this.setReadOffset(0);
                        this.setWriteOffset(this.getLatency());
                        this.setLatency(latency);
                        this.setLittleEndian(littleEndian);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CircularBuffer.prototype.getTypeString = function () {
                    return '[fm.icelink.CircularBuffer]';
                };
                CircularBuffer.prototype.fmicelinkCircularBufferInit = function () {
                    this.__allowRead = false;
                    this._latency = 0;
                    this._littleEndian = false;
                    this._readOffset = 0;
                    this._writeOffset = 0;
                };
                CircularBuffer.prototype.getAvailable = function () {
                    if (arguments.length == 0) {
                        return (this.getWriteOffset() - this.getReadOffset());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.getLatency = function () {
                    if (arguments.length == 0) {
                        return this._latency;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.getLength = function () {
                    if (arguments.length == 0) {
                        return this.__buffer.getLength();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.getLittleEndian = function () {
                    if (arguments.length == 0) {
                        return this._littleEndian;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.getReadOffset = function () {
                    if (arguments.length == 0) {
                        return this._readOffset;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.getWriteOffset = function () {
                    if (arguments.length == 0) {
                        return this._writeOffset;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.read = function (length) {
                    if (arguments.length == 1) {
                        length = fm.icelink.Global.toInt(arguments[0]);
                        if ((length > this.getLength())) {
                            return null;
                        }
                        var buffer = fm.icelink.DataBuffer.allocate(length, this.getLittleEndian());
                        if (this.__allowRead) {
                            if (((this.getReadOffset() + length) <= this.getLength())) {
                                buffer.write(this.__buffer.subset(this.getReadOffset(), length), 0);
                                this.__buffer.set(0, this.getReadOffset(), length);
                            }
                            else {
                                var num = (this.__buffer.getLength() - this.getReadOffset());
                                var num2 = (length - num);
                                buffer.write(this.__buffer.subset(this.getReadOffset(), num), 0);
                                buffer.write(this.__buffer.subset(0, num2), num);
                                this.__buffer.set(0, this.getReadOffset(), num);
                                this.__buffer.set(0, 0, num2);
                            }
                            this.setReadOffset(((this.getReadOffset() + length) % this.getLength()));
                        }
                        return buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.setLatency = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._latency = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.setLittleEndian = function (value) {
                    if (arguments.length == 1) {
                        this._littleEndian = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.setReadOffset = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._readOffset = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.setWriteOffset = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._writeOffset = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CircularBuffer.prototype.write = function (buffer) {
                    if (arguments.length == 1) {
                        var num2 = void 0;
                        for (var i = 0; (i < buffer.getLength()); i = (i + num2)) {
                            num2 = 0;
                            if (((buffer.getLength() - i) < (this.getLength() - this.getWriteOffset()))) {
                                num2 = (buffer.getLength() - i);
                            }
                            else {
                                num2 = (this.getLength() - this.getWriteOffset());
                            }
                            this.__buffer.write(buffer.subset(i, num2), this.getWriteOffset());
                            this.setWriteOffset(((this.getWriteOffset() + num2) % this.getLength()));
                        }
                        if ((!this.__allowRead && (this.getWriteOffset() >= (this.getReadOffset() + this.getLatency())))) {
                            this.__allowRead = true;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CircularBuffer;
            }());
            icelink.CircularBuffer = CircularBuffer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Collection =  (function () {
                function Collection() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.__values = new Array();
                        this.__valuesLock = new Object();
                        this.__valuesCache = this.arrayFromList(this.__values);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Collection.prototype.getTypeString = function () {
                    return '[fm.icelink.Collection]';
                };
                Collection.prototype.add = function (value) {
                    if (arguments.length == 1) {
                        var flag = false;
                        if ((!fm.icelink.Global.equals(value, null))) {
                            if (!fm.icelink.ArrayExtensions.contains(this.__values, value)) {
                                flag = true;
                                fm.icelink.ArrayExtensions.add(this.__values, value);
                                this.__valuesCache = this.arrayFromList(this.__values);
                                this.addSuccess(value);
                            }
                            if (flag) {
                                this.addSuccessNoLock(value);
                            }
                        }
                        return flag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.addMany = function (values) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(values, null))) {
                            var list = new Array();
                            for (var _i = 0, values_2 = values; _i < values_2.length; _i++) {
                                var local = values_2[_i];
                                if (!fm.icelink.ArrayExtensions.contains(this.__values, local)) {
                                    fm.icelink.ArrayExtensions.add(this.__values, local);
                                    this.__valuesCache = this.arrayFromList(this.__values);
                                    fm.icelink.ArrayExtensions.add(list, local);
                                    this.addSuccess(local);
                                }
                            }
                            for (var _a = 0, list_1 = list; _a < list_1.length; _a++) {
                                var local2 = list_1[_a];
                                this.addSuccessNoLock(local2);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.addSuccess = function (value) {
                    if (arguments.length == 1) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.addSuccessNoLock = function (value) {
                    if (arguments.length == 1) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.any = function () {
                    if (arguments.length == 0) {
                        return this.any(null);
                    }
                    else if (arguments.length == 1) {
                        var predicate = arguments[0];
                        for (var _i = 0, _a = this.__values; _i < _a.length; _i++) {
                            var local = _a[_i];
                            if (!((fm.icelink.Global.equals(predicate, null)) ? false : !predicate(local))) {
                                return true;
                            }
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.contains = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(value, null))) {
                            return fm.icelink.ArrayExtensions.contains(this.__values, value);
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.first = function () {
                    if (arguments.length == 0) {
                        var local = this.firstOrDefault();
                        if ((fm.icelink.Global.equals(local, null))) {
                            throw new fm.icelink.Exception("The collection does not contain any values.");
                        }
                        return local;
                    }
                    else if (arguments.length == 1) {
                        var predicate = arguments[0];
                        var local = this.firstOrDefault(predicate);
                        if ((fm.icelink.Global.equals(local, null))) {
                            throw new fm.icelink.Exception("The collection does not contain any matching values.");
                        }
                        return local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.firstOrDefault = function () {
                    if (arguments.length == 0) {
                        return this.firstOrDefault(null);
                    }
                    else if (arguments.length == 1) {
                        var predicate = arguments[0];
                        for (var i = 0; (i < fm.icelink.ArrayExtensions.getCount(this.__values)); i++) {
                            var p = this.__values[i];
                            if (!((fm.icelink.Global.equals(predicate, null)) ? false : !predicate(p))) {
                                return p;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.forEach = function (callback) {
                    if (arguments.length == 1) {
                        var num = 0;
                        for (var _i = 0, _a = this.getValues(); _i < _a.length; _i++) {
                            var local = _a[_i];
                            callback(local, num++);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.getCount = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ArrayExtensions.getCount(this.__values);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.getValue = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.ArrayExtensions.getCount(this.__values) > 0)) {
                            return this.__values[0];
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.getValues = function () {
                    if (arguments.length == 0) {
                        return this.__valuesCache;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.last = function () {
                    if (arguments.length == 0) {
                        var local = this.lastOrDefault();
                        if ((fm.icelink.Global.equals(local, null))) {
                            throw new fm.icelink.Exception("The collection does not contain any values.");
                        }
                        return local;
                    }
                    else if (arguments.length == 1) {
                        var predicate = arguments[0];
                        var local = this.lastOrDefault(predicate);
                        if ((fm.icelink.Global.equals(local, null))) {
                            throw new fm.icelink.Exception("The collection does not contain any matching values.");
                        }
                        return local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.lastOrDefault = function () {
                    if (arguments.length == 0) {
                        return this.lastOrDefault(null);
                    }
                    else if (arguments.length == 1) {
                        var predicate = arguments[0];
                        for (var i = (fm.icelink.ArrayExtensions.getCount(this.__values) - 1); (i > -1); i--) {
                            var p = this.__values[i];
                            if (!((fm.icelink.Global.equals(predicate, null)) ? false : !predicate(p))) {
                                return p;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.remove = function (value) {
                    if (arguments.length == 1) {
                        var flag = false;
                        if ((!fm.icelink.Global.equals(value, null))) {
                            if (fm.icelink.ArrayExtensions.remove(this.__values, value)) {
                                this.__valuesCache = this.arrayFromList(this.__values);
                                flag = true;
                                this.removeSuccess(value);
                            }
                            if (flag) {
                                this.removeSuccessNoLock(value);
                            }
                        }
                        return flag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.removeAll = function () {
                    if (arguments.length == 0) {
                        var localArray = void 0;
                        localArray = this.arrayFromList(this.__values);
                        this.__values = new Array();
                        this.__valuesCache = this.arrayFromList(this.__values);
                        for (var _i = 0, localArray_1 = localArray; _i < localArray_1.length; _i++) {
                            var local = localArray_1[_i];
                            this.removeSuccess(local);
                        }
                        for (var _a = 0, localArray_2 = localArray; _a < localArray_2.length; _a++) {
                            var local = localArray_2[_a];
                            this.removeSuccessNoLock(local);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.removeFirst = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.ArrayExtensions.getCount(this.__values) > 0)) {
                            var local = this.__values[0];
                            this.remove(local);
                            return local;
                        }
                        return null;
                    }
                    else if (arguments.length == 1) {
                        var condition = arguments[0];
                        for (var i = 0; (i < fm.icelink.ArrayExtensions.getCount(this.__values)); i++) {
                            var p = this.__values[i];
                            if (condition(p)) {
                                return p;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.removeLast = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.ArrayExtensions.getCount(this.__values) > 0)) {
                            var local = this.__values[(fm.icelink.ArrayExtensions.getCount(this.__values) - 1)];
                            this.remove(local);
                            return local;
                        }
                        return null;
                    }
                    else if (arguments.length == 1) {
                        var condition = arguments[0];
                        for (var i = (fm.icelink.ArrayExtensions.getCount(this.__values) - 1); (i >= 0); i++) {
                            var p = this.__values[i];
                            if (condition(p)) {
                                return p;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.removeMany = function (values) {
                    if (arguments.length == 1) {
                        if (((!fm.icelink.Global.equals(values, null)) && (values.length > 0))) {
                            var list = new Array();
                            for (var _i = 0, values_3 = values; _i < values_3.length; _i++) {
                                var local = values_3[_i];
                                if (fm.icelink.ArrayExtensions.remove(this.__values, local)) {
                                    this.__valuesCache = this.arrayFromList(this.__values);
                                    fm.icelink.ArrayExtensions.add(list, local);
                                    this.removeSuccess(local);
                                }
                            }
                            for (var _a = 0, list_2 = list; _a < list_2.length; _a++) {
                                var local2 = list_2[_a];
                                this.removeSuccessNoLock(local2);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.removeSuccess = function (value) {
                    if (arguments.length == 1) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.removeSuccessNoLock = function (value) {
                    if (arguments.length == 1) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.replace = function (values) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.clear(this.__values);
                        if ((!fm.icelink.Global.equals(values, null))) {
                            fm.icelink.ArrayExtensions.addRange(this.__values, values);
                        }
                        this.__valuesCache = this.arrayFromList(this.__values);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.setValue = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.clear(this.__values);
                        if ((!fm.icelink.Global.equals(value, null))) {
                            fm.icelink.ArrayExtensions.add(this.__values, value);
                        }
                        this.__valuesCache = this.arrayFromList(this.__values);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.setValues = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.clear(this.__values);
                        if ((!fm.icelink.Global.equals(value, null))) {
                            fm.icelink.ArrayExtensions.addRange(this.__values, value);
                        }
                        this.__valuesCache = this.arrayFromList(this.__values);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.single = function () {
                    if (arguments.length == 0) {
                        var local = this.singleOrDefault();
                        if ((fm.icelink.Global.equals(local, null))) {
                            throw new fm.icelink.Exception("The collection does not contain a single value.");
                        }
                        return local;
                    }
                    else if (arguments.length == 1) {
                        var predicate = arguments[0];
                        var local = this.singleOrDefault(predicate);
                        if ((fm.icelink.Global.equals(local, null))) {
                            throw new fm.icelink.Exception("The collection does not contain a single matching value.");
                        }
                        return local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.singleOrDefault = function () {
                    if (arguments.length == 0) {
                        return this.singleOrDefault(null);
                    }
                    else if (arguments.length == 1) {
                        var predicate = arguments[0];
                        var local = null;
                        var flag = false;
                        for (var i = 0; (i < fm.icelink.ArrayExtensions.getCount(this.__values)); i++) {
                            var p = this.__values[i];
                            if (!((fm.icelink.Global.equals(predicate, null)) ? false : !predicate(p))) {
                                if (flag) {
                                    throw new fm.icelink.Exception("Collection contains more than one matching element.");
                                }
                                local = p;
                                flag = true;
                            }
                        }
                        return local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.toArray = function () {
                    if (arguments.length == 0) {
                        return this.arrayFromList(this.__values);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.valueAt = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        var local = this.valueAtOrDefault(index);
                        if ((fm.icelink.Global.equals(local, null))) {
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Value does not exist at index {0}.", fm.icelink.NumberExtensions.toString(index)));
                        }
                        return local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.valueAtOrDefault = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if ((index < fm.icelink.ArrayExtensions.getCount(this.__values))) {
                            for (var i = 0; (i < fm.icelink.ArrayExtensions.getCount(this.__values)); i++) {
                                if ((fm.icelink.Global.equals(i, index))) {
                                    return this.__values[i];
                                }
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Collection.prototype.where = function (predicate) {
                    if (arguments.length == 1) {
                        var local = this.createCollection();
                        for (var i = 0; (i < fm.icelink.ArrayExtensions.getCount(this.__values)); i++) {
                            var local2 = this.__values[i];
                            if (!((fm.icelink.Global.equals(predicate, null)) ? false : !predicate(local2, i))) {
                                local.add(local2);
                            }
                        }
                        return local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Collection;
            }());
            icelink.Collection = Collection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DiagnosticSampler =  (function () {
                function DiagnosticSampler() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        __arguments = new Array(1);
                        __arguments[0] = null;
                        {
                            var label = __arguments[0];
                            __arguments = new Array(2);
                            __arguments[0] = 100;
                            __arguments[1] = label;
                            {
                                var averageSampleCount = __arguments[0];
                                var label_1 = __arguments[1];
                                this.fmicelinkDiagnosticSamplerInit();
                                this.setLastValue(0);
                                this.setLabel(label_1);
                                this.__min = new fm.icelink.AtomicLong(9223372036854775807);
                                this.__max = new fm.icelink.AtomicLong();
                                this.__count = new fm.icelink.AtomicLong();
                                this.__sum = new fm.icelink.AtomicLong();
                                this.__arrayPointer = new fm.icelink.AtomicInteger();
                                this.__samples = new Array(averageSampleCount);
                            }
                        }
                    }
                    else if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                        var averageSampleCount = __arguments[0];
                        __arguments = new Array(2);
                        __arguments[0] = averageSampleCount;
                        __arguments[1] = null;
                        {
                            var averageSampleCount_1 = __arguments[0];
                            var label = __arguments[1];
                            this.fmicelinkDiagnosticSamplerInit();
                            this.setLastValue(0);
                            this.setLabel(label);
                            this.__min = new fm.icelink.AtomicLong(9223372036854775807);
                            this.__max = new fm.icelink.AtomicLong();
                            this.__count = new fm.icelink.AtomicLong();
                            this.__sum = new fm.icelink.AtomicLong();
                            this.__arrayPointer = new fm.icelink.AtomicInteger();
                            this.__samples = new Array(averageSampleCount_1);
                        }
                    }
                    else if (__arguments.length == 2) {
                        var averageSampleCount = __arguments[0];
                        var label = __arguments[1];
                        this.fmicelinkDiagnosticSamplerInit();
                        this.setLastValue(0);
                        this.setLabel(label);
                        this.__min = new fm.icelink.AtomicLong(9223372036854775807);
                        this.__max = new fm.icelink.AtomicLong();
                        this.__count = new fm.icelink.AtomicLong();
                        this.__sum = new fm.icelink.AtomicLong();
                        this.__arrayPointer = new fm.icelink.AtomicInteger();
                        this.__samples = new Array(averageSampleCount);
                    }
                    else if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var label = __arguments[0];
                        __arguments = new Array(2);
                        __arguments[0] = 100;
                        __arguments[1] = label;
                        {
                            var averageSampleCount = __arguments[0];
                            var label_2 = __arguments[1];
                            this.fmicelinkDiagnosticSamplerInit();
                            this.setLastValue(0);
                            this.setLabel(label_2);
                            this.__min = new fm.icelink.AtomicLong(9223372036854775807);
                            this.__max = new fm.icelink.AtomicLong();
                            this.__count = new fm.icelink.AtomicLong();
                            this.__sum = new fm.icelink.AtomicLong();
                            this.__arrayPointer = new fm.icelink.AtomicInteger();
                            this.__samples = new Array(averageSampleCount);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                DiagnosticSampler.prototype.getTypeString = function () {
                    return '[fm.icelink.DiagnosticSampler]';
                };
                DiagnosticSampler.prototype.fmicelinkDiagnosticSamplerInit = function () {
                    this._lastValue = 0;
                };
                DiagnosticSampler.prototype.addSample = function (longSample) {
                    if (arguments.length == 1) {
                        longSample = fm.icelink.Global.toInt(arguments[0]);
                        this.setLastValue(longSample);
                        this.__count.increment();
                        this.__sum.add(longSample);
                        var index = (this.__arrayPointer.increment() % this.__samples.length);
                        this.__samples[index] = longSample;
                        if ((this.__min.getValue() > longSample)) {
                            var num2 = this.__min.getValue();
                            for (var i = fm.icelink.MathAssistant.min(num2, longSample); (!fm.icelink.Global.equals(this.__min.compareAndSwap(num2, i), num2)); i = fm.icelink.MathAssistant.min(num2, longSample)) {
                                num2 = this.__min.getValue();
                            }
                        }
                        if ((this.__max.getValue() < longSample)) {
                            var num4 = this.__max.getValue();
                            for (var j = fm.icelink.MathAssistant.max(num4, longSample); (!fm.icelink.Global.equals(this.__max.compareAndSwap(num4, j), num4)); j = fm.icelink.MathAssistant.max(num4, longSample)) {
                                num4 = this.__max.getValue();
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DiagnosticSampler.prototype.getAverage = function () {
                    if (arguments.length == 0) {
                        var num = fm.icelink.MathAssistant.min(this.__samples.length, this.getCount());
                        var num2 = 0;
                        for (var i = 0; (i < num); i++) {
                            num2 = (num2 + this.__samples[i]);
                        }
                        return (num2 / num);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DiagnosticSampler.prototype.getCount = function () {
                    if (arguments.length == 0) {
                        return this.__count.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DiagnosticSampler.prototype.getLabel = function () {
                    if (arguments.length == 0) {
                        return this._label;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DiagnosticSampler.prototype.getLastValue = function () {
                    if (arguments.length == 0) {
                        return this._lastValue;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DiagnosticSampler.prototype.getMax = function () {
                    if (arguments.length == 0) {
                        return this.__max.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DiagnosticSampler.prototype.getMin = function () {
                    if (arguments.length == 0) {
                        return this.__min.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DiagnosticSampler.prototype.getSamplesInAverage = function () {
                    if (arguments.length == 0) {
                        return this.__samples.length;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DiagnosticSampler.prototype.getSum = function () {
                    if (arguments.length == 0) {
                        return this.__sum.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DiagnosticSampler.prototype.setLabel = function (value) {
                    if (arguments.length == 1) {
                        this._label = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DiagnosticSampler.prototype.setLastValue = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._lastValue = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DiagnosticSampler;
            }());
            icelink.DiagnosticSampler = DiagnosticSampler;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Iso8601Timestamp =  (function () {
                function Iso8601Timestamp() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Iso8601Timestamp.prototype.getTypeString = function () {
                    return '[fm.icelink.Iso8601Timestamp]';
                };
                Iso8601Timestamp.dateTimeToIso8601 = function (dateTime) {
                    if (arguments.length == 1) {
                        var str = fm.icelink.NumberExtensions.toString(dateTime.getYear());
                        var str2 = fm.icelink.NumberExtensions.toString(dateTime.getMonth());
                        var str3 = fm.icelink.NumberExtensions.toString(dateTime.getDay());
                        var str4 = fm.icelink.NumberExtensions.toString(dateTime.getHour());
                        var str5 = fm.icelink.NumberExtensions.toString(dateTime.getMinute());
                        var str6 = fm.icelink.NumberExtensions.toString(dateTime.getSecond());
                        var str7 = fm.icelink.NumberExtensions.toString(dateTime.getMillisecond());
                        while ((fm.icelink.StringExtensions.getLength(str) < 4)) {
                            str = fm.icelink.StringExtensions.concat("0", str);
                        }
                        while ((fm.icelink.StringExtensions.getLength(str2) < 2)) {
                            str2 = fm.icelink.StringExtensions.concat("0", str2);
                        }
                        while ((fm.icelink.StringExtensions.getLength(str3) < 2)) {
                            str3 = fm.icelink.StringExtensions.concat("0", str3);
                        }
                        while ((fm.icelink.StringExtensions.getLength(str4) < 2)) {
                            str4 = fm.icelink.StringExtensions.concat("0", str4);
                        }
                        while ((fm.icelink.StringExtensions.getLength(str5) < 2)) {
                            str5 = fm.icelink.StringExtensions.concat("0", str5);
                        }
                        while ((fm.icelink.StringExtensions.getLength(str6) < 2)) {
                            str6 = fm.icelink.StringExtensions.concat("0", str6);
                        }
                        while ((fm.icelink.StringExtensions.getLength(str7) < 3)) {
                            str7 = fm.icelink.StringExtensions.concat("0", str7);
                        }
                        return fm.icelink.StringExtensions.format("{0}-{1}-{2}T{3}:{4}:{5}.{6}Z", [str, str2, str3, str4, str5, str6, str7]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Iso8601Timestamp.getMinimumNeedleIndex = function (haystack, needles) {
                    if (arguments.length == 2) {
                        var num = -1;
                        for (var _i = 0, needles_1 = needles; _i < needles_1.length; _i++) {
                            var str = needles_1[_i];
                            var index = fm.icelink.StringExtensions.indexOf(haystack, str);
                            if ((!fm.icelink.Global.equals(index, -1))) {
                                if ((fm.icelink.Global.equals(num, -1))) {
                                    num = index;
                                }
                                else {
                                    num = fm.icelink.MathAssistant.min(num, index);
                                }
                            }
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Iso8601Timestamp.getUtcNow = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Iso8601Timestamp.dateTimeToIso8601(fm.icelink.DateTime.getUtcNow());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Iso8601Timestamp.iso8601ToDateTime = function (iso8601) {
                    if (arguments.length == 1) {
                        var year = 0;
                        var month = 0;
                        var day = 0;
                        var hour = 0;
                        var minute = 0;
                        var second = 0;
                        var millisecond = 0;
                        var num8 = 0;
                        var num9 = 0;
                        var offset = 0;
                        var _var0 = new fm.icelink.Holder(offset);
                        var _var1 = new fm.icelink.Holder(year);
                        var _var2 = new fm.icelink.Holder(month);
                        var _var3 = new fm.icelink.Holder(day);
                        var _var4 = fm.icelink.Iso8601Timestamp.tryParseDate(iso8601, offset, _var0, _var1, _var2, _var3);
                        offset = _var0.getValue();
                        year = _var1.getValue();
                        month = _var2.getValue();
                        day = _var3.getValue();
                        var _var5 = new fm.icelink.Holder(offset);
                        var _var6 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, "T", _var5);
                        offset = _var5.getValue();
                        var _var7 = new fm.icelink.Holder(offset);
                        var _var8 = new fm.icelink.Holder(hour);
                        var _var9 = new fm.icelink.Holder(minute);
                        var _var10 = new fm.icelink.Holder(second);
                        var _var11 = new fm.icelink.Holder(millisecond);
                        var _var12 = fm.icelink.Iso8601Timestamp.tryParseTime(iso8601, offset, _var7, _var8, _var9, _var10, _var11);
                        offset = _var7.getValue();
                        hour = _var8.getValue();
                        minute = _var9.getValue();
                        second = _var10.getValue();
                        millisecond = _var11.getValue();
                        if (((_var4 && _var6) && _var12)) {
                            var _var13 = new fm.icelink.Holder(offset);
                            var _var14 = new fm.icelink.Holder(num8);
                            var _var15 = new fm.icelink.Holder(num9);
                            fm.icelink.Iso8601Timestamp.tryParseTimezone(iso8601, offset, _var13, _var14, _var15);
                            offset = _var13.getValue();
                            num8 = _var14.getValue();
                            num9 = _var15.getValue();
                        }
                        var time2 = new fm.icelink.DateTime(year, month, day, hour, minute, second, millisecond);
                        return time2.addHours(num8).addMinutes(num9);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Iso8601Timestamp.tryParseDate = function (iso8601, offset, offsetPlus, year, month, day) {
                    if (arguments.length == 6) {
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        year.setValue(1970);
                        month.setValue(1);
                        day.setValue(1);
                        var str = null;
                        var str2 = null;
                        var str3 = null;
                        var _var0 = new fm.icelink.Holder(str);
                        var _var1 = new fm.icelink.Holder(offset);
                        var _var2 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, 4, _var0, _var1);
                        str = _var0.getValue();
                        offset = _var1.getValue();
                        if (_var2) {
                            var _var3 = new fm.icelink.Holder(offset);
                            fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, "-", _var3);
                            offset = _var3.getValue();
                            var _var5 = new fm.icelink.Holder(str2);
                            var _var6 = new fm.icelink.Holder(offset);
                            var _var7 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, 2, _var5, _var6);
                            str2 = _var5.getValue();
                            offset = _var6.getValue();
                            if (_var7) {
                                var _var8 = new fm.icelink.Holder(offset);
                                fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, "-", _var8);
                                offset = _var8.getValue();
                                var _var10 = new fm.icelink.Holder(str3);
                                var _var11 = new fm.icelink.Holder(offset);
                                fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, 2, _var10, _var11);
                                str3 = _var10.getValue();
                                offset = _var11.getValue();
                            }
                        }
                        var _var13 = fm.icelink.ParseAssistant.tryParseIntegerValue(str, year);
                        if (!((fm.icelink.Global.equals(str, null)) || _var13)) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        var _var14 = fm.icelink.ParseAssistant.tryParseIntegerValue(str2, month);
                        if (!((fm.icelink.Global.equals(str2, null)) || _var14)) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        var _var15 = fm.icelink.ParseAssistant.tryParseIntegerValue(str3, day);
                        if (!((fm.icelink.Global.equals(str3, null)) || _var15)) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        offsetPlus.setValue(offset);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Iso8601Timestamp.tryParseTime = function (iso8601, offset, offsetPlus, hour, minute, second, millisecond) {
                    if (arguments.length == 7) {
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        hour.setValue(0);
                        minute.setValue(0);
                        second.setValue(0);
                        millisecond.setValue(0);
                        var str = null;
                        var str2 = null;
                        var str3 = null;
                        var s = null;
                        var terminalStrings = ["Z", "+", "-"];
                        var _var0 = new fm.icelink.Holder(str);
                        var _var1 = new fm.icelink.Holder(offset);
                        var _var2 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, 2, terminalStrings, _var0, _var1);
                        str = _var0.getValue();
                        offset = _var1.getValue();
                        if (_var2) {
                            var _var3 = new fm.icelink.Holder(offset);
                            fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, ":", _var3);
                            offset = _var3.getValue();
                            var _var5 = new fm.icelink.Holder(str2);
                            var _var6 = new fm.icelink.Holder(offset);
                            var _var7 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, 2, terminalStrings, _var5, _var6);
                            str2 = _var5.getValue();
                            offset = _var6.getValue();
                            if (_var7) {
                                var _var8 = new fm.icelink.Holder(offset);
                                fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, ":", _var8);
                                offset = _var8.getValue();
                                var _var10 = new fm.icelink.Holder(str3);
                                var _var11 = new fm.icelink.Holder(offset);
                                var _var12 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, 2, terminalStrings, _var10, _var11);
                                str3 = _var10.getValue();
                                offset = _var11.getValue();
                                var _var13 = new fm.icelink.Holder(offset);
                                var _var14 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, ".", _var13);
                                offset = _var13.getValue();
                                if ((_var12 && _var14)) {
                                    var str5 = null;
                                    var _var15 = new fm.icelink.Holder(str5);
                                    var _var16 = new fm.icelink.Holder(offset);
                                    var _var17 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, terminalStrings, _var15, _var16);
                                    str5 = _var15.getValue();
                                    offset = _var16.getValue();
                                    if (_var17) {
                                        if ((fm.icelink.StringExtensions.getLength(str5) < 3)) {
                                            for (s = str5; (fm.icelink.StringExtensions.getLength(s) < 3); s = fm.icelink.StringExtensions.concat(s, "0")) {
                                            }
                                        }
                                        else {
                                            s = fm.icelink.StringExtensions.substring(str5, 0, 3);
                                        }
                                    }
                                }
                            }
                        }
                        var _var18 = fm.icelink.ParseAssistant.tryParseIntegerValue(str, hour);
                        if (!((fm.icelink.Global.equals(str, null)) || _var18)) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        var _var19 = fm.icelink.ParseAssistant.tryParseIntegerValue(str2, minute);
                        if (!((fm.icelink.Global.equals(str2, null)) || _var19)) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        var _var20 = fm.icelink.ParseAssistant.tryParseIntegerValue(str3, second);
                        if (!((fm.icelink.Global.equals(str3, null)) || _var20)) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        var _var21 = fm.icelink.ParseAssistant.tryParseIntegerValue(s, millisecond);
                        if (!((fm.icelink.Global.equals(s, null)) || _var21)) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        offsetPlus.setValue(offset);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Iso8601Timestamp.tryParseTimezone = function (iso8601, offset, offsetPlus, hour, minute) {
                    if (arguments.length == 5) {
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        var flag = void 0;
                        hour.setValue(0);
                        minute.setValue(0);
                        var _var0 = new fm.icelink.Holder(offset);
                        var _var1 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, "Z", _var0);
                        offset = _var0.getValue();
                        if (_var1) {
                            offsetPlus.setValue(offset);
                            return true;
                        }
                        var str = null;
                        var str2 = null;
                        var _var2 = new fm.icelink.Holder(offset);
                        var _var3 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, "+", _var2);
                        offset = _var2.getValue();
                        if (_var3) {
                            flag = false;
                        }
                        else {
                            var _var4 = new fm.icelink.Holder(offset);
                            var _var5 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, "-", _var4);
                            offset = _var4.getValue();
                            if (_var5) {
                                flag = true;
                            }
                            else {
                                offsetPlus.setValue(offset);
                                return false;
                            }
                        }
                        var _var6 = new fm.icelink.Holder(str);
                        var _var7 = new fm.icelink.Holder(offset);
                        var _var8 = fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, 2, _var6, _var7);
                        str = _var6.getValue();
                        offset = _var7.getValue();
                        if (_var8) {
                            var _var9 = new fm.icelink.Holder(offset);
                            fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, ":", _var9);
                            offset = _var9.getValue();
                            var _var11 = new fm.icelink.Holder(str2);
                            var _var12 = new fm.icelink.Holder(offset);
                            fm.icelink.Iso8601Timestamp.tryRead(iso8601, offset, 2, _var11, _var12);
                            str2 = _var11.getValue();
                            offset = _var12.getValue();
                        }
                        var _var14 = fm.icelink.ParseAssistant.tryParseIntegerValue(str, hour);
                        if (!((fm.icelink.Global.equals(str, null)) || _var14)) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        var _var15 = fm.icelink.ParseAssistant.tryParseIntegerValue(str2, minute);
                        if (!((fm.icelink.Global.equals(str2, null)) || _var15)) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        if (flag) {
                            hour.setValue(-hour.getValue());
                            minute.setValue(-minute.getValue());
                        }
                        offsetPlus.setValue(offset);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Iso8601Timestamp.tryRead = function () {
                    if (arguments.length == 6) {
                        var input = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var count = fm.icelink.Global.toInt(arguments[2]);
                        var terminalStrings = arguments[3];
                        var value = arguments[4];
                        var offsetPlus = arguments[5];
                        if ((fm.icelink.Global.equals(count, -1))) {
                            if ((offset > fm.icelink.StringExtensions.getLength(input))) {
                                value.setValue(null);
                                offsetPlus.setValue(offset);
                                return false;
                            }
                            value.setValue(input.substring(offset));
                            offsetPlus.setValue((offset + fm.icelink.StringExtensions.getLength(value.getValue())));
                            if (((!fm.icelink.Global.equals(terminalStrings, null)) && (!fm.icelink.Global.equals(terminalStrings.length, 0)))) {
                                var minimumNeedleIndex = fm.icelink.Iso8601Timestamp.getMinimumNeedleIndex(value.getValue(), terminalStrings);
                                if ((fm.icelink.Global.equals(minimumNeedleIndex, -1))) {
                                    return true;
                                }
                                value.setValue(fm.icelink.StringExtensions.substring(input, offset, minimumNeedleIndex));
                                offsetPlus.setValue((offset + fm.icelink.StringExtensions.getLength(value.getValue())));
                            }
                            return true;
                        }
                        if (((offset + count) > fm.icelink.StringExtensions.getLength(input))) {
                            value.setValue(null);
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        value.setValue(fm.icelink.StringExtensions.substring(input, offset, count));
                        offsetPlus.setValue((offset + fm.icelink.StringExtensions.getLength(value.getValue())));
                        return (((fm.icelink.Global.equals(terminalStrings, null)) || (fm.icelink.Global.equals(terminalStrings.length, 0))) || (fm.icelink.Global.equals(fm.icelink.Iso8601Timestamp.getMinimumNeedleIndex(value.getValue(), terminalStrings), -1)));
                    }
                    else if (arguments.length == 5 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || fm.icelink.Util.isNumber(arguments[2]))) {
                        var input = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var count = fm.icelink.Global.toInt(arguments[2]);
                        var value = arguments[3];
                        var offsetPlus = arguments[4];
                        var _var0 = fm.icelink.Iso8601Timestamp.tryRead(input, offset, count, null, value, offsetPlus);
                        return _var0;
                    }
                    else if (arguments.length == 5 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || (fm.icelink.Util.isArray(arguments[2]) && (arguments[2].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[2][0]) || fm.icelink.Util.isString(arguments[2][0])))))) {
                        var input = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var terminalStrings = arguments[2];
                        var value = arguments[3];
                        var offsetPlus = arguments[4];
                        var _var0 = fm.icelink.Iso8601Timestamp.tryRead(input, offset, -1, terminalStrings, value, offsetPlus);
                        return _var0;
                    }
                    else if (arguments.length == 4) {
                        var input = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var value = arguments[2];
                        var offsetPlus = arguments[3];
                        if (((offset + fm.icelink.StringExtensions.getLength(value)) > fm.icelink.StringExtensions.getLength(input))) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        if ((!fm.icelink.Global.equals(fm.icelink.StringExtensions.substring(input, offset, fm.icelink.StringExtensions.getLength(value)), value))) {
                            offsetPlus.setValue(offset);
                            return false;
                        }
                        offsetPlus.setValue((offset + fm.icelink.StringExtensions.getLength(value)));
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Iso8601Timestamp;
            }());
            icelink.Iso8601Timestamp = Iso8601Timestamp;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var JsonCheckerModeWrapper =  (function () {
                function JsonCheckerModeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_3 = __arguments[0];
                        this._value = value_3;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                JsonCheckerModeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.JsonCheckerModeWrapper]';
                };
                JsonCheckerModeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.JsonCheckerMode.Array)
                            return 'Array';
                        if (this._value == fm.icelink.JsonCheckerMode.Done)
                            return 'Done';
                        if (this._value == fm.icelink.JsonCheckerMode.Key)
                            return 'Key';
                        if (this._value == fm.icelink.JsonCheckerMode.Object)
                            return 'Object';
                        if (this._value == fm.icelink.JsonCheckerMode.String)
                            return 'String';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return JsonCheckerModeWrapper;
            }());
            icelink.JsonCheckerModeWrapper = JsonCheckerModeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ManagedCountdownLatch =  (function () {
                function ManagedCountdownLatch() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.reset();
                    }
                    else if (__arguments.length == 1) {
                        var initialCount = __arguments[0];
                        this.reset(initialCount);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                ManagedCountdownLatch.prototype.getTypeString = function () {
                    return '[fm.icelink.ManagedCountdownLatch]';
                };
                ManagedCountdownLatch.prototype.decrement = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(this.__counter.decrement(), 0))) {
                            this.__waitPromise.resolveAsync(null);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedCountdownLatch.prototype.getCount = function () {
                    if (arguments.length == 0) {
                        return this.__counter.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedCountdownLatch.prototype.reset = function () {
                    if (arguments.length == 0) {
                        this.__counter = new fm.icelink.AtomicInteger();
                        this.__waitPromise = new fm.icelink.Promise();
                    }
                    else if (arguments.length == 1) {
                        var initialCount = fm.icelink.Global.toInt(arguments[0]);
                        this.__counter = new fm.icelink.AtomicInteger(initialCount);
                        this.__waitPromise = new fm.icelink.Promise();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedCountdownLatch.prototype.setCount = function (count) {
                    if (arguments.length == 1) {
                        count = fm.icelink.Global.toInt(arguments[0]);
                        if ((fm.icelink.Global.equals(this.__counter.add(count), 0))) {
                            this.__waitPromise.resolveAsync(null);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedCountdownLatch.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.format("Countdown Latch ({0})", fm.icelink.NumberExtensions.toString(this.getCount()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedCountdownLatch.prototype.waitAsync = function () {
                    if (arguments.length == 0) {
                        if ((this.__counter.getValue() <= 0)) {
                            return fm.icelink.PromiseBase.resolveNow(null);
                        }
                        return this.__waitPromise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ManagedCountdownLatch;
            }());
            icelink.ManagedCountdownLatch = ManagedCountdownLatch;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var OperatingSystemWrapper =  (function () {
                function OperatingSystemWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_4 = __arguments[0];
                        this._value = value_4;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                OperatingSystemWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.OperatingSystemWrapper]';
                };
                OperatingSystemWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.OperatingSystem.Unknown)
                            return 'Unknown';
                        if (this._value == fm.icelink.OperatingSystem.Windows)
                            return 'Windows';
                        if (this._value == fm.icelink.OperatingSystem.Android)
                            return 'Android';
                        if (this._value == fm.icelink.OperatingSystem.MacOS)
                            return 'MacOS';
                        if (this._value == fm.icelink.OperatingSystem.IOS)
                            return 'IOS';
                        if (this._value == fm.icelink.OperatingSystem.Linux)
                            return 'Linux';
                        if (this._value == fm.icelink.OperatingSystem.TvOS)
                            return 'TvOS';
                        if (this._value == fm.icelink.OperatingSystem.WatchOS)
                            return 'WatchOS';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return OperatingSystemWrapper;
            }());
            icelink.OperatingSystemWrapper = OperatingSystemWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ArchitectureWrapper =  (function () {
                function ArchitectureWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_5 = __arguments[0];
                        this._value = value_5;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                ArchitectureWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.ArchitectureWrapper]';
                };
                ArchitectureWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.Architecture.Unknown)
                            return 'Unknown';
                        if (this._value == fm.icelink.Architecture.X86)
                            return 'X86';
                        if (this._value == fm.icelink.Architecture.X64)
                            return 'X64';
                        if (this._value == fm.icelink.Architecture.Armv7)
                            return 'Armv7';
                        if (this._value == fm.icelink.Architecture.Armv8)
                            return 'Armv8';
                        if (this._value == fm.icelink.Architecture.Arm64)
                            return 'Arm64';
                        if (this._value == fm.icelink.Architecture.Mips)
                            return 'Mips';
                        if (this._value == fm.icelink.Architecture.Mips64)
                            return 'Mips64';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ArchitectureWrapper;
            }());
            icelink.ArchitectureWrapper = ArchitectureWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Pool =  (function () {
                function Pool() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var createObject = __arguments[0];
                        __arguments = new Array(2);
                        __arguments[0] = createObject;
                        __arguments[1] = 0;
                        {
                            var createObject_1 = __arguments[0];
                            var minSize = __arguments[1];
                            __arguments = new Array(3);
                            __arguments[0] = createObject_1;
                            __arguments[1] = minSize;
                            __arguments[2] = 2147483647;
                            {
                                var createObject_2 = __arguments[0];
                                var minSize_1 = __arguments[1];
                                var maxSize = __arguments[2];
                                this.fmicelinkPoolInit();
                                this.__destroyLock = new Object();
                                this.__isDestroyed = false;
                                if ((fm.icelink.Global.equals(createObject_2, null))) {
                                    throw new fm.icelink.Exception("Cannot initialize pool without a function to create objects.");
                                }
                                if ((minSize_1 < 0)) {
                                    throw new fm.icelink.Exception("Minimum pool size cannot be less than zero.");
                                }
                                if ((maxSize < 0)) {
                                    throw new fm.icelink.Exception("Maximum pool size cannot be less than zero.");
                                }
                                if ((minSize_1 > maxSize)) {
                                    throw new fm.icelink.Exception("Minimum pool size cannot be greater than maximum pool size.");
                                }
                                this.__createObject = createObject_2;
                                this.setMinSize(minSize_1);
                                this.setMaxSize(maxSize);
                                this.__stack = new fm.icelink.ManagedConcurrentStack();
                                this.__createObjectCounter = new fm.icelink.AtomicInteger();
                                for (var i = 0; (i < this.getMinSize()); i++) {
                                    this.__createObjectCounter.increment();
                                    this.__stack.push(this.__createObject());
                                }
                            }
                        }
                    }
                    else if (__arguments.length == 2) {
                        var createObject = __arguments[0];
                        var minSize = __arguments[1];
                        __arguments = new Array(3);
                        __arguments[0] = createObject;
                        __arguments[1] = minSize;
                        __arguments[2] = 2147483647;
                        {
                            var createObject_3 = __arguments[0];
                            var minSize_2 = __arguments[1];
                            var maxSize = __arguments[2];
                            this.fmicelinkPoolInit();
                            this.__destroyLock = new Object();
                            this.__isDestroyed = false;
                            if ((fm.icelink.Global.equals(createObject_3, null))) {
                                throw new fm.icelink.Exception("Cannot initialize pool without a function to create objects.");
                            }
                            if ((minSize_2 < 0)) {
                                throw new fm.icelink.Exception("Minimum pool size cannot be less than zero.");
                            }
                            if ((maxSize < 0)) {
                                throw new fm.icelink.Exception("Maximum pool size cannot be less than zero.");
                            }
                            if ((minSize_2 > maxSize)) {
                                throw new fm.icelink.Exception("Minimum pool size cannot be greater than maximum pool size.");
                            }
                            this.__createObject = createObject_3;
                            this.setMinSize(minSize_2);
                            this.setMaxSize(maxSize);
                            this.__stack = new fm.icelink.ManagedConcurrentStack();
                            this.__createObjectCounter = new fm.icelink.AtomicInteger();
                            for (var i = 0; (i < this.getMinSize()); i++) {
                                this.__createObjectCounter.increment();
                                this.__stack.push(this.__createObject());
                            }
                        }
                    }
                    else if (__arguments.length == 3) {
                        var createObject = __arguments[0];
                        var minSize = __arguments[1];
                        var maxSize = __arguments[2];
                        this.fmicelinkPoolInit();
                        this.__destroyLock = new Object();
                        this.__isDestroyed = false;
                        if ((fm.icelink.Global.equals(createObject, null))) {
                            throw new fm.icelink.Exception("Cannot initialize pool without a function to create objects.");
                        }
                        if ((minSize < 0)) {
                            throw new fm.icelink.Exception("Minimum pool size cannot be less than zero.");
                        }
                        if ((maxSize < 0)) {
                            throw new fm.icelink.Exception("Maximum pool size cannot be less than zero.");
                        }
                        if ((minSize > maxSize)) {
                            throw new fm.icelink.Exception("Minimum pool size cannot be greater than maximum pool size.");
                        }
                        this.__createObject = createObject;
                        this.setMinSize(minSize);
                        this.setMaxSize(maxSize);
                        this.__stack = new fm.icelink.ManagedConcurrentStack();
                        this.__createObjectCounter = new fm.icelink.AtomicInteger();
                        for (var i = 0; (i < this.getMinSize()); i++) {
                            this.__createObjectCounter.increment();
                            this.__stack.push(this.__createObject());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Pool.prototype.getTypeString = function () {
                    return '[fm.icelink.Pool]';
                };
                Pool.prototype.fmicelinkPoolInit = function () {
                    this.__isDestroyed = false;
                    this._maxSize = 0;
                    this._minSize = 0;
                };
                Pool.prototype.destroy = function (destroyCallback) {
                    if (arguments.length == 1) {
                        this.__isDestroyed = true;
                        var result = null;
                        var _var0 = new fm.icelink.Holder(result);
                        var _var1 = this.__stack.tryPop(_var0);
                        result = _var0.getValue();
                        while (_var1) {
                            destroyCallback(result);
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pool.prototype.get = function () {
                    if (arguments.length == 0) {
                        var result = null;
                        var _var0 = new fm.icelink.Holder(result);
                        var _var1 = this.__stack.tryPop(_var0);
                        result = _var0.getValue();
                        if (_var1) {
                            return result;
                        }
                        if ((this.__createObjectCounter.increment() > this.getMaxSize())) {
                            this.__createObjectCounter.decrement();
                            throw new fm.icelink.Exception("Could not create pooled object. Maximum size reached.");
                        }
                        return this.__createObject();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pool.prototype.getAvailable = function () {
                    if (arguments.length == 0) {
                        return this.__stack.getCount();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pool.prototype.getMaxSize = function () {
                    if (arguments.length == 0) {
                        return this._maxSize;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pool.prototype.getMinSize = function () {
                    if (arguments.length == 0) {
                        return this._minSize;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pool.prototype.getSize = function () {
                    if (arguments.length == 0) {
                        return this.__createObjectCounter.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pool.prototype.put = function (item) {
                    if (arguments.length == 1) {
                        if (((!fm.icelink.Global.equals(item, null)) && !this.__isDestroyed)) {
                            this.__stack.push(item);
                            return true;
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pool.prototype.setMaxSize = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._maxSize = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pool.prototype.setMinSize = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._minSize = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Pool;
            }());
            icelink.Pool = Pool;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ProtocolTypeWrapper =  (function () {
                function ProtocolTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_6 = __arguments[0];
                        this._value = value_6;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                ProtocolTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.ProtocolTypeWrapper]';
                };
                ProtocolTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.ProtocolType.Udp)
                            return 'Udp';
                        if (this._value == fm.icelink.ProtocolType.Tcp)
                            return 'Tcp';
                        if (this._value == fm.icelink.ProtocolType.Tls)
                            return 'Tls';
                        if (this._value == fm.icelink.ProtocolType.Unknown)
                            return 'Unknown';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ProtocolTypeWrapper;
            }());
            icelink.ProtocolTypeWrapper = ProtocolTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SourceLanguageWrapper =  (function () {
                function SourceLanguageWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_7 = __arguments[0];
                        this._value = value_7;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SourceLanguageWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.SourceLanguageWrapper]';
                };
                SourceLanguageWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.SourceLanguage.CSharp)
                            return 'CSharp';
                        if (this._value == fm.icelink.SourceLanguage.Java)
                            return 'Java';
                        if (this._value == fm.icelink.SourceLanguage.ObjectiveC)
                            return 'ObjectiveC';
                        if (this._value == fm.icelink.SourceLanguage.TypeScript)
                            return 'TypeScript';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SourceLanguageWrapper;
            }());
            icelink.SourceLanguageWrapper = SourceLanguageWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var JsonSerializer =  (function () {
                function JsonSerializer() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                JsonSerializer.prototype.getTypeString = function () {
                    return '[fm.icelink.JsonSerializer]';
                };
                JsonSerializer.charToUnicodeString = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        var ch = fm.icelink.JsonSerializer.intToHex(((value >> 12) & 15));
                        var ch2 = fm.icelink.JsonSerializer.intToHex(((value >> 8) & 15));
                        var ch3 = fm.icelink.JsonSerializer.intToHex(((value >> 4) & 15));
                        var ch4 = fm.icelink.JsonSerializer.intToHex((value & 15));
                        return fm.icelink.StringExtensions.concat(["\\u", String.fromCharCode(ch), String.fromCharCode(ch2), String.fromCharCode(ch3), String.fromCharCode(ch4)]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeBoolean = function (valueJson) {
                    if (arguments.length == 1) {
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(valueJson)) {
                            valueJson = fm.icelink.StringExtensions.trim(valueJson);
                            if ((fm.icelink.Global.equals(valueJson, "null"))) {
                                return null;
                            }
                            var boolResult = false;
                            var _var0 = new fm.icelink.Holder(boolResult);
                            var _var1 = fm.icelink.ParseAssistant.tryParseBooleanValue(valueJson, _var0);
                            boolResult = _var0.getValue();
                            if (_var1) {
                                return boolResult;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeBooleanArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                            return null;
                        }
                        arrayJson = fm.icelink.StringExtensions.trim(arrayJson);
                        if ((fm.icelink.Global.equals(arrayJson, "null"))) {
                            return null;
                        }
                        var flagArray = null;
                        if ((fm.icelink.Global.equals(arrayJson.charCodeAt(0), 91))) {
                            arrayJson = fm.icelink.StringExtensions.substring(arrayJson, 1, (fm.icelink.StringExtensions.getLength(arrayJson) - 2));
                            if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                                flagArray = new Array(0);
                            }
                            else {
                                var strArray = fm.icelink.StringExtensions.split(arrayJson, [44]);
                                flagArray = new Array(strArray.length);
                                for (var i = 0; (i < strArray.length); i++) {
                                    flagArray[i] = fm.icelink.JsonSerializer.deserializeBoolean(fm.icelink.StringExtensions.trim(strArray[i]));
                                }
                            }
                        }
                        return flagArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeDecimal = function (valueJson) {
                    if (arguments.length == 1) {
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(valueJson)) {
                            valueJson = fm.icelink.StringExtensions.trim(valueJson);
                            if ((fm.icelink.Global.equals(valueJson, "null"))) {
                                return null;
                            }
                            var decimalResult = 0;
                            var _var0 = new fm.icelink.Holder(decimalResult);
                            var _var1 = fm.icelink.ParseAssistant.tryParseDecimalValue(valueJson, _var0);
                            decimalResult = _var0.getValue();
                            if (_var1) {
                                return decimalResult;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeDecimalArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                            return null;
                        }
                        arrayJson = fm.icelink.StringExtensions.trim(arrayJson);
                        if ((fm.icelink.Global.equals(arrayJson, "null"))) {
                            return null;
                        }
                        var numArray = null;
                        if ((fm.icelink.Global.equals(arrayJson.charCodeAt(0), 91))) {
                            arrayJson = fm.icelink.StringExtensions.substring(arrayJson, 1, (fm.icelink.StringExtensions.getLength(arrayJson) - 2));
                            if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                                numArray = new Array(0);
                            }
                            else {
                                var strArray = fm.icelink.StringExtensions.split(arrayJson, [44]);
                                numArray = new Array(strArray.length);
                                for (var i = 0; (i < strArray.length); i++) {
                                    numArray[i] = fm.icelink.JsonSerializer.deserializeDecimal(fm.icelink.StringExtensions.trim(strArray[i]));
                                }
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeDictionary = function (dictionaryJson, createDictionaryCallback, deserializeValueCallback) {
                    if (arguments.length == 3) {
                        return fm.icelink.JsonSerializer.deserializeObject(dictionaryJson, createDictionaryCallback, function (dictionary, key, valueJson) {
                            dictionary[key] = deserializeValueCallback(valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeDouble = function (valueJson) {
                    if (arguments.length == 1) {
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(valueJson)) {
                            valueJson = fm.icelink.StringExtensions.trim(valueJson);
                            if ((fm.icelink.Global.equals(valueJson, "null"))) {
                                return null;
                            }
                            var doubleResult = 0;
                            var _var0 = new fm.icelink.Holder(doubleResult);
                            var _var1 = fm.icelink.ParseAssistant.tryParseDoubleValue(valueJson, _var0);
                            doubleResult = _var0.getValue();
                            if (_var1) {
                                return doubleResult;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeDoubleArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                            return null;
                        }
                        arrayJson = fm.icelink.StringExtensions.trim(arrayJson);
                        if ((fm.icelink.Global.equals(arrayJson, "null"))) {
                            return null;
                        }
                        var numArray = null;
                        if ((fm.icelink.Global.equals(arrayJson.charCodeAt(0), 91))) {
                            arrayJson = fm.icelink.StringExtensions.substring(arrayJson, 1, (fm.icelink.StringExtensions.getLength(arrayJson) - 2));
                            if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                                numArray = new Array(0);
                            }
                            else {
                                var strArray = fm.icelink.StringExtensions.split(arrayJson, [44]);
                                numArray = new Array(strArray.length);
                                for (var i = 0; (i < strArray.length); i++) {
                                    numArray[i] = fm.icelink.JsonSerializer.deserializeDouble(fm.icelink.StringExtensions.trim(strArray[i]));
                                }
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeFloat = function (valueJson) {
                    if (arguments.length == 1) {
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(valueJson)) {
                            valueJson = fm.icelink.StringExtensions.trim(valueJson);
                            if ((fm.icelink.Global.equals(valueJson, "null"))) {
                                return null;
                            }
                            var floatResult = 0;
                            var _var0 = new fm.icelink.Holder(floatResult);
                            var _var1 = fm.icelink.ParseAssistant.tryParseFloatValue(valueJson, _var0);
                            floatResult = _var0.getValue();
                            if (_var1) {
                                return floatResult;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeFloatArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                            return null;
                        }
                        arrayJson = fm.icelink.StringExtensions.trim(arrayJson);
                        if ((fm.icelink.Global.equals(arrayJson, "null"))) {
                            return null;
                        }
                        var numArray = null;
                        if ((fm.icelink.Global.equals(arrayJson.charCodeAt(0), 91))) {
                            arrayJson = fm.icelink.StringExtensions.substring(arrayJson, 1, (fm.icelink.StringExtensions.getLength(arrayJson) - 2));
                            if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                                numArray = new Array(0);
                            }
                            else {
                                var strArray = fm.icelink.StringExtensions.split(arrayJson, [44]);
                                numArray = new Array(strArray.length);
                                for (var i = 0; (i < strArray.length); i++) {
                                    numArray[i] = fm.icelink.JsonSerializer.deserializeFloat(fm.icelink.StringExtensions.trim(strArray[i]));
                                }
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeGuid = function (valueJson) {
                    if (arguments.length == 1) {
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(valueJson)) {
                            valueJson = fm.icelink.StringExtensions.trim(valueJson);
                            if ((fm.icelink.Global.equals(valueJson, "null"))) {
                                return null;
                            }
                            var empty = fm.icelink.Guid.empty;
                            var _var0 = new fm.icelink.Holder(empty);
                            var _var1 = fm.icelink.ParseAssistant.tryParseGuidValue(fm.icelink.JsonSerializer.deserializeString(valueJson), _var0);
                            empty = _var0.getValue();
                            if (_var1) {
                                return empty;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeGuidArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                            return null;
                        }
                        arrayJson = fm.icelink.StringExtensions.trim(arrayJson);
                        if ((fm.icelink.Global.equals(arrayJson, "null"))) {
                            return null;
                        }
                        var guidArray = null;
                        if ((fm.icelink.Global.equals(arrayJson.charCodeAt(0), 91))) {
                            arrayJson = fm.icelink.StringExtensions.substring(arrayJson, 1, (fm.icelink.StringExtensions.getLength(arrayJson) - 2));
                            if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                                guidArray = new Array(0);
                            }
                            else {
                                var strArray = fm.icelink.StringExtensions.split(arrayJson, [44]);
                                guidArray = new Array(strArray.length);
                                for (var i = 0; (i < strArray.length); i++) {
                                    guidArray[i] = fm.icelink.JsonSerializer.deserializeGuid(fm.icelink.StringExtensions.trim(strArray[i]));
                                }
                            }
                        }
                        return guidArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeInteger = function (valueJson) {
                    if (arguments.length == 1) {
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(valueJson)) {
                            valueJson = fm.icelink.StringExtensions.trim(valueJson);
                            if ((fm.icelink.Global.equals(valueJson, "null"))) {
                                return null;
                            }
                            var intResult = 0;
                            var _var0 = new fm.icelink.Holder(intResult);
                            var _var1 = fm.icelink.ParseAssistant.tryParseIntegerValue(valueJson, _var0);
                            intResult = _var0.getValue();
                            if (_var1) {
                                return intResult;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeIntegerArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                            return null;
                        }
                        arrayJson = fm.icelink.StringExtensions.trim(arrayJson);
                        if ((fm.icelink.Global.equals(arrayJson, "null"))) {
                            return null;
                        }
                        var numArray = null;
                        if ((fm.icelink.Global.equals(arrayJson.charCodeAt(0), 91))) {
                            arrayJson = fm.icelink.StringExtensions.substring(arrayJson, 1, (fm.icelink.StringExtensions.getLength(arrayJson) - 2));
                            if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                                numArray = new Array(0);
                            }
                            else {
                                var strArray = fm.icelink.StringExtensions.split(arrayJson, [44]);
                                numArray = new Array(strArray.length);
                                for (var i = 0; (i < strArray.length); i++) {
                                    numArray[i] = fm.icelink.JsonSerializer.deserializeInteger(fm.icelink.StringExtensions.trim(strArray[i]));
                                }
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeLong = function (valueJson) {
                    if (arguments.length == 1) {
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(valueJson)) {
                            valueJson = fm.icelink.StringExtensions.trim(valueJson);
                            if ((fm.icelink.Global.equals(valueJson, "null"))) {
                                return null;
                            }
                            var longResult = 0;
                            var _var0 = new fm.icelink.Holder(longResult);
                            var _var1 = fm.icelink.ParseAssistant.tryParseLongValue(valueJson, _var0);
                            longResult = _var0.getValue();
                            if (_var1) {
                                return longResult;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeLongArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                            return null;
                        }
                        arrayJson = fm.icelink.StringExtensions.trim(arrayJson);
                        if ((fm.icelink.Global.equals(arrayJson, "null"))) {
                            return null;
                        }
                        var numArray = null;
                        if ((fm.icelink.Global.equals(arrayJson.charCodeAt(0), 91))) {
                            arrayJson = fm.icelink.StringExtensions.substring(arrayJson, 1, (fm.icelink.StringExtensions.getLength(arrayJson) - 2));
                            if (fm.icelink.StringExtensions.isNullOrEmpty(arrayJson)) {
                                numArray = new Array(0);
                            }
                            else {
                                var strArray = fm.icelink.StringExtensions.split(arrayJson, [44]);
                                numArray = new Array(strArray.length);
                                for (var i = 0; (i < strArray.length); i++) {
                                    numArray[i] = fm.icelink.JsonSerializer.deserializeLong(fm.icelink.StringExtensions.trim(strArray[i]));
                                }
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeObject = function (json, creator, callback) {
                    if (arguments.length == 3) {
                        if ((fm.icelink.Global.equals(json, null))) {
                            return null;
                        }
                        json = fm.icelink.StringExtensions.trim(json);
                        if (((fm.icelink.Global.equals(json, "null")) || (fm.icelink.StringExtensions.getLength(json) < 2))) {
                            return null;
                        }
                        var local = creator();
                        if ((((fm.icelink.Global.equals(json.charCodeAt(0), 123)) && (fm.icelink.Global.equals(json.charCodeAt((fm.icelink.StringExtensions.getLength(json) - 1)), 125))) && (fm.icelink.StringExtensions.getLength(json) > 2))) {
                            json = fm.icelink.StringExtensions.concat(fm.icelink.StringExtensions.substring(json, 1, (fm.icelink.StringExtensions.getLength(json) - 2)), ",");
                            var num = 0;
                            var num2 = 0;
                            var flag = false;
                            var num3 = -2;
                            var none = fm.icelink.StringType.None;
                            var startIndex = 0;
                            var num5 = 0;
                            var valueJson = fm.icelink.StringExtensions.empty;
                            var str2 = fm.icelink.StringExtensions.empty;
                            for (var i = 0; (i < fm.icelink.StringExtensions.getLength(json)); i++) {
                                var ch = json.charCodeAt(i);
                                var flag2 = (fm.icelink.Global.equals(num3, (i - 1)));
                                var flag3 = false;
                                if (!flag) {
                                    var _var0 = ch;
                                    do {
                                        if (_var0 == 91) {
                                            num2++;
                                            flag3 = true;
                                            break;
                                        }
                                        else if (_var0 == 93) {
                                            num2--;
                                            flag3 = true;
                                            break;
                                        }
                                        else if (_var0 == 123) {
                                            num++;
                                            flag3 = true;
                                            break;
                                        }
                                        else if (_var0 == 125) {
                                            num--;
                                            flag3 = true;
                                            break;
                                        }
                                    } while (false);
                                }
                                if (!flag3) {
                                    if ((flag && !((!fm.icelink.Global.equals(ch, 92)) || flag2))) {
                                        num3 = i;
                                        flag3 = true;
                                    }
                                    if (!flag3) {
                                        if (((fm.icelink.Global.equals(num, 0)) && (fm.icelink.Global.equals(num2, 0)))) {
                                            var _var1 = ch;
                                            do {
                                                if (_var1 == 44) {
                                                    if (!flag) {
                                                        str2 = fm.icelink.StringExtensions.trim(fm.icelink.StringExtensions.substring(json, num5, (i - num5)));
                                                        callback(local, fm.icelink.JsonSerializer.deserializeString(valueJson), str2);
                                                        startIndex = (i + 1);
                                                    }
                                                    flag3 = true;
                                                    break;
                                                }
                                                else if (_var1 == 58) {
                                                    if (!flag) {
                                                        valueJson = fm.icelink.StringExtensions.trim(fm.icelink.StringExtensions.substring(json, startIndex, (i - startIndex)));
                                                        num5 = (i + 1);
                                                    }
                                                    flag3 = true;
                                                    break;
                                                }
                                            } while (false);
                                        }
                                        if ((!flag3 && (((fm.icelink.Global.equals(ch, 39)) || (fm.icelink.Global.equals(ch, 34))) && !flag2))) {
                                            var type2 = ((fm.icelink.Global.equals(ch, 34)) ? fm.icelink.StringType.Double : fm.icelink.StringType.Single);
                                            if (!flag) {
                                                flag = true;
                                                none = type2;
                                            }
                                            else {
                                                if ((fm.icelink.Global.equals(none, type2))) {
                                                    flag = false;
                                                    none = fm.icelink.StringType.None;
                                                }
                                            }
                                            flag3 = true;
                                        }
                                    }
                                }
                            }
                        }
                        return local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeObjectArray = function (json, deserializer) {
                    if (arguments.length == 2) {
                        var list = fm.icelink.JsonSerializer.deserializeRawArray(json);
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        var list2 = new Array();
                        for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
                            var str = list_3[_i];
                            var item = deserializer(str);
                            fm.icelink.ArrayExtensions.add(list2, item);
                        }
                        return list2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeObjectFast = function (json, creator, callback) {
                    if (arguments.length == 3) {
                        var local = fm.icelink.JsonSerializer.deserializeObject(json, creator, callback);
                        if ((!fm.icelink.Global.equals(local, null))) {
                            local.setSerialized(json);
                        }
                        return local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeRaw = function (dataJson) {
                    if (arguments.length == 1) {
                        if (fm.icelink.StringExtensions.isNullOrEmpty(dataJson)) {
                            return null;
                        }
                        return fm.icelink.StringExtensions.trim(dataJson);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeRawArray = function (json) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(json, null))) {
                            return null;
                        }
                        json = fm.icelink.StringExtensions.trim(json);
                        if (((fm.icelink.Global.equals(json, "null")) || (fm.icelink.StringExtensions.getLength(json) < 2))) {
                            return null;
                        }
                        var list = new Array();
                        if ((((fm.icelink.Global.equals(json.charCodeAt(0), 91)) && (fm.icelink.Global.equals(json.charCodeAt((fm.icelink.StringExtensions.getLength(json) - 1)), 93))) && (fm.icelink.StringExtensions.getLength(json) > 2))) {
                            var num = 0;
                            var startIndex = 0;
                            var flag = false;
                            var num3 = -2;
                            var none = fm.icelink.StringType.None;
                            for (var i = 1; (i < (fm.icelink.StringExtensions.getLength(json) - 1)); i++) {
                                var ch = json.charCodeAt(i);
                                var flag2 = (fm.icelink.Global.equals(num3, (i - 1)));
                                if (!flag) {
                                    var _var0 = ch;
                                    do {
                                        if (_var0 == 123) {
                                            if ((fm.icelink.Global.equals(num, 0))) {
                                                startIndex = i;
                                            }
                                            num++;
                                            break;
                                        }
                                        else if (_var0 == 125) {
                                            num--;
                                            if ((fm.icelink.Global.equals(num, 0))) {
                                                fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.substring(json, startIndex, ((i - startIndex) + 1)));
                                            }
                                            break;
                                        }
                                    } while (false);
                                }
                                if ((flag && !((!fm.icelink.Global.equals(ch, 92)) || flag2))) {
                                    num3 = i;
                                }
                                else {
                                    if ((((fm.icelink.Global.equals(ch, 39)) || (fm.icelink.Global.equals(ch, 34))) && !flag2)) {
                                        var type2 = ((fm.icelink.Global.equals(ch, 34)) ? fm.icelink.StringType.Double : fm.icelink.StringType.Single);
                                        if (!flag) {
                                            flag = true;
                                            none = type2;
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(none, type2))) {
                                                flag = false;
                                                none = fm.icelink.StringType.None;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        return list;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeString = function (valueJson) {
                    if (arguments.length == 1) {
                        if (fm.icelink.StringExtensions.isNullOrEmpty(valueJson)) {
                            return null;
                        }
                        valueJson = fm.icelink.StringExtensions.trim(valueJson);
                        if ((fm.icelink.Global.equals(valueJson, "null"))) {
                            return null;
                        }
                        var flag = (fm.icelink.StringExtensions.startsWith(valueJson, "\"") || fm.icelink.StringExtensions.startsWith(valueJson, "'"));
                        var flag2 = (fm.icelink.StringExtensions.endsWith(valueJson, "\"") || fm.icelink.StringExtensions.endsWith(valueJson, "'"));
                        if (!(flag && flag2)) {
                            return null;
                        }
                        return fm.icelink.JsonSerializer.unescapeString(fm.icelink.JsonSerializer.trimQuotes(valueJson));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.deserializeStringArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(arrayJson, null))) {
                            return null;
                        }
                        var str = null;
                        var list = new Array();
                        var str2 = "array-start";
                        for (var i = 0; (i < fm.icelink.StringExtensions.getLength(arrayJson)); i++) {
                            var ch = arrayJson.charCodeAt(i);
                            var _var0 = str2;
                            do {
                                if (_var0 == "array-start") {
                                    if ((fm.icelink.Global.equals(ch, 91))) {
                                        str2 = "value-start";
                                    }
                                    else {
                                        if (((((!fm.icelink.Global.equals(ch, 32)) && (fm.icelink.Global.equals(ch, 9))) && (!fm.icelink.Global.equals(ch, 10))) && (!fm.icelink.Global.equals(ch, 13)))) {
                                            return null;
                                        }
                                    }
                                    break;
                                }
                                else if (_var0 == "value-start") {
                                    if ((fm.icelink.Global.equals(ch, 93))) {
                                        str2 = "array-end";
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(ch, 34))) {
                                            str = "";
                                            str2 = "in-string";
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(ch, 110))) {
                                                str = null;
                                                str2 = "in-null-n";
                                            }
                                            else {
                                                if (((((!fm.icelink.Global.equals(ch, 32)) && (!fm.icelink.Global.equals(ch, 9))) && (!fm.icelink.Global.equals(ch, 10))) && (!fm.icelink.Global.equals(ch, 13)))) {
                                                    return null;
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                                else if (_var0 == "in-null-n") {
                                    if ((!fm.icelink.Global.equals(ch, 117))) {
                                        return null;
                                    }
                                    str2 = "in-null-nu";
                                    break;
                                }
                                else if (_var0 == "in-null-nu") {
                                    if ((fm.icelink.Global.equals(ch, 108))) {
                                        str2 = "in-null-nul";
                                        break;
                                    }
                                    return null;
                                }
                                else if (_var0 == "in-null-nul") {
                                    if ((fm.icelink.Global.equals(ch, 108))) {
                                        fm.icelink.ArrayExtensions.add(list, null);
                                        str2 = "value-end";
                                        break;
                                    }
                                    return null;
                                }
                                else if (_var0 == "in-string") {
                                    if ((fm.icelink.Global.equals(ch, 34))) {
                                        fm.icelink.ArrayExtensions.add(list, fm.icelink.JsonSerializer.unescapeString(fm.icelink.JsonSerializer.trimQuotes(fm.icelink.StringExtensions.trim(str))));
                                        str = null;
                                        str2 = "value-end";
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(ch, 92))) {
                                            str = fm.icelink.StringExtensions.concat(str, "\\");
                                            str2 = "in-string-escape";
                                        }
                                        else {
                                            str = fm.icelink.StringExtensions.concat(str, String.fromCharCode(ch));
                                        }
                                    }
                                    break;
                                }
                                else if (_var0 == "in-string-escape") {
                                    str = fm.icelink.StringExtensions.concat(str, String.fromCharCode(ch));
                                    str2 = "in-string";
                                    break;
                                }
                                else if (_var0 == "value-end") {
                                    if ((fm.icelink.Global.equals(ch, 44))) {
                                        str2 = "value-start";
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(ch, 93))) {
                                            str2 = "array-end";
                                        }
                                        else {
                                            if (((((!fm.icelink.Global.equals(ch, 32)) && (!fm.icelink.Global.equals(ch, 9))) && (!fm.icelink.Global.equals(ch, 10))) && (!fm.icelink.Global.equals(ch, 13)))) {
                                                return null;
                                            }
                                        }
                                    }
                                    break;
                                }
                                else {
                                    if (((fm.icelink.Global.equals(str2, "array-end")) && ((((!fm.icelink.Global.equals(ch, 32)) && (!fm.icelink.Global.equals(ch, 9))) && (!fm.icelink.Global.equals(ch, 10))) && (!fm.icelink.Global.equals(ch, 13))))) {
                                        return null;
                                    }
                                    break;
                                }
                            } while (false);
                        }
                        if ((!fm.icelink.Global.equals(str2, "array-end"))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.escapeString = function (text) {
                    if (arguments.length == 1) {
                        var builder = new fm.icelink.StringBuilder();
                        var startIndex = -1;
                        for (var i = 0; (i < fm.icelink.StringExtensions.getLength(text)); i++) {
                            var ch = text.charCodeAt(i);
                            if ((ch > 126)) {
                                if ((!fm.icelink.Global.equals(startIndex, -1))) {
                                    builder.append(text, startIndex, (i - startIndex));
                                    startIndex = -1;
                                }
                                builder.append(fm.icelink.JsonSerializer.charToUnicodeString(ch));
                            }
                            else {
                                var _var0 = ch;
                                do {
                                    if (_var0 == 8) {
                                        if ((!fm.icelink.Global.equals(startIndex, -1))) {
                                            builder.append(text, startIndex, (i - startIndex));
                                            startIndex = -1;
                                        }
                                        builder.append("\\b");
                                        break;
                                    }
                                    else if (_var0 == 12) {
                                        if ((!fm.icelink.Global.equals(startIndex, -1))) {
                                            builder.append(text, startIndex, (i - startIndex));
                                            startIndex = -1;
                                        }
                                        builder.append("\\f");
                                        break;
                                    }
                                    else if (_var0 == 10) {
                                        if ((!fm.icelink.Global.equals(startIndex, -1))) {
                                            builder.append(text, startIndex, (i - startIndex));
                                            startIndex = -1;
                                        }
                                        builder.append("\\n");
                                        break;
                                    }
                                    else if (_var0 == 13) {
                                        if ((!fm.icelink.Global.equals(startIndex, -1))) {
                                            builder.append(text, startIndex, (i - startIndex));
                                            startIndex = -1;
                                        }
                                        builder.append("\\r");
                                        break;
                                    }
                                    else if (_var0 == 9) {
                                        if ((!fm.icelink.Global.equals(startIndex, -1))) {
                                            builder.append(text, startIndex, (i - startIndex));
                                            startIndex = -1;
                                        }
                                        builder.append("\\t");
                                        break;
                                    }
                                    else if (_var0 == 34) {
                                        if ((!fm.icelink.Global.equals(startIndex, -1))) {
                                            builder.append(text, startIndex, (i - startIndex));
                                            startIndex = -1;
                                        }
                                        builder.append("\\\"");
                                        break;
                                    }
                                    else if (_var0 == 47) {
                                        if ((!fm.icelink.Global.equals(startIndex, -1))) {
                                            builder.append(text, startIndex, (i - startIndex));
                                            startIndex = -1;
                                        }
                                        builder.append("\\/");
                                        break;
                                    }
                                    else if (_var0 == 92) {
                                        if ((!fm.icelink.Global.equals(startIndex, -1))) {
                                            builder.append(text, startIndex, (i - startIndex));
                                            startIndex = -1;
                                        }
                                        builder.append("\\\\");
                                        break;
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(startIndex, -1))) {
                                            startIndex = i;
                                        }
                                        break;
                                    }
                                } while (false);
                            }
                        }
                        if ((!fm.icelink.Global.equals(startIndex, -1))) {
                            builder.append(text, startIndex, (fm.icelink.StringExtensions.getLength(text) - startIndex));
                        }
                        return builder.toString();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.intToHex = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        if ((value <= 9)) {
                            return (value + 48);
                        }
                        return ((value - 10) + 97);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.isValidJson = function (json) {
                    if (arguments.length == 1) {
                        return new fm.icelink.JsonChecker().checkString(json);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeBoolean = function (value) {
                    if (arguments.length == 1) {
                        if (!(value != null)) {
                            return "null";
                        }
                        if (value) {
                            return "true";
                        }
                        return "false";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeBooleanArray = function (array) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(array, null))) {
                            return "null";
                        }
                        var strArray = new Array(array.length);
                        for (var i = 0; (i < array.length); i++) {
                            strArray[i] = fm.icelink.JsonSerializer.serializeBoolean(array[i]);
                        }
                        return fm.icelink.StringExtensions.concat("[", fm.icelink.StringExtensions.join(",", strArray), "]");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeDecimal = function (value) {
                    if (arguments.length == 1) {
                        if (!(value != null)) {
                            return "null";
                        }
                        return fm.icelink.NumberExtensions.toString(value, fm.icelink.CultureInfo.getInvariantCulture());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeDecimalArray = function (array) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(array, null))) {
                            return "null";
                        }
                        var strArray = new Array(array.length);
                        for (var i = 0; (i < array.length); i++) {
                            strArray[i] = fm.icelink.JsonSerializer.serializeDecimal(array[i]);
                        }
                        return fm.icelink.StringExtensions.concat("[", fm.icelink.StringExtensions.join(",", strArray), "]");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeDictionary = function (dictionary, serializeValueCallback) {
                    if (arguments.length == 2) {
                        return fm.icelink.JsonSerializer.serializeObject(dictionary, function (d, jsonObject) {
                            for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(d); _i < _a.length; _i++) {
                                var str = _a[_i];
                                jsonObject[str] = serializeValueCallback(d[str]);
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeDouble = function (value) {
                    if (arguments.length == 1) {
                        if (!(value != null)) {
                            return "null";
                        }
                        return fm.icelink.NumberExtensions.toString(value, fm.icelink.CultureInfo.getInvariantCulture());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeDoubleArray = function (array) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(array, null))) {
                            return "null";
                        }
                        var strArray = new Array(array.length);
                        for (var i = 0; (i < array.length); i++) {
                            strArray[i] = fm.icelink.JsonSerializer.serializeDouble(array[i]);
                        }
                        return fm.icelink.StringExtensions.concat("[", fm.icelink.StringExtensions.join(",", strArray), "]");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeFloat = function (value) {
                    if (arguments.length == 1) {
                        if (!(value != null)) {
                            return "null";
                        }
                        return fm.icelink.NumberExtensions.toString(value, fm.icelink.CultureInfo.getInvariantCulture());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeFloatArray = function (array) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(array, null))) {
                            return "null";
                        }
                        var strArray = new Array(array.length);
                        for (var i = 0; (i < array.length); i++) {
                            strArray[i] = fm.icelink.JsonSerializer.serializeFloat(array[i]);
                        }
                        return fm.icelink.StringExtensions.concat("[", fm.icelink.StringExtensions.join(",", strArray), "]");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeGuid = function (value) {
                    if (arguments.length == 1) {
                        if (!(value != null)) {
                            return "null";
                        }
                        return fm.icelink.StringExtensions.concat("\"", value.toString(), "\"");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeGuidArray = function (array) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(array, null))) {
                            return "null";
                        }
                        var strArray = new Array(array.length);
                        for (var i = 0; (i < array.length); i++) {
                            strArray[i] = fm.icelink.JsonSerializer.serializeGuid(array[i]);
                        }
                        return fm.icelink.StringExtensions.concat("[", fm.icelink.StringExtensions.join(",", strArray), "]");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeInteger = function (value) {
                    if (arguments.length == 1) {
                        if (!(value != null)) {
                            return "null";
                        }
                        return fm.icelink.NumberExtensions.toString(value, fm.icelink.CultureInfo.getInvariantCulture());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeIntegerArray = function (array) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(array, null))) {
                            return "null";
                        }
                        var strArray = new Array(array.length);
                        for (var i = 0; (i < array.length); i++) {
                            strArray[i] = fm.icelink.JsonSerializer.serializeInteger(array[i]);
                        }
                        return fm.icelink.StringExtensions.concat("[", fm.icelink.StringExtensions.join(",", strArray), "]");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeLong = function (value) {
                    if (arguments.length == 1) {
                        if (!(value != null)) {
                            return "null";
                        }
                        return fm.icelink.NumberExtensions.toString(value, fm.icelink.CultureInfo.getInvariantCulture());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeLongArray = function (array) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(array, null))) {
                            return "null";
                        }
                        var strArray = new Array(array.length);
                        for (var i = 0; (i < array.length); i++) {
                            strArray[i] = fm.icelink.JsonSerializer.serializeLong(array[i]);
                        }
                        return fm.icelink.StringExtensions.concat("[", fm.icelink.StringExtensions.join(",", strArray), "]");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeObject = function (source, callback) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(source, null))) {
                            return "null";
                        }
                        var dictionary = {};
                        callback(source, dictionary);
                        var list = new Array();
                        for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(dictionary); _i < _a.length; _i++) {
                            var str = _a[_i];
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.concat(fm.icelink.JsonSerializer.serializeString(str), ":", dictionary[str]));
                        }
                        return fm.icelink.StringExtensions.concat("{", fm.icelink.StringExtensions.join(",", fm.icelink.ArrayExtensions.toArray(list)), "}");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeObjectArray = function (objects, serializer) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(objects, null))) {
                            return "null";
                        }
                        if ((fm.icelink.Global.equals(objects.length, 0))) {
                            return "[]";
                        }
                        var strArray = new Array(objects.length);
                        for (var i = 0; (i < objects.length); i++) {
                            strArray[i] = serializer(objects[i]);
                        }
                        return fm.icelink.StringExtensions.concat("[", fm.icelink.StringExtensions.join(",", strArray), "]");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeObjectFast = function (source, callback) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(source, null))) {
                            return "null";
                        }
                        if (!(source.getIsSerialized() && !source.getIsDirty())) {
                            source.setSerialized(fm.icelink.JsonSerializer.serializeObject(source, callback));
                        }
                        return source.getSerialized();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeRaw = function (dataJson) {
                    if (arguments.length == 1) {
                        return dataJson;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeRawArray = function (jsons) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(jsons, null))) {
                            return "null";
                        }
                        return fm.icelink.StringExtensions.concat("[", fm.icelink.StringExtensions.join(",", jsons), "]");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeString = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            return "null";
                        }
                        return fm.icelink.StringExtensions.concat("\"", fm.icelink.JsonSerializer.escapeString(value), "\"");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.serializeStringArray = function (array) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(array, null))) {
                            return "null";
                        }
                        var strArray = new Array(array.length);
                        for (var i = 0; (i < array.length); i++) {
                            strArray[i] = fm.icelink.JsonSerializer.serializeString(array[i]);
                        }
                        return fm.icelink.StringExtensions.concat("[", fm.icelink.StringExtensions.join(",", strArray), "]");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.trimQuotes = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.StringExtensions.getLength(value) > 1)) {
                            var ch = value.charCodeAt(0);
                            var ch2 = value.charCodeAt((fm.icelink.StringExtensions.getLength(value) - 1));
                            if (((fm.icelink.Global.equals(ch, ch2)) && ((fm.icelink.Global.equals(ch, 39)) || (fm.icelink.Global.equals(ch, 34))))) {
                                value = fm.icelink.StringExtensions.substring(value, 1, (fm.icelink.StringExtensions.getLength(value) - 2));
                            }
                        }
                        return value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.unescapeString = function (text) {
                    if (arguments.length == 1) {
                        var builder = new fm.icelink.StringBuilder();
                        var startIndex = -1;
                        for (var i = 0; (i < fm.icelink.StringExtensions.getLength(text)); i++) {
                            var ch = text.charCodeAt(i);
                            if ((fm.icelink.Global.equals(ch, 92))) {
                                if ((!fm.icelink.Global.equals(startIndex, -1))) {
                                    builder.append(text, startIndex, (i - startIndex));
                                    startIndex = -1;
                                }
                                if ((fm.icelink.Global.equals(i, (fm.icelink.StringExtensions.getLength(text) - 1)))) {
                                    continue;
                                }
                                var ch2 = text.charCodeAt((i + 1));
                                var _var0 = ch2;
                                do {
                                    if (_var0 == 98) {
                                        builder.append("\b");
                                        break;
                                    }
                                    else if (_var0 == 102) {
                                        builder.append("\f");
                                        break;
                                    }
                                    else if (_var0 == 110) {
                                        builder.append("\n");
                                        break;
                                    }
                                    else if (_var0 == 114) {
                                        builder.append("\r");
                                        break;
                                    }
                                    else if (_var0 == 116) {
                                        builder.append("\t");
                                        break;
                                    }
                                    else if (_var0 == 47) {
                                        builder.append("/");
                                        break;
                                    }
                                    else if (_var0 == 117) {
                                        if ((i < (fm.icelink.StringExtensions.getLength(text) - 5))) {
                                            builder.append(String.fromCharCode(fm.icelink.JsonSerializer.unicodeStringToChar(fm.icelink.StringExtensions.substring(text, i, 6))));
                                            i = (i + 4);
                                        }
                                        else {
                                            builder.append("u");
                                        }
                                        break;
                                    }
                                    else if (_var0 == 120) {
                                        if ((i < (fm.icelink.StringExtensions.getLength(text) - 3))) {
                                            builder.append(String.fromCharCode(fm.icelink.JsonSerializer.unicodeStringToChar(fm.icelink.StringExtensions.substring(text, i, 4))));
                                            i = (i + 2);
                                        }
                                        else {
                                            builder.append("x");
                                        }
                                        break;
                                    }
                                    else {
                                        builder.append(String.fromCharCode(ch2));
                                        break;
                                    }
                                } while (false);
                                i++;
                                continue;
                            }
                            if ((fm.icelink.Global.equals(startIndex, -1))) {
                                startIndex = i;
                            }
                        }
                        if ((!fm.icelink.Global.equals(startIndex, -1))) {
                            builder.append(text, startIndex, (fm.icelink.StringExtensions.getLength(text) - startIndex));
                        }
                        return builder.toString();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonSerializer.unicodeStringToChar = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.StringExtensions.getLength(value) < 2)) {
                            throw new fm.icelink.Exception("Unicode string has invalid length.");
                        }
                        return fm.icelink.Convert.toInt32(value.substring(2), 16);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return JsonSerializer;
            }());
            icelink.JsonSerializer = JsonSerializer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Serializer =  (function (_super) {
                __extends(Serializer, _super);
                function Serializer() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                Serializer.prototype.getTypeString = function () {
                    return '[fm.icelink.Serializer]' + ',' + _super.prototype.getTypeString.call(this);
                };
                return Serializer;
            }(fm.icelink.JsonSerializer));
            icelink.Serializer = Serializer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StateMachine =  (function () {
                function StateMachine(initialState) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var initialState_1 = __arguments[0];
                        this.fmicelinkStateMachineInit();
                        this.__pendingPromises = {};
                        this.__transitions = {};
                        this.__transitionReachabilityMatrix = {};
                        this.__states = new Array();
                        this.__transitionsLock = new Object();
                        this.setSystemTimestamp(-1);
                        this.setLastStateTicks(-1);
                        this.setStateValue(this.stateToValue(initialState_1));
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                StateMachine.prototype.getTypeString = function () {
                    return '[fm.icelink.StateMachine]';
                };
                StateMachine.prototype.fmicelinkStateMachineInit = function () {
                    this.__stateValue = 0;
                    this._lastStateTicks = 0;
                    this._systemTimestamp = 0;
                };
                StateMachine.prototype.addPendingPromise = function (state, promise, returnValue) {
                    if (arguments.length == 3) {
                        var item = new fm.icelink.PendingPromise(promise, returnValue);
                        var list = null;
                        var _var0 = new fm.icelink.Holder(list);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__pendingPromises, state, _var0);
                        list = _var0.getValue();
                        if (!_var1) {
                            this.__pendingPromises[state] = list = new Array();
                        }
                        fm.icelink.ArrayExtensions.add(list, item);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.addTransition = function (fromState, toState) {
                    if (arguments.length == 2) {
                        var key = fm.icelink.NumberExtensions.toString(this.stateToValue(fromState));
                        var item = fm.icelink.NumberExtensions.toString(this.stateToValue(toState));
                        var list = null;
                        var _var0 = new fm.icelink.Holder(list);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__transitions, key, _var0);
                        list = _var0.getValue();
                        if (!_var1) {
                            this.__transitions[key] = list = new Array();
                        }
                        if (!fm.icelink.ArrayExtensions.contains(list, item)) {
                            fm.icelink.ArrayExtensions.add(list, item);
                        }
                        if (!fm.icelink.ArrayExtensions.contains(this.__states, key)) {
                            fm.icelink.ArrayExtensions.add(this.__states, key);
                        }
                        if (!fm.icelink.ArrayExtensions.contains(this.__states, item)) {
                            fm.icelink.ArrayExtensions.add(this.__states, item);
                        }
                        this.computeTransitionMatrix();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.canTransition = function (toState) {
                    if (arguments.length == 1) {
                        var item = fm.icelink.NumberExtensions.toString(this.stateToValue(toState));
                        var list = null;
                        var _var0 = new fm.icelink.Holder(list);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__transitions, fm.icelink.NumberExtensions.toString(this.getStateValue()), _var0);
                        list = _var0.getValue();
                        if (!_var1) {
                            return false;
                        }
                        return fm.icelink.ArrayExtensions.contains(list, item);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.checkReachable = function (toState) {
                    if (arguments.length == 1) {
                        var str = fm.icelink.NumberExtensions.toString(this.getStateValue());
                        return this.__transitionReachabilityMatrix[str][toState];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.computeTransitionMatrix = function () {
                    if (arguments.length == 0) {
                        fm.icelink.HashExtensions.clear(this.__transitionReachabilityMatrix);
                        for (var _i = 0, _a = this.__states; _i < _a.length; _i++) {
                            var str = _a[_i];
                            var discoveredToStates = {};
                            for (var _b = 0, _c = this.__states; _b < _c.length; _b++) {
                                var str2 = _c[_b];
                                discoveredToStates[str2] = false;
                            }
                            this.exploreStates(str, discoveredToStates);
                            this.__transitionReachabilityMatrix[str] = discoveredToStates;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.exploreStates = function (fromState, discoveredToStates) {
                    if (arguments.length == 2) {
                        var list = null;
                        var _var0 = new fm.icelink.Holder(list);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__transitions, fromState, _var0);
                        list = _var0.getValue();
                        if (_var1) {
                            for (var _i = 0, list_4 = list; _i < list_4.length; _i++) {
                                var str = list_4[_i];
                                if (!discoveredToStates[str]) {
                                    discoveredToStates[str] = true;
                                    this.exploreStates(str, discoveredToStates);
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.getLastStateMillis = function () {
                    if (arguments.length == 0) {
                        var lastStateTicks = this.getLastStateTicks();
                        if ((fm.icelink.Global.equals(lastStateTicks, -1))) {
                            return -1;
                        }
                        return fm.icelink.MathAssistant.floor(lastStateTicks / fm.icelink.Constants.getTicksPerMillisecond());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.getLastStateTicks = function () {
                    if (arguments.length == 0) {
                        return this._lastStateTicks;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.getPromise = function (state, returnValue) {
                    if (arguments.length == 2) {
                        var toState = fm.icelink.NumberExtensions.toString(this.stateToValue(state));
                        var promise = new fm.icelink.Promise();
                        if ((fm.icelink.Global.equals(this.getStateValue(), this.stateToValue(state)))) {
                            promise.resolve(returnValue);
                            return promise;
                        }
                        if (!this.checkReachable(toState)) {
                            promise.reject(new fm.icelink.Exception(fm.icelink.StringExtensions.format("Cannot transition to state {0}.", state.toString())));
                            return promise;
                        }
                        this.addPendingPromise(toState, promise, returnValue);
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.getState = function () {
                    if (arguments.length == 0) {
                        return this.valueToState(this.__stateValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.getStateValue = function () {
                    if (arguments.length == 0) {
                        return this.__stateValue;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.getSystemTimestamp = function () {
                    if (arguments.length == 0) {
                        return this._systemTimestamp;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.isReachable = function (state) {
                    if (arguments.length == 1) {
                        var toState = fm.icelink.NumberExtensions.toString(this.stateToValue(state));
                        return this.checkReachable(toState);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.setLastStateTicks = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._lastStateTicks = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.setStateValue = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        var timestamp = fm.icelink.Global.toInt(fm.icelink.ManagedStopwatch.getTimestamp());
                        if ((!fm.icelink.Global.equals(this.getSystemTimestamp(), -1))) {
                            this.setLastStateTicks((timestamp - this.getSystemTimestamp()));
                        }
                        this.setSystemTimestamp(timestamp);
                        this.__stateValue = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.setSystemTimestamp = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._systemTimestamp = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.transition = function (toState) {
                    if (arguments.length == 1) {
                        if (!this.canTransition(toState)) {
                            return false;
                        }
                        this.setStateValue(this.stateToValue(toState));
                        this.validatePendingPromises();
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StateMachine.prototype.validatePendingPromises = function () {
                    if (arguments.length == 0) {
                        for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(this.__pendingPromises); _i < _a.length; _i++) {
                            var str = _a[_i];
                            if ((fm.icelink.Global.equals(fm.icelink.NumberExtensions.toString(this.getStateValue()), str))) {
                                for (var _b = 0, _c = this.__pendingPromises[str]; _b < _c.length; _b++) {
                                    var promise = _c[_b];
                                    promise.resolve();
                                }
                                fm.icelink.HashExtensions.remove(this.__pendingPromises, str);
                            }
                            else {
                                if (!this.checkReachable(str)) {
                                    for (var _d = 0, _e = this.__pendingPromises[str]; _d < _e.length; _d++) {
                                        var promise = _e[_d];
                                        promise.reject(new fm.icelink.Exception(fm.icelink.StringExtensions.format("Cannot transition to state {0}.", str.toString())));
                                    }
                                    fm.icelink.HashExtensions.remove(this.__pendingPromises, str);
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StateMachine;
            }());
            icelink.StateMachine = StateMachine;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StringTypeWrapper =  (function () {
                function StringTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_8 = __arguments[0];
                        this._value = value_8;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                StringTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.StringTypeWrapper]';
                };
                StringTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.StringType.None)
                            return 'None';
                        if (this._value == fm.icelink.StringType.Single)
                            return 'Single';
                        if (this._value == fm.icelink.StringType.Double)
                            return 'Double';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StringTypeWrapper;
            }());
            icelink.StringTypeWrapper = StringTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LinkedListNode =  (function () {
                function LinkedListNode(item) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var item_1 = __arguments[0];
                        this.setValue(item_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LinkedListNode.prototype.getTypeString = function () {
                    return '[fm.icelink.LinkedListNode]';
                };
                LinkedListNode.prototype.getNext = function () {
                    if (arguments.length == 0) {
                        return this._next;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LinkedListNode.prototype.getPrevious = function () {
                    if (arguments.length == 0) {
                        return this._previous;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LinkedListNode.prototype.getValue = function () {
                    if (arguments.length == 0) {
                        return this._value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LinkedListNode.prototype.setNext = function (value) {
                    if (arguments.length == 1) {
                        this._next = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LinkedListNode.prototype.setPrevious = function (value) {
                    if (arguments.length == 1) {
                        this._previous = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LinkedListNode.prototype.setValue = function (value) {
                    if (arguments.length == 1) {
                        this._value = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LinkedListNode;
            }());
            icelink.LinkedListNode = LinkedListNode;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LinkedListEnumerator =  (function () {
                function LinkedListEnumerator(root) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var root_1 = __arguments[0];
                        this.fmicelinkLinkedListEnumeratorInit();
                        this.__root = root_1;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LinkedListEnumerator.prototype.getTypeString = function () {
                    return '[fm.icelink.LinkedListEnumerator]';
                };
                LinkedListEnumerator.prototype.fmicelinkLinkedListEnumeratorInit = function () {
                    this.__started = false;
                };
                LinkedListEnumerator.prototype.getCurrent = function () {
                    if (arguments.length == 0) {
                        return this.__currentNode.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LinkedListEnumerator.prototype.getCurrentNode = function () {
                    if (arguments.length == 0) {
                        return this.__currentNode;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LinkedListEnumerator.prototype.moveNext = function () {
                    if (arguments.length == 0) {
                        if (!((!fm.icelink.Global.equals(this.__currentNode, null)) || this.__started)) {
                            this.__started = true;
                            this.__currentNode = this.__root;
                        }
                        else {
                            this.__currentNode = this.__currentNode.getNext();
                        }
                        return (!fm.icelink.Global.equals(this.__currentNode, null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LinkedListEnumerator.prototype.reset = function () {
                    if (arguments.length == 0) {
                        this.__started = false;
                        this.__currentNode = null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LinkedListEnumerator;
            }());
            icelink.LinkedListEnumerator = LinkedListEnumerator;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var InternalConcurrentQueue =  (function () {
                function InternalConcurrentQueue() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this._backingData = new Array();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                InternalConcurrentQueue.prototype.getTypeString = function () {
                    return '[fm.icelink.InternalConcurrentQueue]';
                };
                InternalConcurrentQueue.prototype.enqueue = function (item) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this._backingData, item);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentQueue.prototype.getCount = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ArrayExtensions.getCount(this._backingData);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentQueue.prototype.getIsEmpty = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.Global.equals(this.getCount(), 0));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentQueue.prototype.tryDequeue = function (item) {
                    if (arguments.length == 1) {
                        if (this.getIsEmpty()) {
                            item.setValue(null);
                            return false;
                        }
                        item.setValue(this._backingData[0]);
                        fm.icelink.ArrayExtensions.removeAt(this._backingData, 0);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentQueue.prototype.tryPeek = function (item) {
                    if (arguments.length == 1) {
                        if (this.getIsEmpty()) {
                            item.setValue(null);
                            return false;
                        }
                        item.setValue(this._backingData[0]);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return InternalConcurrentQueue;
            }());
            icelink.InternalConcurrentQueue = InternalConcurrentQueue;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var InternalConcurrentStack =  (function () {
                function InternalConcurrentStack() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this._backingData = new Array();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                InternalConcurrentStack.prototype.getTypeString = function () {
                    return '[fm.icelink.InternalConcurrentStack]';
                };
                InternalConcurrentStack.prototype.clear = function () {
                    if (arguments.length == 0) {
                        fm.icelink.ArrayExtensions.clear(this._backingData);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentStack.prototype.getCount = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ArrayExtensions.getCount(this._backingData);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentStack.prototype.getIsEmpty = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.Global.equals(this.getCount(), 0));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentStack.prototype.push = function (item) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this._backingData, item);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentStack.prototype.tryPeek = function (result) {
                    if (arguments.length == 1) {
                        if (this.getIsEmpty()) {
                            result.setValue(null);
                            return false;
                        }
                        result.setValue(this._backingData[(fm.icelink.ArrayExtensions.getCount(this._backingData) - 1)]);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                InternalConcurrentStack.prototype.tryPop = function (result) {
                    if (arguments.length == 1) {
                        if (this.getIsEmpty()) {
                            result.setValue(null);
                            return false;
                        }
                        result.setValue(this._backingData[(fm.icelink.ArrayExtensions.getCount(this._backingData) - 1)]);
                        fm.icelink.ArrayExtensions.removeAt(this._backingData, (fm.icelink.ArrayExtensions.getCount(this._backingData) - 1));
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return InternalConcurrentStack;
            }());
            icelink.InternalConcurrentStack = InternalConcurrentStack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ManagedConcurrentDictionary =  (function () {
                function ManagedConcurrentDictionary() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        __arguments = new Array(1);
                        __arguments[0] = null;
                        {
                            var hashCallback = __arguments[0];
                            if ((fm.icelink.Global.equals(hashCallback, null))) {
                                this.__dictionary = new fm.icelink.InternalConcurrentDictionary(this.hash.bind(this));
                            }
                            else {
                                this.__dictionary = new fm.icelink.InternalConcurrentDictionary(hashCallback);
                            }
                        }
                    }
                    else if (__arguments.length == 1) {
                        var hashCallback = __arguments[0];
                        if ((fm.icelink.Global.equals(hashCallback, null))) {
                            this.__dictionary = new fm.icelink.InternalConcurrentDictionary(this.hash.bind(this));
                        }
                        else {
                            this.__dictionary = new fm.icelink.InternalConcurrentDictionary(hashCallback);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                ManagedConcurrentDictionary.prototype.getTypeString = function () {
                    return '[fm.icelink.ManagedConcurrentDictionary]';
                };
                ManagedConcurrentDictionary.prototype.addOrUpdate = function () {
                    if (arguments.length == 2) {
                        var key = arguments[0];
                        var addValue_1 = arguments[1];
                        return this.__dictionary.addOrUpdate(key, addValue_1, function (k, v) {
                            return addValue_1;
                        });
                    }
                    else if (arguments.length == 3) {
                        var key = arguments[0];
                        var addValue = arguments[1];
                        var updateValueFactory_1 = arguments[2];
                        return this.__dictionary.addOrUpdate(key, addValue, function (k, v) {
                            return updateValueFactory_1(k, v);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.clear = function () {
                    if (arguments.length == 0) {
                        this.__dictionary.clear();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.containsKey = function (key) {
                    if (arguments.length == 1) {
                        return this.__dictionary.containsKey(key);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.getCount = function () {
                    if (arguments.length == 0) {
                        return this.__dictionary.getCount();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.getIsEmpty = function () {
                    if (arguments.length == 0) {
                        return this.__dictionary.getIsEmpty();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.getKeys = function () {
                    if (arguments.length == 0) {
                        return this.__dictionary.getKeys();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.getOrAdd = function (key, valueFactory) {
                    if (arguments.length == 2) {
                        return this.__dictionary.getOrAdd(key, function (k) {
                            return valueFactory(k);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.getValues = function () {
                    if (arguments.length == 0) {
                        return this.__dictionary.getValues();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.hash = function (key) {
                    if (arguments.length == 1) {
                        return key.toString();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.tryAdd = function (key, value) {
                    if (arguments.length == 2) {
                        return this.__dictionary.tryAdd(key, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.tryGetValue = function (key, value) {
                    if (arguments.length == 2) {
                        var _var0 = this.__dictionary.tryGetValue(key, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.tryRemove = function () {
                    if (arguments.length == 1) {
                        var key = arguments[0];
                        var local = null;
                        var _var0 = new fm.icelink.Holder(local);
                        var _var1 = this.__dictionary.tryRemove(key, _var0);
                        local = _var0.getValue();
                        return _var1;
                    }
                    else if (arguments.length == 2) {
                        var key = arguments[0];
                        var value = arguments[1];
                        var _var0 = this.__dictionary.tryRemove(key, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentDictionary.prototype.tryUpdate = function (key, newValue, comparisonValue) {
                    if (arguments.length == 3) {
                        return this.__dictionary.tryUpdate(key, newValue, comparisonValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ManagedConcurrentDictionary;
            }());
            icelink.ManagedConcurrentDictionary = ManagedConcurrentDictionary;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ManagedConcurrentQueue =  (function () {
                function ManagedConcurrentQueue() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.__queue = new fm.icelink.InternalConcurrentQueue();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                ManagedConcurrentQueue.prototype.getTypeString = function () {
                    return '[fm.icelink.ManagedConcurrentQueue]';
                };
                ManagedConcurrentQueue.prototype.enqueue = function (item) {
                    if (arguments.length == 1) {
                        this.__queue.enqueue(item);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentQueue.prototype.getCount = function () {
                    if (arguments.length == 0) {
                        return this.__queue.getCount();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentQueue.prototype.getIsEmpty = function () {
                    if (arguments.length == 0) {
                        return this.__queue.getIsEmpty();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentQueue.prototype.tryDequeue = function (item) {
                    if (arguments.length == 1) {
                        var _var0 = this.__queue.tryDequeue(item);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentQueue.prototype.tryPeek = function (item) {
                    if (arguments.length == 1) {
                        var _var0 = this.__queue.tryPeek(item);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ManagedConcurrentQueue;
            }());
            icelink.ManagedConcurrentQueue = ManagedConcurrentQueue;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ManagedConcurrentStack =  (function () {
                function ManagedConcurrentStack() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.__stack = new fm.icelink.InternalConcurrentStack();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                ManagedConcurrentStack.prototype.getTypeString = function () {
                    return '[fm.icelink.ManagedConcurrentStack]';
                };
                ManagedConcurrentStack.prototype.clear = function () {
                    if (arguments.length == 0) {
                        this.__stack.clear();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentStack.prototype.getCount = function () {
                    if (arguments.length == 0) {
                        return this.__stack.getCount();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentStack.prototype.getIsEmpty = function () {
                    if (arguments.length == 0) {
                        return this.__stack.getIsEmpty();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentStack.prototype.push = function (item) {
                    if (arguments.length == 1) {
                        this.__stack.push(item);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentStack.prototype.tryPeek = function (result) {
                    if (arguments.length == 1) {
                        var _var0 = this.__stack.tryPeek(result);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ManagedConcurrentStack.prototype.tryPop = function (result) {
                    if (arguments.length == 1) {
                        var _var0 = this.__stack.tryPop(result);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ManagedConcurrentStack;
            }());
            icelink.ManagedConcurrentStack = ManagedConcurrentStack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MutablePair =  (function () {
                function MutablePair(item1, item2) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var item1_1 = __arguments[0];
                        var item2_1 = __arguments[1];
                        this.setItem1(item1_1);
                        this.setItem2(item2_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                MutablePair.prototype.getTypeString = function () {
                    return '[fm.icelink.MutablePair]';
                };
                MutablePair.prototype.getItem1 = function () {
                    if (arguments.length == 0) {
                        return this._item1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MutablePair.prototype.getItem2 = function () {
                    if (arguments.length == 0) {
                        return this._item2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MutablePair.prototype.setItem1 = function (value) {
                    if (arguments.length == 1) {
                        this._item1 = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MutablePair.prototype.setItem2 = function (value) {
                    if (arguments.length == 1) {
                        this._item2 = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MutablePair;
            }());
            icelink.MutablePair = MutablePair;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MutableUnit =  (function () {
                function MutableUnit(item) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var item_2 = __arguments[0];
                        this.setItem(item_2);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                MutableUnit.prototype.getTypeString = function () {
                    return '[fm.icelink.MutableUnit]';
                };
                MutableUnit.prototype.getItem = function () {
                    if (arguments.length == 0) {
                        return this._item;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MutableUnit.prototype.setItem = function (value) {
                    if (arguments.length == 1) {
                        this._item = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MutableUnit;
            }());
            icelink.MutableUnit = MutableUnit;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Pair =  (function () {
                function Pair(item1, item2) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var item1_2 = __arguments[0];
                        var item2_2 = __arguments[1];
                        this.setItem1(item1_2);
                        this.setItem2(item2_2);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Pair.prototype.getTypeString = function () {
                    return '[fm.icelink.Pair]';
                };
                Pair.prototype.getHashCode = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.ObjectExtensions.getHashCode(this.getItem1()) + fm.icelink.ObjectExtensions.getHashCode(this.getItem2()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pair.prototype.getItem1 = function () {
                    if (arguments.length == 0) {
                        return this._item1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pair.prototype.getItem2 = function () {
                    if (arguments.length == 0) {
                        return this._item2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pair.prototype.setItem1 = function (value) {
                    if (arguments.length == 1) {
                        this._item1 = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Pair.prototype.setItem2 = function (value) {
                    if (arguments.length == 1) {
                        this._item2 = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Pair;
            }());
            icelink.Pair = Pair;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LogEventLogProvider =  (function (_super) {
                __extends(LogEventLogProvider, _super);
                function LogEventLogProvider() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        __arguments = new Array(1);
                        __arguments[0] = fm.icelink.LogLevel.Info;
                        {
                            var level = __arguments[0];
                            _this = _super.call(this) || this;
                            _this.__events = new Array();
                            _this.__eventsLock = new Object();
                            _super.prototype.setLevel.call(_this, level);
                        }
                    }
                    else if (__arguments.length == 1) {
                        var level = __arguments[0];
                        _this = _super.call(this) || this;
                        _this.__events = new Array();
                        _this.__eventsLock = new Object();
                        _super.prototype.setLevel.call(_this, level);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                LogEventLogProvider.prototype.getTypeString = function () {
                    return '[fm.icelink.LogEventLogProvider]' + ',' + _super.prototype.getTypeString.call(this);
                };
                LogEventLogProvider.prototype.clear = function () {
                    if (arguments.length == 0) {
                        var eventArray = void 0;
                        eventArray = fm.icelink.ArrayExtensions.toArray(this.__events);
                        this.__events = new Array();
                        return eventArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEventLogProvider.prototype.doLog = function (logEvent) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__events, logEvent);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEventLogProvider.prototype.getEvents = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ArrayExtensions.toArray(this.__events);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LogEventLogProvider;
            }(fm.icelink.LogProvider));
            icelink.LogEventLogProvider = LogEventLogProvider;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Triple =  (function () {
                function Triple(item1, item2, item3) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 3) {
                        var item1_3 = __arguments[0];
                        var item2_3 = __arguments[1];
                        var item3_1 = __arguments[2];
                        this.setItem1(item1_3);
                        this.setItem2(item2_3);
                        this.setItem3(item3_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Triple.prototype.getTypeString = function () {
                    return '[fm.icelink.Triple]';
                };
                Triple.prototype.getItem1 = function () {
                    if (arguments.length == 0) {
                        return this._item1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Triple.prototype.getItem2 = function () {
                    if (arguments.length == 0) {
                        return this._item2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Triple.prototype.getItem3 = function () {
                    if (arguments.length == 0) {
                        return this._item3;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Triple.prototype.setItem1 = function (value) {
                    if (arguments.length == 1) {
                        this._item1 = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Triple.prototype.setItem2 = function (value) {
                    if (arguments.length == 1) {
                        this._item2 = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Triple.prototype.setItem3 = function (value) {
                    if (arguments.length == 1) {
                        this._item3 = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Triple;
            }());
            icelink.Triple = Triple;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Unit =  (function () {
                function Unit(item) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var item_3 = __arguments[0];
                        this.setItem(item_3);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Unit.prototype.getTypeString = function () {
                    return '[fm.icelink.Unit]';
                };
                Unit.prototype.getItem = function () {
                    if (arguments.length == 0) {
                        return this._item;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Unit.prototype.setItem = function (value) {
                    if (arguments.length == 1) {
                        this._item = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Unit;
            }());
            icelink.Unit = Unit;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CompareResultWrapper =  (function () {
                function CompareResultWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_9 = __arguments[0];
                        this._value = value_9;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CompareResultWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.CompareResultWrapper]';
                };
                CompareResultWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.CompareResult.Equal)
                            return 'Equal';
                        if (this._value == fm.icelink.CompareResult.Negative)
                            return 'Negative';
                        if (this._value == fm.icelink.CompareResult.Positive)
                            return 'Positive';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CompareResultWrapper;
            }());
            icelink.CompareResultWrapper = CompareResultWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Constants =  (function () {
                function Constants() {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Constants.prototype.getTypeString = function () {
                    return '[fm.icelink.Constants]';
                };
                Constants.getHoursPerDay = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___hoursPerDay;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getMillisecondsPerDay = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___millisecondsPerDay;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getMillisecondsPerHour = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___millisecondsPerHour;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getMillisecondsPerMinute = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___millisecondsPerMinute;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getMillisecondsPerSecond = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___millisecondsPerSecond;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getMinutesPerDay = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___minutesPerDay;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getMinutesPerHour = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___minutesPerHour;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getNanosecondsPerTick = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___nanosecondsPerTick;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getSecondsPerDay = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___secondsPerDay;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getSecondsPerHour = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___secondsPerHour;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getSecondsPerMinute = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___secondsPerMinute;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getTicksPerDay = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___ticksPerDay;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getTicksPerHour = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___ticksPerHour;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getTicksPerMillisecond = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___ticksPerMillisecond;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getTicksPerMinute = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___ticksPerMinute;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.getTicksPerSecond = function () {
                    fm.icelink.Constants.fmicelinkConstantsInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.Constants.fm_icelink_Constants___ticksPerSecond;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Constants.fmicelinkConstantsInitialize = function () {
                    if (!fm.icelink.Constants.__fmicelinkConstantsInitialized && !fm.icelink.Constants.__fmicelinkConstantsInitializing) {
                        fm.icelink.Constants.__fmicelinkConstantsInitializing = true;
                        Constants.fm_icelink_Constants___hoursPerDay = 0;
                        Constants.fm_icelink_Constants___millisecondsPerDay = 0;
                        Constants.fm_icelink_Constants___millisecondsPerHour = 0;
                        Constants.fm_icelink_Constants___millisecondsPerMinute = 0;
                        Constants.fm_icelink_Constants___millisecondsPerSecond = 0;
                        Constants.fm_icelink_Constants___minutesPerDay = 0;
                        Constants.fm_icelink_Constants___minutesPerHour = 0;
                        Constants.fm_icelink_Constants___nanosecondsPerTick = 0;
                        Constants.fm_icelink_Constants___secondsPerDay = 0;
                        Constants.fm_icelink_Constants___secondsPerHour = 0;
                        Constants.fm_icelink_Constants___secondsPerMinute = 0;
                        Constants.fm_icelink_Constants___ticksPerDay = 0;
                        Constants.fm_icelink_Constants___ticksPerHour = 0;
                        Constants.fm_icelink_Constants___ticksPerMillisecond = 0;
                        Constants.fm_icelink_Constants___ticksPerMinute = 0;
                        Constants.fm_icelink_Constants___ticksPerSecond = 0;
                        fm.icelink.Constants.fm_icelink_Constants___nanosecondsPerTick = 100;
                        fm.icelink.Constants.fm_icelink_Constants___ticksPerMillisecond = 10000;
                        fm.icelink.Constants.fm_icelink_Constants___millisecondsPerSecond = 1000;
                        fm.icelink.Constants.fm_icelink_Constants___secondsPerMinute = 60;
                        fm.icelink.Constants.fm_icelink_Constants___minutesPerHour = 60;
                        fm.icelink.Constants.fm_icelink_Constants___hoursPerDay = 24;
                        fm.icelink.Constants.fm_icelink_Constants___ticksPerSecond = (fm.icelink.Constants.getTicksPerMillisecond() * fm.icelink.Constants.getMillisecondsPerSecond());
                        fm.icelink.Constants.fm_icelink_Constants___ticksPerMinute = (fm.icelink.Constants.getTicksPerSecond() * fm.icelink.Constants.getSecondsPerMinute());
                        fm.icelink.Constants.fm_icelink_Constants___ticksPerHour = (fm.icelink.Constants.getTicksPerMinute() * fm.icelink.Constants.getMinutesPerHour());
                        fm.icelink.Constants.fm_icelink_Constants___ticksPerDay = (fm.icelink.Constants.getTicksPerHour() * fm.icelink.Constants.getHoursPerDay());
                        fm.icelink.Constants.fm_icelink_Constants___millisecondsPerMinute = (fm.icelink.Constants.getMillisecondsPerSecond() * fm.icelink.Constants.getSecondsPerMinute());
                        fm.icelink.Constants.fm_icelink_Constants___millisecondsPerHour = (fm.icelink.Constants.getMillisecondsPerMinute() * fm.icelink.Constants.getMinutesPerHour());
                        fm.icelink.Constants.fm_icelink_Constants___millisecondsPerDay = (fm.icelink.Constants.getMillisecondsPerHour() * fm.icelink.Constants.getHoursPerDay());
                        fm.icelink.Constants.fm_icelink_Constants___secondsPerHour = (fm.icelink.Constants.getSecondsPerMinute() * fm.icelink.Constants.getMinutesPerHour());
                        fm.icelink.Constants.fm_icelink_Constants___secondsPerDay = (fm.icelink.Constants.getSecondsPerHour() * fm.icelink.Constants.getHoursPerDay());
                        fm.icelink.Constants.fm_icelink_Constants___minutesPerDay = (fm.icelink.Constants.getMinutesPerHour() * fm.icelink.Constants.getHoursPerDay());
                        fm.icelink.Constants.__fmicelinkConstantsInitialized = true;
                        fm.icelink.Constants.__fmicelinkConstantsInitializing = false;
                    }
                };
                Constants.__fmicelinkConstantsInitialized = false;
                Constants.__fmicelinkConstantsInitializing = false;
                return Constants;
            }());
            icelink.Constants = Constants;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataBufferStream =  (function () {
                function DataBufferStream() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataBuffer]'))) {
                        var buffer = __arguments[0];
                        this.fmicelinkDataBufferStreamInit();
                        this.__buffer = buffer;
                    }
                    else if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                        var dataBufferSize = __arguments[0];
                        __arguments = new Array(2);
                        __arguments[0] = dataBufferSize;
                        __arguments[1] = false;
                        {
                            var dataBufferSize_1 = __arguments[0];
                            var littleEndian = __arguments[1];
                            __arguments = new Array(1);
                            __arguments[0] = fm.icelink.DataBuffer.allocate(dataBufferSize_1, littleEndian);
                            {
                                var buffer = __arguments[0];
                                this.fmicelinkDataBufferStreamInit();
                                this.__buffer = buffer;
                            }
                        }
                    }
                    else if (__arguments.length == 2) {
                        var dataBufferSize = __arguments[0];
                        var littleEndian = __arguments[1];
                        __arguments = new Array(1);
                        __arguments[0] = fm.icelink.DataBuffer.allocate(dataBufferSize, littleEndian);
                        {
                            var buffer = __arguments[0];
                            this.fmicelinkDataBufferStreamInit();
                            this.__buffer = buffer;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                DataBufferStream.prototype.getTypeString = function () {
                    return '[fm.icelink.DataBufferStream]';
                };
                DataBufferStream.prototype.fmicelinkDataBufferStreamInit = function () {
                    this.__bitPosition = 0;
                    this.__position = 0;
                };
                DataBufferStream.prototype.getAvailable = function () {
                    if (arguments.length == 0) {
                        return (this.getLength() - this.__position);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.getBitPosition = function () {
                    if (arguments.length == 0) {
                        return this.__bitPosition;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.getBuffer = function () {
                    if (arguments.length == 0) {
                        return this.__buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.getLength = function () {
                    if (arguments.length == 0) {
                        return this.__buffer.getLength();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.getPosition = function () {
                    if (arguments.length == 0) {
                        return this.__position;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.nextByte = function () {
                    if (arguments.length == 0) {
                        this.__bitPosition = 0;
                        this.__position++;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.peek = function () {
                    if (arguments.length == 0) {
                        return this.__buffer.read8(this.getPosition());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read = function (length) {
                    if (arguments.length == 1) {
                        length = fm.icelink.Global.toInt(arguments[0]);
                        var buffer = this.__buffer.subset(this.__position, length);
                        this.__position = (this.__position + length);
                        return buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read1 = function () {
                    if (arguments.length == 0) {
                        var flag = this.__buffer.read1(this.__position, this.__bitPosition);
                        this.__bitPosition = (this.__bitPosition + 1);
                        if ((fm.icelink.Global.equals(this.__bitPosition, 8))) {
                            this.__position++;
                            this.__bitPosition = 0;
                        }
                        return flag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read15 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read15(this.__position, this.__bitPosition);
                        this.__position++;
                        this.__bitPosition = (this.__bitPosition + 7);
                        if ((this.__bitPosition >= 8)) {
                            this.__position++;
                            this.__bitPosition = (this.__bitPosition - 8);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read16 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read16(this.__position);
                        this.__position = (this.__position + 2);
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read2 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read2(this.__position, this.__bitPosition);
                        this.__bitPosition = (this.__bitPosition + 2);
                        if ((this.__bitPosition >= 8)) {
                            this.__position++;
                            this.__bitPosition = (this.__bitPosition - 8);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read24 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read24(this.__position);
                        this.__position = (this.__position + 3);
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read3 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read3(this.__position, this.__bitPosition);
                        this.__bitPosition = (this.__bitPosition + 3);
                        if ((this.__bitPosition >= 8)) {
                            this.__position++;
                            this.__bitPosition = (this.__bitPosition - 8);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read32 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read32(this.__position);
                        this.__position = (this.__position + 4);
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read4 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read4(this.__position, this.__bitPosition);
                        this.__bitPosition = (this.__bitPosition + 4);
                        if ((this.__bitPosition >= 8)) {
                            this.__position++;
                            this.__bitPosition = (this.__bitPosition - 8);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read40 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read40(this.__position);
                        this.__position = (this.__position + 5);
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read48 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read48(this.__position);
                        this.__position = (this.__position + 6);
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read56 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read56(this.__position);
                        this.__position = (this.__position + 7);
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read64 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read64(this.__position);
                        this.__position = (this.__position + 8);
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read7 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read7(this.__position, this.__bitPosition);
                        this.__bitPosition = (this.__bitPosition + 7);
                        if ((this.__bitPosition >= 8)) {
                            this.__position++;
                            this.__bitPosition = (this.__bitPosition - 8);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.read8 = function () {
                    if (arguments.length == 0) {
                        var num = this.__buffer.read8(this.__position);
                        this.__position++;
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.readByte = function () {
                    if (arguments.length == 0) {
                        return this.read8();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.readBytes = function (length) {
                    if (arguments.length == 1) {
                        length = fm.icelink.Global.toInt(arguments[0]);
                        var buffer = this.__buffer.subset(this.__position, length).toArray();
                        this.__position = (this.__position + length);
                        return buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.setBitPosition = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__bitPosition = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.setPosition = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__position = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.write = function (buffer) {
                    if (arguments.length == 1) {
                        this.__buffer.write(buffer, this.__position);
                        this.__position = (this.__position + buffer.getLength());
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.write16 = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__buffer.write16(value, this.__position);
                        this.__position = (this.__position + 2);
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.write32 = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__buffer.write32(value, this.__position);
                        this.__position = (this.__position + 4);
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.write64 = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__buffer.write64(value, this.__position);
                        this.__position = (this.__position + 8);
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.write8 = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__buffer.write8(value, this.__position);
                        this.__position++;
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferStream.prototype.writeBytes = function () {
                    if (arguments.length == 1) {
                        var data = arguments[0];
                        return this.writeBytes(data, 0, data.length);
                    }
                    else if (arguments.length == 3) {
                        var data = arguments[0];
                        var index = fm.icelink.Global.toInt(arguments[1]);
                        var length_17 = fm.icelink.Global.toInt(arguments[2]);
                        if ((this.getAvailable() < length_17)) {
                            this.getBuffer().resize(((this.getBuffer().getLength() - this.getAvailable()) + length_17));
                        }
                        this.__buffer.writeBytes(data, index, length_17, this.__position);
                        this.__position = (this.__position + length_17);
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataBufferStream;
            }());
            icelink.DataBufferStream = DataBufferStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataBuffer =  (function () {
                function DataBuffer() {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkDataBufferInit();
                    }
                    else if (__arguments.length == 4) {
                        var data = __arguments[0];
                        var index = __arguments[1];
                        var length_18 = __arguments[2];
                        var littleEndian = __arguments[3];
                        this.fmicelinkDataBufferInit();
                        this.setInnerData(data);
                        this.setIndex(index);
                        this.setLength(length_18);
                        this.setLittleEndian(littleEndian);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                DataBuffer.prototype.getTypeString = function () {
                    return '[fm.icelink.DataBuffer]';
                };
                DataBuffer.prototype.fmicelinkDataBufferInit = function () {
                    this._index = 0;
                    this._length = 0;
                    this._littleEndian = false;
                };
                DataBuffer.allocate = function () {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    if (arguments.length == 1) {
                        var count = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.DataBuffer.allocate(count, false);
                    }
                    else if (arguments.length == 2) {
                        var count = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        return fm.icelink.DataBuffer.wrap(new Uint8Array(count), littleEndian);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.areEqual = function (buffer1, buffer2) {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    if (arguments.length == 2) {
                        if ((!fm.icelink.Global.equals(buffer1.getLength(), buffer2.getLength()))) {
                            return false;
                        }
                        for (var i = 0; (i < buffer1.getLength()); i++) {
                            if ((!fm.icelink.Global.equals(buffer1.read8(i), buffer2.read8(i)))) {
                                return false;
                            }
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.fromBytes = function () {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    if (arguments.length == 1) {
                        var bytes = arguments[0];
                        return fm.icelink.DataBuffer.wrap(bytes);
                    }
                    else if (arguments.length == 2) {
                        var bytes = arguments[0];
                        var littleEndian = arguments[1];
                        return fm.icelink.DataBuffer.wrap(bytes, littleEndian);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.fromHexString = function () {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    if (arguments.length == 1) {
                        var hexString = arguments[0];
                        return fm.icelink.DataBuffer.wrap(fm.icelink.BitAssistant.getHexBytes(hexString));
                    }
                    else if (arguments.length == 2) {
                        var hexString = arguments[0];
                        var littleEndian = arguments[1];
                        return fm.icelink.DataBuffer.wrap(fm.icelink.BitAssistant.getHexBytes(hexString), littleEndian);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.fromJson = function (dataBufferJson) {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(dataBufferJson, function () {
                            return new fm.icelink.DataBuffer();
                        }, function (dataBuffer, name, valueJson) {
                            var str = name;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "data"))) {
                                    if ((fm.icelink.Global.equals(str, "index"))) {
                                        dataBuffer.setIndex(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "length"))) {
                                            dataBuffer.setLength(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "littleEndian"))) {
                                                dataBuffer.setLittleEndian(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                            }
                                        }
                                    }
                                }
                                else {
                                    dataBuffer.setInnerData(fm.icelink.Base64.decode(valueJson));
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.fromJsonArray = function (dataBuffersJson) {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(dataBuffersJson, fm.icelink.DataBuffer.fromJson.bind(fm.icelink.DataBuffer));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.getEmpty = function () {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.DataBuffer.allocate(0, false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.toJson = function (dataBuffer) {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(dataBuffer, function (obj, jsonObject) {
                            var b = dataBuffer.toArray();
                            jsonObject["data"] = fm.icelink.Base64.encode(b);
                            jsonObject["index"] = fm.icelink.JsonSerializer.serializeInteger(0);
                            jsonObject["length"] = fm.icelink.JsonSerializer.serializeInteger(b.length);
                            jsonObject["littleEndian"] = fm.icelink.JsonSerializer.serializeBoolean(dataBuffer.getLittleEndian());
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.toJsonArray = function (dataBuffers) {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(dataBuffers, fm.icelink.DataBuffer.toJson.bind(fm.icelink.DataBuffer));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.wrap = function () {
                    fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
                    if (arguments.length == 1) {
                        var data = arguments[0];
                        return fm.icelink.DataBuffer.wrap(data, 0, -1, false);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isNumber(arguments[1]))) {
                        var data = arguments[0];
                        var index = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.DataBuffer.wrap(data, index, -1, false);
                    }
                    else if (arguments.length == 3 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || fm.icelink.Util.isNumber(arguments[2]))) {
                        var data = arguments[0];
                        var index = fm.icelink.Global.toInt(arguments[1]);
                        var length_19 = fm.icelink.Global.toInt(arguments[2]);
                        return fm.icelink.DataBuffer.wrap(data, index, length_19, false);
                    }
                    else if (arguments.length == 4) {
                        var data = arguments[0];
                        var index = fm.icelink.Global.toInt(arguments[1]);
                        var length_20 = fm.icelink.Global.toInt(arguments[2]);
                        var littleEndian = arguments[3];
                        if ((fm.icelink.Global.equals(data, null))) {
                            return null;
                        }
                        if ((index < 0)) {
                            return null;
                        }
                        if ((length_20 < 0)) {
                            length_20 = (data.length - index);
                        }
                        return new fm.icelink.DataBuffer(data, index, length_20, littleEndian);
                    }
                    else if (arguments.length == 3 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || fm.icelink.Util.isBoolean(arguments[2]))) {
                        var data = arguments[0];
                        var index = fm.icelink.Global.toInt(arguments[1]);
                        var littleEndian = arguments[2];
                        return fm.icelink.DataBuffer.wrap(data, index, -1, littleEndian);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isBoolean(arguments[1]))) {
                        var data = arguments[0];
                        var littleEndian = arguments[1];
                        return fm.icelink.DataBuffer.wrap(data, 0, -1, littleEndian);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.and = function (value, offset) {
                    if (arguments.length == 2) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        return this.write8((this.read8(offset) & value), offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.append = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataBuffer]'))) {
                        var buffer = arguments[0];
                        if (((!fm.icelink.Global.equals(buffer, null)) && (buffer.getLength() > 0))) {
                            var newLength = (this.getLength() + buffer.getLength());
                            if ((newLength > this.getLength())) {
                                var length_21 = this.getLength();
                                this.resize(newLength);
                                this.write(buffer, length_21);
                                length_21 = (length_21 + buffer.getLength());
                            }
                        }
                        return this;
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || (fm.icelink.Util.isArray(arguments[0]) && (arguments[0].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[0][0]) || fm.icelink.Util.isObjectType(arguments[0][0], '[fm.icelink.DataBuffer]')))))) {
                        var buffers = arguments[0];
                        if (((!fm.icelink.Global.equals(buffers, null)) && (buffers.length > 0))) {
                            var length_22 = this.getLength();
                            for (var _i = 0, buffers_1 = buffers; _i < buffers_1.length; _i++) {
                                var buffer = buffers_1[_i];
                                length_22 = (length_22 + buffer.getLength());
                            }
                            if ((length_22 > this.getLength())) {
                                var offset = this.getLength();
                                this.resize(length_22);
                                for (var _a = 0, buffers_2 = buffers; _a < buffers_2.length; _a++) {
                                    var buffer = buffers_2[_a];
                                    this.write(buffer, offset);
                                    offset = (offset + buffer.getLength());
                                }
                            }
                        }
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.canResize = function (newLength, offset) {
                    if (arguments.length == 2) {
                        newLength = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        if (this.getIsPooled()) {
                            var num = (newLength - this.getLength());
                            if ((num <= 0)) {
                                return true;
                            }
                            if ((offset >= this.getIndex())) {
                                if (((this.getIndex() + newLength) >= this.getData().length)) {
                                    return false;
                                }
                            }
                            else {
                                if ((offset < 0)) {
                                    if (((this.getIndex() + newLength) > this.getData().length)) {
                                        return false;
                                    }
                                }
                                else {
                                    if ((((this.getIndex() - offset) + newLength) >= this.getData().length)) {
                                        return false;
                                    }
                                }
                            }
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.clone = function () {
                    if (arguments.length == 0) {
                        return this.clone(this.getLittleEndian());
                    }
                    else if (arguments.length == 1) {
                        return this.subset(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.copy = function () {
                    if (arguments.length == 0) {
                        return this.copy(false);
                    }
                    else if (arguments.length == 1) {
                        var usePool = arguments[0];
                        var buffer = void 0;
                        if (usePool) {
                            buffer = fm.icelink.DataBuffer.fm_icelink_DataBuffer___dataBufferPool.take(this.getLength());
                        }
                        else {
                            buffer = fm.icelink.DataBuffer.allocate(this.getLength(), this.getLittleEndian());
                        }
                        buffer.write(this);
                        return buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.free = function () {
                    if (arguments.length == 0) {
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.getData = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(this.getInnerData(), null))) {
                            throw new fm.icelink.Exception("This data buffer has been invalidated.");
                        }
                        return this.getInnerData();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.getIndex = function () {
                    if (arguments.length == 0) {
                        return this._index;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.getInnerData = function () {
                    if (arguments.length == 0) {
                        return this._innerData;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.getIsPooled = function () {
                    if (arguments.length == 0) {
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.getIsSubset = function () {
                    if (arguments.length == 0) {
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.getLength = function () {
                    if (arguments.length == 0) {
                        return this._length;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.getLittleEndian = function () {
                    if (arguments.length == 0) {
                        return this._littleEndian;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.keep = function () {
                    if (arguments.length == 0) {
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.or = function (value, offset) {
                    if (arguments.length == 2) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        return this.write8((this.read8(offset) | value), offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.prepend = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataBuffer]'))) {
                        var buffer = arguments[0];
                        var length_23 = buffer.getLength();
                        if ((length_23 <= this.getIndex())) {
                            this.setIndex((this.getIndex() - length_23));
                            this.setLength((this.getLength() + length_23));
                        }
                        else {
                            this.resize((this.getLength() + length_23), 0);
                        }
                        var offset = 0;
                        this.write(buffer, offset);
                        offset = (offset + buffer.getLength());
                        return this;
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || (fm.icelink.Util.isArray(arguments[0]) && (arguments[0].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[0][0]) || fm.icelink.Util.isObjectType(arguments[0][0], '[fm.icelink.DataBuffer]')))))) {
                        var buffers = arguments[0];
                        if (((!fm.icelink.Global.equals(buffers, null)) && (buffers.length > 0))) {
                            var num = 0;
                            for (var _i = 0, buffers_3 = buffers; _i < buffers_3.length; _i++) {
                                var buffer = buffers_3[_i];
                                num = (num + buffer.getLength());
                            }
                            if ((num <= this.getIndex())) {
                                this.setIndex((this.getIndex() - num));
                                this.setLength((this.getLength() + num));
                            }
                            else {
                                this.resize((this.getLength() + num), 0);
                            }
                            var offset = 0;
                            for (var _a = 0, buffers_4 = buffers; _a < buffers_4.length; _a++) {
                                var buffer = buffers_4[_a];
                                this.write(buffer, offset);
                                offset = (offset + buffer.getLength());
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read1 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes1(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read10 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes10(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read10Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read10(offset, bitOffset);
                        if ((num > 511)) {
                            num = (num - 1024);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read11 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes11(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read11Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read11(offset, bitOffset);
                        if ((num > 1023)) {
                            num = (num - 2048);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read12 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes12(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read12Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read12(offset, bitOffset);
                        if ((num > 2047)) {
                            num = (num - 4096);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read13 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes13(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read13Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read13(offset, bitOffset);
                        if ((num > 4095)) {
                            num = (num - 8192);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read14 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes14(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read14Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read14(offset, bitOffset);
                        if ((num > 8191)) {
                            num = (num - 16384);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read15 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes15(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read15Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read15(offset, bitOffset);
                        if ((num > 16383)) {
                            num = (num - 32768);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read16 = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.Binary.fromBytes16(this.getData(), (this.getIndex() + offset), this.getLittleEndian());
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 2));
                        return this.read16(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read16Signed = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var num = this.read16(offset);
                        if ((num > 32767)) {
                            num = (num - 65536);
                        }
                        return num;
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 2));
                        return this.read16Signed(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read17 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes17(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read17Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read17(offset, bitOffset);
                        if ((num > 65535)) {
                            num = (num - 131072);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read18 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes18(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read18Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read18(offset, bitOffset);
                        if ((num > 131071)) {
                            num = (num - 262144);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read19 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes19(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read19Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read19(offset, bitOffset);
                        if ((num > 262143)) {
                            num = (num - 524288);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read2 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes2(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read20 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes20(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read20Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read20(offset, bitOffset);
                        if ((num > 524287)) {
                            num = (num - 1048576);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read21 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes21(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read21Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read21(offset, bitOffset);
                        if ((num > 1048575)) {
                            num = (num - 2097152);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read22 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes22(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read22Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read22(offset, bitOffset);
                        if ((num > 2097151)) {
                            num = (num - 4194304);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read23 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes23(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read23Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read23(offset, bitOffset);
                        if ((num > 4194303)) {
                            num = (num - 8388608);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read24 = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.Binary.fromBytes24(this.getData(), (this.getIndex() + offset), this.getLittleEndian());
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 3));
                        return this.read24(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read24Signed = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var num = this.read24(offset);
                        if ((num > 8388607)) {
                            num = (num - 16777216);
                        }
                        return num;
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 3));
                        return this.read24Signed(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read2Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read2(offset, bitOffset);
                        if ((num > 1)) {
                            num = (num - 4);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read3 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes3(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read32 = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.Binary.fromBytes32(this.getData(), (this.getIndex() + offset), this.getLittleEndian());
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 4));
                        return this.read32(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read32Signed = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var num = this.read32(offset);
                        if ((num > 2147483647)) {
                            num = (num - 4294967296);
                        }
                        return num;
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 4));
                        return this.read32Signed(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read3Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read3(offset, bitOffset);
                        if ((num > 3)) {
                            num = (num - 8);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read4 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes4(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read40 = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.Binary.fromBytes40(this.getData(), (this.getIndex() + offset), this.getLittleEndian());
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 5));
                        return this.read40(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read40Signed = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var num = this.read40(offset);
                        if ((num > 549755813887)) {
                            num = (num - 1099511627776);
                        }
                        return num;
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 5));
                        return this.read40Signed(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read48 = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.Binary.fromBytes48(this.getData(), (this.getIndex() + offset), this.getLittleEndian());
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 6));
                        return this.read48(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read48Signed = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var num = this.read48(offset);
                        if ((num > 140737488355327)) {
                            num = (num - 281474976710656);
                        }
                        return num;
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 6));
                        return this.read48Signed(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read4Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read4(offset, bitOffset);
                        if ((num > 7)) {
                            num = (num - 16);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read5 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes5(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read56 = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.Binary.fromBytes56(this.getData(), (this.getIndex() + offset), this.getLittleEndian());
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 7));
                        return this.read56(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read56Signed = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var num = this.read56(offset);
                        if ((num > 36028797018963967)) {
                            num = (num - 72057594037927936);
                        }
                        return num;
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 7));
                        return this.read56Signed(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read5Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read5(offset, bitOffset);
                        if ((num > 15)) {
                            num = (num - 32);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read6 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes6(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read64 = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.Binary.fromBytes64(this.getData(), (this.getIndex() + offset), this.getLittleEndian());
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 8));
                        return this.read64(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read64Signed = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return this.read64(offset);
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 8));
                        return this.read64Signed(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read6Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read6(offset, bitOffset);
                        if ((num > 31)) {
                            num = (num - 64);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read7 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes7(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read7Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read7(offset, bitOffset);
                        if ((num > 63)) {
                            num = (num - 128);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read8 = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.Binary.fromBytes8(this.getData(), (this.getIndex() + offset));
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 1));
                        return this.read8(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read8Signed = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var num = this.read8(offset);
                        if ((num > 127)) {
                            num = (num - 256);
                        }
                        return num;
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var offsetPlus = arguments[1];
                        offsetPlus.setValue((offset + 1));
                        return this.read8Signed(offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read9 = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Binary.fromBytes9(this.getData(), (this.getIndex() + offset), bitOffset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.read9Signed = function (offset, bitOffset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var num = this.read9(offset, bitOffset);
                        if ((num > 255)) {
                            num = (num - 512);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.readUtf8String = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.Encoding.getUtf8().getString(this.getData(), (this.getIndex() + offset), (this.getLength() - offset));
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var length_24 = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.Encoding.getUtf8().getString(this.getData(), (this.getIndex() + offset), length_24);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.resize = function () {
                    if (arguments.length == 1) {
                        var newLength = fm.icelink.Global.toInt(arguments[0]);
                        this.resize(newLength, this.getLength());
                    }
                    else if (arguments.length == 2) {
                        var newLength = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        this.resize(newLength, offset, false);
                    }
                    else if (arguments.length == 3) {
                        var newLength = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var setZero = arguments[2];
                        if ((fm.icelink.Global.equals(offset, -1))) {
                            offset = this.getLength();
                        }
                        if ((offset < 0)) {
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Offset '{0}' is invalid.", fm.icelink.NumberExtensions.toString(offset)));
                        }
                        var length_25 = (newLength - this.getLength());
                        if ((length_25 < 0)) {
                            length_25 = -length_25;
                            if (((offset + length_25) > this.getLength())) {
                                throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Truncating at offset '{0}' for length '{1}' would exceed data buffer length '{2}'.", fm.icelink.NumberExtensions.toString(offset), fm.icelink.NumberExtensions.toString(length_25), fm.icelink.NumberExtensions.toString(this.getLength())));
                            }
                            if ((fm.icelink.Global.equals(offset, 0))) {
                                this.setIndex((this.getIndex() + length_25));
                            }
                            else {
                                if ((!fm.icelink.Global.equals((offset + length_25), this.getLength()))) {
                                    fm.icelink.BitAssistant.copy(this.getData(), ((this.getIndex() + offset) + length_25), this.getData(), (this.getIndex() + offset), ((this.getLength() - offset) - length_25));
                                }
                            }
                        }
                        else {
                            if ((length_25 > 0)) {
                                if ((offset > this.getLength())) {
                                    throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Offset '{0}' exceeds data buffer length '{1}'.", fm.icelink.NumberExtensions.toString(offset), fm.icelink.NumberExtensions.toString(this.getLength())));
                                }
                                if (((fm.icelink.Global.equals(offset, 0)) && (length_25 <= this.getIndex()))) {
                                    this.setIndex((this.getIndex() - length_25));
                                    if (setZero) {
                                        fm.icelink.BitAssistant.set(this.getData(), this.getIndex(), length_25, 0);
                                    }
                                }
                                else {
                                    if (((fm.icelink.Global.equals(offset, this.getLength())) && (((this.getIndex() + this.getLength()) + length_25) < this.getData().length))) {
                                        if (setZero) {
                                            fm.icelink.BitAssistant.set(this.getData(), (this.getIndex() + this.getLength()), length_25, 0);
                                        }
                                    }
                                    else {
                                        if ((newLength > this.getData().length)) {
                                            if (this.getIsPooled()) {
                                                throw new fm.icelink.Exception("Cannot expand the underlying byte array of a pooled data buffer.");
                                            }
                                            var destination = new Uint8Array(newLength);
                                            fm.icelink.BitAssistant.copy(this.getData(), this.getIndex(), destination, 0, offset);
                                            fm.icelink.BitAssistant.copy(this.getData(), (this.getIndex() + offset), destination, (offset + length_25), (this.getLength() - offset));
                                            this.setInnerData(destination);
                                        }
                                        else {
                                            if (((this.getIndex() + newLength) > this.getData().length)) {
                                                var destinationIndex = (this.getData().length - newLength);
                                                fm.icelink.BitAssistant.copy(this.getData(), this.getIndex(), this.getData(), destinationIndex, offset);
                                                fm.icelink.BitAssistant.copy(this.getData(), (this.getIndex() + offset), this.getData(), ((destinationIndex + offset) + length_25), (this.getLength() - offset));
                                                this.setIndex(destinationIndex);
                                                if (setZero) {
                                                    fm.icelink.BitAssistant.set(this.getData(), (this.getIndex() + offset), length_25, 0);
                                                }
                                            }
                                            else {
                                                fm.icelink.BitAssistant.copy(this.getData(), (this.getIndex() + offset), this.getData(), ((this.getIndex() + offset) + length_25), (this.getLength() - offset));
                                                if (setZero) {
                                                    fm.icelink.BitAssistant.set(this.getData(), (this.getIndex() + offset), length_25, 0);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        this.setLength(newLength);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.sequenceEquals = function (buffer) {
                    if (arguments.length == 1) {
                        return fm.icelink.BitAssistant.sequencesAreEqual(this.getData(), this.getIndex(), buffer.getData(), buffer.getIndex(), this.getLength());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.sequenceEqualsConstantTime = function (buffer) {
                    if (arguments.length == 1) {
                        return fm.icelink.BitAssistant.sequencesAreEqualConstantTime(this.getData(), this.getIndex(), buffer.getData(), buffer.getIndex(), this.getLength());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.set = function () {
                    if (arguments.length == 1) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        this.set(value, 0, this.getLength());
                    }
                    else if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        fm.icelink.BitAssistant.set(this.getData(), (this.getIndex() + offset), (this.getLength() - offset), value);
                    }
                    else if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var length_26 = fm.icelink.Global.toInt(arguments[2]);
                        fm.icelink.BitAssistant.set(this.getData(), (this.getIndex() + offset), length_26, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.setIndex = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._index = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.setInnerData = function (value) {
                    if (arguments.length == 1) {
                        this._innerData = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.setLength = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._length = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.setLittleEndian = function (value) {
                    if (arguments.length == 1) {
                        this._littleEndian = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.subset = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return this.subset(offset, (this.getLength() - offset));
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var length_27 = fm.icelink.Global.toInt(arguments[1]);
                        if ((((offset + length_27) > this.getLength()) || (length_27 < 0))) {
                            return null;
                        }
                        if (this.getIsPooled()) {
                            return new fm.icelink.DataBufferSubset(this, (this.getIndex() + offset), length_27);
                        }
                        return new fm.icelink.DataBuffer(this.getData(), (this.getIndex() + offset), length_27, this.getLittleEndian());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.toArray = function () {
                    if (arguments.length == 0) {
                        return this.toBytes();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.toBytes = function () {
                    if (arguments.length == 0) {
                        var destination = new Uint8Array(this.getLength());
                        fm.icelink.BitAssistant.copy(this.getData(), this.getIndex(), destination, 0, this.getLength());
                        return destination;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.toHexString = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.BitAssistant.getHexString(this.getData(), this.getIndex(), this.getLength());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.DataBuffer.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryKeep = function () {
                    if (arguments.length == 0) {
                        try {
                            this.keep();
                            return true;
                        }
                        catch (obj1) {
                            return false;
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead1 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes1(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead10 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes10(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead11 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes11(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead12 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes12(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead13 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes13(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead14 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes14(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead15 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes15(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead16 = function (offset, value) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        var _var0 = fm.icelink.Binary.tryFromBytes16(this.getData(), (this.getIndex() + offset), this.getLittleEndian(), value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead17 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes17(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead18 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes18(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead19 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes19(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead2 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes2(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead20 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes20(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead21 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes21(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead22 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes22(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead23 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes23(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead24 = function (offset, value) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        var _var0 = fm.icelink.Binary.tryFromBytes24(this.getData(), (this.getIndex() + offset), this.getLittleEndian(), value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead3 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes3(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead32 = function (offset, value) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        var _var0 = fm.icelink.Binary.tryFromBytes32(this.getData(), (this.getIndex() + offset), this.getLittleEndian(), value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead4 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes4(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead40 = function (offset, value) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        var _var0 = fm.icelink.Binary.tryFromBytes40(this.getData(), (this.getIndex() + offset), this.getLittleEndian(), value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead48 = function (offset, value) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        var _var0 = fm.icelink.Binary.tryFromBytes48(this.getData(), (this.getIndex() + offset), this.getLittleEndian(), value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead5 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes5(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead56 = function (offset, value) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        var _var0 = fm.icelink.Binary.tryFromBytes56(this.getData(), (this.getIndex() + offset), this.getLittleEndian(), value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead6 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes6(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead64 = function (offset, value) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        var _var0 = fm.icelink.Binary.tryFromBytes64(this.getData(), (this.getIndex() + offset), this.getLittleEndian(), value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead7 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes7(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead8 = function (offset, value) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        var _var0 = fm.icelink.Binary.tryFromBytes8(this.getData(), (this.getIndex() + offset), value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.tryRead9 = function (offset, bitOffset, value) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[0]);
                        bitOffset = fm.icelink.Global.toInt(arguments[1]);
                        var _var0 = fm.icelink.Binary.tryFromBytes9(this.getData(), (this.getIndex() + offset), bitOffset, value);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write = function () {
                    if (arguments.length == 1) {
                        var buffer = arguments[0];
                        this.write(buffer, 0);
                    }
                    else if (arguments.length == 2) {
                        var buffer = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        fm.icelink.BitAssistant.copy(buffer.getData(), buffer.getIndex(), this.getData(), (this.getIndex() + offset), buffer.getLength());
                    }
                    else if (arguments.length == 3) {
                        var buffer = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var offsetPlus = arguments[2];
                        offsetPlus.setValue((offset + buffer.getLength()));
                        this.write(buffer, offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write1 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes1(value, bitOffset, this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write10 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes10(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write11 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes11(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write12 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes12(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write13 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes13(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write14 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes14(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write15 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes15(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write16 = function () {
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes16(value, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var offsetPlus = arguments[2];
                        offsetPlus.setValue((offset + 2));
                        return this.write16(value, offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write17 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes17(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write18 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes18(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write19 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes19(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write2 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes2(value, bitOffset, this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write20 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes20(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write21 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes21(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write22 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes22(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write23 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes23(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write24 = function () {
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes24(value, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var offsetPlus = arguments[2];
                        offsetPlus.setValue((offset + 3));
                        return this.write24(value, offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write3 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes3(value, bitOffset, this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write32 = function () {
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes32(value, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var offsetPlus = arguments[2];
                        offsetPlus.setValue((offset + 4));
                        return this.write32(value, offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write4 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes4(value, bitOffset, this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write40 = function () {
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes40(value, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var offsetPlus = arguments[2];
                        offsetPlus.setValue((offset + 5));
                        return this.write40(value, offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write48 = function () {
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes48(value, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var offsetPlus = arguments[2];
                        offsetPlus.setValue((offset + 6));
                        return this.write48(value, offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write5 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes5(value, bitOffset, this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write56 = function () {
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes56(value, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var offsetPlus = arguments[2];
                        offsetPlus.setValue((offset + 7));
                        return this.write56(value, offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write6 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes6(value, bitOffset, this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write64 = function () {
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes64(value, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var offsetPlus = arguments[2];
                        offsetPlus.setValue((offset + 8));
                        return this.write64(value, offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write7 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes7(value, bitOffset, this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write8 = function () {
                    if (arguments.length == 2) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes8(value, this.getData(), (this.getIndex() + offset)), null));
                    }
                    else if (arguments.length == 3) {
                        var value = fm.icelink.Global.toInt(arguments[0]);
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var offsetPlus = arguments[2];
                        offsetPlus.setValue((offset + 1));
                        return this.write8(value, offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.write9 = function (value, offset, bitOffset) {
                    if (arguments.length == 3) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        bitOffset = fm.icelink.Global.toInt(arguments[2]);
                        return (!fm.icelink.Global.equals(fm.icelink.Binary.toBytes9(value, bitOffset, this.getLittleEndian(), this.getData(), (this.getIndex() + offset)), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.writeBytes = function () {
                    if (arguments.length == 1) {
                        var bytes = arguments[0];
                        this.writeBytes(bytes, 0, bytes.length, 0);
                    }
                    else if (arguments.length == 4) {
                        var bytes = arguments[0];
                        var bytesIndex = fm.icelink.Global.toInt(arguments[1]);
                        var bytesLength = fm.icelink.Global.toInt(arguments[2]);
                        var offset = fm.icelink.Global.toInt(arguments[3]);
                        if (((offset + bytesLength) > this.getLength())) {
                            throw new fm.icelink.Exception("Would write out of the allowed bounds for this data buffer.");
                        }
                        fm.icelink.BitAssistant.copy(bytes, bytesIndex, this.getData(), (this.getIndex() + offset), bytesLength);
                    }
                    else if (arguments.length == 5) {
                        var bytes = arguments[0];
                        var bytesIndex = fm.icelink.Global.toInt(arguments[1]);
                        var bytesLength = fm.icelink.Global.toInt(arguments[2]);
                        var offset = fm.icelink.Global.toInt(arguments[3]);
                        var offsetPlus = arguments[4];
                        offsetPlus.setValue((offset + bytesLength));
                        this.writeBytes(bytes, bytesIndex, bytesLength, offset);
                    }
                    else if (arguments.length == 3) {
                        var bytes = arguments[0];
                        var bytesIndex = fm.icelink.Global.toInt(arguments[1]);
                        var offset = fm.icelink.Global.toInt(arguments[2]);
                        this.writeBytes(bytes, bytesIndex, (bytes.length - bytesIndex), offset);
                    }
                    else if (arguments.length == 2) {
                        var bytes = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        this.writeBytes(bytes, 0, bytes.length, offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.prototype.xor = function (value, offset) {
                    if (arguments.length == 2) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        return this.write8((this.read8(offset) ^ value), offset);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBuffer.fmicelinkDataBufferInitialize = function () {
                    if (!fm.icelink.DataBuffer.__fmicelinkDataBufferInitialized && !fm.icelink.DataBuffer.__fmicelinkDataBufferInitializing) {
                        fm.icelink.DataBuffer.__fmicelinkDataBufferInitializing = true;
                        fm.icelink.DataBuffer.fm_icelink_DataBuffer___dataBufferPool = fm.icelink.DataBufferPool.getTracer(new fm.icelink.Type('[fm.icelink.DataBuffer]'));
                        fm.icelink.DataBuffer.__fmicelinkDataBufferInitialized = true;
                        fm.icelink.DataBuffer.__fmicelinkDataBufferInitializing = false;
                    }
                };
                DataBuffer.__fmicelinkDataBufferInitialized = false;
                DataBuffer.__fmicelinkDataBufferInitializing = false;
                return DataBuffer;
            }());
            icelink.DataBuffer = DataBuffer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataBufferPooled =  (function (_super) {
                __extends(DataBufferPooled, _super);
                function DataBufferPooled(pool, data, length, littleEndian, tag) {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 5) {
                        var pool_2 = __arguments[0];
                        var data_1 = __arguments[1];
                        var length_28 = __arguments[2];
                        var littleEndian_1 = __arguments[3];
                        var tag_3 = __arguments[4];
                        _this = _super.call(this, data_1, 0, length_28, littleEndian_1) || this;
                        _this.__pool = pool_2;
                        _this.__counter = new fm.icelink.AtomicInteger();
                        _this.__tag = tag_3;
                        _this.keep();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                DataBufferPooled.prototype.getTypeString = function () {
                    return '[fm.icelink.DataBufferPooled]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DataBufferPooled.prototype.decrementRetain = function () {
                    if (arguments.length == 0) {
                        return this.__counter.decrement();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPooled.prototype.free = function () {
                    if (arguments.length == 0) {
                        this.__pool.returnBuffer(this, this.__tag);
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPooled.prototype.getIsPooled = function () {
                    if (arguments.length == 0) {
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPooled.prototype.getRetainCount = function () {
                    if (arguments.length == 0) {
                        return this.__counter.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPooled.prototype.invalidate = function () {
                    if (arguments.length == 0) {
                        var innerData = _super.prototype.getInnerData.call(this);
                        _super.prototype.setInnerData.call(this, null);
                        return innerData;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPooled.prototype.keep = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(_super.prototype.getInnerData.call(this), null))) {
                            throw new fm.icelink.Exception("DataBuffer already invalidated.");
                        }
                        this.__counter.increment();
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataBufferPooled;
            }(fm.icelink.DataBuffer));
            icelink.DataBufferPooled = DataBufferPooled;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataBufferSubset =  (function (_super) {
                __extends(DataBufferSubset, _super);
                function DataBufferSubset(buffer, index, length) {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 3) {
                        var buffer_1 = __arguments[0];
                        var index_1 = __arguments[1];
                        var length_29 = __arguments[2];
                        _this = _super.call(this, null, index_1, length_29, buffer_1.getLittleEndian()) || this;
                        _this.setParent(buffer_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                DataBufferSubset.prototype.getTypeString = function () {
                    return '[fm.icelink.DataBufferSubset]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DataBufferSubset.prototype.append = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataBuffer]'))) {
                        throw new fm.icelink.Exception("Cannot append to a DataBuffer subset.");
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || (fm.icelink.Util.isArray(arguments[0]) && (arguments[0].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[0][0]) || fm.icelink.Util.isObjectType(arguments[0][0], '[fm.icelink.DataBuffer]')))))) {
                        throw new fm.icelink.Exception("Cannot append to a DataBuffer subset.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferSubset.prototype.free = function () {
                    if (arguments.length == 0) {
                        this.getParent().free();
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferSubset.prototype.getData = function () {
                    if (arguments.length == 0) {
                        return this.getParent().getData();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferSubset.prototype.getIsPooled = function () {
                    if (arguments.length == 0) {
                        return this.getParent().getIsPooled();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferSubset.prototype.getIsSubset = function () {
                    if (arguments.length == 0) {
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferSubset.prototype.getParent = function () {
                    if (arguments.length == 0) {
                        return this._parent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferSubset.prototype.keep = function () {
                    if (arguments.length == 0) {
                        this.getParent().keep();
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferSubset.prototype.prepend = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataBuffer]'))) {
                        throw new fm.icelink.Exception("Cannot prepend to a DataBuffer subset.");
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || (fm.icelink.Util.isArray(arguments[0]) && (arguments[0].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[0][0]) || fm.icelink.Util.isObjectType(arguments[0][0], '[fm.icelink.DataBuffer]')))))) {
                        throw new fm.icelink.Exception("Cannot prepend to a DataBuffer subset.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferSubset.prototype.setParent = function (value) {
                    if (arguments.length == 1) {
                        this._parent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferSubset.prototype.subset = function () {
                    if (arguments.length == 1) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        return this.getParent().subset((offset + _super.prototype.getIndex.call(this)), (_super.prototype.getLength.call(this) - offset));
                    }
                    else if (arguments.length == 2) {
                        var offset = fm.icelink.Global.toInt(arguments[0]);
                        var length_30 = fm.icelink.Global.toInt(arguments[1]);
                        return this.getParent().subset((offset + _super.prototype.getIndex.call(this)), length_30);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataBufferSubset;
            }(fm.icelink.DataBuffer));
            icelink.DataBufferSubset = DataBufferSubset;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LogEvent =  (function () {
                function LogEvent() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkLogEventInit();
                    }
                    else if (__arguments.length == 7) {
                        var timestamp = __arguments[0];
                        var tag = __arguments[1];
                        var scope = __arguments[2];
                        var level = __arguments[3];
                        var message = __arguments[4];
                        var exception = __arguments[5];
                        var threadId = __arguments[6];
                        this.fmicelinkLogEventInit();
                        this.setTimestamp(timestamp);
                        this.setTag(tag);
                        this.setScope(scope);
                        this.setLevel(level);
                        this.setMessage(message);
                        this.setException(exception);
                        this.setThreadId(threadId);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LogEvent.prototype.getTypeString = function () {
                    return '[fm.icelink.LogEvent]';
                };
                LogEvent.prototype.fmicelinkLogEventInit = function () {
                    this._threadId = 0;
                };
                LogEvent.fromJson = function (logEventJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(logEventJson, function () {
                            return new fm.icelink.LogEvent();
                        }, function (logEvent, key, valueJson) {
                            var _var0 = key;
                            do {
                                if (_var0 == "timestamp") {
                                    logEvent.setTimestamp(fm.icelink.Iso8601Timestamp.iso8601ToDateTime(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                                    break;
                                }
                                else if (_var0 == "tag") {
                                    logEvent.setTag(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    break;
                                }
                                else if (_var0 == "scope") {
                                    logEvent.setScope(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    break;
                                }
                                else if (_var0 == "level") {
                                    logEvent.setLevel(fm.icelink.LogEvent.stringToLogLevel(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                                    break;
                                }
                                else if (_var0 == "message") {
                                    logEvent.setMessage(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    break;
                                }
                                else if (_var0 == "exception") {
                                    logEvent.setException(new fm.icelink.Exception(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                                    break;
                                }
                                else if (_var0 == "threadId") {
                                    logEvent.setThreadId(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                    break;
                                }
                            } while (false);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.logLevelToString = function (logLevel) {
                    if (arguments.length == 1) {
                        var _var0 = logLevel;
                        do {
                            if (_var0 == fm.icelink.LogLevel.Verbose) {
                                return "verbose";
                            }
                            else if (_var0 == fm.icelink.LogLevel.Debug) {
                                return "debug";
                            }
                            else if (_var0 == fm.icelink.LogLevel.Info) {
                                return "info";
                            }
                            else if (_var0 == fm.icelink.LogLevel.Warn) {
                                return "warn";
                            }
                            else if (_var0 == fm.icelink.LogLevel.Error) {
                                return "error";
                            }
                            else if (_var0 == fm.icelink.LogLevel.Fatal) {
                                return "fatal";
                            }
                        } while (false);
                        return "none";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.stringToLogLevel = function (logLevelString) {
                    if (arguments.length == 1) {
                        var _var0 = logLevelString;
                        do {
                            if (_var0 == "verbose") {
                                return fm.icelink.LogLevel.Verbose;
                            }
                            else if (_var0 == "debug") {
                                return fm.icelink.LogLevel.Debug;
                            }
                            else if (_var0 == "info") {
                                return fm.icelink.LogLevel.Info;
                            }
                            else if (_var0 == "warn") {
                                return fm.icelink.LogLevel.Warn;
                            }
                            else if (_var0 == "error") {
                                return fm.icelink.LogLevel.Error;
                            }
                            else if (_var0 == "fatal") {
                                return fm.icelink.LogLevel.Fatal;
                            }
                        } while (false);
                        return fm.icelink.LogLevel.None;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.toJson = function (logEvent) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(logEvent, function (le, jsonObj) {
                            jsonObj["timestamp"] = fm.icelink.JsonSerializer.serializeString(fm.icelink.Iso8601Timestamp.dateTimeToIso8601(logEvent.getTimestamp()));
                            if ((!fm.icelink.Global.equals(logEvent.getTag(), null))) {
                                jsonObj["tag"] = fm.icelink.JsonSerializer.serializeString(logEvent.getTag());
                            }
                            if ((!fm.icelink.Global.equals(logEvent.getScope(), null))) {
                                jsonObj["scope"] = fm.icelink.JsonSerializer.serializeString(logEvent.getScope());
                            }
                            jsonObj["level"] = fm.icelink.JsonSerializer.serializeString(fm.icelink.LogEvent.logLevelToString(logEvent.getLevel()));
                            if ((!fm.icelink.Global.equals(logEvent.getMessage(), null))) {
                                jsonObj["message"] = fm.icelink.JsonSerializer.serializeString(logEvent.getMessage());
                            }
                            if ((!fm.icelink.Global.equals(logEvent.getException(), null))) {
                                jsonObj["exception"] = fm.icelink.JsonSerializer.serializeString(logEvent.getException().message);
                            }
                            jsonObj["threadId"] = fm.icelink.JsonSerializer.serializeLong(logEvent.getThreadId());
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.getException = function () {
                    if (arguments.length == 0) {
                        return this._exception;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.getLevel = function () {
                    if (arguments.length == 0) {
                        return this._level;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.getLogLevel = function () {
                    if (arguments.length == 0) {
                        return this.getLevel();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.getMessage = function () {
                    if (arguments.length == 0) {
                        return this._message;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.getScope = function () {
                    if (arguments.length == 0) {
                        return this._scope;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.getThreadId = function () {
                    if (arguments.length == 0) {
                        return this._threadId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.getTimestamp = function () {
                    if (arguments.length == 0) {
                        return this._timestamp;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.setException = function (value) {
                    if (arguments.length == 1) {
                        this._exception = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.setLevel = function (value) {
                    if (arguments.length == 1) {
                        this._level = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.setLogLevel = function (value) {
                    if (arguments.length == 1) {
                        this.setLevel(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.setMessage = function (value) {
                    if (arguments.length == 1) {
                        this._message = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.setScope = function (value) {
                    if (arguments.length == 1) {
                        this._scope = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.setThreadId = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._threadId = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.setTimestamp = function (value) {
                    if (arguments.length == 1) {
                        this._timestamp = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.LogEvent.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogEvent.prototype.toString = function () {
                    if (arguments.length == 0) {
                        var product = fm.icelink.LogProvider.getProduct();
                        var str2 = fm.icelink.StringExtensions.format("[{0}][{1}][{2}] {3} [{4}][{5}] {6} {7}", [product, "0", fm.icelink.NumberExtensions.toString(this.getThreadId()), fm.icelink.LogProvider.getLogLevelString(this.getLevel()), ((fm.icelink.Global.equals(this.getTag(), null)) ? "-" : this.getTag()), ((fm.icelink.Global.equals(this.getScope(), null)) ? "-" : this.getScope()), fm.icelink.LogProvider.getPrefixTimestamp(this.getTimestamp()), this.getMessage()]);
                        if ((!fm.icelink.Global.equals(this.getException(), null))) {
                            str2 = fm.icelink.StringExtensions.concat(str2, fm.icelink.StringExtensions.format("\n{0}", this.getException().toString()));
                        }
                        return str2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LogEvent;
            }());
            icelink.LogEvent = LogEvent;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HashTypeWrapper =  (function () {
                function HashTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_10 = __arguments[0];
                        this._value = value_10;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                HashTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.HashTypeWrapper]';
                };
                HashTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.HashType.Md5)
                            return 'Md5';
                        if (this._value == fm.icelink.HashType.Sha1)
                            return 'Sha1';
                        if (this._value == fm.icelink.HashType.Sha256)
                            return 'Sha256';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HashTypeWrapper;
            }());
            icelink.HashTypeWrapper = HashTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MacTypeWrapper =  (function () {
                function MacTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_11 = __arguments[0];
                        this._value = value_11;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                MacTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.MacTypeWrapper]';
                };
                MacTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.MacType.HmacMd5)
                            return 'HmacMd5';
                        if (this._value == fm.icelink.MacType.HmacSha1)
                            return 'HmacSha1';
                        if (this._value == fm.icelink.MacType.HmacSha256)
                            return 'HmacSha256';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MacTypeWrapper;
            }());
            icelink.MacTypeWrapper = MacTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var UnixTimestamp =  (function () {
                function UnixTimestamp() {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                UnixTimestamp.prototype.getTypeString = function () {
                    return '[fm.icelink.UnixTimestamp]';
                };
                UnixTimestamp.dateTimeToUnix = function (dateTime) {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.UnixTimestamp.ticksToUnix(dateTime.getTicks());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnixTimestamp.dateTimeToUnixMillis = function (dateTime) {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.UnixTimestamp.ticksToUnixMillis(dateTime.getTicks());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnixTimestamp.getUtcNow = function () {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.UnixTimestamp.dateTimeToUnix(fm.icelink.DateTime.getUtcNow());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnixTimestamp.getUtcNowMillis = function () {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.UnixTimestamp.dateTimeToUnixMillis(fm.icelink.DateTime.getUtcNow());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnixTimestamp.ticksToUnix = function (ticks) {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    if (arguments.length == 1) {
                        ticks = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.MathAssistant.floor((ticks - fm.icelink.UnixTimestamp.fm_icelink_UnixTimestamp__baseTicks) / fm.icelink.Constants.getTicksPerSecond());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnixTimestamp.ticksToUnixMillis = function (ticks) {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    if (arguments.length == 1) {
                        ticks = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.MathAssistant.floor((ticks - fm.icelink.UnixTimestamp.fm_icelink_UnixTimestamp__baseTicks) / fm.icelink.Constants.getTicksPerMillisecond());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnixTimestamp.unixMillisToDateTime = function (unix) {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    if (arguments.length == 1) {
                        unix = fm.icelink.Global.toInt(arguments[0]);
                        return new fm.icelink.DateTime(fm.icelink.UnixTimestamp.unixMillisToTicks(unix));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnixTimestamp.unixMillisToTicks = function (unix) {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    if (arguments.length == 1) {
                        unix = fm.icelink.Global.toInt(arguments[0]);
                        return (fm.icelink.UnixTimestamp.fm_icelink_UnixTimestamp__baseTicks + (unix * fm.icelink.Constants.getTicksPerMillisecond()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnixTimestamp.unixToDateTime = function (unix) {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    if (arguments.length == 1) {
                        unix = fm.icelink.Global.toInt(arguments[0]);
                        return new fm.icelink.DateTime(fm.icelink.UnixTimestamp.unixToTicks(unix));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnixTimestamp.unixToTicks = function (unix) {
                    fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
                    if (arguments.length == 1) {
                        unix = fm.icelink.Global.toInt(arguments[0]);
                        return (fm.icelink.UnixTimestamp.fm_icelink_UnixTimestamp__baseTicks + (unix * fm.icelink.Constants.getTicksPerSecond()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnixTimestamp.fmicelinkUnixTimestampInitialize = function () {
                    if (!fm.icelink.UnixTimestamp.__fmicelinkUnixTimestampInitialized && !fm.icelink.UnixTimestamp.__fmicelinkUnixTimestampInitializing) {
                        fm.icelink.UnixTimestamp.__fmicelinkUnixTimestampInitializing = true;
                        UnixTimestamp.fm_icelink_UnixTimestamp__baseTicks = 0;
                        var time = new fm.icelink.DateTime(1970, 1, 1, 0, 0, 0);
                        fm.icelink.UnixTimestamp.fm_icelink_UnixTimestamp__baseTicks = time.getTicks();
                        fm.icelink.UnixTimestamp.__fmicelinkUnixTimestampInitialized = true;
                        fm.icelink.UnixTimestamp.__fmicelinkUnixTimestampInitializing = false;
                    }
                };
                UnixTimestamp.__fmicelinkUnixTimestampInitialized = false;
                UnixTimestamp.__fmicelinkUnixTimestampInitializing = false;
                return UnixTimestamp;
            }());
            icelink.UnixTimestamp = UnixTimestamp;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DoubleHolder =  (function () {
                function DoubleHolder() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkDoubleHolderInit();
                    }
                    else if (__arguments.length == 1) {
                        var value = __arguments[0];
                        this.fmicelinkDoubleHolderInit();
                        this.setValue(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                DoubleHolder.prototype.getTypeString = function () {
                    return '[fm.icelink.DoubleHolder]';
                };
                DoubleHolder.prototype.fmicelinkDoubleHolderInit = function () {
                    this._value = 0;
                };
                DoubleHolder.prototype.getValue = function () {
                    if (arguments.length == 0) {
                        return this._value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DoubleHolder.prototype.setValue = function (value) {
                    if (arguments.length == 1) {
                        this._value = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DoubleHolder;
            }());
            icelink.DoubleHolder = DoubleHolder;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Serializable =  (function () {
                function Serializable() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkSerializableInit();
                        this.setIsSerialized(false);
                        this.setIsDirty(false);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Serializable.prototype.getTypeString = function () {
                    return '[fm.icelink.Serializable]';
                };
                Serializable.prototype.fmicelinkSerializableInit = function () {
                    this._isDirty = false;
                    this._isSerialized = false;
                };
                Serializable.prototype.getIsDirty = function () {
                    if (arguments.length == 0) {
                        return this._isDirty;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Serializable.prototype.getIsSerialized = function () {
                    if (arguments.length == 0) {
                        return this._isSerialized;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Serializable.prototype.getSerialized = function () {
                    if (arguments.length == 0) {
                        return this.__serialized;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Serializable.prototype.setIsDirty = function (value) {
                    if (arguments.length == 1) {
                        this._isDirty = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Serializable.prototype.setIsSerialized = function (value) {
                    if (arguments.length == 1) {
                        this._isSerialized = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Serializable.prototype.setSerialized = function (value) {
                    if (arguments.length == 1) {
                        this.__serialized = value;
                        this.setIsSerialized(true);
                        this.setIsDirty(false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Serializable;
            }());
            icelink.Serializable = Serializable;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Dynamic =  (function (_super) {
                __extends(Dynamic, _super);
                function Dynamic() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.__dynamicProperties = null;
                        _this.__dynamicPropertiesLock = new Object();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                Dynamic.prototype.getTypeString = function () {
                    return '[fm.icelink.Dynamic]' + ',' + _super.prototype.getTypeString.call(this);
                };
                Dynamic.prototype.getDynamicProperties = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(this.__dynamicProperties, null))) {
                            return null;
                        }
                        var dictionary = {};
                        for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(this.__dynamicProperties); _i < _a.length; _i++) {
                            var str = _a[_i];
                            dictionary[str] = this.__dynamicProperties[str];
                        }
                        return dictionary;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Dynamic.prototype.getDynamicValue = function (key) {
                    if (arguments.length == 1) {
                        var obj2 = null;
                        this.tryInitDynamicProperties();
                        var _var0 = new fm.icelink.Holder(obj2);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__dynamicProperties, key, _var0);
                        obj2 = _var0.getValue();
                        if (_var1) {
                            return obj2;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Dynamic.prototype.setDynamicProperties = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            this.__dynamicProperties = null;
                        }
                        else {
                            this.__dynamicProperties = {};
                            for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(value); _i < _a.length; _i++) {
                                var str = _a[_i];
                                this.__dynamicProperties[str] = value[str];
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Dynamic.prototype.setDynamicValue = function (key, value) {
                    if (arguments.length == 2) {
                        this.tryInitDynamicProperties();
                        this.__dynamicProperties[key] = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Dynamic.prototype.tryInitDynamicProperties = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(this.__dynamicProperties, null))) {
                            this.__dynamicProperties = {};
                            return true;
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Dynamic.prototype.unsetDynamicValue = function (key) {
                    if (arguments.length == 1) {
                        this.tryInitDynamicProperties();
                        return fm.icelink.HashExtensions.remove(this.__dynamicProperties, key);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Dynamic;
            }(fm.icelink.Serializable));
            icelink.Dynamic = Dynamic;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Error =  (function () {
                function Error() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else if (__arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isError(arguments[1]))) {
                        var code = __arguments[0];
                        var exception = __arguments[1];
                        this.setCode(code);
                        this.setException(exception);
                    }
                    else if (__arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isString(arguments[1]))) {
                        var code = __arguments[0];
                        var message = __arguments[1];
                        this.setCode(code);
                        this.setMessage(message);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Error.prototype.getTypeString = function () {
                    return '[fm.icelink.Error]';
                };
                Error.fromJson = function (errorJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(errorJson, function () {
                            return new fm.icelink.Error();
                        }, function (error, name, valueJson) {
                            var str = name;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "code"))) {
                                    if ((fm.icelink.Global.equals(str, "message"))) {
                                        error.setMessage(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                }
                                else {
                                    error.setCodeValue(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.toJson = function (error) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(error, function (obj, jsonObject) {
                            jsonObject["code"] = fm.icelink.JsonSerializer.serializeInteger(obj.getCodeValue());
                            if ((!fm.icelink.Global.equals(error.getMessage(), null))) {
                                jsonObject["message"] = fm.icelink.JsonSerializer.serializeString(obj.getMessage());
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.getCode = function () {
                    if (arguments.length == 0) {
                        return this._code;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.getCodeValue = function () {
                    if (arguments.length == 0) {
                        return this.getCode();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.getDescription = function () {
                    if (arguments.length == 0) {
                        var str = new fm.icelink.ErrorCodeWrapper(this.getCode()).toString();
                        var message = this.getMessage();
                        if ((!fm.icelink.Global.equals(message, null))) {
                            str = fm.icelink.StringExtensions.concat(str, " ", message);
                        }
                        str = fm.icelink.StringExtensions.trimEnd(str, new Array(0));
                        if (!fm.icelink.StringExtensions.endsWith(str, ".")) {
                            str = fm.icelink.StringExtensions.concat(str, ".");
                        }
                        return str;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.getErrorCode = function () {
                    if (arguments.length == 0) {
                        return this.getCode();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.getException = function () {
                    if (arguments.length == 0) {
                        return this._exception;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.getMessage = function () {
                    if (arguments.length == 0) {
                        return ((fm.icelink.Global.equals(this.getException(), null)) ? null : this.getException().message);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.setCode = function (value) {
                    if (arguments.length == 1) {
                        this._code = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.setCodeValue = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.setCode(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.setErrorCode = function (value) {
                    if (arguments.length == 1) {
                        this.setCode(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.setException = function (value) {
                    if (arguments.length == 1) {
                        this._exception = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.setMessage = function (value) {
                    if (arguments.length == 1) {
                        this.setException(((fm.icelink.Global.equals(value, null)) ? null : new fm.icelink.Exception(value)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Error.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Error.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return this.getDescription();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Error;
            }());
            icelink.Error = Error;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ErrorCodeWrapper =  (function () {
                function ErrorCodeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_12 = __arguments[0];
                        this._value = value_12;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                ErrorCodeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.ErrorCodeWrapper]';
                };
                ErrorCodeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.ErrorCode.SocketSendError)
                            return 'SocketSendError';
                        if (this._value == fm.icelink.ErrorCode.SocketReceiveError)
                            return 'SocketReceiveError';
                        if (this._value == fm.icelink.ErrorCode.SocketClosed)
                            return 'SocketClosed';
                        if (this._value == fm.icelink.ErrorCode.SocketSendBufferFull)
                            return 'SocketSendBufferFull';
                        if (this._value == fm.icelink.ErrorCode.IPProtocolMismatch)
                            return 'IPProtocolMismatch';
                        if (this._value == fm.icelink.ErrorCode.PacketTooLarge)
                            return 'PacketTooLarge';
                        if (this._value == fm.icelink.ErrorCode.NetworkUnreachable)
                            return 'NetworkUnreachable';
                        if (this._value == fm.icelink.ErrorCode.StunTryAlternate)
                            return 'StunTryAlternate';
                        if (this._value == fm.icelink.ErrorCode.StunBadRequest)
                            return 'StunBadRequest';
                        if (this._value == fm.icelink.ErrorCode.StunUnauthorized)
                            return 'StunUnauthorized';
                        if (this._value == fm.icelink.ErrorCode.StunTurnForbidden)
                            return 'StunTurnForbidden';
                        if (this._value == fm.icelink.ErrorCode.StunTurnMobilityForbidden)
                            return 'StunTurnMobilityForbidden';
                        if (this._value == fm.icelink.ErrorCode.StunUnknownAttribute)
                            return 'StunUnknownAttribute';
                        if (this._value == fm.icelink.ErrorCode.StunStaleCredentials)
                            return 'StunStaleCredentials';
                        if (this._value == fm.icelink.ErrorCode.StunIntegrityCheckFailure)
                            return 'StunIntegrityCheckFailure';
                        if (this._value == fm.icelink.ErrorCode.StunMissingUsername)
                            return 'StunMissingUsername';
                        if (this._value == fm.icelink.ErrorCode.StunTurnAllocationMismatch)
                            return 'StunTurnAllocationMismatch';
                        if (this._value == fm.icelink.ErrorCode.StunStaleNonce)
                            return 'StunStaleNonce';
                        if (this._value == fm.icelink.ErrorCode.StunAddressFamilyNotSupported)
                            return 'StunAddressFamilyNotSupported';
                        if (this._value == fm.icelink.ErrorCode.StunTurnWrongCredentials)
                            return 'StunTurnWrongCredentials';
                        if (this._value == fm.icelink.ErrorCode.StunTurnUnsupportedTransportProtocol)
                            return 'StunTurnUnsupportedTransportProtocol';
                        if (this._value == fm.icelink.ErrorCode.StunTurnPeerAddressFamilyMismatch)
                            return 'StunTurnPeerAddressFamilyMismatch';
                        if (this._value == fm.icelink.ErrorCode.StunTurnConnectionAlreadyExists)
                            return 'StunTurnConnectionAlreadyExists';
                        if (this._value == fm.icelink.ErrorCode.StunTurnConnectionTimeoutOrFailure)
                            return 'StunTurnConnectionTimeoutOrFailure';
                        if (this._value == fm.icelink.ErrorCode.StunTurnAllocationQuotaReached)
                            return 'StunTurnAllocationQuotaReached';
                        if (this._value == fm.icelink.ErrorCode.StunIceRoleConflict)
                            return 'StunIceRoleConflict';
                        if (this._value == fm.icelink.ErrorCode.StunServerError)
                            return 'StunServerError';
                        if (this._value == fm.icelink.ErrorCode.StunTurnInsufficientCapacity)
                            return 'StunTurnInsufficientCapacity';
                        if (this._value == fm.icelink.ErrorCode.StunInvalidResponseType)
                            return 'StunInvalidResponseType';
                        if (this._value == fm.icelink.ErrorCode.StunInvalidErrorCode)
                            return 'StunInvalidErrorCode';
                        if (this._value == fm.icelink.ErrorCode.StunInvalidTransactionId)
                            return 'StunInvalidTransactionId';
                        if (this._value == fm.icelink.ErrorCode.StunUnknownStunErrorCode)
                            return 'StunUnknownStunErrorCode';
                        if (this._value == fm.icelink.ErrorCode.StunInvalidMessageIntegrity)
                            return 'StunInvalidMessageIntegrity';
                        if (this._value == fm.icelink.ErrorCode.SocketIPError)
                            return 'SocketIPError';
                        if (this._value == fm.icelink.ErrorCode.IceLocalRelayedDatagramCandidateError)
                            return 'IceLocalRelayedDatagramCandidateError';
                        if (this._value == fm.icelink.ErrorCode.IceLocalServerReflexiveCandidateError)
                            return 'IceLocalServerReflexiveCandidateError';
                        if (this._value == fm.icelink.ErrorCode.SocketManagerInvalidState)
                            return 'SocketManagerInvalidState';
                        if (this._value == fm.icelink.ErrorCode.IceStartError)
                            return 'IceStartError';
                        if (this._value == fm.icelink.ErrorCode.IceUnsuitableSocketAssignment)
                            return 'IceUnsuitableSocketAssignment';
                        if (this._value == fm.icelink.ErrorCode.IceAllPortsInUse)
                            return 'IceAllPortsInUse';
                        if (this._value == fm.icelink.ErrorCode.IceLocalAddressUnavailable)
                            return 'IceLocalAddressUnavailable';
                        if (this._value == fm.icelink.ErrorCode.IceGenericGathererError)
                            return 'IceGenericGathererError';
                        if (this._value == fm.icelink.ErrorCode.IceRefreshTimeout)
                            return 'IceRefreshTimeout';
                        if (this._value == fm.icelink.ErrorCode.IceRefreshError)
                            return 'IceRefreshError';
                        if (this._value == fm.icelink.ErrorCode.IceCreatePermissionTimeout)
                            return 'IceCreatePermissionTimeout';
                        if (this._value == fm.icelink.ErrorCode.IceCreatePermissionError)
                            return 'IceCreatePermissionError';
                        if (this._value == fm.icelink.ErrorCode.IceConnectivityCheckFailed)
                            return 'IceConnectivityCheckFailed';
                        if (this._value == fm.icelink.ErrorCode.IceSendError)
                            return 'IceSendError';
                        if (this._value == fm.icelink.ErrorCode.IcePeerReflexiveError)
                            return 'IcePeerReflexiveError';
                        if (this._value == fm.icelink.ErrorCode.IncompatibleIceSetup)
                            return 'IncompatibleIceSetup';
                        if (this._value == fm.icelink.ErrorCode.DtlsInternalError)
                            return 'DtlsInternalError';
                        if (this._value == fm.icelink.ErrorCode.DtlsKeyExchangeFailed)
                            return 'DtlsKeyExchangeFailed';
                        if (this._value == fm.icelink.ErrorCode.DtlsNotReady)
                            return 'DtlsNotReady';
                        if (this._value == fm.icelink.ErrorCode.SctpNoPayloadData)
                            return 'SctpNoPayloadData';
                        if (this._value == fm.icelink.ErrorCode.SctpUnsupportedStream)
                            return 'SctpUnsupportedStream';
                        if (this._value == fm.icelink.ErrorCode.SctpInvalidState)
                            return 'SctpInvalidState';
                        if (this._value == fm.icelink.ErrorCode.SctpInternalError)
                            return 'SctpInternalError';
                        if (this._value == fm.icelink.ErrorCode.MediaTransportFailed)
                            return 'MediaTransportFailed';
                        if (this._value == fm.icelink.ErrorCode.ReliableDataChannelOpenError)
                            return 'ReliableDataChannelOpenError';
                        if (this._value == fm.icelink.ErrorCode.ReliableDataChannelSendError)
                            return 'ReliableDataChannelSendError';
                        if (this._value == fm.icelink.ErrorCode.ConnectionInvalidArchitecture)
                            return 'ConnectionInvalidArchitecture';
                        if (this._value == fm.icelink.ErrorCode.ConnectionInternalError)
                            return 'ConnectionInternalError';
                        if (this._value == fm.icelink.ErrorCode.ConnectionTransportStartError)
                            return 'ConnectionTransportStartError';
                        if (this._value == fm.icelink.ErrorCode.ConnectionTransportClosed)
                            return 'ConnectionTransportClosed';
                        if (this._value == fm.icelink.ErrorCode.ConnectionDeadStream)
                            return 'ConnectionDeadStream';
                        if (this._value == fm.icelink.ErrorCode.ConnectionNotEstablished)
                            return 'ConnectionNotEstablished';
                        if (this._value == fm.icelink.ErrorCode.ConnectionRemoteFailure)
                            return 'ConnectionRemoteFailure';
                        if (this._value == fm.icelink.ErrorCode.ConnectionSimulcastNotSupported)
                            return 'ConnectionSimulcastNotSupported';
                        if (this._value == fm.icelink.ErrorCode.StreamDisabled)
                            return 'StreamDisabled';
                        if (this._value == fm.icelink.ErrorCode.StreamEncryptionMismatch)
                            return 'StreamEncryptionMismatch';
                        if (this._value == fm.icelink.ErrorCode.StreamDirectionMismatch)
                            return 'StreamDirectionMismatch';
                        if (this._value == fm.icelink.ErrorCode.DataStreamDirectionCannotBeChanged)
                            return 'DataStreamDirectionCannotBeChanged';
                        if (this._value == fm.icelink.ErrorCode.InvalidStreamDirectionChange)
                            return 'InvalidStreamDirectionChange';
                        if (this._value == fm.icelink.ErrorCode.LocalDescriptionError)
                            return 'LocalDescriptionError';
                        if (this._value == fm.icelink.ErrorCode.RemoteDescriptionError)
                            return 'RemoteDescriptionError';
                        if (this._value == fm.icelink.ErrorCode.IceLocalRelayedStreamCandidateError)
                            return 'IceLocalRelayedStreamCandidateError';
                        if (this._value == fm.icelink.ErrorCode.IceInvalidServerAssignmentError)
                            return 'IceInvalidServerAssignmentError';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ErrorCodeWrapper;
            }());
            icelink.ErrorCodeWrapper = ErrorCodeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var FloatHolder =  (function () {
                function FloatHolder() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkFloatHolderInit();
                    }
                    else if (__arguments.length == 1) {
                        var value = __arguments[0];
                        this.fmicelinkFloatHolderInit();
                        this.setValue(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                FloatHolder.prototype.getTypeString = function () {
                    return '[fm.icelink.FloatHolder]';
                };
                FloatHolder.prototype.fmicelinkFloatHolderInit = function () {
                    this._value = 0;
                };
                FloatHolder.prototype.getValue = function () {
                    if (arguments.length == 0) {
                        return this._value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FloatHolder.prototype.setValue = function (value) {
                    if (arguments.length == 1) {
                        this._value = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return FloatHolder;
            }());
            icelink.FloatHolder = FloatHolder;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpMethodWrapper =  (function () {
                function HttpMethodWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_13 = __arguments[0];
                        this._value = value_13;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                HttpMethodWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpMethodWrapper]';
                };
                HttpMethodWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.HttpMethod.Get)
                            return 'Get';
                        if (this._value == fm.icelink.HttpMethod.Head)
                            return 'Head';
                        if (this._value == fm.icelink.HttpMethod.Post)
                            return 'Post';
                        if (this._value == fm.icelink.HttpMethod.Put)
                            return 'Put';
                        if (this._value == fm.icelink.HttpMethod.Patch)
                            return 'Patch';
                        if (this._value == fm.icelink.HttpMethod.Delete)
                            return 'Delete';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HttpMethodWrapper;
            }());
            icelink.HttpMethodWrapper = HttpMethodWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpRequestArgs =  (function (_super) {
                __extends(HttpRequestArgs, _super);
                function HttpRequestArgs() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkHttpRequestArgsInit();
                        _this.setTimeout(15000);
                        _this.setMethod(fm.icelink.HttpMethod.Post);
                        _this.__headers = new fm.icelink.NameValueCollection();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                HttpRequestArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpRequestArgs]' + ',' + _super.prototype.getTypeString.call(this);
                };
                HttpRequestArgs.prototype.fmicelinkHttpRequestArgsInit = function () {
                    this._maxRetries = 0;
                    this._timeout = 0;
                };
                HttpRequestArgs.prototype.getBinaryContent = function () {
                    if (arguments.length == 0) {
                        return this._binaryContent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.getHeaders = function () {
                    if (arguments.length == 0) {
                        return this.__headers;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.getMaxRetries = function () {
                    if (arguments.length == 0) {
                        return this._maxRetries;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.getMethod = function () {
                    if (arguments.length == 0) {
                        return this._method;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.getOnRequestCreated = function () {
                    if (arguments.length == 0) {
                        return this._onRequestCreated;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.getOnResponseReceived = function () {
                    if (arguments.length == 0) {
                        return this._onResponseReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.getSender = function () {
                    if (arguments.length == 0) {
                        return this._sender;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.getTextContent = function () {
                    if (arguments.length == 0) {
                        return this._textContent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.getTimeout = function () {
                    if (arguments.length == 0) {
                        return this._timeout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.getUrl = function () {
                    if (arguments.length == 0) {
                        return this._url;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.setBinaryContent = function (value) {
                    if (arguments.length == 1) {
                        this._binaryContent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.setHeaders = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            this.__headers = new fm.icelink.NameValueCollection();
                        }
                        else {
                            this.__headers = value;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.setMaxRetries = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._maxRetries = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.setMethod = function (value) {
                    if (arguments.length == 1) {
                        this._method = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.setOnRequestCreated = function (value) {
                    if (arguments.length == 1) {
                        this._onRequestCreated = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.setOnResponseReceived = function (value) {
                    if (arguments.length == 1) {
                        this._onResponseReceived = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.setSender = function (value) {
                    if (arguments.length == 1) {
                        this._sender = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.setTextContent = function (value) {
                    if (arguments.length == 1) {
                        this._textContent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.setTimeout = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._timeout = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestArgs.prototype.setUrl = function (value) {
                    if (arguments.length == 1) {
                        this._url = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HttpRequestArgs;
            }(fm.icelink.Dynamic));
            icelink.HttpRequestArgs = HttpRequestArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpRequestCreatedArgs =  (function () {
                function HttpRequestCreatedArgs() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                HttpRequestCreatedArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpRequestCreatedArgs]';
                };
                HttpRequestCreatedArgs.prototype.getRequest = function () {
                    if (arguments.length == 0) {
                        return this._request;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestCreatedArgs.prototype.getRequestArgs = function () {
                    if (arguments.length == 0) {
                        return this._requestArgs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestCreatedArgs.prototype.getSender = function () {
                    if (arguments.length == 0) {
                        return this._sender;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestCreatedArgs.prototype.setRequest = function (value) {
                    if (arguments.length == 1) {
                        this._request = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestCreatedArgs.prototype.setRequestArgs = function (value) {
                    if (arguments.length == 1) {
                        this._requestArgs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpRequestCreatedArgs.prototype.setSender = function (value) {
                    if (arguments.length == 1) {
                        this._sender = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HttpRequestCreatedArgs;
            }());
            icelink.HttpRequestCreatedArgs = HttpRequestCreatedArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpResponseArgs =  (function () {
                function HttpResponseArgs() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkHttpResponseArgsInit();
                        this.setHeaders(new fm.icelink.NameValueCollection());
                    }
                    else if (__arguments.length == 1) {
                        var requestArgs = __arguments[0];
                        __arguments = new Array(0);
                        {
                            this.fmicelinkHttpResponseArgsInit();
                            this.setHeaders(new fm.icelink.NameValueCollection());
                        }
                        this.setRequestArgs(requestArgs);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                HttpResponseArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpResponseArgs]';
                };
                HttpResponseArgs.prototype.fmicelinkHttpResponseArgsInit = function () {
                    this._retries = 0;
                    this._statusCode = 0;
                };
                HttpResponseArgs.prototype.getBinaryContent = function () {
                    if (arguments.length == 0) {
                        return this._binaryContent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.getException = function () {
                    if (arguments.length == 0) {
                        return this._exception;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.getHeaders = function () {
                    if (arguments.length == 0) {
                        return this._headers;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.getRequestArgs = function () {
                    if (arguments.length == 0) {
                        return this._requestArgs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.getRetries = function () {
                    if (arguments.length == 0) {
                        return this._retries;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.getStatusCode = function () {
                    if (arguments.length == 0) {
                        return this._statusCode;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.getTextContent = function () {
                    if (arguments.length == 0) {
                        return this._textContent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.setBinaryContent = function (value) {
                    if (arguments.length == 1) {
                        this._binaryContent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.setException = function (value) {
                    if (arguments.length == 1) {
                        this._exception = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.setHeaders = function (value) {
                    if (arguments.length == 1) {
                        this._headers = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.setRequestArgs = function (value) {
                    if (arguments.length == 1) {
                        this._requestArgs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.setRetries = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._retries = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.setStatusCode = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._statusCode = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseArgs.prototype.setTextContent = function (value) {
                    if (arguments.length == 1) {
                        this._textContent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HttpResponseArgs;
            }());
            icelink.HttpResponseArgs = HttpResponseArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpResponseReceivedArgs =  (function () {
                function HttpResponseReceivedArgs() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                HttpResponseReceivedArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpResponseReceivedArgs]';
                };
                HttpResponseReceivedArgs.prototype.getRequestArgs = function () {
                    if (arguments.length == 0) {
                        return this._requestArgs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseReceivedArgs.prototype.getResponse = function () {
                    if (arguments.length == 0) {
                        return this._response;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseReceivedArgs.prototype.getSender = function () {
                    if (arguments.length == 0) {
                        return this._sender;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseReceivedArgs.prototype.setRequestArgs = function (value) {
                    if (arguments.length == 1) {
                        this._requestArgs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseReceivedArgs.prototype.setResponse = function (value) {
                    if (arguments.length == 1) {
                        this._response = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpResponseReceivedArgs.prototype.setSender = function (value) {
                    if (arguments.length == 1) {
                        this._sender = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HttpResponseReceivedArgs;
            }());
            icelink.HttpResponseReceivedArgs = HttpResponseReceivedArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpSendFinishArgs =  (function () {
                function HttpSendFinishArgs() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                HttpSendFinishArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpSendFinishArgs]';
                };
                HttpSendFinishArgs.prototype.getRequestBinaryContent = function () {
                    if (arguments.length == 0) {
                        return this._requestBinaryContent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.getRequestTextContent = function () {
                    if (arguments.length == 0) {
                        return this._requestTextContent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.getResponseBinaryContent = function () {
                    if (arguments.length == 0) {
                        return this._responseBinaryContent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.getResponseHeaders = function () {
                    if (arguments.length == 0) {
                        return this._responseHeaders;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.getResponseTextContent = function () {
                    if (arguments.length == 0) {
                        return this._responseTextContent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.getSender = function () {
                    if (arguments.length == 0) {
                        return this._sender;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.setRequestBinaryContent = function (value) {
                    if (arguments.length == 1) {
                        this._requestBinaryContent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.setRequestTextContent = function (value) {
                    if (arguments.length == 1) {
                        this._requestTextContent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.setResponseBinaryContent = function (value) {
                    if (arguments.length == 1) {
                        this._responseBinaryContent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.setResponseHeaders = function (value) {
                    if (arguments.length == 1) {
                        this._responseHeaders = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.setResponseTextContent = function (value) {
                    if (arguments.length == 1) {
                        this._responseTextContent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendFinishArgs.prototype.setSender = function (value) {
                    if (arguments.length == 1) {
                        this._sender = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HttpSendFinishArgs;
            }());
            icelink.HttpSendFinishArgs = HttpSendFinishArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpSendStartArgs =  (function () {
                function HttpSendStartArgs() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                HttpSendStartArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpSendStartArgs]';
                };
                HttpSendStartArgs.prototype.getRequestBinaryContent = function () {
                    if (arguments.length == 0) {
                        return this._requestBinaryContent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendStartArgs.prototype.getRequestTextContent = function () {
                    if (arguments.length == 0) {
                        return this._requestTextContent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendStartArgs.prototype.getSender = function () {
                    if (arguments.length == 0) {
                        return this._sender;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendStartArgs.prototype.setRequestBinaryContent = function (value) {
                    if (arguments.length == 1) {
                        this._requestBinaryContent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendStartArgs.prototype.setRequestTextContent = function (value) {
                    if (arguments.length == 1) {
                        this._requestTextContent = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpSendStartArgs.prototype.setSender = function (value) {
                    if (arguments.length == 1) {
                        this._sender = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HttpSendStartArgs;
            }());
            icelink.HttpSendStartArgs = HttpSendStartArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpTransferFactory =  (function () {
                function HttpTransferFactory() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                HttpTransferFactory.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpTransferFactory]';
                };
                HttpTransferFactory.defaultCreateHttpTransfer = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.HttpWebRequestTransfer();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransferFactory.getCreateHttpTransfer = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.HttpTransferFactory.fm_icelink_HttpTransferFactory__createHttpTransfer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransferFactory.getHttpTransfer = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(fm.icelink.HttpTransferFactory.getCreateHttpTransfer(), null))) {
                            fm.icelink.HttpTransferFactory.setCreateHttpTransfer(fm.icelink.HttpTransferFactory.defaultCreateHttpTransfer.bind(fm.icelink.HttpTransferFactory));
                        }
                        var transfer = fm.icelink.HttpTransferFactory.getCreateHttpTransfer()();
                        if ((fm.icelink.Global.equals(transfer, null))) {
                            transfer = fm.icelink.HttpTransferFactory.defaultCreateHttpTransfer();
                        }
                        return transfer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpTransferFactory.setCreateHttpTransfer = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.HttpTransferFactory.fm_icelink_HttpTransferFactory__createHttpTransfer = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HttpTransferFactory;
            }());
            icelink.HttpTransferFactory = HttpTransferFactory;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var HttpWebRequestSender =  (function (_super) {
                __extends(HttpWebRequestSender, _super);
                function HttpWebRequestSender() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkHttpWebRequestSenderInit();
                        _this.__disableJsonp = true;
                        _this.__forceJsonp = false;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                HttpWebRequestSender.prototype.getTypeString = function () {
                    return '[fm.icelink.HttpWebRequestSender]' + ',' + _super.prototype.getTypeString.call(this);
                };
                HttpWebRequestSender.prototype.fmicelinkHttpWebRequestSenderInit = function () {
                    this.__disableJsonp = false;
                    this.__forceJsonp = false;
                    this._disableCors = false;
                    this._disablePostMessage = false;
                };
                HttpWebRequestSender.prototype.getDisableCors = function () {
                    if (arguments.length == 0) {
                        return this._disableCors;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpWebRequestSender.prototype.getDisableJsonp = function () {
                    if (arguments.length == 0) {
                        return this.__disableJsonp;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpWebRequestSender.prototype.getDisablePostMessage = function () {
                    if (arguments.length == 0) {
                        return this._disablePostMessage;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpWebRequestSender.prototype.getForceJsonp = function () {
                    if (arguments.length == 0) {
                        return this.__forceJsonp;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpWebRequestSender.prototype.setDisableCors = function (value) {
                    if (arguments.length == 1) {
                        this._disableCors = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpWebRequestSender.prototype.setDisableJsonp = function (value) {
                    if (arguments.length == 1) {
                        this.__disableJsonp = value;
                        if (this.__disableJsonp) {
                            this.__forceJsonp = false;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpWebRequestSender.prototype.setDisablePostMessage = function (value) {
                    if (arguments.length == 1) {
                        this._disablePostMessage = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                HttpWebRequestSender.prototype.setForceJsonp = function (value) {
                    if (arguments.length == 1) {
                        this.__forceJsonp = value;
                        if (this.__forceJsonp) {
                            this.__disableJsonp = false;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return HttpWebRequestSender;
            }(fm.icelink.Dynamic));
            icelink.HttpWebRequestSender = HttpWebRequestSender;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var IntegerHolder =  (function () {
                function IntegerHolder() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkIntegerHolderInit();
                    }
                    else if (__arguments.length == 1) {
                        var value = __arguments[0];
                        this.fmicelinkIntegerHolderInit();
                        this.setValue(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                IntegerHolder.prototype.getTypeString = function () {
                    return '[fm.icelink.IntegerHolder]';
                };
                IntegerHolder.prototype.fmicelinkIntegerHolderInit = function () {
                    this._value = 0;
                };
                IntegerHolder.prototype.getValue = function () {
                    if (arguments.length == 0) {
                        return this._value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IntegerHolder.prototype.setValue = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._value = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return IntegerHolder;
            }());
            icelink.IntegerHolder = IntegerHolder;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var JsonChecker =  (function () {
                function JsonChecker() {
                    fm.icelink.JsonChecker.fmicelinkJsonCheckerInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        __arguments = new Array(1);
                        __arguments[0] = 0;
                        {
                            var depth = __arguments[0];
                            this.fmicelinkJsonCheckerInit();
                            if ((depth < 0)) {
                                throw new fm.icelink.Exception("Invalid depth.");
                            }
                            this.__state = 0;
                            this.__depth = depth;
                            this.__stack = new fm.icelink.Stack(depth);
                            this.push(fm.icelink.JsonCheckerMode.Done);
                        }
                    }
                    else if (__arguments.length == 1) {
                        var depth = __arguments[0];
                        this.fmicelinkJsonCheckerInit();
                        if ((depth < 0)) {
                            throw new fm.icelink.Exception("Invalid depth.");
                        }
                        this.__state = 0;
                        this.__depth = depth;
                        this.__stack = new fm.icelink.Stack(depth);
                        this.push(fm.icelink.JsonCheckerMode.Done);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                JsonChecker.prototype.getTypeString = function () {
                    return '[fm.icelink.JsonChecker]';
                };
                JsonChecker.prototype.fmicelinkJsonCheckerInit = function () {
                    this.__depth = 0;
                    this.__offset = 0;
                    this.__state = 0;
                };
                JsonChecker.prototype.check = function (ch) {
                    if (arguments.length == 1) {
                        ch = fm.icelink.Global.toInt(arguments[0]);
                        var num = void 0;
                        if ((ch < 0)) {
                            this.onError();
                        }
                        if ((ch >= 128)) {
                            num = 30;
                        }
                        else {
                            num = fm.icelink.JsonChecker.fm_icelink_JsonChecker__ascii_class[ch];
                            if ((num <= -1)) {
                                this.onError();
                            }
                        }
                        var num2 = fm.icelink.JsonChecker.fm_icelink_JsonChecker__state_transition_table[this.__state][num];
                        if ((num2 >= 0)) {
                            this.__state = num2;
                            this.__offset = (this.__offset + 1);
                        }
                        else {
                            if ((fm.icelink.Global.equals(num2, -9))) {
                                this.pop(fm.icelink.JsonCheckerMode.Key);
                                this.__state = 1;
                            }
                            else {
                                if ((fm.icelink.Global.equals(num2, -8))) {
                                    this.pop(fm.icelink.JsonCheckerMode.Object);
                                    this.__state = 1;
                                }
                                else {
                                    if ((fm.icelink.Global.equals(num2, -7))) {
                                        this.pop(fm.icelink.JsonCheckerMode.Array);
                                        this.__state = 1;
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(num2, -6))) {
                                            this.push(fm.icelink.JsonCheckerMode.Key);
                                            this.__state = 2;
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(num2, -5))) {
                                                this.push(fm.icelink.JsonCheckerMode.Array);
                                                this.__state = 6;
                                            }
                                            else {
                                                var mode = void 0;
                                                if ((fm.icelink.Global.equals(num2, -4))) {
                                                    mode = this.__stack.peek();
                                                    if ((fm.icelink.Global.equals(mode, fm.icelink.JsonCheckerMode.Key))) {
                                                        this.__state = 4;
                                                    }
                                                    else {
                                                        if (((fm.icelink.Global.equals(mode, fm.icelink.JsonCheckerMode.Array)) || (fm.icelink.Global.equals(mode, fm.icelink.JsonCheckerMode.Object)))) {
                                                            this.__state = 1;
                                                        }
                                                        else {
                                                            if ((fm.icelink.Global.equals(mode, fm.icelink.JsonCheckerMode.Done))) {
                                                                this.push(fm.icelink.JsonCheckerMode.String);
                                                                this.__state = 7;
                                                            }
                                                            else {
                                                                if ((fm.icelink.Global.equals(mode, fm.icelink.JsonCheckerMode.String))) {
                                                                    this.pop(fm.icelink.JsonCheckerMode.String);
                                                                    this.__state = 1;
                                                                }
                                                                else {
                                                                    this.onError();
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                else {
                                                    if ((fm.icelink.Global.equals(num2, -3))) {
                                                        mode = this.__stack.peek();
                                                        if ((fm.icelink.Global.equals(mode, fm.icelink.JsonCheckerMode.Object))) {
                                                            this.pop(fm.icelink.JsonCheckerMode.Object);
                                                            this.push(fm.icelink.JsonCheckerMode.Key);
                                                            this.__state = 3;
                                                        }
                                                        else {
                                                            if ((fm.icelink.Global.equals(mode, fm.icelink.JsonCheckerMode.Array))) {
                                                                this.__state = 5;
                                                            }
                                                            else {
                                                                this.onError();
                                                            }
                                                        }
                                                    }
                                                    else {
                                                        if ((fm.icelink.Global.equals(num2, -2))) {
                                                            this.pop(fm.icelink.JsonCheckerMode.Key);
                                                            this.push(fm.icelink.JsonCheckerMode.Object);
                                                            this.__state = 5;
                                                        }
                                                        else {
                                                            this.onError();
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            this.__offset = (this.__offset + 1);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonChecker.prototype.checkString = function (str) {
                    if (arguments.length == 1) {
                        var doubleResult = 0;
                        var decimalResult = 0;
                        var _var0 = new fm.icelink.Holder(doubleResult);
                        var _var1 = fm.icelink.ParseAssistant.tryParseDoubleValue(str, _var0);
                        doubleResult = _var0.getValue();
                        var _var2 = new fm.icelink.Holder(decimalResult);
                        var _var3 = fm.icelink.ParseAssistant.tryParseDecimalValue(str, _var2);
                        decimalResult = _var2.getValue();
                        if (((((fm.icelink.Global.equals(str, "true")) || (fm.icelink.Global.equals(str, "false"))) || ((fm.icelink.Global.equals(str, "null")) || _var1)) || _var3)) {
                            return true;
                        }
                        try {
                            for (var i = 0; (i < fm.icelink.StringExtensions.getLength(str)); i++) {
                                this.check(str.charCodeAt(i));
                            }
                            this.finalCheck();
                            return true;
                        }
                        catch (exception1) {
                            return false;
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonChecker.prototype.finalCheck = function () {
                    if (arguments.length == 0) {
                        if ((!fm.icelink.Global.equals(this.__state, 1))) {
                            this.onError();
                        }
                        this.pop(fm.icelink.JsonCheckerMode.Done);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonChecker.prototype.onError = function () {
                    if (arguments.length == 0) {
                        throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Invalid JSON text at character offset {0}.", fm.icelink.NumberExtensions.toString(this.__offset, "N0")));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonChecker.prototype.pop = function (mode) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.__stack.pop(), mode))) {
                            this.onError();
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonChecker.prototype.push = function (mode) {
                    if (arguments.length == 1) {
                        if (((this.__depth > 0) && (this.__stack.getCount() >= this.__depth))) {
                            this.onError();
                        }
                        this.__stack.push(mode);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                JsonChecker.fmicelinkJsonCheckerInitialize = function () {
                    if (!fm.icelink.JsonChecker.__fmicelinkJsonCheckerInitialized && !fm.icelink.JsonChecker.__fmicelinkJsonCheckerInitializing) {
                        fm.icelink.JsonChecker.__fmicelinkJsonCheckerInitializing = true;
                        fm.icelink.JsonChecker.fm_icelink_JsonChecker__ascii_class = [-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 30, 8, 30, 30, 30, 30, 30, 30, 30, 30, 11, 7, 12, 13, 10, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 6, 30, 30, 30, 30, 30, 30, 28, 28, 28, 28, 29, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 4, 9, 5, 30, 30, 30, 16, 17, 18, 19, 20, 21, 30, 30, 30, 30, 30, 22, 30, 23, 30, 30, 30, 24, 25, 26, 27, 30, 30, 30, 30, 30, 2, 30, 3, 30, 30];
                        fm.icelink.JsonChecker.fm_icelink_JsonChecker__state_transition_table = [[0, 0, -6, -1, -5, -1, -1, -1, -4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, -1, -8, -1, -7, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [2, 2, -1, -9, -1, -1, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [3, 3, -1, -1, -1, -1, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [4, 4, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [5, 5, -6, -1, -5, -1, -1, -1, 7, -1, -1, -1, 13, -1, 14, 15, -1, -1, -1, -1, -1, 23, -1, 27, -1, -1, 20, -1, -1, -1, -1], [6, 6, -6, -1, -5, -7, -1, -1, 7, -1, -1, -1, 13, -1, 14, 15, -1, -1, -1, -1, -1, 23, -1, 27, -1, -1, 20, -1, -1, -1, -1], [7, -1, 7, 7, 7, 7, 7, 7, -4, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [-1, -1, -1, -1, -1, -1, -1, -1, 7, 7, 7, -1, -1, -1, -1, -1, -1, 7, -1, -1, -1, 7, -1, 7, 7, -1, 7, 9, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 10, 10, 10, 10, 10, 10, 10, -1, -1, -1, -1, -1, -1, 10, 10, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 11, 11, 11, 11, 11, 11, 11, -1, -1, -1, -1, -1, -1, 11, 11, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 12, 12, 12, 12, 12, 12, 12, -1, -1, -1, -1, -1, -1, 12, 12, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, 7, 7, 7, 7, 7, 7, 7, -1, -1, -1, -1, -1, -1, 7, 7, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, -1, -8, -1, -7, -1, -3, -1, -1, -1, -1, -1, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, -1, -8, -1, -7, -1, -3, -1, -1, -1, -1, -1, 16, 15, 15, -1, -1, -1, -1, 17, -1, -1, -1, -1, -1, -1, -1, -1, 17, -1], [1, 1, -1, -8, -1, -7, -1, -3, -1, -1, -1, -1, -1, -1, 16, 16, -1, -1, -1, -1, 17, -1, -1, -1, -1, -1, -1, -1, -1, 17, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, 18, -1, 19, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, -1, -8, -1, -7, -1, -3, -1, -1, -1, -1, -1, -1, 19, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1]];
                        fm.icelink.JsonChecker.__fmicelinkJsonCheckerInitialized = true;
                        fm.icelink.JsonChecker.__fmicelinkJsonCheckerInitializing = false;
                    }
                };
                JsonChecker.__fmicelinkJsonCheckerInitialized = false;
                JsonChecker.__fmicelinkJsonCheckerInitializing = false;
                return JsonChecker;
            }());
            icelink.JsonChecker = JsonChecker;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var JsonProvider =  (function () {
                function JsonProvider() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                JsonProvider.prototype.getTypeString = function () {
                    return '[fm.icelink.JsonProvider]';
                };
                return JsonProvider;
            }());
            icelink.JsonProvider = JsonProvider;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LockedRandomizer =  (function () {
                function LockedRandomizer() {
                }
                LockedRandomizer.prototype.getTypeString = function () {
                    return '[fm.icelink.LockedRandomizer]';
                };
                LockedRandomizer.next = function () {
                    fm.icelink.LockedRandomizer.fmicelinkLockedRandomizerInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.LockedRandomizer.fm_icelink_LockedRandomizer__randomizer.next();
                    }
                    else if (arguments.length == 1) {
                        var maxValue = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.LockedRandomizer.fm_icelink_LockedRandomizer__randomizer.next(maxValue);
                    }
                    else if (arguments.length == 2) {
                        var minValue = fm.icelink.Global.toInt(arguments[0]);
                        var maxValue = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.LockedRandomizer.fm_icelink_LockedRandomizer__randomizer.next(minValue, maxValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LockedRandomizer.nextBytes = function (buffer) {
                    fm.icelink.LockedRandomizer.fmicelinkLockedRandomizerInitialize();
                    if (arguments.length == 1) {
                        fm.icelink.LockedRandomizer.fm_icelink_LockedRandomizer__randomizer.nextBytes(buffer);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LockedRandomizer.nextDouble = function () {
                    fm.icelink.LockedRandomizer.fmicelinkLockedRandomizerInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.LockedRandomizer.fm_icelink_LockedRandomizer__randomizer.nextDouble();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LockedRandomizer.nextLong = function () {
                    fm.icelink.LockedRandomizer.fmicelinkLockedRandomizerInitialize();
                    if (arguments.length == 0) {
                        return (fm.icelink.LockedRandomizer.fm_icelink_LockedRandomizer__randomizer.nextDouble() * 9.22337203685478e+18);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LockedRandomizer.randomString = function (size) {
                    fm.icelink.LockedRandomizer.fmicelinkLockedRandomizerInitialize();
                    if (arguments.length == 1) {
                        size = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.LockedRandomizer.fm_icelink_LockedRandomizer__randomizer.randomString(size);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LockedRandomizer.fmicelinkLockedRandomizerInitialize = function () {
                    if (!fm.icelink.LockedRandomizer.__fmicelinkLockedRandomizerInitialized && !fm.icelink.LockedRandomizer.__fmicelinkLockedRandomizerInitializing) {
                        fm.icelink.LockedRandomizer.__fmicelinkLockedRandomizerInitializing = true;
                        fm.icelink.LockedRandomizer.fm_icelink_LockedRandomizer__randomizer = new fm.icelink.Randomizer();
                        fm.icelink.LockedRandomizer.fm_icelink_LockedRandomizer__randomLock = new Object();
                        fm.icelink.LockedRandomizer.__fmicelinkLockedRandomizerInitialized = true;
                        fm.icelink.LockedRandomizer.__fmicelinkLockedRandomizerInitializing = false;
                    }
                };
                LockedRandomizer.__fmicelinkLockedRandomizerInitialized = false;
                LockedRandomizer.__fmicelinkLockedRandomizerInitializing = false;
                return LockedRandomizer;
            }());
            icelink.LockedRandomizer = LockedRandomizer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Log =  (function () {
                function Log() {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Log.prototype.getTypeString = function () {
                    return '[fm.icelink.Log]';
                };
                Log.addProvider = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        var provider = arguments[0];
                        fm.icelink.Log.registerProvider(provider);
                    }
                    else if (arguments.length == 2) {
                        var provider = arguments[0];
                        var level = arguments[1];
                        fm.icelink.Log.registerProvider(provider, level);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.debug = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.debug(message);
                    }
                    else if (arguments.length == 2) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.debug(message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.error = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.error(message);
                    }
                    else if (arguments.length == 2) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.error(message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.fatal = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.fatal(message);
                    }
                    else if (arguments.length == 2) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.fatal(message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.flush = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        fm.icelink.Log.fm_icelink_Log___staticLogger.flush();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.getIsDebugEnabled = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        return (fm.icelink.LogConfiguration.getDefaultLogLevel() <= fm.icelink.LogLevel.Debug);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.getIsErrorEnabled = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        return (fm.icelink.LogConfiguration.getDefaultLogLevel() <= fm.icelink.LogLevel.Error);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.getIsFatalEnabled = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        return (fm.icelink.LogConfiguration.getDefaultLogLevel() <= fm.icelink.LogLevel.Fatal);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.getIsInfoEnabled = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        return (fm.icelink.LogConfiguration.getDefaultLogLevel() <= fm.icelink.LogLevel.Info);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.getIsVerboseEnabled = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        return (fm.icelink.LogConfiguration.getDefaultLogLevel() <= fm.icelink.LogLevel.Verbose);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.getIsWarnEnabled = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        return (fm.icelink.LogConfiguration.getDefaultLogLevel() <= fm.icelink.LogLevel.Warn);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.getLogger = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var tag = arguments[0];
                        return new fm.icelink.AsyncLogger(tag);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var tag = arguments[0];
                        var level = arguments[1];
                        fm.icelink.LogConfiguration.setTagLogLevel(tag, level);
                        return fm.icelink.Log.getLogger(tag);
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.Type]'))) {
                        var type = arguments[0];
                        return fm.icelink.Log.getLogger(type.getFullName());
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.Type]'))) {
                        var type = arguments[0];
                        var level = arguments[1];
                        return fm.icelink.Log.getLogger(type.getFullName(), level);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.getLogLevel = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.LogConfiguration.getDefaultLogLevel();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.getProvider = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        var logProviders = fm.icelink.LogConfiguration.getLogProviders();
                        return ((logProviders.length > 0) ? logProviders[0] : null);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.getProviders = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.LogConfiguration.getLogProviders();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.info = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.info(message);
                    }
                    else if (arguments.length == 2) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.info(message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.registerProvider = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        var provider = arguments[0];
                        fm.icelink.LogConfiguration.addLogProvider(provider);
                        if ((provider.getLevel() < fm.icelink.LogConfiguration.getDefaultLogLevel())) {
                            fm.icelink.LogConfiguration.setDefaultLogLevel(provider.getLevel());
                        }
                    }
                    else if (arguments.length == 2) {
                        var provider = arguments[0];
                        var level = arguments[1];
                        provider.setLevel(level);
                        fm.icelink.Log.registerProvider(provider);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.removeProvider = function (provider) {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.Log.unregisterProvider(provider);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.removeProviders = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        fm.icelink.Log.unregisterProviders();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.setLogLevel = function (value) {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        fm.icelink.LogConfiguration.setDefaultLogLevel(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.setProvider = function (value) {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        fm.icelink.LogConfiguration.clearLogProviders();
                        fm.icelink.Log.registerProvider(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.setTagOverride = function (tag, level) {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 2) {
                        fm.icelink.LogConfiguration.setTagLogLevel(tag, level);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.unregisterProvider = function (provider) {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.LogConfiguration.removeLogProvider(provider);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.unregisterProviders = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 0) {
                        fm.icelink.LogConfiguration.clearLogProviders();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.verbose = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.verbose(message);
                    }
                    else if (arguments.length == 2) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.verbose(message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.warn = function () {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        var message = arguments[0];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.warn(message);
                    }
                    else if (arguments.length == 2) {
                        var message = arguments[0];
                        var ex = arguments[1];
                        fm.icelink.Log.fm_icelink_Log___staticLogger.warn(message, ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.writeLine = function (text) {
                    fm.icelink.Log.fmicelinkLogInitialize();
                    if (arguments.length == 1) {
                        fm.icelink.Log.fm_icelink_Log___staticLogger.log(text);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Log.fmicelinkLogInitialize = function () {
                    if (!fm.icelink.Log.__fmicelinkLogInitialized && !fm.icelink.Log.__fmicelinkLogInitializing) {
                        fm.icelink.Log.__fmicelinkLogInitializing = true;
                        fm.icelink.Log.fm_icelink_Log___staticLogger = new fm.icelink.AsyncLogger("FM");
                        fm.icelink.Log.__fmicelinkLogInitialized = true;
                        fm.icelink.Log.__fmicelinkLogInitializing = false;
                    }
                };
                Log.__fmicelinkLogInitialized = false;
                Log.__fmicelinkLogInitializing = false;
                return Log;
            }());
            icelink.Log = Log;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LogConfiguration =  (function () {
                function LogConfiguration() {
                    fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LogConfiguration.prototype.getTypeString = function () {
                    return '[fm.icelink.LogConfiguration]';
                };
                LogConfiguration.addLogProvider = function (provider) {
                    fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
                    if (arguments.length == 1) {
                        var list = fm.icelink.ArrayExtensions.newArray(fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___logProviders);
                        fm.icelink.ArrayExtensions.add(list, provider);
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___providerCount++;
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___logProviders = fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogConfiguration.clearLogProviders = function () {
                    fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
                    if (arguments.length == 0) {
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___logProviders = new Array(0);
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___providerCount = 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogConfiguration.getDefaultLogLevel = function () {
                    fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.LogConfiguration.fm_icelink_LogConfiguration__defaultLogLevel;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogConfiguration.getHasProviders = function () {
                    fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
                    if (arguments.length == 0) {
                        return (fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___providerCount > 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogConfiguration.getLogProviders = function () {
                    fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___logProviders;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogConfiguration.getTagLogLevel = function (tag) {
                    fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(tag, null))) {
                            if (fm.icelink.HashExtensions.containsKey(fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___tagOverrides, tag)) {
                                return fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___tagOverrides[tag];
                            }
                        }
                        return fm.icelink.LogConfiguration.getDefaultLogLevel();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogConfiguration.removeLogProvider = function (provider) {
                    fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
                    if (arguments.length == 1) {
                        var list = fm.icelink.ArrayExtensions.newArray(fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___logProviders);
                        if (!fm.icelink.ArrayExtensions.remove(list, provider)) {
                            return false;
                        }
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___providerCount--;
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___logProviders = fm.icelink.ArrayExtensions.toArray(list);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogConfiguration.setDefaultLogLevel = function (value) {
                    fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
                    if (arguments.length == 1) {
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration__defaultLogLevel = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogConfiguration.setTagLogLevel = function (tag, logLevel) {
                    fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
                    if (arguments.length == 2) {
                        if ((!fm.icelink.Global.equals(tag, null))) {
                            fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___tagOverrides[tag] = logLevel;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LogConfiguration.fmicelinkLogConfigurationInitialize = function () {
                    if (!fm.icelink.LogConfiguration.__fmicelinkLogConfigurationInitialized && !fm.icelink.LogConfiguration.__fmicelinkLogConfigurationInitializing) {
                        fm.icelink.LogConfiguration.__fmicelinkLogConfigurationInitializing = true;
                        LogConfiguration.fm_icelink_LogConfiguration___providerCount = 0;
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___lock = new Object();
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___tagOverridesLock = new Object();
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___logProviders = new Array(0);
                        fm.icelink.LogConfiguration.fm_icelink_LogConfiguration___tagOverrides = {};
                        fm.icelink.LogConfiguration.setDefaultLogLevel(fm.icelink.LogLevel.Info);
                        fm.icelink.LogConfiguration.__fmicelinkLogConfigurationInitialized = true;
                        fm.icelink.LogConfiguration.__fmicelinkLogConfigurationInitializing = false;
                    }
                };
                LogConfiguration.__fmicelinkLogConfigurationInitialized = false;
                LogConfiguration.__fmicelinkLogConfigurationInitializing = false;
                return LogConfiguration;
            }());
            icelink.LogConfiguration = LogConfiguration;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LogLevelWrapper =  (function () {
                function LogLevelWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_14 = __arguments[0];
                        this._value = value_14;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LogLevelWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.LogLevelWrapper]';
                };
                LogLevelWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.LogLevel.Verbose)
                            return 'Verbose';
                        if (this._value == fm.icelink.LogLevel.Debug)
                            return 'Debug';
                        if (this._value == fm.icelink.LogLevel.Info)
                            return 'Info';
                        if (this._value == fm.icelink.LogLevel.Warn)
                            return 'Warn';
                        if (this._value == fm.icelink.LogLevel.Error)
                            return 'Error';
                        if (this._value == fm.icelink.LogLevel.Fatal)
                            return 'Fatal';
                        if (this._value == fm.icelink.LogLevel.None)
                            return 'None';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LogLevelWrapper;
            }());
            icelink.LogLevelWrapper = LogLevelWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LongHolder =  (function () {
                function LongHolder() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkLongHolderInit();
                    }
                    else if (__arguments.length == 1) {
                        var value = __arguments[0];
                        this.fmicelinkLongHolderInit();
                        this.setValue(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LongHolder.prototype.getTypeString = function () {
                    return '[fm.icelink.LongHolder]';
                };
                LongHolder.prototype.fmicelinkLongHolderInit = function () {
                    this._value = 0;
                };
                LongHolder.prototype.getValue = function () {
                    if (arguments.length == 0) {
                        return this._value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LongHolder.prototype.setValue = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._value = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LongHolder;
            }());
            icelink.LongHolder = LongHolder;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var NullJsonProvider =  (function (_super) {
                __extends(NullJsonProvider, _super);
                function NullJsonProvider() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                NullJsonProvider.prototype.getTypeString = function () {
                    return '[fm.icelink.NullJsonProvider]' + ',' + _super.prototype.getTypeString.call(this);
                };
                NullJsonProvider.prototype.deserialize = function (valueJson) {
                    if (arguments.length == 1) {
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                NullJsonProvider.prototype.serialize = function (value) {
                    if (arguments.length == 1) {
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return NullJsonProvider;
            }(fm.icelink.JsonProvider));
            icelink.NullJsonProvider = NullJsonProvider;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var NullLogProvider =  (function (_super) {
                __extends(NullLogProvider, _super);
                function NullLogProvider() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                NullLogProvider.prototype.getTypeString = function () {
                    return '[fm.icelink.NullLogProvider]' + ',' + _super.prototype.getTypeString.call(this);
                };
                NullLogProvider.prototype.doLog = function (logEvent) {
                    if (arguments.length == 1) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return NullLogProvider;
            }(fm.icelink.LogProvider));
            icelink.NullLogProvider = NullLogProvider;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataBufferPool =  (function () {
                function DataBufferPool() {
                    fm.icelink.DataBufferPool.fmicelinkDataBufferPoolInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        __arguments = new Array(1);
                        __arguments[0] = new fm.icelink.Type('[fm.icelink.DataBufferPool]').getFullName();
                        {
                            var tag = __arguments[0];
                            this.fmicelinkDataBufferPoolInit();
                            this._log = fm.icelink.Log.getLogger("DataBufferPool", fm.icelink.LogLevel.Info);
                            this.__blockSize = 128;
                            this.__traceStatistics = new fm.icelink.ManagedConcurrentDictionary();
                            this.__pools = new fm.icelink.ManagedConcurrentDictionary();
                            this.setEnableStatistics(false);
                            this.setStatistics(new fm.icelink.PoolStatistics(tag));
                        }
                    }
                    else if (__arguments.length == 1) {
                        var tag = __arguments[0];
                        this.fmicelinkDataBufferPoolInit();
                        this._log = fm.icelink.Log.getLogger("DataBufferPool", fm.icelink.LogLevel.Info);
                        this.__blockSize = 128;
                        this.__traceStatistics = new fm.icelink.ManagedConcurrentDictionary();
                        this.__pools = new fm.icelink.ManagedConcurrentDictionary();
                        this.setEnableStatistics(false);
                        this.setStatistics(new fm.icelink.PoolStatistics(tag));
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                DataBufferPool.prototype.getTypeString = function () {
                    return '[fm.icelink.DataBufferPool]';
                };
                DataBufferPool.prototype.fmicelinkDataBufferPoolInit = function () {
                    this.__blockSize = 0;
                    this._disabled = false;
                    this._enableStatistics = false;
                };
                DataBufferPool.getInstance = function () {
                    fm.icelink.DataBufferPool.fmicelinkDataBufferPoolInitialize();
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(fm.icelink.DataBufferPool.fm_icelink_DataBufferPool___singleton, null))) {
                            fm.icelink.DataBufferPool.fm_icelink_DataBufferPool___singleton = new fm.icelink.DataBufferPool();
                        }
                        return fm.icelink.DataBufferPool.fm_icelink_DataBufferPool___singleton;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.getIsSupported = function () {
                    fm.icelink.DataBufferPool.fmicelinkDataBufferPoolInitialize();
                    if (arguments.length == 0) {
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.getTracer = function () {
                    fm.icelink.DataBufferPool.fmicelinkDataBufferPoolInitialize();
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var tag = arguments[0];
                        return fm.icelink.DataBufferPool.getTracer(tag, fm.icelink.DataBufferPool.getInstance());
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var tag = arguments[0];
                        var pool = arguments[1];
                        return new fm.icelink.DataBufferPoolTracer(tag, pool);
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.Type]'))) {
                        var type = arguments[0];
                        return fm.icelink.DataBufferPool.getTracer(type.getFullName());
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.Type]'))) {
                        var type = arguments[0];
                        var pool = arguments[1];
                        return fm.icelink.DataBufferPool.getTracer(type.getFullName(), pool);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.createStack = function (tagStatistics) {
                    if (arguments.length == 1) {
                        if (this.getEnableStatistics()) {
                            this.getStatistics().__creates.increment();
                            if ((!fm.icelink.Global.equals(tagStatistics, null))) {
                                tagStatistics.__creates.increment();
                            }
                        }
                        return new fm.icelink.ManagedConcurrentStack();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.createTraceStatistics = function (tag) {
                    if (arguments.length == 1) {
                        return new fm.icelink.PoolStatistics(tag);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.doTraceTake = function (size, littleEndian, clearBytes, tag, tagStatistics) {
                    var _this = this;
                    if (arguments.length == 5) {
                        size = fm.icelink.Global.toInt(arguments[0]);
                        var valueFactory = null;
                        var key = this.padToBlock(size);
                        var orAdd = null;
                        var _var0 = new fm.icelink.Holder(orAdd);
                        var _var1 = this.__pools.tryGetValue(key, _var0);
                        orAdd = _var0.getValue();
                        if (!_var1) {
                            if ((fm.icelink.Global.equals(valueFactory, null))) {
                                valueFactory = function (s) {
                                    return _this.createStack(tagStatistics);
                                };
                            }
                            orAdd = this.__pools.getOrAdd(key, valueFactory);
                        }
                        if (this.getEnableStatistics()) {
                            this.getStatistics().__paddingWasted.add((key - size));
                            if ((!fm.icelink.Global.equals(tagStatistics, null))) {
                                tagStatistics.__paddingWasted.add((key - size));
                            }
                        }
                        var result = null;
                        var _var2 = new fm.icelink.Holder(result);
                        var _var3 = orAdd.tryPop(_var2);
                        result = _var2.getValue();
                        if (_var3) {
                            if (clearBytes) {
                                fm.icelink.BitAssistant.set(result, 0, result.length, 0);
                            }
                            if (this.getEnableStatistics()) {
                                this.getStatistics().__hits.increment();
                                this.getStatistics().__takenSize.add(result.length);
                                this.getStatistics().__pendingPoolSize.subtract(result.length);
                                if ((!fm.icelink.Global.equals(tagStatistics, null))) {
                                    tagStatistics.__hits.increment();
                                    tagStatistics.__takenSize.add(result.length);
                                    tagStatistics.__pendingPoolSize.subtract(result.length);
                                }
                            }
                            return new fm.icelink.DataBufferPooled(this, result, size, littleEndian, tag);
                        }
                        if (this.getEnableStatistics()) {
                            this.getStatistics().__misses.increment();
                            this.getStatistics().__takenSize.add(key);
                            this.getStatistics().__totalPoolSize.add(key);
                            if ((!fm.icelink.Global.equals(tagStatistics, null))) {
                                tagStatistics.__misses.increment();
                                tagStatistics.__takenSize.add(key);
                                tagStatistics.__totalPoolSize.add(key);
                            }
                        }
                        return new fm.icelink.DataBufferPooled(this, new Uint8Array(key), size, littleEndian, tag);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.getBlockSize = function () {
                    if (arguments.length == 0) {
                        return this.__blockSize;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.getDisabled = function () {
                    if (arguments.length == 0) {
                        return this._disabled;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.getEnableStatistics = function () {
                    if (arguments.length == 0) {
                        return this._enableStatistics;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.getOrAddTraceStatistics = function (tag) {
                    if (arguments.length == 1) {
                        var orAdd = null;
                        var _var0 = new fm.icelink.Holder(orAdd);
                        var _var1 = this.__traceStatistics.tryGetValue(tag, _var0);
                        orAdd = _var0.getValue();
                        if (!_var1) {
                            orAdd = this.__traceStatistics.getOrAdd(tag, this.createTraceStatistics.bind(this));
                        }
                        return orAdd;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.getStatistics = function () {
                    if (arguments.length == 0) {
                        return this._statistics;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.getTraceStatistics = function () {
                    if (arguments.length == 0) {
                        var values = this.__traceStatistics.getValues();
                        var statisticsArray = new Array(fm.icelink.ArrayExtensions.getCount(values));
                        var num = 0;
                        for (var _i = 0, values_4 = values; _i < values_4.length; _i++) {
                            var statistics = values_4[_i];
                            statisticsArray[num++] = statistics;
                        }
                        return statisticsArray;
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var tag = arguments[0];
                        if ((fm.icelink.Global.equals(tag, null))) {
                            return this.getStatistics();
                        }
                        var statistics = null;
                        var _var0 = new fm.icelink.Holder(statistics);
                        var _var1 = this.__traceStatistics.tryGetValue(tag, _var0);
                        statistics = _var0.getValue();
                        if (_var1) {
                            return statistics;
                        }
                        return null;
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.Type]'))) {
                        var type = arguments[0];
                        return this.getTraceStatistics(type.getFullName());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.padToBlock = function (size) {
                    if (arguments.length == 1) {
                        size = fm.icelink.Global.toInt(arguments[0]);
                        var num = ((size + this.__blockSize) - 1);
                        return (num - (num & (this.__blockSize - 1)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.returnBuffer = function (buffer, tag) {
                    if (arguments.length == 2) {
                        if (!this.getDisabled()) {
                            var orAddTraceStatistics = null;
                            if ((this.getEnableStatistics() && (!fm.icelink.Global.equals(tag, null)))) {
                                orAddTraceStatistics = this.getOrAddTraceStatistics(tag);
                            }
                            var num = buffer.decrementRetain();
                            if ((fm.icelink.Global.equals(num, 0))) {
                                var item = buffer.invalidate();
                                var stack = null;
                                var _var0 = new fm.icelink.Holder(stack);
                                var _var1 = this.__pools.tryGetValue(item.length, _var0);
                                stack = _var0.getValue();
                                if (!_var1) {
                                    throw new fm.icelink.Exception("Cannot return a buffer to the pool that was not taken from the pool.");
                                }
                                stack.push(item);
                                if (this.getEnableStatistics()) {
                                    this.getStatistics().__returnedSize.add(item.length);
                                    this.getStatistics().__pendingPoolSize.add(item.length);
                                    if ((!fm.icelink.Global.equals(orAddTraceStatistics, null))) {
                                        orAddTraceStatistics.__returnedSize.add(item.length);
                                        orAddTraceStatistics.__pendingPoolSize.add(item.length);
                                    }
                                }
                            }
                            else {
                                if ((num < 0)) {
                                    this._log.warn("Cannot return a buffer to the pool with a negative retain count.");
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.setBlockSize = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__blockSize = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.setDisabled = function (value) {
                    if (arguments.length == 1) {
                        this._disabled = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.setEnableStatistics = function (value) {
                    if (arguments.length == 1) {
                        this._enableStatistics = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.setStatistics = function (value) {
                    if (arguments.length == 1) {
                        this._statistics = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.take = function () {
                    if (arguments.length == 1) {
                        var size = fm.icelink.Global.toInt(arguments[0]);
                        return this.traceTake(size, null);
                    }
                    else if (arguments.length == 2) {
                        var size = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        return this.traceTake(size, littleEndian, null);
                    }
                    else if (arguments.length == 3) {
                        var size = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var clearBytes = arguments[2];
                        return this.traceTake(size, littleEndian, clearBytes, null);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.prototype.traceTake = function () {
                    if (arguments.length == 4) {
                        var size = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var clearBytes = arguments[2];
                        var tag = arguments[3];
                        if (this.getDisabled()) {
                            return fm.icelink.DataBuffer.allocate(size, littleEndian);
                        }
                        var tagStatistics = null;
                        if ((this.getEnableStatistics() && (!fm.icelink.Global.equals(tag, null)))) {
                            tagStatistics = this.getOrAddTraceStatistics(tag);
                        }
                        return this.doTraceTake(size, littleEndian, clearBytes, tag, tagStatistics);
                    }
                    else if (arguments.length == 3) {
                        var size = fm.icelink.Global.toInt(arguments[0]);
                        var littleEndian = arguments[1];
                        var tag = arguments[2];
                        return this.traceTake(size, littleEndian, false, tag);
                    }
                    else if (arguments.length == 2) {
                        var size = fm.icelink.Global.toInt(arguments[0]);
                        var tag = arguments[1];
                        return this.traceTake(size, false, tag);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataBufferPool.fmicelinkDataBufferPoolInitialize = function () {
                    if (!fm.icelink.DataBufferPool.__fmicelinkDataBufferPoolInitialized && !fm.icelink.DataBufferPool.__fmicelinkDataBufferPoolInitializing) {
                        fm.icelink.DataBufferPool.__fmicelinkDataBufferPoolInitializing = true;
                        fm.icelink.DataBufferPool.fm_icelink_DataBufferPool___singleton = null;
                        fm.icelink.DataBufferPool.fm_icelink_DataBufferPool___singletonLock = new Object();
                        fm.icelink.DataBufferPool.__fmicelinkDataBufferPoolInitialized = true;
                        fm.icelink.DataBufferPool.__fmicelinkDataBufferPoolInitializing = false;
                    }
                };
                DataBufferPool.__fmicelinkDataBufferPoolInitialized = false;
                DataBufferPool.__fmicelinkDataBufferPoolInitializing = false;
                return DataBufferPool;
            }());
            icelink.DataBufferPool = DataBufferPool;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PoolStatistics =  (function () {
                function PoolStatistics(tag) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var tag_4 = __arguments[0];
                        this.setTag(tag_4);
                        this.__hits = new fm.icelink.AtomicLong();
                        this.__misses = new fm.icelink.AtomicLong();
                        this.__creates = new fm.icelink.AtomicLong();
                        this.__paddingWasted = new fm.icelink.AtomicLong();
                        this.__totalPoolSize = new fm.icelink.AtomicLong();
                        this.__pendingPoolSize = new fm.icelink.AtomicLong();
                        this.__takenSize = new fm.icelink.AtomicLong();
                        this.__returnedSize = new fm.icelink.AtomicLong();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                PoolStatistics.prototype.getTypeString = function () {
                    return '[fm.icelink.PoolStatistics]';
                };
                PoolStatistics.prototype.getActivePools = function () {
                    if (arguments.length == 0) {
                        return this.__creates.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.getHitPercentage = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(this.getTotalCalls(), 0))) {
                            return -1;
                        }
                        return ((this.__hits.getValue() / this.getTotalCalls()) * 100);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.getMissPercentage = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(this.getTotalCalls(), 0))) {
                            return -1;
                        }
                        return ((this.__misses.getValue() / this.getTotalCalls()) * 100);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.getPaddingWasted = function () {
                    if (arguments.length == 0) {
                        return this.__paddingWasted.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.getPendingPoolSize = function () {
                    if (arguments.length == 0) {
                        return this.__pendingPoolSize.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.getReturnPercentage = function () {
                    if (arguments.length == 0) {
                        var num = this.__returnedSize.getValue();
                        var num2 = this.__takenSize.getValue();
                        if ((fm.icelink.Global.equals(num2, 0))) {
                            return -1;
                        }
                        return ((num / num2) * 100);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.getTotalCalls = function () {
                    if (arguments.length == 0) {
                        return (this.__hits.getValue() + this.__misses.getValue());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.getTotalPools = function () {
                    if (arguments.length == 0) {
                        return this.__creates.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.getTotalPoolSize = function () {
                    if (arguments.length == 0) {
                        return this.__totalPoolSize.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                PoolStatistics.prototype.toString = function () {
                    if (arguments.length == 0) {
                        var num = this.__hits.getValue();
                        var num2 = this.__misses.getValue();
                        var num3 = (num + num2);
                        var num4 = ((fm.icelink.Global.equals(num3, 0)) ? -1 : ((num / num3) * 100));
                        var num5 = ((fm.icelink.Global.equals(num3, 0)) ? -1 : ((num2 / num3) * 100));
                        var num6 = this.__returnedSize.getValue();
                        var num7 = this.__takenSize.getValue();
                        var num8 = ((fm.icelink.Global.equals(num7, 0)) ? -1 : ((num6 / num7) * 100));
                        return fm.icelink.StringExtensions.format("{0}:\n\tHit Rate: {1}%\n\tMiss Rate: {2}%\n\tReturn Rate: {3}%\n\tPools: {4}\n\tAllocated: {5} bytes\n\tReady: {6} bytes", [this.getTag(), fm.icelink.NumberExtensions.toString(num4), fm.icelink.NumberExtensions.toString(num5), fm.icelink.NumberExtensions.toString(num8), fm.icelink.NumberExtensions.toString(this.getTotalPools()), fm.icelink.NumberExtensions.toString(this.getTotalPoolSize()), fm.icelink.NumberExtensions.toString(this.getPendingPoolSize())]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return PoolStatistics;
            }());
            icelink.PoolStatistics = PoolStatistics;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var FutureStateWrapper =  (function () {
                function FutureStateWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_15 = __arguments[0];
                        this._value = value_15;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                FutureStateWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.FutureStateWrapper]';
                };
                FutureStateWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.FutureState.Pending)
                            return 'Pending';
                        if (this._value == fm.icelink.FutureState.Resolved)
                            return 'Resolved';
                        if (this._value == fm.icelink.FutureState.Rejected)
                            return 'Rejected';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return FutureStateWrapper;
            }());
            icelink.FutureStateWrapper = FutureStateWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ShortHolder =  (function () {
                function ShortHolder() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkShortHolderInit();
                    }
                    else if (__arguments.length == 1) {
                        var value = __arguments[0];
                        this.fmicelinkShortHolderInit();
                        this.setValue(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                ShortHolder.prototype.getTypeString = function () {
                    return '[fm.icelink.ShortHolder]';
                };
                ShortHolder.prototype.fmicelinkShortHolderInit = function () {
                    this._value = 0;
                };
                ShortHolder.prototype.getValue = function () {
                    if (arguments.length == 0) {
                        return this._value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ShortHolder.prototype.setValue = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._value = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ShortHolder;
            }());
            icelink.ShortHolder = ShortHolder;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Sort =  (function () {
                function Sort() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Sort.prototype.getTypeString = function () {
                    return '[fm.icelink.Sort]';
                };
                Sort.doQuickSort = function (array, left, right, comparer) {
                    if (arguments.length == 4) {
                        left = fm.icelink.Global.toInt(arguments[1]);
                        right = fm.icelink.Global.toInt(arguments[2]);
                        if ((left < right)) {
                            var pivotIndex = (left + fm.icelink.MathAssistant.floor((right - left) / 2));
                            var num2 = fm.icelink.Sort.partition(array, left, right, pivotIndex, comparer);
                            fm.icelink.Sort.doQuickSort(array, left, (num2 - 1), comparer);
                            fm.icelink.Sort.doQuickSort(array, (num2 + 1), right, comparer);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Sort.partition = function (array, left, right, pivotIndex, comparer) {
                    if (arguments.length == 5) {
                        left = fm.icelink.Global.toInt(arguments[1]);
                        right = fm.icelink.Global.toInt(arguments[2]);
                        pivotIndex = fm.icelink.Global.toInt(arguments[3]);
                        var local = array[pivotIndex];
                        fm.icelink.Sort.swap(array, pivotIndex, right);
                        var num = left;
                        for (var i = left; (i < right); i++) {
                            if ((fm.icelink.Global.equals(comparer(array[i], local), fm.icelink.CompareResult.Negative))) {
                                fm.icelink.Sort.swap(array, i, num);
                                num++;
                            }
                        }
                        fm.icelink.Sort.swap(array, num, right);
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Sort.quickSort = function (array, comparer) {
                    if (arguments.length == 2) {
                        var right = (fm.icelink.ArrayExtensions.getCount(array) - 1);
                        fm.icelink.Sort.doQuickSort(array, 0, right, comparer);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Sort.swap = function (array, pos1, pos2) {
                    if (arguments.length == 3) {
                        pos1 = fm.icelink.Global.toInt(arguments[1]);
                        pos2 = fm.icelink.Global.toInt(arguments[2]);
                        var local = array[pos1];
                        array[pos1] = array[pos2];
                        array[pos2] = local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Sort;
            }());
            icelink.Sort = Sort;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Splitter =  (function () {
                function Splitter() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Splitter.prototype.getTypeString = function () {
                    return '[fm.icelink.Splitter]';
                };
                Splitter.split = function (str, delimiter) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(str, null))) {
                            throw new fm.icelink.Exception("str cannot be null.");
                        }
                        if ((fm.icelink.Global.equals(delimiter, null))) {
                            throw new fm.icelink.Exception("delimiter cannot be null.");
                        }
                        if ((fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(delimiter), 0))) {
                            return [str];
                        }
                        var startIndex = 0;
                        var num2 = 0;
                        var list = new Array();
                        for (var i = 0; (i < fm.icelink.StringExtensions.getLength(str)); i++) {
                            var ch = str.charCodeAt(i);
                            var ch2 = delimiter.charCodeAt(num2);
                            if ((fm.icelink.Global.equals(ch, ch2))) {
                                if ((fm.icelink.Global.equals(num2, (fm.icelink.StringExtensions.getLength(delimiter) - 1)))) {
                                    fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.substring(str, startIndex, ((i - num2) - startIndex)));
                                    startIndex = (i + 1);
                                    num2 = 0;
                                }
                                else {
                                    num2++;
                                }
                            }
                            else {
                                num2 = 0;
                            }
                        }
                        fm.icelink.ArrayExtensions.add(list, str.substring(startIndex));
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Splitter;
            }());
            icelink.Splitter = Splitter;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StringAssistant =  (function () {
                function StringAssistant() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                StringAssistant.prototype.getTypeString = function () {
                    return '[fm.icelink.StringAssistant]';
                };
                StringAssistant.isNullOrWhiteSpace = function (s) {
                    if (arguments.length == 1) {
                        return ((fm.icelink.Global.equals(s, null)) || fm.icelink.StringExtensions.isNullOrEmpty(fm.icelink.StringExtensions.trim(s)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StringAssistant.subArray = function () {
                    if (arguments.length == 2) {
                        var array = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.StringAssistant.subArray(array, offset, (array.length - offset));
                    }
                    else if (arguments.length == 3) {
                        var array = arguments[0];
                        var offset = fm.icelink.Global.toInt(arguments[1]);
                        var count = fm.icelink.Global.toInt(arguments[2]);
                        var strArray = new Array(count);
                        for (var i = 0; (i < count); i++) {
                            strArray[i] = array[(offset + i)];
                        }
                        return strArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StringAssistant;
            }());
            icelink.StringAssistant = StringAssistant;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var TextLogProvider =  (function (_super) {
                __extends(TextLogProvider, _super);
                function TextLogProvider() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        __arguments = new Array(1);
                        __arguments[0] = fm.icelink.LogLevel.Info;
                        {
                            var level = __arguments[0];
                            _this = _super.call(this) || this;
                            _this.__text = new fm.icelink.StringBuilder();
                            _this.__textLock = new Object();
                            _super.prototype.setLevel.call(_this, level);
                        }
                    }
                    else if (__arguments.length == 1) {
                        var level = __arguments[0];
                        _this = _super.call(this) || this;
                        _this.__text = new fm.icelink.StringBuilder();
                        _this.__textLock = new Object();
                        _super.prototype.setLevel.call(_this, level);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                TextLogProvider.prototype.getTypeString = function () {
                    return '[fm.icelink.TextLogProvider]' + ',' + _super.prototype.getTypeString.call(this);
                };
                TextLogProvider.prototype.clear = function () {
                    if (arguments.length == 0) {
                        var str = void 0;
                        str = this.__text.toString();
                        this.__text = new fm.icelink.StringBuilder();
                        return str;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TextLogProvider.prototype.doLog = function (logEvent) {
                    if (arguments.length == 1) {
                        this.writeLine(this.generateLogLine(logEvent));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TextLogProvider.prototype.getCallback = function () {
                    if (arguments.length == 0) {
                        return this.__callback;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TextLogProvider.prototype.getText = function () {
                    if (arguments.length == 0) {
                        return this.__text.toString();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TextLogProvider.prototype.setCallback = function (value) {
                    if (arguments.length == 1) {
                        var str = this.__text.toString();
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(str)) {
                            if (fm.icelink.StringExtensions.endsWith(str, "\n")) {
                                str = fm.icelink.StringExtensions.substring(str, 0, (fm.icelink.StringExtensions.getLength(str) - 1));
                            }
                            value(str);
                        }
                        this.__callback = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TextLogProvider.prototype.writeLine = function (text) {
                    if (arguments.length == 1) {
                        this.__text.append(fm.icelink.StringExtensions.concat(text, "\n"));
                        if ((!fm.icelink.Global.equals(this.__callback, null))) {
                            this.__callback(text);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return TextLogProvider;
            }(fm.icelink.LogProvider));
            icelink.TextLogProvider = TextLogProvider;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Unhandled =  (function () {
                function Unhandled() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Unhandled.prototype.getTypeString = function () {
                    return '[fm.icelink.Unhandled]';
                };
                Unhandled.logException = function (ex, source) {
                    if (arguments.length == 2) {
                        fm.icelink.Log.error(fm.icelink.StringExtensions.concat("An exception in user code (", source, ") was unhandled."), ex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Unhandled;
            }());
            icelink.Unhandled = Unhandled;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var UnhandledExceptionArgs =  (function () {
                function UnhandledExceptionArgs(exception) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var exception_1 = __arguments[0];
                        this.fmicelinkUnhandledExceptionArgsInit();
                        this.__exception = exception_1;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                UnhandledExceptionArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.UnhandledExceptionArgs]';
                };
                UnhandledExceptionArgs.prototype.fmicelinkUnhandledExceptionArgsInit = function () {
                    this._handled = false;
                };
                UnhandledExceptionArgs.prototype.getException = function () {
                    if (arguments.length == 0) {
                        return this.__exception;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnhandledExceptionArgs.prototype.getHandled = function () {
                    if (arguments.length == 0) {
                        return this._handled;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                UnhandledExceptionArgs.prototype.setHandled = function (value) {
                    if (arguments.length == 1) {
                        this._handled = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return UnhandledExceptionArgs;
            }());
            icelink.UnhandledExceptionArgs = UnhandledExceptionArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Utf8 =  (function () {
                function Utf8() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Utf8.prototype.getTypeString = function () {
                    return '[fm.icelink.Utf8]';
                };
                Utf8.decode = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataBuffer]'))) {
                        var buffer = arguments[0];
                        return fm.icelink.Utf8.decode(buffer.getData(), buffer.getIndex(), buffer.getLength());
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isUint8Array(arguments[0]))) {
                        var input = arguments[0];
                        return fm.icelink.Utf8.decode(input, 0, input.length);
                    }
                    else if (arguments.length == 3) {
                        var input = arguments[0];
                        var index = fm.icelink.Global.toInt(arguments[1]);
                        var length_31 = fm.icelink.Global.toInt(arguments[2]);
                        return fm.icelink.Encoding.getUtf8().getString(input, index, length_31);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utf8.encode = function (input) {
                    if (arguments.length == 1) {
                        return fm.icelink.Encoding.getUtf8().getBytes(input);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utf8.getByteCount = function (input) {
                    if (arguments.length == 1) {
                        return fm.icelink.Encoding.getUtf8().getByteCount(input);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Utf8;
            }());
            icelink.Utf8 = Utf8;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketSendState =  (function () {
                function WebSocketSendState() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                WebSocketSendState.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketSendState]';
                };
                WebSocketSendState.prototype.getRequestBytes = function () {
                    if (arguments.length == 0) {
                        return this._requestBytes;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketSendState.prototype.getSendArgs = function () {
                    if (arguments.length == 0) {
                        return this._sendArgs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketSendState.prototype.setRequestBytes = function (value) {
                    if (arguments.length == 1) {
                        this._requestBytes = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketSendState.prototype.setSendArgs = function (value) {
                    if (arguments.length == 1) {
                        this._sendArgs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketSendState;
            }());
            icelink.WebSocketSendState = WebSocketSendState;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketCloseArgs =  (function (_super) {
                __extends(WebSocketCloseArgs, _super);
                function WebSocketCloseArgs() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.setStatusCode(fm.icelink.WebSocketStatusCode.Normal);
                        _this.setReason(fm.icelink.StringExtensions.empty);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebSocketCloseArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketCloseArgs]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebSocketCloseArgs.prototype.getOnComplete = function () {
                    if (arguments.length == 0) {
                        return this._onComplete;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketCloseArgs.prototype.getReason = function () {
                    if (arguments.length == 0) {
                        return this._reason;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketCloseArgs.prototype.getStatusCode = function () {
                    if (arguments.length == 0) {
                        return this._statusCode;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketCloseArgs.prototype.setOnComplete = function (value) {
                    if (arguments.length == 1) {
                        this._onComplete = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketCloseArgs.prototype.setReason = function (value) {
                    if (arguments.length == 1) {
                        this._reason = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketCloseArgs.prototype.setStatusCode = function (value) {
                    if (arguments.length == 1) {
                        this._statusCode = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketCloseArgs;
            }(fm.icelink.Dynamic));
            icelink.WebSocketCloseArgs = WebSocketCloseArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketCloseCompleteArgs =  (function (_super) {
                __extends(WebSocketCloseCompleteArgs, _super);
                function WebSocketCloseCompleteArgs() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebSocketCloseCompleteArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketCloseCompleteArgs]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebSocketCloseCompleteArgs.prototype.getCloseArgs = function () {
                    if (arguments.length == 0) {
                        return this._closeArgs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketCloseCompleteArgs.prototype.getReason = function () {
                    if (arguments.length == 0) {
                        return this._reason;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketCloseCompleteArgs.prototype.getStatusCode = function () {
                    if (arguments.length == 0) {
                        return this._statusCode;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketCloseCompleteArgs.prototype.setCloseArgs = function (value) {
                    if (arguments.length == 1) {
                        this._closeArgs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketCloseCompleteArgs.prototype.setReason = function (value) {
                    if (arguments.length == 1) {
                        this._reason = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketCloseCompleteArgs.prototype.setStatusCode = function (value) {
                    if (arguments.length == 1) {
                        this._statusCode = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketCloseCompleteArgs;
            }(fm.icelink.Dynamic));
            icelink.WebSocketCloseCompleteArgs = WebSocketCloseCompleteArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketOpenArgs =  (function (_super) {
                __extends(WebSocketOpenArgs, _super);
                function WebSocketOpenArgs() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkWebSocketOpenArgsInit();
                        _this.setHandshakeTimeout(15000);
                        _this.setStreamTimeout(40000);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebSocketOpenArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketOpenArgs]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebSocketOpenArgs.prototype.fmicelinkWebSocketOpenArgsInit = function () {
                    this._handshakeTimeout = 0;
                    this._streamTimeout = 0;
                };
                WebSocketOpenArgs.prototype.getHandshakeTimeout = function () {
                    if (arguments.length == 0) {
                        return this._handshakeTimeout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.getHeaders = function () {
                    if (arguments.length == 0) {
                        return this._headers;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.getOnFailure = function () {
                    if (arguments.length == 0) {
                        return this._onFailure;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.getOnReceive = function () {
                    if (arguments.length == 0) {
                        return this._onReceive;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.getOnRequestCreated = function () {
                    if (arguments.length == 0) {
                        return this._onRequestCreated;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.getOnResponseReceived = function () {
                    if (arguments.length == 0) {
                        return this._onResponseReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.getOnStreamFailure = function () {
                    if (arguments.length == 0) {
                        return this._onStreamFailure;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.getOnSuccess = function () {
                    if (arguments.length == 0) {
                        return this._onSuccess;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.getSender = function () {
                    if (arguments.length == 0) {
                        return this._sender;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.getStreamTimeout = function () {
                    if (arguments.length == 0) {
                        return this._streamTimeout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.setHandshakeTimeout = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._handshakeTimeout = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.setHeaders = function (value) {
                    if (arguments.length == 1) {
                        this._headers = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.setOnFailure = function (value) {
                    if (arguments.length == 1) {
                        this._onFailure = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.setOnReceive = function (value) {
                    if (arguments.length == 1) {
                        this._onReceive = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.setOnRequestCreated = function (value) {
                    if (arguments.length == 1) {
                        this._onRequestCreated = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.setOnResponseReceived = function (value) {
                    if (arguments.length == 1) {
                        this._onResponseReceived = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.setOnStreamFailure = function (value) {
                    if (arguments.length == 1) {
                        this._onStreamFailure = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.setOnSuccess = function (value) {
                    if (arguments.length == 1) {
                        this._onSuccess = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.setSender = function (value) {
                    if (arguments.length == 1) {
                        this._sender = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenArgs.prototype.setStreamTimeout = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._streamTimeout = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketOpenArgs;
            }(fm.icelink.Dynamic));
            icelink.WebSocketOpenArgs = WebSocketOpenArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketOpenFailureArgs =  (function (_super) {
                __extends(WebSocketOpenFailureArgs, _super);
                function WebSocketOpenFailureArgs() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebSocketOpenFailureArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketOpenFailureArgs]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebSocketOpenFailureArgs.prototype.getException = function () {
                    if (arguments.length == 0) {
                        return this._exception;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenFailureArgs.prototype.getOpenArgs = function () {
                    if (arguments.length == 0) {
                        return this._openArgs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenFailureArgs.prototype.getStatusCode = function () {
                    if (arguments.length == 0) {
                        return this._statusCode;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenFailureArgs.prototype.setException = function (value) {
                    if (arguments.length == 1) {
                        this._exception = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenFailureArgs.prototype.setOpenArgs = function (value) {
                    if (arguments.length == 1) {
                        this._openArgs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenFailureArgs.prototype.setStatusCode = function (value) {
                    if (arguments.length == 1) {
                        this._statusCode = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketOpenFailureArgs;
            }(fm.icelink.Dynamic));
            icelink.WebSocketOpenFailureArgs = WebSocketOpenFailureArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketOpenSuccessArgs =  (function (_super) {
                __extends(WebSocketOpenSuccessArgs, _super);
                function WebSocketOpenSuccessArgs() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebSocketOpenSuccessArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketOpenSuccessArgs]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebSocketOpenSuccessArgs.prototype.getOpenArgs = function () {
                    if (arguments.length == 0) {
                        return this._openArgs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketOpenSuccessArgs.prototype.setOpenArgs = function (value) {
                    if (arguments.length == 1) {
                        this._openArgs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketOpenSuccessArgs;
            }(fm.icelink.Dynamic));
            icelink.WebSocketOpenSuccessArgs = WebSocketOpenSuccessArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketReceiveArgs =  (function (_super) {
                __extends(WebSocketReceiveArgs, _super);
                function WebSocketReceiveArgs() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebSocketReceiveArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketReceiveArgs]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebSocketReceiveArgs.prototype.getBinaryMessage = function () {
                    if (arguments.length == 0) {
                        return this._binaryMessage;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketReceiveArgs.prototype.getIsText = function () {
                    if (arguments.length == 0) {
                        return (!fm.icelink.Global.equals(this.getTextMessage(), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketReceiveArgs.prototype.getOpenArgs = function () {
                    if (arguments.length == 0) {
                        return this._openArgs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketReceiveArgs.prototype.getTextMessage = function () {
                    if (arguments.length == 0) {
                        return this._textMessage;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketReceiveArgs.prototype.setBinaryMessage = function (value) {
                    if (arguments.length == 1) {
                        this._binaryMessage = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketReceiveArgs.prototype.setOpenArgs = function (value) {
                    if (arguments.length == 1) {
                        this._openArgs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketReceiveArgs.prototype.setTextMessage = function (value) {
                    if (arguments.length == 1) {
                        this._textMessage = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketReceiveArgs;
            }(fm.icelink.Dynamic));
            icelink.WebSocketReceiveArgs = WebSocketReceiveArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketRequest =  (function () {
                function WebSocketRequest() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                WebSocketRequest.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketRequest]';
                };
                WebSocketRequest.prototype.getArgs = function () {
                    if (arguments.length == 0) {
                        return this._args;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketRequest.prototype.getCallback = function () {
                    if (arguments.length == 0) {
                        return this._callback;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketRequest.prototype.setArgs = function (value) {
                    if (arguments.length == 1) {
                        this._args = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketRequest.prototype.setCallback = function (value) {
                    if (arguments.length == 1) {
                        this._callback = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketRequest;
            }());
            icelink.WebSocketRequest = WebSocketRequest;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketSendArgs =  (function (_super) {
                __extends(WebSocketSendArgs, _super);
                function WebSocketSendArgs() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkWebSocketSendArgsInit();
                        _this.setTimeout(15000);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebSocketSendArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketSendArgs]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebSocketSendArgs.prototype.fmicelinkWebSocketSendArgsInit = function () {
                    this._timeout = 0;
                };
                WebSocketSendArgs.prototype.getBinaryMessage = function () {
                    if (arguments.length == 0) {
                        return this._binaryMessage;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketSendArgs.prototype.getIsText = function () {
                    if (arguments.length == 0) {
                        return (!fm.icelink.Global.equals(this.getTextMessage(), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketSendArgs.prototype.getTextMessage = function () {
                    if (arguments.length == 0) {
                        return this._textMessage;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketSendArgs.prototype.getTimeout = function () {
                    if (arguments.length == 0) {
                        return this._timeout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketSendArgs.prototype.setBinaryMessage = function (value) {
                    if (arguments.length == 1) {
                        this._binaryMessage = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketSendArgs.prototype.setTextMessage = function (value) {
                    if (arguments.length == 1) {
                        this._textMessage = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketSendArgs.prototype.setTimeout = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._timeout = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketSendArgs;
            }(fm.icelink.Dynamic));
            icelink.WebSocketSendArgs = WebSocketSendArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketStatusCodeWrapper =  (function () {
                function WebSocketStatusCodeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_16 = __arguments[0];
                        this._value = value_16;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                WebSocketStatusCodeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketStatusCodeWrapper]';
                };
                WebSocketStatusCodeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.WebSocketStatusCode.Normal)
                            return 'Normal';
                        if (this._value == fm.icelink.WebSocketStatusCode.GoingAway)
                            return 'GoingAway';
                        if (this._value == fm.icelink.WebSocketStatusCode.ProtocolError)
                            return 'ProtocolError';
                        if (this._value == fm.icelink.WebSocketStatusCode.InvalidType)
                            return 'InvalidType';
                        if (this._value == fm.icelink.WebSocketStatusCode.NoStatus)
                            return 'NoStatus';
                        if (this._value == fm.icelink.WebSocketStatusCode.Abnormal)
                            return 'Abnormal';
                        if (this._value == fm.icelink.WebSocketStatusCode.InvalidData)
                            return 'InvalidData';
                        if (this._value == fm.icelink.WebSocketStatusCode.PolicyViolation)
                            return 'PolicyViolation';
                        if (this._value == fm.icelink.WebSocketStatusCode.MessageTooLarge)
                            return 'MessageTooLarge';
                        if (this._value == fm.icelink.WebSocketStatusCode.UnsupportedExtension)
                            return 'UnsupportedExtension';
                        if (this._value == fm.icelink.WebSocketStatusCode.UnexpectedCondition)
                            return 'UnexpectedCondition';
                        if (this._value == fm.icelink.WebSocketStatusCode.SecureHandshakeFailure)
                            return 'SecureHandshakeFailure';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketStatusCodeWrapper;
            }());
            icelink.WebSocketStatusCodeWrapper = WebSocketStatusCodeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketStreamFailureArgs =  (function (_super) {
                __extends(WebSocketStreamFailureArgs, _super);
                function WebSocketStreamFailureArgs() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebSocketStreamFailureArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketStreamFailureArgs]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebSocketStreamFailureArgs.prototype.getException = function () {
                    if (arguments.length == 0) {
                        return this._exception;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketStreamFailureArgs.prototype.getOpenArgs = function () {
                    if (arguments.length == 0) {
                        return this._openArgs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketStreamFailureArgs.prototype.getStatusCode = function () {
                    if (arguments.length == 0) {
                        return this._statusCode;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketStreamFailureArgs.prototype.setException = function (value) {
                    if (arguments.length == 1) {
                        this._exception = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketStreamFailureArgs.prototype.setOpenArgs = function (value) {
                    if (arguments.length == 1) {
                        this._openArgs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketStreamFailureArgs.prototype.setStatusCode = function (value) {
                    if (arguments.length == 1) {
                        this._statusCode = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketStreamFailureArgs;
            }(fm.icelink.Dynamic));
            icelink.WebSocketStreamFailureArgs = WebSocketStreamFailureArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketTransfer =  (function () {
                function WebSocketTransfer(url) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var url_1 = __arguments[0];
                        this.fmicelinkWebSocketTransferInit();
                        this.setUrl(url_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                WebSocketTransfer.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketTransfer]';
                };
                WebSocketTransfer.prototype.fmicelinkWebSocketTransferInit = function () {
                    this._handshakeTimeout = 0;
                    this._streamTimeout = 0;
                };
                WebSocketTransfer.prototype.getHandshakeTimeout = function () {
                    if (arguments.length == 0) {
                        return this._handshakeTimeout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.getOnOpenFailure = function () {
                    if (arguments.length == 0) {
                        return this._onOpenFailure;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.getOnOpenSuccess = function () {
                    if (arguments.length == 0) {
                        return this._onOpenSuccess;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.getOnRequestCreated = function () {
                    if (arguments.length == 0) {
                        return this._onRequestCreated;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.getOnResponseReceived = function () {
                    if (arguments.length == 0) {
                        return this._onResponseReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.getOnStreamFailure = function () {
                    if (arguments.length == 0) {
                        return this._onStreamFailure;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.getSender = function () {
                    if (arguments.length == 0) {
                        return this._sender;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.getStreamTimeout = function () {
                    if (arguments.length == 0) {
                        return this._streamTimeout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.getUrl = function () {
                    if (arguments.length == 0) {
                        return this.__url;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.setHandshakeTimeout = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._handshakeTimeout = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.setOnOpenFailure = function (value) {
                    if (arguments.length == 1) {
                        this._onOpenFailure = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.setOnOpenSuccess = function (value) {
                    if (arguments.length == 1) {
                        this._onOpenSuccess = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.setOnRequestCreated = function (value) {
                    if (arguments.length == 1) {
                        this._onRequestCreated = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.setOnResponseReceived = function (value) {
                    if (arguments.length == 1) {
                        this._onResponseReceived = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.setOnStreamFailure = function (value) {
                    if (arguments.length == 1) {
                        this._onStreamFailure = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.setSender = function (value) {
                    if (arguments.length == 1) {
                        this._sender = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.setStreamTimeout = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._streamTimeout = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransfer.prototype.setUrl = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.StringExtensions.replace(value, "https://", "wss://");
                        value = fm.icelink.StringExtensions.replace(value, "http://", "ws://");
                        this.__url = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketTransfer;
            }());
            icelink.WebSocketTransfer = WebSocketTransfer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketTransferFactory =  (function () {
                function WebSocketTransferFactory() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                WebSocketTransferFactory.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketTransferFactory]';
                };
                WebSocketTransferFactory.defaultCreateWebSocketTransfer = function (url) {
                    if (arguments.length == 1) {
                        return new fm.icelink.WebSocketWebRequestTransfer(url);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransferFactory.getCreateWebSocketTransfer = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.WebSocketTransferFactory.fm_icelink_WebSocketTransferFactory__createWebSocketTransfer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransferFactory.getWebSocketTransfer = function (url) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(fm.icelink.WebSocketTransferFactory.getCreateWebSocketTransfer(), null))) {
                            fm.icelink.WebSocketTransferFactory.setCreateWebSocketTransfer(fm.icelink.WebSocketTransferFactory.defaultCreateWebSocketTransfer.bind(fm.icelink.WebSocketTransferFactory));
                        }
                        var transfer = fm.icelink.WebSocketTransferFactory.getCreateWebSocketTransfer()(url);
                        if ((fm.icelink.Global.equals(transfer, null))) {
                            transfer = fm.icelink.WebSocketTransferFactory.defaultCreateWebSocketTransfer(url);
                        }
                        return transfer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketTransferFactory.setCreateWebSocketTransfer = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.WebSocketTransferFactory.fm_icelink_WebSocketTransferFactory__createWebSocketTransfer = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketTransferFactory;
            }());
            icelink.WebSocketTransferFactory = WebSocketTransferFactory;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebSocketWebRequestTransfer =  (function (_super) {
                __extends(WebSocketWebRequestTransfer, _super);
                function WebSocketWebRequestTransfer(url) {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var url_2 = __arguments[0];
                        _this = _super.call(this, url_2) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebSocketWebRequestTransfer.prototype.getTypeString = function () {
                    return '[fm.icelink.WebSocketWebRequestTransfer]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebSocketWebRequestTransfer.prototype.connectFailure = function (e) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(_super.prototype.getOnOpenFailure.call(this), null))) {
                            _super.prototype.getOnOpenFailure.call(this)(e);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketWebRequestTransfer.prototype.connectSuccess = function (e) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(_super.prototype.getOnOpenSuccess.call(this), null))) {
                            _super.prototype.getOnOpenSuccess.call(this)(e);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketWebRequestTransfer.prototype.getWebSocket = function () {
                    if (arguments.length == 0) {
                        return this._webSocket;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketWebRequestTransfer.prototype.open = function (headers) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.getWebSocket(), null))) {
                            this.getWebSocket().close();
                            this.setWebSocket(null);
                        }
                        this.setWebSocket(new fm.icelink.WebSocket(_super.prototype.getUrl.call(this)));
                        try {
                            var openArgs = new fm.icelink.WebSocketOpenArgs();
                            openArgs.setHandshakeTimeout(_super.prototype.getHandshakeTimeout.call(this));
                            openArgs.setHeaders(headers);
                            openArgs.setOnSuccess(this.connectSuccess.bind(this));
                            openArgs.setOnFailure(this.connectFailure.bind(this));
                            openArgs.setOnStreamFailure(this.streamFailure.bind(this));
                            openArgs.setOnRequestCreated(_super.prototype.getOnRequestCreated.call(this));
                            openArgs.setOnResponseReceived(_super.prototype.getOnResponseReceived.call(this));
                            openArgs.setOnReceive(this.receive.bind(this));
                            openArgs.setSender(_super.prototype.getSender.call(this));
                            this.getWebSocket().open(openArgs);
                        }
                        catch (exception) {
                            fm.icelink.Log.error("Could not open WebSocket.", exception);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketWebRequestTransfer.prototype.receive = function (e) {
                    if (arguments.length == 1) {
                        var p = new fm.icelink.HttpResponseArgs(this._activeRequest.getArgs());
                        p.setTextContent(e.getTextMessage());
                        p.setBinaryContent(e.getBinaryMessage());
                        this._activeRequest.getCallback()(p);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketWebRequestTransfer.prototype.send = function (requestArgs) {
                    if (arguments.length == 1) {
                        throw new fm.icelink.Exception("Synchronous WebSockets are not supported.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketWebRequestTransfer.prototype.sendAsync = function (requestArgs, callback) {
                    if (arguments.length == 2) {
                        try {
                            var request2 = new fm.icelink.WebSocketRequest();
                            request2.setArgs(requestArgs);
                            request2.setCallback(callback);
                            var request = request2;
                            var args2 = new fm.icelink.WebSocketSendArgs();
                            args2.setTimeout(request.getArgs().getTimeout());
                            var sendArgs = args2;
                            sendArgs.setTextMessage(request.getArgs().getTextContent());
                            sendArgs.setBinaryMessage(request.getArgs().getBinaryContent());
                            this._activeRequest = request;
                            this.getWebSocket().send(sendArgs);
                        }
                        catch (exception) {
                            var p = new fm.icelink.HttpResponseArgs(requestArgs);
                            p.setException(exception);
                            p.setStatusCode(0);
                            callback(p);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketWebRequestTransfer.prototype.setWebSocket = function (value) {
                    if (arguments.length == 1) {
                        this._webSocket = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketWebRequestTransfer.prototype.shutdown = function () {
                    if (arguments.length == 0) {
                        _super.prototype.setOnOpenFailure.call(this, null);
                        _super.prototype.setOnOpenSuccess.call(this, null);
                        _super.prototype.setOnRequestCreated.call(this, null);
                        _super.prototype.setOnResponseReceived.call(this, null);
                        _super.prototype.setOnStreamFailure.call(this, null);
                        this.getWebSocket().close();
                        this.setWebSocket(null);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebSocketWebRequestTransfer.prototype.streamFailure = function (e) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(_super.prototype.getOnStreamFailure.call(this), null))) {
                            _super.prototype.getOnStreamFailure.call(this)(e);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebSocketWebRequestTransfer;
            }(fm.icelink.WebSocketTransfer));
            icelink.WebSocketWebRequestTransfer = WebSocketWebRequestTransfer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaBuffer =  (function (_super) {
                __extends(MediaBuffer, _super);
                function MediaBuffer() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaBufferInit();
                    }
                    else if (__arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataBuffer]'))) {
                        var dataBuffer = __arguments[0];
                        var format = __arguments[1];
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaBufferInit();
                        _this.setDataBuffer(dataBuffer);
                        _this.setFormat(format);
                    }
                    else if (__arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || (fm.icelink.Util.isArray(arguments[0]) && (arguments[0].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[0][0]) || fm.icelink.Util.isObjectType(arguments[0][0], '[fm.icelink.DataBuffer]')))))) {
                        var dataBuffers = __arguments[0];
                        var format = __arguments[1];
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaBufferInit();
                        _this.setDataBuffers(dataBuffers);
                        _this.setFormat(format);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaBuffer.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaBuffer]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaBuffer.prototype.fmicelinkMediaBufferInit = function () {
                    this._recoveredByFec = false;
                };
                MediaBuffer.prototype.clone = function () {
                    if (arguments.length == 0) {
                        var local = this.createInstance();
                        local.setDataBuffers(this.getDataBuffers());
                        local.setSequenceNumbers(fm.icelink.Utility.cloneLongArray(this.getSequenceNumbers()));
                        if ((!fm.icelink.Global.equals(this.getRtpHeaders(), null))) {
                            local.setRtpHeaders(new Array(this.getRtpHeaders().length));
                            for (var i = 0; (i < local.getRtpHeaders().length); i++) {
                                if ((!fm.icelink.Global.equals(this.getRtpHeaders()[i], null))) {
                                    local.getRtpHeaders()[i] = this.getRtpHeaders()[i].clone();
                                }
                            }
                        }
                        local.setFormat(this.getFormat().clone());
                        return local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.free = function () {
                    if (arguments.length == 0) {
                        for (var _i = 0, _a = this.getDataBuffers(); _i < _a.length; _i++) {
                            var buffer = _a[_i];
                            buffer.free();
                        }
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getDataBuffer = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getDataBuffers());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getDataBuffers = function () {
                    if (arguments.length == 0) {
                        return this.__dataBuffers;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getFootprint = function () {
                    if (arguments.length == 0) {
                        var num = 0;
                        for (var _i = 0, _a = this.getDataBuffers(); _i < _a.length; _i++) {
                            var buffer = _a[_i];
                            num = (num + buffer.getLength());
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getFormat = function () {
                    if (arguments.length == 0) {
                        return this.__format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getIsPacketized = function () {
                    if (arguments.length == 0) {
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getLastSequenceNumber = function () {
                    if (arguments.length == 0) {
                        var sequenceNumbers = this.getSequenceNumbers();
                        if ((fm.icelink.Global.equals(sequenceNumbers, null))) {
                            return -1;
                        }
                        return sequenceNumbers[(sequenceNumbers.length - 1)];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getRecoveredByFec = function () {
                    if (arguments.length == 0) {
                        return this._recoveredByFec;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getRtpHeader = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getRtpHeaders());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getRtpHeaders = function () {
                    if (arguments.length == 0) {
                        return this._rtpHeaders;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getRtpSequenceNumber = function () {
                    if (arguments.length == 0) {
                        var rtpSequenceNumbers = this.getRtpSequenceNumbers();
                        if ((fm.icelink.Global.equals(rtpSequenceNumbers, null))) {
                            return -1;
                        }
                        return rtpSequenceNumbers[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getRtpSequenceNumbers = function () {
                    if (arguments.length == 0) {
                        var rtpHeaders = this.getRtpHeaders();
                        if ((fm.icelink.Global.equals(rtpHeaders, null))) {
                            return null;
                        }
                        var numArray = new Array(rtpHeaders.length);
                        for (var i = 0; (i < numArray.length); i++) {
                            var header = rtpHeaders[i];
                            if ((fm.icelink.Global.equals(header, null))) {
                                numArray[i] = -1;
                            }
                            else {
                                numArray[i] = rtpHeaders[i].getSequenceNumber();
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getSequenceNumber = function () {
                    if (arguments.length == 0) {
                        var sequenceNumbers = this.getSequenceNumbers();
                        if ((fm.icelink.Global.equals(sequenceNumbers, null))) {
                            return -1;
                        }
                        return sequenceNumbers[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getSequenceNumbers = function () {
                    if (arguments.length == 0) {
                        return this._sequenceNumbers;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.getSourceId = function () {
                    if (arguments.length == 0) {
                        return this._sourceId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.keep = function () {
                    if (arguments.length == 0) {
                        for (var _i = 0, _a = this.getDataBuffers(); _i < _a.length; _i++) {
                            var buffer = _a[_i];
                            buffer.keep();
                        }
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.setDataBuffer = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            throw new fm.icelink.Exception("Data buffer cannot be null.");
                        }
                        this.__dataBuffers = [value];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.setDataBuffers = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            throw new fm.icelink.Exception("Data buffers cannot be null.");
                        }
                        this.__dataBuffers = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.setFormat = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            throw new fm.icelink.Exception("Format cannot be null.");
                        }
                        this.__format = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.setRecoveredByFec = function (value) {
                    if (arguments.length == 1) {
                        this._recoveredByFec = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.setRtpHeader = function (value) {
                    if (arguments.length == 1) {
                        this.setRtpHeaders(((fm.icelink.Global.equals(value, null)) ? null : [value]));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.setRtpHeaders = function (value) {
                    if (arguments.length == 1) {
                        this._rtpHeaders = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.setSequenceNumber = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.setSequenceNumbers([value]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.setSequenceNumbers = function (value) {
                    if (arguments.length == 1) {
                        this._sequenceNumbers = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.setSourceId = function (value) {
                    if (arguments.length == 1) {
                        this._sourceId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return this.getFormat().toString();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaBuffer.prototype.tryKeep = function () {
                    if (arguments.length == 0) {
                        try {
                            for (var _i = 0, _a = this.getDataBuffers(); _i < _a.length; _i++) {
                                var buffer = _a[_i];
                                buffer.keep();
                            }
                            return true;
                        }
                        catch (obj1) {
                            return false;
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaBuffer;
            }(fm.icelink.Dynamic));
            icelink.MediaBuffer = MediaBuffer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaFormat =  (function () {
                function MediaFormat() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkMediaFormatInit();
                        this.initialize();
                    }
                    else if (__arguments.length == 2) {
                        var name_3 = __arguments[0];
                        var clockRate = __arguments[1];
                        this.fmicelinkMediaFormatInit();
                        this.initialize();
                        this.initialize(name_3, clockRate, null, null, null, null);
                    }
                    else if (__arguments.length == 3) {
                        var name_4 = __arguments[0];
                        var clockRate = __arguments[1];
                        var packetizationMode = __arguments[2];
                        this.fmicelinkMediaFormatInit();
                        this.initialize();
                        this.initialize(name_4, clockRate, null, null, packetizationMode, null);
                    }
                    else if (__arguments.length == 4) {
                        var name_5 = __arguments[0];
                        var clockRate = __arguments[1];
                        var profile = __arguments[2];
                        var level = __arguments[3];
                        this.fmicelinkMediaFormatInit();
                        this.initialize();
                        this.initialize(name_5, clockRate, profile, level, null, null);
                    }
                    else if (__arguments.length == 5) {
                        var name_6 = __arguments[0];
                        var clockRate = __arguments[1];
                        var profile = __arguments[2];
                        var level = __arguments[3];
                        var packetizationMode = __arguments[4];
                        this.fmicelinkMediaFormatInit();
                        this.initialize();
                        this.initialize(name_6, clockRate, profile, level, packetizationMode, null);
                    }
                    else if (__arguments.length == 6) {
                        var name_7 = __arguments[0];
                        var clockRate = __arguments[1];
                        var profile = __arguments[2];
                        var level = __arguments[3];
                        var packetizationMode = __arguments[4];
                        var tier = __arguments[5];
                        this.fmicelinkMediaFormatInit();
                        this.initialize();
                        this.initialize(name_7, clockRate, profile, level, packetizationMode, tier);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                MediaFormat.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaFormat]';
                };
                MediaFormat.prototype.fmicelinkMediaFormatInit = function () {
                    this._clockRate = 0;
                    this._isEncrypted = false;
                    this._isFixedBitrate = false;
                    this._isInjected = false;
                    this._isPacketized = false;
                    this._levelIsStrict = false;
                    this._registeredPayloadType = 0;
                    this._staticPayloadType = 0;
                };
                MediaFormat.getRedName = function () {
                    if (arguments.length == 0) {
                        return "red";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.getUlpFecName = function () {
                    if (arguments.length == 0) {
                        return "ulpfec";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.clone = function () {
                    if (arguments.length == 0) {
                        var local = this.createInstance();
                        local.setName(this.getName());
                        local.setClockRate(this.getClockRate());
                        local.setIsPacketized(this.getIsPacketized());
                        local.setPacketizationMode(this.getPacketizationMode());
                        local.setProfile(this.getProfile());
                        local.setLevel(this.getLevel());
                        local.setLevelIsStrict(this.getLevelIsStrict());
                        local.setTier(this.getTier());
                        local.setIsEncrypted(this.getIsEncrypted());
                        local.setIsInjected(this.getIsInjected());
                        local.setRegisteredPayloadType(this.getRegisteredPayloadType());
                        local.setStaticPayloadType(this.getStaticPayloadType());
                        local.setIsFixedBitrate(this.getIsFixedBitrate());
                        return local;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getClockRate = function () {
                    if (arguments.length == 0) {
                        return this._clockRate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getFullName = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(this.getName(), null))) {
                            throw new fm.icelink.Exception("Name cannot be null.");
                        }
                        var parameters = this.getParameters();
                        if (fm.icelink.StringExtensions.isNullOrEmpty(parameters)) {
                            return fm.icelink.StringExtensions.format("{0}/{1}", this.getName(), fm.icelink.NumberExtensions.toString(this.getClockRate()));
                        }
                        return fm.icelink.StringExtensions.format("{0}/{1}/{2}", this.getName(), fm.icelink.NumberExtensions.toString(this.getClockRate()), parameters);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getIsEncrypted = function () {
                    if (arguments.length == 0) {
                        return this._isEncrypted;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getIsFixedBitrate = function () {
                    if (arguments.length == 0) {
                        return this._isFixedBitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getIsInjected = function () {
                    if (arguments.length == 0) {
                        return this._isInjected;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getIsPacketized = function () {
                    if (arguments.length == 0) {
                        return this._isPacketized;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getLevel = function () {
                    if (arguments.length == 0) {
                        return this._level;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getLevelIsStrict = function () {
                    if (arguments.length == 0) {
                        return this._levelIsStrict;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getMaxBitrate = function () {
                    if (arguments.length == 0) {
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getMaxLevel = function (level1, level2) {
                    if (arguments.length == 2) {
                        return level1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getMinBitrate = function () {
                    if (arguments.length == 0) {
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getMinLevel = function (level1, level2) {
                    if (arguments.length == 2) {
                        return level1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getName = function () {
                    if (arguments.length == 0) {
                        return this.__name;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getPacketizationMode = function () {
                    if (arguments.length == 0) {
                        if (this.getIsPacketized()) {
                            return this.__packetizationMode;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getProfile = function () {
                    if (arguments.length == 0) {
                        return this._profile;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getRegisteredPayloadType = function () {
                    if (arguments.length == 0) {
                        return this._registeredPayloadType;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getStaticPayloadType = function () {
                    if (arguments.length == 0) {
                        return this._staticPayloadType;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.getTier = function () {
                    if (arguments.length == 0) {
                        return this._tier;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.initialize = function () {
                    if (arguments.length == 0) {
                        this.setRegisteredPayloadType(-1);
                        this.setStaticPayloadType(-1);
                    }
                    else if (arguments.length == 6) {
                        var name_8 = arguments[0];
                        var clockRate = fm.icelink.Global.toInt(arguments[1]);
                        var profile = arguments[2];
                        var level = arguments[3];
                        var packetizationMode = arguments[4];
                        var tier = arguments[5];
                        this.setName(name_8);
                        this.setClockRate(clockRate);
                        this.setProfile(profile);
                        this.setLevel(level);
                        this.setPacketizationMode(packetizationMode);
                        this.setTier(tier);
                        if ((!fm.icelink.Global.equals(packetizationMode, null))) {
                            this.setIsPacketized(true);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.isCompatible = function (format) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(format, null))) {
                            return false;
                        }
                        if (!fm.icelink.StringExtensions.isEqual(this.getName(), format.getName(), fm.icelink.StringComparison.InvariantCultureIgnoreCase)) {
                            return false;
                        }
                        if ((!fm.icelink.Global.equals(this.getClockRate(), format.getClockRate()))) {
                            return false;
                        }
                        if ((!fm.icelink.Global.equals(this.getIsPacketized(), format.getIsPacketized()))) {
                            return false;
                        }
                        if ((!fm.icelink.Global.equals(this.getPacketizationMode(), format.getPacketizationMode()))) {
                            return false;
                        }
                        if (((((!fm.icelink.Global.equals(this.getProfile(), null)) && (!fm.icelink.Global.equals(format.getProfile(), null))) && !fm.icelink.StringExtensions.isEqual(this.getProfile(), format.getProfile(), fm.icelink.StringComparison.InvariantCultureIgnoreCase)) && !this.isProfileCompatible(format.getProfile()))) {
                            return false;
                        }
                        if (((((!fm.icelink.Global.equals(this.getLevel(), null)) && (!fm.icelink.Global.equals(format.getLevel(), null))) && this.getLevelIsStrict()) && (!fm.icelink.StringExtensions.isEqual(this.getLevel(), format.getLevel(), fm.icelink.StringComparison.InvariantCultureIgnoreCase) && !this.isLevelCompatible(format.getLevel())))) {
                            return false;
                        }
                        if ((((!fm.icelink.Global.equals(this.getTier(), null)) && (!fm.icelink.Global.equals(format.getTier(), null))) && !fm.icelink.StringExtensions.isEqual(this.getTier(), format.getTier(), fm.icelink.StringComparison.InvariantCultureIgnoreCase))) {
                            return false;
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.isEquivalent = function (format, ignoreIsPacketized) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(format, null))) {
                            return false;
                        }
                        if (!fm.icelink.StringExtensions.isEqual(this.getName(), format.getName(), fm.icelink.StringComparison.InvariantCultureIgnoreCase)) {
                            return false;
                        }
                        if ((!fm.icelink.Global.equals(this.getClockRate(), format.getClockRate()))) {
                            return false;
                        }
                        if (!ignoreIsPacketized) {
                            if ((!fm.icelink.Global.equals(this.getIsPacketized(), format.getIsPacketized()))) {
                                return false;
                            }
                            if ((!fm.icelink.Global.equals(this.getPacketizationMode(), format.getPacketizationMode()))) {
                                return false;
                            }
                        }
                        if ((fm.icelink.Global.equals(this.getProfile(), null))) {
                            if ((!fm.icelink.Global.equals(format.getProfile(), null))) {
                                return false;
                            }
                        }
                        else {
                            if (!fm.icelink.StringExtensions.isEqual(this.getProfile(), format.getProfile(), fm.icelink.StringComparison.InvariantCultureIgnoreCase)) {
                                return false;
                            }
                        }
                        if ((fm.icelink.Global.equals(this.getLevel(), null))) {
                            if ((!fm.icelink.Global.equals(format.getLevel(), null))) {
                                return false;
                            }
                        }
                        else {
                            if (!fm.icelink.StringExtensions.isEqual(this.getLevel(), format.getLevel(), fm.icelink.StringComparison.InvariantCultureIgnoreCase)) {
                                return false;
                            }
                        }
                        if ((fm.icelink.Global.equals(this.getTier(), null))) {
                            if ((!fm.icelink.Global.equals(format.getTier(), null))) {
                                return false;
                            }
                        }
                        else {
                            if (!fm.icelink.StringExtensions.isEqual(this.getTier(), format.getLevel(), fm.icelink.StringComparison.InvariantCultureIgnoreCase)) {
                                return false;
                            }
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.isLevelCompatible = function (level) {
                    if (arguments.length == 1) {
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.isProfileCompatible = function (profile) {
                    if (arguments.length == 1) {
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setClockRate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._clockRate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setIsEncrypted = function (value) {
                    if (arguments.length == 1) {
                        this._isEncrypted = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setIsFixedBitrate = function (value) {
                    if (arguments.length == 1) {
                        this._isFixedBitrate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setIsInjected = function (value) {
                    if (arguments.length == 1) {
                        this._isInjected = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setIsPacketized = function (value) {
                    if (arguments.length == 1) {
                        this._isPacketized = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setLevel = function (value) {
                    if (arguments.length == 1) {
                        this._level = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setLevelIsStrict = function (value) {
                    if (arguments.length == 1) {
                        this._levelIsStrict = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setName = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            throw new fm.icelink.Exception("Name cannot be null.");
                        }
                        this.__name = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setPacketizationMode = function (value) {
                    if (arguments.length == 1) {
                        this.__packetizationMode = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setProfile = function (value) {
                    if (arguments.length == 1) {
                        this._profile = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setRegisteredPayloadType = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._registeredPayloadType = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setStaticPayloadType = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._staticPayloadType = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.setTier = function (value) {
                    if (arguments.length == 1) {
                        this._tier = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.toString = function () {
                    if (arguments.length == 0) {
                        var builder = new fm.icelink.StringBuilder();
                        builder.append(this.getFullName());
                        var list = new Array();
                        if ((!fm.icelink.Global.equals(this.getPacketizationMode(), null))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Packetization Mode {0}", this.getPacketizationMode()));
                        }
                        if ((!fm.icelink.Global.equals(this.getProfile(), null))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Profile {0}", this.getProfile()));
                        }
                        if ((!fm.icelink.Global.equals(this.getLevel(), null))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Level {0}", this.getLevel()));
                        }
                        if ((!fm.icelink.Global.equals(this.getTier(), null))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Tier {0}", this.getTier()));
                        }
                        if ((fm.icelink.ArrayExtensions.getCount(list) > 0)) {
                            builder.append(" (");
                            builder.append(fm.icelink.StringExtensions.join("; ", fm.icelink.ArrayExtensions.toArray(list)));
                            builder.append(")");
                        }
                        return builder.toString();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.updateLevelIsStrictToCompatible = function (format) {
                    if (arguments.length == 1) {
                        if (format.getLevelIsStrict()) {
                            this.setLevelIsStrict(true);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.updateLevelToCompatible = function (format) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(format.getLevel(), null))) {
                            if ((fm.icelink.Global.equals(this.getLevel(), null))) {
                                this.setLevel(format.getLevel());
                            }
                            else {
                                if (!this.getLevelIsStrict()) {
                                    if (format.getLevelIsStrict()) {
                                        this.setLevel(format.getLevel());
                                    }
                                    else {
                                        this.setLevel(this.getMinLevel(this.getLevel(), format.getLevel()));
                                    }
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.updateProfileToCompatible = function (format) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(format.getProfile(), null))) {
                            this.setProfile(format.getProfile());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.updateTierToCompatible = function (format) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(format.getTier(), null))) {
                            this.setTier(format.getTier());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaFormat.prototype.updateToCompatible = function (format) {
                    if (arguments.length == 1) {
                        this.updateProfileToCompatible(format);
                        this.updateLevelToCompatible(format);
                        this.updateLevelIsStrictToCompatible(format);
                        this.updateTierToCompatible(format);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaFormat;
            }());
            icelink.MediaFormat = MediaFormat;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AudioFormat =  (function (_super) {
                __extends(AudioFormat, _super);
                function AudioFormat() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkAudioFormatInit();
                    }
                    else if (__arguments.length == 3) {
                        var name_9 = __arguments[0];
                        var clockRate = __arguments[1];
                        var channelCount = __arguments[2];
                        _this = _super.call(this, name_9, clockRate) || this;
                        _this.fmicelinkAudioFormatInit();
                        _this.setChannelCount(channelCount);
                    }
                    else if (__arguments.length == 2) {
                        var name_10 = __arguments[0];
                        var config = __arguments[1];
                        _this = _super.call(this, name_10, config.getClockRate()) || this;
                        _this.fmicelinkAudioFormatInit();
                        _this.setChannelCount(config.getChannelCount());
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                AudioFormat.prototype.getTypeString = function () {
                    return '[fm.icelink.AudioFormat]' + ',' + _super.prototype.getTypeString.call(this);
                };
                AudioFormat.prototype.fmicelinkAudioFormatInit = function () {
                    this._channelCount = 0;
                    this._littleEndian = false;
                };
                AudioFormat.fromJson = function (audioFormatJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(audioFormatJson, function () {
                            return new fm.icelink.AudioFormat();
                        }, function (audioFormat, name, valueJson) {
                            var _var0 = name;
                            do {
                                if (_var0 == "channelCount") {
                                    audioFormat.setChannelCount(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    break;
                                }
                                else if (_var0 == "littleEndian") {
                                    audioFormat.setLittleEndian(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    break;
                                }
                                else if (_var0 == "name") {
                                    audioFormat.setName(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    break;
                                }
                                else if (_var0 == "clockRate") {
                                    audioFormat.setClockRate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    break;
                                }
                                else if (_var0 == "isPacketized") {
                                    audioFormat.setIsPacketized(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    break;
                                }
                                else if (_var0 == "isEncrypted") {
                                    audioFormat.setIsEncrypted(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    break;
                                }
                                else if (_var0 == "registeredPayloadType") {
                                    audioFormat.setRegisteredPayloadType(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    break;
                                }
                                else if (_var0 == "staticPayloadType") {
                                    audioFormat.setStaticPayloadType(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    break;
                                }
                            } while (false);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.getDtmfName = function () {
                    if (arguments.length == 0) {
                        return "telephone-event";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.getG722Name = function () {
                    if (arguments.length == 0) {
                        return "G722";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.getL16Name = function () {
                    if (arguments.length == 0) {
                        return "L16";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.getOpusName = function () {
                    if (arguments.length == 0) {
                        return "opus";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.getPcmaName = function () {
                    if (arguments.length == 0) {
                        return "PCMA";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.getPcmName = function () {
                    if (arguments.length == 0) {
                        return "PCM";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.getPcmuName = function () {
                    if (arguments.length == 0) {
                        return "PCMU";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.toJson = function (audioFormat) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(audioFormat, function (obj, jsonObject) {
                            jsonObject["channelCount"] = fm.icelink.JsonSerializer.serializeInteger(audioFormat.getChannelCount());
                            jsonObject["littleEndian"] = fm.icelink.JsonSerializer.serializeBoolean(audioFormat.getLittleEndian());
                            jsonObject["name"] = fm.icelink.JsonSerializer.serializeString(audioFormat.getName());
                            jsonObject["clockRate"] = fm.icelink.JsonSerializer.serializeInteger(audioFormat.getClockRate());
                            jsonObject["isPacketized"] = fm.icelink.JsonSerializer.serializeBoolean(audioFormat.getIsPacketized());
                            jsonObject["isEncrypted"] = fm.icelink.JsonSerializer.serializeBoolean(audioFormat.getIsEncrypted());
                            jsonObject["registeredPayloadType"] = fm.icelink.JsonSerializer.serializeInteger(audioFormat.getRegisteredPayloadType());
                            jsonObject["staticPayloadType"] = fm.icelink.JsonSerializer.serializeInteger(audioFormat.getStaticPayloadType());
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.clone = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.clone.call(this);
                        format.setChannelCount(this.getChannelCount());
                        format.setLittleEndian(this.getLittleEndian());
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.createInstance = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.AudioFormat();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getChannelCount = function () {
                    if (arguments.length == 0) {
                        return this._channelCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getConfig = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.AudioConfig(_super.prototype.getClockRate.call(this), this.getChannelCount());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getInfo = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.FormatInfo(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getIsCompressed = function () {
                    if (arguments.length == 0) {
                        return !this.getIsPcm();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getIsDtmf = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.AudioFormat.getDtmfName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getIsG722 = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.AudioFormat.getG722Name(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getIsL16 = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.AudioFormat.getL16Name(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getIsOpus = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.AudioFormat.getOpusName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getIsPcm = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.AudioFormat.getPcmName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getIsPcma = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.AudioFormat.getPcmaName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getIsPcmu = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.AudioFormat.getPcmuName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getLittleEndian = function () {
                    if (arguments.length == 0) {
                        return this._littleEndian;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.getParameters = function () {
                    if (arguments.length == 0) {
                        var channelCount = this.getChannelCount();
                        if ((fm.icelink.Global.equals(channelCount, 1))) {
                            return null;
                        }
                        return fm.icelink.NumberExtensions.toString(channelCount);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.isCompatible = function (format) {
                    if (arguments.length == 1) {
                        if (!_super.prototype.isCompatible.call(this, format)) {
                            return false;
                        }
                        if ((!fm.icelink.Global.equals(this.getChannelCount(), format.getChannelCount()))) {
                            return false;
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.isEquivalent = function (format, ignoreIsPacketized) {
                    if (arguments.length == 2) {
                        return (_super.prototype.isEquivalent.call(this, format, ignoreIsPacketized) && (fm.icelink.Global.equals(this.getChannelCount(), format.getChannelCount())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.setChannelCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._channelCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.setLittleEndian = function (value) {
                    if (arguments.length == 1) {
                        this._littleEndian = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioFormat.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.AudioFormat.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return AudioFormat;
            }(fm.icelink.MediaFormat));
            icelink.AudioFormat = AudioFormat;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaSinkBase =  (function (_super) {
                __extends(MediaSinkBase, _super);
                function MediaSinkBase() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.__id = fm.icelink.Utility.generateId();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaSinkBase.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaSinkBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaSinkBase.prototype.getExternalId = function () {
                    if (arguments.length == 0) {
                        return this._externalId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkBase.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this.__id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkBase.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkBase.prototype.setExternalId = function (value) {
                    if (arguments.length == 1) {
                        this._externalId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkBase.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaSinkBase;
            }(fm.icelink.Dynamic));
            icelink.MediaSinkBase = MediaSinkBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaSourceBase =  (function (_super) {
                __extends(MediaSourceBase, _super);
                function MediaSourceBase() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.__id = fm.icelink.Utility.generateId();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaSourceBase.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaSourceBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaSourceBase.prototype.getExternalId = function () {
                    if (arguments.length == 0) {
                        return this._externalId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceBase.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this.__id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceBase.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceBase.prototype.setExternalId = function (value) {
                    if (arguments.length == 1) {
                        this._externalId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceBase.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaSourceBase;
            }(fm.icelink.Dynamic));
            icelink.MediaSourceBase = MediaSourceBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcStreamBase =  (function (_super) {
                __extends(WebRtcStreamBase, _super);
                function WebRtcStreamBase(type) {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var type_3 = __arguments[0];
                        _this = _super.call(this) || this;
                        _this.fmicelinkWebRtcStreamBaseInit();
                        _this.__id = fm.icelink.Utility.generateId();
                        _this.__stateLock = new Object();
                        _this.setType(type_3);
                        _this.setConnectedTimestamp(-1);
                        _this.__stateMachine = new fm.icelink.StreamStateMachine();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebRtcStreamBase.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcStreamBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcStreamBase.prototype.fmicelinkWebRtcStreamBaseInit = function () {
                    var _this = this;
                    this.__onDirectionChange = [];
                    this.__onStateChange = [];
                    this._connectedTimestamp = 0;
                    this._onDirectionChange = function () { for (var _i = 0, _a = _this.__onDirectionChange; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action();
                    } };
                    this._onStateChange = function () { for (var _i = 0, _a = _this.__onStateChange; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action();
                    } };
                };
                WebRtcStreamBase.prototype.addOnDirectionChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onDirectionChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.addOnStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getConnectedTimestamp = function () {
                    if (arguments.length == 0) {
                        return this._connectedTimestamp;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getConnectionId = function () {
                    if (arguments.length == 0) {
                        return this._connectionId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getExternalId = function () {
                    if (arguments.length == 0) {
                        return this._externalId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this.__id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getIsTerminated = function () {
                    if (arguments.length == 0) {
                        return ((fm.icelink.Global.equals(this.getState(), fm.icelink.StreamState.Closed)) || (fm.icelink.Global.equals(this.getState(), fm.icelink.StreamState.Failed)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getIsTerminating = function () {
                    if (arguments.length == 0) {
                        return ((fm.icelink.Global.equals(this.getState(), fm.icelink.StreamState.Closing)) || (fm.icelink.Global.equals(this.getState(), fm.icelink.StreamState.Failing)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getIsTerminatingOrTerminated = function () {
                    if (arguments.length == 0) {
                        return (this.getIsTerminating() || this.getIsTerminated());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getLocalReceive = function () {
                    if (arguments.length == 0) {
                        var localDirection = this.getLocalDirection();
                        return ((fm.icelink.Global.equals(localDirection, fm.icelink.StreamDirection.SendReceive)) || (fm.icelink.Global.equals(localDirection, fm.icelink.StreamDirection.ReceiveOnly)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getLocalSend = function () {
                    if (arguments.length == 0) {
                        var localDirection = this.getLocalDirection();
                        return ((fm.icelink.Global.equals(localDirection, fm.icelink.StreamDirection.SendReceive)) || (fm.icelink.Global.equals(localDirection, fm.icelink.StreamDirection.SendOnly)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getMediaDescriptionId = function () {
                    if (arguments.length == 0) {
                        return this.getMediaStreamIdentification();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getMediaStreamIdentification = function () {
                    if (arguments.length == 0) {
                        return this.__mediaStreamIdentification;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getRemoteReceive = function () {
                    if (arguments.length == 0) {
                        var remoteDirection = this.getRemoteDirection();
                        return ((fm.icelink.Global.equals(remoteDirection, fm.icelink.StreamDirection.SendReceive)) || (fm.icelink.Global.equals(remoteDirection, fm.icelink.StreamDirection.ReceiveOnly)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getRemoteSend = function () {
                    if (arguments.length == 0) {
                        var remoteDirection = this.getRemoteDirection();
                        return ((fm.icelink.Global.equals(remoteDirection, fm.icelink.StreamDirection.SendReceive)) || (fm.icelink.Global.equals(remoteDirection, fm.icelink.StreamDirection.SendOnly)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getState = function () {
                    if (arguments.length == 0) {
                        return this.__stateMachine.getState();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getStateLock = function () {
                    if (arguments.length == 0) {
                        return this.__stateLock;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.getType = function () {
                    if (arguments.length == 0) {
                        return this._type;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.logInvalidStateTransition = function (state) {
                    if (arguments.length == 1) {
                        if (fm.icelink.Log.getIsDebugEnabled()) {
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Stream {0} state for connection {1} is currently {2}. Cannot transition to {3} state.", [this.getId(), this.getConnectionId(), fm.icelink.StringExtensions.toLower(new fm.icelink.StreamStateWrapper(this.getState()).toString()), fm.icelink.StringExtensions.toLower(new fm.icelink.StreamStateWrapper(state).toString())]));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.processStateChange = function () {
                    if (arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.processStateLockChange = function () {
                    if (arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.processUpdateToMediaStreamIdentification = function (oldValue) {
                    if (arguments.length == 1) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.raiseDirectionChange = function () {
                    if (arguments.length == 0) {
                        var onDirectionChange = this._onDirectionChange;
                        if ((!fm.icelink.Global.equals(onDirectionChange, null))) {
                            try {
                                onDirectionChange();
                            }
                            catch (exception) {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising direction change to the application code for stream {0}.", this.getId()), exception);
                            }
                            finally {
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.raiseStateChange = function () {
                    if (arguments.length == 0) {
                        var onStateChange = this._onStateChange;
                        if ((!fm.icelink.Global.equals(onStateChange, null))) {
                            try {
                                onStateChange();
                            }
                            catch (exception) {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising state change to the application code for stream {0}.", this.getId()), exception);
                            }
                            finally {
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.removeOnDirectionChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onDirectionChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.removeOnStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.setConnectedTimestamp = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._connectedTimestamp = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.setConnectionId = function (value) {
                    if (arguments.length == 1) {
                        this._connectionId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.setExternalId = function (value) {
                    if (arguments.length == 1) {
                        this._externalId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.setLocalReceive = function (value) {
                    if (arguments.length == 1) {
                        var localDirection = this.getLocalDirection();
                        var _var0 = localDirection;
                        do {
                            if (_var0 == fm.icelink.StreamDirection.SendReceive) {
                                if (!value) {
                                    this.setLocalDirection(fm.icelink.StreamDirection.SendOnly);
                                }
                                break;
                            }
                            else if (_var0 == fm.icelink.StreamDirection.Inactive || _var0 == fm.icelink.StreamDirection.Unset) {
                                if (value) {
                                    this.setLocalDirection(fm.icelink.StreamDirection.ReceiveOnly);
                                }
                                else {
                                    this.setLocalDirection(fm.icelink.StreamDirection.SendOnly);
                                }
                                break;
                            }
                            else if (_var0 == fm.icelink.StreamDirection.SendOnly) {
                                if (value) {
                                    this.setLocalDirection(fm.icelink.StreamDirection.SendReceive);
                                }
                                break;
                            }
                            else {
                                if (((fm.icelink.Global.equals(localDirection, fm.icelink.StreamDirection.ReceiveOnly)) && !value)) {
                                    this.setLocalDirection(fm.icelink.StreamDirection.Inactive);
                                }
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.setLocalSend = function (value) {
                    if (arguments.length == 1) {
                        var localDirection = this.getLocalDirection();
                        var _var0 = localDirection;
                        do {
                            if (_var0 == fm.icelink.StreamDirection.SendReceive) {
                                if (!value) {
                                    this.setLocalDirection(fm.icelink.StreamDirection.ReceiveOnly);
                                }
                                break;
                            }
                            else if (_var0 == fm.icelink.StreamDirection.Inactive || _var0 == fm.icelink.StreamDirection.Unset) {
                                if (value) {
                                    this.setLocalDirection(fm.icelink.StreamDirection.SendOnly);
                                }
                                else {
                                    this.setLocalDirection(fm.icelink.StreamDirection.ReceiveOnly);
                                }
                                break;
                            }
                            else if (_var0 == fm.icelink.StreamDirection.ReceiveOnly) {
                                if (value) {
                                    this.setLocalDirection(fm.icelink.StreamDirection.SendReceive);
                                }
                                break;
                            }
                            else {
                                if (((fm.icelink.Global.equals(localDirection, fm.icelink.StreamDirection.SendOnly)) && !value)) {
                                    this.setLocalDirection(fm.icelink.StreamDirection.Inactive);
                                }
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.setMediaStreamIdentification = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.__mediaStreamIdentification, value))) {
                            var oldValue = this.__mediaStreamIdentification;
                            this.__mediaStreamIdentification = value;
                            this.processUpdateToMediaStreamIdentification(oldValue);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.setState = function (state) {
                    if (arguments.length == 1) {
                        if (!this.__stateMachine.transition(state)) {
                            if (((!fm.icelink.Global.equals(state, this.getState())) && ((!fm.icelink.Global.equals(state, fm.icelink.StreamState.Closing)) || ((!fm.icelink.Global.equals(this.getState(), fm.icelink.StreamState.Closed)) && (!fm.icelink.Global.equals(this.getState(), fm.icelink.StreamState.Failed)))))) {
                                this.logInvalidStateTransition(state);
                            }
                            return false;
                        }
                        if ((fm.icelink.Global.equals(this.getState(), fm.icelink.StreamState.Connected))) {
                            this.setConnectedTimestamp(fm.icelink.ManagedStopwatch.getTimestamp());
                        }
                        if (fm.icelink.Log.getIsInfoEnabled()) {
                            if ((fm.icelink.Global.equals(this.getState(), fm.icelink.StreamState.Connected))) {
                                fm.icelink.Log.info(fm.icelink.StringExtensions.format("{0} stream {1} for connection {2} took {3}ms to connect (connectivity checks and secure key exchange).", [new fm.icelink.StreamTypeWrapper(this.getType()).toString(), this.getId(), this.getConnectionId(), fm.icelink.NumberExtensions.toString(this.__stateMachine.getLastStateMillis())]));
                            }
                            fm.icelink.Log.info(fm.icelink.StringExtensions.format("Setting {0} stream {1} state for connection {2} to {3}.", [fm.icelink.StringExtensions.toLower(new fm.icelink.StreamTypeWrapper(this.getType()).toString()), this.getId(), this.getConnectionId(), fm.icelink.StringExtensions.toLower(new fm.icelink.StreamStateWrapper(this.getState()).toString())]));
                        }
                        this.raiseStateChange();
                        this.processStateChange();
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.setStateLock = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.__stateLock, value))) {
                            this.__stateLock = value;
                            this.processStateLockChange();
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.setType = function (value) {
                    if (arguments.length == 1) {
                        this._type = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcStreamBase.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return this.getLabel();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebRtcStreamBase;
            }(fm.icelink.Dynamic));
            icelink.WebRtcStreamBase = WebRtcStreamBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcStream =  (function (_super) {
                __extends(WebRtcStream, _super);
                function WebRtcStream() {
                    return _super !== null && _super.apply(this, arguments) || this;
                }
                WebRtcStream.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcStream.prototype.getConnection = function () {
                    return this._connection;
                };
                WebRtcStream.prototype.setConnection = function (remoteTrack) {
                    this._connection = remoteTrack;
                };
                WebRtcStream.prototype.getMediaDescriptionManager = function () {
                    if (this._mediaDescriptionManager == null) {
                        this._mediaDescriptionManager = new fm.icelink.MediaDescriptionManager();
                    }
                    return this._mediaDescriptionManager;
                };
                WebRtcStream.prototype.setMediaDescriptionManager = function (manager) {
                    this._mediaDescriptionManager = manager;
                };
                WebRtcStream.prototype.setTransportInfo = function (transportInfo) {
                    this._transportInfo = transportInfo;
                };
                WebRtcStream.prototype.getTransportInfo = function () {
                    return this._transportInfo;
                };
                return WebRtcStream;
            }(fm.icelink.WebRtcStreamBase));
            icelink.WebRtcStream = WebRtcStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcMediaStreamBase =  (function (_super) {
                __extends(WebRtcMediaStreamBase, _super);
                function WebRtcMediaStreamBase(type) {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var type_4 = __arguments[0];
                        _this = _super.call(this, type_4) || this;
                        _this.fmicelinkWebRtcMediaStreamBaseInit();
                        _this._renegotiationLock = new Object();
                        _this.__maxSendBitrate = -1;
                        _this.__maxReceiveBitrate = -1;
                        _this.__pendingLocalDirection = fm.icelink.StreamDirection.Inactive;
                        _this.__disabledCodecs = {};
                        _this.setLocalDirection(fm.icelink.StreamDirection.Unset);
                        _this.setRemoteDirection(fm.icelink.StreamDirection.Unset);
                        _this.setLocalBandwidth(-1);
                        _this.setRemoteBandwidth(-1);
                        if ((!fm.icelink.Global.equals(fm.icelink.Platform.getInstance().getSourceLanguage(), fm.icelink.SourceLanguage.TypeScript))) {
                            _this.__localCanonicalName = fm.icelink.Utility.generateId();
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebRtcMediaStreamBase.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcMediaStreamBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcMediaStreamBase.prototype.fmicelinkWebRtcMediaStreamBaseInit = function () {
                    var _this = this;
                    this.__maxReceiveBitrate = 0;
                    this.__maxSendBitrate = 0;
                    this.__onLocalEncodingDisabled = [];
                    this.__onLocalEncodingEnabled = [];
                    this._localBandwidth = 0;
                    this._onLocalEncodingDisabled = function (p0) { for (var _i = 0, _a = _this.__onLocalEncodingDisabled; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0);
                    } };
                    this._onLocalEncodingEnabled = function (p0) { for (var _i = 0, _a = _this.__onLocalEncodingEnabled; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0);
                    } };
                    this._remoteBandwidth = 0;
                    this._remoteMuted = false;
                    this._renegotiationPending = false;
                };
                WebRtcMediaStreamBase.prototype.addOnLocalEncodingDisabled = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onLocalEncodingDisabled, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.addOnLocalEncodingEnabled = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onLocalEncodingEnabled, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.changeDirection = function (newDirection) {
                    if (arguments.length == 1) {
                        var message = "An attempt has been made to modify exisiting media stream direction; however, existing stream capabilities do not support a new setting.";
                        if ((fm.icelink.Global.equals(this.getDirectionCapabilities(), fm.icelink.StreamDirection.Inactive))) {
                            if ((!fm.icelink.Global.equals(newDirection, fm.icelink.StreamDirection.Inactive))) {
                                return new fm.icelink.Error(fm.icelink.ErrorCode.InvalidStreamDirectionChange, new fm.icelink.Exception(message));
                            }
                        }
                        else {
                            if ((fm.icelink.Global.equals(this.getDirectionCapabilities(), fm.icelink.StreamDirection.SendOnly))) {
                                if (((!fm.icelink.Global.equals(newDirection, fm.icelink.StreamDirection.Inactive)) && (!fm.icelink.Global.equals(newDirection, fm.icelink.StreamDirection.SendOnly)))) {
                                    return new fm.icelink.Error(fm.icelink.ErrorCode.InvalidStreamDirectionChange, new fm.icelink.Exception(message));
                                }
                            }
                            else {
                                if (((fm.icelink.Global.equals(this.getDirectionCapabilities(), fm.icelink.StreamDirection.ReceiveOnly)) && ((!fm.icelink.Global.equals(newDirection, fm.icelink.StreamDirection.Inactive)) && (!fm.icelink.Global.equals(newDirection, fm.icelink.StreamDirection.ReceiveOnly))))) {
                                    return new fm.icelink.Error(fm.icelink.ErrorCode.InvalidStreamDirectionChange, new fm.icelink.Exception(message));
                                }
                            }
                        }
                        this.setPendingLocalDirection(newDirection);
                        this.setRenegotiationPending(true);
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.extractCanonicalName = function (mediaDescription, isLocalDescription) {
                    if (arguments.length == 2) {
                        var ssrcAttributes = mediaDescription.getSsrcAttributes();
                        var str = null;
                        for (var _i = 0, ssrcAttributes_1 = ssrcAttributes; _i < ssrcAttributes_1.length; _i++) {
                            var attribute = ssrcAttributes_1[_i];
                            if ((fm.icelink.Global.equals(attribute.getName(), fm.icelink.sdp.rtp.SsrcAttributeName.getCName()))) {
                                str = attribute.getValue();
                                break;
                            }
                        }
                        if (isLocalDescription) {
                            this.setLocalCanonicalName(str);
                        }
                        else {
                            this.setRemoteCanonicalName(str);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getCanonicalName = function () {
                    if (arguments.length == 0) {
                        fm.icelink.Log.warn("Getting the value of MediaStream.CanonicalName is deprecated. Get the value of MediaStream.LocalCanonicalName instead.");
                        return this.getLocalCanonicalName();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getCodecDisabled = function (name) {
                    if (arguments.length == 1) {
                        var key = fm.icelink.StringExtensions.toLower(name);
                        return fm.icelink.HashExtensions.containsKey(this.__disabledCodecs, key);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getDirection = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(this.getLocalDirection(), fm.icelink.StreamDirection.SendReceive))) {
                            if ((fm.icelink.Global.equals(this.getRemoteDirection(), fm.icelink.StreamDirection.ReceiveOnly))) {
                                return fm.icelink.StreamDirection.SendOnly;
                            }
                            if ((fm.icelink.Global.equals(this.getRemoteDirection(), fm.icelink.StreamDirection.SendOnly))) {
                                return fm.icelink.StreamDirection.ReceiveOnly;
                            }
                            return this.getRemoteDirection();
                        }
                        if ((fm.icelink.Global.equals(this.getLocalDirection(), fm.icelink.StreamDirection.SendOnly))) {
                            if (((fm.icelink.Global.equals(this.getRemoteDirection(), fm.icelink.StreamDirection.Inactive)) || (fm.icelink.Global.equals(this.getRemoteDirection(), fm.icelink.StreamDirection.SendOnly)))) {
                                return fm.icelink.StreamDirection.Inactive;
                            }
                            return this.getLocalDirection();
                        }
                        if ((fm.icelink.Global.equals(this.getLocalDirection(), fm.icelink.StreamDirection.ReceiveOnly))) {
                            if (((fm.icelink.Global.equals(this.getRemoteDirection(), fm.icelink.StreamDirection.Inactive)) || (fm.icelink.Global.equals(this.getRemoteDirection(), fm.icelink.StreamDirection.ReceiveOnly)))) {
                                return fm.icelink.StreamDirection.Inactive;
                            }
                            return this.getLocalDirection();
                        }
                        return fm.icelink.StreamDirection.Inactive;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getInfo = function () {
                    if (arguments.length == 0) {
                        var info2 = new fm.icelink.MediaStreamInfo();
                        info2.setId(_super.prototype.getId.call(this));
                        info2.setTag(_super.prototype.getTag.call(this));
                        info2.setSendMuted(this.getInputMuted());
                        info2.setSendDisabled(fm.icelink.StreamDirectionHelper.isSendDisabled(this.getDirection()));
                        info2.setReceiveDisabled(fm.icelink.StreamDirectionHelper.isReceiveDisabled(this.getDirection()));
                        var info = info2;
                        this.populateInfo(info);
                        return info;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getLabel = function () {
                    if (arguments.length == 0) {
                        var _var0 = _super.prototype.getType.call(this);
                        do {
                            if (_var0 == fm.icelink.StreamType.Audio) {
                                return "Audio Stream";
                            }
                            else if (_var0 == fm.icelink.StreamType.Video) {
                                return "Video Stream";
                            }
                            else if (_var0 == fm.icelink.StreamType.Application) {
                                return "Application Stream";
                            }
                            else if (_var0 == fm.icelink.StreamType.Message) {
                                return "Message Stream";
                            }
                            else if (_var0 == fm.icelink.StreamType.Text) {
                                return "Text Stream";
                            }
                        } while (false);
                        return "Unknown Stream";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getLocalBandwidth = function () {
                    if (arguments.length == 0) {
                        return this._localBandwidth;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getLocalCanonicalName = function () {
                    if (arguments.length == 0) {
                        return this.__localCanonicalName;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getLocalDirection = function () {
                    if (arguments.length == 0) {
                        return this.__localDirection;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getLocalMuted = function () {
                    if (arguments.length == 0) {
                        return this.getMuted();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getMaxReceiveBitrate = function () {
                    if (arguments.length == 0) {
                        return this.__maxReceiveBitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getMaxSendBitrate = function () {
                    if (arguments.length == 0) {
                        return this.__maxSendBitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getMuted = function () {
                    if (arguments.length == 0) {
                        return this.getInputMuted();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getPendingLocalDirection = function () {
                    if (arguments.length == 0) {
                        return this.__pendingLocalDirection;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getPreferredCodecs = function () {
                    if (arguments.length == 0) {
                        return this._preferredCodecs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getRemoteBandwidth = function () {
                    if (arguments.length == 0) {
                        return this._remoteBandwidth;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getRemoteCanonicalName = function () {
                    if (arguments.length == 0) {
                        return this._remoteCanonicalName;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getRemoteDirection = function () {
                    if (arguments.length == 0) {
                        return this.__remoteDirection;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getRemoteEncoding = function () {
                    if (arguments.length == 0) {
                        return this._remoteEncoding;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getRemoteMuted = function () {
                    if (arguments.length == 0) {
                        return this._remoteMuted;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.getRenegotiationPending = function () {
                    if (arguments.length == 0) {
                        return this._renegotiationPending;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.raiseLocalEncodingDisabled = function (encoding) {
                    if (arguments.length == 1) {
                        var onLocalEncodingDisabled = this._onLocalEncodingDisabled;
                        if ((!fm.icelink.Global.equals(onLocalEncodingDisabled, null))) {
                            onLocalEncodingDisabled(encoding);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.raiseLocalEncodingEnabled = function (encoding) {
                    if (arguments.length == 1) {
                        var onLocalEncodingEnabled = this._onLocalEncodingEnabled;
                        if ((!fm.icelink.Global.equals(onLocalEncodingEnabled, null))) {
                            onLocalEncodingEnabled(encoding);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.removeOnLocalEncodingDisabled = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onLocalEncodingDisabled, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.removeOnLocalEncodingEnabled = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onLocalEncodingEnabled, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setCodecDisabled = function (name, disabled) {
                    if (arguments.length == 2) {
                        var key = fm.icelink.StringExtensions.toLower(name);
                        if (disabled) {
                            this.__disabledCodecs[key] = new Object();
                        }
                        else {
                            fm.icelink.HashExtensions.remove(this.__disabledCodecs, key);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setLocalBandwidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._localBandwidth = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setLocalCanonicalName = function (value) {
                    if (arguments.length == 1) {
                        this.__localCanonicalName = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setLocalDirection = function (value) {
                    if (arguments.length == 1) {
                        var direction = this.getDirection();
                        this.__localDirection = value;
                        if ((!fm.icelink.Global.equals(direction, this.getDirection()))) {
                            _super.prototype.raiseDirectionChange.call(this);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setLocalMuted = function (value) {
                    if (arguments.length == 1) {
                        this.setMuted(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setMaxReceiveBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        var localBandwidth = fm.icelink.Global.toInt(this.getLocalBandwidth());
                        if (((!fm.icelink.Global.equals(localBandwidth, -1)) && (value > localBandwidth))) {
                            value = fm.icelink.Global.toInt(localBandwidth);
                        }
                        if ((value < 0)) {
                            value = fm.icelink.Global.toInt(-1);
                        }
                        this.__maxReceiveBitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setMaxSendBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        var remoteBandwidth = fm.icelink.Global.toInt(this.getRemoteBandwidth());
                        if (((!fm.icelink.Global.equals(remoteBandwidth, -1)) && (value > remoteBandwidth))) {
                            value = fm.icelink.Global.toInt(remoteBandwidth);
                        }
                        if ((value < 0)) {
                            value = fm.icelink.Global.toInt(-1);
                        }
                        this.__maxSendBitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setMuted = function (value) {
                    if (arguments.length == 1) {
                        this.setInputMuted(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setPendingLocalDirection = function (value) {
                    if (arguments.length == 1) {
                        this.__pendingLocalDirection = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setPreferredCodecs = function (value) {
                    if (arguments.length == 1) {
                        this._preferredCodecs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setRemoteBandwidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._remoteBandwidth = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setRemoteCanonicalName = function (value) {
                    if (arguments.length == 1) {
                        this._remoteCanonicalName = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setRemoteDirection = function (value) {
                    if (arguments.length == 1) {
                        var direction = this.getDirection();
                        this.__remoteDirection = value;
                        if ((!fm.icelink.Global.equals(direction, this.getDirection()))) {
                            _super.prototype.raiseDirectionChange.call(this);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setRemoteEncoding = function (value) {
                    if (arguments.length == 1) {
                        this._remoteEncoding = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setRemoteMuted = function (value) {
                    if (arguments.length == 1) {
                        this._remoteMuted = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaStreamBase.prototype.setRenegotiationPending = function (value) {
                    if (arguments.length == 1) {
                        this._renegotiationPending = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebRtcMediaStreamBase;
            }(fm.icelink.WebRtcStream));
            icelink.WebRtcMediaStreamBase = WebRtcMediaStreamBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CcmTmmbnPolicyWrapper =  (function () {
                function CcmTmmbnPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_17 = __arguments[0];
                        this._value = value_17;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CcmTmmbnPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.CcmTmmbnPolicyWrapper]';
                };
                CcmTmmbnPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.CcmTmmbnPolicy.Disabled)
                            return 'Disabled';
                        if (this._value == fm.icelink.CcmTmmbnPolicy.Negotiated)
                            return 'Negotiated';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CcmTmmbnPolicyWrapper;
            }());
            icelink.CcmTmmbnPolicyWrapper = CcmTmmbnPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CcmTmmbrPolicyWrapper =  (function () {
                function CcmTmmbrPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_18 = __arguments[0];
                        this._value = value_18;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CcmTmmbrPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.CcmTmmbrPolicyWrapper]';
                };
                CcmTmmbrPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.CcmTmmbrPolicy.Disabled)
                            return 'Disabled';
                        if (this._value == fm.icelink.CcmTmmbrPolicy.Negotiated)
                            return 'Negotiated';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CcmTmmbrPolicyWrapper;
            }());
            icelink.CcmTmmbrPolicyWrapper = CcmTmmbrPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaDescriptionManagerBase =  (function () {
                function MediaDescriptionManagerBase() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                MediaDescriptionManagerBase.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaDescriptionManagerBase]';
                };
                MediaDescriptionManagerBase.syncroniseMediaIdentification = function (sdpMediaDescription, index) {
                    if (arguments.length == 2) {
                        index = fm.icelink.Global.toInt(arguments[1]);
                        var str = "";
                        var mediaStreamIdentifierAttribute = sdpMediaDescription.getMediaStreamIdentifierAttribute();
                        if ((fm.icelink.Global.equals(mediaStreamIdentifierAttribute, null))) {
                            var idValue = fm.icelink.NumberExtensions.toString(index);
                            str = idValue;
                            sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.MediaStreamIdAttribute(idValue));
                            return str;
                        }
                        return mediaStreamIdentifierAttribute.getIdentificationTag();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaDescriptionManagerBase.prototype.getMediaStreamIdentifier = function () {
                    if (arguments.length == 0) {
                        return this._mediaStreamIdentifier;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaDescriptionManagerBase.prototype.processSdpMediaDescription = function (mediaRequirements, sdpMessage, index, isLocalDescription, isRenegotiation, isOffer) {
                    if (arguments.length == 6) {
                        index = fm.icelink.Global.toInt(arguments[2]);
                        mediaRequirements.setMediaStreamIdentifier(fm.icelink.MediaDescriptionManagerBase.syncroniseMediaIdentification(sdpMessage.getMediaDescriptions()[index], index));
                        this.setMediaStreamIdentifier(mediaRequirements.getMediaStreamIdentifier());
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaDescriptionManagerBase.prototype.setMediaStreamIdentifier = function (value) {
                    if (arguments.length == 1) {
                        this._mediaStreamIdentifier = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaDescriptionManagerBase;
            }());
            icelink.MediaDescriptionManagerBase = MediaDescriptionManagerBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaDescriptionRequirementsBase =  (function () {
                function MediaDescriptionRequirementsBase() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                MediaDescriptionRequirementsBase.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaDescriptionRequirementsBase]';
                };
                MediaDescriptionRequirementsBase.prototype.getMediaStreamIdentifier = function () {
                    if (arguments.length == 0) {
                        return this._mediaStreamIdentifier;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaDescriptionRequirementsBase.prototype.setMediaStreamIdentifier = function (value) {
                    if (arguments.length == 1) {
                        this._mediaStreamIdentifier = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaDescriptionRequirementsBase;
            }());
            icelink.MediaDescriptionRequirementsBase = MediaDescriptionRequirementsBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var RateLimiter =  (function () {
                function RateLimiter() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        __arguments = new Array(1);
                        __arguments[0] = fm.icelink.RateLimiter.generateRateLimiterRules(200, 2, 9);
                        {
                            var rules = __arguments[0];
                            this.fmicelinkRateLimiterInit();
                            this.__lock = new Object();
                            this.__nextAllowedExecution = -1;
                            this.__rules = rules;
                        }
                    }
                    else if (__arguments.length == 1) {
                        var rules = __arguments[0];
                        this.fmicelinkRateLimiterInit();
                        this.__lock = new Object();
                        this.__nextAllowedExecution = -1;
                        this.__rules = rules;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                RateLimiter.prototype.getTypeString = function () {
                    return '[fm.icelink.RateLimiter]';
                };
                RateLimiter.prototype.fmicelinkRateLimiterInit = function () {
                    this.__nextAllowedExecution = 0;
                    this.__numExecutions = 0;
                    this.__originalExecutionTime = 0;
                };
                RateLimiter.generateRateLimiterRules = function (originalInterval, backoffMultiplier, numRules) {
                    if (arguments.length == 3) {
                        originalInterval = fm.icelink.Global.toInt(arguments[0]);
                        backoffMultiplier = fm.icelink.Global.toInt(arguments[1]);
                        numRules = fm.icelink.Global.toInt(arguments[2]);
                        var ruleArray = new Array(numRules);
                        ruleArray[0] = new fm.icelink.RateLimiterRule(1, originalInterval);
                        for (var i = 1; (i < numRules); i++) {
                            ruleArray[i] = new fm.icelink.RateLimiterRule((i + 1), (backoffMultiplier * ruleArray[(i - 1)].getPeriod()));
                        }
                        return ruleArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RateLimiter.prototype.checkDelay = function (currentTime) {
                    if (arguments.length == 1) {
                        currentTime = fm.icelink.Global.toInt(arguments[0]);
                        if ((this.__nextAllowedExecution <= currentTime)) {
                            var index = fm.icelink.MathAssistant.min(this.__numExecutions, this.__rules.length);
                            if ((fm.icelink.Global.equals(index, 0))) {
                                this.__originalExecutionTime = currentTime;
                            }
                            this.__nextAllowedExecution = (this.__rules[index].getPeriod() + this.__originalExecutionTime);
                            this.__numExecutions++;
                            return 0;
                        }
                        return (this.__nextAllowedExecution - currentTime);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RateLimiter.prototype.getRules = function () {
                    if (arguments.length == 0) {
                        return this.__rules;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RateLimiter.prototype.reset = function () {
                    if (arguments.length == 0) {
                        this.__nextAllowedExecution = -1;
                        this.__numExecutions = 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return RateLimiter;
            }());
            icelink.RateLimiter = RateLimiter;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var RateLimiterRule =  (function () {
                function RateLimiterRule(limit, period) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var limit_1 = __arguments[0];
                        var period_1 = __arguments[1];
                        this.fmicelinkRateLimiterRuleInit();
                        this.setLimit(limit_1);
                        this.setPeriod(period_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                RateLimiterRule.prototype.getTypeString = function () {
                    return '[fm.icelink.RateLimiterRule]';
                };
                RateLimiterRule.prototype.fmicelinkRateLimiterRuleInit = function () {
                    this._limit = 0;
                    this._period = 0;
                };
                RateLimiterRule.prototype.getLimit = function () {
                    if (arguments.length == 0) {
                        return this._limit;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RateLimiterRule.prototype.getPeriod = function () {
                    if (arguments.length == 0) {
                        return this._period;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RateLimiterRule.prototype.setLimit = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._limit = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RateLimiterRule.prototype.setPeriod = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._period = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return RateLimiterRule;
            }());
            icelink.RateLimiterRule = RateLimiterRule;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaStreamMediaDescriptionManagerUtility =  (function () {
                function MediaStreamMediaDescriptionManagerUtility() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                MediaStreamMediaDescriptionManagerUtility.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaStreamMediaDescriptionManagerUtility]';
                };
                MediaStreamMediaDescriptionManagerUtility.prototype.checkIfMuted = function (sdpMediaDescription) {
                    if (arguments.length == 1) {
                        return sdpMediaDescription.getIsMuted();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamMediaDescriptionManagerUtility.prototype.setMuted = function (muted, sdpMediaDescription) {
                    if (arguments.length == 2) {
                        sdpMediaDescription.setIsMuted(muted);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamMediaDescriptionManagerUtility.prototype.updateSdpMediaDescription = function (mediaDescription, requirements) {
                    if (arguments.length == 2) {
                        if (requirements.getLocalMuted()) {
                            mediaDescription.addMediaAttribute(new fm.icelink.sdp.MutedAttribute(true));
                        }
                        return mediaDescription;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaStreamMediaDescriptionManagerUtility;
            }());
            icelink.MediaStreamMediaDescriptionManagerUtility = MediaStreamMediaDescriptionManagerUtility;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var VideoTypeWrapper =  (function () {
                function VideoTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_19 = __arguments[0];
                        this._value = value_19;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                VideoTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.VideoTypeWrapper]';
                };
                VideoTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.VideoType.Unknown)
                            return 'Unknown';
                        if (this._value == fm.icelink.VideoType.Camera)
                            return 'Camera';
                        if (this._value == fm.icelink.VideoType.Screen)
                            return 'Screen';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return VideoTypeWrapper;
            }());
            icelink.VideoTypeWrapper = VideoTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var VideoDegradationPreferenceWrapper =  (function () {
                function VideoDegradationPreferenceWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_20 = __arguments[0];
                        this._value = value_20;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                VideoDegradationPreferenceWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.VideoDegradationPreferenceWrapper]';
                };
                VideoDegradationPreferenceWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.VideoDegradationPreference.Automatic)
                            return 'Automatic';
                        if (this._value == fm.icelink.VideoDegradationPreference.Balanced)
                            return 'Balanced';
                        if (this._value == fm.icelink.VideoDegradationPreference.FrameRate)
                            return 'FrameRate';
                        if (this._value == fm.icelink.VideoDegradationPreference.Resolution)
                            return 'Resolution';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return VideoDegradationPreferenceWrapper;
            }());
            icelink.VideoDegradationPreferenceWrapper = VideoDegradationPreferenceWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SimulcastConfig =  (function () {
                function SimulcastConfig(encodingCount, preferredBitrate) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var encodingCount_1 = __arguments[0];
                        var preferredBitrate_1 = __arguments[1];
                        this.fmicelinkSimulcastConfigInit();
                        this.setEncodingCount(encodingCount_1);
                        this.setPreferredBitrate(preferredBitrate_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SimulcastConfig.prototype.getTypeString = function () {
                    return '[fm.icelink.SimulcastConfig]';
                };
                SimulcastConfig.prototype.fmicelinkSimulcastConfigInit = function () {
                    this.__encodingCount = 0;
                    this.__preferredBitrate = 0;
                    this._disabled = false;
                };
                SimulcastConfig.prototype.getDisabled = function () {
                    if (arguments.length == 0) {
                        return this._disabled;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SimulcastConfig.prototype.getEncodingCount = function () {
                    if (arguments.length == 0) {
                        return this.__encodingCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SimulcastConfig.prototype.getPreferredBitrate = function () {
                    if (arguments.length == 0) {
                        return this.__preferredBitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SimulcastConfig.prototype.setDisabled = function (value) {
                    if (arguments.length == 1) {
                        this._disabled = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SimulcastConfig.prototype.setEncodingCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        if ((value <= 0)) {
                            throw new fm.icelink.Exception("Encoding count must be a positive integer.");
                        }
                        this.__encodingCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SimulcastConfig.prototype.setPreferredBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        if ((value <= 0)) {
                            throw new fm.icelink.Exception("Preferred bitrate must be a positive integer.");
                        }
                        this.__preferredBitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SimulcastConfig;
            }());
            icelink.SimulcastConfig = SimulcastConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AudioSimulcastConfig =  (function (_super) {
                __extends(AudioSimulcastConfig, _super);
                function AudioSimulcastConfig(encodingCount, preferredBitrate) {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var encodingCount_2 = __arguments[0];
                        var preferredBitrate_2 = __arguments[1];
                        _this = _super.call(this, encodingCount_2, preferredBitrate_2) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                AudioSimulcastConfig.prototype.getTypeString = function () {
                    return '[fm.icelink.AudioSimulcastConfig]' + ',' + _super.prototype.getTypeString.call(this);
                };
                AudioSimulcastConfig.prototype.getEncodingConfigs = function () {
                    if (arguments.length == 0) {
                        var list = new Array();
                        if (_super.prototype.getDisabled.call(this)) {
                            fm.icelink.ArrayExtensions.add(list, new fm.icelink.AudioEncodingConfig());
                        }
                        else {
                            var format = new fm.icelink.opus.Format();
                            var num = fm.icelink.MathAssistant.min(fm.icelink.MathAssistant.max(format.getMinBitrate(), _super.prototype.getPreferredBitrate.call(this)), format.getMaxBitrate());
                            for (var i = 0; (i < _super.prototype.getEncodingCount.call(this)); i++) {
                                var num3 = (1 / fm.icelink.MathAssistant.pow(2, i));
                                var config2 = new fm.icelink.AudioEncodingConfig();
                                config2.setBitrate(fm.icelink.MathAssistant.ceil((num * num3)));
                                var item = config2;
                                if ((item.getBitrate() >= format.getMinBitrate())) {
                                    fm.icelink.ArrayExtensions.add(list, item);
                                }
                            }
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return AudioSimulcastConfig;
            }(fm.icelink.SimulcastConfig));
            icelink.AudioSimulcastConfig = AudioSimulcastConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var VideoSimulcastConfig =  (function (_super) {
                __extends(VideoSimulcastConfig, _super);
                function VideoSimulcastConfig() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var encodingCount = __arguments[0];
                        var preferredBitrate = __arguments[1];
                        __arguments = new Array(3);
                        __arguments[0] = encodingCount;
                        __arguments[1] = preferredBitrate;
                        __arguments[2] = 0;
                        {
                            var encodingCount_3 = __arguments[0];
                            var preferredBitrate_3 = __arguments[1];
                            var bitsPerPixel = __arguments[2];
                            _this = _super.call(this, encodingCount_3, preferredBitrate_3) || this;
                            _this.fmicelinkVideoSimulcastConfigInit();
                            _this.setBitsPerPixel(bitsPerPixel);
                            _this.setDegradationPreference(fm.icelink.VideoDegradationPreference.Automatic);
                        }
                    }
                    else if (__arguments.length == 3) {
                        var encodingCount = __arguments[0];
                        var preferredBitrate = __arguments[1];
                        var bitsPerPixel = __arguments[2];
                        _this = _super.call(this, encodingCount, preferredBitrate) || this;
                        _this.fmicelinkVideoSimulcastConfigInit();
                        _this.setBitsPerPixel(bitsPerPixel);
                        _this.setDegradationPreference(fm.icelink.VideoDegradationPreference.Automatic);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                VideoSimulcastConfig.prototype.getTypeString = function () {
                    return '[fm.icelink.VideoSimulcastConfig]' + ',' + _super.prototype.getTypeString.call(this);
                };
                VideoSimulcastConfig.prototype.fmicelinkVideoSimulcastConfigInit = function () {
                    this.__bitsPerPixel = 0;
                };
                VideoSimulcastConfig.prototype.getBitsPerPixel = function () {
                    if (arguments.length == 0) {
                        return this.__bitsPerPixel;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoSimulcastConfig.prototype.getDegradationPreference = function () {
                    if (arguments.length == 0) {
                        return this._degradationPreference;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoSimulcastConfig.prototype.getEncodingConfigs = function (sourceType, sourceWidth, sourceHeight, sourceFrameRate) {
                    if (arguments.length == 4) {
                        sourceWidth = fm.icelink.Global.toInt(arguments[1]);
                        sourceHeight = fm.icelink.Global.toInt(arguments[2]);
                        var list = new Array();
                        if (_super.prototype.getDisabled.call(this)) {
                            fm.icelink.ArrayExtensions.add(list, new fm.icelink.VideoEncodingConfig());
                        }
                        else {
                            var format = new fm.icelink.vp8.Format();
                            var num = fm.icelink.MathAssistant.min(fm.icelink.MathAssistant.max(format.getMinBitrate(), fm.icelink.VideoUtility.getBitrate(_super.prototype.getPreferredBitrate.call(this), sourceWidth, sourceHeight, sourceFrameRate, this.getBitsPerPixel())), format.getMaxBitrate());
                            var degradationPreference = fm.icelink.VideoUtility.processDegradationPreference(this.getDegradationPreference(), sourceType);
                            for (var i = 0; (i < _super.prototype.getEncodingCount.call(this)); i++) {
                                var multiplier = fm.icelink.MathAssistant.pow((1 / fm.icelink.MathAssistant.pow(2, i)), fm.icelink.VideoUtility.getBitratePowerScale());
                                var config2 = new fm.icelink.VideoEncodingConfig();
                                config2.setBitrate(fm.icelink.MathAssistant.ceil((num * multiplier)));
                                var encodingConfig = config2;
                                fm.icelink.VideoUtility.updateEncodingConfig(encodingConfig, degradationPreference, multiplier, sourceFrameRate);
                                if ((encodingConfig.getBitrate() >= format.getMinBitrate())) {
                                    fm.icelink.ArrayExtensions.add(list, encodingConfig);
                                }
                            }
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoSimulcastConfig.prototype.setBitsPerPixel = function (value) {
                    if (arguments.length == 1) {
                        if ((value < 0)) {
                            throw new fm.icelink.Exception("Bits-per-pixel must be greater than or equal to zero.");
                        }
                        this.__bitsPerPixel = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoSimulcastConfig.prototype.setDegradationPreference = function (value) {
                    if (arguments.length == 1) {
                        this._degradationPreference = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return VideoSimulcastConfig;
            }(fm.icelink.SimulcastConfig));
            icelink.VideoSimulcastConfig = VideoSimulcastConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var VideoFormat =  (function (_super) {
                __extends(VideoFormat, _super);
                function VideoFormat() {
                    var _this = this;
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else if (__arguments.length == 1) {
                        var name_11 = __arguments[0];
                        _this = _super.call(this, name_11, fm.icelink.VideoFormat.getDefaultClockRate()) || this;
                    }
                    else if (__arguments.length == 2) {
                        var name_12 = __arguments[0];
                        var clockRate = __arguments[1];
                        _this = _super.call(this, name_12, clockRate) || this;
                    }
                    else if (__arguments.length == 3) {
                        var name_13 = __arguments[0];
                        var clockRate = __arguments[1];
                        var packetizationMode = __arguments[2];
                        _this = _super.call(this, name_13, clockRate, packetizationMode) || this;
                    }
                    else if (__arguments.length == 4) {
                        var name_14 = __arguments[0];
                        var clockRate = __arguments[1];
                        var profile = __arguments[2];
                        var level = __arguments[3];
                        _this = _super.call(this, name_14, clockRate, profile, level) || this;
                    }
                    else if (__arguments.length == 5) {
                        var name_15 = __arguments[0];
                        var clockRate = __arguments[1];
                        var profile = __arguments[2];
                        var level = __arguments[3];
                        var packetizationMode = __arguments[4];
                        _this = _super.call(this, name_15, clockRate, profile, level, packetizationMode) || this;
                    }
                    else if (__arguments.length == 6) {
                        var name_16 = __arguments[0];
                        var clockRate = __arguments[1];
                        var profile = __arguments[2];
                        var level = __arguments[3];
                        var packetizationMode = __arguments[4];
                        var tier = __arguments[5];
                        _this = _super.call(this, name_16, clockRate, profile, level, packetizationMode, tier) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                VideoFormat.prototype.getTypeString = function () {
                    return '[fm.icelink.VideoFormat]' + ',' + _super.prototype.getTypeString.call(this);
                };
                VideoFormat.formatNameToFourCC = function (formatName) {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 1) {
                        if (fm.icelink.HashExtensions.containsKey(fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup, formatName)) {
                            return fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[formatName];
                        }
                        return 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.fromJson = function (videoFormatJson) {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(videoFormatJson, function () {
                            return new fm.icelink.VideoFormat();
                        }, function (videoFormat, name, valueJson) {
                            var _var0 = name;
                            do {
                                if (_var0 == "name") {
                                    videoFormat.setName(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    break;
                                }
                                else if (_var0 == "clockRate") {
                                    videoFormat.setClockRate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    break;
                                }
                                else if (_var0 == "isPacketized") {
                                    videoFormat.setIsPacketized(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    break;
                                }
                                else if (_var0 == "isEncrypted") {
                                    videoFormat.setIsEncrypted(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    break;
                                }
                                else if (_var0 == "registeredPayloadType") {
                                    videoFormat.setRegisteredPayloadType(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    break;
                                }
                                else if (_var0 == "staticPayloadType") {
                                    videoFormat.setStaticPayloadType(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    break;
                                }
                                else if (_var0 == "packetizationMode") {
                                    videoFormat.setPacketizationMode(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    break;
                                }
                                else if (_var0 == "profile") {
                                    videoFormat.setProfile(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    break;
                                }
                                else if (_var0 == "level") {
                                    videoFormat.setLevel(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    break;
                                }
                                else if (_var0 == "tier") {
                                    videoFormat.setTier(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    break;
                                }
                                else if (_var0 == "levelIsStrict") {
                                    videoFormat.setLevelIsStrict(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    break;
                                }
                            } while (false);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getAbgr = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        var format = new fm.icelink.VideoFormat(fm.icelink.VideoFormat.getAbgrName());
                        format.setIsFixedBitrate(true);
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getAbgrName = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "ABGR";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getArgb = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        var format = new fm.icelink.VideoFormat(fm.icelink.VideoFormat.getArgbName());
                        format.setIsFixedBitrate(true);
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getArgbName = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "ARGB";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getBgr = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        var format = new fm.icelink.VideoFormat(fm.icelink.VideoFormat.getBgrName());
                        format.setIsFixedBitrate(true);
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getBgra = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        var format = new fm.icelink.VideoFormat(fm.icelink.VideoFormat.getBgraName());
                        format.setIsFixedBitrate(true);
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getBgraName = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "BGRA";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getBgrName = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "BGR";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getDefaultClockRate = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return 90000;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getH264 = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return new fm.icelink.h264.Format();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getH264Name = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "H264";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getH265 = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return new fm.icelink.h265.Format();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getH265Name = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "H265";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getI420 = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        var format = new fm.icelink.VideoFormat(fm.icelink.VideoFormat.getI420Name());
                        format.setIsFixedBitrate(true);
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getI420Name = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "I420";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getNv12 = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        var format = new fm.icelink.VideoFormat(fm.icelink.VideoFormat.getNv12Name());
                        format.setIsFixedBitrate(true);
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getNv12Name = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "NV12";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getNv21 = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        var format = new fm.icelink.VideoFormat(fm.icelink.VideoFormat.getNv21Name());
                        format.setIsFixedBitrate(true);
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getNv21Name = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "NV21";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getRgb = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        var format = new fm.icelink.VideoFormat(fm.icelink.VideoFormat.getRgbName());
                        format.setIsFixedBitrate(true);
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getRgba = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        var format = new fm.icelink.VideoFormat(fm.icelink.VideoFormat.getRgbaName());
                        format.setIsFixedBitrate(true);
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getRgbaName = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "RGBA";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getRgbName = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "RGB";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getVp8 = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return new fm.icelink.vp8.Format();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getVp8Name = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "VP8";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getVp9 = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return new fm.icelink.vp9.Format();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getVp9Name = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "VP9";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getYv12 = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        var format = new fm.icelink.VideoFormat(fm.icelink.VideoFormat.getYv12Name());
                        format.setIsFixedBitrate(true);
                        return format;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.getYv12Name = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 0) {
                        return "YV12";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.toFourCC = function () {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 4) {
                        var a = arguments[0];
                        var b = arguments[1];
                        var c = arguments[2];
                        var d = arguments[3];
                        return (((a | fm.icelink.BitAssistant.leftShiftInteger(b, 8)) | fm.icelink.BitAssistant.leftShiftInteger(c, 16)) | fm.icelink.BitAssistant.leftShiftInteger(d, 24));
                    }
                    else if (arguments.length == 1) {
                        var fourcc = arguments[0];
                        return fm.icelink.VideoFormat.toFourCC(fourcc.charCodeAt(0), fourcc.charCodeAt(1), fourcc.charCodeAt(2), fourcc.charCodeAt(3));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.toJson = function (videoFormat) {
                    fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(videoFormat, function (obj, jsonObject) {
                            jsonObject["name"] = fm.icelink.JsonSerializer.serializeString(videoFormat.getName());
                            jsonObject["clockRate"] = fm.icelink.JsonSerializer.serializeInteger(videoFormat.getClockRate());
                            jsonObject["isPacketized"] = fm.icelink.JsonSerializer.serializeBoolean(videoFormat.getIsPacketized());
                            jsonObject["isEncrypted"] = fm.icelink.JsonSerializer.serializeBoolean(videoFormat.getIsEncrypted());
                            jsonObject["registeredPayloadType"] = fm.icelink.JsonSerializer.serializeInteger(videoFormat.getRegisteredPayloadType());
                            jsonObject["staticPayloadType"] = fm.icelink.JsonSerializer.serializeInteger(videoFormat.getStaticPayloadType());
                            jsonObject["packetizationMode"] = fm.icelink.JsonSerializer.serializeString(videoFormat.getPacketizationMode());
                            jsonObject["profile"] = fm.icelink.JsonSerializer.serializeString(videoFormat.getProfile());
                            jsonObject["level"] = fm.icelink.JsonSerializer.serializeString(videoFormat.getLevel());
                            jsonObject["tier"] = fm.icelink.JsonSerializer.serializeString(videoFormat.getTier());
                            jsonObject["levelIsStrict"] = fm.icelink.JsonSerializer.serializeBoolean(videoFormat.getLevelIsStrict());
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.clone = function () {
                    if (arguments.length == 0) {
                        return _super.prototype.clone.call(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.createInstance = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.VideoFormat();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.fourCCToFormatName = function (fourcc) {
                    if (arguments.length == 1) {
                        fourcc = fm.icelink.Global.toInt(arguments[0]);
                        if ((fm.icelink.Global.equals(fm.icelink.VideoFormat.fm_icelink_VideoFormat__reverseFourCCLookup, null))) {
                            var dictionary = {};
                            for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup); _i < _a.length; _i++) {
                                var str = _a[_i];
                                dictionary[fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[str]] = str;
                            }
                            fm.icelink.VideoFormat.fm_icelink_VideoFormat__reverseFourCCLookup = dictionary;
                        }
                        var str2 = null;
                        var _var0 = new fm.icelink.Holder(str2);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(fm.icelink.VideoFormat.fm_icelink_VideoFormat__reverseFourCCLookup, fourcc, _var0);
                        str2 = _var0.getValue();
                        if (_var1) {
                            return str2;
                        }
                        return "";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getFourCC = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.VideoFormat.formatNameToFourCC(_super.prototype.getName.call(this));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getInfo = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.FormatInfo(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsAbgr = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getAbgrName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsArgb = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getArgbName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsBgr = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getBgrName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsBgra = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getBgraName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsCompressed = function () {
                    if (arguments.length == 0) {
                        return !this.getIsRaw();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsH264 = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getH264Name(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsH265 = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getH265Name(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsI420 = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getI420Name(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsNv12 = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getNv12Name(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsNv21 = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getNv21Name(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsRaw = function () {
                    if (arguments.length == 0) {
                        return ((this.getIsYuvType() || this.getIsRgbType()) || this.getIsRgbaType());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsRgb = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getRgbName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsRgba = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getRgbaName(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsRgbaType = function () {
                    if (arguments.length == 0) {
                        return (((this.getIsRgba() || this.getIsBgra()) || this.getIsArgb()) || this.getIsAbgr());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsRgbType = function () {
                    if (arguments.length == 0) {
                        return (this.getIsRgb() || this.getIsBgr());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsVp8 = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getVp8Name(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsVp9 = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getVp9Name(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsYuvType = function () {
                    if (arguments.length == 0) {
                        return (((this.getIsI420() || this.getIsYv12()) || this.getIsNv12()) || this.getIsNv21());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getIsYv12 = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.isEqual(_super.prototype.getName.call(this), fm.icelink.VideoFormat.getYv12Name(), fm.icelink.StringComparison.OrdinalIgnoreCase);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getMaxLevel = function (level1, level2) {
                    if (arguments.length == 2) {
                        if (this.getIsH264()) {
                            var hexBytes = fm.icelink.BitAssistant.getHexBytes(level1);
                            var buffer2 = fm.icelink.BitAssistant.getHexBytes(level2);
                            if ((hexBytes[0] > buffer2[0])) {
                                return level1;
                            }
                            return level2;
                        }
                        if ((this.getIsH265() && !(fm.icelink.StringExtensions.isNullOrEmpty(level1) || fm.icelink.StringExtensions.isNullOrEmpty(level2)))) {
                            var num = fm.icelink.ParseAssistant.parseIntegerValue(level1);
                            var num2 = fm.icelink.ParseAssistant.parseIntegerValue(level2);
                            return ((num > num2) ? level1 : level2);
                        }
                        return _super.prototype.getMaxLevel.call(this, level1, level2);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getMinLevel = function (level1, level2) {
                    if (arguments.length == 2) {
                        if (this.getIsH264()) {
                            var hexBytes = fm.icelink.BitAssistant.getHexBytes(level1);
                            var buffer2 = fm.icelink.BitAssistant.getHexBytes(level2);
                            if ((hexBytes[0] > buffer2[0])) {
                                return level2;
                            }
                            return level1;
                        }
                        if ((this.getIsH265() && !(fm.icelink.StringExtensions.isNullOrEmpty(level1) || fm.icelink.StringExtensions.isNullOrEmpty(level2)))) {
                            var num = fm.icelink.ParseAssistant.parseIntegerValue(level1);
                            var num2 = fm.icelink.ParseAssistant.parseIntegerValue(level2);
                            return ((num > num2) ? level2 : level1);
                        }
                        return _super.prototype.getMinLevel.call(this, level1, level2);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.getParameters = function () {
                    if (arguments.length == 0) {
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.isLevelCompatible = function (level) {
                    if (arguments.length == 1) {
                        if (this.getIsH264()) {
                            if (((fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(_super.prototype.getLevel.call(this)), 2)) && (fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(level), 2)))) {
                                var hexBytes = fm.icelink.BitAssistant.getHexBytes(_super.prototype.getLevel.call(this));
                                var buffer2 = fm.icelink.BitAssistant.getHexBytes(level);
                                return (hexBytes[0] <= buffer2[0]);
                            }
                        }
                        else {
                            if ((this.getIsH265() && !(fm.icelink.StringExtensions.isNullOrEmpty(_super.prototype.getLevel.call(this)) || fm.icelink.StringExtensions.isNullOrEmpty(level)))) {
                                var num = fm.icelink.ParseAssistant.parseIntegerValue(_super.prototype.getLevel.call(this));
                                var num2 = fm.icelink.ParseAssistant.parseIntegerValue(level);
                                return (num <= num2);
                            }
                        }
                        return _super.prototype.isLevelCompatible.call(this, level);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.isProfileCompatible = function (profile) {
                    if (arguments.length == 1) {
                        if ((this.getIsH264() && ((fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(_super.prototype.getProfile.call(this)), 4)) && (fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(profile), 4))))) {
                            var hexBytes = fm.icelink.BitAssistant.getHexBytes(_super.prototype.getProfile.call(this));
                            var buffer2 = fm.icelink.BitAssistant.getHexBytes(profile);
                            return (hexBytes[0] <= buffer2[0]);
                        }
                        return _super.prototype.isProfileCompatible.call(this, profile);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.setFourCC = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        _super.prototype.setName.call(this, this.fourCCToFormatName(value));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.VideoFormat.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.prototype.updateProfileToCompatible = function (format) {
                    if (arguments.length == 1) {
                        if ((this.getIsH264() && (!fm.icelink.Global.equals(format.getProfile(), null)))) {
                            if ((((fm.icelink.Global.equals(_super.prototype.getProfile.call(this), null)) || (!fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(_super.prototype.getProfile.call(this)), 4))) || (!fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(format.getProfile()), 4)))) {
                                _super.prototype.setProfile.call(this, format.getProfile());
                            }
                            else {
                                var hexBytes = fm.icelink.BitAssistant.getHexBytes(_super.prototype.getProfile.call(this));
                                var buffer2 = fm.icelink.BitAssistant.getHexBytes(format.getProfile());
                                _super.prototype.setProfile.call(this, fm.icelink.BitAssistant.getHexString(new Uint8Array([buffer2[0], (hexBytes[1] | buffer2[1])])));
                            }
                        }
                        _super.prototype.updateProfileToCompatible.call(this, format);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoFormat.fmicelinkVideoFormatInitialize = function () {
                    if (!fm.icelink.VideoFormat.__fmicelinkVideoFormatInitialized && !fm.icelink.VideoFormat.__fmicelinkVideoFormatInitializing) {
                        fm.icelink.VideoFormat.__fmicelinkVideoFormatInitializing = true;
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup = {};
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__reverseFourCCLookup = null;
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[fm.icelink.VideoFormat.getRgbName()] = fm.icelink.VideoFormat.toFourCC(114, 97, 119, 32);
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[fm.icelink.VideoFormat.getBgrName()] = fm.icelink.VideoFormat.toFourCC(50, 52, 66, 71);
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[fm.icelink.VideoFormat.getNv12Name()] = fm.icelink.VideoFormat.toFourCC(78, 86, 49, 50);
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[fm.icelink.VideoFormat.getNv21Name()] = fm.icelink.VideoFormat.toFourCC(78, 86, 50, 49);
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[fm.icelink.VideoFormat.getI420Name()] = fm.icelink.VideoFormat.toFourCC(73, 52, 50, 48);
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[fm.icelink.VideoFormat.getYv12Name()] = fm.icelink.VideoFormat.toFourCC(89, 86, 49, 50);
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[fm.icelink.VideoFormat.getArgbName()] = fm.icelink.VideoFormat.toFourCC(65, 82, 71, 66);
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[fm.icelink.VideoFormat.getAbgrName()] = fm.icelink.VideoFormat.toFourCC(65, 66, 71, 82);
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[fm.icelink.VideoFormat.getRgbaName()] = fm.icelink.VideoFormat.toFourCC(82, 71, 66, 65);
                        fm.icelink.VideoFormat.fm_icelink_VideoFormat__fourCCLookup[fm.icelink.VideoFormat.getBgraName()] = fm.icelink.VideoFormat.toFourCC(66, 71, 82, 65);
                        fm.icelink.VideoFormat.__fmicelinkVideoFormatInitialized = true;
                        fm.icelink.VideoFormat.__fmicelinkVideoFormatInitializing = false;
                    }
                };
                VideoFormat.__fmicelinkVideoFormatInitialized = false;
                VideoFormat.__fmicelinkVideoFormatInitializing = false;
                return VideoFormat;
            }(fm.icelink.MediaFormat));
            icelink.VideoFormat = VideoFormat;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (h265) {
                var Format =  (function (_super) {
                    __extends(Format, _super);
                    function Format() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this, fm.icelink.VideoFormat.getH265Name()) || this;
                        }
                        else if (__arguments.length == 1) {
                            var clockRate = __arguments[0];
                            _this = _super.call(this, fm.icelink.VideoFormat.getH265Name(), clockRate) || this;
                        }
                        else if (__arguments.length == 4) {
                            var clockRate = __arguments[0];
                            var profile = __arguments[1];
                            var level = __arguments[2];
                            var tier = __arguments[3];
                            _this = _super.call(this, fm.icelink.VideoFormat.getH265Name(), clockRate, fm.icelink.NumberExtensions.toString(profile), fm.icelink.NumberExtensions.toString(level), null, fm.icelink.NumberExtensions.toString(tier)) || this;
                        }
                        else if (__arguments.length == 3) {
                            var profile = __arguments[0];
                            var level = __arguments[1];
                            var tier = __arguments[2];
                            _this = _super.call(this, fm.icelink.VideoFormat.getH265Name(), 90000, fm.icelink.NumberExtensions.toString(profile), fm.icelink.NumberExtensions.toString(level), null, fm.icelink.NumberExtensions.toString(tier)) || this;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Format.prototype.getTypeString = function () {
                        return '[fm.icelink.h265.Format]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    return Format;
                }(fm.icelink.VideoFormat));
                h265.Format = Format;
            })(icelink.h265 || (icelink.h265 = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (g722) {
                var Format =  (function (_super) {
                    __extends(Format, _super);
                    function Format() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            __arguments = new Array(1);
                            __arguments[0] = fm.icelink.g722.Format.getDefaultConfig();
                            {
                                var config = __arguments[0];
                                __arguments = new Array(2);
                                __arguments[0] = config.getClockRate();
                                __arguments[1] = config.getChannelCount();
                                {
                                    var clockRate = __arguments[0];
                                    var channelCount = __arguments[1];
                                    _this = _super.call(this, fm.icelink.AudioFormat.getG722Name(), clockRate, channelCount) || this;
                                    _super.prototype.setIsFixedBitrate.call(_this, true);
                                    _super.prototype.setStaticPayloadType.call(_this, 9);
                                }
                            }
                        }
                        else if (__arguments.length == 2) {
                            var clockRate = __arguments[0];
                            var channelCount = __arguments[1];
                            _this = _super.call(this, fm.icelink.AudioFormat.getG722Name(), clockRate, channelCount) || this;
                            _super.prototype.setIsFixedBitrate.call(_this, true);
                            _super.prototype.setStaticPayloadType.call(_this, 9);
                        }
                        else if (__arguments.length == 1) {
                            var config = __arguments[0];
                            __arguments = new Array(2);
                            __arguments[0] = config.getClockRate();
                            __arguments[1] = config.getChannelCount();
                            {
                                var clockRate = __arguments[0];
                                var channelCount = __arguments[1];
                                _this = _super.call(this, fm.icelink.AudioFormat.getG722Name(), clockRate, channelCount) || this;
                                _super.prototype.setIsFixedBitrate.call(_this, true);
                                _super.prototype.setStaticPayloadType.call(_this, 9);
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Format.prototype.getTypeString = function () {
                        return '[fm.icelink.g722.Format]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    Format.getDefaultChannelCount = function () {
                        if (arguments.length == 0) {
                            return 1;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.getDefaultClockRate = function () {
                        if (arguments.length == 0) {
                            return 16000;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.getDefaultConfig = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.AudioConfig(fm.icelink.g722.Format.getDefaultClockRate(), fm.icelink.g722.Format.getDefaultChannelCount());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.createInstance = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.g722.Format();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getFixedBitrate = function () {
                        if (arguments.length == 0) {
                            return 64;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMaxBitrate = function () {
                        if (arguments.length == 0) {
                            return this.getFixedBitrate();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMinBitrate = function () {
                        if (arguments.length == 0) {
                            return this.getFixedBitrate();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Format;
                }(fm.icelink.AudioFormat));
                g722.Format = Format;
            })(icelink.g722 || (icelink.g722 = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SessionDescriptionManagerBase =  (function () {
                function SessionDescriptionManagerBase() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.__streamIndex = new Array();
                        this.__audioStreamIndex = new Array();
                        this.__videoStreamIndex = new Array();
                        this.__dataStreamIndex = new Array();
                        this.__streamMatcher = new fm.icelink.SessionDescriptionStreamMatcher(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SessionDescriptionManagerBase.prototype.getTypeString = function () {
                    return '[fm.icelink.SessionDescriptionManagerBase]';
                };
                SessionDescriptionManagerBase.updateTrickleIcePolicy = function (message, policy) {
                    if (arguments.length == 2) {
                        if (((fm.icelink.Global.equals(policy, fm.icelink.TrickleIcePolicy.FullTrickle)) || (fm.icelink.Global.equals(policy, fm.icelink.TrickleIcePolicy.HalfTrickle)))) {
                            message.setSupportsTrickleIce(true);
                        }
                        else {
                            message.setSupportsTrickleIce(false);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.addMediaDescriptions = function (msg, descriptions) {
                    if (arguments.length == 2) {
                        var length_32 = descriptions.length;
                        var descriptionArray = new Array(length_32);
                        for (var i = 0; (i < length_32); i++) {
                            var offererStreamIndexFor = this.__streamMatcher.getOffererStreamIndexFor(i);
                            descriptionArray[offererStreamIndexFor] = descriptions[i];
                        }
                        for (var _i = 0, descriptionArray_1 = descriptionArray; _i < descriptionArray_1.length; _i++) {
                            var description = descriptionArray_1[_i];
                            msg.addMediaDescription(description);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.addStream = function (stream) {
                    if (arguments.length == 1) {
                        fm.icelink.HashExtensions.add(this.getStreams(), stream.getId(), stream);
                        this.addToIndex(stream);
                        this.resetStreamMatcher();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.addToIndex = function (stream) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__streamIndex, stream);
                        if ((fm.icelink.Global.equals(stream.getType(), fm.icelink.StreamType.Audio))) {
                            fm.icelink.ArrayExtensions.add(this.__audioStreamIndex, stream);
                        }
                        else {
                            if ((fm.icelink.Global.equals(stream.getType(), fm.icelink.StreamType.Video))) {
                                fm.icelink.ArrayExtensions.add(this.__videoStreamIndex, stream);
                            }
                            else {
                                if ((!fm.icelink.Global.equals(stream.getType(), fm.icelink.StreamType.Application))) {
                                    throw new fm.icelink.Exception("Unsupported stream type.");
                                }
                                fm.icelink.ArrayExtensions.add(this.__dataStreamIndex, stream);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.getOffererStreamIndexFor = function (answererStreamIndex) {
                    if (arguments.length == 1) {
                        answererStreamIndex = fm.icelink.Global.toInt(arguments[0]);
                        return this.__streamMatcher.getOffererStreamIndexFor(answererStreamIndex);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.matchAndProcessDescriptionPerType = function (streams, description, isLocalDescription, streamMatcher, processSdpMediaDescriptionForStreamHandler, processSdpMediaDescriptionInternal) {
                    if (arguments.length == 6) {
                        if ((fm.icelink.Global.equals(processSdpMediaDescriptionForStreamHandler, null))) {
                            throw new fm.icelink.Exception("ProcessSdpMediaDescriptionForStreamHandler is not set.");
                        }
                        var indexInType = 0;
                        var sdpMessage = description.getSdpMessage();
                        var mediaDescriptions = sdpMessage.getMediaDescriptions();
                        for (var _i = 0, streams_1 = streams; _i < streams_1.length; _i++) {
                            var local = streams_1[_i];
                            var type = local.getType();
                            var offererStreamMediaIndexForStream = streamMatcher.getOffererStreamMediaIndexForStream(type, indexInType);
                            if ((fm.icelink.Global.equals(offererStreamMediaIndexForStream, -1))) {
                                return new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, new fm.icelink.Exception(fm.icelink.StringExtensions.format("SDP offer did not contain stream of type {0} or stream of this type is not supported.", new fm.icelink.StreamTypeWrapper(local.getType()).toString())));
                            }
                            var internalStreamMediaIndexForStream = streamMatcher.getInternalStreamMediaIndexForStream(type, indexInType);
                            streamMatcher.setMatchingIndexes(internalStreamMediaIndexForStream, offererStreamMediaIndexForStream);
                            var description2 = mediaDescriptions[offererStreamMediaIndexForStream];
                            var error = processSdpMediaDescriptionForStreamHandler(local, description2, offererStreamMediaIndexForStream, isLocalDescription, description.getRenegotiation());
                            if ((!fm.icelink.Global.equals(error, null))) {
                                return error;
                            }
                            if (processSdpMediaDescriptionInternal) {
                                error = local.processSdpMediaDescription(sdpMessage, description2, offererStreamMediaIndexForStream, isLocalDescription, description.getIsOffer(), description.getRenegotiation());
                                if ((!fm.icelink.Global.equals(error, null))) {
                                    return error;
                                }
                            }
                            indexInType++;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.parseSessionDescriptionForStreamChangesAndUpdateMids = function (newRemoteDescription, existingAudioStreams, existingVideoStreams, existingDataStreams) {
                    if (arguments.length == 4) {
                        var renegotiation = newRemoteDescription.getRenegotiation();
                        var mediaDescriptions = newRemoteDescription.getSdpMessage().getMediaDescriptions();
                        var streamsByMid = {};
                        var index = -1;
                        var num2 = -1;
                        var num3 = -1;
                        for (var _i = 0, existingAudioStreams_1 = existingAudioStreams; _i < existingAudioStreams_1.length; _i++) {
                            var local = existingAudioStreams_1[_i];
                            if (!fm.icelink.StringExtensions.isNullOrEmpty(local.getMediaStreamIdentification())) {
                                streamsByMid[local.getMediaStreamIdentification()] = local;
                            }
                        }
                        for (var _a = 0, existingVideoStreams_1 = existingVideoStreams; _a < existingVideoStreams_1.length; _a++) {
                            var local = existingVideoStreams_1[_a];
                            if (!fm.icelink.StringExtensions.isNullOrEmpty(local.getMediaStreamIdentification())) {
                                streamsByMid[local.getMediaStreamIdentification()] = local;
                            }
                        }
                        for (var _b = 0, existingDataStreams_1 = existingDataStreams; _b < existingDataStreams_1.length; _b++) {
                            var local = existingDataStreams_1[_b];
                            if (!fm.icelink.StringExtensions.isNullOrEmpty(local.getMediaStreamIdentification())) {
                                streamsByMid[local.getMediaStreamIdentification()] = local;
                            }
                        }
                        var foundStreams = new Array();
                        var newStreams = new Array();
                        for (var _c = 0, mediaDescriptions_1 = mediaDescriptions; _c < mediaDescriptions_1.length; _c++) {
                            var description = mediaDescriptions_1[_c];
                            var mediaType = description.getMedia().getMediaType();
                            var mediaStreamIdentifierAttribute = description.getMediaStreamIdentifierAttribute();
                            var mid = fm.icelink.StringExtensions.empty;
                            if ((!fm.icelink.Global.equals(mediaStreamIdentifierAttribute, null))) {
                                mid = mediaStreamIdentifierAttribute.getIdentificationTag();
                            }
                            mediaType = fm.icelink.StringExtensions.trim(mediaType);
                            var _var0 = mediaType;
                            do {
                                if (_var0 == "audio") {
                                    index++;
                                    if ((fm.icelink.Global.equals(mid, fm.icelink.StringExtensions.empty))) {
                                        mid = fm.icelink.StringExtensions.concat("audio", fm.icelink.NumberExtensions.toString(index));
                                    }
                                    if (renegotiation) {
                                        this.processMSection(foundStreams, newStreams, streamsByMid, description, mid);
                                    }
                                    else {
                                        existingAudioStreams[index].setMediaStreamIdentification(mid);
                                    }
                                    break;
                                }
                                else if (_var0 == "video") {
                                    num3++;
                                    if ((fm.icelink.Global.equals(mid, fm.icelink.StringExtensions.empty))) {
                                        mid = fm.icelink.StringExtensions.concat("video", fm.icelink.NumberExtensions.toString(num3));
                                    }
                                    if (renegotiation) {
                                        this.processMSection(foundStreams, newStreams, streamsByMid, description, mid);
                                    }
                                    else {
                                        existingVideoStreams[num3].setMediaStreamIdentification(mid);
                                    }
                                    break;
                                }
                                else {
                                    if (!(fm.icelink.Global.equals(mediaType, "application"))) {
                                        throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Unsupported stream type {0}", mediaType));
                                    }
                                    num2++;
                                    if ((fm.icelink.Global.equals(mid, fm.icelink.StringExtensions.empty))) {
                                        mid = fm.icelink.StringExtensions.concat("application", fm.icelink.NumberExtensions.toString(num2));
                                    }
                                    if (renegotiation) {
                                        this.processMSection(foundStreams, newStreams, streamsByMid, description, mid);
                                    }
                                    else {
                                        existingDataStreams[num2].setMediaStreamIdentification(mid);
                                    }
                                    break;
                                }
                            } while (false);
                        }
                        for (var _d = 0, foundStreams_1 = foundStreams; _d < foundStreams_1.length; _d++) {
                            var local = foundStreams_1[_d];
                            fm.icelink.HashExtensions.remove(streamsByMid, local.getMediaStreamIdentification());
                        }
                        var list3 = new Array();
                        for (var _e = 0, _f = fm.icelink.HashExtensions.getValues(streamsByMid); _e < _f.length; _e++) {
                            var local2 = _f[_e];
                            fm.icelink.ArrayExtensions.add(list3, local2);
                        }
                        return new fm.icelink.Pair(fm.icelink.ArrayExtensions.toArray(newStreams), fm.icelink.ArrayExtensions.toArray(list3));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.populateStreamTypeIndexes = function (descriptions, streams, streamMatcher) {
                    if (arguments.length == 3) {
                        streamMatcher.reset(fm.icelink.ArrayExtensions.getCount(streams));
                        var error = streamMatcher.populateInternalStreamTypeIndexes(streams);
                        if ((fm.icelink.Global.equals(error, null))) {
                            error = streamMatcher.populateOffererStreamTypeIndexes(descriptions);
                        }
                        return error;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.processDescription = function (description, isLocalDescription) {
                    if (arguments.length == 2) {
                        var error = this.validateBaseDescription(description, isLocalDescription);
                        if ((!fm.icelink.Global.equals(error, null))) {
                            return error;
                        }
                        var mediaDescriptions = description.getSdpMessage().getMediaDescriptions();
                        if (description.getIsOffer()) {
                            error = this.populateStreamTypeIndexes(mediaDescriptions, this.__streamIndex, this.__streamMatcher);
                            if ((!fm.icelink.Global.equals(error, null))) {
                                return error;
                            }
                        }
                        error = this.matchAndProcessDescriptionPerType(this.__audioStreamIndex, description, isLocalDescription, this.__streamMatcher, this.processSdpMediaDescriptionForStream.bind(this), true);
                        if ((!fm.icelink.Global.equals(error, null))) {
                            return error;
                        }
                        error = this.matchAndProcessDescriptionPerType(this.__videoStreamIndex, description, isLocalDescription, this.__streamMatcher, this.processSdpMediaDescriptionForStream.bind(this), true);
                        if ((!fm.icelink.Global.equals(error, null))) {
                            return error;
                        }
                        error = this.matchAndProcessDescriptionPerType(this.__dataStreamIndex, description, isLocalDescription, this.__streamMatcher, this.processSdpMediaDescriptionForStream.bind(this), true);
                        if ((!fm.icelink.Global.equals(error, null))) {
                            return error;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.processMSection = function (foundStreams, newStreams, streamsByMid, mSection, mid) {
                    if (arguments.length == 5) {
                        var local = null;
                        var _var0 = new fm.icelink.Holder(local);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(streamsByMid, mid, _var0);
                        local = _var0.getValue();
                        if (_var1) {
                            fm.icelink.ArrayExtensions.add(foundStreams, local);
                        }
                        else {
                            fm.icelink.ArrayExtensions.add(newStreams, new fm.icelink.StreamDescription(mSection));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.removeFromIndex = function (stream) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__streamIndex, stream);
                        if ((fm.icelink.Global.equals(stream.getType(), fm.icelink.StreamType.Audio))) {
                            fm.icelink.ArrayExtensions.remove(this.__audioStreamIndex, stream);
                        }
                        else {
                            if ((fm.icelink.Global.equals(stream.getType(), fm.icelink.StreamType.Video))) {
                                fm.icelink.ArrayExtensions.remove(this.__videoStreamIndex, stream);
                            }
                            else {
                                if ((!fm.icelink.Global.equals(stream.getType(), fm.icelink.StreamType.Application))) {
                                    throw new fm.icelink.Exception("Unsupported stream type.");
                                }
                                fm.icelink.ArrayExtensions.remove(this.__dataStreamIndex, stream);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.removeStream = function (stream) {
                    if (arguments.length == 1) {
                        if (fm.icelink.HashExtensions.remove(this.getStreams(), stream.getId())) {
                            this.removeFromIndex(stream);
                            this.resetStreamMatcher();
                            return true;
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.resetStreamMatcher = function () {
                    if (arguments.length == 0) {
                        if ((!fm.icelink.Global.equals(this.__streamMatcher, null))) {
                            this.__streamMatcher.reset(fm.icelink.HashExtensions.getCount(this.getStreams()));
                        }
                        else {
                            this.__streamMatcher = new fm.icelink.SessionDescriptionStreamMatcher(fm.icelink.HashExtensions.getCount(this.getStreams()));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.updateLocalAudioDescription = function (mediaDescription, audioStream) {
                    if (arguments.length == 2) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.updateLocalDescription = function (localDescription) {
                    if (arguments.length == 1) {
                        var num = void 0;
                        var preferredCodecs = void 0;
                        var username = localDescription.getSdpMessage().getOrigin().getUsername();
                        username = ((fm.icelink.Global.equals(fm.icelink.StringExtensions.trim(username), "-")) ? fm.icelink.StringExtensions.concat("IceLink-", fm.icelink.Build.getVersion()) : fm.icelink.StringExtensions.concat(username, "_IceLink-", fm.icelink.Build.getVersion()));
                        localDescription.getSdpMessage().getOrigin().setUsername(username);
                        var audioStreams = this.getAudioStreams();
                        if ((!fm.icelink.Global.equals(audioStreams, null))) {
                            for (num = 0; (num < audioStreams.length); num++) {
                                var audioStream = audioStreams[num];
                                if (audioStream.getOpusDisabled()) {
                                    localDescription.getSdpMessage().getAudioDescriptions()[num].purgeFormat(fm.icelink.AudioFormat.getOpusName());
                                }
                                if (audioStream.getG722Disabled()) {
                                    localDescription.getSdpMessage().getAudioDescriptions()[num].purgeFormat(fm.icelink.AudioFormat.getG722Name());
                                }
                                if (audioStream.getPcmuDisabled()) {
                                    localDescription.getSdpMessage().getAudioDescriptions()[num].purgeFormat(fm.icelink.AudioFormat.getPcmuName());
                                }
                                if (audioStream.getPcmaDisabled()) {
                                    localDescription.getSdpMessage().getAudioDescriptions()[num].purgeFormat(fm.icelink.AudioFormat.getPcmaName());
                                }
                                preferredCodecs = audioStream.getPreferredCodecs();
                                if ((!fm.icelink.Global.equals(preferredCodecs, null))) {
                                    localDescription.getSdpMessage().getAudioDescriptions()[num].orderFormats(preferredCodecs);
                                }
                                this.updateLocalAudioDescription(localDescription.getSdpMessage().getAudioDescriptions()[num], audioStream);
                            }
                        }
                        var videoStreams = this.getVideoStreams();
                        if ((!fm.icelink.Global.equals(videoStreams, null))) {
                            for (num = 0; (num < videoStreams.length); num++) {
                                var videoStream = videoStreams[num];
                                if (videoStream.getVp8Disabled()) {
                                    localDescription.getSdpMessage().getVideoDescriptions()[num].purgeFormat(fm.icelink.VideoFormat.getVp8Name());
                                }
                                if (videoStream.getVp9Disabled()) {
                                    localDescription.getSdpMessage().getVideoDescriptions()[num].purgeFormat(fm.icelink.VideoFormat.getVp9Name());
                                }
                                if (videoStream.getH264Disabled()) {
                                    localDescription.getSdpMessage().getVideoDescriptions()[num].purgeFormat(fm.icelink.VideoFormat.getH264Name());
                                }
                                if (videoStream.getH265Disabled()) {
                                    localDescription.getSdpMessage().getVideoDescriptions()[num].purgeFormat(fm.icelink.VideoFormat.getH265Name());
                                }
                                preferredCodecs = videoStream.getPreferredCodecs();
                                if ((!fm.icelink.Global.equals(preferredCodecs, null))) {
                                    localDescription.getSdpMessage().getVideoDescriptions()[num].orderFormats(preferredCodecs);
                                }
                                this.updateLocalVideoDescription(localDescription.getSdpMessage().getVideoDescriptions()[num], videoStream);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.updateLocalVideoDescription = function (mediaDescription, videoStream) {
                    if (arguments.length == 2) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionManagerBase.prototype.validateBaseDescription = function (description, isLocalDescription) {
                    if (arguments.length == 2) {
                        var sdpMessage = description.getSdpMessage();
                        if ((fm.icelink.Global.equals(sdpMessage, null))) {
                            return new fm.icelink.Error(fm.icelink.ErrorCode.LocalDescriptionError, new fm.icelink.Exception(fm.icelink.StringExtensions.format("{0} session description is empty.", (isLocalDescription ? "Local" : "Remote"))));
                        }
                        var streams = this.getStreams();
                        if (((fm.icelink.Global.equals(streams, null)) || (fm.icelink.Global.equals(fm.icelink.HashExtensions.getCount(streams), 0)))) {
                            return new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, new fm.icelink.Exception("At least one local stream is required for the connection to conduct signalling exchange."));
                        }
                        var mediaDescriptions = sdpMessage.getMediaDescriptions();
                        if (((fm.icelink.Global.equals(mediaDescriptions, null)) || (fm.icelink.Global.equals(mediaDescriptions.length, 0)))) {
                            return new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, new fm.icelink.Exception("At least one media description is required for the connection to conduct signalling exchange."));
                        }
                        var count = fm.icelink.HashExtensions.getCount(streams);
                        var length_33 = mediaDescriptions.length;
                        if ((!fm.icelink.Global.equals(count, length_33))) {
                            return new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, new fm.icelink.Exception(fm.icelink.StringExtensions.format("There is a mismatch between the number of local streams ({0}) and the number of media descriptions ({1}).", fm.icelink.NumberExtensions.toString(count), fm.icelink.NumberExtensions.toString(length_33))));
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SessionDescriptionManagerBase;
            }());
            icelink.SessionDescriptionManagerBase = SessionDescriptionManagerBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CcmLrrPolicyWrapper =  (function () {
                function CcmLrrPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_21 = __arguments[0];
                        this._value = value_21;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CcmLrrPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.CcmLrrPolicyWrapper]';
                };
                CcmLrrPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.CcmLrrPolicy.Disabled)
                            return 'Disabled';
                        if (this._value == fm.icelink.CcmLrrPolicy.Negotiated)
                            return 'Negotiated';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CcmLrrPolicyWrapper;
            }());
            icelink.CcmLrrPolicyWrapper = CcmLrrPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataMessage =  (function () {
                function DataMessage() {
                    fm.icelink.DataMessage.fmicelinkDataMessageInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataBuffer]'))) {
                        var messageBytes = __arguments[0];
                        this.__elements = new Array();
                        this.setDataBytes(messageBytes);
                    }
                    else if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var messageString = __arguments[0];
                        this.__elements = new Array();
                        this.setDataString(messageString);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                DataMessage.prototype.getTypeString = function () {
                    return '[fm.icelink.DataMessage]';
                };
                DataMessage.parseBytes = function (buffer) {
                    fm.icelink.DataMessage.fmicelinkDataMessageInitialize();
                    if (arguments.length == 1) {
                        var num = buffer.read4(0, 0);
                        if ((!fm.icelink.Global.equals(num, 1))) {
                            fm.icelink.DataMessage.fm_icelink_DataMessage___log.error(fm.icelink.StringExtensions.format("Cannot parse Liveswitch Data Message of version {0}", fm.icelink.NumberExtensions.toString(num)));
                            return null;
                        }
                        var num2 = buffer.read4(0, 4);
                        var offset = buffer.read16(2);
                        var num4 = 0;
                        var list = null;
                        if ((offset > 0)) {
                            list = new Array();
                            var offsetPlus = -1;
                            var item = null;
                            while (((num4 + 4) < offset)) {
                                var _var0 = new fm.icelink.Holder(offsetPlus);
                                var _var1 = fm.icelink.datamessageheader.Element.parseBytes(buffer, (4 + num4), _var0);
                                offsetPlus = _var0.getValue();
                                item = _var1;
                                num4 = (num4 + offsetPlus);
                                if (((num4 + 4) > offset)) {
                                    var num6 = (num4 + 4);
                                    fm.icelink.DataMessage.fm_icelink_DataMessage___log.error(fm.icelink.StringExtensions.format("Could not parse Data Message. Header length declared to have {0} bytes, while {1} bytes of header length were read.", fm.icelink.NumberExtensions.toString(offset), fm.icelink.NumberExtensions.toString(num6)));
                                    return null;
                                }
                                if ((!fm.icelink.Global.equals(item, null))) {
                                    fm.icelink.ArrayExtensions.add(list, item);
                                }
                            }
                        }
                        var message = null;
                        var _var2 = num2;
                        do {
                            if (_var2 == 0) {
                                message = new fm.icelink.DataMessage(buffer.subset(offset));
                                break;
                            }
                            else if (_var2 == 1) {
                                message = new fm.icelink.DataMessage(buffer.readUtf8String(offset));
                                break;
                            }
                            else {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Received a data message with an unknown payload {0}. Will not parse.", fm.icelink.NumberExtensions.toString(num2)));
                                return null;
                            }
                        } while (false);
                        if ((!fm.icelink.Global.equals(list, null))) {
                            message.setElements(fm.icelink.ArrayExtensions.toArray(list));
                        }
                        return message;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.getBytes = function () {
                    if (arguments.length == 0) {
                        var element = void 0;
                        var size = 4;
                        var bytes = null;
                        var num2 = 4;
                        if ((!fm.icelink.Global.equals(this.getDataBytes(), null))) {
                            size = (size + this.getDataBytes().getLength());
                        }
                        else {
                            if ((!fm.icelink.Global.equals(this.getDataString(), null))) {
                                bytes = fm.icelink.Utf8.encode(this.getDataString());
                                size = (size + bytes.length);
                            }
                        }
                        var index = 0;
                        while ((index < this.getElements().length)) {
                            element = this.getElements()[index];
                            size = (size + element.getLength());
                            num2 = (num2 + element.getLength());
                            index++;
                        }
                        var buffer2 = null;
                        if (fm.icelink.DataBufferPool.getIsSupported()) {
                            buffer2 = fm.icelink.DataMessage.fm_icelink_DataMessage___dataBufferPool.take(size);
                        }
                        else {
                            buffer2 = fm.icelink.DataBuffer.allocate(size);
                        }
                        buffer2.write4(1, 0, 0);
                        if ((!fm.icelink.Global.equals(this.getDataString(), null))) {
                            buffer2.write4(1, 0, 4);
                        }
                        else {
                            if ((!fm.icelink.Global.equals(this.getDataBytes(), null))) {
                                buffer2.write4(0, 0, 4);
                            }
                        }
                        buffer2.write8(0, 1);
                        buffer2.write16(num2, 2);
                        var offset = 4;
                        for (index = 0; (index < this.getElements().length); index++) {
                            element = this.getElements()[index];
                            var length_34 = element.getLength();
                            buffer2.write(element.getBytes(), offset);
                            offset = (offset + length_34);
                        }
                        if ((!fm.icelink.Global.equals(bytes, null))) {
                            buffer2.writeBytes(bytes, offset);
                            return buffer2;
                        }
                        if ((!fm.icelink.Global.equals(this.getDataBytes(), null))) {
                            buffer2.write(this.getDataBytes(), offset);
                        }
                        return buffer2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.getDataBytes = function () {
                    if (arguments.length == 0) {
                        return this._dataBytes;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.getDataString = function () {
                    if (arguments.length == 0) {
                        return this._dataString;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.getElements = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ArrayExtensions.toArray(this.__elements);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.getNumberOfRetransmissions = function () {
                    if (arguments.length == 0) {
                        for (var _i = 0, _a = this.getElements(); _i < _a.length; _i++) {
                            var element = _a[_i];
                            if ((fm.icelink.Global.equals(element.getType(), fm.icelink.datamessageheader.Type.getDeliveryAttempts()))) {
                                return element.getDeliveryAttempts();
                            }
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.getRemoteConnectionId = function () {
                    if (arguments.length == 0) {
                        for (var _i = 0, _a = this.getElements(); _i < _a.length; _i++) {
                            var element = _a[_i];
                            if ((fm.icelink.Global.equals(element.getType(), fm.icelink.datamessageheader.Type.getConnectionId()))) {
                                return element.getConnectionId();
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.getTimeToLive = function () {
                    if (arguments.length == 0) {
                        for (var _i = 0, _a = this.getElements(); _i < _a.length; _i++) {
                            var element = _a[_i];
                            if ((fm.icelink.Global.equals(element.getType(), fm.icelink.datamessageheader.Type.getTimeToLive()))) {
                                return element.getTimeToLive();
                            }
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.getVersion = function () {
                    if (arguments.length == 0) {
                        return 1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.setDataBytes = function (value) {
                    if (arguments.length == 1) {
                        this._dataBytes = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.setDataString = function (value) {
                    if (arguments.length == 1) {
                        this._dataString = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.setElements = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(value, null))) {
                            fm.icelink.ArrayExtensions.addRange(this.__elements, value);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.setNumberOfRetransmissions = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        for (var _i = 0, _a = this.getElements(); _i < _a.length; _i++) {
                            var element = _a[_i];
                            if ((fm.icelink.Global.equals(element.getType(), fm.icelink.datamessageheader.Type.getDeliveryAttempts()))) {
                                fm.icelink.ArrayExtensions.remove(this.__elements, element);
                            }
                        }
                        fm.icelink.ArrayExtensions.add(this.__elements, new fm.icelink.datamessageheader.DeliveryAttemptsElement(value));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.setRemoteConnectionId = function (value) {
                    if (arguments.length == 1) {
                        for (var _i = 0, _a = this.getElements(); _i < _a.length; _i++) {
                            var element = _a[_i];
                            if ((fm.icelink.Global.equals(element.getType(), fm.icelink.datamessageheader.Type.getConnectionId()))) {
                                fm.icelink.ArrayExtensions.remove(this.__elements, element);
                            }
                        }
                        fm.icelink.ArrayExtensions.add(this.__elements, new fm.icelink.datamessageheader.ConnectionIdElement(value));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.prototype.setTimeToLive = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        for (var _i = 0, _a = this.getElements(); _i < _a.length; _i++) {
                            var element = _a[_i];
                            if ((fm.icelink.Global.equals(element.getType(), fm.icelink.datamessageheader.Type.getTimeToLive()))) {
                                fm.icelink.ArrayExtensions.remove(this.__elements, element);
                            }
                        }
                        fm.icelink.ArrayExtensions.add(this.__elements, new fm.icelink.datamessageheader.TimeToLiveElement(value));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataMessage.fmicelinkDataMessageInitialize = function () {
                    if (!fm.icelink.DataMessage.__fmicelinkDataMessageInitialized && !fm.icelink.DataMessage.__fmicelinkDataMessageInitializing) {
                        fm.icelink.DataMessage.__fmicelinkDataMessageInitializing = true;
                        fm.icelink.DataMessage.fm_icelink_DataMessage___dataBufferPool = fm.icelink.DataBufferPool.getTracer(new fm.icelink.Type('[fm.icelink.DataMessage]'));
                        fm.icelink.DataMessage.fm_icelink_DataMessage___log = fm.icelink.Log.getLogger(new fm.icelink.Type('[fm.icelink.DataMessage]'));
                        fm.icelink.DataMessage.__fmicelinkDataMessageInitialized = true;
                        fm.icelink.DataMessage.__fmicelinkDataMessageInitializing = false;
                    }
                };
                DataMessage.IntUnset = -1;
                DataMessage.__fmicelinkDataMessageInitialized = false;
                DataMessage.__fmicelinkDataMessageInitializing = false;
                return DataMessage;
            }());
            icelink.DataMessage = DataMessage;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (datamessageheader) {
                var Element =  (function () {
                    function Element() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            this.fmicelinkdatamessageheaderElementInit();
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    Element.prototype.getTypeString = function () {
                        return '[fm.icelink.datamessageheader.Element]';
                    };
                    Element.prototype.fmicelinkdatamessageheaderElementInit = function () {
                        this._type = 0;
                    };
                    Element.parseBytes = function (buffer, offset, offsetPlus) {
                        if (arguments.length == 3) {
                            offset = fm.icelink.Global.toInt(arguments[1]);
                            var num = buffer.read8(offset);
                            if ((fm.icelink.Global.equals(num, fm.icelink.datamessageheader.Type.getTimeToLive()))) {
                                var _var0 = fm.icelink.datamessageheader.TimeToLiveElement.doParseBytes(buffer, offset, offsetPlus);
                                return _var0;
                            }
                            if ((fm.icelink.Global.equals(num, fm.icelink.datamessageheader.Type.getDeliveryAttempts()))) {
                                var _var1 = fm.icelink.datamessageheader.DeliveryAttemptsElement.doParseBytes(buffer, offset, offsetPlus);
                                return _var1;
                            }
                            if ((fm.icelink.Global.equals(num, fm.icelink.datamessageheader.Type.getConnectionId()))) {
                                var _var2 = fm.icelink.datamessageheader.ConnectionIdElement.doParseBytes(buffer, offset, offsetPlus);
                                return _var2;
                            }
                            var _var3 = fm.icelink.datamessageheader.UnknownElement.doParseBytes(buffer, offset, offsetPlus);
                            return _var3;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Element.prototype.getType = function () {
                        if (arguments.length == 0) {
                            return this._type;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Element.prototype.setType = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._type = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Element;
                }());
                datamessageheader.Element = Element;
            })(icelink.datamessageheader || (icelink.datamessageheader = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (datamessageheader) {
                var DeliveryAttemptsElement =  (function (_super) {
                    __extends(DeliveryAttemptsElement, _super);
                    function DeliveryAttemptsElement(numAttempts) {
                        var _this = this;
                        fm.icelink.datamessageheader.DeliveryAttemptsElement.fmicelinkdatamessageheaderDeliveryAttemptsElementInitialize();
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var numAttempts_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            _this.fmicelinkdatamessageheaderDeliveryAttemptsElementInit();
                            _super.prototype.setType.call(_this, fm.icelink.datamessageheader.Type.getDeliveryAttempts());
                            _this.setDeliveryAttempts(numAttempts_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    DeliveryAttemptsElement.prototype.getTypeString = function () {
                        return '[fm.icelink.datamessageheader.DeliveryAttemptsElement]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    DeliveryAttemptsElement.prototype.fmicelinkdatamessageheaderDeliveryAttemptsElementInit = function () {
                        this._deliveryAttempts = 0;
                    };
                    DeliveryAttemptsElement.doParseBytes = function (buffer, index, offsetPlus) {
                        fm.icelink.datamessageheader.DeliveryAttemptsElement.fmicelinkdatamessageheaderDeliveryAttemptsElementInitialize();
                        if (arguments.length == 3) {
                            index = fm.icelink.Global.toInt(arguments[1]);
                            offsetPlus.setValue(5);
                            return new fm.icelink.datamessageheader.DeliveryAttemptsElement(buffer.read16((index + 3)));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    DeliveryAttemptsElement.prototype.getBytes = function () {
                        if (arguments.length == 0) {
                            var buffer = fm.icelink.datamessageheader.DeliveryAttemptsElement.fm_icelink_datamessageheader_DeliveryAttemptsElement___dataBufferPool.take(this.getLength());
                            buffer.write8(_super.prototype.getType.call(this), 0);
                            buffer.write16(this.getLength(), 1);
                            buffer.write16(this.getDeliveryAttempts(), 3);
                            return buffer;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    DeliveryAttemptsElement.prototype.getDeliveryAttempts = function () {
                        if (arguments.length == 0) {
                            return this._deliveryAttempts;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    DeliveryAttemptsElement.prototype.getLength = function () {
                        if (arguments.length == 0) {
                            return 5;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    DeliveryAttemptsElement.prototype.setDeliveryAttempts = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._deliveryAttempts = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    DeliveryAttemptsElement.fmicelinkdatamessageheaderDeliveryAttemptsElementInitialize = function () {
                        if (!fm.icelink.datamessageheader.DeliveryAttemptsElement.__fmicelinkdatamessageheaderDeliveryAttemptsElementInitialized && !fm.icelink.datamessageheader.DeliveryAttemptsElement.__fmicelinkdatamessageheaderDeliveryAttemptsElementInitializing) {
                            fm.icelink.datamessageheader.DeliveryAttemptsElement.__fmicelinkdatamessageheaderDeliveryAttemptsElementInitializing = true;
                            fm.icelink.datamessageheader.DeliveryAttemptsElement.fm_icelink_datamessageheader_DeliveryAttemptsElement___dataBufferPool = fm.icelink.DataBufferPool.getTracer(new fm.icelink.Type('[fm.icelink.datamessageheader.DeliveryAttemptsElement]'));
                            fm.icelink.datamessageheader.DeliveryAttemptsElement.__fmicelinkdatamessageheaderDeliveryAttemptsElementInitialized = true;
                            fm.icelink.datamessageheader.DeliveryAttemptsElement.__fmicelinkdatamessageheaderDeliveryAttemptsElementInitializing = false;
                        }
                    };
                    DeliveryAttemptsElement.__fmicelinkdatamessageheaderDeliveryAttemptsElementInitialized = false;
                    DeliveryAttemptsElement.__fmicelinkdatamessageheaderDeliveryAttemptsElementInitializing = false;
                    return DeliveryAttemptsElement;
                }(fm.icelink.datamessageheader.Element));
                datamessageheader.DeliveryAttemptsElement = DeliveryAttemptsElement;
            })(icelink.datamessageheader || (icelink.datamessageheader = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (datamessageheader) {
                var ConnectionIdElement =  (function (_super) {
                    __extends(ConnectionIdElement, _super);
                    function ConnectionIdElement(idValue) {
                        var _this = this;
                        fm.icelink.datamessageheader.ConnectionIdElement.fmicelinkdatamessageheaderConnectionIdElementInitialize();
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var idValue_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setType.call(_this, fm.icelink.datamessageheader.Type.getConnectionId());
                            _this.setConnectionId(idValue_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    ConnectionIdElement.prototype.getTypeString = function () {
                        return '[fm.icelink.datamessageheader.ConnectionIdElement]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    ConnectionIdElement.doParseBytes = function (buffer, index, offsetPlus) {
                        fm.icelink.datamessageheader.ConnectionIdElement.fmicelinkdatamessageheaderConnectionIdElementInitialize();
                        if (arguments.length == 3) {
                            index = fm.icelink.Global.toInt(arguments[1]);
                            offsetPlus.setValue(buffer.read16((index + 1)));
                            return new fm.icelink.datamessageheader.ConnectionIdElement(buffer.readUtf8String((index + 3), (offsetPlus.getValue() - 3)));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionIdElement.prototype.getBytes = function () {
                        if (arguments.length == 0) {
                            var buffer = fm.icelink.datamessageheader.ConnectionIdElement.fm_icelink_datamessageheader_ConnectionIdElement___dataBufferPool.take(this.getLength());
                            buffer.write8(_super.prototype.getType.call(this), 0);
                            buffer.write16(this.getLength(), 1);
                            buffer.write(fm.icelink.DataBuffer.wrap(this.__connectionId), 3);
                            return buffer;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionIdElement.prototype.getConnectionId = function () {
                        if (arguments.length == 0) {
                            if ((!fm.icelink.Global.equals(this.__connectionId, null))) {
                                return fm.icelink.Encoding.getUtf8().getString(this.__connectionId);
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionIdElement.prototype.getLength = function () {
                        if (arguments.length == 0) {
                            return ((!fm.icelink.Global.equals(this.__connectionId, null)) ? (this.__connectionId.length + 3) : 3);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionIdElement.prototype.setConnectionId = function (value) {
                        if (arguments.length == 1) {
                            this.__connectionId = fm.icelink.Utf8.encode(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionIdElement.fmicelinkdatamessageheaderConnectionIdElementInitialize = function () {
                        if (!fm.icelink.datamessageheader.ConnectionIdElement.__fmicelinkdatamessageheaderConnectionIdElementInitialized && !fm.icelink.datamessageheader.ConnectionIdElement.__fmicelinkdatamessageheaderConnectionIdElementInitializing) {
                            fm.icelink.datamessageheader.ConnectionIdElement.__fmicelinkdatamessageheaderConnectionIdElementInitializing = true;
                            fm.icelink.datamessageheader.ConnectionIdElement.fm_icelink_datamessageheader_ConnectionIdElement___dataBufferPool = fm.icelink.DataBufferPool.getTracer(new fm.icelink.Type('[fm.icelink.datamessageheader.ConnectionIdElement]'));
                            fm.icelink.datamessageheader.ConnectionIdElement.__fmicelinkdatamessageheaderConnectionIdElementInitialized = true;
                            fm.icelink.datamessageheader.ConnectionIdElement.__fmicelinkdatamessageheaderConnectionIdElementInitializing = false;
                        }
                    };
                    ConnectionIdElement.__fmicelinkdatamessageheaderConnectionIdElementInitialized = false;
                    ConnectionIdElement.__fmicelinkdatamessageheaderConnectionIdElementInitializing = false;
                    return ConnectionIdElement;
                }(fm.icelink.datamessageheader.Element));
                datamessageheader.ConnectionIdElement = ConnectionIdElement;
            })(icelink.datamessageheader || (icelink.datamessageheader = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (datamessageheader) {
                var TimeToLiveElement =  (function (_super) {
                    __extends(TimeToLiveElement, _super);
                    function TimeToLiveElement(ttl) {
                        var _this = this;
                        fm.icelink.datamessageheader.TimeToLiveElement.fmicelinkdatamessageheaderTimeToLiveElementInitialize();
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var ttl_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            _this.fmicelinkdatamessageheaderTimeToLiveElementInit();
                            _super.prototype.setType.call(_this, fm.icelink.datamessageheader.Type.getTimeToLive());
                            _this.setTimeToLive(ttl_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    TimeToLiveElement.prototype.getTypeString = function () {
                        return '[fm.icelink.datamessageheader.TimeToLiveElement]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    TimeToLiveElement.prototype.fmicelinkdatamessageheaderTimeToLiveElementInit = function () {
                        this._timeToLive = 0;
                    };
                    TimeToLiveElement.doParseBytes = function (buffer, index, offsetPlus) {
                        fm.icelink.datamessageheader.TimeToLiveElement.fmicelinkdatamessageheaderTimeToLiveElementInitialize();
                        if (arguments.length == 3) {
                            index = fm.icelink.Global.toInt(arguments[1]);
                            offsetPlus.setValue(7);
                            return new fm.icelink.datamessageheader.TimeToLiveElement(buffer.read32((index + 3)));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeToLiveElement.prototype.getBytes = function () {
                        if (arguments.length == 0) {
                            var buffer = fm.icelink.datamessageheader.TimeToLiveElement.fm_icelink_datamessageheader_TimeToLiveElement___dataBufferPool.take(this.getLength());
                            buffer.write8(_super.prototype.getType.call(this), 0);
                            buffer.write16(this.getLength(), 1);
                            buffer.write32(this.getTimeToLive(), 3);
                            return buffer;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeToLiveElement.prototype.getLength = function () {
                        if (arguments.length == 0) {
                            return 7;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeToLiveElement.prototype.getTimeToLive = function () {
                        if (arguments.length == 0) {
                            return this._timeToLive;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeToLiveElement.prototype.setTimeToLive = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._timeToLive = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeToLiveElement.fmicelinkdatamessageheaderTimeToLiveElementInitialize = function () {
                        if (!fm.icelink.datamessageheader.TimeToLiveElement.__fmicelinkdatamessageheaderTimeToLiveElementInitialized && !fm.icelink.datamessageheader.TimeToLiveElement.__fmicelinkdatamessageheaderTimeToLiveElementInitializing) {
                            fm.icelink.datamessageheader.TimeToLiveElement.__fmicelinkdatamessageheaderTimeToLiveElementInitializing = true;
                            fm.icelink.datamessageheader.TimeToLiveElement.fm_icelink_datamessageheader_TimeToLiveElement___dataBufferPool = fm.icelink.DataBufferPool.getTracer(new fm.icelink.Type('[fm.icelink.datamessageheader.TimeToLiveElement]'));
                            fm.icelink.datamessageheader.TimeToLiveElement.__fmicelinkdatamessageheaderTimeToLiveElementInitialized = true;
                            fm.icelink.datamessageheader.TimeToLiveElement.__fmicelinkdatamessageheaderTimeToLiveElementInitializing = false;
                        }
                    };
                    TimeToLiveElement.__fmicelinkdatamessageheaderTimeToLiveElementInitialized = false;
                    TimeToLiveElement.__fmicelinkdatamessageheaderTimeToLiveElementInitializing = false;
                    return TimeToLiveElement;
                }(fm.icelink.datamessageheader.Element));
                datamessageheader.TimeToLiveElement = TimeToLiveElement;
            })(icelink.datamessageheader || (icelink.datamessageheader = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (datamessageheader) {
                var Type =  (function () {
                    function Type() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) ;
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    Type.prototype.getTypeString = function () {
                        return '[fm.icelink.datamessageheader.Type]';
                    };
                    Type.getConnectionId = function () {
                        if (arguments.length == 0) {
                            return 3;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Type.getDeliveryAttempts = function () {
                        if (arguments.length == 0) {
                            return 2;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Type.getTimeToLive = function () {
                        if (arguments.length == 0) {
                            return 1;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Type;
                }());
                datamessageheader.Type = Type;
            })(icelink.datamessageheader || (icelink.datamessageheader = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (datamessageheader) {
                var UnknownElement =  (function (_super) {
                    __extends(UnknownElement, _super);
                    function UnknownElement(type, payload) {
                        var _this = this;
                        fm.icelink.datamessageheader.UnknownElement.fmicelinkdatamessageheaderUnknownElementInitialize();
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 2) {
                            var type_5 = __arguments[0];
                            var payload_1 = __arguments[1];
                            _this = _super.call(this) || this;
                            _this.fmicelinkdatamessageheaderUnknownElementInit();
                            _super.prototype.setType.call(_this, type_5);
                            _this.setPayload(payload_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    UnknownElement.prototype.getTypeString = function () {
                        return '[fm.icelink.datamessageheader.UnknownElement]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    UnknownElement.prototype.fmicelinkdatamessageheaderUnknownElementInit = function () {
                        this.__length = 0;
                    };
                    UnknownElement.doParseBytes = function (buffer, index, offsetPlus) {
                        fm.icelink.datamessageheader.UnknownElement.fmicelinkdatamessageheaderUnknownElementInitialize();
                        if (arguments.length == 3) {
                            index = fm.icelink.Global.toInt(arguments[1]);
                            var num = buffer.read8(index);
                            offsetPlus.setValue(buffer.read16((index + 1)));
                            return new fm.icelink.datamessageheader.UnknownElement(num, buffer.subset((index + 3), (offsetPlus.getValue() - 3)));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UnknownElement.prototype.getBytes = function () {
                        if (arguments.length == 0) {
                            var buffer = fm.icelink.datamessageheader.UnknownElement.fm_icelink_datamessageheader_UnknownElement___dataBufferPool.take(this.getLength());
                            buffer.write8(_super.prototype.getType.call(this), 0);
                            buffer.write16(this.getLength(), 1);
                            buffer.write(this.getPayload(), 3);
                            return buffer;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UnknownElement.prototype.getLength = function () {
                        if (arguments.length == 0) {
                            return this.__length;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UnknownElement.prototype.getPayload = function () {
                        if (arguments.length == 0) {
                            return this.__payload;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UnknownElement.prototype.setPayload = function (value) {
                        if (arguments.length == 1) {
                            this.__payload = value;
                            this.__length = fm.icelink.Global.toInt((this.__payload.getLength() + 3));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UnknownElement.fmicelinkdatamessageheaderUnknownElementInitialize = function () {
                        if (!fm.icelink.datamessageheader.UnknownElement.__fmicelinkdatamessageheaderUnknownElementInitialized && !fm.icelink.datamessageheader.UnknownElement.__fmicelinkdatamessageheaderUnknownElementInitializing) {
                            fm.icelink.datamessageheader.UnknownElement.__fmicelinkdatamessageheaderUnknownElementInitializing = true;
                            fm.icelink.datamessageheader.UnknownElement.fm_icelink_datamessageheader_UnknownElement___dataBufferPool = fm.icelink.DataBufferPool.getTracer(new fm.icelink.Type('[fm.icelink.datamessageheader.UnknownElement]'));
                            fm.icelink.datamessageheader.UnknownElement.__fmicelinkdatamessageheaderUnknownElementInitialized = true;
                            fm.icelink.datamessageheader.UnknownElement.__fmicelinkdatamessageheaderUnknownElementInitializing = false;
                        }
                    };
                    UnknownElement.__fmicelinkdatamessageheaderUnknownElementInitialized = false;
                    UnknownElement.__fmicelinkdatamessageheaderUnknownElementInitializing = false;
                    return UnknownElement;
                }(fm.icelink.datamessageheader.Element));
                datamessageheader.UnknownElement = UnknownElement;
            })(icelink.datamessageheader || (icelink.datamessageheader = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CcmFirPolicyWrapper =  (function () {
                function CcmFirPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_22 = __arguments[0];
                        this._value = value_22;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CcmFirPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.CcmFirPolicyWrapper]';
                };
                CcmFirPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.CcmFirPolicy.Disabled)
                            return 'Disabled';
                        if (this._value == fm.icelink.CcmFirPolicy.Negotiated)
                            return 'Negotiated';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CcmFirPolicyWrapper;
            }());
            icelink.CcmFirPolicyWrapper = CcmFirPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var NackPliPolicyWrapper =  (function () {
                function NackPliPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_23 = __arguments[0];
                        this._value = value_23;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                NackPliPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.NackPliPolicyWrapper]';
                };
                NackPliPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.NackPliPolicy.Disabled)
                            return 'Disabled';
                        if (this._value == fm.icelink.NackPliPolicy.Negotiated)
                            return 'Negotiated';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return NackPliPolicyWrapper;
            }());
            icelink.NackPliPolicyWrapper = NackPliPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SessionDescriptionStreamMatcher =  (function () {
                function SessionDescriptionStreamMatcher(numStreams) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var numStreams_1 = __arguments[0];
                        this.__offererAudioStreamIndex = new Array();
                        this.__offererVideoStreamIndex = new Array();
                        this.__offererDataStreamIndex = new Array();
                        this.__internalAudioStreamIndex = new Array();
                        this.__internalVideoStreamIndex = new Array();
                        this.__internalDataStreamIndex = new Array();
                        this.reset(numStreams_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SessionDescriptionStreamMatcher.prototype.getTypeString = function () {
                    return '[fm.icelink.SessionDescriptionStreamMatcher]';
                };
                SessionDescriptionStreamMatcher.prototype.getInternalStreamIndexFor = function (oferrerStreamIndex) {
                    if (arguments.length == 1) {
                        oferrerStreamIndex = fm.icelink.Global.toInt(arguments[0]);
                        if ((this.__internalStreamIndexByOfferIndex.length > oferrerStreamIndex)) {
                            return this.__internalStreamIndexByOfferIndex[oferrerStreamIndex];
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionStreamMatcher.prototype.getInternalStreamMediaIndexForStream = function (type, indexInType) {
                    if (arguments.length == 2) {
                        indexInType = fm.icelink.Global.toInt(arguments[1]);
                        if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Audio))) {
                            return this.__internalAudioStreamIndex[indexInType];
                        }
                        if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Video))) {
                            return this.__internalVideoStreamIndex[indexInType];
                        }
                        if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Application))) {
                            return this.__internalDataStreamIndex[indexInType];
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionStreamMatcher.prototype.getOffererStreamIndexFor = function (internalStreamIndex) {
                    if (arguments.length == 1) {
                        internalStreamIndex = fm.icelink.Global.toInt(arguments[0]);
                        if ((this.__offererStreamIndexByInternalIndex.length > internalStreamIndex)) {
                            return this.__offererStreamIndexByInternalIndex[internalStreamIndex];
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionStreamMatcher.prototype.getOffererStreamMediaIndexForStream = function (type, indexInType) {
                    if (arguments.length == 2) {
                        indexInType = fm.icelink.Global.toInt(arguments[1]);
                        if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Audio))) {
                            return this.__offererAudioStreamIndex[indexInType];
                        }
                        if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Video))) {
                            return this.__offererVideoStreamIndex[indexInType];
                        }
                        if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Application))) {
                            return this.__offererDataStreamIndex[indexInType];
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionStreamMatcher.prototype.populateInternalStreamTypeIndexes = function (streams) {
                    if (arguments.length == 1) {
                        for (var i = 0; (i < fm.icelink.ArrayExtensions.getCount(streams)); i++) {
                            var local = streams[i];
                            var type = local.getType();
                            if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Audio))) {
                                fm.icelink.ArrayExtensions.add(this.__internalAudioStreamIndex, i);
                            }
                            else {
                                if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Video))) {
                                    fm.icelink.ArrayExtensions.add(this.__internalVideoStreamIndex, i);
                                }
                                else {
                                    if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Application))) {
                                        fm.icelink.ArrayExtensions.add(this.__internalDataStreamIndex, i);
                                    }
                                    else {
                                        return new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, new fm.icelink.Exception(fm.icelink.StringExtensions.format("Sdp offer contains a stream of type {0}. Processing of such streams is not currently supported.", new fm.icelink.StreamTypeWrapper(type).toString())));
                                    }
                                }
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionStreamMatcher.prototype.populateOffererStreamTypeIndexes = function (sdpMediaDescriptions) {
                    if (arguments.length == 1) {
                        for (var i = 0; (i < sdpMediaDescriptions.length); i++) {
                            var type = fm.icelink.sdp.MediaType.toStreamType(sdpMediaDescriptions[i].getMedia().getMediaType());
                            if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Audio))) {
                                fm.icelink.ArrayExtensions.add(this.__offererAudioStreamIndex, i);
                            }
                            else {
                                if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Video))) {
                                    fm.icelink.ArrayExtensions.add(this.__offererVideoStreamIndex, i);
                                }
                                else {
                                    if ((fm.icelink.Global.equals(type, fm.icelink.StreamType.Application))) {
                                        fm.icelink.ArrayExtensions.add(this.__offererDataStreamIndex, i);
                                    }
                                    else {
                                        return new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, new fm.icelink.Exception(fm.icelink.StringExtensions.format("Sdp offer contains a stream of type {0}. Processing of such streams is not currently supported.", new fm.icelink.StreamTypeWrapper(type).toString())));
                                    }
                                }
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionStreamMatcher.prototype.reset = function () {
                    if (arguments.length == 0) {
                        this.reset(this.__offererStreamIndexByInternalIndex.length);
                    }
                    else if (arguments.length == 1) {
                        var numStreams = fm.icelink.Global.toInt(arguments[0]);
                        fm.icelink.ArrayExtensions.clear(this.__offererAudioStreamIndex);
                        fm.icelink.ArrayExtensions.clear(this.__offererVideoStreamIndex);
                        fm.icelink.ArrayExtensions.clear(this.__offererDataStreamIndex);
                        this.__offererStreamIndexByInternalIndex = new Array(numStreams);
                        fm.icelink.ArrayExtensions.clear(this.__internalAudioStreamIndex);
                        fm.icelink.ArrayExtensions.clear(this.__internalVideoStreamIndex);
                        fm.icelink.ArrayExtensions.clear(this.__internalDataStreamIndex);
                        this.__internalStreamIndexByOfferIndex = new Array(numStreams);
                        for (var i = 0; (i < numStreams); i++) {
                            this.__offererStreamIndexByInternalIndex[i] = i;
                            this.__internalStreamIndexByOfferIndex[i] = i;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescriptionStreamMatcher.prototype.setMatchingIndexes = function (internalStreamIndex, offererStreamIndex) {
                    if (arguments.length == 2) {
                        internalStreamIndex = fm.icelink.Global.toInt(arguments[0]);
                        offererStreamIndex = fm.icelink.Global.toInt(arguments[1]);
                        if ((this.__offererStreamIndexByInternalIndex.length <= internalStreamIndex)) {
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Cannot set offerer stream index for the internal stream index {0}. Number of streams exceeded.", fm.icelink.NumberExtensions.toString(internalStreamIndex)));
                        }
                        this.__offererStreamIndexByInternalIndex[internalStreamIndex] = offererStreamIndex;
                        this.__internalStreamIndexByOfferIndex[offererStreamIndex] = internalStreamIndex;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SessionDescriptionStreamMatcher;
            }());
            icelink.SessionDescriptionStreamMatcher = SessionDescriptionStreamMatcher;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SimulcastModeWrapper =  (function () {
                function SimulcastModeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_24 = __arguments[0];
                        this._value = value_24;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SimulcastModeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.SimulcastModeWrapper]';
                };
                SimulcastModeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.SimulcastMode.Disabled)
                            return 'Disabled';
                        if (this._value == fm.icelink.SimulcastMode.RtpStreamId)
                            return 'RtpStreamId';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SimulcastModeWrapper;
            }());
            icelink.SimulcastModeWrapper = SimulcastModeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcMediaTrackBase =  (function (_super) {
                __extends(WebRtcMediaTrackBase, _super);
                function WebRtcMediaTrackBase() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebRtcMediaTrackBase.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcMediaTrackBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                return WebRtcMediaTrackBase;
            }(fm.icelink.Dynamic));
            icelink.WebRtcMediaTrackBase = WebRtcMediaTrackBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var BundlePolicyWrapper =  (function () {
                function BundlePolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_25 = __arguments[0];
                        this._value = value_25;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                BundlePolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.BundlePolicyWrapper]';
                };
                BundlePolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.BundlePolicy.Balanced)
                            return 'Balanced';
                        if (this._value == fm.icelink.BundlePolicy.MaxCompatibility)
                            return 'MaxCompatibility';
                        if (this._value == fm.icelink.BundlePolicy.MaxBundle)
                            return 'MaxBundle';
                        if (this._value == fm.icelink.BundlePolicy.Disabled)
                            return 'Disabled';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return BundlePolicyWrapper;
            }());
            icelink.BundlePolicyWrapper = BundlePolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Candidate =  (function () {
                function Candidate() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkCandidateInit();
                        this.__relayProtocol = fm.icelink.ProtocolType.Unknown;
                        this.__protocol = fm.icelink.ProtocolType.Unknown;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Candidate.prototype.getTypeString = function () {
                    return '[fm.icelink.Candidate]';
                };
                Candidate.prototype.fmicelinkCandidateInit = function () {
                    this._dispatched = false;
                    this._sdpMediaIndex = 0;
                };
                Candidate.fromJson = function (candidateJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(candidateJson, function () {
                            return new fm.icelink.Candidate();
                        }, function (candidate, name, valueJson) {
                            var str2 = name;
                            if ((!fm.icelink.Global.equals(str2, null))) {
                                if (!(fm.icelink.Global.equals(str2, "sdpCandidateAttribute"))) {
                                    if ((fm.icelink.Global.equals(str2, "sdpMediaIndex"))) {
                                        candidate.setSdpMediaIndex(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    }
                                }
                                else {
                                    var s = fm.icelink.JsonSerializer.deserializeString(valueJson);
                                    if ((!fm.icelink.Global.equals(s, null))) {
                                        if (!fm.icelink.StringExtensions.startsWith(s, "a=")) {
                                            s = fm.icelink.StringExtensions.concat("a=", s);
                                        }
                                        candidate.setSdpCandidateAttribute(fm.icelink.Global.tryCast(fm.icelink.sdp.Attribute.parse(s), fm.icelink.sdp.ice.CandidateAttribute));
                                    }
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.toJson = function (candidate) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(candidate, function (c, jsonObject) {
                            var sdpCandidateAttribute = candidate.getSdpCandidateAttribute();
                            if ((!fm.icelink.Global.equals(sdpCandidateAttribute, null))) {
                                var str = sdpCandidateAttribute.toString();
                                if (!fm.icelink.StringExtensions.startsWith(str, "a=")) {
                                    str = fm.icelink.StringExtensions.concat("a=", str);
                                }
                                jsonObject["sdpCandidateAttribute"] = fm.icelink.JsonSerializer.serializeString(str);
                            }
                            jsonObject["sdpMediaIndex"] = fm.icelink.JsonSerializer.serializeInteger(candidate.getSdpMediaIndex());
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.getDispatched = function () {
                    if (arguments.length == 0) {
                        return this._dispatched;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.getProtocol = function () {
                    if (arguments.length == 0) {
                        return this.__protocol;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.getRelayProtocol = function () {
                    if (arguments.length == 0) {
                        return this.__relayProtocol;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.getSdpCandidateAttribute = function () {
                    if (arguments.length == 0) {
                        return this.__sdpCandidateAttribute;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.getSdpMediaIndex = function () {
                    if (arguments.length == 0) {
                        return this._sdpMediaIndex;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.getTurnTransportProtocol = function () {
                    if (arguments.length == 0) {
                        return this.getRelayProtocol();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.setDispatched = function (value) {
                    if (arguments.length == 1) {
                        this._dispatched = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.setProtocol = function (value) {
                    if (arguments.length == 1) {
                        this.__protocol = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.setRelayProtocol = function (value) {
                    if (arguments.length == 1) {
                        this.__relayProtocol = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.setSdpCandidateAttribute = function (value) {
                    if (arguments.length == 1) {
                        this.setProtocol(fm.icelink.CandidateUtility.protocolTypeFromString(value.getProtocol()));
                        this.__sdpCandidateAttribute = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.setSdpMediaIndex = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._sdpMediaIndex = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.setTurnTransportProtocol = function (value) {
                    if (arguments.length == 1) {
                        this.setRelayProtocol(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Candidate.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Candidate.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Candidate;
            }());
            icelink.Candidate = Candidate;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Color =  (function () {
                function Color(r, g, b) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 3) {
                        var r_1 = __arguments[0];
                        var g_1 = __arguments[1];
                        var b_1 = __arguments[2];
                        this.fmicelinkColorInit();
                        this.setR(fm.icelink.MathAssistant.max(0, fm.icelink.MathAssistant.min(255, r_1)));
                        this.setG(fm.icelink.MathAssistant.max(0, fm.icelink.MathAssistant.min(255, g_1)));
                        this.setB(fm.icelink.MathAssistant.max(0, fm.icelink.MathAssistant.min(255, b_1)));
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Color.prototype.getTypeString = function () {
                    return '[fm.icelink.Color]';
                };
                Color.prototype.fmicelinkColorInit = function () {
                    this._b = 0;
                    this._g = 0;
                    this._r = 0;
                };
                Color.fromHsb = function (hue, saturation, brightness) {
                    if (arguments.length == 3) {
                        hue = fm.icelink.MathAssistant.max(0, fm.icelink.MathAssistant.min(359, hue));
                        saturation = fm.icelink.MathAssistant.max(0, fm.icelink.MathAssistant.min(1, saturation));
                        brightness = fm.icelink.MathAssistant.max(0, fm.icelink.MathAssistant.min(1, brightness));
                        if ((fm.icelink.Global.equals(saturation, 0))) {
                            var r = ((brightness * 255) + 0.5);
                            return new fm.icelink.Color(r, r, r);
                        }
                        var num2 = ((hue - fm.icelink.MathAssistant.floor(hue)) * 6);
                        var num3 = (num2 - fm.icelink.MathAssistant.floor(num2));
                        var num4 = (brightness * (1 - saturation));
                        var num5 = (brightness * (1 - (saturation * num3)));
                        var num6 = (brightness * (1 - (saturation * (1 - num3))));
                        var _var0 = num2;
                        do {
                            if (_var0 == 0) {
                                return new fm.icelink.Color(((brightness * 255) + 0.5), ((num6 * 255) + 0.5), ((num4 * 255) + 0.5));
                            }
                            else if (_var0 == 1) {
                                return new fm.icelink.Color(((num5 * 255) + 0.5), ((brightness * 255) + 0.5), ((num4 * 255) + 0.5));
                            }
                            else if (_var0 == 2) {
                                return new fm.icelink.Color(((num4 * 255) + 0.5), ((brightness * 255) + 0.5), ((num6 * 255) + 0.5));
                            }
                            else if (_var0 == 3) {
                                return new fm.icelink.Color(((num4 * 255) + 0.5), ((num5 * 255) + 0.5), ((brightness * 255) + 0.5));
                            }
                            else if (_var0 == 4) {
                                return new fm.icelink.Color(((num6 * 255) + 0.5), ((num4 * 255) + 0.5), ((brightness * 255) + 0.5));
                            }
                        } while (false);
                        return new fm.icelink.Color(((brightness * 255) + 0.5), ((num4 * 255) + 0.5), ((num5 * 255) + 0.5));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getBlack = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(0, 0, 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getBlue = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(0, 0, 255);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getCyan = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(0, 255, 255);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getDarkBlue = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(0, 0, 127);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getDarkGreen = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(0, 127, 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getDarkRed = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(127, 0, 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getGray = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(127, 127, 127);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getGreen = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(0, 255, 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getMagenta = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(255, 0, 255);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getOlive = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(127, 127, 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getPurple = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(127, 0, 127);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getRed = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(255, 0, 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getTeal = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(0, 127, 127);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getWhite = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(255, 255, 255);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.getYellow = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.Color(255, 255, 0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.prototype.getB = function () {
                    if (arguments.length == 0) {
                        return this._b;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.prototype.getG = function () {
                    if (arguments.length == 0) {
                        return this._g;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.prototype.getR = function () {
                    if (arguments.length == 0) {
                        return this._r;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.prototype.setB = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._b = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.prototype.setG = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._g = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Color.prototype.setR = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._r = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Color;
            }());
            icelink.Color = Color;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcConnectionBase =  (function (_super) {
                __extends(WebRtcConnectionBase, _super);
                function WebRtcConnectionBase(sharedLock) {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var sharedLock_1 = __arguments[0];
                        _this = _super.call(this) || this;
                        _this.fmicelinkWebRtcConnectionBaseInit();
                        _this.__id = fm.icelink.Utility.generateId();
                        _this.__bundlePolicy = fm.icelink.BundlePolicy.MaxCompatibility;
                        _this.__connected = new fm.icelink.Promise();
                        _this.__closed = new fm.icelink.Promise();
                        _this.__failed = new fm.icelink.Promise();
                        _this.__iceServers = new fm.icelink.IceServerCollection();
                        _this.__useTrickleIce = true;
                        _this.__trickleIcePolicy = fm.icelink.TrickleIcePolicy.FullTrickle;
                        _this._earlyRemoteCandidatePromises = new Array();
                        _this.__signallingState = fm.icelink.SignallingState.New;
                        _this._connectionLock = sharedLock_1;
                        _this.setLegacyTimeout(true);
                        _this.setTieBreaker(fm.icelink.Utility.generateId());
                        _this.setTimeout(30000);
                        _this.setDeadStreamTimeout(15000);
                        _this.setIceGatherPolicy(fm.icelink.IceGatherPolicy.All);
                        _this.setTrickleIcePolicy(fm.icelink.TrickleIcePolicy.FullTrickle);
                        _this.__stateMachine = new fm.icelink.ConnectionStateMachine();
                        _this.addOnStateChange(_this.connectionBase_OnStateChange.bind(_this));
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebRtcConnectionBase.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcConnectionBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcConnectionBase.prototype.fmicelinkWebRtcConnectionBaseInit = function () {
                    var _this = this;
                    this.__onExternalIdChange = [];
                    this.__onGatheringStateChange = [];
                    this.__onIceConnectionStateChange = [];
                    this.__onLocalCandidate = [];
                    this.__onLocalDescription = [];
                    this.__onRemoteCandidate = [];
                    this.__onRemoteDescription = [];
                    this.__onSignallingStateChange = [];
                    this.__onStateChange = [];
                    this.__useTrickleIce = false;
                    this._deadStreamTimeout = 0;
                    this._legacyTimeout = false;
                    this._onExternalIdChange = function (p0, p1) { for (var _i = 0, _a = _this.__onExternalIdChange; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0, p1);
                    } };
                    this._onGatheringStateChange = function (p0) { for (var _i = 0, _a = _this.__onGatheringStateChange; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0);
                    } };
                    this._onIceConnectionStateChange = function (p0) { for (var _i = 0, _a = _this.__onIceConnectionStateChange; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0);
                    } };
                    this._onLocalCandidate = function (p0, p1) { for (var _i = 0, _a = _this.__onLocalCandidate; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0, p1);
                    } };
                    this._onLocalDescription = function (p0, p1) { for (var _i = 0, _a = _this.__onLocalDescription; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0, p1);
                    } };
                    this._onRemoteCandidate = function (p0, p1) { for (var _i = 0, _a = _this.__onRemoteCandidate; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0, p1);
                    } };
                    this._onRemoteDescription = function (p0, p1) { for (var _i = 0, _a = _this.__onRemoteDescription; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0, p1);
                    } };
                    this._onSignallingStateChange = function (p0) { for (var _i = 0, _a = _this.__onSignallingStateChange; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0);
                    } };
                    this._onStateChange = function (p0) { for (var _i = 0, _a = _this.__onStateChange; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0);
                    } };
                    this._timeout = 0;
                };
                WebRtcConnectionBase.prototype.addIceServer = function (iceServer) {
                    if (arguments.length == 1) {
                        this.__iceServers.add(iceServer);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addIceServers = function (iceServers) {
                    if (arguments.length == 1) {
                        this.__iceServers.addMany(iceServers);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addOnExternalIdChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onExternalIdChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addOnGatheringStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onGatheringStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addOnIceConnectionStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onIceConnectionStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addOnLocalCandidate = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onLocalCandidate, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addOnLocalDescription = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onLocalDescription, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addOnRemoteCandidate = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onRemoteCandidate, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addOnRemoteDescription = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onRemoteDescription, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addOnSignallingStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onSignallingStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addOnStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addRemoteCandidate = function (remoteCandidate) {
                    if (arguments.length == 1) {
                        var item = new fm.icelink.RemoteCandidatePromise(remoteCandidate);
                        if (((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.New)) || (fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Initializing)))) {
                            fm.icelink.ArrayExtensions.add(this._earlyRemoteCandidatePromises, item);
                            if (((!fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.New)) && (!fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Initializing)))) {
                                fm.icelink.ArrayExtensions.clear(this._earlyRemoteCandidatePromises);
                                this.addRemoteCandidatePromise(item);
                            }
                            return item;
                        }
                        if (!this.getIsTerminatingOrTerminated()) {
                            this.addRemoteCandidatePromise(item);
                        }
                        return item;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.addRemoteCandidatePromise = function (remoteCandidatePromise) {
                    if (arguments.length == 1) {
                        try {
                            var remoteCandidate = remoteCandidatePromise.getRemoteCandidate();
                            this.updateRemoteCandidateIndex(remoteCandidate);
                            this.raiseRemoteCandidate(remoteCandidatePromise.getRemoteCandidate());
                            this.doAddRemoteCandidate(remoteCandidatePromise, remoteCandidatePromise.getRemoteCandidate());
                        }
                        catch (exception) {
                            remoteCandidatePromise.reject(exception);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.connectionBase_OnStateChange = function (p) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Connected))) {
                            this.saveDtlsSRole(this.getLocalDescription(), true);
                            this.saveDtlsSRole(this.getRemoteDescription(), false);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.createAnswer = function () {
                    if (arguments.length == 0) {
                        var asyncPromise = new fm.icelink.Promise();
                        this.createAnswerWrapper(asyncPromise);
                        return asyncPromise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.createAnswerWrapper = function (asyncPromise) {
                    if (arguments.length == 1) {
                        var resolveAction = null;
                        var rejectAction = null;
                        try {
                            var promise = new fm.icelink.Promise();
                            this.doCreateAnswer(promise);
                            if ((fm.icelink.Global.equals(resolveAction, null))) {
                                resolveAction = function (sd) {
                                    asyncPromise.resolveAsync(sd);
                                };
                            }
                            if ((fm.icelink.Global.equals(rejectAction, null))) {
                                rejectAction = function (ex) {
                                    asyncPromise.rejectAsync(ex);
                                };
                            }
                            promise.then(resolveAction, rejectAction);
                        }
                        catch (exception) {
                            asyncPromise.rejectAsync(exception);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.createOffer = function () {
                    if (arguments.length == 0) {
                        var asyncPromise = new fm.icelink.Promise();
                        this.createOfferWrapper(asyncPromise);
                        return asyncPromise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.createOfferWrapper = function (asyncPromise) {
                    if (arguments.length == 1) {
                        var resolveAction = null;
                        var rejectAction = null;
                        try {
                            var promise = new fm.icelink.Promise();
                            this.doCreateOffer(promise);
                            if ((fm.icelink.Global.equals(resolveAction, null))) {
                                resolveAction = function (sd) {
                                    asyncPromise.resolveAsync(sd);
                                };
                            }
                            if ((fm.icelink.Global.equals(rejectAction, null))) {
                                rejectAction = function (ex) {
                                    asyncPromise.rejectAsync(ex);
                                };
                            }
                            promise.then(resolveAction, rejectAction);
                        }
                        catch (exception) {
                            asyncPromise.rejectAsync(exception);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.doProcessDescription = function (description, isLocalDescription) {
                    if (arguments.length == 2) {
                        var error = this.getSessionDescriptionManager().processDescription(description, isLocalDescription);
                        if ((!fm.icelink.Global.equals(error, null))) {
                            return error;
                        }
                        if ((!isLocalDescription && (fm.icelink.Global.equals(this.getTrickleIcePolicy(), fm.icelink.TrickleIcePolicy.HalfTrickle)))) {
                            if (description.getSdpMessage().getSupportsTrickleIce()) {
                                fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Peer supports Trickle-Ice. Trickle Ice will be enabled in all subsequent communications with the peer for the lifetime of connection {0}.", this.getId()));
                                this.setUseTrickleIce(true);
                            }
                            else {
                                this.setUseTrickleIce(false);
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.doSetLocalDescriptionInternal = function (localDescription) {
                    if (arguments.length == 1) {
                        var promise = new fm.icelink.Promise();
                        this.doSetLocalDescription(promise, localDescription);
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.doSetRemoteDescriptionInternal = function (remoteDescription) {
                    if (arguments.length == 1) {
                        var promise = new fm.icelink.Promise();
                        this.doSetRemoteDescription(promise, remoteDescription);
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.dtlsRole = function (sessionDescription) {
                    if (arguments.length == 1) {
                        var setup = "";
                        var sdpMessage = sessionDescription.getSdpMessage();
                        if ((!fm.icelink.Global.equals(sdpMessage, null))) {
                            var sessionLevelSetupAttribute = sdpMessage.getSessionLevelSetupAttribute();
                            if ((fm.icelink.Global.equals(sessionLevelSetupAttribute, null))) {
                                var mediaDescriptions = sdpMessage.getMediaDescriptions();
                                if ((mediaDescriptions.length > 0)) {
                                    sessionLevelSetupAttribute = mediaDescriptions[0].getSetupAttribute();
                                }
                            }
                            if ((!fm.icelink.Global.equals(sessionLevelSetupAttribute, null))) {
                                setup = sessionLevelSetupAttribute.getSetup();
                            }
                        }
                        return setup;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getAudioStream = function () {
                    if (arguments.length == 0) {
                        var audioStreams = this.getAudioStreams();
                        if (((fm.icelink.Global.equals(audioStreams, null)) || (fm.icelink.Global.equals(audioStreams.length, 0)))) {
                            return null;
                        }
                        return audioStreams[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getBundlePolicy = function () {
                    if (arguments.length == 0) {
                        return this.__bundlePolicy;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getCanonicalName = function () {
                    if (arguments.length == 0) {
                        fm.icelink.Log.warn("Getting the value of Connection.CanonicalName is deprecated. Get the value of MediaStream.LocalCanonicalName instead.");
                        return this.getConnectionWideCanonicalName();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getClosed = function () {
                    if (arguments.length == 0) {
                        return this.__closed;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getConnected = function () {
                    if (arguments.length == 0) {
                        return this.__connected;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getConnectionWideCanonicalName = function () {
                    if (arguments.length == 0) {
                        var streams = this.getStreams();
                        for (var _i = 0, streams_2 = streams; _i < streams_2.length; _i++) {
                            var local = streams_2[_i];
                            if ((fm.icelink.Global.equals(local.getType(), fm.icelink.StreamType.Audio))) {
                                return fm.icelink.Global.tryCast(local, fm.icelink.WebRtcMediaStreamBase).getLocalCanonicalName();
                            }
                            if ((fm.icelink.Global.equals(local.getType(), fm.icelink.StreamType.Video))) {
                                return fm.icelink.Global.tryCast(local, fm.icelink.WebRtcMediaStreamBase).getLocalCanonicalName();
                            }
                        }
                        return this.getId();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getDataStream = function () {
                    if (arguments.length == 0) {
                        var dataStreams = this.getDataStreams();
                        if (((fm.icelink.Global.equals(dataStreams, null)) || (fm.icelink.Global.equals(dataStreams.length, 0)))) {
                            return null;
                        }
                        return dataStreams[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getDeadStreamTimeout = function () {
                    if (arguments.length == 0) {
                        return this._deadStreamTimeout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getError = function () {
                    if (arguments.length == 0) {
                        return this._error;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getExternalId = function () {
                    if (arguments.length == 0) {
                        return this.__externalId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getFailed = function () {
                    if (arguments.length == 0) {
                        return this.__failed;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getHasAudio = function () {
                    if (arguments.length == 0) {
                        return (!fm.icelink.Global.equals(this.getAudioStream(), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getHasData = function () {
                    if (arguments.length == 0) {
                        return (!fm.icelink.Global.equals(this.getDataStream(), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getHasVideo = function () {
                    if (arguments.length == 0) {
                        return (!fm.icelink.Global.equals(this.getVideoStream(), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getIceGatherPolicy = function () {
                    if (arguments.length == 0) {
                        return this._iceGatherPolicy;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getIceServer = function () {
                    if (arguments.length == 0) {
                        return this.__iceServers.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getIceServers = function () {
                    if (arguments.length == 0) {
                        return this.__iceServers.getValues();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this.__id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getIsTerminated = function () {
                    if (arguments.length == 0) {
                        return ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Closed)) || (fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Failed)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getIsTerminating = function () {
                    if (arguments.length == 0) {
                        return ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Closing)) || (fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Failing)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getIsTerminatingOrTerminated = function () {
                    if (arguments.length == 0) {
                        return (this.getIsTerminating() || this.getIsTerminated());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getLegacyTimeout = function () {
                    if (arguments.length == 0) {
                        return this._legacyTimeout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getSignallingState = function () {
                    if (arguments.length == 0) {
                        return this.__signallingState;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getState = function () {
                    if (arguments.length == 0) {
                        return this.__stateMachine.getState();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getStream = function () {
                    if (arguments.length == 0) {
                        var streams = this.getStreams();
                        if (((fm.icelink.Global.equals(streams, null)) || (fm.icelink.Global.equals(streams.length, 0)))) {
                            return null;
                        }
                        return streams[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getTieBreaker = function () {
                    if (arguments.length == 0) {
                        return this._tieBreaker;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getTimeout = function () {
                    if (arguments.length == 0) {
                        return this._timeout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getTrickleIcePolicy = function () {
                    if (arguments.length == 0) {
                        return this.__trickleIcePolicy;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getUseTrickleIce = function () {
                    if (arguments.length == 0) {
                        return this.__useTrickleIce;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.getVideoStream = function () {
                    if (arguments.length == 0) {
                        var videoStreams = this.getVideoStreams();
                        if (((fm.icelink.Global.equals(videoStreams, null)) || (fm.icelink.Global.equals(videoStreams.length, 0)))) {
                            return null;
                        }
                        return videoStreams[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.logInvalidStateTransition = function (state) {
                    if (arguments.length == 1) {
                        if (fm.icelink.Log.getIsDebugEnabled()) {
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Connection {0} state is currently {1}. Cannot transition to {2}.", this.getId(), fm.icelink.StringExtensions.toLower(new fm.icelink.ConnectionStateWrapper(this.getState()).toString()), fm.icelink.StringExtensions.toLower(new fm.icelink.ConnectionStateWrapper(state).toString())));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.processDescription = function (description, isLocalDescription) {
                    if (arguments.length == 2) {
                        return this.doProcessDescription(description, isLocalDescription);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.processStateChange = function () {
                    if (arguments.length == 0) {
                        var streams = this.getStreams();
                        if ((!fm.icelink.Global.equals(streams, null))) {
                            for (var _i = 0, streams_3 = streams; _i < streams_3.length; _i++) {
                                var local = streams_3[_i];
                                if ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Initializing))) {
                                    local.setState(fm.icelink.StreamState.Initializing);
                                }
                                else {
                                    if ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Connecting))) {
                                        local.setState(fm.icelink.StreamState.Connecting);
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Connected))) {
                                            local.setState(fm.icelink.StreamState.Connected);
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Closing))) {
                                                local.setState(fm.icelink.StreamState.Closing);
                                            }
                                            else {
                                                if ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Closed))) {
                                                    local.setState(fm.icelink.StreamState.Closed);
                                                }
                                                else {
                                                    if ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Failing))) {
                                                        local.setState(fm.icelink.StreamState.Failing);
                                                    }
                                                    else {
                                                        if ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Failed))) {
                                                            local.setState(fm.icelink.StreamState.Failed);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.raiseCachedCandidates = function () {
                    if (arguments.length == 0) {
                        for (var _i = 0, _a = this._earlyRemoteCandidatePromises; _i < _a.length; _i++) {
                            var promise = _a[_i];
                            this.addRemoteCandidatePromise(promise);
                        }
                        fm.icelink.ArrayExtensions.clear(this._earlyRemoteCandidatePromises);
                        this.doSendCachedLocalCandidates();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.raiseConnected = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(this.__connected.getState(), fm.icelink.FutureState.Pending))) {
                            this.__connected.resolve(null);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.raiseGatheringStateChange = function (connection) {
                    if (arguments.length == 1) {
                        var onGatheringStateChange = this._onGatheringStateChange;
                        if ((!fm.icelink.Global.equals(onGatheringStateChange, null))) {
                            try {
                                onGatheringStateChange(connection);
                            }
                            catch (exception) {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising gathering state change to the application code for connection {0}.", this.getId()), exception);
                            }
                            finally {
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.raiseIceConnectionStateChange = function (connection) {
                    if (arguments.length == 1) {
                        var onIceConnectionStateChange = this._onIceConnectionStateChange;
                        if ((!fm.icelink.Global.equals(onIceConnectionStateChange, null))) {
                            try {
                                onIceConnectionStateChange(connection);
                            }
                            catch (exception) {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising ICE connection state change to the application code for connection {0}.", this.getId()), exception);
                            }
                            finally {
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.raiseLocalCandidate = function (localCandidate) {
                    if (arguments.length == 1) {
                        var onLocalCandidate = this._onLocalCandidate;
                        if (((!fm.icelink.Global.equals(onLocalCandidate, null)) && !localCandidate.getDispatched())) {
                            try {
                                onLocalCandidate(this.getInstance(), localCandidate);
                            }
                            catch (exception) {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising local candidate to the application code for connection {0}.", this.getId()), exception);
                            }
                            finally {
                            }
                        }
                        if ((fm.icelink.Global.equals(localCandidate.getRelayProtocol(), fm.icelink.ProtocolType.Tcp))) {
                            fm.icelink.Log.info(fm.icelink.StringExtensions.format("Local candidate for stream {0} (over TCP) for connection {2}:\n{1}", fm.icelink.NumberExtensions.toString(localCandidate.getSdpMediaIndex()), localCandidate.getSdpCandidateAttribute().toString(), this.getId()));
                        }
                        else {
                            if ((fm.icelink.Global.equals(localCandidate.getRelayProtocol(), fm.icelink.ProtocolType.Tls))) {
                                fm.icelink.Log.info(fm.icelink.StringExtensions.format("Local candidate for stream {0} (over TLS) for connection {2}:\n{1}", fm.icelink.NumberExtensions.toString(localCandidate.getSdpMediaIndex()), localCandidate.getSdpCandidateAttribute().toString(), this.getId()));
                            }
                            else {
                                fm.icelink.Log.info(fm.icelink.StringExtensions.format("Local candidate for stream {0} for connection {2}:\n{1}", fm.icelink.NumberExtensions.toString(localCandidate.getSdpMediaIndex()), localCandidate.getSdpCandidateAttribute().toString(), this.getId()));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.raiseLocalDescription = function (localDescription) {
                    if (arguments.length == 1) {
                        var onLocalDescription = this._onLocalDescription;
                        if ((!fm.icelink.Global.equals(onLocalDescription, null))) {
                            try {
                                onLocalDescription(this.getInstance(), localDescription);
                            }
                            catch (exception) {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising local description to the application code for connection {0}.", this.getId()), exception);
                            }
                            finally {
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.raiseRemoteCandidate = function (remoteCandidate) {
                    if (arguments.length == 1) {
                        var onRemoteCandidate = this._onRemoteCandidate;
                        if ((!fm.icelink.Global.equals(onRemoteCandidate, null))) {
                            try {
                                onRemoteCandidate(this.getInstance(), remoteCandidate);
                            }
                            catch (exception) {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising remote candidate to the application code for connection {0}.", this.getId()), exception);
                            }
                            finally {
                            }
                        }
                        fm.icelink.Log.info(fm.icelink.StringExtensions.format("Remote candidate for stream {0} for connection {2}:\n{1}", fm.icelink.NumberExtensions.toString(remoteCandidate.getSdpMediaIndex()), remoteCandidate.getSdpCandidateAttribute().toString(), this.getId()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.raiseRemoteDescription = function (remoteDescription) {
                    if (arguments.length == 1) {
                        var onRemoteDescription = this._onRemoteDescription;
                        if ((!fm.icelink.Global.equals(onRemoteDescription, null))) {
                            try {
                                onRemoteDescription(this.getInstance(), remoteDescription);
                            }
                            catch (exception) {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising remote description to the application code for connection {0}.", this.getId()), exception);
                            }
                            finally {
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.raiseStateChange = function () {
                    var _this = this;
                    if (arguments.length == 0) {
                        var action2 = null;
                        var action3 = null;
                        var action4 = null;
                        var _var0 = this.getState();
                        do {
                            if (_var0 == fm.icelink.ConnectionState.Connected) {
                                if ((fm.icelink.Global.equals(action2, null))) {
                                    action2 = function () {
                                        _this.raiseConnected();
                                    };
                                }
                                fm.icelink.ManagedThread.dispatch(action2);
                                break;
                            }
                            else if (_var0 == fm.icelink.ConnectionState.Failed) {
                                if ((fm.icelink.Global.equals(action4, null))) {
                                    action4 = function () {
                                        _this.raiseTerminated(true);
                                    };
                                }
                                fm.icelink.ManagedThread.dispatch(action4);
                                break;
                            }
                            else if (_var0 == fm.icelink.ConnectionState.Closed) {
                                if ((fm.icelink.Global.equals(action3, null))) {
                                    action3 = function () {
                                        _this.raiseTerminated(false);
                                    };
                                }
                                fm.icelink.ManagedThread.dispatch(action3);
                                break;
                            }
                        } while (false);
                        var onStateChange = this._onStateChange;
                        if ((!fm.icelink.Global.equals(onStateChange, null))) {
                            try {
                                onStateChange(this.getInstance());
                            }
                            catch (exception) {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising state change to the application code for connection {0}.", this.getId()), exception);
                            }
                            finally {
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.raiseTerminated = function (failed) {
                    if (arguments.length == 1) {
                        if (failed) {
                            if ((fm.icelink.Global.equals(this.__connected.getState(), fm.icelink.FutureState.Pending))) {
                                this.__connected.reject(this.getError().getException());
                            }
                            if ((fm.icelink.Global.equals(this.__closed.getState(), fm.icelink.FutureState.Pending))) {
                                this.__closed.reject(this.getError().getException());
                            }
                            if ((fm.icelink.Global.equals(this.__failed.getState(), fm.icelink.FutureState.Pending))) {
                                this.__failed.resolve(null);
                            }
                        }
                        else {
                            if ((fm.icelink.Global.equals(this.__connected.getState(), fm.icelink.FutureState.Pending))) {
                                this.__connected.reject(new fm.icelink.Exception("Connection closed."));
                            }
                            if ((fm.icelink.Global.equals(this.__failed.getState(), fm.icelink.FutureState.Pending))) {
                                this.__failed.reject(new fm.icelink.Exception("Connection closed."));
                            }
                            if ((fm.icelink.Global.equals(this.__closed.getState(), fm.icelink.FutureState.Pending))) {
                                this.__closed.resolve(null);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.registerStreamWithSessionDescriptionManager = function (stream) {
                    if (arguments.length == 1) {
                        this.getSessionDescriptionManager().addStream(stream);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeIceServer = function (iceServer) {
                    if (arguments.length == 1) {
                        this.__iceServers.remove(iceServer);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeIceServers = function (iceServers) {
                    if (arguments.length == 1) {
                        this.__iceServers.removeMany(iceServers);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeOnExternalIdChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onExternalIdChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeOnGatheringStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onGatheringStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeOnIceConnectionStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onIceConnectionStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeOnLocalCandidate = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onLocalCandidate, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeOnLocalDescription = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onLocalDescription, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeOnRemoteCandidate = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onRemoteCandidate, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeOnRemoteDescription = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onRemoteDescription, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeOnSignallingStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onSignallingStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.removeOnStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.saveDtlsSRole = function (sessionDescription, isLocalDescription) {
                    if (arguments.length == 2) {
                        if (((!fm.icelink.Global.equals(sessionDescription, null)) && (!fm.icelink.Global.equals(sessionDescription.getSdpMessage(), null)))) {
                            var mediaDescriptions = sessionDescription.getSdpMessage().getMediaDescriptions();
                            if ((mediaDescriptions.length >= 1)) {
                                var setupAttribute = mediaDescriptions[0].getSetupAttribute();
                                if ((!fm.icelink.Global.equals(setupAttribute, null))) {
                                    var attribute2 = new fm.icelink.sdp.SetupAttribute(setupAttribute.getSetup());
                                    if (isLocalDescription) {
                                        this.__localDTLSRole = attribute2;
                                    }
                                    else {
                                        this.__remoteDTLSRole = attribute2;
                                    }
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setBundlePolicy = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, fm.icelink.BundlePolicy.Balanced))) {
                            throw new fm.icelink.Exception("Balanced stream bundling is currently not supported.");
                        }
                        this.__bundlePolicy = value;
                        this.updateBundlePolicy(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setDeadStreamTimeout = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._deadStreamTimeout = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setError = function (value) {
                    if (arguments.length == 1) {
                        this._error = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setExternalId = function (value) {
                    if (arguments.length == 1) {
                        var str = this.__externalId;
                        if ((!fm.icelink.Global.equals(str, value))) {
                            this.__externalId = value;
                            var onExternalIdChange = this._onExternalIdChange;
                            if ((!fm.icelink.Global.equals(onExternalIdChange, null))) {
                                try {
                                    onExternalIdChange(this.getId(), str);
                                }
                                catch (exception) {
                                    fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising external ID change to the application code for connection {0}.", this.getId()), exception);
                                }
                                finally {
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setIceGatherPolicy = function (value) {
                    if (arguments.length == 1) {
                        this._iceGatherPolicy = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setIceServer = function (value) {
                    if (arguments.length == 1) {
                        this.__iceServers.setValue(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setIceServers = function (value) {
                    if (arguments.length == 1) {
                        this.__iceServers.replace(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setLegacyTimeout = function (value) {
                    if (arguments.length == 1) {
                        this._legacyTimeout = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setLocalDescription = function (localDescription) {
                    if (arguments.length == 1) {
                        var promise = new fm.icelink.Promise();
                        try {
                            this.setLocalDescriptionInternal(promise, localDescription);
                        }
                        catch (exception) {
                            promise.reject(exception);
                        }
                        finally {
                        }
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setLocalDescriptionInternal = function (promise, localDescription) {
                    var _this = this;
                    if (arguments.length == 2) {
                        this.getSessionDescriptionManager().updateLocalDescription(localDescription);
                        this.raiseLocalDescription(localDescription);
                        var future = null;
                        if (this.getIsTerminatingOrTerminated()) {
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Cannot set local description: connection is {0}.", new fm.icelink.ConnectionStateWrapper(this.getState()).toString()));
                        }
                        future = this.doSetLocalDescriptionInternal(localDescription);
                        future.then(function (ld) {
                            try {
                                fm.icelink.Log.info(fm.icelink.StringExtensions.format("Local session description ({0}) for connection {2}:\n{1}", fm.icelink.StringExtensions.toLower(new fm.icelink.SessionDescriptionTypeWrapper(ld.getType()).toString()), fm.icelink.StringExtensions.replace(ld.getSdpMessage().toString(), "\r\n", "\n"), _this.getId()));
                                var sdpMessage = ld.getSdpMessage();
                                if ((!fm.icelink.Global.equals(sdpMessage, null))) {
                                    for (var _i = 0, _a = sdpMessage.getMediaDescriptions(); _i < _a.length; _i++) {
                                        var description = _a[_i];
                                        var exception = void 0;
                                        var simulcastAttribute = description.getSimulcastAttribute();
                                        if ((!fm.icelink.Global.equals(simulcastAttribute, null))) {
                                            if ((!fm.icelink.Global.equals(simulcastAttribute.getSendDescription(), null))) {
                                                exception = new fm.icelink.Exception("Sending simulcast streams is not supported.");
                                                _this.setError(new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionSimulcastNotSupported, exception));
                                                throw exception;
                                            }
                                            if ((!fm.icelink.Global.equals(simulcastAttribute.getReceiveDescription(), null))) {
                                                exception = new fm.icelink.Exception("Receiving simulcast streams is not supported.");
                                                _this.setError(new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionSimulcastNotSupported, exception));
                                                throw exception;
                                            }
                                        }
                                        if ((!fm.icelink.Global.equals(description.getSsrcGroupSsrcs("SIM"), null))) {
                                            exception = new fm.icelink.Exception("Sending simulcast streams is not supported.");
                                            _this.setError(new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionSimulcastNotSupported, exception));
                                            throw exception;
                                        }
                                    }
                                }
                                promise.resolve(ld);
                            }
                            catch (exception2) {
                                promise.reject(exception2);
                            }
                            finally {
                            }
                        }, function (ex) {
                            promise.reject(ex);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setRemoteDescription = function (remoteDescription) {
                    if (arguments.length == 1) {
                        var promise = new fm.icelink.Promise();
                        try {
                            this.setRemoteDescriptionInternal(promise, remoteDescription);
                        }
                        catch (exception) {
                            promise.reject(exception);
                        }
                        finally {
                        }
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setRemoteDescriptionInternal = function (promise, remoteDescription) {
                    var _this = this;
                    if (arguments.length == 2) {
                        var sdpMessage = remoteDescription.getSdpMessage();
                        if ((!fm.icelink.Global.equals(sdpMessage, null))) {
                            for (var _i = 0, _a = sdpMessage.getMediaDescriptions(); _i < _a.length; _i++) {
                                var description = _a[_i];
                                var exception = void 0;
                                var simulcastAttribute = description.getSimulcastAttribute();
                                if ((!fm.icelink.Global.equals(simulcastAttribute, null))) {
                                    if ((!fm.icelink.Global.equals(simulcastAttribute.getReceiveDescription(), null))) {
                                        exception = new fm.icelink.Exception("Sending simulcast streams is not supported.");
                                        this.setError(new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionSimulcastNotSupported, exception));
                                        throw exception;
                                    }
                                    if ((!fm.icelink.Global.equals(simulcastAttribute.getSendDescription(), null))) {
                                        exception = new fm.icelink.Exception("Receiving simulcast streams is not supported.");
                                        this.setError(new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionSimulcastNotSupported, exception));
                                        throw exception;
                                    }
                                }
                                if ((!fm.icelink.Global.equals(description.getSsrcGroupSsrcs("SIM"), null))) {
                                    exception = new fm.icelink.Exception("Receiving simulcast streams is not supported.");
                                    this.setError(new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionSimulcastNotSupported, exception));
                                    throw exception;
                                }
                            }
                        }
                        this.updateRemoteDescriptionDtlsRole(remoteDescription);
                        this.raiseRemoteDescription(remoteDescription);
                        var future = null;
                        this.verifySessionIdAndVersion(remoteDescription);
                        if (this.getIsTerminatingOrTerminated()) {
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Cannot set remote description: connection is {0}.", new fm.icelink.ConnectionStateWrapper(this.getState()).toString()));
                        }
                        future = this.doSetRemoteDescriptionInternal(remoteDescription);
                        future.then(function (rd) {
                            fm.icelink.Log.info(fm.icelink.StringExtensions.format("Remote session description ({0}) for connection {2}:\n{1}", fm.icelink.StringExtensions.toLower(new fm.icelink.SessionDescriptionTypeWrapper(rd.getType()).toString()), fm.icelink.StringExtensions.replace(rd.getSdpMessage().toString(), "\r\n", "\n"), _this.getId()));
                            promise.resolve(rd);
                        }, function (ex) {
                            promise.reject(ex);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setSignallingState = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.__signallingState, value))) {
                            this.__signallingState = value;
                            var onSignallingStateChange = this._onSignallingStateChange;
                            if ((!fm.icelink.Global.equals(onSignallingStateChange, null))) {
                                try {
                                    onSignallingStateChange(this.getInstance());
                                }
                                catch (exception) {
                                    fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising signalling state change to the application code for connection {0}.", this.getId()), exception);
                                }
                                finally {
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setState = function () {
                    if (arguments.length == 1) {
                        var state = arguments[0];
                        return this.setState(state, null);
                    }
                    else if (arguments.length == 2) {
                        var state = arguments[0];
                        var error = arguments[1];
                        var flag = false;
                        if (((fm.icelink.Global.equals(state, fm.icelink.ConnectionState.Failing)) && (fm.icelink.Global.equals(error, null)))) {
                            throw new fm.icelink.Exception("Transitioning to the failing state requires an error.");
                        }
                        if (((!fm.icelink.Global.equals(state, fm.icelink.ConnectionState.Failing)) && (!fm.icelink.Global.equals(error, null)))) {
                            throw new fm.icelink.Exception("An error can only be specified when transitioning to the failing state.");
                        }
                        if (!this.__stateMachine.transition(state)) {
                            if (((!fm.icelink.Global.equals(state, this.getState())) && ((!fm.icelink.Global.equals(state, fm.icelink.ConnectionState.Closing)) || ((!fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Closed)) && (!fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Failed)))))) {
                                this.logInvalidStateTransition(state);
                            }
                            return false;
                        }
                        if ((!fm.icelink.Global.equals(error, null))) {
                            this.setError(error);
                        }
                        var idValue = this.getId();
                        var externalId = this.getExternalId();
                        if ((!fm.icelink.Global.equals(externalId, null))) {
                            idValue = fm.icelink.StringExtensions.format("{0} (external ID {1})", idValue, externalId);
                        }
                        flag = (fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Connecting));
                        if (fm.icelink.Log.getIsInfoEnabled()) {
                            if ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Connecting))) {
                                fm.icelink.Log.info(fm.icelink.StringExtensions.format("Connection {0} took {1}ms to initialize (offer/answer signalling).", this.getId(), fm.icelink.NumberExtensions.toString(this.__stateMachine.getLastStateMillis())));
                            }
                            else {
                                if ((fm.icelink.Global.equals(this.getState(), fm.icelink.ConnectionState.Connected))) {
                                    fm.icelink.Log.info(fm.icelink.StringExtensions.format("Connection {0} took {1}ms to connect (connectivity checks and secure key exchange).", this.getId(), fm.icelink.NumberExtensions.toString(this.__stateMachine.getLastStateMillis())));
                                }
                            }
                            var description = null;
                            if ((!fm.icelink.Global.equals(error, null))) {
                                description = error.getDescription();
                            }
                            if ((fm.icelink.Global.equals(description, null))) {
                                fm.icelink.Log.info(fm.icelink.StringExtensions.format("Setting connection {0} state to {1}.", idValue, fm.icelink.StringExtensions.toLower(new fm.icelink.ConnectionStateWrapper(this.getState()).toString())));
                            }
                            else {
                                fm.icelink.Log.info(fm.icelink.StringExtensions.format("Setting connection {0} state to {1}. Error: {2}", idValue, fm.icelink.StringExtensions.toLower(new fm.icelink.ConnectionStateWrapper(this.getState()).toString()), description));
                            }
                        }
                        this.raiseStateChange();
                        this.processStateChange();
                        if (flag) {
                            this.raiseCachedCandidates();
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setTieBreaker = function (value) {
                    if (arguments.length == 1) {
                        this._tieBreaker = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setTimeout = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._timeout = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setTrickleIcePolicy = function (value) {
                    if (arguments.length == 1) {
                        this.__trickleIcePolicy = value;
                        if ((fm.icelink.Global.equals(value, fm.icelink.TrickleIcePolicy.FullTrickle))) {
                            this.setUseTrickleIce(true);
                        }
                        else {
                            if ((fm.icelink.Global.equals(value, fm.icelink.TrickleIcePolicy.NotSupported))) {
                                this.setUseTrickleIce(false);
                            }
                            else {
                                if ((fm.icelink.Global.equals(value, fm.icelink.TrickleIcePolicy.HalfTrickle))) {
                                    this.setUseTrickleIce(false);
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.setUseTrickleIce = function (value) {
                    if (arguments.length == 1) {
                        this.__useTrickleIce = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.unregisterStreamWithSessionDescriptionManager = function (stream) {
                    if (arguments.length == 1) {
                        this.getSessionDescriptionManager().removeStream(stream);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.updateBundlePolicy = function (policy) {
                    if (arguments.length == 1) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.updateRemoteCandidateIndex = function (candidate) {
                    if (arguments.length == 1) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.updateRemoteDescriptionDtlsRole = function (remoteDescription) {
                    if (arguments.length == 1) {
                        if (((((!fm.icelink.Global.equals(remoteDescription, null)) && (!fm.icelink.Global.equals(remoteDescription.getSdpMessage(), null))) && ((!remoteDescription.getIsOffer() && (!fm.icelink.Global.equals(this.__localDTLSRole, null))) && (!fm.icelink.Global.equals(this.__remoteDTLSRole, null)))) && (fm.icelink.Global.equals(this.dtlsRole(remoteDescription), fm.icelink.sdp.Setup.getActPass())))) {
                            var setup = this.__remoteDTLSRole.getSetup();
                            if ((fm.icelink.Global.equals(setup, fm.icelink.sdp.Setup.getActPass()))) {
                                if ((fm.icelink.Global.equals(this.__localDTLSRole.getSetup(), fm.icelink.sdp.Setup.getPassive()))) {
                                    setup = fm.icelink.sdp.Setup.getActive();
                                }
                                else {
                                    setup = fm.icelink.sdp.Setup.getPassive();
                                }
                            }
                            var sdpMessage = remoteDescription.getSdpMessage();
                            sdpMessage.updateSetupValue(setup);
                            for (var _i = 0, _a = sdpMessage.getMediaDescriptions(); _i < _a.length; _i++) {
                                var description = _a[_i];
                                var attribute = new fm.icelink.sdp.SetupAttribute(setup);
                                description.setSetupAttribute(attribute);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcConnectionBase.prototype.verifySessionIdAndVersion = function (remoteDescription) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.getRemoteDescription(), null))) {
                            var sessionId = this.getRemoteDescription().getSessionId();
                            var num2 = remoteDescription.getSessionId();
                            var sessionVersion = this.getRemoteDescription().getSessionVersion();
                            var num4 = remoteDescription.getSessionVersion();
                            if ((!fm.icelink.Global.equals(sessionId, num2))) {
                                throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Received new remote description with session id {0} and session version {1}, but current remote description has id {2} and version {3}. Cannot set remote description.", [fm.icelink.NumberExtensions.toString(num2), fm.icelink.NumberExtensions.toString(num4), fm.icelink.NumberExtensions.toString(sessionId), fm.icelink.NumberExtensions.toString(sessionVersion)]));
                            }
                            if ((sessionVersion >= num4)) {
                                throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Received new remote description with session id {0} and session version {1}, but current remote description has id {2} and version {3}. Cannot set remote description.", [fm.icelink.NumberExtensions.toString(num2), fm.icelink.NumberExtensions.toString(num4), fm.icelink.NumberExtensions.toString(sessionId), fm.icelink.NumberExtensions.toString(sessionVersion)]));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebRtcConnectionBase;
            }(fm.icelink.Dynamic));
            icelink.WebRtcConnectionBase = WebRtcConnectionBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ConnectionCollection =  (function (_super) {
                __extends(ConnectionCollection, _super);
                function ConnectionCollection() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.__lookupByExternalId = {};
                        _this.__lookupByInternalId = {};
                        _this.__lookupLock = new Object();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                ConnectionCollection.prototype.getTypeString = function () {
                    return '[fm.icelink.ConnectionCollection]' + ',' + _super.prototype.getTypeString.call(this);
                };
                ConnectionCollection.prototype.addSuccess = function (value) {
                    if (arguments.length == 1) {
                        _super.prototype.addSuccess.call(this, value);
                        this.__lookupByInternalId[value.getId()] = value;
                        var externalId = value.getExternalId();
                        if ((!fm.icelink.Global.equals(externalId, null))) {
                            this.__lookupByExternalId[externalId] = value;
                        }
                        value.removeOnExternalIdChange(this.processExternalIdChange.bind(this));
                        value.addOnExternalIdChange(this.processExternalIdChange.bind(this));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionCollection.prototype.arrayFromList = function (list) {
                    if (arguments.length == 1) {
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionCollection.prototype.createCollection = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.ConnectionCollection();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionCollection.prototype.getByExternalId = function (idValue) {
                    if (arguments.length == 1) {
                        var connection = null;
                        var _var0 = new fm.icelink.Holder(connection);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__lookupByExternalId, idValue, _var0);
                        connection = _var0.getValue();
                        if (_var1) {
                            return connection;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionCollection.prototype.getById = function (idValue) {
                    if (arguments.length == 1) {
                        var connection = null;
                        var _var0 = new fm.icelink.Holder(connection);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__lookupByInternalId, idValue, _var0);
                        connection = _var0.getValue();
                        if (_var1) {
                            return connection;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionCollection.prototype.processExternalIdChange = function (internalId, oldExternalId) {
                    if (arguments.length == 2) {
                        var connection = null;
                        var _var0 = new fm.icelink.Holder(connection);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__lookupByInternalId, internalId, _var0);
                        connection = _var0.getValue();
                        if (_var1) {
                            var externalId = connection.getExternalId();
                            if ((!fm.icelink.Global.equals(oldExternalId, null))) {
                                fm.icelink.HashExtensions.remove(this.__lookupByExternalId, oldExternalId);
                            }
                            this.__lookupByExternalId[externalId] = connection;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionCollection.prototype.removeSuccess = function (value) {
                    if (arguments.length == 1) {
                        _super.prototype.removeSuccess.call(this, value);
                        fm.icelink.HashExtensions.remove(this.__lookupByInternalId, value.getId());
                        var externalId = value.getExternalId();
                        if ((!fm.icelink.Global.equals(externalId, null))) {
                            fm.icelink.HashExtensions.remove(this.__lookupByExternalId, externalId);
                        }
                        value.removeOnExternalIdChange(this.processExternalIdChange.bind(this));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionCollection.prototype.tryGetByExternalId = function (idValue, connection) {
                    if (arguments.length == 2) {
                        var _var0 = fm.icelink.HashExtensions.tryGetValue(this.__lookupByExternalId, idValue, connection);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionCollection.prototype.tryGetById = function (idValue, connection) {
                    if (arguments.length == 2) {
                        var _var0 = fm.icelink.HashExtensions.tryGetValue(this.__lookupByInternalId, idValue, connection);
                        return _var0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ConnectionCollection;
            }(fm.icelink.Collection));
            icelink.ConnectionCollection = ConnectionCollection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataChannelStateMachine =  (function (_super) {
                __extends(DataChannelStateMachine, _super);
                function DataChannelStateMachine() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this, fm.icelink.DataChannelState.New) || this;
                        _super.prototype.addTransition.call(_this, fm.icelink.DataChannelState.New, fm.icelink.DataChannelState.Connecting);
                        _super.prototype.addTransition.call(_this, fm.icelink.DataChannelState.New, fm.icelink.DataChannelState.Failed);
                        _super.prototype.addTransition.call(_this, fm.icelink.DataChannelState.New, fm.icelink.DataChannelState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.DataChannelState.Connecting, fm.icelink.DataChannelState.Connected);
                        _super.prototype.addTransition.call(_this, fm.icelink.DataChannelState.Connecting, fm.icelink.DataChannelState.Failed);
                        _super.prototype.addTransition.call(_this, fm.icelink.DataChannelState.Connecting, fm.icelink.DataChannelState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.DataChannelState.Connected, fm.icelink.DataChannelState.Failed);
                        _super.prototype.addTransition.call(_this, fm.icelink.DataChannelState.Connected, fm.icelink.DataChannelState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.DataChannelState.Closing, fm.icelink.DataChannelState.Failed);
                        _super.prototype.addTransition.call(_this, fm.icelink.DataChannelState.Closing, fm.icelink.DataChannelState.Closed);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                DataChannelStateMachine.prototype.getTypeString = function () {
                    return '[fm.icelink.DataChannelStateMachine]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DataChannelStateMachine.prototype.stateToValue = function (state) {
                    if (arguments.length == 1) {
                        return state;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStateMachine.prototype.valueToState = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        return value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataChannelStateMachine;
            }(fm.icelink.StateMachine));
            icelink.DataChannelStateMachine = DataChannelStateMachine;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StreamStateMachine =  (function (_super) {
                __extends(StreamStateMachine, _super);
                function StreamStateMachine() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this, fm.icelink.StreamState.New) || this;
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.New, fm.icelink.StreamState.Initializing);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.New, fm.icelink.StreamState.Failing);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.New, fm.icelink.StreamState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Initializing, fm.icelink.StreamState.Connecting);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Initializing, fm.icelink.StreamState.Failing);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Initializing, fm.icelink.StreamState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Connecting, fm.icelink.StreamState.Connected);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Connecting, fm.icelink.StreamState.Failing);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Connecting, fm.icelink.StreamState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Connected, fm.icelink.StreamState.Failing);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Connected, fm.icelink.StreamState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Closing, fm.icelink.StreamState.Failing);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Closing, fm.icelink.StreamState.Closed);
                        _super.prototype.addTransition.call(_this, fm.icelink.StreamState.Failing, fm.icelink.StreamState.Failed);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                StreamStateMachine.prototype.getTypeString = function () {
                    return '[fm.icelink.StreamStateMachine]' + ',' + _super.prototype.getTypeString.call(this);
                };
                StreamStateMachine.prototype.stateToValue = function (state) {
                    if (arguments.length == 1) {
                        return state;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStateMachine.prototype.valueToState = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        return value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StreamStateMachine;
            }(fm.icelink.StateMachine));
            icelink.StreamStateMachine = StreamStateMachine;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ConnectionStateMachine =  (function (_super) {
                __extends(ConnectionStateMachine, _super);
                function ConnectionStateMachine() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this, fm.icelink.ConnectionState.New) || this;
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.New, fm.icelink.ConnectionState.Initializing);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.New, fm.icelink.ConnectionState.Failing);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.New, fm.icelink.ConnectionState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Initializing, fm.icelink.ConnectionState.Connecting);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Initializing, fm.icelink.ConnectionState.Failing);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Initializing, fm.icelink.ConnectionState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Connecting, fm.icelink.ConnectionState.Connected);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Connecting, fm.icelink.ConnectionState.Failing);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Connecting, fm.icelink.ConnectionState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Connected, fm.icelink.ConnectionState.Failing);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Connected, fm.icelink.ConnectionState.Closing);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Closing, fm.icelink.ConnectionState.Failing);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Closing, fm.icelink.ConnectionState.Closed);
                        _super.prototype.addTransition.call(_this, fm.icelink.ConnectionState.Failing, fm.icelink.ConnectionState.Failed);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                ConnectionStateMachine.prototype.getTypeString = function () {
                    return '[fm.icelink.ConnectionStateMachine]' + ',' + _super.prototype.getTypeString.call(this);
                };
                ConnectionStateMachine.prototype.stateToValue = function (state) {
                    if (arguments.length == 1) {
                        return state;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStateMachine.prototype.valueToState = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        return value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ConnectionStateMachine;
            }(fm.icelink.StateMachine));
            icelink.ConnectionStateMachine = ConnectionStateMachine;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcDataChannelBase =  (function (_super) {
                __extends(WebRtcDataChannelBase, _super);
                function WebRtcDataChannelBase(label, ordered, subprotocol) {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 3) {
                        var label_3 = __arguments[0];
                        var ordered_1 = __arguments[1];
                        var subprotocol_1 = __arguments[2];
                        _this = _super.call(this) || this;
                        _this.fmicelinkWebRtcDataChannelBaseInit();
                        _this.__log = fm.icelink.Log.getLogger(new fm.icelink.Type('[fm.icelink.DataChannel]'));
                        _this.__id = fm.icelink.Utility.generateId();
                        _this.__stateLock = new Object();
                        _this.__messagesSent = new fm.icelink.AtomicLong();
                        _this.__messagesReceived = new fm.icelink.AtomicLong();
                        _this.__bytesSent = new fm.icelink.AtomicLong();
                        _this.__bytesReceived = new fm.icelink.AtomicLong();
                        _this.setLabel(label_3);
                        _this.setOrdered(ordered_1);
                        _this.setSubprotocol(subprotocol_1);
                        _this.__stateMachine = new fm.icelink.DataChannelStateMachine();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebRtcDataChannelBase.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcDataChannelBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcDataChannelBase.prototype.fmicelinkWebRtcDataChannelBaseInit = function () {
                    var _this = this;
                    this.__onDataReceived = [];
                    this.__onDataSent = [];
                    this.__onStateChange = [];
                    this._onDataReceived = function (p0) { for (var _i = 0, _a = _this.__onDataReceived; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0);
                    } };
                    this._onDataSent = function (p0) { for (var _i = 0, _a = _this.__onDataSent; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0);
                    } };
                    this._onStateChange = function (p0) { for (var _i = 0, _a = _this.__onStateChange; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0);
                    } };
                    this._ordered = false;
                };
                WebRtcDataChannelBase.prototype.addOnDataReceived = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onDataReceived, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.addOnDataSent = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onDataSent, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.addOnStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getBytesReceived = function () {
                    if (arguments.length == 0) {
                        return this.__bytesReceived.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getBytesSent = function () {
                    if (arguments.length == 0) {
                        return this.__bytesSent.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getConnectionId = function () {
                    if (arguments.length == 0) {
                        return this._connectionId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getGetRemoteConnectionInfo = function () {
                    if (arguments.length == 0) {
                        return this._getRemoteConnectionInfo;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this.__id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getInfo = function () {
                    if (arguments.length == 0) {
                        var info = new fm.icelink.DataChannelInfo();
                        info.setId(this.getId());
                        info.setLabel(this.getLabel());
                        info.setOrdered(this.getOrdered());
                        info.setSubprotocol(this.getSubprotocol());
                        return info;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getIsTerminated = function () {
                    if (arguments.length == 0) {
                        return ((fm.icelink.Global.equals(this.getState(), fm.icelink.DataChannelState.Closed)) || (fm.icelink.Global.equals(this.getState(), fm.icelink.DataChannelState.Failed)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getIsTerminating = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.Global.equals(this.getState(), fm.icelink.DataChannelState.Closing));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getIsTerminatingOrTerminated = function () {
                    if (arguments.length == 0) {
                        return (this.getIsTerminating() || this.getIsTerminated());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getLabel = function () {
                    if (arguments.length == 0) {
                        return this._label;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getMessagesReceived = function () {
                    if (arguments.length == 0) {
                        return this.__messagesReceived.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getMessagesSent = function () {
                    if (arguments.length == 0) {
                        return this.__messagesSent.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getOnReceive = function () {
                    if (arguments.length == 0) {
                        return this._onReceive;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getOrdered = function () {
                    if (arguments.length == 0) {
                        return this._ordered;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getState = function () {
                    if (arguments.length == 0) {
                        return this.__stateMachine.getState();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getStateLock = function () {
                    if (arguments.length == 0) {
                        return this.__stateLock;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getStreamId = function () {
                    if (arguments.length == 0) {
                        return this._streamId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.getSubprotocol = function () {
                    if (arguments.length == 0) {
                        return this._subprotocol;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.logInvalidStateTransition = function (state) {
                    if (arguments.length == 1) {
                        if (fm.icelink.Log.getIsDebugEnabled()) {
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Data channel {0} ({1}) state for stream {2} for connection {3} is currently {4}. Cannot transition to {5} state.", [this.getId(), this.getLabel(), this.getStreamId(), this.getConnectionId(), fm.icelink.StringExtensions.toLower(new fm.icelink.DataChannelStateWrapper(this.getState()).toString()), fm.icelink.StringExtensions.toLower(new fm.icelink.DataChannelStateWrapper(state).toString())]));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.prepareAndSendMessage = function () {
                    if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataBuffer]'))) {
                        var buffer = arguments[0];
                        var promise = arguments[1];
                        var length_35 = buffer.getLength();
                        this.promisedSendDataBytes(buffer, length_35, promise);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var msg = arguments[0];
                        var promise = arguments[1];
                        var length_36 = fm.icelink.Utf8.encode(msg).length;
                        this.promisedSendDataString(msg, length_36, promise);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.processStateChange = function () {
                    if (arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.processStateLockChange = function () {
                    if (arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.raiseDataBytes = function (dataBytes) {
                    if (arguments.length == 1) {
                        this.registerDataReceived(dataBytes.getLength());
                        var onReceive = this.getOnReceive();
                        if ((!fm.icelink.Global.equals(onReceive, null))) {
                            var p = new fm.icelink.DataChannelReceiveArgs();
                            p.setDataBytes(dataBytes);
                            onReceive(p);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.raiseDataString = function (dataString) {
                    if (arguments.length == 1) {
                        this.registerDataReceived(fm.icelink.Utf8.encode(dataString).length);
                        var onReceive = this.getOnReceive();
                        if ((!fm.icelink.Global.equals(onReceive, null))) {
                            var p = new fm.icelink.DataChannelReceiveArgs();
                            p.setDataString(dataString);
                            onReceive(p);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.raiseStateChange = function () {
                    if (arguments.length == 0) {
                        var onStateChange = this._onStateChange;
                        if ((!fm.icelink.Global.equals(onStateChange, null))) {
                            try {
                                onStateChange(this.getInstance());
                            }
                            catch (exception) {
                                fm.icelink.Log.error(fm.icelink.StringExtensions.format("Exception occurred while raising state change to the application code for data stream {0}.", this.getId()), exception);
                            }
                            finally {
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.registerDataReceived = function (dataLength) {
                    if (arguments.length == 1) {
                        dataLength = fm.icelink.Global.toInt(arguments[0]);
                        var onDataReceived = this._onDataReceived;
                        if ((!fm.icelink.Global.equals(onDataReceived, null))) {
                            onDataReceived(dataLength);
                        }
                        this.__messagesReceived.increment();
                        this.__bytesReceived.add(dataLength);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.registerDataSent = function (dataLength) {
                    if (arguments.length == 1) {
                        dataLength = fm.icelink.Global.toInt(arguments[0]);
                        var onDataSent = this._onDataSent;
                        if ((!fm.icelink.Global.equals(onDataSent, null))) {
                            onDataSent(dataLength);
                        }
                        this.__messagesSent.increment();
                        this.__bytesSent.add(dataLength);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.removeOnDataReceived = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onDataReceived, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.removeOnDataSent = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onDataSent, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.removeOnStateChange = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onStateChange, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.setConnectionId = function (value) {
                    if (arguments.length == 1) {
                        this._connectionId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.setGetRemoteConnectionInfo = function (value) {
                    if (arguments.length == 1) {
                        this._getRemoteConnectionInfo = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.setLabel = function (value) {
                    if (arguments.length == 1) {
                        this._label = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.setOnReceive = function (value) {
                    if (arguments.length == 1) {
                        this._onReceive = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.setOrdered = function (value) {
                    if (arguments.length == 1) {
                        this._ordered = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.setState = function (state) {
                    if (arguments.length == 1) {
                        if (!this.__stateMachine.transition(state)) {
                            if (((!fm.icelink.Global.equals(state, this.getState())) && ((!fm.icelink.Global.equals(state, fm.icelink.DataChannelState.Closing)) || ((!fm.icelink.Global.equals(this.getState(), fm.icelink.DataChannelState.Closed)) && (!fm.icelink.Global.equals(this.getState(), fm.icelink.DataChannelState.Failed)))))) {
                                this.logInvalidStateTransition(state);
                            }
                            return false;
                        }
                        if (fm.icelink.Log.getIsInfoEnabled()) {
                            if ((fm.icelink.Global.equals(this.getState(), fm.icelink.DataChannelState.Connected))) {
                                fm.icelink.Log.info(fm.icelink.StringExtensions.format("Data channel {0} ({1} for stream {2} for connection {3} took {4}ms to connect.", [this.getId(), this.getLabel(), this.getStreamId(), this.getConnectionId(), fm.icelink.NumberExtensions.toString(this.__stateMachine.getLastStateMillis())]));
                            }
                            fm.icelink.Log.info(fm.icelink.StringExtensions.format("Setting data channel {0} ({1}) state for stream {2} for connection {3} to {4}.", [this.getId(), this.getLabel(), this.getStreamId(), this.getConnectionId(), fm.icelink.StringExtensions.toLower(new fm.icelink.DataChannelStateWrapper(this.getState()).toString())]));
                        }
                        this.raiseStateChange();
                        this.processStateChange();
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.setStateLock = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.__stateLock, value))) {
                            this.__stateLock = value;
                            this.processStateLockChange();
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.setStreamId = function (value) {
                    if (arguments.length == 1) {
                        this._streamId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataChannelBase.prototype.setSubprotocol = function (value) {
                    if (arguments.length == 1) {
                        this._subprotocol = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebRtcDataChannelBase;
            }(fm.icelink.Dynamic));
            icelink.WebRtcDataChannelBase = WebRtcDataChannelBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataChannelCollection =  (function (_super) {
                __extends(DataChannelCollection, _super);
                function DataChannelCollection() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                DataChannelCollection.prototype.getTypeString = function () {
                    return '[fm.icelink.DataChannelCollection]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DataChannelCollection.prototype.arrayFromList = function (list) {
                    if (arguments.length == 1) {
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelCollection.prototype.createCollection = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.DataChannelCollection();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataChannelCollection;
            }(fm.icelink.Collection));
            icelink.DataChannelCollection = DataChannelCollection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataChannelReceiveArgs =  (function () {
                function DataChannelReceiveArgs() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                DataChannelReceiveArgs.prototype.getTypeString = function () {
                    return '[fm.icelink.DataChannelReceiveArgs]';
                };
                DataChannelReceiveArgs.prototype.getDataBytes = function () {
                    if (arguments.length == 0) {
                        return this._dataBytes;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelReceiveArgs.prototype.getDataString = function () {
                    if (arguments.length == 0) {
                        return this._dataString;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelReceiveArgs.prototype.setDataBytes = function (value) {
                    if (arguments.length == 1) {
                        this._dataBytes = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelReceiveArgs.prototype.setDataString = function (value) {
                    if (arguments.length == 1) {
                        this._dataString = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelReceiveArgs.prototype.setRemoteConnectionInfo = function (remoteConnectionInfo) {
                    if (arguments.length == 1) {
                        this.__remoteConnectionInfo = remoteConnectionInfo;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataChannelReceiveArgs;
            }());
            icelink.DataChannelReceiveArgs = DataChannelReceiveArgs;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcDataStreamBase =  (function (_super) {
                __extends(WebRtcDataStreamBase, _super);
                function WebRtcDataStreamBase() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this, fm.icelink.StreamType.Application) || this;
                        _this.__messagesSent = new fm.icelink.AtomicLong();
                        _this.__messagesReceived = new fm.icelink.AtomicLong();
                        _this.__bytesSent = new fm.icelink.AtomicLong();
                        _this.__bytesReceived = new fm.icelink.AtomicLong();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebRtcDataStreamBase.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcDataStreamBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcDataStreamBase.prototype.attachToChannel = function (channel) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(channel.getStreamId(), null))) {
                            channel.setStreamId(_super.prototype.getId.call(this));
                            channel.removeOnDataSent(this.registerDataSent.bind(this));
                            channel.addOnDataSent(this.registerDataSent.bind(this));
                            channel.removeOnDataReceived(this.registerDataReceived.bind(this));
                            channel.addOnDataReceived(this.registerDataReceived.bind(this));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.changeDirection = function (newDirection) {
                    if (arguments.length == 1) {
                        return new fm.icelink.Error(fm.icelink.ErrorCode.DataStreamDirectionCannotBeChanged, new fm.icelink.Exception("Changes to Stream Direction of Data Streams are not permitted."));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getBytesReceived = function () {
                    if (arguments.length == 0) {
                        return this.__bytesReceived.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getBytesSent = function () {
                    if (arguments.length == 0) {
                        return this.__bytesSent.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getCanonicalName = function () {
                    if (arguments.length == 0) {
                        fm.icelink.Log.warn("Getting the value of DataStream.CanonicalName is deprecated and will be removed in a future release.");
                        return this.__obsoleteCanonicalName;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getDirection = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StreamDirection.SendReceive;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getDirectionCapabilities = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StreamDirection.SendReceive;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getGetRemoteConnectionInfo = function () {
                    if (arguments.length == 0) {
                        return this.__getRemoteConnectionInfo;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getInfo = function () {
                    if (arguments.length == 0) {
                        var list = new Array();
                        for (var _i = 0, _a = this.getChannels(); _i < _a.length; _i++) {
                            var local = _a[_i];
                            fm.icelink.ArrayExtensions.add(list, local.getInfo());
                        }
                        var info = new fm.icelink.DataStreamInfo();
                        info.setId(_super.prototype.getId.call(this));
                        info.setTag(_super.prototype.getTag.call(this));
                        info.setChannels(fm.icelink.ArrayExtensions.toArray(list));
                        return info;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getLabel = function () {
                    if (arguments.length == 0) {
                        return "Data Stream";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getLocalDirection = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StreamDirection.SendReceive;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getMessagesReceived = function () {
                    if (arguments.length == 0) {
                        return this.__messagesReceived.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getMessagesSent = function () {
                    if (arguments.length == 0) {
                        return this.__messagesSent.getValue();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.getRemoteDirection = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StreamDirection.SendReceive;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.processStateChange = function () {
                    if (arguments.length == 0) {
                        _super.prototype.processStateChange.call(this);
                        var channels = this.getChannels();
                        if ((!fm.icelink.Global.equals(channels, null))) {
                            for (var _i = 0, channels_1 = channels; _i < channels_1.length; _i++) {
                                var local = channels_1[_i];
                                if ((fm.icelink.Global.equals(_super.prototype.getState.call(this), fm.icelink.StreamState.Closing))) {
                                    local.setState(fm.icelink.DataChannelState.Closing);
                                }
                                else {
                                    if ((fm.icelink.Global.equals(_super.prototype.getState.call(this), fm.icelink.StreamState.Closed))) {
                                        local.setState(fm.icelink.DataChannelState.Closed);
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(_super.prototype.getState.call(this), fm.icelink.StreamState.Failed))) {
                                            local.setState(fm.icelink.DataChannelState.Failed);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.processStateLockChange = function () {
                    if (arguments.length == 0) {
                        _super.prototype.processStateLockChange.call(this);
                        var channels = this.getChannels();
                        if ((!fm.icelink.Global.equals(channels, null))) {
                            for (var _i = 0, channels_2 = channels; _i < channels_2.length; _i++) {
                                var local = channels_2[_i];
                                this.attachToChannel(local);
                                local.setConnectionId(_super.prototype.getConnectionId.call(this));
                                local.setStateLock(_super.prototype.getStateLock.call(this));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.registerDataReceived = function (dataLength) {
                    if (arguments.length == 1) {
                        dataLength = fm.icelink.Global.toInt(arguments[0]);
                        this.__messagesReceived.increment();
                        this.__bytesReceived.add(dataLength);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.registerDataSent = function (dataLength) {
                    if (arguments.length == 1) {
                        dataLength = fm.icelink.Global.toInt(arguments[0]);
                        this.__messagesSent.increment();
                        this.__bytesSent.add(dataLength);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.setCanonicalName = function (canonicalName) {
                    if (arguments.length == 1) {
                        this.__obsoleteCanonicalName = canonicalName;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.setGetRemoteConnectionInfo = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.__getRemoteConnectionInfo, value))) {
                            this.__getRemoteConnectionInfo = value;
                            for (var _i = 0, _a = this.getChannels(); _i < _a.length; _i++) {
                                var local = _a[_i];
                                local.setGetRemoteConnectionInfo(value);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.setLocalDirection = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(value, fm.icelink.StreamDirection.SendReceive))) {
                            throw new fm.icelink.Exception("Local direction other than SendReceive for DataStreams is not currently supported.");
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcDataStreamBase.prototype.setRemoteDirection = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(value, fm.icelink.StreamDirection.SendReceive))) {
                            throw new fm.icelink.Exception("Remote direction other than SendReceive for DataStreams is not currently supported.");
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebRtcDataStreamBase;
            }(fm.icelink.WebRtcStream));
            icelink.WebRtcDataStreamBase = WebRtcDataStreamBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (dtmf) {
                var Format =  (function (_super) {
                    __extends(Format, _super);
                    function Format() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            __arguments = new Array(1);
                            __arguments[0] = fm.icelink.dtmf.Format.getDefaultClockRate();
                            {
                                var clockRate = __arguments[0];
                                _this = _super.call(this, fm.icelink.AudioFormat.getDtmfName(), clockRate, 1) || this;
                                _super.prototype.setIsFixedBitrate.call(_this, true);
                                _super.prototype.setIsInjected.call(_this, true);
                            }
                        }
                        else if (__arguments.length == 1) {
                            var clockRate = __arguments[0];
                            _this = _super.call(this, fm.icelink.AudioFormat.getDtmfName(), clockRate, 1) || this;
                            _super.prototype.setIsFixedBitrate.call(_this, true);
                            _super.prototype.setIsInjected.call(_this, true);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Format.prototype.getTypeString = function () {
                        return '[fm.icelink.dtmf.Format]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    Format.getDefaultClockRate = function () {
                        if (arguments.length == 0) {
                            return 8000;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Format;
                }(fm.icelink.AudioFormat));
                dtmf.Format = Format;
            })(icelink.dtmf || (icelink.dtmf = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var EncryptionPolicyWrapper =  (function () {
                function EncryptionPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_26 = __arguments[0];
                        this._value = value_26;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                EncryptionPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.EncryptionPolicyWrapper]';
                };
                EncryptionPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.EncryptionPolicy.Required)
                            return 'Required';
                        if (this._value == fm.icelink.EncryptionPolicy.Negotiated)
                            return 'Negotiated';
                        if (this._value == fm.icelink.EncryptionPolicy.Disabled)
                            return 'Disabled';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return EncryptionPolicyWrapper;
            }());
            icelink.EncryptionPolicyWrapper = EncryptionPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (g711) {
                var Format =  (function (_super) {
                    __extends(Format, _super);
                    function Format(name, clockRate, channelCount) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 3) {
                            var name_17 = __arguments[0];
                            var clockRate_1 = __arguments[1];
                            var channelCount_1 = __arguments[2];
                            _this = _super.call(this, name_17, clockRate_1, channelCount_1) || this;
                            _super.prototype.setIsFixedBitrate.call(_this, true);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Format.prototype.getTypeString = function () {
                        return '[fm.icelink.g711.Format]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    Format.getDefaultChannelCount = function () {
                        if (arguments.length == 0) {
                            return 1;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.getDefaultClockRate = function () {
                        if (arguments.length == 0) {
                            return 8000;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.getDefaultConfig = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.AudioConfig(fm.icelink.g711.Format.getDefaultClockRate(), fm.icelink.g711.Format.getDefaultChannelCount());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getFixedBitrate = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.MathAssistant.floor(fm.icelink.MathAssistant.floor((((_super.prototype.getConfig.call(this).getClockRate() * _super.prototype.getConfig.call(this).getChannelCount()) * 2) * 8) / 2) / 1000);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMaxBitrate = function () {
                        if (arguments.length == 0) {
                            return this.getFixedBitrate();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMinBitrate = function () {
                        if (arguments.length == 0) {
                            return this.getFixedBitrate();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Format;
                }(fm.icelink.AudioFormat));
                g711.Format = Format;
            })(icelink.g711 || (icelink.g711 = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (h264) {
                var Format =  (function (_super) {
                    __extends(Format, _super);
                    function Format() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this, fm.icelink.VideoFormat.getH264Name()) || this;
                        }
                        else if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                            var clockRate = __arguments[0];
                            _this = _super.call(this, fm.icelink.VideoFormat.getH264Name(), clockRate) || this;
                        }
                        else if (__arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                            var clockRate = __arguments[0];
                            var packetizationMode = __arguments[1];
                            _this = _super.call(this, fm.icelink.VideoFormat.getH264Name(), clockRate, fm.icelink.NumberExtensions.toString(packetizationMode)) || this;
                        }
                        else if (__arguments.length == 4) {
                            var clockRate = __arguments[0];
                            var profile = __arguments[1];
                            var level = __arguments[2];
                            var packetizationMode = __arguments[3];
                            _this = _super.call(this, fm.icelink.VideoFormat.getH264Name(), clockRate, profile, level, fm.icelink.NumberExtensions.toString(packetizationMode)) || this;
                        }
                        else if (__arguments.length == 3 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0])) && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isObjectType(arguments[1], '[fm.icelink.h264.ProfileLevelId]'))) {
                            var clockRate = __arguments[0];
                            var profileLevelId = __arguments[1];
                            var packetizationMode = __arguments[2];
                            _this = _super.call(this, fm.icelink.VideoFormat.getH264Name(), clockRate, profileLevelId.getProfile(), profileLevelId.getLevel(), fm.icelink.NumberExtensions.toString(packetizationMode)) || this;
                        }
                        else if (__arguments.length == 3 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0])) && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isString(arguments[1]))) {
                            var profile = __arguments[0];
                            var level = __arguments[1];
                            var packetizationMode = __arguments[2];
                            _this = _super.call(this, fm.icelink.VideoFormat.getH264Name(), 90000, profile, level, fm.icelink.NumberExtensions.toString(packetizationMode)) || this;
                        }
                        else if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.h264.ProfileLevelId]'))) {
                            var profileLevelId = __arguments[0];
                            _this = _super.call(this, fm.icelink.VideoFormat.getH264Name(), 90000, profileLevelId.getProfile(), profileLevelId.getLevel()) || this;
                        }
                        else if (__arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.h264.ProfileLevelId]'))) {
                            var profileLevelId = __arguments[0];
                            var packetizationMode = __arguments[1];
                            _this = _super.call(this, fm.icelink.VideoFormat.getH264Name(), 90000, profileLevelId.getProfile(), profileLevelId.getLevel(), fm.icelink.NumberExtensions.toString(packetizationMode)) || this;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Format.prototype.getTypeString = function () {
                        return '[fm.icelink.h264.Format]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    Format.prototype.createInstance = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.h264.Format();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMaxBitrate = function () {
                        if (arguments.length == 0) {
                            return 100000;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMinBitrate = function () {
                        if (arguments.length == 0) {
                            return 100;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Format;
                }(fm.icelink.VideoFormat));
                h264.Format = Format;
            })(icelink.h264 || (icelink.h264 = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (h264) {
                var ProfileIop =  (function () {
                    function ProfileIop(profileIop) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var profileIop_1 = __arguments[0];
                            this.setDataBuffer(fm.icelink.DataBuffer.wrap(new Uint8Array([profileIop_1])));
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    ProfileIop.prototype.getTypeString = function () {
                        return '[fm.icelink.h264.ProfileIop]';
                    };
                    ProfileIop.prototype.getConstraintSet0 = function () {
                        if (arguments.length == 0) {
                            return this.getDataBuffer().read1(0, 0);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileIop.prototype.getConstraintSet1 = function () {
                        if (arguments.length == 0) {
                            return this.getDataBuffer().read1(0, 1);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileIop.prototype.getConstraintSet2 = function () {
                        if (arguments.length == 0) {
                            return this.getDataBuffer().read1(0, 2);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileIop.prototype.getDataBuffer = function () {
                        if (arguments.length == 0) {
                            return this._dataBuffer;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileIop.prototype.setConstraintSet0 = function (value) {
                        if (arguments.length == 1) {
                            this.getDataBuffer().write1(value, 0, 0);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileIop.prototype.setConstraintSet1 = function (value) {
                        if (arguments.length == 1) {
                            this.getDataBuffer().write1(value, 0, 1);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileIop.prototype.setConstraintSet2 = function (value) {
                        if (arguments.length == 1) {
                            this.getDataBuffer().write1(value, 0, 2);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileIop.prototype.setDataBuffer = function (value) {
                        if (arguments.length == 1) {
                            this._dataBuffer = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return ProfileIop;
                }());
                h264.ProfileIop = ProfileIop;
            })(icelink.h264 || (icelink.h264 = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (h264) {
                var ProfileLevelId =  (function () {
                    function ProfileLevelId() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            this.fmicelinkh264ProfileLevelIdInit();
                        }
                        else if (__arguments.length == 2) {
                            var profile = __arguments[0];
                            var level = __arguments[1];
                            this.fmicelinkh264ProfileLevelIdInit();
                            if ((fm.icelink.Global.equals(profile, null))) {
                                throw new fm.icelink.Exception("Cannot initialize with null profile.");
                            }
                            if ((fm.icelink.Global.equals(level, null))) {
                                throw new fm.icelink.Exception("Cannot initialize with null level.");
                            }
                            if ((!fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(profile), 4))) {
                                throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Invalid profile. (Length was {0} and should be 4.)", fm.icelink.NumberExtensions.toString(fm.icelink.StringExtensions.getLength(profile))));
                            }
                            if ((!fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(level), 2))) {
                                throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Invalid level. (Length was {0} and should be 2.)", fm.icelink.NumberExtensions.toString(fm.icelink.StringExtensions.getLength(level))));
                            }
                            var hexBytes = fm.icelink.BitAssistant.getHexBytes(profile);
                            var buffer2 = fm.icelink.BitAssistant.getHexBytes(level);
                            this.setProfileIdc(hexBytes[0]);
                            this.setProfileIop(new fm.icelink.h264.ProfileIop(hexBytes[1]));
                            this.setLevelIdc(buffer2[0]);
                        }
                        else if (__arguments.length == 3) {
                            var profileIdc = __arguments[0];
                            var profileIop = __arguments[1];
                            var levelIdc = __arguments[2];
                            this.fmicelinkh264ProfileLevelIdInit();
                            this.setProfileIdc(profileIdc);
                            this.setProfileIop(new fm.icelink.h264.ProfileIop(profileIop));
                            this.setLevelIdc(levelIdc);
                        }
                        else if (__arguments.length == 1) {
                            var profileLevelId = __arguments[0];
                            this.fmicelinkh264ProfileLevelIdInit();
                            if ((fm.icelink.Global.equals(profileLevelId, null))) {
                                throw new fm.icelink.Exception("Cannot initialize with null profile level ID.");
                            }
                            if ((!fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(profileLevelId), 6))) {
                                throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Invalid profile level ID. (Length was {0} and should be 6.)", fm.icelink.NumberExtensions.toString(fm.icelink.StringExtensions.getLength(profileLevelId))));
                            }
                            var hexBytes = fm.icelink.BitAssistant.getHexBytes(fm.icelink.StringExtensions.substring(profileLevelId, 0, 2));
                            var buffer2 = fm.icelink.BitAssistant.getHexBytes(fm.icelink.StringExtensions.substring(profileLevelId, 2, 2));
                            var buffer3 = fm.icelink.BitAssistant.getHexBytes(fm.icelink.StringExtensions.substring(profileLevelId, 4, 2));
                            this.setProfileIdc(hexBytes[0]);
                            this.setProfileIop(new fm.icelink.h264.ProfileIop(buffer2[0]));
                            this.setLevelIdc(buffer3[0]);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    ProfileLevelId.prototype.getTypeString = function () {
                        return '[fm.icelink.h264.ProfileLevelId]';
                    };
                    ProfileLevelId.prototype.fmicelinkh264ProfileLevelIdInit = function () {
                        this._levelIdc = 0;
                        this._profileIdc = 0;
                    };
                    ProfileLevelId.getBaselineLevel10 = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.h264.ProfileLevelId(66, 0, 10);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.getBaselineLevel31 = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.h264.ProfileLevelId(66, 0, 31);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.getConstrainedBaselineLevel10 = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.h264.ProfileLevelId(66, 224, 10);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.getConstrainedBaselineLevel31 = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.h264.ProfileLevelId(66, 224, 31);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.getDefault = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.h264.ProfileLevelId.getConstrainedBaselineLevel31();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.getHighLevel50 = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.h264.ProfileLevelId(100, 0, 50);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.getMainLevel50 = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.h264.ProfileLevelId(77, 0, 50);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.prototype.getLevel = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.StringExtensions.substring(this.toString(), 4, 2);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.prototype.getLevelIdc = function () {
                        if (arguments.length == 0) {
                            return this._levelIdc;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.prototype.getMaxEncoding = function () {
                        if (arguments.length == 0) {
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "0a", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info = new fm.icelink.EncodingInfo();
                                info.setBitrate(64);
                                info.setFrameRate(15);
                                info.setSize(new fm.icelink.Size(176, 144));
                                return info;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "0b", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info2 = new fm.icelink.EncodingInfo();
                                info2.setBitrate(192);
                                info2.setFrameRate(7.5);
                                info2.setSize(new fm.icelink.Size(352, 288));
                                return info2;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "0c", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info3 = new fm.icelink.EncodingInfo();
                                info3.setBitrate(384);
                                info3.setFrameRate(15.2);
                                info3.setSize(new fm.icelink.Size(352, 288));
                                return info3;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "0d", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info4 = new fm.icelink.EncodingInfo();
                                info4.setBitrate(768);
                                info4.setFrameRate(30);
                                info4.setSize(new fm.icelink.Size(352, 288));
                                return info4;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "14", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info5 = new fm.icelink.EncodingInfo();
                                info5.setBitrate(2000);
                                info5.setFrameRate(30);
                                info5.setSize(new fm.icelink.Size(352, 288));
                                return info5;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "15", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info6 = new fm.icelink.EncodingInfo();
                                info6.setBitrate(4000);
                                info6.setFrameRate(25);
                                info6.setSize(new fm.icelink.Size(352, 576));
                                return info6;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "16", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info7 = new fm.icelink.EncodingInfo();
                                info7.setBitrate(4000);
                                info7.setFrameRate(12.5);
                                info7.setSize(new fm.icelink.Size(720, 576));
                                return info7;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "1e", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info8 = new fm.icelink.EncodingInfo();
                                info8.setBitrate(10000);
                                info8.setFrameRate(25);
                                info8.setSize(new fm.icelink.Size(720, 576));
                                return info8;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "1f", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info9 = new fm.icelink.EncodingInfo();
                                info9.setBitrate(14000);
                                info9.setFrameRate(30);
                                info9.setSize(new fm.icelink.Size(1280, 720));
                                return info9;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "20", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info10 = new fm.icelink.EncodingInfo();
                                info10.setBitrate(20000);
                                info10.setFrameRate(42.2);
                                info10.setSize(new fm.icelink.Size(1280, 1024));
                                return info10;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "28", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info11 = new fm.icelink.EncodingInfo();
                                info11.setBitrate(20000);
                                info11.setFrameRate(30);
                                info11.setSize(new fm.icelink.Size(2048, 1024));
                                return info11;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "29", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info12 = new fm.icelink.EncodingInfo();
                                info12.setBitrate(50000);
                                info12.setFrameRate(30);
                                info12.setSize(new fm.icelink.Size(2048, 1024));
                                return info12;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "2a", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info13 = new fm.icelink.EncodingInfo();
                                info13.setBitrate(50000);
                                info13.setFrameRate(60);
                                info13.setSize(new fm.icelink.Size(2048, 1080));
                                return info13;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "32", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info14 = new fm.icelink.EncodingInfo();
                                info14.setBitrate(135000);
                                info14.setFrameRate(26.7);
                                info14.setSize(new fm.icelink.Size(3672, 1536));
                                return info14;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "33", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info15 = new fm.icelink.EncodingInfo();
                                info15.setBitrate(240000);
                                info15.setFrameRate(26.7);
                                info15.setSize(new fm.icelink.Size(4096, 2304));
                                return info15;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "34", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info16 = new fm.icelink.EncodingInfo();
                                info16.setBitrate(240000);
                                info16.setFrameRate(56.3);
                                info16.setSize(new fm.icelink.Size(4096, 2304));
                                return info16;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "3c", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info17 = new fm.icelink.EncodingInfo();
                                info17.setBitrate(240000);
                                info17.setFrameRate(30.2);
                                info17.setSize(new fm.icelink.Size(8192, 4320));
                                return info17;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "3d", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info18 = new fm.icelink.EncodingInfo();
                                info18.setBitrate(480000);
                                info18.setFrameRate(60.4);
                                info18.setSize(new fm.icelink.Size(8192, 4320));
                                return info18;
                            }
                            if (fm.icelink.StringExtensions.isEqual(this.getLevel(), "3e", fm.icelink.StringComparison.OrdinalIgnoreCase)) {
                                var info19 = new fm.icelink.EncodingInfo();
                                info19.setBitrate(800000);
                                info19.setFrameRate(120.9);
                                info19.setSize(new fm.icelink.Size(8192, 4320));
                                return info19;
                            }
                            var info20 = new fm.icelink.EncodingInfo();
                            info20.setBitrate(64);
                            info20.setFrameRate(15);
                            info20.setSize(new fm.icelink.Size(176, 144));
                            return info20;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.prototype.getProfile = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.StringExtensions.substring(this.toString(), 0, 4);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.prototype.getProfileIdc = function () {
                        if (arguments.length == 0) {
                            return this._profileIdc;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.prototype.getProfileIop = function () {
                        if (arguments.length == 0) {
                            return this._profileIop;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.prototype.setLevelIdc = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._levelIdc = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.prototype.setProfileIdc = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._profileIdc = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.prototype.setProfileIop = function (value) {
                        if (arguments.length == 1) {
                            this._profileIop = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ProfileLevelId.prototype.toString = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.BitAssistant.getHexString(new Uint8Array([this.getProfileIdc(), this.getProfileIop().getDataBuffer().read8(0), this.getLevelIdc()]));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return ProfileLevelId;
                }());
                h264.ProfileLevelId = ProfileLevelId;
            })(icelink.h264 || (icelink.h264 = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var IceConnectionStateWrapper =  (function () {
                function IceConnectionStateWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_27 = __arguments[0];
                        this._value = value_27;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                IceConnectionStateWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.IceConnectionStateWrapper]';
                };
                IceConnectionStateWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.IceConnectionState.New)
                            return 'New';
                        if (this._value == fm.icelink.IceConnectionState.Checking)
                            return 'Checking';
                        if (this._value == fm.icelink.IceConnectionState.Connected)
                            return 'Connected';
                        if (this._value == fm.icelink.IceConnectionState.Completed)
                            return 'Completed';
                        if (this._value == fm.icelink.IceConnectionState.Failed)
                            return 'Failed';
                        if (this._value == fm.icelink.IceConnectionState.Disconnected)
                            return 'Disconnected';
                        if (this._value == fm.icelink.IceConnectionState.Closed)
                            return 'Closed';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return IceConnectionStateWrapper;
            }());
            icelink.IceConnectionStateWrapper = IceConnectionStateWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var IceGatheringStateWrapper =  (function () {
                function IceGatheringStateWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_28 = __arguments[0];
                        this._value = value_28;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                IceGatheringStateWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.IceGatheringStateWrapper]';
                };
                IceGatheringStateWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.IceGatheringState.New)
                            return 'New';
                        if (this._value == fm.icelink.IceGatheringState.Gathering)
                            return 'Gathering';
                        if (this._value == fm.icelink.IceGatheringState.Complete)
                            return 'Complete';
                        if (this._value == fm.icelink.IceGatheringState.Closing)
                            return 'Closing';
                        if (this._value == fm.icelink.IceGatheringState.Closed)
                            return 'Closed';
                        if (this._value == fm.icelink.IceGatheringState.Failed)
                            return 'Failed';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return IceGatheringStateWrapper;
            }());
            icelink.IceGatheringStateWrapper = IceGatheringStateWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var IceGatherPolicyWrapper =  (function () {
                function IceGatherPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_29 = __arguments[0];
                        this._value = value_29;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                IceGatherPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.IceGatherPolicyWrapper]';
                };
                IceGatherPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.IceGatherPolicy.All)
                            return 'All';
                        if (this._value == fm.icelink.IceGatherPolicy.NoHost)
                            return 'NoHost';
                        if (this._value == fm.icelink.IceGatherPolicy.Relay)
                            return 'Relay';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return IceGatherPolicyWrapper;
            }());
            icelink.IceGatherPolicyWrapper = IceGatherPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var IceServer =  (function () {
                function IceServer() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else if (__arguments.length == 1) {
                        var url = __arguments[0];
                        if (fm.icelink.StringExtensions.isNullOrEmpty(url)) {
                            throw new fm.icelink.Exception("URL cannot be null or empty.");
                        }
                        if ((fm.icelink.StringExtensions.startsWith(url, "turn:") || fm.icelink.StringExtensions.startsWith(url, "turns:"))) {
                            throw new fm.icelink.Exception("TURN servers require a username and password.");
                        }
                        if (!(fm.icelink.StringExtensions.startsWith(url, "stun:") || fm.icelink.StringExtensions.startsWith(url, "stuns:"))) {
                            url = fm.icelink.StringExtensions.format("stun:{0}", url);
                        }
                        if (!fm.icelink.StringExtensions.contains(url, "?transport=")) {
                            url = fm.icelink.StringExtensions.format("{0}?transport=udp", url);
                        }
                        this.setUrl(url);
                    }
                    else if (__arguments.length == 3) {
                        var url = __arguments[0];
                        var username = __arguments[1];
                        var password = __arguments[2];
                        if (fm.icelink.StringExtensions.isNullOrEmpty(url)) {
                            throw new fm.icelink.Exception("URL cannot be null or empty.");
                        }
                        if ((fm.icelink.Global.equals(username, null))) {
                            throw new fm.icelink.Exception("Username cannot be null.");
                        }
                        if ((fm.icelink.Global.equals(password, null))) {
                            throw new fm.icelink.Exception("Password cannot be null.");
                        }
                        if ((fm.icelink.StringExtensions.startsWith(url, "stun:") || fm.icelink.StringExtensions.startsWith(url, "stuns:"))) {
                            throw new fm.icelink.Exception("STUN servers do not have a username or password.");
                        }
                        if (!(fm.icelink.StringExtensions.startsWith(url, "turn:") || fm.icelink.StringExtensions.startsWith(url, "turns:"))) {
                            url = fm.icelink.StringExtensions.format("turn:{0}", url);
                        }
                        this.setUrl(url);
                        this.setUsername(username);
                        this.setPassword(password);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                IceServer.prototype.getTypeString = function () {
                    return '[fm.icelink.IceServer]';
                };
                IceServer.fromJson = function (iceServerJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(iceServerJson, function () {
                            return new fm.icelink.IceServer();
                        }, function (iceServer, name, valueJson) {
                            var str = name;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "url"))) {
                                    if ((fm.icelink.Global.equals(str, "username"))) {
                                        iceServer.setUsername(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "password"))) {
                                            iceServer.setPassword(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                        }
                                    }
                                }
                                else {
                                    iceServer.setUrl(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.fromJsonArray = function (iceServersJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(iceServersJson, fm.icelink.IceServer.fromJson.bind(fm.icelink.IceServer));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.getDefaultPort = function () {
                    if (arguments.length == 0) {
                        fm.icelink.Log.warn("Getting the value of IceServer.DefaultPort is deprecated. Get the value of IceServer.DefaultStunsPort/DefaultStunPort/DefaultTurnsPort/DefaultTurnPort instead.");
                        return 3478;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.getDefaultStunPort = function () {
                    if (arguments.length == 0) {
                        return 3478;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.getDefaultStunsPort = function () {
                    if (arguments.length == 0) {
                        return 5349;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.getDefaultTurnPort = function () {
                    if (arguments.length == 0) {
                        return 3478;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.getDefaultTurnsPort = function () {
                    if (arguments.length == 0) {
                        return 5349;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.parseAddress = function (address, host, port) {
                    if (arguments.length == 3) {
                        var strArray = void 0;
                        host.setValue(null);
                        port.setValue(-1);
                        if ((fm.icelink.Global.equals(address, null))) {
                            return false;
                        }
                        address = fm.icelink.StringExtensions.split(address, [63])[0];
                        if ((((fm.icelink.StringExtensions.startsWith(address, "stun:") || fm.icelink.StringExtensions.startsWith(address, "stuns:")) || fm.icelink.StringExtensions.startsWith(address, "turn:")) || fm.icelink.StringExtensions.startsWith(address, "turns:"))) {
                            address = address.substring((fm.icelink.StringExtensions.indexOf(address, ":") + 1));
                        }
                        if (fm.icelink.StringExtensions.startsWith(address, "[")) {
                            address = fm.icelink.StringExtensions.substring(address, 1, (fm.icelink.StringExtensions.getLength(address) - 1));
                            strArray = fm.icelink.StringExtensions.split(address, [93]);
                            host.setValue(strArray[0]);
                            if (((strArray.length > 1) && fm.icelink.StringExtensions.startsWith(strArray[1], ":"))) {
                                port.setValue(fm.icelink.IceServer.parsePort(strArray[1].substring(1)));
                            }
                        }
                        else {
                            strArray = fm.icelink.StringExtensions.split(address, [58]);
                            if ((fm.icelink.Global.equals(strArray.length, 1))) {
                                host.setValue(address);
                            }
                            else {
                                if ((fm.icelink.Global.equals(strArray.length, 2))) {
                                    host.setValue(strArray[0]);
                                    port.setValue(fm.icelink.IceServer.parsePort(strArray[1]));
                                }
                                else {
                                    if ((strArray.length > 2)) {
                                        host.setValue(address);
                                    }
                                }
                            }
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.parsePort = function (portString) {
                    if (arguments.length == 1) {
                        var intResult = -1;
                        var _var0 = new fm.icelink.Holder(intResult);
                        var _var1 = fm.icelink.ParseAssistant.tryParseIntegerValue(portString, _var0);
                        intResult = _var0.getValue();
                        if (!_var1) {
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Could not parse port when trying to interpret uri in the IceServer constructor. Please verify that the port was given as an integer. Tried parsing value {0}.", portString));
                        }
                        return intResult;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.toJson = function (iceServer) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(iceServer, function (i, jsonObject) {
                            if ((!fm.icelink.Global.equals(iceServer.getUrl(), null))) {
                                jsonObject["url"] = fm.icelink.JsonSerializer.serializeString(iceServer.getUrl());
                            }
                            if ((!fm.icelink.Global.equals(iceServer.getUsername(), null))) {
                                jsonObject["username"] = fm.icelink.JsonSerializer.serializeString(iceServer.getUsername());
                            }
                            if ((!fm.icelink.Global.equals(iceServer.getPassword(), null))) {
                                jsonObject["password"] = fm.icelink.JsonSerializer.serializeString(iceServer.getPassword());
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.toJsonArray = function (iceServers) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(iceServers, fm.icelink.IceServer.toJson.bind(fm.icelink.IceServer));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getHost = function () {
                    if (arguments.length == 0) {
                        var host = null;
                        var port = -1;
                        var _var0 = new fm.icelink.Holder(host);
                        var _var1 = new fm.icelink.Holder(port);
                        fm.icelink.IceServer.parseAddress(this.getUrl(), _var0, _var1);
                        host = _var0.getValue();
                        port = _var1.getValue();
                        return host;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getIPAddress = function () {
                    if (arguments.length == 0) {
                        if ((((fm.icelink.Global.equals(this.__ipAddress, null)) && (!fm.icelink.Global.equals(this.__ipAddresses, null))) && (this.__ipAddresses.length > 0))) {
                            this.__ipAddress = this.__ipAddresses[0];
                        }
                        return this.__ipAddress;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getIPAddresses = function () {
                    if (arguments.length == 0) {
                        if (((fm.icelink.Global.equals(this.__ipAddresses, null)) && (!fm.icelink.Global.equals(this.__ipAddress, null)))) {
                            this.__ipAddresses = [this.__ipAddress];
                        }
                        return this.__ipAddresses;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getIsSecure = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.StringExtensions.startsWith(this.getUrl(), "stuns:") || fm.icelink.StringExtensions.startsWith(this.getUrl(), "turns:"));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getIsStun = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.StringExtensions.startsWith(this.getUrl(), "stun:") || fm.icelink.StringExtensions.startsWith(this.getUrl(), "stuns:"));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getIsTcp = function () {
                    if (arguments.length == 0) {
                        return !fm.icelink.StringExtensions.endsWith(this.getUrl(), "?transport=udp");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getIsTurn = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.StringExtensions.startsWith(this.getUrl(), "turn:") || fm.icelink.StringExtensions.startsWith(this.getUrl(), "turns:"));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getIsUdp = function () {
                    if (arguments.length == 0) {
                        return !fm.icelink.StringExtensions.endsWith(this.getUrl(), "?transport=tcp");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getPassword = function () {
                    if (arguments.length == 0) {
                        return this._password;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getPort = function () {
                    if (arguments.length == 0) {
                        var host = null;
                        var port = -1;
                        var _var0 = new fm.icelink.Holder(host);
                        var _var1 = new fm.icelink.Holder(port);
                        fm.icelink.IceServer.parseAddress(this.getUrl(), _var0, _var1);
                        host = _var0.getValue();
                        port = _var1.getValue();
                        if ((fm.icelink.Global.equals(port, -1))) {
                            if (!(this.getIsSecure() || !this.getIsTurn())) {
                                return fm.icelink.IceServer.getDefaultTurnPort();
                            }
                            if (!(this.getIsSecure() || !this.getIsStun())) {
                                return fm.icelink.IceServer.getDefaultStunPort();
                            }
                            if ((this.getIsSecure() && this.getIsTurn())) {
                                return fm.icelink.IceServer.getDefaultTurnsPort();
                            }
                            return fm.icelink.IceServer.getDefaultStunsPort();
                        }
                        return port;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getUrl = function () {
                    if (arguments.length == 0) {
                        return this._url;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.getUsername = function () {
                    if (arguments.length == 0) {
                        return this._username;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.setIPAddress = function (value) {
                    if (arguments.length == 1) {
                        this.__ipAddress = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.setIPAddresses = function (value) {
                    if (arguments.length == 1) {
                        this.__ipAddresses = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.setPassword = function (value) {
                    if (arguments.length == 1) {
                        this._password = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.setUrl = function (value) {
                    if (arguments.length == 1) {
                        this._url = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.setUsername = function (value) {
                    if (arguments.length == 1) {
                        this._username = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServer.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.IceServer.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return IceServer;
            }());
            icelink.IceServer = IceServer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var IceServerCollection =  (function (_super) {
                __extends(IceServerCollection, _super);
                function IceServerCollection() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                IceServerCollection.prototype.getTypeString = function () {
                    return '[fm.icelink.IceServerCollection]' + ',' + _super.prototype.getTypeString.call(this);
                };
                IceServerCollection.prototype.arrayFromList = function (list) {
                    if (arguments.length == 1) {
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                IceServerCollection.prototype.createCollection = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.IceServerCollection();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return IceServerCollection;
            }(fm.icelink.Collection));
            icelink.IceServerCollection = IceServerCollection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Layout =  (function () {
                function Layout() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkLayoutInit();
                        this.__localFrame = new fm.icelink.LayoutFrame(0, 0, 0, 0);
                        this.__remoteFrames = new Array(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Layout.prototype.getTypeString = function () {
                    return '[fm.icelink.Layout]';
                };
                Layout.prototype.fmicelinkLayoutInit = function () {
                    this._height = 0;
                    this._width = 0;
                };
                Layout.prototype.getAllFrames = function () {
                    if (arguments.length == 0) {
                        var list = new Array();
                        fm.icelink.ArrayExtensions.add(list, this.getLocalFrame());
                        fm.icelink.ArrayExtensions.addRange(list, this.getRemoteFrames());
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.getHeight = function () {
                    if (arguments.length == 0) {
                        return this._height;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.getLocalFrame = function () {
                    if (arguments.length == 0) {
                        return this.__localFrame;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.getOrigin = function () {
                    if (arguments.length == 0) {
                        return this._origin;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.getRemoteFrames = function () {
                    if (arguments.length == 0) {
                        return this.__remoteFrames;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.getWidth = function () {
                    if (arguments.length == 0) {
                        return this._width;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.setHeight = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._height = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.setLocalFrame = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            this.__localFrame = new fm.icelink.LayoutFrame(0, 0, 0, 0);
                        }
                        else {
                            this.__localFrame = value;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.setOrigin = function (value) {
                    if (arguments.length == 1) {
                        this._origin = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.setRemoteFrames = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            this.__remoteFrames = new Array(0);
                        }
                        else {
                            this.__remoteFrames = value;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.setWidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._width = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.swapFrames = function (frame1, frame2) {
                    if (arguments.length == 2) {
                        var x = frame1.getX();
                        var y = frame1.getY();
                        var width = frame1.getWidth();
                        var height = frame1.getHeight();
                        frame1.setX(frame2.getX());
                        frame1.setY(frame2.getY());
                        frame1.setWidth(frame2.getWidth());
                        frame1.setHeight(frame2.getHeight());
                        frame2.setX(x);
                        frame2.setY(y);
                        frame2.setWidth(width);
                        frame2.setHeight(height);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.swapLocalFrame = function (remoteFrameIndex) {
                    if (arguments.length == 1) {
                        remoteFrameIndex = fm.icelink.Global.toInt(arguments[0]);
                        var localFrame = this.getLocalFrame();
                        var remoteFrames = this.getRemoteFrames();
                        if (((!fm.icelink.Global.equals(localFrame, null)) && (remoteFrameIndex < remoteFrames.length))) {
                            this.swapFrames(localFrame, remoteFrames[remoteFrameIndex]);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Layout.prototype.swapRemoteFrames = function (remoteFrameIndex1, remoteFrameIndex2) {
                    if (arguments.length == 2) {
                        remoteFrameIndex1 = fm.icelink.Global.toInt(arguments[0]);
                        remoteFrameIndex2 = fm.icelink.Global.toInt(arguments[1]);
                        var remoteFrames = this.getRemoteFrames();
                        if (((remoteFrameIndex1 < remoteFrames.length) && (remoteFrameIndex2 < remoteFrames.length))) {
                            this.swapFrames(remoteFrames[remoteFrameIndex1], remoteFrames[remoteFrameIndex2]);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Layout;
            }());
            icelink.Layout = Layout;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LayoutAlignmentWrapper =  (function () {
                function LayoutAlignmentWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_30 = __arguments[0];
                        this._value = value_30;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LayoutAlignmentWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.LayoutAlignmentWrapper]';
                };
                LayoutAlignmentWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.LayoutAlignment.TopLeft)
                            return 'TopLeft';
                        if (this._value == fm.icelink.LayoutAlignment.Top)
                            return 'Top';
                        if (this._value == fm.icelink.LayoutAlignment.TopRight)
                            return 'TopRight';
                        if (this._value == fm.icelink.LayoutAlignment.Left)
                            return 'Left';
                        if (this._value == fm.icelink.LayoutAlignment.Center)
                            return 'Center';
                        if (this._value == fm.icelink.LayoutAlignment.Right)
                            return 'Right';
                        if (this._value == fm.icelink.LayoutAlignment.BottomLeft)
                            return 'BottomLeft';
                        if (this._value == fm.icelink.LayoutAlignment.Bottom)
                            return 'Bottom';
                        if (this._value == fm.icelink.LayoutAlignment.BottomRight)
                            return 'BottomRight';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LayoutAlignmentWrapper;
            }());
            icelink.LayoutAlignmentWrapper = LayoutAlignmentWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LayoutDirectionWrapper =  (function () {
                function LayoutDirectionWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_31 = __arguments[0];
                        this._value = value_31;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LayoutDirectionWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.LayoutDirectionWrapper]';
                };
                LayoutDirectionWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.LayoutDirection.Horizontal)
                            return 'Horizontal';
                        if (this._value == fm.icelink.LayoutDirection.Vertical)
                            return 'Vertical';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LayoutDirectionWrapper;
            }());
            icelink.LayoutDirectionWrapper = LayoutDirectionWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LayoutPreset =  (function (_super) {
                __extends(LayoutPreset, _super);
                function LayoutPreset() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkLayoutPresetInit();
                        _this.__floatWidthPercent = 0;
                        _this.__floatHeightPercent = 0;
                        _this.__floatMarginXPercent = 0;
                        _this.__floatMarginYPercent = 0;
                        _this.__floatWidth = 0;
                        _this.__floatHeight = 0;
                        _this.__floatMarginX = 0;
                        _this.__floatMarginY = 0;
                        _this.__blockWidthPercent = 0;
                        _this.__blockHeightPercent = 0;
                        _this.__blockMarginXPercent = 0;
                        _this.__blockMarginYPercent = 0;
                        _this.__blockWidth = 0;
                        _this.__blockHeight = 0;
                        _this.__blockMarginX = 0;
                        _this.__blockMarginY = 0;
                        _this.setMode(fm.icelink.LayoutMode.FloatLocal);
                        _this.setDirection(fm.icelink.LayoutDirection.Horizontal);
                        _this.setAlignment(fm.icelink.LayoutAlignment.BottomRight);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                LayoutPreset.prototype.getTypeString = function () {
                    return '[fm.icelink.LayoutPreset]' + ',' + _super.prototype.getTypeString.call(this);
                };
                LayoutPreset.prototype.fmicelinkLayoutPresetInit = function () {
                    this.__blockHeight = 0;
                    this.__blockHeightPercent = 0;
                    this.__blockMarginX = 0;
                    this.__blockMarginXPercent = 0;
                    this.__blockMarginY = 0;
                    this.__blockMarginYPercent = 0;
                    this.__blockWidth = 0;
                    this.__blockWidthPercent = 0;
                    this.__floatHeight = 0;
                    this.__floatHeightPercent = 0;
                    this.__floatMarginX = 0;
                    this.__floatMarginXPercent = 0;
                    this.__floatMarginY = 0;
                    this.__floatMarginYPercent = 0;
                    this.__floatWidth = 0;
                    this.__floatWidthPercent = 0;
                    this._inlineMargin = 0;
                };
                LayoutPreset.calculateInlineOverflowFrame = function (baseCoordinate, layoutMeasurement, videoSize, direction) {
                    if (arguments.length == 4) {
                        baseCoordinate = fm.icelink.Global.toInt(arguments[0]);
                        layoutMeasurement = fm.icelink.Global.toInt(arguments[1]);
                        if ((fm.icelink.Global.equals(direction, fm.icelink.LayoutDirection.Horizontal))) {
                            if ((fm.icelink.Global.equals(videoSize.getHeight(), 0))) {
                                return new fm.icelink.LayoutFrame(baseCoordinate, 0, 0, layoutMeasurement);
                            }
                            return new fm.icelink.LayoutFrame(baseCoordinate, 0, fm.icelink.MathAssistant.floor((layoutMeasurement * videoSize.getWidth()) / videoSize.getHeight()), layoutMeasurement);
                        }
                        if ((fm.icelink.Global.equals(videoSize.getWidth(), 0))) {
                            return new fm.icelink.LayoutFrame(0, baseCoordinate, layoutMeasurement, 0);
                        }
                        return new fm.icelink.LayoutFrame(0, baseCoordinate, layoutMeasurement, fm.icelink.MathAssistant.floor((layoutMeasurement * videoSize.getHeight()) / videoSize.getWidth()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.calculateTable = function (tableWidth, tableHeight, count) {
                    if (arguments.length == 3) {
                        tableWidth = fm.icelink.Global.toInt(arguments[0]);
                        tableHeight = fm.icelink.Global.toInt(arguments[1]);
                        count = fm.icelink.Global.toInt(arguments[2]);
                        var num = 0;
                        var num2 = 1;
                        var num3 = 1;
                        for (var i = count; (i >= 1); i--) {
                            var num5 = fm.icelink.MathAssistant.ceil((count / i));
                            var num6 = (tableWidth / i);
                            var num7 = (tableHeight / num5);
                            var num8 = ((num6 < num7) ? num6 : num7);
                            if ((num8 >= num)) {
                                num = num8;
                                num2 = i;
                                num3 = num5;
                            }
                        }
                        var cellWidth = fm.icelink.MathAssistant.floor((tableWidth / num2));
                        return new fm.icelink.LayoutTable(num2, num3, cellWidth, fm.icelink.MathAssistant.floor((tableHeight / num3)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.divideByTwo = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        return fm.icelink.MathAssistant.floor((value / 2));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.getFacetime = function () {
                    if (arguments.length == 0) {
                        var preset = new fm.icelink.LayoutPreset();
                        preset.setMode(fm.icelink.LayoutMode.FloatLocal);
                        preset.setAlignment(fm.icelink.LayoutAlignment.BottomRight);
                        preset.setFloatMarginX(10);
                        preset.setFloatMarginY(10);
                        preset.setFloatWidthPercent(0.25);
                        preset.setFloatHeightPercent(0.25);
                        preset.setInlineMargin(0);
                        return preset;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.getGoogleHangouts = function () {
                    if (arguments.length == 0) {
                        if (fm.icelink.Platform.getInstance().getIsMobile()) {
                            var preset = new fm.icelink.LayoutPreset();
                            preset.setMode(fm.icelink.LayoutMode.FloatRemote);
                            preset.setAlignment(fm.icelink.LayoutAlignment.BottomRight);
                            preset.setFloatMarginX(0);
                            preset.setFloatMarginY(10);
                            preset.setFloatWidthPercent(0.25);
                            preset.setFloatHeightPercent(0.25);
                            preset.setInlineMargin(5);
                            return preset;
                        }
                        var preset2 = new fm.icelink.LayoutPreset();
                        preset2.setMode(fm.icelink.LayoutMode.Block);
                        preset2.setAlignment(fm.icelink.LayoutAlignment.Top);
                        preset2.setBlockWidthPercent(0.666666666666667);
                        preset2.setBlockHeightPercent(0.666666666666667);
                        preset2.setInlineMargin(0);
                        return preset2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.getSingleLayout = function (layoutWidth, layoutHeight, local) {
                    if (arguments.length == 3) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        var layout = new fm.icelink.Layout();
                        layout.setLocalFrame((local ? new fm.icelink.LayoutFrame(0, 0, layoutWidth, layoutHeight) : null));
                        return layout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.getSkype = function () {
                    if (arguments.length == 0) {
                        if (fm.icelink.Platform.getInstance().getIsMobile()) {
                            return fm.icelink.LayoutPreset.getFacetime();
                        }
                        var preset = new fm.icelink.LayoutPreset();
                        preset.setMode(fm.icelink.LayoutMode.Block);
                        preset.setDirection(fm.icelink.LayoutDirection.Horizontal);
                        preset.setAlignment(fm.icelink.LayoutAlignment.Bottom);
                        preset.setBlockMarginX(10);
                        preset.setBlockMarginY(10);
                        preset.setBlockWidthPercent(0.333333333333333);
                        preset.setBlockHeightPercent(0.333333333333333);
                        preset.setInlineMargin(10);
                        return preset;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.getXMax = function (frames) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(frames.length, 0))) {
                            return frames[0].getX();
                        }
                        var x = frames[0].getX();
                        for (var i = 1; (i < frames.length); i++) {
                            var frame = frames[i];
                            if ((frame.getX() > x)) {
                                x = frame.getX();
                            }
                        }
                        return x;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.getXMid = function (frames) {
                    if (arguments.length == 1) {
                        var xMin = fm.icelink.LayoutPreset.getXMin(frames);
                        var xMax = fm.icelink.LayoutPreset.getXMax(frames);
                        if ((fm.icelink.Global.equals(xMin, xMax))) {
                            return xMin;
                        }
                        var num3 = fm.icelink.LayoutPreset.divideByTwo((xMin + xMax));
                        var x = frames[0].getX();
                        var num5 = fm.icelink.MathAssistant.abs((num3 - x));
                        for (var i = 1; (i < frames.length); i++) {
                            var frame = frames[i];
                            var num7 = fm.icelink.MathAssistant.abs((num3 - frame.getX()));
                            if ((num7 < num5)) {
                                x = frame.getX();
                                num5 = num7;
                            }
                        }
                        return x;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.getXMin = function (frames) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(frames.length, 0))) {
                            return frames[0].getX();
                        }
                        var x = frames[0].getX();
                        for (var i = 1; (i < frames.length); i++) {
                            var frame = frames[i];
                            if ((frame.getX() < x)) {
                                x = frame.getX();
                            }
                        }
                        return x;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.getYMax = function (frames) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(frames.length, 0))) {
                            return frames[0].getY();
                        }
                        var y = frames[0].getY();
                        for (var i = 1; (i < frames.length); i++) {
                            var frame = frames[i];
                            if ((frame.getY() > y)) {
                                y = frame.getY();
                            }
                        }
                        return y;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.getYMid = function (frames) {
                    if (arguments.length == 1) {
                        var yMin = fm.icelink.LayoutPreset.getYMin(frames);
                        var yMax = fm.icelink.LayoutPreset.getYMax(frames);
                        if ((fm.icelink.Global.equals(yMin, yMax))) {
                            return yMin;
                        }
                        var num3 = fm.icelink.LayoutPreset.divideByTwo((yMin + yMax));
                        var y = frames[0].getY();
                        var num5 = fm.icelink.MathAssistant.abs((num3 - y));
                        for (var i = 1; (i < frames.length); i++) {
                            var frame = frames[i];
                            var num7 = fm.icelink.MathAssistant.abs((num3 - frame.getY()));
                            if ((num7 < num5)) {
                                y = frame.getY();
                                num5 = num7;
                            }
                        }
                        return y;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.getYMin = function (frames) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(frames.length, 0))) {
                            return frames[0].getY();
                        }
                        var y = frames[0].getY();
                        for (var i = 1; (i < frames.length); i++) {
                            var frame = frames[i];
                            if ((frame.getY() < y)) {
                                y = frame.getY();
                            }
                        }
                        return y;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.mergeLayoutFrames = function (firstFrames, lastFrames) {
                    if (arguments.length == 2) {
                        var num3 = void 0;
                        var length_37 = firstFrames.length;
                        var num2 = lastFrames.length;
                        var frameArray = new Array((length_37 + num2));
                        for (num3 = 0; (num3 < length_37); num3++) {
                            frameArray[num3] = firstFrames[num3];
                        }
                        for (num3 = 0; (num3 < num2); num3++) {
                            frameArray[(num3 + length_37)] = lastFrames[num3];
                        }
                        return frameArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.spliceLayoutFrame = function (frames, index) {
                    if (arguments.length == 2) {
                        index = fm.icelink.Global.toInt(arguments[1]);
                        var start = (index + 1);
                        return fm.icelink.LayoutPreset.mergeLayoutFrames(fm.icelink.LayoutPreset.takeLayoutFrames(frames, 0, index), fm.icelink.LayoutPreset.takeLayoutFrames(frames, start, (frames.length - start)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.takeLayoutFrames = function (frames, start, length) {
                    if (arguments.length == 3) {
                        start = fm.icelink.Global.toInt(arguments[1]);
                        length = fm.icelink.Global.toInt(arguments[2]);
                        var frameArray = new Array(length);
                        for (var i = 0; (i < frameArray.length); i++) {
                            frameArray[i] = frames[(start + i)];
                        }
                        return frameArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.transformFrame = function (frame, origin, layoutWidth, layoutHeight) {
                    if (arguments.length == 4) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[2]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[3]);
                        var flag = false;
                        var flag2 = false;
                        var _var0 = origin;
                        do {
                            if (_var0 == fm.icelink.LayoutOrigin.TopRight) {
                                flag = true;
                                break;
                            }
                            else if (_var0 == fm.icelink.LayoutOrigin.BottomRight) {
                                flag = true;
                                flag2 = true;
                                break;
                            }
                            else if (_var0 == fm.icelink.LayoutOrigin.BottomLeft) {
                                flag2 = true;
                                break;
                            }
                        } while (false);
                        if (flag) {
                            frame.setX(((layoutWidth - frame.getX()) - frame.getWidth()));
                        }
                        if (flag2) {
                            frame.setY(((layoutHeight - frame.getY()) - frame.getHeight()));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.applyPreset = function (preset) {
                    if (arguments.length == 1) {
                        this.setMode(preset.getMode());
                        this.setDirection(preset.getDirection());
                        this.setAlignment(preset.getAlignment());
                        this.setFloatWidth(0);
                        this.setFloatHeight(0);
                        this.setFloatMarginX(0);
                        this.setFloatMarginY(0);
                        this.setFloatWidthPercent(0);
                        this.setFloatHeightPercent(0);
                        this.setFloatMarginXPercent(0);
                        this.setFloatMarginYPercent(0);
                        this.setBlockWidth(0);
                        this.setBlockHeight(0);
                        this.setBlockMarginX(0);
                        this.setBlockMarginY(0);
                        this.setBlockWidthPercent(0);
                        this.setBlockHeightPercent(0);
                        this.setBlockMarginXPercent(0);
                        this.setBlockMarginYPercent(0);
                        this.setInlineMargin(0);
                        if ((preset.getFloatWidth() > 0)) {
                            this.setFloatWidth(preset.getFloatWidth());
                        }
                        if ((preset.getFloatHeight() > 0)) {
                            this.setFloatHeight(preset.getFloatHeight());
                        }
                        if ((preset.getFloatMarginX() > 0)) {
                            this.setFloatMarginX(preset.getFloatMarginX());
                        }
                        if ((preset.getFloatMarginY() > 0)) {
                            this.setFloatMarginY(preset.getFloatMarginY());
                        }
                        if ((preset.getFloatWidthPercent() > 0)) {
                            this.setFloatWidthPercent(preset.getFloatWidthPercent());
                        }
                        if ((preset.getFloatHeightPercent() > 0)) {
                            this.setFloatHeightPercent(preset.getFloatHeightPercent());
                        }
                        if ((preset.getFloatMarginXPercent() > 0)) {
                            this.setFloatMarginXPercent(preset.getFloatMarginXPercent());
                        }
                        if ((preset.getFloatMarginYPercent() > 0)) {
                            this.setFloatMarginYPercent(preset.getFloatMarginYPercent());
                        }
                        if ((preset.getBlockWidth() > 0)) {
                            this.setBlockWidth(preset.getBlockWidth());
                        }
                        if ((preset.getBlockHeight() > 0)) {
                            this.setBlockHeight(preset.getBlockHeight());
                        }
                        if ((preset.getBlockMarginX() > 0)) {
                            this.setBlockMarginX(preset.getBlockMarginX());
                        }
                        if ((preset.getBlockMarginY() > 0)) {
                            this.setBlockMarginY(preset.getBlockMarginY());
                        }
                        if ((preset.getBlockWidthPercent() > 0)) {
                            this.setBlockWidthPercent(preset.getBlockWidthPercent());
                        }
                        if ((preset.getBlockHeightPercent() > 0)) {
                            this.setBlockHeightPercent(preset.getBlockHeightPercent());
                        }
                        if ((preset.getBlockMarginXPercent() > 0)) {
                            this.setBlockMarginXPercent(preset.getBlockMarginXPercent());
                        }
                        if ((preset.getBlockMarginYPercent() > 0)) {
                            this.setBlockMarginYPercent(preset.getBlockMarginYPercent());
                        }
                        if ((preset.getInlineMargin() > 0)) {
                            this.setInlineMargin(preset.getInlineMargin());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.calculateBlockFrame = function (layoutWidth, layoutHeight, marginX, marginY) {
                    if (arguments.length == 4) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        if (((fm.icelink.Global.equals(this.getBlockWidth(), 0)) && (fm.icelink.Global.equals(this.getBlockWidthPercent(), 0)))) {
                            this.setBlockWidthPercent(0.25);
                        }
                        if (((fm.icelink.Global.equals(this.getBlockHeight(), 0)) && (fm.icelink.Global.equals(this.getBlockHeightPercent(), 0)))) {
                            this.setBlockHeightPercent(0.25);
                        }
                        var width = ((this.getBlockWidth() > 0) ? this.getBlockWidth() : (layoutWidth * this.getBlockWidthPercent()));
                        var height = ((this.getBlockHeight() > 0) ? this.getBlockHeight() : (layoutHeight * this.getBlockHeightPercent()));
                        marginX.setValue(((this.getBlockMarginX() > 0) ? this.getBlockMarginX() : (layoutWidth * this.getBlockMarginXPercent())));
                        marginY.setValue(((this.getBlockMarginY() > 0) ? this.getBlockMarginY() : (layoutHeight * this.getBlockMarginYPercent())));
                        var x = 0;
                        var _var0 = this.getAlignment();
                        do {
                            if (_var0 == fm.icelink.LayoutAlignment.Top || _var0 == fm.icelink.LayoutAlignment.Center || _var0 == fm.icelink.LayoutAlignment.Bottom) {
                                x = fm.icelink.LayoutPreset.divideByTwo((layoutWidth - width));
                                break;
                            }
                            else if (_var0 == fm.icelink.LayoutAlignment.TopRight || _var0 == fm.icelink.LayoutAlignment.Right || _var0 == fm.icelink.LayoutAlignment.BottomRight) {
                                x = (layoutWidth - width);
                                break;
                            }
                            else {
                                x = 0;
                                break;
                            }
                        } while (false);
                        var y = 0;
                        var _var1 = this.getAlignment();
                        do {
                            if (_var1 == fm.icelink.LayoutAlignment.Left || _var1 == fm.icelink.LayoutAlignment.Center || _var1 == fm.icelink.LayoutAlignment.Right) {
                                y = fm.icelink.LayoutPreset.divideByTwo((layoutHeight - height));
                                break;
                            }
                            else if (_var1 == fm.icelink.LayoutAlignment.BottomLeft || _var1 == fm.icelink.LayoutAlignment.Bottom || _var1 == fm.icelink.LayoutAlignment.BottomRight) {
                                y = (layoutHeight - height);
                                break;
                            }
                            else {
                                y = 0;
                                break;
                            }
                        } while (false);
                        return new fm.icelink.LayoutFrame(x, y, width, height);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.calculateFillFrame = function (layoutWidth, layoutHeight) {
                    if (arguments.length == 2) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        return new fm.icelink.LayoutFrame(0, 0, layoutWidth, layoutHeight);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.calculateFloatFrame = function (layoutWidth, layoutHeight) {
                    if (arguments.length == 2) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        return this.calculateFloatFrames(layoutWidth, layoutHeight, 1)[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.calculateFloatFrames = function (layoutWidth, layoutHeight, count) {
                    if (arguments.length == 3) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        count = fm.icelink.Global.toInt(arguments[2]);
                        if (((fm.icelink.Global.equals(this.getFloatWidth(), 0)) && (fm.icelink.Global.equals(this.getFloatWidthPercent(), 0)))) {
                            this.setFloatWidthPercent(0.25);
                        }
                        if (((fm.icelink.Global.equals(this.getFloatHeight(), 0)) && (fm.icelink.Global.equals(this.getFloatHeightPercent(), 0)))) {
                            this.setFloatHeightPercent(0.25);
                        }
                        var num = ((this.getFloatWidth() > 0) ? this.getFloatWidth() : (layoutWidth * this.getFloatWidthPercent()));
                        var num2 = ((this.getFloatHeight() > 0) ? this.getFloatHeight() : (layoutHeight * this.getFloatHeightPercent()));
                        var num3 = ((this.getFloatMarginX() > 0) ? this.getFloatMarginX() : (layoutWidth * this.getFloatMarginXPercent()));
                        var num4 = ((this.getFloatMarginY() > 0) ? this.getFloatMarginY() : (layoutHeight * this.getFloatMarginYPercent()));
                        if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Horizontal))) {
                            num = fm.icelink.MathAssistant.min(layoutWidth, (num * count));
                        }
                        else {
                            num2 = fm.icelink.MathAssistant.min(layoutHeight, (num2 * count));
                        }
                        var frameArray = this.calculateInlineFrames(num, num2, count, 0, 0);
                        var _var0 = this.getAlignment();
                        do {
                            if (_var0 == fm.icelink.LayoutAlignment.TopLeft || _var0 == fm.icelink.LayoutAlignment.Top || _var0 == fm.icelink.LayoutAlignment.TopRight) {
                                for (var _i = 0, frameArray_1 = frameArray; _i < frameArray_1.length; _i++) {
                                    var frame = frameArray_1[_i];
                                    frame.setY((frame.getY() + num4));
                                }
                                break;
                            }
                            else if (_var0 == fm.icelink.LayoutAlignment.Left || _var0 == fm.icelink.LayoutAlignment.Center || _var0 == fm.icelink.LayoutAlignment.Right) {
                                for (var _a = 0, frameArray_2 = frameArray; _a < frameArray_2.length; _a++) {
                                    var frame = frameArray_2[_a];
                                    frame.setY((frame.getY() + fm.icelink.LayoutPreset.divideByTwo((layoutHeight - num2))));
                                }
                                break;
                            }
                            else if (_var0 == fm.icelink.LayoutAlignment.BottomLeft || _var0 == fm.icelink.LayoutAlignment.Bottom || _var0 == fm.icelink.LayoutAlignment.BottomRight) {
                                for (var _b = 0, frameArray_3 = frameArray; _b < frameArray_3.length; _b++) {
                                    var frame = frameArray_3[_b];
                                    frame.setY((frame.getY() + ((layoutHeight - num2) - num4)));
                                }
                                break;
                            }
                        } while (false);
                        var _var1 = this.getAlignment();
                        do {
                            if (_var1 == fm.icelink.LayoutAlignment.TopLeft || _var1 == fm.icelink.LayoutAlignment.Left || _var1 == fm.icelink.LayoutAlignment.BottomLeft) {
                                for (var _c = 0, frameArray_4 = frameArray; _c < frameArray_4.length; _c++) {
                                    var frame = frameArray_4[_c];
                                    frame.setX((frame.getX() + num3));
                                }
                                return frameArray;
                            }
                            else if (_var1 == fm.icelink.LayoutAlignment.Top || _var1 == fm.icelink.LayoutAlignment.Center || _var1 == fm.icelink.LayoutAlignment.Bottom) {
                                for (var _d = 0, frameArray_5 = frameArray; _d < frameArray_5.length; _d++) {
                                    var frame = frameArray_5[_d];
                                    frame.setX((frame.getX() + fm.icelink.LayoutPreset.divideByTwo((layoutWidth - num))));
                                }
                                return frameArray;
                            }
                            else if (_var1 == fm.icelink.LayoutAlignment.TopRight || _var1 == fm.icelink.LayoutAlignment.Right || _var1 == fm.icelink.LayoutAlignment.BottomRight) {
                                for (var _e = 0, frameArray_6 = frameArray; _e < frameArray_6.length; _e++) {
                                    var frame = frameArray_6[_e];
                                    frame.setX((frame.getX() + ((layoutWidth - num) - num3)));
                                }
                                return frameArray;
                            }
                        } while (false);
                        return frameArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.calculateInlineFrame = function (cellX, cellY, cellWidth, cellHeight) {
                    if (arguments.length == 4) {
                        cellX = fm.icelink.Global.toInt(arguments[0]);
                        cellY = fm.icelink.Global.toInt(arguments[1]);
                        cellWidth = fm.icelink.Global.toInt(arguments[2]);
                        cellHeight = fm.icelink.Global.toInt(arguments[3]);
                        var num = fm.icelink.LayoutPreset.divideByTwo(this.getInlineMargin());
                        var x = (cellX - num);
                        var y = (cellY - num);
                        var width = (cellWidth - this.getInlineMargin());
                        return new fm.icelink.LayoutFrame(x, y, width, (cellHeight - this.getInlineMargin()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.calculateInlineFrames = function (layoutWidth, layoutHeight, count, baseX, baseY) {
                    if (arguments.length == 5) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        count = fm.icelink.Global.toInt(arguments[2]);
                        baseX = fm.icelink.Global.toInt(arguments[3]);
                        baseY = fm.icelink.Global.toInt(arguments[4]);
                        var num6 = void 0;
                        var num7 = void 0;
                        var num8 = void 0;
                        var num9 = void 0;
                        var num10 = void 0;
                        var num12 = void 0;
                        var num13 = void 0;
                        var num14 = void 0;
                        var num15 = void 0;
                        var num16 = void 0;
                        var num17 = void 0;
                        var frame = void 0;
                        var list = new Array();
                        var table = fm.icelink.LayoutPreset.calculateTable((layoutWidth + this.getInlineMargin()), (layoutHeight + this.getInlineMargin()), count);
                        var columnCount = table.getColumnCount();
                        var rowCount = table.getRowCount();
                        var cellWidth = table.getCellWidth();
                        var cellHeight = table.getCellHeight();
                        var num5 = fm.icelink.LayoutPreset.divideByTwo(this.getInlineMargin());
                        if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Horizontal))) {
                            num6 = 0;
                            num7 = (baseY + num5);
                            num8 = ((layoutHeight - (rowCount * cellHeight)) + this.getInlineMargin());
                            num9 = 0;
                            while ((num9 < rowCount)) {
                                num10 = ((num9 < num8) ? 1 : 0);
                                var num11 = columnCount;
                                if ((fm.icelink.Global.equals(num9, (rowCount - 1)))) {
                                    num11 = (count - num6);
                                }
                                num12 = (baseX + num5);
                                if (((fm.icelink.Global.equals(num9, (rowCount - 1))) && (rowCount > 1))) {
                                    num13 = (num12 - num5);
                                    num14 = (num7 - num5);
                                    fm.icelink.ArrayExtensions.addRange(list, this.calculateInlineFrames((baseX + layoutWidth), ((baseY + layoutHeight) - num14), num11, num13, num14));
                                }
                                else {
                                    num15 = ((layoutWidth - (num11 * cellWidth)) + this.getInlineMargin());
                                    num16 = 0;
                                    while ((num16 < num11)) {
                                        num17 = ((num16 < num15) ? 1 : 0);
                                        frame = this.calculateInlineFrame(num12, num7, (cellWidth + num17), (cellHeight + num10));
                                        fm.icelink.ArrayExtensions.add(list, frame);
                                        num12 = (num12 + (cellWidth + num17));
                                        num16++;
                                        num6++;
                                    }
                                }
                                num7 = (num7 + (cellHeight + num10));
                                num9++;
                            }
                        }
                        else {
                            num6 = 0;
                            num12 = (baseX + num5);
                            num15 = ((layoutWidth - (columnCount * cellWidth)) + this.getInlineMargin());
                            for (num16 = 0; (num16 < columnCount); num16++) {
                                num17 = ((num16 < num15) ? 1 : 0);
                                var num18 = rowCount;
                                if ((fm.icelink.Global.equals(num16, (columnCount - 1)))) {
                                    num18 = (count - num6);
                                }
                                num7 = (baseY + num5);
                                if (((fm.icelink.Global.equals(num16, (columnCount - 1))) && (columnCount > 1))) {
                                    num13 = (num12 - num5);
                                    num14 = (num7 - num5);
                                    fm.icelink.ArrayExtensions.addRange(list, this.calculateInlineFrames(((baseX + layoutWidth) - num13), (baseY + layoutHeight), num18, num13, num14));
                                }
                                else {
                                    num8 = ((layoutHeight - (num18 * cellHeight)) + this.getInlineMargin());
                                    num9 = 0;
                                    while ((num9 < num18)) {
                                        num10 = ((num9 < num8) ? 1 : 0);
                                        frame = this.calculateInlineFrame(num12, num7, (cellWidth + num17), (cellHeight + num10));
                                        fm.icelink.ArrayExtensions.add(list, frame);
                                        num7 = (num7 + (cellHeight + num10));
                                        num9++;
                                        num6++;
                                    }
                                }
                                num12 = (num12 + (cellWidth + num17));
                            }
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.calculateInlineOverflowFrames = function (layoutWidth, layoutHeight, baseX, baseY, localVideoSize, remoteVideoSizes) {
                    if (arguments.length == 6) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        baseX = fm.icelink.Global.toInt(arguments[2]);
                        baseY = fm.icelink.Global.toInt(arguments[3]);
                        var frame = void 0;
                        var frame2 = void 0;
                        var list = new Array();
                        if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Horizontal))) {
                            var baseCoordinate = baseX;
                            if ((!fm.icelink.Global.equals(localVideoSize, null))) {
                                frame = fm.icelink.LayoutPreset.calculateInlineOverflowFrame(baseCoordinate, layoutHeight, localVideoSize, this.getDirection());
                                baseCoordinate = (baseCoordinate + frame.getWidth());
                                fm.icelink.ArrayExtensions.add(list, frame);
                            }
                            if ((!fm.icelink.Global.equals(remoteVideoSizes, null))) {
                                for (var _i = 0, remoteVideoSizes_1 = remoteVideoSizes; _i < remoteVideoSizes_1.length; _i++) {
                                    var size = remoteVideoSizes_1[_i];
                                    frame2 = fm.icelink.LayoutPreset.calculateInlineOverflowFrame(baseCoordinate, layoutHeight, size, this.getDirection());
                                    baseCoordinate = (baseCoordinate + frame2.getWidth());
                                    fm.icelink.ArrayExtensions.add(list, frame2);
                                }
                            }
                        }
                        else {
                            var num2 = baseY;
                            if ((!fm.icelink.Global.equals(localVideoSize, null))) {
                                frame = fm.icelink.LayoutPreset.calculateInlineOverflowFrame(num2, layoutWidth, localVideoSize, this.getDirection());
                                num2 = (num2 + frame.getHeight());
                                fm.icelink.ArrayExtensions.add(list, frame);
                            }
                            if ((!fm.icelink.Global.equals(remoteVideoSizes, null))) {
                                for (var _a = 0, remoteVideoSizes_2 = remoteVideoSizes; _a < remoteVideoSizes_2.length; _a++) {
                                    var size = remoteVideoSizes_2[_a];
                                    frame2 = fm.icelink.LayoutPreset.calculateInlineOverflowFrame(num2, layoutWidth, size, this.getDirection());
                                    num2 = (num2 + frame2.getHeight());
                                    fm.icelink.ArrayExtensions.add(list, frame2);
                                }
                            }
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.calculateLayout = function () {
                    if (arguments.length == 7) {
                        var layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        var layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        var local = arguments[2];
                        var remoteCount = fm.icelink.Global.toInt(arguments[3]);
                        var origin_1 = arguments[4];
                        var localVideoSize = arguments[5];
                        var remoteVideoSizes = arguments[6];
                        if ((layoutWidth < 0)) {
                            layoutWidth = 0;
                        }
                        if ((layoutHeight < 0)) {
                            layoutHeight = 0;
                        }
                        var layout = null;
                        if ((fm.icelink.Global.equals(this.getMode(), fm.icelink.LayoutMode.FloatLocal))) {
                            layout = this.getFloatLocalLayout(layoutWidth, layoutHeight, local, remoteCount, origin_1);
                        }
                        else {
                            if ((fm.icelink.Global.equals(this.getMode(), fm.icelink.LayoutMode.FloatRemote))) {
                                layout = this.getFloatRemoteLayout(layoutWidth, layoutHeight, local, remoteCount, origin_1);
                            }
                            else {
                                if ((fm.icelink.Global.equals(this.getMode(), fm.icelink.LayoutMode.Block))) {
                                    layout = this.getBlockLayout(layoutWidth, layoutHeight, local, remoteCount, origin_1);
                                }
                                else {
                                    if ((fm.icelink.Global.equals(this.getMode(), fm.icelink.LayoutMode.Inline))) {
                                        layout = this.getInlineLayout(layoutWidth, layoutHeight, local, remoteCount, origin_1);
                                    }
                                    else {
                                        if ((!fm.icelink.Global.equals(this.getMode(), fm.icelink.LayoutMode.InlineOverflow))) {
                                            throw new fm.icelink.Exception("Unrecognized layout mode.");
                                        }
                                        layout = this.getInlineOverflowLayout(layoutWidth, layoutHeight, origin_1, localVideoSize, remoteVideoSizes);
                                    }
                                }
                            }
                        }
                        fm.icelink.LayoutPreset.transformFrame(layout.getLocalFrame(), origin_1, layoutWidth, layoutHeight);
                        for (var _i = 0, _a = layout.getRemoteFrames(); _i < _a.length; _i++) {
                            var frame = _a[_i];
                            fm.icelink.LayoutPreset.transformFrame(frame, origin_1, layoutWidth, layoutHeight);
                        }
                        return layout;
                    }
                    else if (arguments.length == 4) {
                        var layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        var layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        var remoteCount = fm.icelink.Global.toInt(arguments[2]);
                        var origin_2 = arguments[3];
                        return this.calculateLayout(layoutWidth, layoutHeight, true, remoteCount, origin_2, null, null);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.copyToPreset = function (preset) {
                    if (arguments.length == 1) {
                        preset.setMode(this.getMode());
                        preset.setDirection(this.getDirection());
                        preset.setAlignment(this.getAlignment());
                        preset.setFloatWidth(0);
                        preset.setFloatHeight(0);
                        preset.setFloatMarginX(0);
                        preset.setFloatMarginY(0);
                        preset.setFloatWidthPercent(0);
                        preset.setFloatHeightPercent(0);
                        preset.setFloatMarginXPercent(0);
                        preset.setFloatMarginYPercent(0);
                        preset.setBlockWidth(0);
                        preset.setBlockHeight(0);
                        preset.setBlockMarginX(0);
                        preset.setBlockMarginY(0);
                        preset.setBlockWidthPercent(0);
                        preset.setBlockHeightPercent(0);
                        preset.setBlockMarginXPercent(0);
                        preset.setBlockMarginYPercent(0);
                        preset.setInlineMargin(0);
                        if ((this.getFloatWidth() > 0)) {
                            preset.setFloatWidth(this.getFloatWidth());
                        }
                        if ((this.getFloatHeight() > 0)) {
                            preset.setFloatHeight(this.getFloatHeight());
                        }
                        if ((this.getFloatMarginX() > 0)) {
                            preset.setFloatMarginX(this.getFloatMarginX());
                        }
                        if ((this.getFloatMarginY() > 0)) {
                            preset.setFloatMarginY(this.getFloatMarginY());
                        }
                        if ((this.getFloatWidthPercent() > 0)) {
                            preset.setFloatWidthPercent(this.getFloatWidthPercent());
                        }
                        if ((this.getFloatHeightPercent() > 0)) {
                            preset.setFloatHeightPercent(this.getFloatHeightPercent());
                        }
                        if ((this.getFloatMarginXPercent() > 0)) {
                            preset.setFloatMarginXPercent(this.getFloatMarginXPercent());
                        }
                        if ((this.getFloatMarginYPercent() > 0)) {
                            preset.setFloatMarginYPercent(this.getFloatMarginYPercent());
                        }
                        if ((this.getBlockWidth() > 0)) {
                            preset.setBlockWidth(this.getBlockWidth());
                        }
                        if ((this.getBlockHeight() > 0)) {
                            preset.setBlockHeight(this.getBlockHeight());
                        }
                        if ((this.getBlockMarginX() > 0)) {
                            preset.setBlockMarginX(this.getBlockMarginX());
                        }
                        if ((this.getBlockMarginY() > 0)) {
                            preset.setBlockMarginY(this.getBlockMarginY());
                        }
                        if ((this.getBlockWidthPercent() > 0)) {
                            preset.setBlockWidthPercent(this.getBlockWidthPercent());
                        }
                        if ((this.getBlockHeightPercent() > 0)) {
                            preset.setBlockHeightPercent(this.getBlockHeightPercent());
                        }
                        if ((this.getBlockMarginXPercent() > 0)) {
                            preset.setBlockMarginXPercent(this.getBlockMarginXPercent());
                        }
                        if ((this.getBlockMarginYPercent() > 0)) {
                            preset.setBlockMarginYPercent(this.getBlockMarginYPercent());
                        }
                        if ((this.getInlineMargin() > 0)) {
                            preset.setInlineMargin(this.getInlineMargin());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getAlignment = function () {
                    if (arguments.length == 0) {
                        return this._alignment;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getBlockHeight = function () {
                    if (arguments.length == 0) {
                        return this.__blockHeight;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getBlockHeightPercent = function () {
                    if (arguments.length == 0) {
                        return this.__blockHeightPercent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getBlockLayout = function (layoutWidth, layoutHeight, local, remoteCount, origin) {
                    if (arguments.length == 5) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        remoteCount = fm.icelink.Global.toInt(arguments[3]);
                        var num7 = void 0;
                        var num8 = void 0;
                        var marginX = 0;
                        var marginY = 0;
                        var _var0 = new fm.icelink.Holder(marginX);
                        var _var1 = new fm.icelink.Holder(marginY);
                        var _var2 = this.calculateBlockFrame(layoutWidth, layoutHeight, _var0, _var1);
                        marginX = _var0.getValue();
                        marginY = _var1.getValue();
                        var frame = (local ? _var2 : null);
                        var list = new Array();
                        if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Center))) {
                            var count = fm.icelink.LayoutPreset.divideByTwo(remoteCount);
                            var num4 = (remoteCount - count);
                            var baseX = 0;
                            var baseY = 0;
                            if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Vertical))) {
                                num7 = ((fm.icelink.Global.equals(frame, null)) ? 0 : ((frame.getWidth() + marginX) + marginX));
                                layoutWidth = fm.icelink.LayoutPreset.divideByTwo((layoutWidth - num7));
                                baseX = (layoutWidth + num7);
                            }
                            else {
                                num8 = ((fm.icelink.Global.equals(frame, null)) ? 0 : ((frame.getHeight() + marginY) + marginY));
                                layoutHeight = fm.icelink.LayoutPreset.divideByTwo((layoutHeight - num8));
                                baseY = (layoutHeight + num8);
                            }
                            if ((count > 0)) {
                                fm.icelink.ArrayExtensions.addRange(list, this.calculateInlineFrames(layoutWidth, layoutHeight, count, 0, 0));
                            }
                            if ((num4 > 0)) {
                                fm.icelink.ArrayExtensions.addRange(list, this.calculateInlineFrames(layoutWidth, layoutHeight, num4, baseX, baseY));
                            }
                        }
                        else {
                            var num9 = 0;
                            var num10 = 0;
                            num7 = ((fm.icelink.Global.equals(frame, null)) ? 0 : (frame.getWidth() + marginX));
                            num8 = ((fm.icelink.Global.equals(frame, null)) ? 0 : (frame.getHeight() + marginY));
                            if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Top))) {
                                num10 = num8;
                                layoutHeight = (layoutHeight - num8);
                            }
                            else {
                                if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Bottom))) {
                                    layoutHeight = (layoutHeight - num8);
                                }
                                else {
                                    if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Left))) {
                                        num9 = num7;
                                        layoutWidth = (layoutWidth - num7);
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Right))) {
                                            layoutWidth = (layoutWidth - num7);
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Vertical))) {
                                                if (((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.TopLeft)) || (fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.BottomLeft)))) {
                                                    num9 = num7;
                                                }
                                                layoutWidth = (layoutWidth - num7);
                                            }
                                            else {
                                                if (((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.TopLeft)) || (fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.TopRight)))) {
                                                    num10 = num8;
                                                }
                                                layoutHeight = (layoutHeight - num8);
                                            }
                                        }
                                    }
                                }
                            }
                            fm.icelink.ArrayExtensions.addRange(list, this.calculateInlineFrames(layoutWidth, layoutHeight, remoteCount, num9, num10));
                        }
                        var layout = new fm.icelink.Layout();
                        layout.setOrigin(origin);
                        layout.setWidth(layoutWidth);
                        layout.setHeight(layoutHeight);
                        layout.setLocalFrame(frame);
                        layout.setRemoteFrames(fm.icelink.ArrayExtensions.toArray(list));
                        return layout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getBlockMarginX = function () {
                    if (arguments.length == 0) {
                        return this.__blockMarginX;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getBlockMarginXPercent = function () {
                    if (arguments.length == 0) {
                        return this.__blockMarginXPercent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getBlockMarginY = function () {
                    if (arguments.length == 0) {
                        return this.__blockMarginY;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getBlockMarginYPercent = function () {
                    if (arguments.length == 0) {
                        return this.__blockMarginYPercent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getBlockWidth = function () {
                    if (arguments.length == 0) {
                        return this.__blockWidth;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getBlockWidthPercent = function () {
                    if (arguments.length == 0) {
                        return this.__blockWidthPercent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getBottomRowIndexes = function (frames) {
                    if (arguments.length == 1) {
                        var num3 = void 0;
                        var yMax = fm.icelink.LayoutPreset.getYMax(frames);
                        var num2 = 0;
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getY(), yMax))) {
                                num2++;
                            }
                        }
                        var num4 = 0;
                        var numArray = new Array(num2);
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getY(), yMax))) {
                                numArray[num4++] = num3;
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getCenterColumnIndexes = function (frames) {
                    if (arguments.length == 1) {
                        var num3 = void 0;
                        var xMid = fm.icelink.LayoutPreset.getXMid(frames);
                        var num2 = 0;
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getX(), xMid))) {
                                num2++;
                            }
                        }
                        var num4 = 0;
                        var numArray = new Array(num2);
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getX(), xMid))) {
                                numArray[num4++] = num3;
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getCenterRowIndexes = function (frames) {
                    if (arguments.length == 1) {
                        var num3 = void 0;
                        var yMid = fm.icelink.LayoutPreset.getYMid(frames);
                        var num2 = 0;
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getY(), yMid))) {
                                num2++;
                            }
                        }
                        var num4 = 0;
                        var numArray = new Array(num2);
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getY(), yMid))) {
                                numArray[num4++] = num3;
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getDirection = function () {
                    if (arguments.length == 0) {
                        return this._direction;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getFloatHeight = function () {
                    if (arguments.length == 0) {
                        return this.__floatHeight;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getFloatHeightPercent = function () {
                    if (arguments.length == 0) {
                        return this.__floatHeightPercent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getFloatLocalLayout = function (layoutWidth, layoutHeight, local, remoteCount, origin) {
                    if (arguments.length == 5) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        remoteCount = fm.icelink.Global.toInt(arguments[3]);
                        if ((fm.icelink.Global.equals(remoteCount, 0))) {
                            return fm.icelink.LayoutPreset.getSingleLayout(layoutWidth, layoutHeight, local);
                        }
                        var layout = new fm.icelink.Layout();
                        layout.setOrigin(origin);
                        layout.setWidth(layoutWidth);
                        layout.setHeight(layoutHeight);
                        layout.setLocalFrame((local ? this.calculateFloatFrame(layoutWidth, layoutHeight) : null));
                        layout.setRemoteFrames(this.calculateInlineFrames(layoutWidth, layoutHeight, remoteCount, 0, 0));
                        return layout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getFloatMarginX = function () {
                    if (arguments.length == 0) {
                        return this.__floatMarginX;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getFloatMarginXPercent = function () {
                    if (arguments.length == 0) {
                        return this.__floatMarginXPercent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getFloatMarginY = function () {
                    if (arguments.length == 0) {
                        return this.__floatMarginY;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getFloatMarginYPercent = function () {
                    if (arguments.length == 0) {
                        return this.__floatMarginYPercent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getFloatRemoteLayout = function (layoutWidth, layoutHeight, local, remoteCount, origin) {
                    if (arguments.length == 5) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        remoteCount = fm.icelink.Global.toInt(arguments[3]);
                        var layout = new fm.icelink.Layout();
                        layout.setOrigin(origin);
                        layout.setWidth(layoutWidth);
                        layout.setHeight(layoutHeight);
                        layout.setLocalFrame((local ? this.calculateFillFrame(layoutWidth, layoutHeight) : null));
                        layout.setRemoteFrames(this.calculateFloatFrames(layoutWidth, layoutHeight, remoteCount));
                        return layout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getFloatWidth = function () {
                    if (arguments.length == 0) {
                        return this.__floatWidth;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getFloatWidthPercent = function () {
                    if (arguments.length == 0) {
                        return this.__floatWidthPercent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getInlineLayout = function (layoutWidth, layoutHeight, local, remoteCount, origin) {
                    if (arguments.length == 5) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        remoteCount = fm.icelink.Global.toInt(arguments[3]);
                        var frames_1 = this.calculateInlineFrames(layoutWidth, layoutHeight, (remoteCount + (local ? 1 : 0)), 0, 0);
                        var index = -1;
                        if (local) {
                            if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.TopLeft))) {
                                index = 0;
                            }
                            else {
                                if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Top))) {
                                    var topRowIndexes = this.getTopRowIndexes(frames_1);
                                    index = topRowIndexes[fm.icelink.LayoutPreset.divideByTwo(topRowIndexes.length)];
                                }
                                else {
                                    var centerRowIndexes = void 0;
                                    if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.TopRight))) {
                                        if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Horizontal))) {
                                            centerRowIndexes = this.getTopRowIndexes(frames_1);
                                            index = centerRowIndexes[(centerRowIndexes.length - 1)];
                                        }
                                        else {
                                            index = this.getRightColumnIndexes(frames_1)[0];
                                        }
                                    }
                                    else {
                                        var leftColumnIndexes = void 0;
                                        if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Left))) {
                                            leftColumnIndexes = this.getLeftColumnIndexes(frames_1);
                                            index = leftColumnIndexes[fm.icelink.LayoutPreset.divideByTwo(leftColumnIndexes.length)];
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Center))) {
                                                if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Horizontal))) {
                                                    centerRowIndexes = this.getCenterRowIndexes(frames_1);
                                                    index = centerRowIndexes[fm.icelink.LayoutPreset.divideByTwo(centerRowIndexes.length)];
                                                }
                                                else {
                                                    leftColumnIndexes = this.getCenterColumnIndexes(frames_1);
                                                    index = leftColumnIndexes[fm.icelink.LayoutPreset.divideByTwo(leftColumnIndexes.length)];
                                                }
                                            }
                                            else {
                                                if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Right))) {
                                                    leftColumnIndexes = this.getRightColumnIndexes(frames_1);
                                                    index = leftColumnIndexes[fm.icelink.LayoutPreset.divideByTwo(leftColumnIndexes.length)];
                                                }
                                                else {
                                                    if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.BottomLeft))) {
                                                        if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Horizontal))) {
                                                            index = this.getBottomRowIndexes(frames_1)[0];
                                                        }
                                                        else {
                                                            leftColumnIndexes = this.getLeftColumnIndexes(frames_1);
                                                            index = leftColumnIndexes[(leftColumnIndexes.length - 1)];
                                                        }
                                                    }
                                                    else {
                                                        if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Bottom))) {
                                                            centerRowIndexes = this.getBottomRowIndexes(frames_1);
                                                            index = centerRowIndexes[fm.icelink.LayoutPreset.divideByTwo(centerRowIndexes.length)];
                                                        }
                                                        else {
                                                            if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.BottomRight))) {
                                                                index = (frames_1.length - 1);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        var layout = new fm.icelink.Layout();
                        layout.setOrigin(origin);
                        layout.setWidth(layoutWidth);
                        layout.setHeight(layoutHeight);
                        layout.setLocalFrame(((fm.icelink.Global.equals(index, -1)) ? null : frames_1[index]));
                        layout.setRemoteFrames(((fm.icelink.Global.equals(index, -1)) ? frames_1 : fm.icelink.LayoutPreset.spliceLayoutFrame(frames_1, index)));
                        return layout;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getInlineMargin = function () {
                    if (arguments.length == 0) {
                        return this._inlineMargin;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getInlineOverflowLayout = function (layoutWidth, layoutHeight, origin, localVideoSize, remoteVideoSizes) {
                    if (arguments.length == 5) {
                        layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        var frames_4 = this.calculateInlineOverflowFrames(layoutWidth, layoutHeight, 0, 0, localVideoSize, remoteVideoSizes);
                        if ((fm.icelink.Global.equals(frames_4.length, 0))) {
                            var layout = new fm.icelink.Layout();
                            layout.setOrigin(origin);
                            layout.setWidth(layoutWidth);
                            layout.setHeight(layoutHeight);
                            layout.setLocalFrame(null);
                            layout.setRemoteFrames(new Array(0));
                            return layout;
                        }
                        var index = -1;
                        if ((!fm.icelink.Global.equals(localVideoSize, null))) {
                            if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.TopLeft))) {
                                index = 0;
                            }
                            else {
                                if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Top))) {
                                    var topRowIndexes = this.getTopRowIndexes(frames_4);
                                    index = topRowIndexes[fm.icelink.LayoutPreset.divideByTwo(topRowIndexes.length)];
                                }
                                else {
                                    var centerRowIndexes = void 0;
                                    if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.TopRight))) {
                                        if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Horizontal))) {
                                            centerRowIndexes = this.getTopRowIndexes(frames_4);
                                            index = centerRowIndexes[(centerRowIndexes.length - 1)];
                                        }
                                        else {
                                            index = this.getRightColumnIndexes(frames_4)[0];
                                        }
                                    }
                                    else {
                                        var leftColumnIndexes = void 0;
                                        if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Left))) {
                                            leftColumnIndexes = this.getLeftColumnIndexes(frames_4);
                                            index = leftColumnIndexes[fm.icelink.LayoutPreset.divideByTwo(leftColumnIndexes.length)];
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Center))) {
                                                if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Horizontal))) {
                                                    centerRowIndexes = this.getCenterRowIndexes(frames_4);
                                                    index = centerRowIndexes[fm.icelink.LayoutPreset.divideByTwo(centerRowIndexes.length)];
                                                }
                                                else {
                                                    leftColumnIndexes = this.getCenterColumnIndexes(frames_4);
                                                    index = leftColumnIndexes[fm.icelink.LayoutPreset.divideByTwo(leftColumnIndexes.length)];
                                                }
                                            }
                                            else {
                                                if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Right))) {
                                                    leftColumnIndexes = this.getRightColumnIndexes(frames_4);
                                                    index = leftColumnIndexes[fm.icelink.LayoutPreset.divideByTwo(leftColumnIndexes.length)];
                                                }
                                                else {
                                                    if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.BottomLeft))) {
                                                        if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Horizontal))) {
                                                            index = this.getBottomRowIndexes(frames_4)[0];
                                                        }
                                                        else {
                                                            leftColumnIndexes = this.getLeftColumnIndexes(frames_4);
                                                            index = leftColumnIndexes[(leftColumnIndexes.length - 1)];
                                                        }
                                                    }
                                                    else {
                                                        if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.Bottom))) {
                                                            centerRowIndexes = this.getBottomRowIndexes(frames_4);
                                                            index = centerRowIndexes[fm.icelink.LayoutPreset.divideByTwo(centerRowIndexes.length)];
                                                        }
                                                        else {
                                                            if ((fm.icelink.Global.equals(this.getAlignment(), fm.icelink.LayoutAlignment.BottomRight))) {
                                                                index = (frames_4.length - 1);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ((fm.icelink.Global.equals(this.getDirection(), fm.icelink.LayoutDirection.Horizontal))) {
                            var num2 = 0;
                            for (var _i = 0, frames_2 = frames_4; _i < frames_2.length; _i++) {
                                var frame = frames_2[_i];
                                num2 = (num2 + frame.getWidth());
                            }
                            var layout2 = new fm.icelink.Layout();
                            layout2.setOrigin(origin);
                            layout2.setWidth(num2);
                            layout2.setHeight(layoutHeight);
                            layout2.setLocalFrame(((fm.icelink.Global.equals(index, -1)) ? null : frames_4[index]));
                            layout2.setRemoteFrames(((fm.icelink.Global.equals(index, -1)) ? frames_4 : fm.icelink.LayoutPreset.spliceLayoutFrame(frames_4, index)));
                            return layout2;
                        }
                        var num3 = 0;
                        for (var _a = 0, frames_3 = frames_4; _a < frames_3.length; _a++) {
                            var frame = frames_3[_a];
                            num3 = (num3 + frame.getHeight());
                        }
                        var layout3 = new fm.icelink.Layout();
                        layout3.setOrigin(origin);
                        layout3.setWidth(layoutWidth);
                        layout3.setHeight(num3);
                        layout3.setLocalFrame(((fm.icelink.Global.equals(index, -1)) ? null : frames_4[index]));
                        layout3.setRemoteFrames(((fm.icelink.Global.equals(index, -1)) ? frames_4 : fm.icelink.LayoutPreset.spliceLayoutFrame(frames_4, index)));
                        return layout3;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getLeftColumnIndexes = function (frames) {
                    if (arguments.length == 1) {
                        var num3 = void 0;
                        var xMin = fm.icelink.LayoutPreset.getXMin(frames);
                        var num2 = 0;
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getX(), xMin))) {
                                num2++;
                            }
                        }
                        var num4 = 0;
                        var numArray = new Array(num2);
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getX(), xMin))) {
                                numArray[num4++] = num3;
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getMode = function () {
                    if (arguments.length == 0) {
                        return this._mode;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getRightColumnIndexes = function (frames) {
                    if (arguments.length == 1) {
                        var num3 = void 0;
                        var xMax = fm.icelink.LayoutPreset.getXMax(frames);
                        var num2 = 0;
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getX(), xMax))) {
                                num2++;
                            }
                        }
                        var num4 = 0;
                        var numArray = new Array(num2);
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getX(), xMax))) {
                                numArray[num4++] = num3;
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.getTopRowIndexes = function (frames) {
                    if (arguments.length == 1) {
                        var num3 = void 0;
                        var yMin = fm.icelink.LayoutPreset.getYMin(frames);
                        var num2 = 0;
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getY(), yMin))) {
                                num2++;
                            }
                        }
                        var num4 = 0;
                        var numArray = new Array(num2);
                        for (num3 = 0; (num3 < frames.length); num3++) {
                            if ((fm.icelink.Global.equals(frames[num3].getY(), yMin))) {
                                numArray[num4++] = num3;
                            }
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setAlignment = function (value) {
                    if (arguments.length == 1) {
                        this._alignment = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setBlockHeight = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__blockHeight = fm.icelink.Global.toInt(value);
                        this.__blockHeightPercent = 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setBlockHeightPercent = function (value) {
                    if (arguments.length == 1) {
                        if ((value < 0)) {
                            value = 0;
                        }
                        if ((value > 1)) {
                            value = 1;
                        }
                        this.__blockHeightPercent = value;
                        this.__blockHeight = fm.icelink.Global.toInt(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setBlockMarginX = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__blockMarginX = fm.icelink.Global.toInt(value);
                        this.__blockMarginXPercent = 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setBlockMarginXPercent = function (value) {
                    if (arguments.length == 1) {
                        if ((value < 0)) {
                            value = 0;
                        }
                        if ((value > 1)) {
                            value = 1;
                        }
                        this.__blockMarginXPercent = value;
                        this.__blockMarginX = fm.icelink.Global.toInt(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setBlockMarginY = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__blockMarginY = fm.icelink.Global.toInt(value);
                        this.__blockMarginYPercent = 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setBlockMarginYPercent = function (value) {
                    if (arguments.length == 1) {
                        if ((value < 0)) {
                            value = 0;
                        }
                        if ((value > 1)) {
                            value = 1;
                        }
                        this.__blockMarginYPercent = value;
                        this.__blockMarginY = fm.icelink.Global.toInt(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setBlockWidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__blockWidth = fm.icelink.Global.toInt(value);
                        this.__blockWidthPercent = 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setBlockWidthPercent = function (value) {
                    if (arguments.length == 1) {
                        if ((value < 0)) {
                            value = 0;
                        }
                        if ((value > 1)) {
                            value = 1;
                        }
                        this.__blockWidthPercent = value;
                        this.__blockWidth = fm.icelink.Global.toInt(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setDirection = function (value) {
                    if (arguments.length == 1) {
                        this._direction = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setFloatHeight = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__floatHeight = fm.icelink.Global.toInt(value);
                        this.__floatHeightPercent = 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setFloatHeightPercent = function (value) {
                    if (arguments.length == 1) {
                        if ((value < 0)) {
                            value = 0;
                        }
                        if ((value > 1)) {
                            value = 1;
                        }
                        this.__floatHeightPercent = value;
                        this.__floatHeight = fm.icelink.Global.toInt(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setFloatMarginX = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__floatMarginX = fm.icelink.Global.toInt(value);
                        this.__floatMarginXPercent = 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setFloatMarginXPercent = function (value) {
                    if (arguments.length == 1) {
                        if ((value < 0)) {
                            value = 0;
                        }
                        if ((value > 1)) {
                            value = 1;
                        }
                        this.__floatMarginXPercent = value;
                        this.__floatMarginX = fm.icelink.Global.toInt(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setFloatMarginY = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__floatMarginY = fm.icelink.Global.toInt(value);
                        this.__floatMarginYPercent = 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setFloatMarginYPercent = function (value) {
                    if (arguments.length == 1) {
                        if ((value < 0)) {
                            value = 0;
                        }
                        if ((value > 1)) {
                            value = 1;
                        }
                        this.__floatMarginYPercent = value;
                        this.__floatMarginY = fm.icelink.Global.toInt(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setFloatWidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__floatWidth = fm.icelink.Global.toInt(value);
                        this.__floatWidthPercent = 0;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setFloatWidthPercent = function (value) {
                    if (arguments.length == 1) {
                        if ((value < 0)) {
                            value = 0;
                        }
                        if ((value > 1)) {
                            value = 1;
                        }
                        this.__floatWidthPercent = value;
                        this.__floatWidth = fm.icelink.Global.toInt(0);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setInlineMargin = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._inlineMargin = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutPreset.prototype.setMode = function (value) {
                    if (arguments.length == 1) {
                        this._mode = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LayoutPreset;
            }(fm.icelink.Dynamic));
            icelink.LayoutPreset = LayoutPreset;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LayoutManager =  (function (_super) {
                __extends(LayoutManager, _super);
                function LayoutManager() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        __arguments = new Array(1);
                        __arguments[0] = null;
                        {
                            var preset = __arguments[0];
                            _this = _super.call(this) || this;
                            _this.fmicelinkLayoutManagerInit();
                            _this._remoteViewsTable = {};
                            _this._remoteViewsLock = new Object();
                            _this._localView = null;
                            _this._inBatch = false;
                            if ((fm.icelink.Global.equals(preset, null))) {
                                preset = fm.icelink.LayoutPreset.getFacetime();
                            }
                            preset.copyToPreset(_this);
                            _this.setLayoutOrigin(fm.icelink.LayoutOrigin.TopLeft);
                        }
                    }
                    else if (__arguments.length == 1) {
                        var preset = __arguments[0];
                        _this = _super.call(this) || this;
                        _this.fmicelinkLayoutManagerInit();
                        _this._remoteViewsTable = {};
                        _this._remoteViewsLock = new Object();
                        _this._localView = null;
                        _this._inBatch = false;
                        if ((fm.icelink.Global.equals(preset, null))) {
                            preset = fm.icelink.LayoutPreset.getFacetime();
                        }
                        preset.copyToPreset(_this);
                        _this.setLayoutOrigin(fm.icelink.LayoutOrigin.TopLeft);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                LayoutManager.prototype.getTypeString = function () {
                    return '[fm.icelink.LayoutManager]' + ',' + _super.prototype.getTypeString.call(this);
                };
                LayoutManager.prototype.fmicelinkLayoutManagerInit = function () {
                    var _this = this;
                    this.__onLayout = [];
                    this._inBatch = false;
                    this._onLayout = function (p0) { for (var _i = 0, _a = _this.__onLayout; _i < _a.length; _i++) {
                        var action = _a[_i];
                        action(p0);
                    } };
                };
                LayoutManager.prototype.addOnLayout = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.add(this.__onLayout, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.addRemoteMedia = function (remoteMedia) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(remoteMedia, null))) {
                            return false;
                        }
                        return this.addRemoteView(remoteMedia.getId(), remoteMedia.getView());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.addRemoteView = function (idValue, view) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(idValue, null))) {
                            fm.icelink.Log.warn("Could not add remote view. The ID cannot be null.");
                            return false;
                        }
                        if ((fm.icelink.Global.equals(view, null))) {
                            fm.icelink.Log.warn("Could not add remote view. The view cannot be null.");
                            return false;
                        }
                        try {
                            this.dispatchToMainThread(this.addRemoteViewUI.bind(this), idValue, view);
                        }
                        catch (exception) {
                            fm.icelink.Log.error("Could not add remote view.", exception);
                        }
                        finally {
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.addRemoteViews = function (ids, views) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(ids, null))) {
                            fm.icelink.Log.warn("Could not add remote views. The IDs cannot be null.");
                            return false;
                        }
                        if ((fm.icelink.Global.equals(views, null))) {
                            fm.icelink.Log.warn("Could not add remote views. The views cannot be null.");
                            return false;
                        }
                        if ((!fm.icelink.Global.equals(ids.length, views.length))) {
                            fm.icelink.Log.warn("Could not add remote views. The number of IDs and views must match.");
                            return false;
                        }
                        try {
                            this.dispatchToMainThread(this.addRemoteViewsUI.bind(this), ids, views);
                        }
                        catch (exception) {
                            fm.icelink.Log.error("Could not add remote views.", exception);
                        }
                        finally {
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.addRemoteViewsUI = function (idsObj, viewsObj) {
                    if (arguments.length == 2) {
                        var strArray = idsObj;
                        var localArray = viewsObj;
                        this._inBatch = true;
                        for (var i = 0; (i < strArray.length); i++) {
                            this.addRemoteViewUI(strArray[i], localArray[i]);
                        }
                        this._inBatch = false;
                        this.layout();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.addRemoteViewUI = function (idObj, viewObj) {
                    if (arguments.length == 2) {
                        var idValue = idObj;
                        var item = viewObj;
                        var list = new Array();
                        fm.icelink.ArrayExtensions.add(list, item);
                        var remoteViewsInternal = this.getRemoteViewsInternal(idValue);
                        if ((!fm.icelink.Global.equals(remoteViewsInternal, null))) {
                            fm.icelink.ArrayExtensions.addRange(list, remoteViewsInternal);
                        }
                        this.addView(item);
                        this._remoteViewsTable[idValue] = list;
                        if (!this._inBatch) {
                            this.layout();
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.doGetLocalView = function () {
                    if (arguments.length == 0) {
                        return this._localView;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.doGetRemoteViews = function (idValue) {
                    if (arguments.length == 1) {
                        var list = null;
                        var _var0 = new fm.icelink.Holder(list);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(this._remoteViewsTable, idValue, _var0);
                        list = _var0.getValue();
                        if (!_var1) {
                            list = null;
                        }
                        return list;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.doGetRemoteViewsIds = function () {
                    if (arguments.length == 0) {
                        var list = new Array();
                        for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(this._remoteViewsTable); _i < _a.length; _i++) {
                            var str = _a[_i];
                            fm.icelink.ArrayExtensions.add(list, str);
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.doSwapRemoteView = function (idToRemove, viewToRemove, idToAdd, viewToAdd) {
                    var _this = this;
                    if (arguments.length == 4) {
                        var action = null;
                        try {
                            if ((fm.icelink.Global.equals(action, null))) {
                                action = function (unused1, unused2) {
                                    if ((!fm.icelink.Global.equals(viewToRemove, null))) {
                                        _this.removeRemoteViewUI(idToRemove, viewToRemove);
                                    }
                                    _this.addRemoteViewUI(idToAdd, viewToAdd);
                                };
                            }
                            this.dispatchToMainThread(action, null, null);
                        }
                        catch (exception) {
                            fm.icelink.Log.error("Could not swap remote view.", exception);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.doSwapRemoteViews = function (idsToRemove, viewsToRemove, idsToAdd, viewsToAdd) {
                    var _this = this;
                    if (arguments.length == 4) {
                        var action = null;
                        try {
                            if ((fm.icelink.Global.equals(action, null))) {
                                action = function (unused1, unused2) {
                                    _this.removeRemoteViewsUI(idsToRemove, viewsToRemove);
                                    _this.addRemoteViewsUI(idsToAdd, viewsToAdd);
                                };
                            }
                            this.dispatchToMainThread(action, null, null);
                        }
                        catch (exception) {
                            fm.icelink.Log.error("Could not swap remote views.", exception);
                        }
                        finally {
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.getLayout = function () {
                    if (arguments.length == 4 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || fm.icelink.Util.isBoolean(arguments[2])) && (fm.icelink.Util.isNullOrUndefined(arguments[3]) || fm.icelink.Util.isNumber(arguments[3]))) {
                        var layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        var layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        var local = arguments[2];
                        var remoteCount = fm.icelink.Global.toInt(arguments[3]);
                        return this.getLayout(layoutWidth, layoutHeight, local, remoteCount, null, null, null);
                    }
                    else if (arguments.length == 5) {
                        var layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        var layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        var local = arguments[2];
                        var remoteCount = fm.icelink.Global.toInt(arguments[3]);
                        var remoteViewIds = arguments[4];
                        return this.getLayout(layoutWidth, layoutHeight, local, remoteCount, remoteViewIds, null, null);
                    }
                    else if (arguments.length == 7) {
                        var layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        var layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        var local = arguments[2];
                        var remoteCount = fm.icelink.Global.toInt(arguments[3]);
                        var remoteViewIds = arguments[4];
                        var localVideoSize = arguments[5];
                        var remoteVideoSizes = arguments[6];
                        var p = _super.prototype.calculateLayout.call(this, layoutWidth, layoutHeight, local, remoteCount, this.getLayoutOrigin(), localVideoSize, remoteVideoSizes);
                        if ((!fm.icelink.Global.equals(remoteViewIds, null))) {
                            var remoteFrames = p.getRemoteFrames();
                            for (var i = 0; (i < remoteFrames.length); i++) {
                                var frame = remoteFrames[i];
                                frame.setViewId(remoteViewIds[i]);
                            }
                        }
                        var onLayout = this._onLayout;
                        if ((!fm.icelink.Global.equals(onLayout, null))) {
                            try {
                                onLayout(p);
                            }
                            catch (exception) {
                                fm.icelink.Unhandled.logException(exception, "LayoutManager -> OnLayout");
                            }
                            finally {
                            }
                        }
                        return p;
                    }
                    else if (arguments.length == 3) {
                        var layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        var layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        var remoteCount = fm.icelink.Global.toInt(arguments[2]);
                        return this.getLayout(layoutWidth, layoutHeight, true, remoteCount, null, null, null);
                    }
                    else if (arguments.length == 4 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || fm.icelink.Util.isNumber(arguments[2])) && (fm.icelink.Util.isNullOrUndefined(arguments[3]) || (fm.icelink.Util.isArray(arguments[3]) && (arguments[3].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[3][0]) || fm.icelink.Util.isString(arguments[3][0])))))) {
                        var layoutWidth = fm.icelink.Global.toInt(arguments[0]);
                        var layoutHeight = fm.icelink.Global.toInt(arguments[1]);
                        var remoteCount = fm.icelink.Global.toInt(arguments[2]);
                        var remoteViewIds = arguments[3];
                        return this.getLayout(layoutWidth, layoutHeight, true, remoteCount, remoteViewIds, null, null);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.getLayoutOrigin = function () {
                    if (arguments.length == 0) {
                        return this._layoutOrigin;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.getLocalView = function () {
                    if (arguments.length == 0) {
                        return this.doGetLocalView();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.getNewestRemoteView = function (idValue) {
                    if (arguments.length == 1) {
                        var remoteViewsInternal = this.getRemoteViewsInternal(idValue);
                        if ((fm.icelink.Global.equals(remoteViewsInternal, null))) {
                            return null;
                        }
                        return remoteViewsInternal[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.getOldestRemoteView = function (idValue) {
                    if (arguments.length == 1) {
                        var remoteViewsInternal = this.getRemoteViewsInternal(idValue);
                        if ((fm.icelink.Global.equals(remoteViewsInternal, null))) {
                            return null;
                        }
                        return remoteViewsInternal[(fm.icelink.ArrayExtensions.getCount(remoteViewsInternal) - 1)];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.getRemoteView = function (idValue) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(idValue, null))) {
                            return null;
                        }
                        return this.getNewestRemoteView(idValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.getRemoteViewIds = function () {
                    if (arguments.length == 0) {
                        return this.doGetRemoteViewsIds();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.getRemoteViews = function () {
                    if (arguments.length == 0) {
                        return this.getRemoteViews(this.getRemoteViewIds());
                    }
                    else if (arguments.length == 1) {
                        var ids = arguments[0];
                        if ((fm.icelink.Global.equals(ids, null))) {
                            throw new fm.icelink.Exception("Could not get remote views. The IDs cannot be null.");
                        }
                        var list = new Array();
                        for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
                            var str = ids_1[_i];
                            fm.icelink.ArrayExtensions.add(list, this.getRemoteView(str));
                        }
                        return list;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.getRemoteViewsInternal = function (idValue) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(idValue, null))) {
                            throw new fm.icelink.Exception("The ID cannot be null.");
                        }
                        return this.doGetRemoteViews(idValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.layoutOnMainThread = function () {
                    if (arguments.length == 0) {
                        this.dispatchToMainThread(this.layoutOnMainThreadUI.bind(this), null, null);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.layoutOnMainThreadUI = function (unused1, unused2) {
                    if (arguments.length == 2) {
                        this.layout();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.removeOnLayout = function (value) {
                    if (arguments.length == 1) {
                        fm.icelink.ArrayExtensions.remove(this.__onLayout, value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.removeRemoteMedia = function (remoteMedia) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(remoteMedia, null))) {
                            return false;
                        }
                        return this.removeRemoteView(remoteMedia.getId());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.removeRemoteView = function (idValue) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(idValue, null))) {
                            fm.icelink.Log.warn("Could not remove remote view. The ID cannot be null.");
                            return false;
                        }
                        var oldestRemoteView = this.getOldestRemoteView(idValue);
                        if ((!fm.icelink.Global.equals(oldestRemoteView, null))) {
                            try {
                                this.dispatchToMainThread(this.removeRemoteViewUI.bind(this), idValue, oldestRemoteView);
                            }
                            catch (exception) {
                                fm.icelink.Log.error("Could not remove remote view.", exception);
                            }
                            finally {
                            }
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.removeRemoteViews = function () {
                    if (arguments.length == 0) {
                        this.removeRemoteViews(this.getRemoteViewIds());
                    }
                    else if (arguments.length == 1) {
                        var ids = arguments[0];
                        if ((fm.icelink.Global.equals(ids, null))) {
                            fm.icelink.Log.warn("Could not remove remote views. The IDs cannot be null.");
                            return false;
                        }
                        try {
                            this.dispatchToMainThread(this.removeRemoteViewsUI.bind(this), ids, this.getRemoteViews(ids));
                        }
                        catch (exception) {
                            fm.icelink.Log.error("Could not remove remote views.", exception);
                        }
                        finally {
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.removeRemoteViewsUI = function (idsObj, viewsObj) {
                    if (arguments.length == 2) {
                        var strArray = idsObj;
                        var list = viewsObj;
                        this._inBatch = true;
                        for (var i = 0; (i < strArray.length); i++) {
                            this.removeRemoteViewUI(strArray[i], list[i]);
                        }
                        this._inBatch = false;
                        this.layout();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.removeRemoteViewUI = function (idObj, viewObj) {
                    if (arguments.length == 2) {
                        var idValue = idObj;
                        var item = viewObj;
                        var list = new Array();
                        var remoteViewsInternal = this.getRemoteViewsInternal(idValue);
                        if ((!fm.icelink.Global.equals(remoteViewsInternal, null))) {
                            fm.icelink.ArrayExtensions.addRange(list, remoteViewsInternal);
                        }
                        fm.icelink.ArrayExtensions.remove(list, item);
                        this.removeView(item);
                        if ((fm.icelink.Global.equals(fm.icelink.ArrayExtensions.getCount(list), 0))) {
                            fm.icelink.HashExtensions.remove(this._remoteViewsTable, idValue);
                        }
                        else {
                            this._remoteViewsTable[idValue] = list;
                        }
                        if (!this._inBatch) {
                            this.layout();
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.reset = function () {
                    if (arguments.length == 0) {
                        this.removeRemoteViews();
                        this.unsetLocalView();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.setLayoutOrigin = function (value) {
                    if (arguments.length == 1) {
                        this._layoutOrigin = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.setLocalMedia = function (localMedia) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(localMedia, null))) {
                            return false;
                        }
                        return this.setLocalView(localMedia.getView());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.setLocalView = function (view) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(view, null))) {
                            fm.icelink.Log.warn("Could not set local view. The view cannot be null.");
                            return false;
                        }
                        if ((!fm.icelink.Global.equals(view, null))) {
                            try {
                                this.dispatchToMainThread(this.setLocalViewUI.bind(this), view, null);
                            }
                            catch (exception) {
                                fm.icelink.Log.error("Could not set local view.", exception);
                            }
                            finally {
                            }
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.setLocalViewUI = function (viewObj, unused) {
                    if (arguments.length == 2) {
                        var view = viewObj;
                        var localView = this._localView;
                        if ((!fm.icelink.Global.equals(localView, null))) {
                            this.removeView(localView);
                        }
                        this._localView = view;
                        this.addView(view);
                        this.layout();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.swapRemoteMedia = function (remoteMediaToRemove, remoteMediaToAdd) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(remoteMediaToRemove, null))) {
                            return false;
                        }
                        if ((fm.icelink.Global.equals(remoteMediaToAdd, null))) {
                            return false;
                        }
                        return this.swapRemoteView(remoteMediaToRemove.getId(), remoteMediaToAdd.getId(), remoteMediaToAdd.getView());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.swapRemoteView = function (idToRemove, idToAdd, viewToAdd) {
                    if (arguments.length == 3) {
                        if ((fm.icelink.Global.equals(idToRemove, null))) {
                            fm.icelink.Log.warn("Could not swap remote view. The ID to remove cannot be null.");
                            return false;
                        }
                        if ((fm.icelink.Global.equals(idToAdd, null))) {
                            fm.icelink.Log.warn("Could not swap remote view. The ID to add cannot be null.");
                            return false;
                        }
                        if ((fm.icelink.Global.equals(viewToAdd, null))) {
                            fm.icelink.Log.warn("Could not swap remote view. The view to add cannot be null.");
                            return false;
                        }
                        this.doSwapRemoteView(idToRemove, this.getOldestRemoteView(idToRemove), idToAdd, viewToAdd);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.swapRemoteViews = function (idsToRemove, idsToAdd, viewsToAdd) {
                    if (arguments.length == 3) {
                        if ((fm.icelink.Global.equals(idsToRemove, null))) {
                            fm.icelink.Log.warn("Could not swap remote views. The IDs to remove cannot be null.");
                            return false;
                        }
                        if ((fm.icelink.Global.equals(idsToAdd, null))) {
                            fm.icelink.Log.warn("Could not swap remote views. The IDs to add cannot be null.");
                            return false;
                        }
                        if ((fm.icelink.Global.equals(viewsToAdd, null))) {
                            fm.icelink.Log.warn("Could not swap remote views. The views to add cannot be null.");
                            return false;
                        }
                        if ((!fm.icelink.Global.equals(idsToAdd.length, viewsToAdd.length))) {
                            fm.icelink.Log.warn("Could not swap remote views. The number of IDs and views to add must match.");
                            return false;
                        }
                        this.doSwapRemoteViews(idsToRemove, this.getRemoteViews(idsToRemove), idsToAdd, viewsToAdd);
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.unsetLocalView = function () {
                    if (arguments.length == 0) {
                        var localView = this.getLocalView();
                        if ((fm.icelink.Global.equals(localView, null))) {
                            fm.icelink.Log.warn("Could not unset local view. A view does not exist.");
                            return false;
                        }
                        try {
                            this.dispatchToMainThread(this.unsetLocalViewUI.bind(this), localView, null);
                        }
                        catch (exception) {
                            fm.icelink.Log.error("Could not unset local view.", exception);
                        }
                        finally {
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutManager.prototype.unsetLocalViewUI = function (viewObj, unused) {
                    if (arguments.length == 2) {
                        var view = viewObj;
                        this._localView = null;
                        this.removeView(view);
                        this.layout();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LayoutManager;
            }(fm.icelink.LayoutPreset));
            icelink.LayoutManager = LayoutManager;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LayoutModeWrapper =  (function () {
                function LayoutModeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_32 = __arguments[0];
                        this._value = value_32;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LayoutModeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.LayoutModeWrapper]';
                };
                LayoutModeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.LayoutMode.FloatLocal)
                            return 'FloatLocal';
                        if (this._value == fm.icelink.LayoutMode.FloatRemote)
                            return 'FloatRemote';
                        if (this._value == fm.icelink.LayoutMode.Block)
                            return 'Block';
                        if (this._value == fm.icelink.LayoutMode.Inline)
                            return 'Inline';
                        if (this._value == fm.icelink.LayoutMode.InlineOverflow)
                            return 'InlineOverflow';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LayoutModeWrapper;
            }());
            icelink.LayoutModeWrapper = LayoutModeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LayoutOriginWrapper =  (function () {
                function LayoutOriginWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_33 = __arguments[0];
                        this._value = value_33;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LayoutOriginWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.LayoutOriginWrapper]';
                };
                LayoutOriginWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.LayoutOrigin.TopLeft)
                            return 'TopLeft';
                        if (this._value == fm.icelink.LayoutOrigin.TopRight)
                            return 'TopRight';
                        if (this._value == fm.icelink.LayoutOrigin.BottomRight)
                            return 'BottomRight';
                        if (this._value == fm.icelink.LayoutOrigin.BottomLeft)
                            return 'BottomLeft';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LayoutOriginWrapper;
            }());
            icelink.LayoutOriginWrapper = LayoutOriginWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LayoutTable =  (function () {
                function LayoutTable(columnCount, rowCount, cellWidth, cellHeight) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 4) {
                        var columnCount_1 = __arguments[0];
                        var rowCount_1 = __arguments[1];
                        var cellWidth_1 = __arguments[2];
                        var cellHeight_1 = __arguments[3];
                        this.fmicelinkLayoutTableInit();
                        this.setColumnCount(columnCount_1);
                        this.setRowCount(rowCount_1);
                        this.setCellWidth(cellWidth_1);
                        this.setCellHeight(cellHeight_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LayoutTable.prototype.getTypeString = function () {
                    return '[fm.icelink.LayoutTable]';
                };
                LayoutTable.prototype.fmicelinkLayoutTableInit = function () {
                    this._cellHeight = 0;
                    this._cellWidth = 0;
                    this._columnCount = 0;
                    this._rowCount = 0;
                };
                LayoutTable.prototype.getCellHeight = function () {
                    if (arguments.length == 0) {
                        return this._cellHeight;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutTable.prototype.getCellWidth = function () {
                    if (arguments.length == 0) {
                        return this._cellWidth;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutTable.prototype.getColumnCount = function () {
                    if (arguments.length == 0) {
                        return this._columnCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutTable.prototype.getRowCount = function () {
                    if (arguments.length == 0) {
                        return this._rowCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutTable.prototype.setCellHeight = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._cellHeight = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutTable.prototype.setCellWidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._cellWidth = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutTable.prototype.setColumnCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._columnCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutTable.prototype.setRowCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._rowCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LayoutTable;
            }());
            icelink.LayoutTable = LayoutTable;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcMediaBase =  (function (_super) {
                __extends(WebRtcMediaBase, _super);
                function WebRtcMediaBase() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.setId(fm.icelink.Utility.generateId());
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebRtcMediaBase.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcMediaBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcMediaBase.prototype.getAudioGain = function () {
                    if (arguments.length == 0) {
                        var audioTrack = this.getAudioTrack();
                        if ((!fm.icelink.Global.equals(audioTrack, null))) {
                            return audioTrack.getGain();
                        }
                        return 1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.getAudioMuted = function () {
                    if (arguments.length == 0) {
                        var audioTrack = this.getAudioTrack();
                        return ((!fm.icelink.Global.equals(audioTrack, null)) && audioTrack.getMuted());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.getAudioTrack = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getAudioTracks());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.getAudioVolume = function () {
                    if (arguments.length == 0) {
                        var audioTrack = this.getAudioTrack();
                        if ((!fm.icelink.Global.equals(audioTrack, null))) {
                            return audioTrack.getVolume();
                        }
                        return 1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this._id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.getVideoMuted = function () {
                    if (arguments.length == 0) {
                        var videoTrack = this.getVideoTrack();
                        return ((!fm.icelink.Global.equals(videoTrack, null)) && videoTrack.getMuted());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.getVideoTrack = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getVideoTracks());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.setAudioGain = function (value) {
                    if (arguments.length == 1) {
                        var audioTrack = this.getAudioTrack();
                        if ((!fm.icelink.Global.equals(audioTrack, null))) {
                            audioTrack.setGain(value);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.setAudioMuted = function (value) {
                    if (arguments.length == 1) {
                        var audioTrack = this.getAudioTrack();
                        if ((!fm.icelink.Global.equals(audioTrack, null))) {
                            audioTrack.setMuted(value);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.setAudioVolume = function (value) {
                    if (arguments.length == 1) {
                        var audioTrack = this.getAudioTrack();
                        if ((!fm.icelink.Global.equals(audioTrack, null))) {
                            audioTrack.setVolume(value);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.setId = function (value) {
                    if (arguments.length == 1) {
                        this._id = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcMediaBase.prototype.setVideoMuted = function (value) {
                    if (arguments.length == 1) {
                        var videoTrack = this.getVideoTrack();
                        if ((!fm.icelink.Global.equals(videoTrack, null))) {
                            videoTrack.setMuted(value);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return WebRtcMediaBase;
            }(fm.icelink.Dynamic));
            icelink.WebRtcMediaBase = WebRtcMediaBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcMedia =  (function (_super) {
                __extends(WebRtcMedia, _super);
                function WebRtcMedia(external) {
                    var _this = _super.call(this) || this;
                    _this._audioMediaStream = null;
                    _this._videoMediaStream = null;
                    _this._audioTrack = null;
                    _this._videoTrack = null;
                    _this._audioSink = null;
                    _this._videoSink = null;
                    _this._onAudioLevelValues = [];
                    _this._onVideoSizeValues = [];
                    _this._onAudioDestroyedValues = [];
                    _this._onVideoDestroyedValues = [];
                    var externalAudioTrack = new fm.icelink.AudioTrack(external, _this);
                    var externalVideoTrack = new fm.icelink.VideoTrack(external, _this);
                    var externalAudioSink = new fm.icelink.DomAudioSink(null);
                    var externalVideoSink = new fm.icelink.DomVideoSink(null);
                    _this._audioTrack = externalAudioTrack._getInternal();
                    _this._videoTrack = externalVideoTrack._getInternal();
                    _this._audioSink = externalAudioSink._getInternal();
                    _this._videoSink = externalVideoSink._getInternal();
                    _this._audioTrack.addOnDestroyed(function () {
                        for (var _i = 0, _a = _this._onAudioDestroyedValues; _i < _a.length; _i++) {
                            var value = _a[_i];
                            value();
                        }
                    });
                    _this._videoTrack.addOnDestroyed(function () {
                        _this._videoSink.destroy();
                        for (var _i = 0, _a = _this._onVideoDestroyedValues; _i < _a.length; _i++) {
                            var value = _a[_i];
                            value();
                        }
                    });
                    return _this;
                }
                WebRtcMedia.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcMedia]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcMedia.prototype._getAudioMediaStream = function () {
                    return this._audioMediaStream;
                };
                WebRtcMedia.prototype._getVideoMediaStream = function () {
                    return this._videoMediaStream;
                };
                WebRtcMedia.prototype._setAudioMediaStream = function (audioMediaStream) {
                    if (audioMediaStream == this._audioMediaStream) {
                        return false;
                    }
                    this._audioMediaStream = audioMediaStream;
                    if (audioMediaStream) {
                        var hasAudio = (audioMediaStream.getAudioTracks().length > 0);
                        if (hasAudio) {
                            this._audioTrack._setMediaStreamTrack(audioMediaStream.getAudioTracks()[0]);
                            this._audioSink.setTrack(this._audioTrack);
                            this.initializeAudioContext();
                        }
                        else {
                            this._audioTrack._setMediaStreamTrack(null);
                            this.destroyAudioContext();
                        }
                    }
                    else {
                        this._audioTrack._setMediaStreamTrack(null);
                        this.destroyAudioContext();
                    }
                    return true;
                };
                WebRtcMedia.prototype._setVideoMediaStream = function (videoMediaStream) {
                    if (videoMediaStream == this._videoMediaStream) {
                        return false;
                    }
                    this._videoMediaStream = videoMediaStream;
                    if (videoMediaStream) {
                        var hasVideo = (videoMediaStream.getVideoTracks().length > 0);
                        if (hasVideo) {
                            this._videoTrack._setMediaStreamTrack(videoMediaStream.getVideoTracks()[0]);
                            this._videoSink.setTrack(this._videoTrack);
                        }
                        else {
                            this._videoTrack._setMediaStreamTrack(null);
                        }
                    }
                    else {
                        this._videoTrack._setMediaStreamTrack(null);
                    }
                    return true;
                };
                WebRtcMedia.prototype._setMediaStreams = function (audioMediaStream, videoMediaStream) {
                    this._setAudioMediaStream(audioMediaStream);
                    this._setVideoMediaStream(videoMediaStream);
                };
                WebRtcMedia.prototype._setMediaStream = function (mediaStream) {
                    this._setMediaStreams(mediaStream, mediaStream);
                };
                WebRtcMedia.prototype.getAudio = function () {
                    return this._audio;
                };
                WebRtcMedia.prototype.setAudio = function (audio) {
                    this._audio = audio;
                };
                WebRtcMedia.prototype.getVideo = function () {
                    return this._video;
                };
                WebRtcMedia.prototype.setVideo = function (video) {
                    this._video = video;
                };
                WebRtcMedia.prototype.addOnAudioDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onAudioDestroyedValues, value);
                };
                WebRtcMedia.prototype.addOnVideoDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onVideoDestroyedValues, value);
                };
                WebRtcMedia.prototype.removeOnAudioDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onAudioDestroyedValues, value);
                };
                WebRtcMedia.prototype.removeOnVideoDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onVideoDestroyedValues, value);
                };
                WebRtcMedia.prototype.addOnAudioLevel = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onAudioLevelValues, value);
                    this.initializeAudioContext();
                };
                WebRtcMedia.prototype.addOnVideoSize = function (value) {
                    var _this = this;
                    fm.icelink.ArrayExtensions.add(this._onVideoSizeValues, value);
                    var video = this._videoSink.getVideo();
                    if (video && !this._videoSizeEventsAttached) {
                        try {
                            fm.icelink.Util.observe(video, 'loadedmetadata', function (evt) {
                                for (var _i = 0, _a = _this._onVideoSizeValues; _i < _a.length; _i++) {
                                    var onVideoSizeValue = _a[_i];
                                    onVideoSizeValue(new fm.icelink.Size(video.videoWidth, video.videoHeight));
                                }
                            });
                            fm.icelink.Util.observe(video, 'timeupdate', function (evt) {
                                for (var _i = 0, _a = _this._onVideoSizeValues; _i < _a.length; _i++) {
                                    var onVideoSizeValue = _a[_i];
                                    onVideoSizeValue(new fm.icelink.Size(video.videoWidth, video.videoHeight));
                                }
                            });
                        }
                        catch (ex) {
                            fm.icelink.Log.error('Could not initialize AudioContext.', ex);
                        }
                    }
                };
                WebRtcMedia.prototype.destroy = function () {
                    this._audioTrack.destroy();
                    this._videoTrack.destroy();
                };
                WebRtcMedia.prototype.getAudioGain = function () {
                    return this.getAudioVolume();
                };
                WebRtcMedia.prototype.getAudioTracks = function () {
                    if (!this._audio || this._audioTrack._getMediaStreamTrackDisabled()) {
                        return [];
                    }
                    return [this._audioTrack];
                };
                WebRtcMedia.prototype.getAudioVolume = function () {
                    if (this._audioSink.getTrack()) {
                        return this._audioSink.getVolume();
                    }
                    if (this._videoSink.getTrack()) {
                        return this._videoSink.getVolume();
                    }
                    return 1.0;
                };
                WebRtcMedia.prototype.getVideoSize = function () {
                    return new fm.icelink.Size(this._videoSink.getVideoWidth(), this._videoSink.getVideoHeight());
                };
                WebRtcMedia.prototype.getVideoTracks = function () {
                    if (!this._video || this._videoTrack._getMediaStreamTrackDisabled()) {
                        return [];
                    }
                    return [this._videoTrack];
                };
                WebRtcMedia.prototype.getAudioSink = function () {
                    if (!this._audio) {
                        return null;
                    }
                    return this._audioSink;
                };
                WebRtcMedia.prototype.getVideoSink = function () {
                    if (!this._video) {
                        return null;
                    }
                    return this._videoSink;
                };
                WebRtcMedia.prototype.getView = function () {
                    if (!this._video) {
                        return null;
                    }
                    return this._videoSink.getView();
                };
                WebRtcMedia.prototype.getViewSink = function () {
                    if (!this._video) {
                        return null;
                    }
                    return this._videoSink;
                };
                WebRtcMedia.prototype.grabVideoFrame = function () {
                    var promise = new fm.icelink.Promise();
                    var video = this._videoSink.getVideo();
                    if (video && video.videoWidth && video.videoHeight) {
                        var width = video.videoWidth;
                        var height = video.videoHeight;
                        var canvas = document.createElement('canvas');
                        canvas.width = width;
                        canvas.height = height;
                        var context = canvas.getContext('2d');
                        context.drawImage(video, 0, 0, width, height);
                        var image = context.getImageData(0, 0, width, height);
                        var data = new Uint8Array(image.data.buffer);
                        promise.resolve(new fm.icelink.VideoBuffer(width, height, fm.icelink.DataBuffer.wrap(data), fm.icelink.VideoFormat.getRgba()));
                    }
                    else {
                        promise.reject(new fm.icelink.Exception('No video to grab.'));
                    }
                    return promise;
                };
                WebRtcMedia.prototype.removeOnAudioLevel = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onAudioLevelValues, value);
                    if (this._onAudioLevelValues.length == 0) {
                        this.destroyAudioContext();
                    }
                };
                WebRtcMedia.prototype.removeOnVideoSize = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onVideoSizeValues, value);
                };
                WebRtcMedia.prototype.setAudioGain = function (value) {
                    this.setAudioVolume(value);
                };
                WebRtcMedia.prototype.setAudioVolume = function (value) {
                    if (this._audioSink.getTrack()) {
                        this._audioSink.setVolume(value);
                    }
                    if (this._videoSink.getTrack()) {
                        this._videoSink.setVolume(value);
                    }
                };
                WebRtcMedia.prototype.initializeAudioContext = function () {
                };
                WebRtcMedia.prototype.destroyAudioContext = function () {
                };
                return WebRtcMedia;
            }(fm.icelink.WebRtcMediaBase));
            icelink.WebRtcMedia = WebRtcMedia;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcLocalMediaBase =  (function (_super) {
                __extends(WebRtcLocalMediaBase, _super);
                function WebRtcLocalMediaBase(external) {
                    var _this = this;
                    fm.icelink.WebRtcLocalMediaBase.fmicelinkWebRtcLocalMediaBaseInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var external_1 = __arguments[0];
                        _this = _super.call(this, external_1) || this;
                        _this.fmicelinkWebRtcLocalMediaBaseInit();
                        _this.__audioEncodingsSetLock = new Object();
                        _this.__videoEncodingsSetLock = new Object();
                        _this.__audioEncodingsSet = false;
                        _this.__videoEncodingsSet = false;
                        _this.__stateLock = new Object();
                        _this.setState(fm.icelink.LocalMediaState.New);
                        _this.initializeSimulcastConfigs();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                WebRtcLocalMediaBase.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcLocalMediaBase]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcLocalMediaBase.prototype.fmicelinkWebRtcLocalMediaBaseInit = function () {
                    this.__audioEncodingsSet = false;
                    this.__videoEncodingsSet = false;
                };
                WebRtcLocalMediaBase.getDefaultVideoBitsPerPixel = function () {
                    fm.icelink.WebRtcLocalMediaBase.fmicelinkWebRtcLocalMediaBaseInitialize();
                    if (arguments.length == 0) {
                        return fm.icelink.WebRtcLocalMediaBase.fm_icelink_WebRtcLocalMediaBase___defaultVideoBitsPerPixel;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.setDefaultVideoBitsPerPixel = function (value) {
                    fm.icelink.WebRtcLocalMediaBase.fmicelinkWebRtcLocalMediaBaseInitialize();
                    if (arguments.length == 1) {
                        if ((value < 0)) {
                            throw new fm.icelink.Exception("Default bits-per-pixel must be greater than or equal to zero.");
                        }
                        fm.icelink.WebRtcLocalMediaBase.fm_icelink_WebRtcLocalMediaBase___defaultVideoBitsPerPixel = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.abortStart = function (promise, exception) {
                    var _this = this;
                    if (arguments.length == 2) {
                        fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local media failed to start and is in a partial state. Stopping...", new Array(0)));
                        this.doStop().then(function (result) {
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local media has successfully stopped.", new Array(0)));
                            _this.setState(fm.icelink.LocalMediaState.Stopped);
                            promise.reject(exception);
                        }, function (ex) {
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local media did not stop successfully.", new Array(0)));
                            _this.setState(fm.icelink.LocalMediaState.Stopped);
                            promise.reject(exception);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getAudioEncoding = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getAudioEncodings());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getAudioEncodings = function () {
                    if (arguments.length == 0) {
                        return this.doGetAudioEncodings();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getAudioSimulcastDisabled = function () {
                    if (arguments.length == 0) {
                        return this.__audioSimulcast.getDisabled();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getAudioSimulcastEncodingCount = function () {
                    if (arguments.length == 0) {
                        return this.__audioSimulcast.getEncodingCount();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getAudioSimulcastPreferredBitrate = function () {
                    if (arguments.length == 0) {
                        return this.__audioSimulcast.getPreferredBitrate();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getState = function () {
                    if (arguments.length == 0) {
                        return this._state;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getVideoEncoding = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getVideoEncodings());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getVideoEncodings = function () {
                    if (arguments.length == 0) {
                        return this.doGetVideoEncodings();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getVideoSimulcastBitsPerPixel = function () {
                    if (arguments.length == 0) {
                        return this.__videoSimulcast.getBitsPerPixel();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getVideoSimulcastDegradationPreference = function () {
                    if (arguments.length == 0) {
                        return this.__videoSimulcast.getDegradationPreference();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getVideoSimulcastDisabled = function () {
                    if (arguments.length == 0) {
                        return this.__videoSimulcast.getDisabled();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getVideoSimulcastEncodingCount = function () {
                    if (arguments.length == 0) {
                        return this.__videoSimulcast.getEncodingCount();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.getVideoSimulcastPreferredBitrate = function () {
                    if (arguments.length == 0) {
                        return this.__videoSimulcast.getPreferredBitrate();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.initializeSimulcastConfigs = function () {
                    if (arguments.length == 0) {
                        var config = new fm.icelink.AudioSimulcastConfig(1, 32);
                        config.setDisabled(true);
                        this.__audioSimulcast = config;
                        var config2 = new fm.icelink.VideoSimulcastConfig(2, 1024, fm.icelink.WebRtcLocalMediaBase.getDefaultVideoBitsPerPixel());
                        config2.setDisabled(false);
                        this.__videoSimulcast = config2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.lockAudioEncodings = function () {
                    if (arguments.length == 0) {
                        if (((fm.icelink.Global.equals(this.getAudioEncodings(), null)) || (fm.icelink.Global.equals(this.getAudioEncodings().length, 0)))) {
                            this.setAudioEncodings(this.__audioSimulcast.getEncodingConfigs());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.lockVideoEncodings = function () {
                    if (arguments.length == 0) {
                        this.lockVideoEncodings(fm.icelink.VideoType.Unknown);
                    }
                    else if (arguments.length == 1) {
                        var sourceType = arguments[0];
                        this.lockVideoEncodings(sourceType, -1, -1, -1);
                    }
                    else if (arguments.length == 4) {
                        var sourceType = arguments[0];
                        var sourceWidth = fm.icelink.Global.toInt(arguments[1]);
                        var sourceHeight = fm.icelink.Global.toInt(arguments[2]);
                        var sourceFrameRate = arguments[3];
                        if (((fm.icelink.Global.equals(this.getVideoEncodings(), null)) || (fm.icelink.Global.equals(this.getVideoEncodings().length, 0)))) {
                            this.setVideoEncodings(this.__videoSimulcast.getEncodingConfigs(sourceType, sourceWidth, sourceHeight, sourceFrameRate));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setAudioEncodings = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            value = [new fm.icelink.AudioEncodingConfig()];
                        }
                        if ((fm.icelink.Global.equals(value.length, 0))) {
                            throw new fm.icelink.Exception("Audio encodings cannot be empty.");
                        }
                        var audioEncodings = this.getAudioEncodings();
                        if (((this.__audioEncodingsSet && (!fm.icelink.Global.equals(audioEncodings, null))) && (!fm.icelink.Global.equals(audioEncodings.length, value.length)))) {
                            throw new fm.icelink.Exception("The number of audio encodings cannot be changed once set.");
                        }
                        this.__audioEncodingsSet = true;
                        this.doSetAudioEncodings(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setAudioSimulcastDisabled = function (value) {
                    if (arguments.length == 1) {
                        this.__audioSimulcast.setDisabled(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setAudioSimulcastEncodingCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__audioSimulcast.setEncodingCount(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setAudioSimulcastPreferredBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__audioSimulcast.setPreferredBitrate(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setState = function (value) {
                    if (arguments.length == 1) {
                        this._state = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setVideoEncodings = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            throw new fm.icelink.Exception("Video encodings cannot be null.");
                        }
                        if ((fm.icelink.Global.equals(value.length, 0))) {
                            throw new fm.icelink.Exception("Video encodings cannot be empty.");
                        }
                        var videoEncodings = this.getVideoEncodings();
                        if (((this.__videoEncodingsSet && (!fm.icelink.Global.equals(videoEncodings, null))) && (!fm.icelink.Global.equals(videoEncodings.length, value.length)))) {
                            throw new fm.icelink.Exception("The number of video encodings cannot be changed once set.");
                        }
                        this.__videoEncodingsSet = true;
                        this.doSetVideoEncodings(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setVideoSimulcastBitsPerPixel = function (value) {
                    if (arguments.length == 1) {
                        this.__videoSimulcast.setBitsPerPixel(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setVideoSimulcastDegradationPreference = function (value) {
                    if (arguments.length == 1) {
                        this.__videoSimulcast.setDegradationPreference(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setVideoSimulcastDisabled = function (value) {
                    if (arguments.length == 1) {
                        this.__videoSimulcast.setDisabled(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setVideoSimulcastEncodingCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__videoSimulcast.setEncodingCount(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.setVideoSimulcastPreferredBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__videoSimulcast.setPreferredBitrate(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.start = function () {
                    if (arguments.length == 0) {
                        return this.startInternal(new fm.icelink.Promise());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.startInternal = function (promise) {
                    var _this = this;
                    if (arguments.length == 1) {
                        var _var0 = this.getState();
                        do {
                            if (_var0 == fm.icelink.LocalMediaState.Starting) {
                                promise.reject(new fm.icelink.Exception("Local media cannot be started while it is being started on a different thread."));
                                return promise;
                            }
                            else if (_var0 == fm.icelink.LocalMediaState.Started) {
                                promise.resolve(this);
                                return promise;
                            }
                            else if (_var0 == fm.icelink.LocalMediaState.Stopping) {
                                promise.reject(new fm.icelink.Exception("Local media cannot be started while it is being stopped."));
                                return promise;
                            }
                            else if (_var0 == fm.icelink.LocalMediaState.Destroying) {
                                promise.reject(new fm.icelink.Exception("Local media cannot be started while it is being destroyed."));
                                return promise;
                            }
                            else if (_var0 == fm.icelink.LocalMediaState.Destroyed) {
                                promise.reject(new fm.icelink.Exception("Local media cannot be started while it is destroyed."));
                                return promise;
                            }
                        } while (false);
                        this.setState(fm.icelink.LocalMediaState.Starting);
                        fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local media is being started.", new Array(0)));
                        this.doStart().then(function (result) {
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local media has successfully started.", new Array(0)));
                            _this.setState(fm.icelink.LocalMediaState.Started);
                            promise.resolve(result);
                        }, function (exception) {
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local media did not start successfully.", new Array(0)));
                            _this.setState(fm.icelink.LocalMediaState.Stopped);
                            promise.reject(exception);
                        });
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.stop = function () {
                    if (arguments.length == 0) {
                        return this.stopInternal(new fm.icelink.Promise());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.prototype.stopInternal = function (promise) {
                    var _this = this;
                    if (arguments.length == 1) {
                        var _var0 = this.getState();
                        do {
                            if (_var0 == fm.icelink.LocalMediaState.New) {
                                promise.resolve(this);
                                return promise;
                            }
                            else if (_var0 == fm.icelink.LocalMediaState.Starting) {
                                promise.reject(new fm.icelink.Exception("Local media cannot be stopped while it is being started."));
                                return promise;
                            }
                            else if (_var0 == fm.icelink.LocalMediaState.Stopping) {
                                promise.reject(new fm.icelink.Exception("Local media cannot be stopped while it is being stopped on a different thread."));
                                return promise;
                            }
                            else if (_var0 == fm.icelink.LocalMediaState.Stopped) {
                                promise.resolve(this);
                                return promise;
                            }
                            else if (_var0 == fm.icelink.LocalMediaState.Destroying) {
                                promise.reject(new fm.icelink.Exception("Local media cannot be stopped while it is being destroyed."));
                                return promise;
                            }
                            else if (_var0 == fm.icelink.LocalMediaState.Destroyed) {
                                promise.reject(new fm.icelink.Exception("Local media cannot be stopped while it is destroyed."));
                                return promise;
                            }
                        } while (false);
                        this.setState(fm.icelink.LocalMediaState.Stopping);
                        fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local media is being stopped.", new Array(0)));
                        this.doStop().then(function (result) {
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local media has successfully stopped.", new Array(0)));
                            _this.setState(fm.icelink.LocalMediaState.Stopped);
                            promise.resolve(result);
                        }, function (exception) {
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local media did not stop successfully.", new Array(0)));
                            _this.setState(fm.icelink.LocalMediaState.Started);
                            promise.reject(exception);
                        });
                        return promise;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                WebRtcLocalMediaBase.fmicelinkWebRtcLocalMediaBaseInitialize = function () {
                    if (!fm.icelink.WebRtcLocalMediaBase.__fmicelinkWebRtcLocalMediaBaseInitialized && !fm.icelink.WebRtcLocalMediaBase.__fmicelinkWebRtcLocalMediaBaseInitializing) {
                        fm.icelink.WebRtcLocalMediaBase.__fmicelinkWebRtcLocalMediaBaseInitializing = true;
                        WebRtcLocalMediaBase.fm_icelink_WebRtcLocalMediaBase___defaultVideoBitsPerPixel = 0;
                        fm.icelink.WebRtcLocalMediaBase.fm_icelink_WebRtcLocalMediaBase___defaultVideoBitsPerPixel = 0.05;
                        fm.icelink.WebRtcLocalMediaBase.__fmicelinkWebRtcLocalMediaBaseInitialized = true;
                        fm.icelink.WebRtcLocalMediaBase.__fmicelinkWebRtcLocalMediaBaseInitializing = false;
                    }
                };
                WebRtcLocalMediaBase.__fmicelinkWebRtcLocalMediaBaseInitialized = false;
                WebRtcLocalMediaBase.__fmicelinkWebRtcLocalMediaBaseInitializing = false;
                return WebRtcLocalMediaBase;
            }(fm.icelink.WebRtcMedia));
            icelink.WebRtcLocalMediaBase = WebRtcLocalMediaBase;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LocalMediaStateWrapper =  (function () {
                function LocalMediaStateWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_34 = __arguments[0];
                        this._value = value_34;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LocalMediaStateWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.LocalMediaStateWrapper]';
                };
                LocalMediaStateWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.LocalMediaState.New)
                            return 'New';
                        if (this._value == fm.icelink.LocalMediaState.Starting)
                            return 'Starting';
                        if (this._value == fm.icelink.LocalMediaState.Started)
                            return 'Started';
                        if (this._value == fm.icelink.LocalMediaState.Stopping)
                            return 'Stopping';
                        if (this._value == fm.icelink.LocalMediaState.Stopped)
                            return 'Stopped';
                        if (this._value == fm.icelink.LocalMediaState.Destroying)
                            return 'Destroying';
                        if (this._value == fm.icelink.LocalMediaState.Destroyed)
                            return 'Destroyed';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LocalMediaStateWrapper;
            }());
            icelink.LocalMediaStateWrapper = LocalMediaStateWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var VideoBuffer =  (function (_super) {
                __extends(VideoBuffer, _super);
                function VideoBuffer() {
                    var _this = this;
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkVideoBufferInit();
                        _this.__orientation = 0;
                    }
                    else if (__arguments.length == 4 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || fm.icelink.Util.isObjectType(arguments[2], '[fm.icelink.DataBuffer]'))) {
                        var width = __arguments[0];
                        var height = __arguments[1];
                        var dataBuffer = __arguments[2];
                        var format = __arguments[3];
                        _this = _super.call(this, dataBuffer, format) || this;
                        _this.fmicelinkVideoBufferInit();
                        _this.__orientation = 0;
                        _this.setWidth(width);
                        _this.setHeight(height);
                        _this.setStrides(_this.getDefaultStrides(width, format));
                    }
                    else if (__arguments.length == 4 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || (fm.icelink.Util.isArray(arguments[2]) && (arguments[2].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[2][0]) || fm.icelink.Util.isObjectType(arguments[2][0], '[fm.icelink.DataBuffer]')))))) {
                        var width = __arguments[0];
                        var height = __arguments[1];
                        var dataBuffers = __arguments[2];
                        var format = __arguments[3];
                        _this = _super.call(this, dataBuffers, format) || this;
                        _this.fmicelinkVideoBufferInit();
                        _this.__orientation = 0;
                        _this.setWidth(width);
                        _this.setHeight(height);
                        _this.setStrides(_this.getDefaultStrides(width, format));
                    }
                    else if (__arguments.length == 5 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || fm.icelink.Util.isNumber(arguments[2])) && (fm.icelink.Util.isNullOrUndefined(arguments[3]) || fm.icelink.Util.isObjectType(arguments[3], '[fm.icelink.DataBuffer]'))) {
                        var width = __arguments[0];
                        var height = __arguments[1];
                        var stride = __arguments[2];
                        var dataBuffer = __arguments[3];
                        var format = __arguments[4];
                        _this = _super.call(this, dataBuffer, format) || this;
                        _this.fmicelinkVideoBufferInit();
                        _this.__orientation = 0;
                        _this.setWidth(width);
                        _this.setHeight(height);
                        _this.setStride(stride);
                    }
                    else if (__arguments.length == 5 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || (fm.icelink.Util.isArray(arguments[2]) && (arguments[2].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[2][0]) || fm.icelink.Util.isNumber(arguments[2][0]))))) && (fm.icelink.Util.isNullOrUndefined(arguments[3]) || (fm.icelink.Util.isArray(arguments[3]) && (arguments[3].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[3][0]) || fm.icelink.Util.isObjectType(arguments[3][0], '[fm.icelink.DataBuffer]')))))) {
                        var width = __arguments[0];
                        var height = __arguments[1];
                        var strides = __arguments[2];
                        var dataBuffers = __arguments[3];
                        var format = __arguments[4];
                        _this = _super.call(this, dataBuffers, format) || this;
                        _this.fmicelinkVideoBufferInit();
                        _this.__orientation = 0;
                        _this.setWidth(width);
                        _this.setHeight(height);
                        _this.setStrides(strides);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                VideoBuffer.prototype.getTypeString = function () {
                    return '[fm.icelink.VideoBuffer]' + ',' + _super.prototype.getTypeString.call(this);
                };
                VideoBuffer.prototype.fmicelinkVideoBufferInit = function () {
                    this.__height = 0;
                    this.__isMuted = false;
                    this.__orientation = 0;
                    this.__width = 0;
                    this._horizontallyMirrored = false;
                    this._verticallyMirrored = false;
                };
                VideoBuffer.calculateByteCount = function (format, width, height) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[1]);
                        height = fm.icelink.Global.toInt(arguments[2]);
                        if (format.getIsYuvType()) {
                            return ((width * height) * 1.5);
                        }
                        if (format.getIsRgbType()) {
                            return ((width * height) * 3);
                        }
                        if (format.getIsRgbaType()) {
                            return ((width * height) * 4);
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.canPackWithoutCopy = function (dataBuffers) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 1) {
                        var data = dataBuffers[0].getData();
                        var index = dataBuffers[0].getIndex();
                        var length_38 = dataBuffers[0].getLength();
                        for (var i = 1; (i < dataBuffers.length); i++) {
                            var buffer2 = dataBuffers[i];
                            if ((!fm.icelink.Global.equals(buffer2.getData(), data))) {
                                return false;
                            }
                            if ((!fm.icelink.Global.equals(buffer2.getIndex(), (index + length_38)))) {
                                return false;
                            }
                            index = buffer2.getIndex();
                            length_38 = buffer2.getLength();
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.clamp = function (value) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.MathAssistant.max(0, fm.icelink.MathAssistant.min(255, fm.icelink.MathAssistant.round(value)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createBlack = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 0, 0, 0, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createBlue = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 0, 0, 255, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createCustom = function () {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 6) {
                        var width = fm.icelink.Global.toInt(arguments[0]);
                        var height = fm.icelink.Global.toInt(arguments[1]);
                        var red = fm.icelink.Global.toInt(arguments[2]);
                        var green = fm.icelink.Global.toInt(arguments[3]);
                        var blue = fm.icelink.Global.toInt(arguments[4]);
                        var formatName = arguments[5];
                        return fm.icelink.VideoBuffer.createCustom(width, height, red, green, blue, formatName, null);
                    }
                    else if (arguments.length == 7) {
                        var width = fm.icelink.Global.toInt(arguments[0]);
                        var height = fm.icelink.Global.toInt(arguments[1]);
                        var red = fm.icelink.Global.toInt(arguments[2]);
                        var green = fm.icelink.Global.toInt(arguments[3]);
                        var blue = fm.icelink.Global.toInt(arguments[4]);
                        var formatName = arguments[5];
                        var buffer = arguments[6];
                        var num3 = void 0;
                        var num4 = void 0;
                        var count = fm.icelink.VideoBuffer.getMinimumBufferLength(width, height, formatName);
                        if ((fm.icelink.Global.equals(count, -1))) {
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Could not create custom video buffer. Format '{0}' is not supported.", formatName));
                        }
                        if ((fm.icelink.Global.equals(buffer, null))) {
                            buffer = fm.icelink.DataBuffer.allocate(count);
                        }
                        if ((buffer.getLength() < count)) {
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Buffer too small. Minimum buffer length is {0} but buffer length is {1}.", fm.icelink.NumberExtensions.toString(count), fm.icelink.NumberExtensions.toString(buffer.getLength())));
                        }
                        var flag = fm.icelink.StringExtensions.isEqual(fm.icelink.VideoFormat.getBgrName(), formatName, fm.icelink.StringComparison.OrdinalIgnoreCase);
                        var flag2 = fm.icelink.StringExtensions.isEqual(fm.icelink.VideoFormat.getRgbName(), formatName, fm.icelink.StringComparison.OrdinalIgnoreCase);
                        var flag3 = (flag || flag2);
                        var flag4 = fm.icelink.StringExtensions.isEqual(fm.icelink.VideoFormat.getBgraName(), formatName, fm.icelink.StringComparison.OrdinalIgnoreCase);
                        var flag5 = fm.icelink.StringExtensions.isEqual(fm.icelink.VideoFormat.getRgbaName(), formatName, fm.icelink.StringComparison.OrdinalIgnoreCase);
                        var flag6 = fm.icelink.StringExtensions.isEqual(fm.icelink.VideoFormat.getAbgrName(), formatName, fm.icelink.StringComparison.OrdinalIgnoreCase);
                        var flag7 = fm.icelink.StringExtensions.isEqual(fm.icelink.VideoFormat.getArgbName(), formatName, fm.icelink.StringComparison.OrdinalIgnoreCase);
                        var flag8 = (((flag4 || flag5) || flag6) || flag7);
                        var flag9 = fm.icelink.StringExtensions.isEqual(fm.icelink.VideoFormat.getI420Name(), formatName, fm.icelink.StringComparison.OrdinalIgnoreCase);
                        var flag10 = fm.icelink.StringExtensions.isEqual(fm.icelink.VideoFormat.getYv12Name(), formatName, fm.icelink.StringComparison.OrdinalIgnoreCase);
                        var flag11 = fm.icelink.StringExtensions.isEqual(fm.icelink.VideoFormat.getNv12Name(), formatName, fm.icelink.StringComparison.OrdinalIgnoreCase);
                        var flag12 = fm.icelink.StringExtensions.isEqual(fm.icelink.VideoFormat.getNv21Name(), formatName, fm.icelink.StringComparison.OrdinalIgnoreCase);
                        var flag13 = (((flag9 || flag10) || flag11) || flag12);
                        var num2 = (width * height);
                        if (flag3) {
                            if (((fm.icelink.Global.equals(red, green)) && (fm.icelink.Global.equals(red, blue)))) {
                                buffer.set(fm.icelink.BitAssistant.castByte(red));
                            }
                            else {
                                num3 = 0;
                                if (flag) {
                                    for (num4 = 0; (num4 < num2); num4++) {
                                        buffer.write8(blue, num3++);
                                        buffer.write8(green, num3++);
                                        buffer.write8(red, num3++);
                                    }
                                }
                                else {
                                    num4 = 0;
                                    while ((num4 < num2)) {
                                        buffer.write8(red, num3++);
                                        buffer.write8(green, num3++);
                                        buffer.write8(blue, num3++);
                                        num4++;
                                    }
                                }
                            }
                        }
                        else {
                            if (flag8) {
                                num3 = 0;
                                var num5 = 255;
                                if (flag4) {
                                    for (num4 = 0; (num4 < num2); num4++) {
                                        buffer.write8(blue, num3++);
                                        buffer.write8(green, num3++);
                                        buffer.write8(red, num3++);
                                        buffer.write8(num5, num3++);
                                    }
                                }
                                else {
                                    if (flag5) {
                                        for (num4 = 0; (num4 < num2); num4++) {
                                            buffer.write8(red, num3++);
                                            buffer.write8(green, num3++);
                                            buffer.write8(blue, num3++);
                                            buffer.write8(num5, num3++);
                                        }
                                    }
                                    else {
                                        if (flag6) {
                                            for (num4 = 0; (num4 < num2); num4++) {
                                                buffer.write8(num5, num3++);
                                                buffer.write8(blue, num3++);
                                                buffer.write8(green, num3++);
                                                buffer.write8(red, num3++);
                                            }
                                        }
                                        else {
                                            if (flag7) {
                                                for (num4 = 0; (num4 < num2); num4++) {
                                                    buffer.write8(num5, num3++);
                                                    buffer.write8(red, num3++);
                                                    buffer.write8(green, num3++);
                                                    buffer.write8(blue, num3++);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                if (!flag13) {
                                    throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Could not create custom video buffer. Format '{0}' is not recognized.", formatName));
                                }
                                var num6 = (((0.299 * red) + (0.587 * green)) + (0.110004 * blue));
                                var num7 = ((((-0.168736 * red) - (0.331264 * green)) + (0.5 * blue)) + 128);
                                var num8 = ((((0.5 * red) - (0.418688 * green)) - (0.081312 * blue)) + 128);
                                var length_39 = num2;
                                buffer.set(fm.icelink.BitAssistant.castByte(num6), 0, length_39);
                                if ((flag9 || flag10)) {
                                    var num10 = fm.icelink.MathAssistant.floor(num2 / 4);
                                    var num11 = fm.icelink.MathAssistant.floor(num2 / 4);
                                    var offset = length_39;
                                    var num13 = (length_39 + num10);
                                    if (flag10) {
                                        num13 = length_39;
                                        offset = (length_39 + num11);
                                    }
                                    buffer.set(fm.icelink.BitAssistant.castByte(num7), offset, num10);
                                    buffer.set(fm.icelink.BitAssistant.castByte(num8), num13, num11);
                                }
                                else {
                                    var num14 = fm.icelink.MathAssistant.floor(num2 / 2);
                                    var num15 = length_39;
                                    var num16 = 0;
                                    var num17 = 1;
                                    if (flag12) {
                                        num16 = 1;
                                        num17 = 0;
                                    }
                                    for (num4 = num15; (num4 < (num15 + num14)); num4 = (num4 + 2)) {
                                        buffer.write8((num15 + num16), num7);
                                        buffer.write8((num15 + num17), num8);
                                    }
                                }
                            }
                        }
                        return new fm.icelink.VideoBuffer(width, height, buffer, new fm.icelink.VideoFormat(formatName));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createCyan = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 0, 255, 255, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createDarkBlue = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 0, 0, 128, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createDarkGreen = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 0, 128, 0, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createDarkRed = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 128, 0, 0, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createGray = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 128, 128, 128, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createGreen = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 0, 255, 0, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createMagenta = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 255, 0, 255, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createOlive = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 128, 128, 0, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createPurple = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 128, 0, 128, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createRed = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 255, 0, 0, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createTeal = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 0, 128, 128, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createWhite = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 255, 255, 255, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.createYellow = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        return fm.icelink.VideoBuffer.createCustom(width, height, 255, 255, 0, formatName);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.fromJson = function (videoBufferJson) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(videoBufferJson, function () {
                            return new fm.icelink.VideoBuffer();
                        }, function (videoBuffer, name, valueJson) {
                            var _var0 = name;
                            do {
                                if (_var0 == "width") {
                                    videoBuffer.setWidth(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    break;
                                }
                                else if (_var0 == "height") {
                                    videoBuffer.setHeight(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    break;
                                }
                                else if (_var0 == "strides") {
                                    videoBuffer.setStrides(fm.icelink.JsonSerializer.deserializeIntegerArray(valueJson));
                                    break;
                                }
                                else if (_var0 == "orientation") {
                                    videoBuffer.setOrientation(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    break;
                                }
                                else if (_var0 == "horizontalMirror") {
                                    videoBuffer.setHorizontallyMirrored(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    break;
                                }
                                else if (_var0 == "verticalMirror") {
                                    videoBuffer.setVerticallyMirrored(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    break;
                                }
                                else if (_var0 == "isMuted") {
                                    videoBuffer.setIsMuted(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    break;
                                }
                                else if (_var0 == "dataBuffers") {
                                    videoBuffer.setDataBuffers(fm.icelink.DataBuffer.fromJsonArray(valueJson));
                                    break;
                                }
                                else if (_var0 == "format") {
                                    videoBuffer.setFormat(fm.icelink.VideoFormat.fromJson(valueJson));
                                    break;
                                }
                            } while (false);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.fromJsonArray = function (videoBuffersJson) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(videoBuffersJson, fm.icelink.VideoBuffer.fromJson.bind(fm.icelink.VideoBuffer));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.getMinimumBufferLength = function (width, height, formatName) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 3) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        height = fm.icelink.Global.toInt(arguments[1]);
                        var num = (width * height);
                        if (((fm.icelink.Global.equals(formatName, fm.icelink.VideoFormat.getBgrName())) || (fm.icelink.Global.equals(formatName, fm.icelink.VideoFormat.getRgbName())))) {
                            return (num * 3);
                        }
                        if (((((fm.icelink.Global.equals(formatName, fm.icelink.VideoFormat.getBgraName())) || (fm.icelink.Global.equals(formatName, fm.icelink.VideoFormat.getRgbaName()))) || (fm.icelink.Global.equals(formatName, fm.icelink.VideoFormat.getAbgrName()))) || (fm.icelink.Global.equals(formatName, fm.icelink.VideoFormat.getArgbName())))) {
                            return (num * 4);
                        }
                        if (((((fm.icelink.Global.equals(formatName, fm.icelink.VideoFormat.getNv12Name())) || (fm.icelink.Global.equals(formatName, fm.icelink.VideoFormat.getNv21Name()))) || (fm.icelink.Global.equals(formatName, fm.icelink.VideoFormat.getI420Name()))) || (fm.icelink.Global.equals(formatName, fm.icelink.VideoFormat.getYv12Name())))) {
                            return (num * 1.5);
                        }
                        fm.icelink.Log.error(fm.icelink.StringExtensions.format("Could not get minimum buffer length. Format '{0}' is not supported.", formatName));
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.toJson = function (videoBuffer) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(videoBuffer, function (obj, jsonObject) {
                            jsonObject["width"] = fm.icelink.JsonSerializer.serializeInteger(videoBuffer.getWidth());
                            jsonObject["height"] = fm.icelink.JsonSerializer.serializeInteger(videoBuffer.getHeight());
                            jsonObject["strides"] = fm.icelink.JsonSerializer.serializeIntegerArray(videoBuffer.getStrides());
                            jsonObject["orientation"] = fm.icelink.JsonSerializer.serializeInteger(videoBuffer.getOrientation());
                            jsonObject["horizontalMirror"] = fm.icelink.JsonSerializer.serializeBoolean(videoBuffer.getHorizontallyMirrored());
                            jsonObject["verticalMirror"] = fm.icelink.JsonSerializer.serializeBoolean(videoBuffer.getVerticallyMirrored());
                            jsonObject["isMuted"] = fm.icelink.JsonSerializer.serializeBoolean(videoBuffer.getIsMuted());
                            jsonObject["dataBuffers"] = fm.icelink.DataBuffer.toJsonArray(videoBuffer.getDataBuffers());
                            jsonObject["format"] = fm.icelink.VideoFormat.toJson(videoBuffer.getFormat());
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.toJsonArray = function (videoBuffers) {
                    fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(videoBuffers, fm.icelink.VideoBuffer.toJson.bind(fm.icelink.VideoBuffer));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.clone = function () {
                    if (arguments.length == 0) {
                        var buffer = _super.prototype.clone.call(this);
                        buffer.setStrides(this.getStrides());
                        buffer.setWidth(this.getWidth());
                        buffer.setHeight(this.getHeight());
                        buffer.setOrientation(this.getOrientation());
                        buffer.setHorizontallyMirrored(this.getHorizontallyMirrored());
                        buffer.setVerticallyMirrored(this.getVerticallyMirrored());
                        buffer.__isMuted = this.__isMuted;
                        return buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.convert = function () {
                    if (arguments.length == 1) {
                        var format = arguments[0];
                        return this.convert(format, false);
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isObjectType(arguments[1], '[fm.icelink.DataBuffer]'))) {
                        var format = arguments[0];
                        var dataBuffer = arguments[1];
                        var numArray = void 0;
                        var numArray2 = void 0;
                        var numArray3 = void 0;
                        var numArray4 = void 0;
                        var numArray5 = void 0;
                        var numArray6 = void 0;
                        var numArray7 = void 0;
                        if (!(_super.prototype.getFormat.call(this).getIsRaw() && format.getIsRaw())) {
                            throw new fm.icelink.Exception("Cannot convert to or from encoded formats.");
                        }
                        if ((fm.icelink.Global.equals(dataBuffer, null))) {
                            dataBuffer = fm.icelink.DataBuffer.allocate(fm.icelink.VideoBuffer.calculateByteCount(format, this.getWidth(), this.getHeight()));
                        }
                        var buffer = new fm.icelink.VideoBuffer(this.getWidth(), this.getHeight(), dataBuffer, format);
                        if (_super.prototype.getFormat.call(this).getIsYuvType()) {
                            numArray = null;
                            numArray2 = null;
                            numArray3 = null;
                            var _var0 = new fm.icelink.Holder(numArray);
                            var _var1 = new fm.icelink.Holder(numArray2);
                            var _var2 = new fm.icelink.Holder(numArray3);
                            this.readYuv(_var0, _var1, _var2);
                            numArray = _var0.getValue();
                            numArray2 = _var1.getValue();
                            numArray3 = _var2.getValue();
                            if (format.getIsYuvType()) {
                                buffer.writeYuv(numArray, numArray2, numArray3);
                                return buffer;
                            }
                            numArray4 = null;
                            numArray5 = null;
                            numArray6 = null;
                            numArray7 = null;
                            var _var3 = new fm.icelink.Holder(numArray4);
                            var _var4 = new fm.icelink.Holder(numArray5);
                            var _var5 = new fm.icelink.Holder(numArray6);
                            var _var6 = new fm.icelink.Holder(numArray7);
                            this.convertYuvToRgba(numArray, numArray2, numArray3, _var3, _var4, _var5, _var6);
                            numArray4 = _var3.getValue();
                            numArray5 = _var4.getValue();
                            numArray6 = _var5.getValue();
                            numArray7 = _var6.getValue();
                            buffer.writeRgba(numArray4, numArray5, numArray6, numArray7);
                            return buffer;
                        }
                        numArray4 = null;
                        numArray5 = null;
                        numArray6 = null;
                        numArray7 = null;
                        var _var7 = new fm.icelink.Holder(numArray4);
                        var _var8 = new fm.icelink.Holder(numArray5);
                        var _var9 = new fm.icelink.Holder(numArray6);
                        var _var10 = new fm.icelink.Holder(numArray7);
                        this.readRgba(_var7, _var8, _var9, _var10);
                        numArray4 = _var7.getValue();
                        numArray5 = _var8.getValue();
                        numArray6 = _var9.getValue();
                        numArray7 = _var10.getValue();
                        if (format.getIsYuvType()) {
                            numArray = null;
                            numArray2 = null;
                            numArray3 = null;
                            var _var11 = new fm.icelink.Holder(numArray);
                            var _var12 = new fm.icelink.Holder(numArray2);
                            var _var13 = new fm.icelink.Holder(numArray3);
                            this.convertRgbaToYuv(numArray4, numArray5, numArray6, numArray7, _var11, _var12, _var13);
                            numArray = _var11.getValue();
                            numArray2 = _var12.getValue();
                            numArray3 = _var13.getValue();
                            buffer.writeYuv(numArray, numArray2, numArray3);
                            return buffer;
                        }
                        buffer.writeRgba(numArray4, numArray5, numArray6, numArray7);
                        return buffer;
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isBoolean(arguments[1]))) {
                        var format = arguments[0];
                        var usePool = arguments[1];
                        if (((fm.icelink.Global.equals(format, null)) || _super.prototype.getFormat.call(this).isEquivalent(format, false))) {
                            return this;
                        }
                        var dataBuffer = null;
                        if (usePool) {
                            dataBuffer = fm.icelink.VideoBuffer.fm_icelink_VideoBuffer___dataBufferPool.take(fm.icelink.VideoBuffer.calculateByteCount(format, this.getWidth(), this.getHeight()));
                        }
                        return this.convert(format, dataBuffer);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.convertRgbaToYuv = function (rValues, gValues, bValues, aValues, yValues, uValues, vValues) {
                    if (arguments.length == 7) {
                        var num = (this.getWidth() * this.getHeight());
                        yValues.setValue(new Array(num));
                        uValues.setValue(new Array(fm.icelink.MathAssistant.floor(num / 4)));
                        vValues.setValue(new Array(fm.icelink.MathAssistant.floor(num / 4)));
                        var index = 0;
                        var num3 = 0;
                        for (var i = 0; (i < this.getHeight()); i++) {
                            for (var j = 0; (j < this.getWidth()); j++) {
                                var num6 = rValues[index];
                                var num7 = gValues[index];
                                var num8 = bValues[index];
                                var num9 = 0.299;
                                var num10 = 0.587;
                                var num11 = 0.114;
                                yValues.getValue()[index] = fm.icelink.VideoBuffer.clamp((((num9 * num6) + (num10 * num7)) + (num11 * num8)));
                                if (((fm.icelink.Global.equals((j % 2), 0)) && (fm.icelink.Global.equals((i % 2), 0)))) {
                                    var num12 = rValues[index];
                                    var num13 = rValues[(index + 1)];
                                    var num14 = rValues[(index + this.getWidth())];
                                    var num15 = rValues[((index + this.getWidth()) + 1)];
                                    var num16 = gValues[index];
                                    var num17 = gValues[(index + 1)];
                                    var num18 = gValues[(index + this.getWidth())];
                                    var num19 = gValues[((index + this.getWidth()) + 1)];
                                    var num20 = bValues[index];
                                    var num21 = bValues[(index + 1)];
                                    var num22 = bValues[(index + this.getWidth())];
                                    var num23 = bValues[((index + this.getWidth()) + 1)];
                                    var num24 = ((((((-0.5 * num12) * num9) / (1 - num11)) - (((0.5 * num16) * num10) / (1 - num11))) + (0.5 * num20)) + 128);
                                    var num25 = ((((((-0.5 * num13) * num9) / (1 - num11)) - (((0.5 * num17) * num10) / (1 - num11))) + (0.5 * num21)) + 128);
                                    var num26 = ((((((-0.5 * num14) * num9) / (1 - num11)) - (((0.5 * num18) * num10) / (1 - num11))) + (0.5 * num22)) + 128);
                                    var num27 = ((((((-0.5 * num15) * num9) / (1 - num11)) - (((0.5 * num19) * num10) / (1 - num11))) + (0.5 * num23)) + 128);
                                    var num28 = ((((0.5 * num12) - (((0.5 * num16) * num10) / (1 - num9))) - (((0.5 * num20) * num11) / (1 - num9))) + 128);
                                    var num29 = ((((0.5 * num13) - (((0.5 * num17) * num10) / (1 - num9))) - (((0.5 * num21) * num11) / (1 - num9))) + 128);
                                    var num30 = ((((0.5 * num14) - (((0.5 * num18) * num10) / (1 - num9))) - (((0.5 * num22) * num11) / (1 - num9))) + 128);
                                    var num31 = ((((0.5 * num15) - (((0.5 * num19) * num10) / (1 - num9))) - (((0.5 * num23) * num11) / (1 - num9))) + 128);
                                    uValues.getValue()[num3] = fm.icelink.VideoBuffer.clamp(((((num24 + num25) + num26) + num27) / 4));
                                    vValues.getValue()[num3] = fm.icelink.VideoBuffer.clamp(((((num28 + num29) + num30) + num31) / 4));
                                    num3++;
                                }
                                index++;
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.convertYuvToRgba = function (yValues, uValues, vValues, rValues, gValues, bValues, aValues) {
                    if (arguments.length == 7) {
                        var num = (this.getWidth() * this.getHeight());
                        rValues.setValue(new Array(num));
                        gValues.setValue(new Array(num));
                        bValues.setValue(new Array(num));
                        aValues.setValue(new Array(num));
                        for (var i = 0; (i < num); i++) {
                            var num3 = yValues[i];
                            var num4 = uValues[fm.icelink.MathAssistant.floor(i / 4)];
                            var num5 = vValues[fm.icelink.MathAssistant.floor(i / 4)];
                            var num6 = 0.299;
                            var num7 = 0.587;
                            var num8 = 0.114;
                            rValues.getValue()[i] = fm.icelink.VideoBuffer.clamp((num3 + ((2 * (num5 - 128)) * (1 - num6))));
                            gValues.getValue()[i] = fm.icelink.VideoBuffer.clamp(((num3 - ((((2 * (num4 - 128)) * (1 - num8)) * num8) / num7)) - ((((2 * (num5 - 128)) * (1 - num6)) * num6) / num7)));
                            bValues.getValue()[i] = fm.icelink.VideoBuffer.clamp((num3 + ((2 * (num4 - 128)) * (1 - num8))));
                            aValues.getValue()[i] = 255;
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.copyTransformationAttributes = function (sourceBuffer) {
                    if (arguments.length == 1) {
                        this.setOrientation(sourceBuffer.getOrientation());
                        this.setHorizontallyMirrored(sourceBuffer.getHorizontallyMirrored());
                        this.setVerticallyMirrored(sourceBuffer.getVerticallyMirrored());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.createInstance = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.VideoBuffer();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getAValue = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if (_super.prototype.getFormat.call(this).getIsRgbaType()) {
                            return _super.prototype.getDataBuffer.call(this).read8(this.getAValueOffset(index));
                        }
                        return 255;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getAValueOffset = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if ((_super.prototype.getFormat.call(this).getIsRgba() || _super.prototype.getFormat.call(this).getIsBgra())) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4)) + 3);
                        }
                        if ((_super.prototype.getFormat.call(this).getIsArgb() || _super.prototype.getFormat.call(this).getIsAbgr())) {
                            return ((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4));
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getBValue = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if ((_super.prototype.getFormat.call(this).getIsRgbType() || _super.prototype.getFormat.call(this).getIsRgbaType())) {
                            return _super.prototype.getDataBuffer.call(this).read8(this.getBValueOffset(index));
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getBValueOffset = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if (_super.prototype.getFormat.call(this).getIsRgb()) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 3)) + 2);
                        }
                        if (_super.prototype.getFormat.call(this).getIsBgr()) {
                            return ((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 3));
                        }
                        if (_super.prototype.getFormat.call(this).getIsRgba()) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4)) + 2);
                        }
                        if (_super.prototype.getFormat.call(this).getIsBgra()) {
                            return ((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4));
                        }
                        if (_super.prototype.getFormat.call(this).getIsArgb()) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4)) + 3);
                        }
                        if (_super.prototype.getFormat.call(this).getIsAbgr()) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4)) + 1);
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getDefaultStrides = function (width, format) {
                    if (arguments.length == 2) {
                        width = fm.icelink.Global.toInt(arguments[0]);
                        if (format.getIsRgbType()) {
                            return [(width * 3)];
                        }
                        if (format.getIsRgbaType()) {
                            return [(width * 4)];
                        }
                        if ((format.getIsI420() || format.getIsYv12())) {
                            if (this.getIsPacked()) {
                                return [width];
                            }
                            return [width, fm.icelink.MathAssistant.floor(width / 2), fm.icelink.MathAssistant.floor(width / 2)];
                        }
                        if ((format.getIsNv12() || format.getIsNv21())) {
                            if (this.getIsPacked()) {
                                return [width];
                            }
                            return [width, width];
                        }
                        if ((((((!fm.icelink.Global.equals(format.getName(), fm.icelink.VideoFormat.getVp8Name())) && (!fm.icelink.Global.equals(format.getName(), fm.icelink.VideoFormat.getVp9Name()))) && ((!fm.icelink.Global.equals(format.getName(), fm.icelink.VideoFormat.getH264Name())) && (!fm.icelink.Global.equals(format.getName(), fm.icelink.VideoFormat.getH265Name())))) && (!fm.icelink.Global.equals(format.getName(), fm.icelink.MediaFormat.getRedName()))) && (!fm.icelink.Global.equals(format.getName(), fm.icelink.MediaFormat.getUlpFecName())))) {
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.concat("Unsupported video format '", format.getName(), "'."));
                        }
                        return new Array(1);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getGValue = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if ((_super.prototype.getFormat.call(this).getIsRgbType() || _super.prototype.getFormat.call(this).getIsRgbaType())) {
                            return _super.prototype.getDataBuffer.call(this).read8(this.getGValueOffset(index));
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getGValueOffset = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if ((_super.prototype.getFormat.call(this).getIsRgb() || _super.prototype.getFormat.call(this).getIsBgr())) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 3)) + 1);
                        }
                        if ((_super.prototype.getFormat.call(this).getIsRgba() || _super.prototype.getFormat.call(this).getIsBgra())) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4)) + 1);
                        }
                        if ((_super.prototype.getFormat.call(this).getIsArgb() || _super.prototype.getFormat.call(this).getIsAbgr())) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4)) + 2);
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getHeight = function () {
                    if (arguments.length == 0) {
                        return this.__height;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getHorizontallyMirrored = function () {
                    if (arguments.length == 0) {
                        return this._horizontallyMirrored;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getInversionRequired = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Global.xor(this.getVerticallyMirrored(), this.getHorizontallyMirrored());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsAbgr = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsAbgr());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsArgb = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsArgb());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsBgr = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsBgr());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsBgra = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsBgra());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsH264 = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsH264());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsH265 = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsH265());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsI420 = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsI420());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsMuted = function () {
                    if (arguments.length == 0) {
                        return this.__isMuted;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsNv12 = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsNv12());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsNv21 = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsNv21());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsPacked = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.Global.equals(_super.prototype.getDataBuffers.call(this).length, 1));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsPlanar = function () {
                    if (arguments.length == 0) {
                        return (_super.prototype.getDataBuffers.call(this).length > 1);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsRaw = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsRaw());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsRgb = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsRgb());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsRgba = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsRgba());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsRgbaType = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsRgbaType());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsRgbType = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsRgbType());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsVp8 = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsVp8());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsVp9 = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsVp9());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsYuvType = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsYuvType());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getIsYv12 = function () {
                    if (arguments.length == 0) {
                        var format = _super.prototype.getFormat.call(this);
                        return ((!fm.icelink.Global.equals(format, null)) && format.getIsYv12());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getOrientation = function () {
                    if (arguments.length == 0) {
                        return this.__orientation;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getRotationRequired = function () {
                    if (arguments.length == 0) {
                        var orientation_1 = this.getOrientation();
                        if ((this.getVerticallyMirrored() && this.getHorizontallyMirrored())) {
                            orientation_1 = (orientation_1 + 180);
                        }
                        else {
                            if (this.getVerticallyMirrored()) {
                                orientation_1 = (360 - orientation_1);
                            }
                            else {
                                if ((this.getHorizontallyMirrored() && ((fm.icelink.Global.equals(this.getOrientation(), 0)) || (fm.icelink.Global.equals(this.getOrientation(), 180))))) {
                                    orientation_1 = (orientation_1 + 180);
                                }
                            }
                        }
                        return (orientation_1 % 360);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getRValue = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if ((_super.prototype.getFormat.call(this).getIsRgbType() || _super.prototype.getFormat.call(this).getIsRgbaType())) {
                            return _super.prototype.getDataBuffer.call(this).read8(this.getRValueOffset(index));
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getRValueOffset = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if (_super.prototype.getFormat.call(this).getIsRgb()) {
                            return ((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 3));
                        }
                        if (_super.prototype.getFormat.call(this).getIsBgr()) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 3)) + 2);
                        }
                        if (_super.prototype.getFormat.call(this).getIsRgba()) {
                            return ((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4));
                        }
                        if (_super.prototype.getFormat.call(this).getIsBgra()) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4)) + 2);
                        }
                        if (_super.prototype.getFormat.call(this).getIsArgb()) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4)) + 1);
                        }
                        if (_super.prototype.getFormat.call(this).getIsAbgr()) {
                            return (((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + ((index % this.getWidth()) * 4)) + 3);
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getStride = function () {
                    if (arguments.length == 0) {
                        var strides = this.getStrides();
                        if ((fm.icelink.Global.equals(strides, null))) {
                            return 0;
                        }
                        return strides[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getStrides = function () {
                    if (arguments.length == 0) {
                        return this._strides;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getTransformRequired = function () {
                    if (arguments.length == 0) {
                        return ((!fm.icelink.Global.equals(this.getRotationRequired(), 0)) || this.getInversionRequired());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getUValue = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if (_super.prototype.getFormat.call(this).getIsYuvType()) {
                            if (this.getIsPacked()) {
                                return _super.prototype.getDataBuffers.call(this)[0].read8(this.getUValueOffset(index));
                            }
                            if (this.getIsYv12()) {
                                return _super.prototype.getDataBuffers.call(this)[2].read8(this.getUValueOffset(index));
                            }
                            return _super.prototype.getDataBuffers.call(this)[1].read8(this.getUValueOffset(index));
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getUValueOffset = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        var num2 = void 0;
                        var num3 = void 0;
                        var num4 = void 0;
                        if (this.getIsPacked()) {
                            if ((this.getIsI420() || this.getIsYv12())) {
                                var num = fm.icelink.MathAssistant.floor(this.getStride() / 2);
                                num2 = fm.icelink.MathAssistant.floor(this.getWidth() / 2);
                                num3 = ((fm.icelink.MathAssistant.floor(index / num2) * num) + (index % num2));
                                if (this.getIsI420()) {
                                    return ((this.getHeight() * this.getStride()) + num3);
                                }
                                return (fm.icelink.MathAssistant.floor(((this.getHeight() * this.getStride()) * 5) / 4) + num3);
                            }
                            num4 = (index * 2);
                            num3 = ((fm.icelink.MathAssistant.floor(num4 / this.getWidth()) * this.getStride()) + (num4 % this.getWidth()));
                            if (this.getIsNv12()) {
                                return ((this.getHeight() * this.getStride()) + num3);
                            }
                            return (((this.getHeight() * this.getStride()) + num3) + 1);
                        }
                        if ((this.getIsI420() || this.getIsYv12())) {
                            num2 = fm.icelink.MathAssistant.floor(this.getWidth() / 2);
                            if (this.getIsI420()) {
                                return ((fm.icelink.MathAssistant.floor(index / num2) * this.getStrides()[1]) + (index % num2));
                            }
                            return ((fm.icelink.MathAssistant.floor(index / num2) * this.getStrides()[2]) + (index % num2));
                        }
                        num4 = (index * 2);
                        num3 = ((fm.icelink.MathAssistant.floor(num4 / this.getWidth()) * this.getStrides()[1]) + (num4 % this.getWidth()));
                        if (this.getIsNv12()) {
                            return num3;
                        }
                        return (num3 + 1);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getVerticallyMirrored = function () {
                    if (arguments.length == 0) {
                        return this._verticallyMirrored;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getVValue = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if (_super.prototype.getFormat.call(this).getIsYuvType()) {
                            if (this.getIsPacked()) {
                                return _super.prototype.getDataBuffers.call(this)[0].read8(this.getVValueOffset(index));
                            }
                            if (this.getIsI420()) {
                                return _super.prototype.getDataBuffers.call(this)[2].read8(this.getVValueOffset(index));
                            }
                            return _super.prototype.getDataBuffers.call(this)[1].read8(this.getVValueOffset(index));
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getVValueOffset = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        var num2 = void 0;
                        var num3 = void 0;
                        var num4 = void 0;
                        if (this.getIsPacked()) {
                            if ((this.getIsI420() || this.getIsYv12())) {
                                var num = fm.icelink.MathAssistant.floor(this.getStride() / 2);
                                num2 = fm.icelink.MathAssistant.floor(this.getWidth() / 2);
                                num3 = ((fm.icelink.MathAssistant.floor(index / num2) * num) + (index % num2));
                                if (this.getIsI420()) {
                                    return (fm.icelink.MathAssistant.floor(((this.getHeight() * this.getStride()) * 5) / 4) + num3);
                                }
                                return ((this.getHeight() * this.getStride()) + num3);
                            }
                            num4 = (index * 2);
                            num3 = ((fm.icelink.MathAssistant.floor(num4 / this.getWidth()) * this.getStride()) + (num4 % this.getWidth()));
                            if (this.getIsNv12()) {
                                return (((this.getHeight() * this.getStride()) + num3) + 1);
                            }
                            return ((this.getHeight() * this.getStride()) + num3);
                        }
                        if ((this.getIsI420() || this.getIsYv12())) {
                            num2 = fm.icelink.MathAssistant.floor(this.getWidth() / 2);
                            if (this.getIsI420()) {
                                return ((fm.icelink.MathAssistant.floor(index / num2) * this.getStrides()[2]) + (index % num2));
                            }
                            return ((fm.icelink.MathAssistant.floor(index / num2) * this.getStrides()[1]) + (index % num2));
                        }
                        num4 = (index * 2);
                        num3 = ((fm.icelink.MathAssistant.floor(num4 / this.getWidth()) * this.getStrides()[1]) + (num4 % this.getWidth()));
                        if (this.getIsNv12()) {
                            return (num3 + 1);
                        }
                        return num3;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getWidth = function () {
                    if (arguments.length == 0) {
                        return this.__width;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getYValue = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        if (_super.prototype.getFormat.call(this).getIsYuvType()) {
                            return _super.prototype.getDataBuffer.call(this).read8(this.getYValueOffset(index));
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.getYValueOffset = function (index) {
                    if (arguments.length == 1) {
                        index = fm.icelink.Global.toInt(arguments[0]);
                        return ((fm.icelink.MathAssistant.floor(index / this.getWidth()) * this.getStride()) + (index % this.getWidth()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.mute = function () {
                    if (arguments.length == 0) {
                        if (!this.__isMuted) {
                            if (_super.prototype.getFormat.call(this).getIsRgbType()) {
                                _super.prototype.getDataBuffer.call(this).set(0);
                            }
                            else {
                                var dataBuffer = void 0;
                                var num3 = void 0;
                                if (_super.prototype.getFormat.call(this).getIsRgbaType()) {
                                    dataBuffer = _super.prototype.getDataBuffer.call(this);
                                    var num = 1;
                                    var num2 = 0;
                                    if ((_super.prototype.getFormat.call(this).getIsBgra() || _super.prototype.getFormat.call(this).getIsRgba())) {
                                        num = 0;
                                        num2 = 3;
                                    }
                                    for (num3 = 0; (num3 < dataBuffer.getLength()); num3 = (num3 + 4)) {
                                        dataBuffer.set(0, (num3 + num), 3);
                                        dataBuffer.set(fm.icelink.BitAssistant.castByte(255), (num3 + num2), 1);
                                    }
                                }
                                else {
                                    if (_super.prototype.getFormat.call(this).getIsYuvType()) {
                                        var dataBuffers = _super.prototype.getDataBuffers.call(this);
                                        if (this.getIsPacked()) {
                                            var length_40 = (this.getWidth() * this.getHeight());
                                            dataBuffer = dataBuffers[0];
                                            dataBuffer.set(0, 0, length_40);
                                            dataBuffer.set(fm.icelink.BitAssistant.castByte(128), length_40);
                                        }
                                        else {
                                            if (this.getIsPlanar()) {
                                                dataBuffers[0].set(0);
                                                for (num3 = 1; (num3 < dataBuffers.length); num3++) {
                                                    dataBuffers[num3].set(fm.icelink.BitAssistant.castByte(128));
                                                }
                                            }
                                        }
                                    }
                                    else {
                                        return false;
                                    }
                                }
                            }
                            this.__isMuted = true;
                        }
                        return true;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.readRgba = function (rValues, gValues, bValues, aValues) {
                    if (arguments.length == 4) {
                        var num = (this.getWidth() * this.getHeight());
                        rValues.setValue(new Array(num));
                        gValues.setValue(new Array(num));
                        bValues.setValue(new Array(num));
                        aValues.setValue(new Array(num));
                        for (var i = 0; (i < num); i++) {
                            rValues.getValue()[i] = this.getRValue(i);
                            gValues.getValue()[i] = this.getGValue(i);
                            bValues.getValue()[i] = this.getBValue(i);
                            aValues.getValue()[i] = this.getAValue(i);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.readYuv = function (yValues, uValues, vValues) {
                    if (arguments.length == 3) {
                        var num2 = void 0;
                        var num = (this.getWidth() * this.getHeight());
                        yValues.setValue(new Array(num));
                        uValues.setValue(new Array(fm.icelink.MathAssistant.floor(num / 4)));
                        vValues.setValue(new Array(fm.icelink.MathAssistant.floor(num / 4)));
                        for (num2 = 0; (num2 < num); num2++) {
                            yValues.getValue()[num2] = this.getYValue(num2);
                        }
                        for (num2 = 0; (num2 < fm.icelink.MathAssistant.floor(num / 4)); num2++) {
                            uValues.getValue()[num2] = this.getUValue(num2);
                            vValues.getValue()[num2] = this.getVValue(num2);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.resetTransformationAttributes = function () {
                    if (arguments.length == 0) {
                        this.setOrientation(0);
                        this.setHorizontallyMirrored(false);
                        this.setVerticallyMirrored(false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setAValue = function (aValue, index) {
                    if (arguments.length == 2) {
                        aValue = fm.icelink.Global.toInt(arguments[0]);
                        index = fm.icelink.Global.toInt(arguments[1]);
                        return (_super.prototype.getFormat.call(this).getIsRgbaType() && _super.prototype.getDataBuffer.call(this).write8(aValue, this.getAValueOffset(index)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setBValue = function (bValue, index) {
                    if (arguments.length == 2) {
                        bValue = fm.icelink.Global.toInt(arguments[0]);
                        index = fm.icelink.Global.toInt(arguments[1]);
                        return ((_super.prototype.getFormat.call(this).getIsRgbType() || _super.prototype.getFormat.call(this).getIsRgbaType()) && _super.prototype.getDataBuffer.call(this).write8(bValue, this.getBValueOffset(index)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setGValue = function (gValue, index) {
                    if (arguments.length == 2) {
                        gValue = fm.icelink.Global.toInt(arguments[0]);
                        index = fm.icelink.Global.toInt(arguments[1]);
                        return ((_super.prototype.getFormat.call(this).getIsRgbType() || _super.prototype.getFormat.call(this).getIsRgbaType()) && _super.prototype.getDataBuffer.call(this).write8(gValue, this.getGValueOffset(index)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setHeight = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        if (((!fm.icelink.Global.equals(value, -1)) && ((value % 2) > 0))) {
                            value--;
                        }
                        this.__height = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setHorizontallyMirrored = function (value) {
                    if (arguments.length == 1) {
                        this._horizontallyMirrored = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setIsMuted = function (value) {
                    if (arguments.length == 1) {
                        this.__isMuted = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setOrientation = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        if (((((!fm.icelink.Global.equals(value, 0)) && (!fm.icelink.Global.equals(value, 90))) && (!fm.icelink.Global.equals(value, 180))) && (!fm.icelink.Global.equals(value, 270)))) {
                            throw new fm.icelink.Exception("Video orientation can only be 0, 90, 180 or 270.");
                        }
                        this.__orientation = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setRValue = function (rValue, index) {
                    if (arguments.length == 2) {
                        rValue = fm.icelink.Global.toInt(arguments[0]);
                        index = fm.icelink.Global.toInt(arguments[1]);
                        return ((_super.prototype.getFormat.call(this).getIsRgbType() || _super.prototype.getFormat.call(this).getIsRgbaType()) && _super.prototype.getDataBuffer.call(this).write8(rValue, this.getRValueOffset(index)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setStride = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.setStrides([value]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setStrides = function (value) {
                    if (arguments.length == 1) {
                        this._strides = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setUValue = function (uValue, index) {
                    if (arguments.length == 2) {
                        uValue = fm.icelink.Global.toInt(arguments[0]);
                        index = fm.icelink.Global.toInt(arguments[1]);
                        if (_super.prototype.getFormat.call(this).getIsYuvType()) {
                            if (this.getIsPacked()) {
                                return _super.prototype.getDataBuffers.call(this)[0].write8(uValue, this.getUValueOffset(index));
                            }
                            if (this.getIsYv12()) {
                                return _super.prototype.getDataBuffers.call(this)[2].write8(uValue, this.getUValueOffset(index));
                            }
                            return _super.prototype.getDataBuffers.call(this)[1].write8(uValue, this.getUValueOffset(index));
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setVerticallyMirrored = function (value) {
                    if (arguments.length == 1) {
                        this._verticallyMirrored = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setVValue = function (vValue, index) {
                    if (arguments.length == 2) {
                        vValue = fm.icelink.Global.toInt(arguments[0]);
                        index = fm.icelink.Global.toInt(arguments[1]);
                        if (_super.prototype.getFormat.call(this).getIsYuvType()) {
                            if (this.getIsPacked()) {
                                return _super.prototype.getDataBuffers.call(this)[0].write8(vValue, this.getVValueOffset(index));
                            }
                            if (this.getIsI420()) {
                                return _super.prototype.getDataBuffers.call(this)[2].write8(vValue, this.getVValueOffset(index));
                            }
                            return _super.prototype.getDataBuffers.call(this)[1].write8(vValue, this.getVValueOffset(index));
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setWidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        if (((!fm.icelink.Global.equals(value, -1)) && ((value % 2) > 0))) {
                            value--;
                        }
                        this.__width = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.setYValue = function (yValue, index) {
                    if (arguments.length == 2) {
                        yValue = fm.icelink.Global.toInt(arguments[0]);
                        index = fm.icelink.Global.toInt(arguments[1]);
                        return (_super.prototype.getFormat.call(this).getIsYuvType() && _super.prototype.getDataBuffer.call(this).write8(yValue, this.getYValueOffset(index)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.VideoBuffer.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.toPacked = function () {
                    if (arguments.length == 0) {
                        return this.toPacked(false);
                    }
                    else if (arguments.length == 1) {
                        var usePool = arguments[0];
                        var num = void 0;
                        var buffer3 = void 0;
                        if (!(this.getIsYuvType() && (_super.prototype.getDataBuffers.call(this).length > 1))) {
                            return this;
                        }
                        var buffer = this.clone();
                        var dataBuffers = buffer.getDataBuffers();
                        var strides = buffer.getStrides();
                        if (fm.icelink.VideoBuffer.canPackWithoutCopy(dataBuffers)) {
                            num = 0;
                            for (var _i = 0, dataBuffers_1 = dataBuffers; _i < dataBuffers_1.length; _i++) {
                                var buffer2 = dataBuffers_1[_i];
                                num = (num + buffer2.getLength());
                            }
                            buffer3 = dataBuffers[0];
                            buffer3.setLength(num);
                            buffer.setDataBuffer(buffer3);
                        }
                        else {
                            num = (((strides[0] * buffer.getHeight()) * 3) / 2);
                            if (usePool) {
                                buffer3 = fm.icelink.VideoBuffer.fm_icelink_VideoBuffer___dataBufferPool.take(num);
                            }
                            else {
                                buffer3 = fm.icelink.DataBuffer.allocate(num);
                            }
                            var offset = 0;
                            for (var _a = 0, dataBuffers_2 = dataBuffers; _a < dataBuffers_2.length; _a++) {
                                var buffer2 = dataBuffers_2[_a];
                                var _var0 = new fm.icelink.Holder(offset);
                                buffer3.write(buffer2, offset, _var0);
                                offset = _var0.getValue();
                            }
                            buffer.setDataBuffer(buffer3);
                        }
                        buffer.setStride(strides[0]);
                        return buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.toPlanar = function () {
                    if (arguments.length == 0) {
                        var num2 = void 0;
                        var num5 = void 0;
                        var num8 = void 0;
                        if (!(this.getIsYuvType() && (_super.prototype.getDataBuffers.call(this).length <= 1))) {
                            return this;
                        }
                        var buffer = this.clone();
                        var dataBuffer = buffer.getDataBuffer();
                        var stride = buffer.getStride();
                        if ((buffer.getIsI420() || buffer.getIsYv12())) {
                            var num9 = void 0;
                            var num10 = void 0;
                            num2 = stride;
                            var num3 = fm.icelink.MathAssistant.floor(stride / 2);
                            var num4 = fm.icelink.MathAssistant.floor(stride / 2);
                            num5 = (stride * buffer.getHeight());
                            var num6 = fm.icelink.MathAssistant.floor(num5 / 4);
                            var num7 = fm.icelink.MathAssistant.floor(num5 / 4);
                            num8 = 0;
                            if (buffer.getIsI420()) {
                                num9 = num5;
                                num10 = (num5 + num6);
                                buffer.setDataBuffers([dataBuffer.subset(num8, num5), dataBuffer.subset(num9, num6), dataBuffer.subset(num10, num7)]);
                                buffer.setStrides([num2, num3, num4]);
                            }
                            else {
                                num10 = num5;
                                num9 = (num5 + num7);
                                buffer.setDataBuffers([dataBuffer.subset(num8, num5), dataBuffer.subset(num10, num7), dataBuffer.subset(num9, num6)]);
                                buffer.setStrides([num2, num4, num3]);
                            }
                            return buffer;
                        }
                        num2 = stride;
                        var num11 = stride;
                        num5 = (stride * buffer.getHeight());
                        var length_41 = fm.icelink.MathAssistant.floor(num5 / 2);
                        num8 = 0;
                        var offset = num5;
                        buffer.setDataBuffers([dataBuffer.subset(num8, num5), dataBuffer.subset(offset, length_41)]);
                        buffer.setStrides([num2, num11]);
                        return buffer;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.writeRgba = function (rValues, gValues, bValues, aValues) {
                    if (arguments.length == 4) {
                        var num = (this.getWidth() * this.getHeight());
                        for (var i = 0; (i < num); i++) {
                            this.setRValue(rValues[i], i);
                            this.setGValue(gValues[i], i);
                            this.setBValue(bValues[i], i);
                            this.setAValue(aValues[i], i);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.prototype.writeYuv = function (yValues, uValues, vValues) {
                    if (arguments.length == 3) {
                        var num = void 0;
                        for (num = 0; (num < yValues.length); num++) {
                            this.setYValue(yValues[num], num);
                        }
                        for (num = 0; (num < uValues.length); num++) {
                            this.setUValue(uValues[num], num);
                        }
                        for (num = 0; (num < vValues.length); num++) {
                            this.setVValue(vValues[num], num);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoBuffer.fmicelinkVideoBufferInitialize = function () {
                    if (!fm.icelink.VideoBuffer.__fmicelinkVideoBufferInitialized && !fm.icelink.VideoBuffer.__fmicelinkVideoBufferInitializing) {
                        fm.icelink.VideoBuffer.__fmicelinkVideoBufferInitializing = true;
                        fm.icelink.VideoBuffer.fm_icelink_VideoBuffer___dataBufferPool = fm.icelink.DataBufferPool.getTracer(new fm.icelink.Type('[fm.icelink.VideoBuffer]'));
                        fm.icelink.VideoBuffer.__fmicelinkVideoBufferInitialized = true;
                        fm.icelink.VideoBuffer.__fmicelinkVideoBufferInitializing = false;
                    }
                };
                VideoBuffer.__fmicelinkVideoBufferInitialized = false;
                VideoBuffer.__fmicelinkVideoBufferInitializing = false;
                return VideoBuffer;
            }(fm.icelink.MediaBuffer));
            icelink.VideoBuffer = VideoBuffer;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var RemoteCandidatePromise =  (function (_super) {
                __extends(RemoteCandidatePromise, _super);
                function RemoteCandidatePromise(remoteCandidate) {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var remoteCandidate_1 = __arguments[0];
                        _this = _super.call(this) || this;
                        _this.setRemoteCandidate(remoteCandidate_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                RemoteCandidatePromise.prototype.getTypeString = function () {
                    return '[fm.icelink.RemoteCandidatePromise]' + ',' + _super.prototype.getTypeString.call(this);
                };
                RemoteCandidatePromise.prototype.getRemoteCandidate = function () {
                    if (arguments.length == 0) {
                        return this._remoteCandidate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RemoteCandidatePromise.prototype.setRemoteCandidate = function (value) {
                    if (arguments.length == 1) {
                        this._remoteCandidate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return RemoteCandidatePromise;
            }(fm.icelink.Promise));
            icelink.RemoteCandidatePromise = RemoteCandidatePromise;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var RemoteMediaCollection =  (function (_super) {
                __extends(RemoteMediaCollection, _super);
                function RemoteMediaCollection() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.__lookup = {};
                        _this.__lookupLock = new Object();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                RemoteMediaCollection.prototype.getTypeString = function () {
                    return '[fm.icelink.RemoteMediaCollection]' + ',' + _super.prototype.getTypeString.call(this);
                };
                RemoteMediaCollection.prototype.addSuccess = function (value) {
                    if (arguments.length == 1) {
                        _super.prototype.addSuccess.call(this, value);
                        this.__lookup[value.getId()] = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RemoteMediaCollection.prototype.arrayFromList = function (list) {
                    if (arguments.length == 1) {
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RemoteMediaCollection.prototype.createCollection = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.RemoteMediaCollection();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RemoteMediaCollection.prototype.getById = function (idValue) {
                    if (arguments.length == 1) {
                        var media = null;
                        var _var0 = new fm.icelink.Holder(media);
                        var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__lookup, idValue, _var0);
                        media = _var0.getValue();
                        if (_var1) {
                            return media;
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RemoteMediaCollection.prototype.removeSuccess = function (value) {
                    if (arguments.length == 1) {
                        _super.prototype.removeSuccess.call(this, value);
                        fm.icelink.HashExtensions.remove(this.__lookup, value.getId());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return RemoteMediaCollection;
            }(fm.icelink.Collection));
            icelink.RemoteMediaCollection = RemoteMediaCollection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaCollection =  (function (_super) {
                __extends(MediaCollection, _super);
                function MediaCollection() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaCollection.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaCollection]' + ',' + _super.prototype.getTypeString.call(this);
                };
                return MediaCollection;
            }(fm.icelink.RemoteMediaCollection));
            icelink.MediaCollection = MediaCollection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var NackPolicyWrapper =  (function () {
                function NackPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_35 = __arguments[0];
                        this._value = value_35;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                NackPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.NackPolicyWrapper]';
                };
                NackPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.NackPolicy.Disabled)
                            return 'Disabled';
                        if (this._value == fm.icelink.NackPolicy.Negotiated)
                            return 'Negotiated';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return NackPolicyWrapper;
            }());
            icelink.NackPolicyWrapper = NackPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (opus) {
                var Format =  (function (_super) {
                    __extends(Format, _super);
                    function Format() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            __arguments = new Array(1);
                            __arguments[0] = fm.icelink.opus.Format.getDefaultConfig();
                            {
                                var config = __arguments[0];
                                __arguments = new Array(2);
                                __arguments[0] = config.getClockRate();
                                __arguments[1] = config.getChannelCount();
                                {
                                    var clockRate = __arguments[0];
                                    var channelCount = __arguments[1];
                                    _this = _super.call(this, fm.icelink.AudioFormat.getOpusName(), clockRate, channelCount) || this;
                                }
                            }
                        }
                        else if (__arguments.length == 2) {
                            var clockRate = __arguments[0];
                            var channelCount = __arguments[1];
                            _this = _super.call(this, fm.icelink.AudioFormat.getOpusName(), clockRate, channelCount) || this;
                        }
                        else if (__arguments.length == 1) {
                            var config = __arguments[0];
                            __arguments = new Array(2);
                            __arguments[0] = config.getClockRate();
                            __arguments[1] = config.getChannelCount();
                            {
                                var clockRate = __arguments[0];
                                var channelCount = __arguments[1];
                                _this = _super.call(this, fm.icelink.AudioFormat.getOpusName(), clockRate, channelCount) || this;
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Format.prototype.getTypeString = function () {
                        return '[fm.icelink.opus.Format]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    Format.getDefaultChannelCount = function () {
                        if (arguments.length == 0) {
                            return 2;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.getDefaultClockRate = function () {
                        if (arguments.length == 0) {
                            return 48000;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.getDefaultConfig = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.AudioConfig(fm.icelink.opus.Format.getDefaultClockRate(), fm.icelink.opus.Format.getDefaultChannelCount());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.createInstance = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.opus.Format();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMaxBitrate = function () {
                        if (arguments.length == 0) {
                            return 510;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMinBitrate = function () {
                        if (arguments.length == 0) {
                            return 6;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Format;
                }(fm.icelink.AudioFormat));
                opus.Format = Format;
            })(icelink.opus || (icelink.opus = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (pcma) {
                var Format =  (function (_super) {
                    __extends(Format, _super);
                    function Format() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            __arguments = new Array(1);
                            __arguments[0] = fm.icelink.g711.Format.getDefaultConfig();
                            {
                                var config = __arguments[0];
                                __arguments = new Array(2);
                                __arguments[0] = config.getClockRate();
                                __arguments[1] = config.getChannelCount();
                                {
                                    var clockRate = __arguments[0];
                                    var channelCount = __arguments[1];
                                    _this = _super.call(this, fm.icelink.AudioFormat.getPcmaName(), clockRate, channelCount) || this;
                                    _super.prototype.setStaticPayloadType.call(_this, 8);
                                }
                            }
                        }
                        else if (__arguments.length == 2) {
                            var clockRate = __arguments[0];
                            var channelCount = __arguments[1];
                            _this = _super.call(this, fm.icelink.AudioFormat.getPcmaName(), clockRate, channelCount) || this;
                            _super.prototype.setStaticPayloadType.call(_this, 8);
                        }
                        else if (__arguments.length == 1) {
                            var config = __arguments[0];
                            __arguments = new Array(2);
                            __arguments[0] = config.getClockRate();
                            __arguments[1] = config.getChannelCount();
                            {
                                var clockRate = __arguments[0];
                                var channelCount = __arguments[1];
                                _this = _super.call(this, fm.icelink.AudioFormat.getPcmaName(), clockRate, channelCount) || this;
                                _super.prototype.setStaticPayloadType.call(_this, 8);
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Format.prototype.getTypeString = function () {
                        return '[fm.icelink.pcma.Format]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    Format.prototype.createInstance = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.pcma.Format();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Format;
                }(fm.icelink.g711.Format));
                pcma.Format = Format;
            })(icelink.pcma || (icelink.pcma = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (pcmu) {
                var Format =  (function (_super) {
                    __extends(Format, _super);
                    function Format() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            __arguments = new Array(1);
                            __arguments[0] = fm.icelink.g711.Format.getDefaultConfig();
                            {
                                var config = __arguments[0];
                                __arguments = new Array(2);
                                __arguments[0] = config.getClockRate();
                                __arguments[1] = config.getChannelCount();
                                {
                                    var clockRate = __arguments[0];
                                    var channelCount = __arguments[1];
                                    _this = _super.call(this, fm.icelink.AudioFormat.getPcmuName(), clockRate, channelCount) || this;
                                    _super.prototype.setStaticPayloadType.call(_this, 0);
                                }
                            }
                        }
                        else if (__arguments.length == 2) {
                            var clockRate = __arguments[0];
                            var channelCount = __arguments[1];
                            _this = _super.call(this, fm.icelink.AudioFormat.getPcmuName(), clockRate, channelCount) || this;
                            _super.prototype.setStaticPayloadType.call(_this, 0);
                        }
                        else if (__arguments.length == 1) {
                            var config = __arguments[0];
                            __arguments = new Array(2);
                            __arguments[0] = config.getClockRate();
                            __arguments[1] = config.getChannelCount();
                            {
                                var clockRate = __arguments[0];
                                var channelCount = __arguments[1];
                                _this = _super.call(this, fm.icelink.AudioFormat.getPcmuName(), clockRate, channelCount) || this;
                                _super.prototype.setStaticPayloadType.call(_this, 0);
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Format.prototype.getTypeString = function () {
                        return '[fm.icelink.pcmu.Format]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    Format.prototype.createInstance = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.pcmu.Format();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Format;
                }(fm.icelink.g711.Format));
                pcmu.Format = Format;
            })(icelink.pcmu || (icelink.pcmu = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var RedFecPolicyWrapper =  (function () {
                function RedFecPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_36 = __arguments[0];
                        this._value = value_36;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                RedFecPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.RedFecPolicyWrapper]';
                };
                RedFecPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.RedFecPolicy.Disabled)
                            return 'Disabled';
                        if (this._value == fm.icelink.RedFecPolicy.Negotiated)
                            return 'Negotiated';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return RedFecPolicyWrapper;
            }());
            icelink.RedFecPolicyWrapper = RedFecPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var RembPolicyWrapper =  (function () {
                function RembPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_37 = __arguments[0];
                        this._value = value_37;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                RembPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.RembPolicyWrapper]';
                };
                RembPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.RembPolicy.Disabled)
                            return 'Disabled';
                        if (this._value == fm.icelink.RembPolicy.Negotiated)
                            return 'Negotiated';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return RembPolicyWrapper;
            }());
            icelink.RembPolicyWrapper = RembPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var RtpPacketHeader =  (function () {
                function RtpPacketHeader() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkRtpPacketHeaderInit();
                        this.setVersion(2);
                        this.setPayloadType(-1);
                        this.setSequenceNumber(-1);
                        this.setTimestamp(-1);
                        this.setSynchronizationSource(-1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                RtpPacketHeader.prototype.getTypeString = function () {
                    return '[fm.icelink.RtpPacketHeader]';
                };
                RtpPacketHeader.prototype.fmicelinkRtpPacketHeaderInit = function () {
                    this._contributingSourceCount = 0;
                    this._extension = false;
                    this._marker = false;
                    this._padding = false;
                    this._paddingLength = 0;
                    this._payloadType = 0;
                    this._sequenceNumber = 0;
                    this._synchronizationSource = 0;
                    this._timestamp = 0;
                    this._version = 0;
                };
                RtpPacketHeader.getFixedHeaderLength = function () {
                    if (arguments.length == 0) {
                        return 12;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.calculateHeaderLength = function () {
                    if (arguments.length == 0) {
                        var num = (fm.icelink.RtpPacketHeader.getFixedHeaderLength() + (this.getContributingSourceCount() * 4));
                        if (this.getExtension()) {
                            num = (num + ((this.getHeaderExtension().getLength() * 4) + 4));
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.clone = function () {
                    if (arguments.length == 0) {
                        var header = new fm.icelink.RtpPacketHeader();
                        header.setVersion(this.getVersion());
                        header.setMarker(this.getMarker());
                        header.setPadding(this.getPadding());
                        header.setExtension(this.getExtension());
                        header.setHeaderExtension(this.getHeaderExtension());
                        header.setContributingSourceCount(this.getContributingSourceCount());
                        header.setPayloadType(this.getPayloadType());
                        header.setSequenceNumber(this.getSequenceNumber());
                        header.setTimestamp(this.getTimestamp());
                        header.setSynchronizationSource(this.getSynchronizationSource());
                        header.setContributingSources(this.getContributingSources());
                        return header;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getContributingSourceCount = function () {
                    if (arguments.length == 0) {
                        return this._contributingSourceCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getContributingSources = function () {
                    if (arguments.length == 0) {
                        return this._contributingSources;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getExtension = function () {
                    if (arguments.length == 0) {
                        return this._extension;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getHeaderExtension = function () {
                    if (arguments.length == 0) {
                        return this.__headerExtension;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getMarker = function () {
                    if (arguments.length == 0) {
                        return this._marker;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getPadding = function () {
                    if (arguments.length == 0) {
                        return this._padding;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getPaddingLength = function () {
                    if (arguments.length == 0) {
                        return this._paddingLength;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getPayloadType = function () {
                    if (arguments.length == 0) {
                        return this._payloadType;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getSequenceNumber = function () {
                    if (arguments.length == 0) {
                        return this._sequenceNumber;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getSynchronizationSource = function () {
                    if (arguments.length == 0) {
                        return this._synchronizationSource;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getTimestamp = function () {
                    if (arguments.length == 0) {
                        return this._timestamp;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.getVersion = function () {
                    if (arguments.length == 0) {
                        return this._version;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setContributingSourceCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._contributingSourceCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setContributingSources = function (value) {
                    if (arguments.length == 1) {
                        this._contributingSources = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setExtension = function (value) {
                    if (arguments.length == 1) {
                        this._extension = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setHeaderExtension = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            this.setExtension(false);
                            this.__headerExtension = value;
                        }
                        else {
                            this.__headerExtension = value;
                            this.setExtension(true);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setMarker = function (value) {
                    if (arguments.length == 1) {
                        this._marker = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setPadding = function (value) {
                    if (arguments.length == 1) {
                        this._padding = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setPaddingLength = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._paddingLength = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setPayloadType = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._payloadType = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setSequenceNumber = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._sequenceNumber = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setSynchronizationSource = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._synchronizationSource = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setTimestamp = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._timestamp = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.setVersion = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._version = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                RtpPacketHeader.prototype.writeTo = function (buffer, offset) {
                    if (arguments.length == 2) {
                        offset = fm.icelink.Global.toInt(arguments[1]);
                        buffer.write2(this.getVersion(), offset, 0);
                        buffer.write1(this.getPadding(), offset, 2);
                        buffer.write1(this.getExtension(), offset, 3);
                        buffer.write4(this.getContributingSourceCount(), offset, 4);
                        buffer.write1(this.getMarker(), (offset + 1), 0);
                        buffer.write7(this.getPayloadType(), (offset + 1), 1);
                        buffer.write16(this.getSequenceNumber(), (offset + 2));
                        buffer.write32(this.getTimestamp(), (offset + 4));
                        buffer.write32(this.getSynchronizationSource(), (offset + 8));
                        if ((this.getContributingSourceCount() > 0)) {
                            if (((fm.icelink.Global.equals(this.getContributingSources(), null)) || (!fm.icelink.Global.equals(this.getContributingSourceCount(), this.getContributingSources().length)))) {
                                throw new fm.icelink.Exception("Contributing sources count has a non-zero value but the contributing sources array is null or contains an invalid count.");
                            }
                            for (var i = 0; (i < this.getContributingSourceCount()); i++) {
                                buffer.write32(this.getContributingSources()[i], ((offset + 12) + (i * 4)));
                            }
                        }
                        if (this.getExtension()) {
                            var num2 = ((offset + fm.icelink.RtpPacketHeader.getFixedHeaderLength()) + (this.getContributingSourceCount() * 4));
                            buffer.getData()[(buffer.getIndex() + num2)] = this.getHeaderExtension().getId()[0];
                            buffer.getData()[((buffer.getIndex() + num2) + 1)] = this.getHeaderExtension().getId()[1];
                            buffer.write16(this.getHeaderExtension().getLength(), (num2 + 2));
                            this.getHeaderExtension().fillBuffer(buffer, (num2 + 4));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return RtpPacketHeader;
            }());
            icelink.RtpPacketHeader = RtpPacketHeader;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (rtp) {
                var HeaderExtensionFormWrapper =  (function () {
                    function HeaderExtensionFormWrapper(value) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var value_38 = __arguments[0];
                            this._value = value_38;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    HeaderExtensionFormWrapper.prototype.getTypeString = function () {
                        return '[fm.icelink.rtp.HeaderExtensionFormWrapper]';
                    };
                    HeaderExtensionFormWrapper.prototype.toString = function () {
                        if (arguments.length == 0) {
                            if (this._value == fm.icelink.rtp.HeaderExtensionForm.OneByte)
                                return 'OneByte';
                            if (this._value == fm.icelink.rtp.HeaderExtensionForm.TwoByte)
                                return 'TwoByte';
                            return '';
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return HeaderExtensionFormWrapper;
                }());
                rtp.HeaderExtensionFormWrapper = HeaderExtensionFormWrapper;
            })(icelink.rtp || (icelink.rtp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (rtp) {
                var RawHeaderExtension =  (function () {
                    function RawHeaderExtension(idValue, payload) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 2) {
                            var idValue_2 = __arguments[0];
                            var payload_2 = __arguments[1];
                            this.fmicelinkrtpRawHeaderExtensionInit();
                            this.setId(idValue_2);
                            this.setPayload(payload_2);
                            if ((fm.icelink.Global.equals(idValue_2[0], 16))) {
                                this.setForm(fm.icelink.rtp.HeaderExtensionForm.TwoByte);
                                this.setAppBits(idValue_2[1]);
                            }
                            else {
                                this.setForm(fm.icelink.rtp.HeaderExtensionForm.OneByte);
                                this.setAppBits(0);
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    RawHeaderExtension.prototype.getTypeString = function () {
                        return '[fm.icelink.rtp.RawHeaderExtension]';
                    };
                    RawHeaderExtension.prototype.fmicelinkrtpRawHeaderExtensionInit = function () {
                        this._appBits = 0;
                    };
                    RawHeaderExtension.prototype.fillBuffer = function (buffer, offset) {
                        if (arguments.length == 2) {
                            offset = fm.icelink.Global.toInt(arguments[1]);
                            buffer.writeBytes(this.getPayload(), offset);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RawHeaderExtension.prototype.getAppBits = function () {
                        if (arguments.length == 0) {
                            return this._appBits;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RawHeaderExtension.prototype.getForm = function () {
                        if (arguments.length == 0) {
                            return this._form;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RawHeaderExtension.prototype.getId = function () {
                        if (arguments.length == 0) {
                            return this._id;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RawHeaderExtension.prototype.getLength = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.MathAssistant.floor(this.getPayload().length / 4);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RawHeaderExtension.prototype.getPayload = function () {
                        if (arguments.length == 0) {
                            return this._payload;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RawHeaderExtension.prototype.setAppBits = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._appBits = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RawHeaderExtension.prototype.setForm = function (value) {
                        if (arguments.length == 1) {
                            this._form = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RawHeaderExtension.prototype.setId = function (value) {
                        if (arguments.length == 1) {
                            this._id = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RawHeaderExtension.prototype.setPayload = function (value) {
                        if (arguments.length == 1) {
                            this._payload = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return RawHeaderExtension;
                }());
                rtp.RawHeaderExtension = RawHeaderExtension;
            })(icelink.rtp || (icelink.rtp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SdesPolicyWrapper =  (function () {
                function SdesPolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_39 = __arguments[0];
                        this._value = value_39;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SdesPolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.SdesPolicyWrapper]';
                };
                SdesPolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.SdesPolicy.Negotiated)
                            return 'Negotiated';
                        if (this._value == fm.icelink.SdesPolicy.Disabled)
                            return 'Disabled';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SdesPolicyWrapper;
            }());
            icelink.SdesPolicyWrapper = SdesPolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SignallingStateWrapper =  (function () {
                function SignallingStateWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_40 = __arguments[0];
                        this._value = value_40;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SignallingStateWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.SignallingStateWrapper]';
                };
                SignallingStateWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.SignallingState.New)
                            return 'New';
                        if (this._value == fm.icelink.SignallingState.HaveLocalOffer)
                            return 'HaveLocalOffer';
                        if (this._value == fm.icelink.SignallingState.HaveRemoteOffer)
                            return 'HaveRemoteOffer';
                        if (this._value == fm.icelink.SignallingState.Stable)
                            return 'Stable';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SignallingStateWrapper;
            }());
            icelink.SignallingStateWrapper = SignallingStateWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SinkOutput =  (function () {
                function SinkOutput() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else if (__arguments.length == 2) {
                        var idValue = __arguments[0];
                        var name_18 = __arguments[1];
                        this.setId(idValue);
                        this.setName(name_18);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SinkOutput.prototype.getTypeString = function () {
                    return '[fm.icelink.SinkOutput]';
                };
                SinkOutput.fromJson = function (sinkOutputJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(sinkOutputJson, function () {
                            return new fm.icelink.SinkOutput();
                        }, function (obj, key, valueJson) {
                            var str = key;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "id"))) {
                                    if ((fm.icelink.Global.equals(str, "name"))) {
                                        obj.setName(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                }
                                else {
                                    obj.setId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SinkOutput.fromJsonArray = function (sinkOutputsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(sinkOutputsJson, fm.icelink.SinkOutput.fromJson.bind(fm.icelink.SinkOutput));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SinkOutput.toJson = function (sinkOutput) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(sinkOutput, function (obj, jsonObject) {
                            if ((!fm.icelink.Global.equals(obj.getId(), null))) {
                                jsonObject["id"] = fm.icelink.JsonSerializer.serializeString(obj.getId());
                            }
                            if ((!fm.icelink.Global.equals(obj.getName(), null))) {
                                jsonObject["name"] = fm.icelink.JsonSerializer.serializeString(obj.getName());
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SinkOutput.toJsonArray = function (sinkOutputs) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(sinkOutputs, fm.icelink.SinkOutput.toJson.bind(fm.icelink.SinkOutput));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SinkOutput.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this._id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SinkOutput.prototype.getName = function () {
                    if (arguments.length == 0) {
                        return this._name;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SinkOutput.prototype.setId = function (value) {
                    if (arguments.length == 1) {
                        this._id = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SinkOutput.prototype.setName = function (value) {
                    if (arguments.length == 1) {
                        this._name = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SinkOutput.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.SinkOutput.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SinkOutput.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return this.getName();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SinkOutput;
            }());
            icelink.SinkOutput = SinkOutput;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SourceInput =  (function () {
                function SourceInput() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else if (__arguments.length == 2) {
                        var idValue = __arguments[0];
                        var name_19 = __arguments[1];
                        this.setId(idValue);
                        this.setName(name_19);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SourceInput.prototype.getTypeString = function () {
                    return '[fm.icelink.SourceInput]';
                };
                SourceInput.fromJson = function (sourceInputJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(sourceInputJson, function () {
                            return new fm.icelink.SourceInput();
                        }, function (obj, key, valueJson) {
                            var str = key;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "id"))) {
                                    if ((fm.icelink.Global.equals(str, "name"))) {
                                        obj.setName(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                }
                                else {
                                    obj.setId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SourceInput.fromJsonArray = function (sourceInputsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(sourceInputsJson, fm.icelink.SourceInput.fromJson.bind(fm.icelink.SourceInput));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SourceInput.toJson = function (sourceInput) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(sourceInput, function (obj, jsonObject) {
                            if ((!fm.icelink.Global.equals(obj.getId(), null))) {
                                jsonObject["id"] = fm.icelink.JsonSerializer.serializeString(obj.getId());
                            }
                            if ((!fm.icelink.Global.equals(obj.getName(), null))) {
                                jsonObject["name"] = fm.icelink.JsonSerializer.serializeString(obj.getName());
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SourceInput.toJsonArray = function (sourceInputs) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(sourceInputs, fm.icelink.SourceInput.toJson.bind(fm.icelink.SourceInput));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SourceInput.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this._id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SourceInput.prototype.getName = function () {
                    if (arguments.length == 0) {
                        return this._name;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SourceInput.prototype.setId = function (value) {
                    if (arguments.length == 1) {
                        this._id = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SourceInput.prototype.setName = function (value) {
                    if (arguments.length == 1) {
                        this._name = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SourceInput.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.SourceInput.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SourceInput.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return this.getName();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SourceInput;
            }());
            icelink.SourceInput = SourceInput;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StreamCollection =  (function (_super) {
                __extends(StreamCollection, _super);
                function StreamCollection() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                StreamCollection.prototype.getTypeString = function () {
                    return '[fm.icelink.StreamCollection]' + ',' + _super.prototype.getTypeString.call(this);
                };
                StreamCollection.prototype.arrayFromList = function (list) {
                    if (arguments.length == 1) {
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamCollection.prototype.createCollection = function () {
                    if (arguments.length == 0) {
                        return new fm.icelink.StreamCollection();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamCollection.prototype.getByType = function (type) {
                    if (arguments.length == 1) {
                        for (var _i = 0, _a = _super.prototype.getValues.call(this); _i < _a.length; _i++) {
                            var stream = _a[_i];
                            if ((fm.icelink.Global.equals(stream.getType(), type))) {
                                return stream;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamCollection.prototype.getManyByType = function (type) {
                    if (arguments.length == 1) {
                        var list = new Array();
                        for (var _i = 0, _a = _super.prototype.getValues.call(this); _i < _a.length; _i++) {
                            var stream = _a[_i];
                            if ((fm.icelink.Global.equals(stream.getType(), type))) {
                                fm.icelink.ArrayExtensions.add(list, stream);
                            }
                        }
                        return list;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StreamCollection;
            }(fm.icelink.Collection));
            icelink.StreamCollection = StreamCollection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var TransportTypeWrapper =  (function () {
                function TransportTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_41 = __arguments[0];
                        this._value = value_41;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                TransportTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.TransportTypeWrapper]';
                };
                TransportTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.TransportType.Gatherer)
                            return 'Gatherer';
                        if (this._value == fm.icelink.TransportType.IceTransport)
                            return 'IceTransport';
                        if (this._value == fm.icelink.TransportType.DtlsTransport)
                            return 'DtlsTransport';
                        if (this._value == fm.icelink.TransportType.SctpTransport)
                            return 'SctpTransport';
                        if (this._value == fm.icelink.TransportType.ReliableDataTransport)
                            return 'ReliableDataTransport';
                        if (this._value == fm.icelink.TransportType.SrtpTransport)
                            return 'SrtpTransport';
                        if (this._value == fm.icelink.TransportType.Unset)
                            return 'Unset';
                        if (this._value == fm.icelink.TransportType.MediaTransport)
                            return 'MediaTransport';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return TransportTypeWrapper;
            }());
            icelink.TransportTypeWrapper = TransportTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var TrickleIcePolicyWrapper =  (function () {
                function TrickleIcePolicyWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_42 = __arguments[0];
                        this._value = value_42;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                TrickleIcePolicyWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.TrickleIcePolicyWrapper]';
                };
                TrickleIcePolicyWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.TrickleIcePolicy.NotSupported)
                            return 'NotSupported';
                        if (this._value == fm.icelink.TrickleIcePolicy.FullTrickle)
                            return 'FullTrickle';
                        if (this._value == fm.icelink.TrickleIcePolicy.HalfTrickle)
                            return 'HalfTrickle';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return TrickleIcePolicyWrapper;
            }());
            icelink.TrickleIcePolicyWrapper = TrickleIcePolicyWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var VideoUtility =  (function () {
                function VideoUtility() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                VideoUtility.prototype.getTypeString = function () {
                    return '[fm.icelink.VideoUtility]';
                };
                VideoUtility.getBitrate = function () {
                    if (arguments.length == 3) {
                        var pixelCount = fm.icelink.Global.toInt(arguments[0]);
                        var frameRate = arguments[1];
                        var bitsPerPixel = arguments[2];
                        var num = 640;
                        var num2 = 480;
                        var num3 = (num * num2);
                        var num4 = (((num3 * frameRate) * bitsPerPixel) / 1000);
                        var x = (pixelCount / num3);
                        return fm.icelink.MathAssistant.ceil((fm.icelink.MathAssistant.pow(x, fm.icelink.VideoUtility.getBitratePowerScale()) * num4));
                    }
                    else if (arguments.length == 5) {
                        var preferredBitrate = fm.icelink.Global.toInt(arguments[0]);
                        var width = fm.icelink.Global.toInt(arguments[1]);
                        var height = fm.icelink.Global.toInt(arguments[2]);
                        var frameRate = arguments[3];
                        var bitsPerPixel = arguments[4];
                        if (((((width > 0) && (height > 0)) && (frameRate > 0)) && (bitsPerPixel > 0))) {
                            return fm.icelink.VideoUtility.getBitrate((width * height), frameRate, bitsPerPixel);
                        }
                        return preferredBitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoUtility.getBitratePowerScale = function () {
                    if (arguments.length == 0) {
                        return 0.75;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoUtility.getEncodingConfig = function (degradationPreference, multiplier, frameRate) {
                    if (arguments.length == 3) {
                        var encodingConfig = new fm.icelink.VideoEncodingConfig();
                        fm.icelink.VideoUtility.updateEncodingConfig(encodingConfig, degradationPreference, multiplier, frameRate);
                        return encodingConfig;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoUtility.getPixelCount = function (bitrate, frameRate, bitsPerPixel) {
                    if (arguments.length == 3) {
                        bitrate = fm.icelink.Global.toInt(arguments[0]);
                        var num = 640;
                        var num2 = 480;
                        var num3 = (num * num2);
                        var num4 = (((num3 * frameRate) * bitsPerPixel) / 1000);
                        return fm.icelink.MathAssistant.round((fm.icelink.MathAssistant.pow((bitrate / num4), (1 / fm.icelink.VideoUtility.getBitratePowerScale())) * num3));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoUtility.processDegradationPreference = function (degradationPreference, type) {
                    if (arguments.length == 2) {
                        if ((!fm.icelink.Global.equals(degradationPreference, fm.icelink.VideoDegradationPreference.Automatic))) {
                            return degradationPreference;
                        }
                        if ((fm.icelink.Global.equals(type, fm.icelink.VideoType.Camera))) {
                            return fm.icelink.VideoDegradationPreference.Resolution;
                        }
                        if ((fm.icelink.Global.equals(type, fm.icelink.VideoType.Screen))) {
                            return fm.icelink.VideoDegradationPreference.FrameRate;
                        }
                        return fm.icelink.VideoDegradationPreference.Balanced;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoUtility.updateEncodingConfig = function (encodingConfig, degradationPreference, multiplier, frameRate) {
                    if (arguments.length == 4) {
                        if ((fm.icelink.Global.equals(degradationPreference, fm.icelink.VideoDegradationPreference.Balanced))) {
                            multiplier = fm.icelink.MathAssistant.sqrt(multiplier);
                        }
                        if ((frameRate > 0)) {
                            if (((fm.icelink.Global.equals(degradationPreference, fm.icelink.VideoDegradationPreference.FrameRate)) || (fm.icelink.Global.equals(degradationPreference, fm.icelink.VideoDegradationPreference.Balanced)))) {
                                encodingConfig.setFrameRate((frameRate * multiplier));
                            }
                            else {
                                encodingConfig.setFrameRate(frameRate);
                            }
                        }
                        if (((fm.icelink.Global.equals(degradationPreference, fm.icelink.VideoDegradationPreference.Resolution)) || (fm.icelink.Global.equals(degradationPreference, fm.icelink.VideoDegradationPreference.Balanced)))) {
                            encodingConfig.setScale(fm.icelink.MathAssistant.sqrt(multiplier));
                        }
                        else {
                            encodingConfig.setScale(1);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return VideoUtility;
            }());
            icelink.VideoUtility = VideoUtility;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (vp8) {
                var Format =  (function (_super) {
                    __extends(Format, _super);
                    function Format() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this, fm.icelink.VideoFormat.getVp8Name()) || this;
                        }
                        else if (__arguments.length == 1) {
                            var clockRate = __arguments[0];
                            _this = _super.call(this, fm.icelink.VideoFormat.getVp8Name(), clockRate) || this;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Format.prototype.getTypeString = function () {
                        return '[fm.icelink.vp8.Format]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    Format.prototype.createInstance = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.vp8.Format();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMaxBitrate = function () {
                        if (arguments.length == 0) {
                            return 100000;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMinBitrate = function () {
                        if (arguments.length == 0) {
                            return 100;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Format;
                }(fm.icelink.VideoFormat));
                vp8.Format = Format;
            })(icelink.vp8 || (icelink.vp8 = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (vp9) {
                var Format =  (function (_super) {
                    __extends(Format, _super);
                    function Format() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this, fm.icelink.VideoFormat.getVp9Name()) || this;
                        }
                        else if (__arguments.length == 1) {
                            var clockRate = __arguments[0];
                            _this = _super.call(this, fm.icelink.VideoFormat.getVp9Name(), clockRate) || this;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Format.prototype.getTypeString = function () {
                        return '[fm.icelink.vp9.Format]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    Format.prototype.createInstance = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.vp9.Format();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMaxBitrate = function () {
                        if (arguments.length == 0) {
                            return 100000;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Format.prototype.getMinBitrate = function () {
                        if (arguments.length == 0) {
                            return 100;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Format;
                }(fm.icelink.VideoFormat));
                vp9.Format = Format;
            })(icelink.vp9 || (icelink.vp9 = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaConfig =  (function () {
                function MediaConfig(clockRate) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var clockRate_2 = __arguments[0];
                        this.fmicelinkMediaConfigInit();
                        this.setClockRate(clockRate_2);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                MediaConfig.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaConfig]';
                };
                MediaConfig.prototype.fmicelinkMediaConfigInit = function () {
                    this._clockRate = 0;
                };
                MediaConfig.prototype.getClockRate = function () {
                    if (arguments.length == 0) {
                        return this._clockRate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaConfig.prototype.isEquivalent = function (config) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(config, null))) {
                            return false;
                        }
                        return (fm.icelink.Global.equals(this.getClockRate(), config.getClockRate()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaConfig.prototype.setClockRate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._clockRate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaConfig;
            }());
            icelink.MediaConfig = MediaConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AudioConfig =  (function (_super) {
                __extends(AudioConfig, _super);
                function AudioConfig(clockRate, channelCount) {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var clockRate_3 = __arguments[0];
                        var channelCount_2 = __arguments[1];
                        _this = _super.call(this, clockRate_3) || this;
                        _this.fmicelinkAudioConfigInit();
                        _this.setChannelCount(channelCount_2);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                AudioConfig.prototype.getTypeString = function () {
                    return '[fm.icelink.AudioConfig]' + ',' + _super.prototype.getTypeString.call(this);
                };
                AudioConfig.prototype.fmicelinkAudioConfigInit = function () {
                    this._channelCount = 0;
                };
                AudioConfig.prototype.getChannelCount = function () {
                    if (arguments.length == 0) {
                        return this._channelCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioConfig.prototype.isEquivalent = function (config) {
                    if (arguments.length == 1) {
                        if (!_super.prototype.isEquivalent.call(this, config)) {
                            return false;
                        }
                        return (fm.icelink.Global.equals(this.getChannelCount(), config.getChannelCount()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioConfig.prototype.setChannelCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._channelCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioConfig.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.format("Clock Rate: {0}, Channel Count: {1}", fm.icelink.NumberExtensions.toString(_super.prototype.getClockRate.call(this)), fm.icelink.NumberExtensions.toString(this.getChannelCount()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return AudioConfig;
            }(fm.icelink.MediaConfig));
            icelink.AudioConfig = AudioConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var BaseStats =  (function () {
                function BaseStats() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                BaseStats.prototype.getTypeString = function () {
                    return '[fm.icelink.BaseStats]';
                };
                BaseStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "id"))) {
                                if ((fm.icelink.Global.equals(str, "timestamp"))) {
                                    this.setTimestamp(fm.icelink.UnixTimestamp.unixMillisToDateTime(fm.icelink.JsonSerializer.deserializeLong(valueJson)));
                                }
                            }
                            else {
                                this.setId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BaseStats.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this._id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BaseStats.prototype.getTimestamp = function () {
                    if (arguments.length == 0) {
                        return this._timestamp;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BaseStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.getId(), null))) {
                            jsonObject["id"] = fm.icelink.JsonSerializer.serializeString(this.getId());
                        }
                        jsonObject["timestamp"] = fm.icelink.JsonSerializer.serializeLong(fm.icelink.UnixTimestamp.dateTimeToUnixMillis(this.getTimestamp()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BaseStats.prototype.setId = function (value) {
                    if (arguments.length == 1) {
                        this._id = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BaseStats.prototype.setTimestamp = function (value) {
                    if (arguments.length == 1) {
                        this._timestamp = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return BaseStats;
            }());
            icelink.BaseStats = BaseStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var BitrateNotification =  (function () {
                function BitrateNotification() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkBitrateNotificationInit();
                        this.setSynchronizationSource(-1);
                        this.setMediaDescriptionId(null);
                        this.setRtpStreamId(null);
                        this.setBitrate(-1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                BitrateNotification.prototype.getTypeString = function () {
                    return '[fm.icelink.BitrateNotification]';
                };
                BitrateNotification.prototype.fmicelinkBitrateNotificationInit = function () {
                    this._bitrate = 0;
                    this._synchronizationSource = 0;
                };
                BitrateNotification.fromJson = function (bitrateNotificationJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(bitrateNotificationJson, function () {
                            return new fm.icelink.BitrateNotification();
                        }, function (bn, key, valueJson) {
                            bn.deserializeProperty(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.fromJsonArray = function (bitrateNotificationsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(bitrateNotificationsJson, fm.icelink.BitrateNotification.fromJson.bind(fm.icelink.BitrateNotification));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.toJson = function (bitrateNotification) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(bitrateNotification, function (bn, dict) {
                            bn.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.toJsonArray = function (bitrateNotifications) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(bitrateNotifications, fm.icelink.BitrateNotification.toJson.bind(fm.icelink.BitrateNotification));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.deserializeProperty = function (key, valueJson) {
                    if (arguments.length == 2) {
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "synchronizationSource"))) {
                                if ((fm.icelink.Global.equals(str, "mediaDescriptionId"))) {
                                    this.setMediaDescriptionId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "rtpStreamId"))) {
                                        this.setRtpStreamId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "bitrate"))) {
                                            this.setBitrate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                        }
                                    }
                                }
                            }
                            else {
                                this.setSynchronizationSource(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.getBitrate = function () {
                    if (arguments.length == 0) {
                        return this._bitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.getMediaDescriptionId = function () {
                    if (arguments.length == 0) {
                        return this._mediaDescriptionId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.getRtpStreamId = function () {
                    if (arguments.length == 0) {
                        return this._rtpStreamId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.getSynchronizationSource = function () {
                    if (arguments.length == 0) {
                        return this._synchronizationSource;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.getSynchronizationSource(), -1))) {
                            jsonObject["synchronizationSource"] = fm.icelink.JsonSerializer.serializeLong(this.getSynchronizationSource());
                        }
                        if ((!fm.icelink.Global.equals(this.getMediaDescriptionId(), null))) {
                            jsonObject["mediaDescriptionId"] = fm.icelink.JsonSerializer.serializeString(this.getMediaDescriptionId());
                        }
                        if ((!fm.icelink.Global.equals(this.getRtpStreamId(), null))) {
                            jsonObject["rtpStreamId"] = fm.icelink.JsonSerializer.serializeString(this.getRtpStreamId());
                        }
                        if ((!fm.icelink.Global.equals(this.getBitrate(), -1))) {
                            jsonObject["bitrate"] = fm.icelink.JsonSerializer.serializeInteger(this.getBitrate());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.setBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.setMediaDescriptionId = function (value) {
                    if (arguments.length == 1) {
                        this._mediaDescriptionId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.setRtpStreamId = function (value) {
                    if (arguments.length == 1) {
                        this._rtpStreamId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.setSynchronizationSource = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._synchronizationSource = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateNotification.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.BitrateNotification.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return BitrateNotification;
            }());
            icelink.BitrateNotification = BitrateNotification;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var BitrateRequest =  (function () {
                function BitrateRequest() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkBitrateRequestInit();
                        this.setSynchronizationSource(-1);
                        this.setMediaDescriptionId(null);
                        this.setRtpStreamId(null);
                        this.setBitrate(-1);
                        this.setSenderSynchronizationSource(-1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                BitrateRequest.prototype.getTypeString = function () {
                    return '[fm.icelink.BitrateRequest]';
                };
                BitrateRequest.prototype.fmicelinkBitrateRequestInit = function () {
                    this._bitrate = 0;
                    this._senderSynchronizationSource = 0;
                    this._synchronizationSource = 0;
                };
                BitrateRequest.fromJson = function (bitrateRequestJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(bitrateRequestJson, function () {
                            return new fm.icelink.BitrateRequest();
                        }, function (br, key, valueJson) {
                            br.deserializeProperty(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.fromJsonArray = function (bitrateRequestsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(bitrateRequestsJson, fm.icelink.BitrateRequest.fromJson.bind(fm.icelink.BitrateRequest));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.toJson = function (bitrateRequest) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(bitrateRequest, function (br, dict) {
                            br.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.toJsonArray = function (bitrateRequests) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(bitrateRequests, fm.icelink.BitrateRequest.toJson.bind(fm.icelink.BitrateRequest));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.deserializeProperty = function (key, valueJson) {
                    if (arguments.length == 2) {
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "synchronizationSource"))) {
                                if ((fm.icelink.Global.equals(str, "mediaDescriptionId"))) {
                                    this.setMediaDescriptionId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "rtpStreamId"))) {
                                        this.setRtpStreamId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "bitrate"))) {
                                            this.setBitrate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "senderSynchronizationSource"))) {
                                                this.setSenderSynchronizationSource(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                this.setSynchronizationSource(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.getBitrate = function () {
                    if (arguments.length == 0) {
                        return this._bitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.getMediaDescriptionId = function () {
                    if (arguments.length == 0) {
                        return this._mediaDescriptionId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.getRtpStreamId = function () {
                    if (arguments.length == 0) {
                        return this._rtpStreamId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.getSenderSynchronizationSource = function () {
                    if (arguments.length == 0) {
                        return this._senderSynchronizationSource;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.getSynchronizationSource = function () {
                    if (arguments.length == 0) {
                        return this._synchronizationSource;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.getSynchronizationSource(), -1))) {
                            jsonObject["synchronizationSource"] = fm.icelink.JsonSerializer.serializeLong(this.getSynchronizationSource());
                        }
                        if ((!fm.icelink.Global.equals(this.getMediaDescriptionId(), null))) {
                            jsonObject["mediaDescriptionId"] = fm.icelink.JsonSerializer.serializeString(this.getMediaDescriptionId());
                        }
                        if ((!fm.icelink.Global.equals(this.getRtpStreamId(), null))) {
                            jsonObject["rtpStreamId"] = fm.icelink.JsonSerializer.serializeString(this.getRtpStreamId());
                        }
                        if ((!fm.icelink.Global.equals(this.getBitrate(), -1))) {
                            jsonObject["bitrate"] = fm.icelink.JsonSerializer.serializeInteger(this.getBitrate());
                        }
                        if ((!fm.icelink.Global.equals(this.getSenderSynchronizationSource(), -1))) {
                            jsonObject["senderSynchronizationSource"] = fm.icelink.JsonSerializer.serializeLong(this.getSenderSynchronizationSource());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.setBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.setMediaDescriptionId = function (value) {
                    if (arguments.length == 1) {
                        this._mediaDescriptionId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.setRtpStreamId = function (value) {
                    if (arguments.length == 1) {
                        this._rtpStreamId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.setSenderSynchronizationSource = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._senderSynchronizationSource = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.setSynchronizationSource = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._synchronizationSource = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                BitrateRequest.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.BitrateRequest.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return BitrateRequest;
            }());
            icelink.BitrateRequest = BitrateRequest;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Info =  (function () {
                function Info() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Info.prototype.getTypeString = function () {
                    return '[fm.icelink.Info]';
                };
                Info.processArray = function (newValues, oldValues) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(newValues, oldValues))) {
                            return null;
                        }
                        if ((((!fm.icelink.Global.equals(newValues, null)) && (!fm.icelink.Global.equals(oldValues, null))) && (fm.icelink.Global.equals(oldValues.length, newValues.length)))) {
                            for (var i = 0; (i < newValues.length); i++) {
                                if (!newValues[i].isEquivalent(oldValues[i])) {
                                    return newValues;
                                }
                            }
                            return null;
                        }
                        return newValues;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processBoolean = function (newValue, oldValue) {
                    if (arguments.length == 2) {
                        return ((fm.icelink.Global.equals(newValue, oldValue)) ? null : newValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processBooleanArray = function (newValues, oldValues) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(newValues, oldValues))) {
                            return null;
                        }
                        if ((((!fm.icelink.Global.equals(newValues, null)) && (!fm.icelink.Global.equals(oldValues, null))) && (fm.icelink.Global.equals(oldValues.length, newValues.length)))) {
                            for (var i = 0; (i < newValues.length); i++) {
                                if ((!fm.icelink.Global.equals(newValues[i], oldValues[i]))) {
                                    return newValues;
                                }
                            }
                            return null;
                        }
                        return newValues;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processDouble = function (newValue, oldValue) {
                    if (arguments.length == 2) {
                        return ((fm.icelink.Global.equals(newValue, oldValue)) ? null : newValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processFloat = function (newValue, oldValue) {
                    if (arguments.length == 2) {
                        return ((fm.icelink.Global.equals(newValue, oldValue)) ? null : newValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processFloatArray = function (newValues, oldValues) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(newValues, oldValues))) {
                            return null;
                        }
                        if ((((!fm.icelink.Global.equals(newValues, null)) && (!fm.icelink.Global.equals(oldValues, null))) && (fm.icelink.Global.equals(oldValues.length, newValues.length)))) {
                            for (var i = 0; (i < newValues.length); i++) {
                                if ((!fm.icelink.Global.equals(newValues[i], oldValues[i]))) {
                                    return newValues;
                                }
                            }
                            return null;
                        }
                        return newValues;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processInteger = function (newValue, oldValue) {
                    if (arguments.length == 2) {
                        newValue = fm.icelink.Global.toInt(arguments[0]);
                        oldValue = fm.icelink.Global.toInt(arguments[1]);
                        return ((fm.icelink.Global.equals(newValue, oldValue)) ? null : newValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processIntegerArray = function (newValues, oldValues) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(newValues, oldValues))) {
                            return null;
                        }
                        if ((((!fm.icelink.Global.equals(newValues, null)) && (!fm.icelink.Global.equals(oldValues, null))) && (fm.icelink.Global.equals(oldValues.length, newValues.length)))) {
                            for (var i = 0; (i < newValues.length); i++) {
                                if ((!fm.icelink.Global.equals(newValues[i], oldValues[i]))) {
                                    return newValues;
                                }
                            }
                            return null;
                        }
                        return newValues;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processLong = function (newValue, oldValue) {
                    if (arguments.length == 2) {
                        newValue = fm.icelink.Global.toInt(arguments[0]);
                        oldValue = fm.icelink.Global.toInt(arguments[1]);
                        return ((fm.icelink.Global.equals(newValue, oldValue)) ? null : newValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processLongArray = function (newValues, oldValues) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(newValues, oldValues))) {
                            return null;
                        }
                        if ((((!fm.icelink.Global.equals(newValues, null)) && (!fm.icelink.Global.equals(oldValues, null))) && (fm.icelink.Global.equals(oldValues.length, newValues.length)))) {
                            for (var i = 0; (i < newValues.length); i++) {
                                if ((!fm.icelink.Global.equals(newValues[i], oldValues[i]))) {
                                    return newValues;
                                }
                            }
                            return null;
                        }
                        return newValues;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processObject = function (newValue, oldValue) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(newValue, oldValue))) {
                            return null;
                        }
                        if ((((!fm.icelink.Global.equals(newValue, null)) && (!fm.icelink.Global.equals(oldValue, null))) && newValue.isEquivalent(oldValue))) {
                            return null;
                        }
                        return newValue;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processShort = function (newValue, oldValue) {
                    if (arguments.length == 2) {
                        newValue = fm.icelink.Global.toInt(arguments[0]);
                        oldValue = fm.icelink.Global.toInt(arguments[1]);
                        return ((fm.icelink.Global.equals(newValue, oldValue)) ? null : newValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processShortArray = function (newValues, oldValues) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(newValues, oldValues))) {
                            return null;
                        }
                        if ((((!fm.icelink.Global.equals(newValues, null)) && (!fm.icelink.Global.equals(oldValues, null))) && (fm.icelink.Global.equals(oldValues.length, newValues.length)))) {
                            for (var i = 0; (i < newValues.length); i++) {
                                if ((!fm.icelink.Global.equals(newValues[i], oldValues[i]))) {
                                    return newValues;
                                }
                            }
                            return null;
                        }
                        return newValues;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.processString = function (newValue, oldValue) {
                    if (arguments.length == 2) {
                        return ((fm.icelink.Global.equals(newValue, oldValue)) ? null : newValue);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        var str = key;
                        if (((!fm.icelink.Global.equals(str, null)) && (fm.icelink.Global.equals(str, "id")))) {
                            this.setId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.prototype.getId = function () {
                    if (arguments.length == 0) {
                        return this._id;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.getId(), null))) {
                            jsonObject["id"] = fm.icelink.JsonSerializer.serializeString(this.getId());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Info.prototype.setId = function (value) {
                    if (arguments.length == 1) {
                        this._id = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Info;
            }());
            icelink.Info = Info;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CandidateInfo =  (function (_super) {
                __extends(CandidateInfo, _super);
                function CandidateInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkCandidateInfoInit();
                    }
                    else if (__arguments.length == 2) {
                        var stats = __arguments[0];
                        var lastStats = __arguments[1];
                        _this = _super.call(this) || this;
                        _this.fmicelinkCandidateInfoInit();
                        _super.prototype.setId.call(_this, stats.getId());
                        var flag = (fm.icelink.Global.equals(lastStats, null));
                        _this.setIPAddress((flag ? stats.getIPAddress() : fm.icelink.Info.processString(stats.getIPAddress(), lastStats.getIPAddress())));
                        _this.setPort((flag ? stats.getPort() : fm.icelink.Info.processInteger(stats.getPort(), lastStats.getPort())));
                        _this.setPriority((flag ? stats.getPriority() : fm.icelink.Info.processLong(stats.getPriority(), lastStats.getPriority())));
                        _this.setProtocol(((!flag && (fm.icelink.Global.equals(stats.getProtocol(), lastStats.getProtocol()))) ? null : fm.icelink.CandidateUtility.protocolTypeToString(stats.getProtocol())));
                        _this.setRelatedIPAddress((flag ? stats.getRelatedIPAddress() : fm.icelink.Info.processString(stats.getRelatedIPAddress(), lastStats.getRelatedIPAddress())));
                        _this.setRelatedPort((flag ? stats.getRelatedPort() : fm.icelink.Info.processInteger(stats.getRelatedPort(), lastStats.getRelatedPort())));
                        _this.setRelayProtocol(((!flag && (fm.icelink.Global.equals(stats.getRelayProtocol(), lastStats.getRelayProtocol()))) ? null : fm.icelink.CandidateUtility.protocolTypeToString(stats.getRelayProtocol())));
                        _this.setType(((!flag && (fm.icelink.Global.equals(stats.getType(), lastStats.getType()))) ? null : fm.icelink.CandidateUtility.typeToString(stats.getType())));
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                CandidateInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.CandidateInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                CandidateInfo.prototype.fmicelinkCandidateInfoInit = function () {
                    this._port = 0;
                    this._priority = 0;
                    this._relatedPort = 0;
                };
                CandidateInfo.fromJson = function (candidateReportJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(candidateReportJson, function () {
                            return new fm.icelink.CandidateInfo();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.fromJsonArray = function (candidateReportsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(candidateReportsJson, fm.icelink.CandidateInfo.fromJson.bind(fm.icelink.CandidateInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.toJson = function (candidateReport) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(candidateReport, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.toJsonArray = function (candidateReports) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(candidateReports, fm.icelink.CandidateInfo.toJson.bind(fm.icelink.CandidateInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var _var0 = key;
                        do {
                            if (_var0 == "ipAddress") {
                                this.setIPAddress(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "port") {
                                this.setPort(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "relatedIPAddress") {
                                this.setRelatedIPAddress(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "relatedPort") {
                                this.setRelatedPort(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "protocol") {
                                this.setProtocol(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "relayProtocol") {
                                this.setRelayProtocol(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "type") {
                                this.setType(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "priority") {
                                this.setPriority(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.getIPAddress = function () {
                    if (arguments.length == 0) {
                        return this._ipAddress;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.getPort = function () {
                    if (arguments.length == 0) {
                        return this._port;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.getPriority = function () {
                    if (arguments.length == 0) {
                        return this._priority;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.getProtocol = function () {
                    if (arguments.length == 0) {
                        return this._protocol;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.getRelatedIPAddress = function () {
                    if (arguments.length == 0) {
                        return this._relatedIPAddress;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.getRelatedPort = function () {
                    if (arguments.length == 0) {
                        return this._relatedPort;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.getRelayProtocol = function () {
                    if (arguments.length == 0) {
                        return this._relayProtocol;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.getType = function () {
                    if (arguments.length == 0) {
                        return this._type;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getIPAddress(), null))) {
                            jsonObject["ipAddress"] = fm.icelink.JsonSerializer.serializeString(this.getIPAddress());
                        }
                        if ((this.getPort() != null)) {
                            jsonObject["port"] = fm.icelink.JsonSerializer.serializeInteger(this.getPort());
                        }
                        if ((!fm.icelink.Global.equals(this.getRelatedIPAddress(), null))) {
                            jsonObject["relatedIPAddress"] = fm.icelink.JsonSerializer.serializeString(this.getRelatedIPAddress());
                        }
                        if ((this.getRelatedPort() != null)) {
                            jsonObject["relatedPort"] = fm.icelink.JsonSerializer.serializeInteger(this.getRelatedPort());
                        }
                        if ((!fm.icelink.Global.equals(this.getProtocol(), null))) {
                            jsonObject["protocol"] = fm.icelink.JsonSerializer.serializeString(this.getProtocol());
                        }
                        if ((!fm.icelink.Global.equals(this.getRelayProtocol(), null))) {
                            jsonObject["relayProtocol"] = fm.icelink.JsonSerializer.serializeString(this.getRelayProtocol());
                        }
                        if ((!fm.icelink.Global.equals(this.getType(), null))) {
                            jsonObject["type"] = fm.icelink.JsonSerializer.serializeString(this.getType());
                        }
                        if ((this.getPriority() != null)) {
                            jsonObject["priority"] = fm.icelink.JsonSerializer.serializeLong(this.getPriority());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.setIPAddress = function (value) {
                    if (arguments.length == 1) {
                        this._ipAddress = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.setPort = function (value) {
                    if (arguments.length == 1) {
                        this._port = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.setPriority = function (value) {
                    if (arguments.length == 1) {
                        this._priority = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.setProtocol = function (value) {
                    if (arguments.length == 1) {
                        this._protocol = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.setRelatedIPAddress = function (value) {
                    if (arguments.length == 1) {
                        this._relatedIPAddress = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.setRelatedPort = function (value) {
                    if (arguments.length == 1) {
                        this._relatedPort = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.setRelayProtocol = function (value) {
                    if (arguments.length == 1) {
                        this._relayProtocol = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.setType = function (value) {
                    if (arguments.length == 1) {
                        this._type = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.CandidateInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CandidateInfo;
            }(fm.icelink.Info));
            icelink.CandidateInfo = CandidateInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CandidatePairInfo =  (function (_super) {
                __extends(CandidatePairInfo, _super);
                function CandidatePairInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkCandidatePairInfoInit();
                    }
                    else if (__arguments.length == 2) {
                        var stats = __arguments[0];
                        var lastStats = __arguments[1];
                        _this = _super.call(this) || this;
                        _this.fmicelinkCandidatePairInfoInit();
                        _super.prototype.setId.call(_this, stats.getId());
                        var flag = (fm.icelink.Global.equals(lastStats, null));
                        _this.setLocalCandidateId(stats.getLocalCandidateId());
                        _this.setRemoteCandidateId(stats.getRemoteCandidateId());
                        _this.setState(((!flag && (fm.icelink.Global.equals(stats.getState(), lastStats.getState()))) ? null : fm.icelink.CandidateUtility.candidatePairStateToString(stats.getState())));
                        _this.setPriority((flag ? stats.getPriority() : fm.icelink.Info.processLong(stats.getPriority(), lastStats.getPriority())));
                        _this.setNominated((flag ? stats.getNominated() : fm.icelink.Info.processBoolean(stats.getNominated(), lastStats.getNominated())));
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                CandidatePairInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.CandidatePairInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                CandidatePairInfo.prototype.fmicelinkCandidatePairInfoInit = function () {
                    this._nominated = false;
                    this._priority = 0;
                };
                CandidatePairInfo.fromJson = function (instanceJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(instanceJson, function () {
                            return new fm.icelink.CandidatePairInfo();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.fromJsonArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(arrayJson, fm.icelink.CandidatePairInfo.fromJson.bind(fm.icelink.CandidatePairInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.toJson = function (instance) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(instance, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.toJsonArray = function (array) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(array, fm.icelink.CandidatePairInfo.toJson.bind(fm.icelink.CandidatePairInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "localCandidateId"))) {
                                if ((fm.icelink.Global.equals(str, "remoteCandidateId"))) {
                                    this.setRemoteCandidateId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "state"))) {
                                        this.setState(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "priority"))) {
                                            this.setPriority(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "nominated"))) {
                                                this.setNominated(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                this.setLocalCandidateId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.getLocalCandidateId = function () {
                    if (arguments.length == 0) {
                        return this._localCandidateId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.getNominated = function () {
                    if (arguments.length == 0) {
                        return this._nominated;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.getPriority = function () {
                    if (arguments.length == 0) {
                        return this._priority;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.getRemoteCandidateId = function () {
                    if (arguments.length == 0) {
                        return this._remoteCandidateId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.getState = function () {
                    if (arguments.length == 0) {
                        return this._state;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getLocalCandidateId(), null))) {
                            jsonObject["localCandidateId"] = fm.icelink.JsonSerializer.serializeString(this.getLocalCandidateId());
                        }
                        if ((!fm.icelink.Global.equals(this.getRemoteCandidateId(), null))) {
                            jsonObject["remoteCandidateId"] = fm.icelink.JsonSerializer.serializeString(this.getRemoteCandidateId());
                        }
                        if ((!fm.icelink.Global.equals(this.getState(), null))) {
                            jsonObject["state"] = fm.icelink.JsonSerializer.serializeString(this.getState());
                        }
                        if ((this.getPriority() != null)) {
                            jsonObject["priority"] = fm.icelink.JsonSerializer.serializeLong(this.getPriority());
                        }
                        if ((this.getNominated() != null)) {
                            jsonObject["nominated"] = fm.icelink.JsonSerializer.serializeBoolean(this.getNominated());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.setLocalCandidateId = function (value) {
                    if (arguments.length == 1) {
                        this._localCandidateId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.setNominated = function (value) {
                    if (arguments.length == 1) {
                        this._nominated = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.setPriority = function (value) {
                    if (arguments.length == 1) {
                        this._priority = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.setRemoteCandidateId = function (value) {
                    if (arguments.length == 1) {
                        this._remoteCandidateId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.setState = function (value) {
                    if (arguments.length == 1) {
                        this._state = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.CandidatePairInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CandidatePairInfo;
            }(fm.icelink.Info));
            icelink.CandidatePairInfo = CandidatePairInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CandidatePairStateWrapper =  (function () {
                function CandidatePairStateWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_43 = __arguments[0];
                        this._value = value_43;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CandidatePairStateWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.CandidatePairStateWrapper]';
                };
                CandidatePairStateWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.CandidatePairState.New)
                            return 'New';
                        if (this._value == fm.icelink.CandidatePairState.Waiting)
                            return 'Waiting';
                        if (this._value == fm.icelink.CandidatePairState.InProgress)
                            return 'InProgress';
                        if (this._value == fm.icelink.CandidatePairState.Succeeded)
                            return 'Succeeded';
                        if (this._value == fm.icelink.CandidatePairState.Failed)
                            return 'Failed';
                        if (this._value == fm.icelink.CandidatePairState.Closed)
                            return 'Closed';
                        if (this._value == fm.icelink.CandidatePairState.ConnectivityLost)
                            return 'ConnectivityLost';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CandidatePairStateWrapper;
            }());
            icelink.CandidatePairStateWrapper = CandidatePairStateWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CandidatePairStats =  (function (_super) {
                __extends(CandidatePairStats, _super);
                function CandidatePairStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkCandidatePairStatsInit();
                        _this.setState(fm.icelink.CandidatePairState.New);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                CandidatePairStats.prototype.getTypeString = function () {
                    return '[fm.icelink.CandidatePairStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                CandidatePairStats.prototype.fmicelinkCandidatePairStatsInit = function () {
                    this._bytesReceived = 0;
                    this._bytesSent = 0;
                    this._consentRequestsReceived = 0;
                    this._consentRequestsSent = 0;
                    this._consentResponsesReceived = 0;
                    this._consentResponsesSent = 0;
                    this._currentRoundTripTime = 0;
                    this._nominated = false;
                    this._priority = 0;
                    this._requestsReceived = 0;
                    this._requestsSent = 0;
                    this._responsesReceived = 0;
                    this._responsesSent = 0;
                    this._totalRoundTripTime = 0;
                };
                CandidatePairStats.fromJson = function (candidatePairJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(candidatePairJson, function () {
                            return new fm.icelink.CandidatePairStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.fromJsonArray = function (candidatePairsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(candidatePairsJson, fm.icelink.CandidatePairStats.fromJson.bind(fm.icelink.CandidatePairStats));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.toJson = function (candidatePair) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(candidatePair, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.toJsonArray = function (candidatePairs) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(candidatePairs, fm.icelink.CandidatePairStats.toJson.bind(fm.icelink.CandidatePairStats));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var _var0 = key;
                        do {
                            if (_var0 == "transportId") {
                                this.setTransportId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "localCandidateId") {
                                this.setLocalCandidateId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "remoteCandidateId") {
                                this.setRemoteCandidateId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "state") {
                                this.setState(fm.icelink.CandidateUtility.candidatePairStateFromString(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                                break;
                            }
                            else if (_var0 == "priority") {
                                this.setPriority(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "nominated") {
                                this.setNominated(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                break;
                            }
                            else if (_var0 == "bytesSent") {
                                this.setBytesSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "bytesReceived") {
                                this.setBytesReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "requestsSent") {
                                this.setRequestsSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "requestsReceived") {
                                this.setRequestsReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "responsesSent") {
                                this.setResponsesSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "responsesReceived") {
                                this.setResponsesReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "consentRequestsSent") {
                                this.setConsentRequestsSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "consentRequestsReceived") {
                                this.setConsentRequestsReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "consentResponsesSent") {
                                this.setConsentResponsesSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "consentResponsesReceived") {
                                this.setConsentResponsesReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "totalRoundTripTime") {
                                this.setTotalRoundTripTime(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "currentRoundTripTime") {
                                this.setCurrentRoundTripTime(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getBytesReceived = function () {
                    if (arguments.length == 0) {
                        return this._bytesReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getBytesSent = function () {
                    if (arguments.length == 0) {
                        return this._bytesSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getConsentRequestsReceived = function () {
                    if (arguments.length == 0) {
                        return this._consentRequestsReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getConsentRequestsSent = function () {
                    if (arguments.length == 0) {
                        return this._consentRequestsSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getConsentResponsesReceived = function () {
                    if (arguments.length == 0) {
                        return this._consentResponsesReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getConsentResponsesSent = function () {
                    if (arguments.length == 0) {
                        return this._consentResponsesSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getCurrentRoundTripTime = function () {
                    if (arguments.length == 0) {
                        return this._currentRoundTripTime;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getLocalCandidateId = function () {
                    if (arguments.length == 0) {
                        return this._localCandidateId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getNominated = function () {
                    if (arguments.length == 0) {
                        return this._nominated;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getPriority = function () {
                    if (arguments.length == 0) {
                        return this._priority;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getRemoteCandidateId = function () {
                    if (arguments.length == 0) {
                        return this._remoteCandidateId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getRequestsReceived = function () {
                    if (arguments.length == 0) {
                        return this._requestsReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getRequestsSent = function () {
                    if (arguments.length == 0) {
                        return this._requestsSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getResponsesReceived = function () {
                    if (arguments.length == 0) {
                        return this._responsesReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getResponsesSent = function () {
                    if (arguments.length == 0) {
                        return this._responsesSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getState = function () {
                    if (arguments.length == 0) {
                        return this._state;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getTotalRoundTripTime = function () {
                    if (arguments.length == 0) {
                        return this._totalRoundTripTime;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.getTransportId = function () {
                    if (arguments.length == 0) {
                        return this._transportId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.isEquivalent = function (instance) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(instance, null))) {
                            return false;
                        }
                        return (((((((fm.icelink.Global.equals(instance.getTransportId(), this.getTransportId())) && (fm.icelink.Global.equals(instance.getLocalCandidateId(), this.getLocalCandidateId()))) && ((fm.icelink.Global.equals(instance.getRemoteCandidateId(), this.getRemoteCandidateId())) && (fm.icelink.Global.equals(instance.getState(), this.getState())))) && (((fm.icelink.Global.equals(instance.getPriority(), this.getPriority())) && (fm.icelink.Global.equals(instance.getNominated(), this.getNominated()))) && ((fm.icelink.Global.equals(instance.getBytesSent(), this.getBytesSent())) && (fm.icelink.Global.equals(instance.getBytesReceived(), this.getBytesReceived()))))) && ((((fm.icelink.Global.equals(instance.getRequestsSent(), this.getRequestsSent())) && (fm.icelink.Global.equals(instance.getRequestsReceived(), this.getRequestsReceived()))) && ((fm.icelink.Global.equals(instance.getResponsesSent(), this.getResponsesSent())) && (fm.icelink.Global.equals(instance.getResponsesReceived(), this.getResponsesReceived())))) && (((fm.icelink.Global.equals(instance.getConsentRequestsSent(), this.getConsentRequestsSent())) && (fm.icelink.Global.equals(instance.getConsentRequestsReceived(), this.getConsentRequestsReceived()))) && ((fm.icelink.Global.equals(instance.getConsentResponsesSent(), this.getConsentResponsesSent())) && (fm.icelink.Global.equals(instance.getConsentResponsesReceived(), this.getConsentResponsesReceived())))))) && (fm.icelink.Global.equals(instance.getTotalRoundTripTime(), this.getTotalRoundTripTime()))) && (fm.icelink.Global.equals(instance.getCurrentRoundTripTime(), this.getCurrentRoundTripTime())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getTransportId(), null))) {
                            jsonObject["transportId"] = fm.icelink.JsonSerializer.serializeString(this.getTransportId());
                        }
                        if ((!fm.icelink.Global.equals(this.getLocalCandidateId(), null))) {
                            jsonObject["localCandidateId"] = fm.icelink.JsonSerializer.serializeString(this.getLocalCandidateId());
                        }
                        if ((!fm.icelink.Global.equals(this.getRemoteCandidateId(), null))) {
                            jsonObject["remoteCandidateId"] = fm.icelink.JsonSerializer.serializeString(this.getRemoteCandidateId());
                        }
                        jsonObject["state"] = fm.icelink.JsonSerializer.serializeString(fm.icelink.CandidateUtility.candidatePairStateToString(this.getState()));
                        jsonObject["priority"] = fm.icelink.JsonSerializer.serializeLong(this.getPriority());
                        jsonObject["nominated"] = fm.icelink.JsonSerializer.serializeBoolean(this.getNominated());
                        jsonObject["bytesSent"] = fm.icelink.JsonSerializer.serializeLong(this.getBytesSent());
                        jsonObject["bytesReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getBytesReceived());
                        jsonObject["requestsSent"] = fm.icelink.JsonSerializer.serializeLong(this.getRequestsSent());
                        jsonObject["requestsReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getRequestsReceived());
                        jsonObject["responsesSent"] = fm.icelink.JsonSerializer.serializeLong(this.getResponsesSent());
                        jsonObject["responsesReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getResponsesReceived());
                        jsonObject["consentRequestsSent"] = fm.icelink.JsonSerializer.serializeLong(this.getConsentRequestsSent());
                        jsonObject["consentRequestsReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getConsentRequestsReceived());
                        jsonObject["consentResponsesSent"] = fm.icelink.JsonSerializer.serializeLong(this.getConsentResponsesSent());
                        jsonObject["consentResponsesReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getConsentResponsesReceived());
                        jsonObject["totalRoundTripTime"] = fm.icelink.JsonSerializer.serializeInteger(this.getTotalRoundTripTime());
                        jsonObject["currentRoundTripTime"] = fm.icelink.JsonSerializer.serializeInteger(this.getCurrentRoundTripTime());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setBytesReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bytesReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setBytesSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bytesSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setConsentRequestsReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._consentRequestsReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setConsentRequestsSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._consentRequestsSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setConsentResponsesReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._consentResponsesReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setConsentResponsesSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._consentResponsesSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setCurrentRoundTripTime = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._currentRoundTripTime = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setLocalCandidateId = function (value) {
                    if (arguments.length == 1) {
                        this._localCandidateId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setNominated = function (value) {
                    if (arguments.length == 1) {
                        this._nominated = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setPriority = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._priority = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setRemoteCandidateId = function (value) {
                    if (arguments.length == 1) {
                        this._remoteCandidateId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setRequestsReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._requestsReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setRequestsSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._requestsSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setResponsesReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._responsesReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setResponsesSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._responsesSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setState = function (value) {
                    if (arguments.length == 1) {
                        this._state = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setTotalRoundTripTime = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._totalRoundTripTime = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.setTransportId = function (value) {
                    if (arguments.length == 1) {
                        this._transportId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidatePairStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.CandidatePairStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CandidatePairStats;
            }(fm.icelink.BaseStats));
            icelink.CandidatePairStats = CandidatePairStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CandidateStats =  (function (_super) {
                __extends(CandidateStats, _super);
                function CandidateStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkCandidateStatsInit();
                        _this.setPort(-1);
                        _this.setRelatedPort(-1);
                        _this.setProtocol(fm.icelink.ProtocolType.Unknown);
                        _this.setRelayProtocol(fm.icelink.ProtocolType.Unknown);
                        _this.setType(fm.icelink.CandidateType.Unknown);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                CandidateStats.prototype.getTypeString = function () {
                    return '[fm.icelink.CandidateStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                CandidateStats.prototype.fmicelinkCandidateStatsInit = function () {
                    this._port = 0;
                    this._priority = 0;
                    this._relatedPort = 0;
                };
                CandidateStats.fromJson = function (candidateJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(candidateJson, function () {
                            return new fm.icelink.CandidateStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.fromJsonArray = function (candidatesJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(candidatesJson, fm.icelink.CandidateStats.fromJson.bind(fm.icelink.CandidateStats));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.toJson = function (candidate) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(candidate, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.toJsonArray = function (candidates) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(candidates, fm.icelink.CandidateStats.toJson.bind(fm.icelink.CandidateStats));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var _var0 = key;
                        do {
                            if (_var0 == "ipAddress") {
                                this.setIPAddress(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "port") {
                                this.setPort(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "relayProtocol") {
                                this.setRelayProtocol(fm.icelink.CandidateUtility.protocolTypeFromString(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                                break;
                            }
                            else if (_var0 == "relatedIPAddress") {
                                this.setRelatedIPAddress(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "relatedPort") {
                                this.setRelatedPort(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "protocol") {
                                this.setProtocol(fm.icelink.CandidateUtility.protocolTypeFromString(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                                break;
                            }
                            else if (_var0 == "type") {
                                this.setType(fm.icelink.CandidateUtility.typeFromString(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                                break;
                            }
                            else if (_var0 == "priority") {
                                this.setPriority(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getIPAddress = function () {
                    if (arguments.length == 0) {
                        return this._ipAddress;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getIsHost = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.Global.equals(this.getType(), fm.icelink.CandidateType.Host));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getIsReflexive = function () {
                    if (arguments.length == 0) {
                        return ((fm.icelink.Global.equals(this.getType(), fm.icelink.CandidateType.ServerReflexive)) || (fm.icelink.Global.equals(this.getType(), fm.icelink.CandidateType.PeerReflexive)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getIsRelayed = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.Global.equals(this.getType(), fm.icelink.CandidateType.Relayed));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getPort = function () {
                    if (arguments.length == 0) {
                        return this._port;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getPriority = function () {
                    if (arguments.length == 0) {
                        return this._priority;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getProtocol = function () {
                    if (arguments.length == 0) {
                        return this._protocol;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getRelatedIPAddress = function () {
                    if (arguments.length == 0) {
                        return this._relatedIPAddress;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getRelatedPort = function () {
                    if (arguments.length == 0) {
                        return this._relatedPort;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getRelayProtocol = function () {
                    if (arguments.length == 0) {
                        return this._relayProtocol;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getTurnProtocol = function () {
                    if (arguments.length == 0) {
                        return this.getRelayProtocol();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.getType = function () {
                    if (arguments.length == 0) {
                        return this._type;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.isEquivalent = function (instance) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(instance, null))) {
                            return false;
                        }
                        return (((((fm.icelink.Global.equals(instance.getIPAddress(), this.getIPAddress())) && (fm.icelink.Global.equals(instance.getPort(), this.getPort()))) && ((fm.icelink.Global.equals(instance.getRelayProtocol(), this.getRelayProtocol())) && (fm.icelink.Global.equals(instance.getRelatedIPAddress(), this.getRelatedIPAddress())))) && (((fm.icelink.Global.equals(instance.getRelatedPort(), this.getRelatedPort())) && (fm.icelink.Global.equals(instance.getProtocol(), this.getProtocol()))) && (fm.icelink.Global.equals(instance.getType(), this.getType())))) && (fm.icelink.Global.equals(instance.getPriority(), this.getPriority())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getIPAddress(), null))) {
                            jsonObject["ipAddress"] = fm.icelink.JsonSerializer.serializeString(this.getIPAddress());
                        }
                        if ((!fm.icelink.Global.equals(this.getPort(), 0))) {
                            jsonObject["port"] = fm.icelink.JsonSerializer.serializeInteger(this.getPort());
                        }
                        if ((!fm.icelink.Global.equals(this.getRelatedIPAddress(), null))) {
                            jsonObject["relatedIPAddress"] = fm.icelink.JsonSerializer.serializeString(this.getRelatedIPAddress());
                        }
                        if ((!fm.icelink.Global.equals(this.getRelatedPort(), 0))) {
                            jsonObject["relatedPort"] = fm.icelink.JsonSerializer.serializeInteger(this.getRelatedPort());
                        }
                        jsonObject["protocol"] = fm.icelink.JsonSerializer.serializeString(fm.icelink.CandidateUtility.protocolTypeToString(this.getProtocol()));
                        jsonObject["type"] = fm.icelink.JsonSerializer.serializeString(fm.icelink.CandidateUtility.typeToString(this.getType()));
                        if ((fm.icelink.Global.equals(this.getType(), fm.icelink.CandidateType.Relayed))) {
                            jsonObject["relayProtocol"] = fm.icelink.JsonSerializer.serializeString(fm.icelink.CandidateUtility.protocolTypeToString(this.getRelayProtocol()));
                        }
                        jsonObject["priority"] = fm.icelink.JsonSerializer.serializeLong(this.getPriority());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.setIPAddress = function (value) {
                    if (arguments.length == 1) {
                        this._ipAddress = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.setPort = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._port = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.setPriority = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._priority = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.setProtocol = function (value) {
                    if (arguments.length == 1) {
                        this._protocol = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.setRelatedIPAddress = function (value) {
                    if (arguments.length == 1) {
                        this._relatedIPAddress = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.setRelatedPort = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._relatedPort = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.setRelayProtocol = function (value) {
                    if (arguments.length == 1) {
                        this._relayProtocol = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.setType = function (value) {
                    if (arguments.length == 1) {
                        this._type = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.CandidateStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CandidateStats;
            }(fm.icelink.BaseStats));
            icelink.CandidateStats = CandidateStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CandidateTypeWrapper =  (function () {
                function CandidateTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_44 = __arguments[0];
                        this._value = value_44;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CandidateTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.CandidateTypeWrapper]';
                };
                CandidateTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.CandidateType.Host)
                            return 'Host';
                        if (this._value == fm.icelink.CandidateType.ServerReflexive)
                            return 'ServerReflexive';
                        if (this._value == fm.icelink.CandidateType.Relayed)
                            return 'Relayed';
                        if (this._value == fm.icelink.CandidateType.PeerReflexive)
                            return 'PeerReflexive';
                        if (this._value == fm.icelink.CandidateType.Unknown)
                            return 'Unknown';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CandidateTypeWrapper;
            }());
            icelink.CandidateTypeWrapper = CandidateTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CandidateUtility =  (function () {
                function CandidateUtility() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CandidateUtility.prototype.getTypeString = function () {
                    return '[fm.icelink.CandidateUtility]';
                };
                CandidateUtility.candidatePairStateFromString = function (stateString) {
                    if (arguments.length == 1) {
                        var _var0 = stateString;
                        do {
                            if (_var0 == "new") {
                                return fm.icelink.CandidatePairState.New;
                            }
                            else if (_var0 == "waiting") {
                                return fm.icelink.CandidatePairState.Waiting;
                            }
                            else if (_var0 == "inProgress") {
                                return fm.icelink.CandidatePairState.InProgress;
                            }
                            else if (_var0 == "succeeded") {
                                return fm.icelink.CandidatePairState.Succeeded;
                            }
                            else if (_var0 == "failed") {
                                return fm.icelink.CandidatePairState.Failed;
                            }
                            else if (_var0 == "closed") {
                                return fm.icelink.CandidatePairState.Closed;
                            }
                            else if (_var0 == "connectivityLost") {
                                return fm.icelink.CandidatePairState.ConnectivityLost;
                            }
                        } while (false);
                        return fm.icelink.CandidatePairState.New;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateUtility.candidatePairStateToString = function (state) {
                    if (arguments.length == 1) {
                        var _var0 = state;
                        do {
                            if (_var0 == fm.icelink.CandidatePairState.New) {
                                return "new";
                            }
                            else if (_var0 == fm.icelink.CandidatePairState.Waiting) {
                                return "waiting";
                            }
                            else if (_var0 == fm.icelink.CandidatePairState.InProgress) {
                                return "inProgress";
                            }
                            else if (_var0 == fm.icelink.CandidatePairState.Succeeded) {
                                return "succeeded";
                            }
                            else if (_var0 == fm.icelink.CandidatePairState.Failed) {
                                return "failed";
                            }
                            else if (_var0 == fm.icelink.CandidatePairState.Closed) {
                                return "closed";
                            }
                            else if (_var0 == fm.icelink.CandidatePairState.ConnectivityLost) {
                                return "connectivityLost";
                            }
                        } while (false);
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateUtility.protocolTypeFromString = function (protocolTypeString) {
                    if (arguments.length == 1) {
                        var _var0 = protocolTypeString;
                        do {
                            if (_var0 == "udp") {
                                return fm.icelink.ProtocolType.Udp;
                            }
                            else if (_var0 == "tcp") {
                                return fm.icelink.ProtocolType.Tcp;
                            }
                            else if (_var0 == "tls") {
                                return fm.icelink.ProtocolType.Tls;
                            }
                        } while (false);
                        return fm.icelink.ProtocolType.Unknown;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateUtility.protocolTypeToString = function (protocolType) {
                    if (arguments.length == 1) {
                        var _var0 = protocolType;
                        do {
                            if (_var0 == fm.icelink.ProtocolType.Udp) {
                                return "udp";
                            }
                            else if (_var0 == fm.icelink.ProtocolType.Tcp) {
                                return "tcp";
                            }
                            else if (_var0 == fm.icelink.ProtocolType.Tls) {
                                return "tls";
                            }
                        } while (false);
                        return "unknown";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateUtility.typeFromString = function (typeString) {
                    if (arguments.length == 1) {
                        var _var0 = typeString;
                        do {
                            if (_var0 == "host") {
                                return fm.icelink.CandidateType.Host;
                            }
                            else if (_var0 == "srflx") {
                                return fm.icelink.CandidateType.ServerReflexive;
                            }
                            else if (_var0 == "relay") {
                                return fm.icelink.CandidateType.Relayed;
                            }
                            else if (_var0 == "prflx") {
                                return fm.icelink.CandidateType.PeerReflexive;
                            }
                        } while (false);
                        return fm.icelink.CandidateType.Unknown;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CandidateUtility.typeToString = function (type) {
                    if (arguments.length == 1) {
                        var _var0 = type;
                        do {
                            if (_var0 == fm.icelink.CandidateType.Host) {
                                return "host";
                            }
                            else if (_var0 == fm.icelink.CandidateType.ServerReflexive) {
                                return "srflx";
                            }
                            else if (_var0 == fm.icelink.CandidateType.Relayed) {
                                return "relay";
                            }
                            else if (_var0 == fm.icelink.CandidateType.PeerReflexive) {
                                return "prflx";
                            }
                        } while (false);
                        return "unknown";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CandidateUtility;
            }());
            icelink.CandidateUtility = CandidateUtility;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CertificateInfo =  (function (_super) {
                __extends(CertificateInfo, _super);
                function CertificateInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else if (__arguments.length == 2) {
                        var stats = __arguments[0];
                        var lastStats = __arguments[1];
                        _this = _super.call(this) || this;
                        var flag = (fm.icelink.Global.equals(lastStats, null));
                        _this.setFingerprint((flag ? stats.getFingerprint() : fm.icelink.Info.processString(stats.getFingerprint(), lastStats.getFingerprint())));
                        _this.setFingerprintAlgorithm((flag ? stats.getFingerprintAlgorithm() : fm.icelink.Info.processString(stats.getFingerprintAlgorithm(), lastStats.getFingerprintAlgorithm())));
                        _this.setBase64((flag ? stats.getCertificateBase64() : fm.icelink.Info.processString(stats.getCertificateBase64(), lastStats.getCertificateBase64())));
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                CertificateInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.CertificateInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                CertificateInfo.fromJson = function (instanceJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(instanceJson, function () {
                            return new fm.icelink.CertificateInfo();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.fromJsonArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(arrayJson, fm.icelink.CertificateInfo.fromJson.bind(fm.icelink.CertificateInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.toJson = function (instance) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(instance, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.toJsonArray = function (array) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(array, fm.icelink.CertificateInfo.toJson.bind(fm.icelink.CertificateInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "fingerprint"))) {
                                if ((fm.icelink.Global.equals(str, "remoteCandidateId"))) {
                                    this.setFingerprintAlgorithm(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "base64"))) {
                                        this.setBase64(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                }
                            }
                            else {
                                this.setFingerprint(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.prototype.getBase64 = function () {
                    if (arguments.length == 0) {
                        return this._base64;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.prototype.getFingerprint = function () {
                    if (arguments.length == 0) {
                        return this._fingerprint;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.prototype.getFingerprintAlgorithm = function () {
                    if (arguments.length == 0) {
                        return this._fingerprintAlgorithm;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getFingerprint(), null))) {
                            jsonObject["fingerprint"] = fm.icelink.JsonSerializer.serializeString(this.getFingerprint());
                        }
                        if ((!fm.icelink.Global.equals(this.getFingerprintAlgorithm(), null))) {
                            jsonObject["fingerprintAlgorithm"] = fm.icelink.JsonSerializer.serializeString(this.getFingerprintAlgorithm());
                        }
                        if ((!fm.icelink.Global.equals(this.getBase64(), null))) {
                            jsonObject["base64"] = fm.icelink.JsonSerializer.serializeString(this.getBase64());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.prototype.setBase64 = function (value) {
                    if (arguments.length == 1) {
                        this._base64 = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.prototype.setFingerprint = function (value) {
                    if (arguments.length == 1) {
                        this._fingerprint = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.prototype.setFingerprintAlgorithm = function (value) {
                    if (arguments.length == 1) {
                        this._fingerprintAlgorithm = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.CertificateInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CertificateInfo;
            }(fm.icelink.Info));
            icelink.CertificateInfo = CertificateInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CertificateStats =  (function (_super) {
                __extends(CertificateStats, _super);
                function CertificateStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                CertificateStats.prototype.getTypeString = function () {
                    return '[fm.icelink.CertificateStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                CertificateStats.fromJson = function (certificateJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(certificateJson, function () {
                            return new fm.icelink.CertificateStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.fromJsonArray = function (certificatesJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(certificatesJson, fm.icelink.CertificateStats.fromJson.bind(fm.icelink.CertificateStats));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.toJson = function (certificate) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(certificate, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.toJsonArray = function (certificates) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(certificates, fm.icelink.CertificateStats.toJson.bind(fm.icelink.CertificateStats));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "fingerprint"))) {
                                if ((fm.icelink.Global.equals(str, "fingerprintAlgorithm"))) {
                                    this.setFingerprintAlgorithm(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "certificateBase64"))) {
                                        this.setCertificateBase64(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                }
                            }
                            else {
                                this.setFingerprint(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.prototype.getCertificateBase64 = function () {
                    if (arguments.length == 0) {
                        return this._certificateBase64;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.prototype.getFingerprint = function () {
                    if (arguments.length == 0) {
                        return this._fingerprint;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.prototype.getFingerprintAlgorithm = function () {
                    if (arguments.length == 0) {
                        return this._fingerprintAlgorithm;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.prototype.isEquivalent = function (instance) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(instance, null))) {
                            return false;
                        }
                        return (((fm.icelink.Global.equals(instance.getFingerprint(), this.getFingerprint())) && (fm.icelink.Global.equals(instance.getFingerprintAlgorithm(), this.getFingerprintAlgorithm()))) && (fm.icelink.Global.equals(instance.getCertificateBase64(), this.getCertificateBase64())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getFingerprint(), null))) {
                            jsonObject["fingerprint"] = fm.icelink.JsonSerializer.serializeString(this.getFingerprint());
                        }
                        if ((!fm.icelink.Global.equals(this.getFingerprintAlgorithm(), null))) {
                            jsonObject["fingerprintAlgorithm"] = fm.icelink.JsonSerializer.serializeString(this.getFingerprintAlgorithm());
                        }
                        if ((!fm.icelink.Global.equals(this.getCertificateBase64(), null))) {
                            jsonObject["certificateBase64"] = fm.icelink.JsonSerializer.serializeString(this.getCertificateBase64());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.prototype.setCertificateBase64 = function (value) {
                    if (arguments.length == 1) {
                        this._certificateBase64 = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.prototype.setFingerprint = function (value) {
                    if (arguments.length == 1) {
                        this._fingerprint = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.prototype.setFingerprintAlgorithm = function (value) {
                    if (arguments.length == 1) {
                        this._fingerprintAlgorithm = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CertificateStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.CertificateStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CertificateStats;
            }(fm.icelink.BaseStats));
            icelink.CertificateStats = CertificateStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CodecInfo =  (function (_super) {
                __extends(CodecInfo, _super);
                function CodecInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkCodecInfoInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                CodecInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.CodecInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                CodecInfo.prototype.fmicelinkCodecInfoInit = function () {
                    this._channelCount = 0;
                    this._clockRate = 0;
                    this._payloadType = 0;
                };
                CodecInfo.fromJson = function (codecInfoJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(codecInfoJson, function () {
                            return new fm.icelink.CodecInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.fromJsonArray = function (codecInfosJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(codecInfosJson, fm.icelink.CodecInfo.fromJson.bind(fm.icelink.CodecInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.toJson = function (codecInfo) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(codecInfo, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.toJsonArray = function (codecInfos) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(codecInfos, fm.icelink.CodecInfo.toJson.bind(fm.icelink.CodecInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "name"))) {
                                if ((fm.icelink.Global.equals(str, "clockRate"))) {
                                    this.setClockRate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "channelCount"))) {
                                        this.setChannelCount(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "parameters"))) {
                                            this.setParameters(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "payloadType"))) {
                                                this.setPayloadType(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                this.setName(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.getChannelCount = function () {
                    if (arguments.length == 0) {
                        return this._channelCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.getClockRate = function () {
                    if (arguments.length == 0) {
                        return this._clockRate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.getName = function () {
                    if (arguments.length == 0) {
                        return this._name;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.getParameters = function () {
                    if (arguments.length == 0) {
                        return this._parameters;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.getPayloadType = function () {
                    if (arguments.length == 0) {
                        return this._payloadType;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getName())) {
                            jsonObject["name"] = fm.icelink.JsonSerializer.serializeString(this.getName());
                        }
                        if ((this.getClockRate() != null)) {
                            jsonObject["clockRate"] = fm.icelink.JsonSerializer.serializeInteger(this.getClockRate());
                        }
                        if ((this.getChannelCount() != null)) {
                            jsonObject["channelCount"] = fm.icelink.JsonSerializer.serializeInteger(this.getChannelCount());
                        }
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getParameters())) {
                            jsonObject["parameters"] = fm.icelink.JsonSerializer.serializeString(this.getParameters());
                        }
                        if ((this.getPayloadType() != null)) {
                            jsonObject["payloadType"] = fm.icelink.JsonSerializer.serializeInteger(this.getPayloadType());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.setChannelCount = function (value) {
                    if (arguments.length == 1) {
                        this._channelCount = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.setClockRate = function (value) {
                    if (arguments.length == 1) {
                        this._clockRate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.setName = function (value) {
                    if (arguments.length == 1) {
                        this._name = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.setParameters = function (value) {
                    if (arguments.length == 1) {
                        this._parameters = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.setPayloadType = function (value) {
                    if (arguments.length == 1) {
                        this._payloadType = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.CodecInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CodecInfo;
            }(fm.icelink.Info));
            icelink.CodecInfo = CodecInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CodecStats =  (function (_super) {
                __extends(CodecStats, _super);
                function CodecStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkCodecStatsInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                CodecStats.prototype.getTypeString = function () {
                    return '[fm.icelink.CodecStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                CodecStats.prototype.fmicelinkCodecStatsInit = function () {
                    this._channelCount = 0;
                    this._clockRate = 0;
                    this._payloadType = 0;
                };
                CodecStats.fromJson = function (codecJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(codecJson, function () {
                            return new fm.icelink.CodecStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.toJson = function (codec) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(codec, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str2 = key;
                        if ((!fm.icelink.Global.equals(str2, null))) {
                            if (!(fm.icelink.Global.equals(str2, "codecType"))) {
                                if ((fm.icelink.Global.equals(str2, "payloadType"))) {
                                    this.setPayloadType(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str2, "name"))) {
                                        this.setName(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str2, "clockRate"))) {
                                            this.setClockRate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str2, "channelCount"))) {
                                                this.setChannelCount(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                            }
                                            else {
                                                if ((fm.icelink.Global.equals(str2, "parameters"))) {
                                                    this.setParameters(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                var str = fm.icelink.JsonSerializer.deserializeString(valueJson);
                                this.setCodecType(((fm.icelink.Global.equals(str, "encode")) ? fm.icelink.CodecType.Encode : fm.icelink.CodecType.Decode));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.getChannelCount = function () {
                    if (arguments.length == 0) {
                        return this._channelCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.getClockRate = function () {
                    if (arguments.length == 0) {
                        return this._clockRate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.getCodecType = function () {
                    if (arguments.length == 0) {
                        return this._codecType;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.getName = function () {
                    if (arguments.length == 0) {
                        return this._name;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.getParameters = function () {
                    if (arguments.length == 0) {
                        return this._parameters;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.getPayloadType = function () {
                    if (arguments.length == 0) {
                        return this._payloadType;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.isEquivalent = function (instance) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(instance, null))) {
                            return false;
                        }
                        return (((((fm.icelink.Global.equals(instance.getCodecType(), this.getCodecType())) && (fm.icelink.Global.equals(instance.getPayloadType(), this.getPayloadType()))) && ((fm.icelink.Global.equals(instance.getName(), this.getName())) && (fm.icelink.Global.equals(instance.getClockRate(), this.getClockRate())))) && (fm.icelink.Global.equals(instance.getChannelCount(), this.getChannelCount()))) && (fm.icelink.Global.equals(instance.getParameters(), this.getParameters())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        jsonObject["codecType"] = fm.icelink.JsonSerializer.serializeString(((fm.icelink.Global.equals(this.getCodecType(), fm.icelink.CodecType.Encode)) ? "encode" : "decode"));
                        jsonObject["payloadType"] = fm.icelink.JsonSerializer.serializeInteger(this.getPayloadType());
                        if ((!fm.icelink.Global.equals(this.getName(), null))) {
                            jsonObject["name"] = fm.icelink.JsonSerializer.serializeString(this.getName());
                        }
                        jsonObject["clockRate"] = fm.icelink.JsonSerializer.serializeInteger(this.getClockRate());
                        if ((!fm.icelink.Global.equals(this.getChannelCount(), 0))) {
                            jsonObject["channelCount"] = fm.icelink.JsonSerializer.serializeInteger(this.getChannelCount());
                        }
                        if ((!fm.icelink.Global.equals(this.getParameters(), null))) {
                            jsonObject["parameters"] = fm.icelink.JsonSerializer.serializeString(this.getParameters());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.setChannelCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._channelCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.setClockRate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._clockRate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.setCodecType = function (value) {
                    if (arguments.length == 1) {
                        this._codecType = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.setName = function (value) {
                    if (arguments.length == 1) {
                        this._name = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.setParameters = function (value) {
                    if (arguments.length == 1) {
                        this._parameters = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.setPayloadType = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._payloadType = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                CodecStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.CodecStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CodecStats;
            }(fm.icelink.BaseStats));
            icelink.CodecStats = CodecStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var CodecTypeWrapper =  (function () {
                function CodecTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_45 = __arguments[0];
                        this._value = value_45;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                CodecTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.CodecTypeWrapper]';
                };
                CodecTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.CodecType.Encode)
                            return 'Encode';
                        if (this._value == fm.icelink.CodecType.Decode)
                            return 'Decode';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return CodecTypeWrapper;
            }());
            icelink.CodecTypeWrapper = CodecTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ConnectionStateWrapper =  (function () {
                function ConnectionStateWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_46 = __arguments[0];
                        this._value = value_46;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                ConnectionStateWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.ConnectionStateWrapper]';
                };
                ConnectionStateWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.ConnectionState.New)
                            return 'New';
                        if (this._value == fm.icelink.ConnectionState.Initializing)
                            return 'Initializing';
                        if (this._value == fm.icelink.ConnectionState.Connecting)
                            return 'Connecting';
                        if (this._value == fm.icelink.ConnectionState.Connected)
                            return 'Connected';
                        if (this._value == fm.icelink.ConnectionState.Failing)
                            return 'Failing';
                        if (this._value == fm.icelink.ConnectionState.Failed)
                            return 'Failed';
                        if (this._value == fm.icelink.ConnectionState.Closing)
                            return 'Closing';
                        if (this._value == fm.icelink.ConnectionState.Closed)
                            return 'Closed';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ConnectionStateWrapper;
            }());
            icelink.ConnectionStateWrapper = ConnectionStateWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ConnectionStats =  (function (_super) {
                __extends(ConnectionStats, _super);
                function ConnectionStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                ConnectionStats.prototype.getTypeString = function () {
                    return '[fm.icelink.ConnectionStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                ConnectionStats.fromJson = function (connectionJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(connectionJson, function () {
                            return new fm.icelink.ConnectionStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.toJson = function (connection) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(connection, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "externalId"))) {
                                if ((fm.icelink.Global.equals(str, "state"))) {
                                    this.setState(this.stateFromString(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "mediaStreams"))) {
                                        this.setMediaStreams(fm.icelink.MediaStreamStats.fromJsonArray(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "dataStream"))) {
                                            this.setDataStream(fm.icelink.DataStreamStats.fromJson(valueJson));
                                        }
                                    }
                                }
                            }
                            else {
                                this.setExternalId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getAudioStream = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getAudioStreams());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getAudioStreams = function () {
                    if (arguments.length == 0) {
                        var list = new Array();
                        var mediaStreams = this.getMediaStreams();
                        if ((!fm.icelink.Global.equals(mediaStreams, null))) {
                            for (var _i = 0, mediaStreams_1 = mediaStreams; _i < mediaStreams_1.length; _i++) {
                                var stats = mediaStreams_1[_i];
                                if ((fm.icelink.Global.equals(stats.getType(), fm.icelink.StreamType.Audio))) {
                                    fm.icelink.ArrayExtensions.add(list, stats);
                                }
                            }
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getDataStream = function () {
                    if (arguments.length == 0) {
                        return this._dataStream;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getExternalId = function () {
                    if (arguments.length == 0) {
                        return this._externalId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getIsHost = function () {
                    if (arguments.length == 0) {
                        var streams = this.getStreams();
                        if ((!fm.icelink.Global.equals(streams, null))) {
                            for (var _i = 0, streams_4 = streams; _i < streams_4.length; _i++) {
                                var stats = streams_4[_i];
                                if (stats.getIsHost()) {
                                    return true;
                                }
                            }
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getIsReflexive = function () {
                    if (arguments.length == 0) {
                        var streams = this.getStreams();
                        if ((!fm.icelink.Global.equals(streams, null))) {
                            for (var _i = 0, streams_5 = streams; _i < streams_5.length; _i++) {
                                var stats = streams_5[_i];
                                if (stats.getIsReflexive()) {
                                    return true;
                                }
                            }
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getIsRelayed = function () {
                    if (arguments.length == 0) {
                        var streams = this.getStreams();
                        if ((!fm.icelink.Global.equals(streams, null))) {
                            for (var _i = 0, streams_6 = streams; _i < streams_6.length; _i++) {
                                var stats = streams_6[_i];
                                if (stats.getIsRelayed()) {
                                    return true;
                                }
                            }
                        }
                        return false;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getMediaStream = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getMediaStreams());
                    }
                    else if (arguments.length == 1) {
                        var mediaStreamId = arguments[0];
                        for (var _i = 0, _a = this.getMediaStreams(); _i < _a.length; _i++) {
                            var stats = _a[_i];
                            if ((fm.icelink.Global.equals(stats.getId(), mediaStreamId))) {
                                return stats;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getMediaStreams = function () {
                    if (arguments.length == 0) {
                        return this._mediaStreams;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getState = function () {
                    if (arguments.length == 0) {
                        return this._state;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getStreams = function () {
                    if (arguments.length == 0) {
                        var list = new Array();
                        var mediaStreams = this.getMediaStreams();
                        if ((!fm.icelink.Global.equals(mediaStreams, null))) {
                            for (var _i = 0, mediaStreams_2 = mediaStreams; _i < mediaStreams_2.length; _i++) {
                                var stats = mediaStreams_2[_i];
                                fm.icelink.ArrayExtensions.add(list, stats);
                            }
                        }
                        var dataStream = this.getDataStream();
                        if ((!fm.icelink.Global.equals(dataStream, null))) {
                            fm.icelink.ArrayExtensions.add(list, dataStream);
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getVideoStream = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getVideoStreams());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.getVideoStreams = function () {
                    if (arguments.length == 0) {
                        var list = new Array();
                        var mediaStreams = this.getMediaStreams();
                        if ((!fm.icelink.Global.equals(mediaStreams, null))) {
                            for (var _i = 0, mediaStreams_3 = mediaStreams; _i < mediaStreams_3.length; _i++) {
                                var stats = mediaStreams_3[_i];
                                if ((fm.icelink.Global.equals(stats.getType(), fm.icelink.StreamType.Video))) {
                                    fm.icelink.ArrayExtensions.add(list, stats);
                                }
                            }
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getExternalId(), null))) {
                            jsonObject["externalId"] = fm.icelink.JsonSerializer.serializeString(this.getExternalId());
                        }
                        jsonObject["state"] = fm.icelink.JsonSerializer.serializeString(this.stateToString(this.getState()));
                        if ((!fm.icelink.Global.equals(this.getMediaStreams(), null))) {
                            jsonObject["mediaStreams"] = fm.icelink.MediaStreamStats.toJsonArray(this.getMediaStreams());
                        }
                        if ((!fm.icelink.Global.equals(this.getDataStream(), null))) {
                            jsonObject["dataStream"] = fm.icelink.DataStreamStats.toJson(this.getDataStream());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.setDataStream = function (value) {
                    if (arguments.length == 1) {
                        this._dataStream = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.setExternalId = function (value) {
                    if (arguments.length == 1) {
                        this._externalId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.setMediaStreams = function (value) {
                    if (arguments.length == 1) {
                        this._mediaStreams = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.setState = function (value) {
                    if (arguments.length == 1) {
                        this._state = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.stateFromString = function (stateString) {
                    if (arguments.length == 1) {
                        var _var0 = stateString;
                        do {
                            if (_var0 == "new") {
                                return fm.icelink.ConnectionState.New;
                            }
                            else if (_var0 == "initializing") {
                                return fm.icelink.ConnectionState.Initializing;
                            }
                            else if (_var0 == "connecting") {
                                return fm.icelink.ConnectionState.Connecting;
                            }
                            else if (_var0 == "connected") {
                                return fm.icelink.ConnectionState.Connected;
                            }
                            else if (_var0 == "failing") {
                                return fm.icelink.ConnectionState.Failing;
                            }
                            else if (_var0 == "failed") {
                                return fm.icelink.ConnectionState.Failed;
                            }
                            else if (_var0 == "closing") {
                                return fm.icelink.ConnectionState.Closing;
                            }
                            else if (_var0 == "closed") {
                                return fm.icelink.ConnectionState.Closed;
                            }
                        } while (false);
                        return fm.icelink.ConnectionState.New;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.stateToString = function (state) {
                    if (arguments.length == 1) {
                        var _var0 = state;
                        do {
                            if (_var0 == fm.icelink.ConnectionState.New) {
                                return "new";
                            }
                            else if (_var0 == fm.icelink.ConnectionState.Initializing) {
                                return "initializing";
                            }
                            else if (_var0 == fm.icelink.ConnectionState.Connecting) {
                                return "connecting";
                            }
                            else if (_var0 == fm.icelink.ConnectionState.Connected) {
                                return "connected";
                            }
                            else if (_var0 == fm.icelink.ConnectionState.Failing) {
                                return "failing";
                            }
                            else if (_var0 == fm.icelink.ConnectionState.Failed) {
                                return "failed";
                            }
                            else if (_var0 == fm.icelink.ConnectionState.Closing) {
                                return "closing";
                            }
                            else if (_var0 == fm.icelink.ConnectionState.Closed) {
                                return "closed";
                            }
                        } while (false);
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ConnectionStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.ConnectionStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ConnectionStats;
            }(fm.icelink.BaseStats));
            icelink.ConnectionStats = ConnectionStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataChannelInfo =  (function (_super) {
                __extends(DataChannelInfo, _super);
                function DataChannelInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkDataChannelInfoInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                DataChannelInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.DataChannelInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DataChannelInfo.prototype.fmicelinkDataChannelInfoInit = function () {
                    this._ordered = false;
                };
                DataChannelInfo.fromJson = function (dataChannelInfoJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(dataChannelInfoJson, function () {
                            return new fm.icelink.DataChannelInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.fromJsonArray = function (dataChannelInfosJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(dataChannelInfosJson, fm.icelink.DataChannelInfo.fromJson.bind(fm.icelink.DataChannelInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.toJson = function (dataChannelInfo) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(dataChannelInfo, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.toJsonArray = function (dataChannelInfos) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(dataChannelInfos, fm.icelink.DataChannelInfo.toJson.bind(fm.icelink.DataChannelInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "label"))) {
                                if ((fm.icelink.Global.equals(str, "ordered"))) {
                                    this.setOrdered(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "subprotocol"))) {
                                        this.setSubprotocol(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                }
                            }
                            else {
                                this.setLabel(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.prototype.getLabel = function () {
                    if (arguments.length == 0) {
                        return this._label;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.prototype.getOrdered = function () {
                    if (arguments.length == 0) {
                        return this._ordered;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.prototype.getSubprotocol = function () {
                    if (arguments.length == 0) {
                        return this._subprotocol;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getLabel(), null))) {
                            jsonObject["label"] = fm.icelink.JsonSerializer.serializeString(this.getLabel());
                        }
                        if (this.getOrdered()) {
                            jsonObject["ordered"] = fm.icelink.JsonSerializer.serializeBoolean(this.getOrdered());
                        }
                        if ((!fm.icelink.Global.equals(this.getSubprotocol(), null))) {
                            jsonObject["subprotocol"] = fm.icelink.JsonSerializer.serializeString(this.getSubprotocol());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.prototype.setLabel = function (value) {
                    if (arguments.length == 1) {
                        this._label = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.prototype.setOrdered = function (value) {
                    if (arguments.length == 1) {
                        this._ordered = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.prototype.setSubprotocol = function (value) {
                    if (arguments.length == 1) {
                        this._subprotocol = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.DataChannelInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataChannelInfo;
            }(fm.icelink.Info));
            icelink.DataChannelInfo = DataChannelInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataChannelStateWrapper =  (function () {
                function DataChannelStateWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_47 = __arguments[0];
                        this._value = value_47;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                DataChannelStateWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.DataChannelStateWrapper]';
                };
                DataChannelStateWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.DataChannelState.New)
                            return 'New';
                        if (this._value == fm.icelink.DataChannelState.Connecting)
                            return 'Connecting';
                        if (this._value == fm.icelink.DataChannelState.Connected)
                            return 'Connected';
                        if (this._value == fm.icelink.DataChannelState.Closing)
                            return 'Closing';
                        if (this._value == fm.icelink.DataChannelState.Closed)
                            return 'Closed';
                        if (this._value == fm.icelink.DataChannelState.Failed)
                            return 'Failed';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataChannelStateWrapper;
            }());
            icelink.DataChannelStateWrapper = DataChannelStateWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataChannelStats =  (function (_super) {
                __extends(DataChannelStats, _super);
                function DataChannelStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkDataChannelStatsInit();
                        _this.setState(fm.icelink.DataChannelState.New);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                DataChannelStats.prototype.getTypeString = function () {
                    return '[fm.icelink.DataChannelStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DataChannelStats.prototype.fmicelinkDataChannelStatsInit = function () {
                    this._bytesReceived = 0;
                    this._bytesSent = 0;
                    this._messagesReceived = 0;
                    this._messagesSent = 0;
                    this._ordered = false;
                };
                DataChannelStats.fromJson = function (dataChannelJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(dataChannelJson, function () {
                            return new fm.icelink.DataChannelStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.fromJsonArray = function (dataChannelsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(dataChannelsJson, fm.icelink.DataChannelStats.fromJson.bind(fm.icelink.DataChannelStats));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.toJson = function (dataChannel) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(dataChannel, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.toJsonArray = function (dataChannels) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(dataChannels, fm.icelink.DataChannelStats.toJson.bind(fm.icelink.DataChannelStats));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var _var0 = key;
                        do {
                            if (_var0 == "label") {
                                this.setLabel(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "ordered") {
                                this.setOrdered(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                break;
                            }
                            else if (_var0 == "protocol") {
                                this.setProtocol(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "state") {
                                this.setState(this.stateFromString(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                                break;
                            }
                            else if (_var0 == "messagesSent") {
                                this.setMessagesSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "bytesSent") {
                                this.setBytesSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "messagesReceived") {
                                this.setMessagesReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "bytesReceived") {
                                this.setBytesReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.getBytesReceived = function () {
                    if (arguments.length == 0) {
                        return this._bytesReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.getBytesSent = function () {
                    if (arguments.length == 0) {
                        return this._bytesSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.getLabel = function () {
                    if (arguments.length == 0) {
                        return this._label;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.getMessagesReceived = function () {
                    if (arguments.length == 0) {
                        return this._messagesReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.getMessagesSent = function () {
                    if (arguments.length == 0) {
                        return this._messagesSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.getOrdered = function () {
                    if (arguments.length == 0) {
                        return this._ordered;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.getProtocol = function () {
                    if (arguments.length == 0) {
                        return this._protocol;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.getState = function () {
                    if (arguments.length == 0) {
                        return this._state;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getLabel(), null))) {
                            jsonObject["label"] = fm.icelink.JsonSerializer.serializeString(this.getLabel());
                        }
                        jsonObject["ordered"] = fm.icelink.JsonSerializer.serializeBoolean(this.getOrdered());
                        if ((!fm.icelink.Global.equals(this.getProtocol(), null))) {
                            jsonObject["protocol"] = fm.icelink.JsonSerializer.serializeString(this.getProtocol());
                        }
                        jsonObject["state"] = fm.icelink.JsonSerializer.serializeString(this.stateToString(this.getState()));
                        jsonObject["messagesSent"] = fm.icelink.JsonSerializer.serializeLong(this.getMessagesSent());
                        jsonObject["bytesSent"] = fm.icelink.JsonSerializer.serializeLong(this.getBytesSent());
                        jsonObject["messagesReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getMessagesReceived());
                        jsonObject["bytesReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getBytesReceived());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.setBytesReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bytesReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.setBytesSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bytesSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.setLabel = function (value) {
                    if (arguments.length == 1) {
                        this._label = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.setMessagesReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._messagesReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.setMessagesSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._messagesSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.setOrdered = function (value) {
                    if (arguments.length == 1) {
                        this._ordered = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.setProtocol = function (value) {
                    if (arguments.length == 1) {
                        this._protocol = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.setState = function (value) {
                    if (arguments.length == 1) {
                        this._state = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.stateFromString = function (stateString) {
                    if (arguments.length == 1) {
                        var _var0 = stateString;
                        do {
                            if (_var0 == "new") {
                                return fm.icelink.DataChannelState.New;
                            }
                            else if (_var0 == "connecting") {
                                return fm.icelink.DataChannelState.Connecting;
                            }
                            else if (_var0 == "connected") {
                                return fm.icelink.DataChannelState.Connected;
                            }
                            else if (_var0 == "failed") {
                                return fm.icelink.DataChannelState.Failed;
                            }
                            else if (_var0 == "closing") {
                                return fm.icelink.DataChannelState.Closing;
                            }
                            else if (_var0 == "closed") {
                                return fm.icelink.DataChannelState.Closed;
                            }
                        } while (false);
                        return fm.icelink.DataChannelState.New;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.stateToString = function (state) {
                    if (arguments.length == 1) {
                        var _var0 = state;
                        do {
                            if (_var0 == fm.icelink.DataChannelState.New) {
                                return "new";
                            }
                            else if (_var0 == fm.icelink.DataChannelState.Connecting) {
                                return "connecting";
                            }
                            else if (_var0 == fm.icelink.DataChannelState.Connected) {
                                return "connected";
                            }
                            else if (_var0 == fm.icelink.DataChannelState.Closing) {
                                return "closing";
                            }
                            else if (_var0 == fm.icelink.DataChannelState.Closed) {
                                return "closed";
                            }
                            else if (_var0 == fm.icelink.DataChannelState.Failed) {
                                return "failed";
                            }
                        } while (false);
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataChannelStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.DataChannelStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataChannelStats;
            }(fm.icelink.BaseStats));
            icelink.DataChannelStats = DataChannelStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StreamInfo =  (function (_super) {
                __extends(StreamInfo, _super);
                function StreamInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                StreamInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.StreamInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                StreamInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "tag"))) {
                                if ((fm.icelink.Global.equals(str, "transportId"))) {
                                    this.setTransportId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                            }
                            else {
                                this.setTag(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamInfo.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamInfo.prototype.getTransportId = function () {
                    if (arguments.length == 0) {
                        return this._transportId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getTag(), null))) {
                            jsonObject["tag"] = fm.icelink.JsonSerializer.serializeString(this.getTag());
                        }
                        if ((!fm.icelink.Global.equals(this.getTransportId(), null))) {
                            jsonObject["transportId"] = fm.icelink.JsonSerializer.serializeString(this.getTransportId());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamInfo.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamInfo.prototype.setTransportId = function (value) {
                    if (arguments.length == 1) {
                        this._transportId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StreamInfo;
            }(fm.icelink.Info));
            icelink.StreamInfo = StreamInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataStreamInfo =  (function (_super) {
                __extends(DataStreamInfo, _super);
                function DataStreamInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                DataStreamInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.DataStreamInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DataStreamInfo.fromJson = function (dataStreamInfoJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(dataStreamInfoJson, function () {
                            return new fm.icelink.DataStreamInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamInfo.fromJsonArray = function (dataStreamInfosJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(dataStreamInfosJson, fm.icelink.DataStreamInfo.fromJson.bind(fm.icelink.DataStreamInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamInfo.toJson = function (dataStreamInfo) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(dataStreamInfo, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamInfo.toJsonArray = function (dataStreamInfos) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(dataStreamInfos, fm.icelink.DataStreamInfo.toJson.bind(fm.icelink.DataStreamInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if (((!fm.icelink.Global.equals(str, null)) && (fm.icelink.Global.equals(str, "channels")))) {
                            this.setChannels(fm.icelink.DataChannelInfo.fromJsonArray(valueJson));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamInfo.prototype.getChannels = function () {
                    if (arguments.length == 0) {
                        return this._channels;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getChannels(), null))) {
                            jsonObject["channels"] = fm.icelink.DataChannelInfo.toJsonArray(this.getChannels());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamInfo.prototype.setChannels = function (value) {
                    if (arguments.length == 1) {
                        this._channels = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.DataStreamInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataStreamInfo;
            }(fm.icelink.StreamInfo));
            icelink.DataStreamInfo = DataStreamInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StreamStats =  (function (_super) {
                __extends(StreamStats, _super);
                function StreamStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                StreamStats.prototype.getTypeString = function () {
                    return '[fm.icelink.StreamStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                StreamStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "type"))) {
                                if ((fm.icelink.Global.equals(str, "transport"))) {
                                    this.setTransport(fm.icelink.TransportStats.fromJson(valueJson));
                                }
                            }
                            else {
                                this.setType(this.typeFromString(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStats.prototype.getIsHost = function () {
                    if (arguments.length == 0) {
                        var transport = this.getTransport();
                        if ((fm.icelink.Global.equals(transport, null))) {
                            return false;
                        }
                        return transport.getIsHost();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStats.prototype.getIsReflexive = function () {
                    if (arguments.length == 0) {
                        var transport = this.getTransport();
                        if ((fm.icelink.Global.equals(transport, null))) {
                            return false;
                        }
                        return transport.getIsReflexive();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStats.prototype.getIsRelayed = function () {
                    if (arguments.length == 0) {
                        var transport = this.getTransport();
                        if ((fm.icelink.Global.equals(transport, null))) {
                            return false;
                        }
                        return transport.getIsRelayed();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStats.prototype.getTransport = function () {
                    if (arguments.length == 0) {
                        return this._transport;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStats.prototype.getType = function () {
                    if (arguments.length == 0) {
                        return this._type;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        jsonObject["type"] = fm.icelink.JsonSerializer.serializeString(this.typeToString(this.getType()));
                        if ((!fm.icelink.Global.equals(this.getTransport(), null))) {
                            jsonObject["transport"] = fm.icelink.TransportStats.toJson(this.getTransport());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStats.prototype.setTransport = function (value) {
                    if (arguments.length == 1) {
                        this._transport = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStats.prototype.setType = function (value) {
                    if (arguments.length == 1) {
                        this._type = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStats.prototype.typeFromString = function (typeString) {
                    if (arguments.length == 1) {
                        var _var0 = typeString;
                        do {
                            if (_var0 == "audio") {
                                return fm.icelink.StreamType.Audio;
                            }
                            else if (_var0 == "video") {
                                return fm.icelink.StreamType.Video;
                            }
                            else if (_var0 == "application") {
                                return fm.icelink.StreamType.Application;
                            }
                            else if (_var0 == "message") {
                                return fm.icelink.StreamType.Message;
                            }
                            else if (_var0 == "text") {
                                return fm.icelink.StreamType.Text;
                            }
                        } while (false);
                        return fm.icelink.StreamType.Text;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamStats.prototype.typeToString = function (type) {
                    if (arguments.length == 1) {
                        var _var0 = type;
                        do {
                            if (_var0 == fm.icelink.StreamType.Audio) {
                                return "audio";
                            }
                            else if (_var0 == fm.icelink.StreamType.Video) {
                                return "video";
                            }
                            else if (_var0 == fm.icelink.StreamType.Application) {
                                return "application";
                            }
                            else if (_var0 == fm.icelink.StreamType.Message) {
                                return "message";
                            }
                            else if (_var0 == fm.icelink.StreamType.Text) {
                                return "text";
                            }
                        } while (false);
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StreamStats;
            }(fm.icelink.BaseStats));
            icelink.StreamStats = StreamStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataStreamStats =  (function (_super) {
                __extends(DataStreamStats, _super);
                function DataStreamStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkDataStreamStatsInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                DataStreamStats.prototype.getTypeString = function () {
                    return '[fm.icelink.DataStreamStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DataStreamStats.prototype.fmicelinkDataStreamStatsInit = function () {
                    this._bytesReceived = 0;
                    this._bytesSent = 0;
                    this._messagesReceived = 0;
                    this._messagesSent = 0;
                };
                DataStreamStats.fromJson = function (dataStreamJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(dataStreamJson, function () {
                            return new fm.icelink.DataStreamStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.fromJsonArray = function (dataStreamsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(dataStreamsJson, fm.icelink.DataStreamStats.fromJson.bind(fm.icelink.DataStreamStats));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.toJson = function (dataStream) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(dataStream, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.toJsonArray = function (dataStreams) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(dataStreams, fm.icelink.DataStreamStats.toJson.bind(fm.icelink.DataStreamStats));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "messagesSent"))) {
                                if ((fm.icelink.Global.equals(str, "bytesSent"))) {
                                    this.setBytesSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "messagesReceived"))) {
                                        this.setMessagesReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "bytesReceived"))) {
                                            this.setBytesReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "channels"))) {
                                                this.setChannels(fm.icelink.DataChannelStats.fromJsonArray(valueJson));
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                this.setMessagesSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.getBytesReceived = function () {
                    if (arguments.length == 0) {
                        return this._bytesReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.getBytesSent = function () {
                    if (arguments.length == 0) {
                        return this._bytesSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.getChannel = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getChannels());
                    }
                    else if (arguments.length == 1) {
                        var channelId = arguments[0];
                        for (var _i = 0, _a = this.getChannels(); _i < _a.length; _i++) {
                            var stats = _a[_i];
                            if ((fm.icelink.Global.equals(stats.getId(), channelId))) {
                                return stats;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.getChannels = function () {
                    if (arguments.length == 0) {
                        return this._channels;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.getDataChannel = function () {
                    if (arguments.length == 0) {
                        return this.getChannel();
                    }
                    else if (arguments.length == 1) {
                        var dataChannelId = arguments[0];
                        return this.getChannel(dataChannelId);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.getDataChannels = function () {
                    if (arguments.length == 0) {
                        return this.getChannels();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.getMessagesReceived = function () {
                    if (arguments.length == 0) {
                        return this._messagesReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.getMessagesSent = function () {
                    if (arguments.length == 0) {
                        return this._messagesSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        jsonObject["messagesSent"] = fm.icelink.JsonSerializer.serializeLong(this.getMessagesSent());
                        jsonObject["bytesSent"] = fm.icelink.JsonSerializer.serializeLong(this.getBytesSent());
                        jsonObject["messagesReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getMessagesReceived());
                        jsonObject["bytesReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getBytesReceived());
                        if ((!fm.icelink.Global.equals(this.getChannels(), null))) {
                            jsonObject["channels"] = fm.icelink.DataChannelStats.toJsonArray(this.getChannels());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.setBytesReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bytesReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.setBytesSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bytesSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.setChannels = function (value) {
                    if (arguments.length == 1) {
                        this._channels = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.setMessagesReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._messagesReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.setMessagesSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._messagesSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                DataStreamStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.DataStreamStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return DataStreamStats;
            }(fm.icelink.StreamStats));
            icelink.DataStreamStats = DataStreamStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var EncodingConfig =  (function () {
                function EncodingConfig() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkEncodingConfigInit();
                        this.setRtpStreamId(null);
                        this.setSynchronizationSource(-1);
                        this.setDeactivated(false);
                        this.setBitrate(-1);
                    }
                    else if (__arguments.length == 1) {
                        var encoding = __arguments[0];
                        this.fmicelinkEncodingConfigInit();
                        this.setRtpStreamId(encoding.getRtpStreamId());
                        this.setSynchronizationSource(encoding.getSynchronizationSource());
                        this.setDeactivated(encoding.getDeactivated());
                        this.setBitrate(encoding.getBitrate());
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                EncodingConfig.prototype.getTypeString = function () {
                    return '[fm.icelink.EncodingConfig]';
                };
                EncodingConfig.prototype.fmicelinkEncodingConfigInit = function () {
                    this._bitrate = 0;
                    this._deactivated = false;
                    this._synchronizationSource = 0;
                };
                EncodingConfig.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "rtpStreamId"))) {
                                if ((fm.icelink.Global.equals(str, "synchronizationSource"))) {
                                    this.setSynchronizationSource(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "deactivated"))) {
                                        this.setDeactivated(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "bitrate"))) {
                                            this.setBitrate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                        }
                                    }
                                }
                            }
                            else {
                                this.setRtpStreamId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingConfig.prototype.getBitrate = function () {
                    if (arguments.length == 0) {
                        return this._bitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingConfig.prototype.getDeactivated = function () {
                    if (arguments.length == 0) {
                        return this._deactivated;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingConfig.prototype.getRtpStreamId = function () {
                    if (arguments.length == 0) {
                        return this._rtpStreamId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingConfig.prototype.getSynchronizationSource = function () {
                    if (arguments.length == 0) {
                        return this._synchronizationSource;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingConfig.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.getRtpStreamId(), null))) {
                            jsonObject["rtpStreamId"] = fm.icelink.JsonSerializer.serializeString(this.getRtpStreamId());
                        }
                        if ((!fm.icelink.Global.equals(this.getSynchronizationSource(), -1))) {
                            jsonObject["synchronizationSource"] = fm.icelink.JsonSerializer.serializeLong(this.getSynchronizationSource());
                        }
                        if (this.getDeactivated()) {
                            jsonObject["deactivated"] = fm.icelink.JsonSerializer.serializeBoolean(this.getDeactivated());
                        }
                        if ((!fm.icelink.Global.equals(this.getBitrate(), -1))) {
                            jsonObject["bitrate"] = fm.icelink.JsonSerializer.serializeInteger(this.getBitrate());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingConfig.prototype.setBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingConfig.prototype.setDeactivated = function (value) {
                    if (arguments.length == 1) {
                        this._deactivated = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingConfig.prototype.setRtpStreamId = function (value) {
                    if (arguments.length == 1) {
                        this._rtpStreamId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingConfig.prototype.setSynchronizationSource = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._synchronizationSource = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return EncodingConfig;
            }());
            icelink.EncodingConfig = EncodingConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AudioEncodingConfig =  (function (_super) {
                __extends(AudioEncodingConfig, _super);
                function AudioEncodingConfig() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else if (__arguments.length == 1) {
                        var encoding = __arguments[0];
                        _this = _super.call(this, encoding) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                AudioEncodingConfig.prototype.getTypeString = function () {
                    return '[fm.icelink.AudioEncodingConfig]' + ',' + _super.prototype.getTypeString.call(this);
                };
                AudioEncodingConfig.fromJson = function (encodingConfigJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(encodingConfigJson, function () {
                            return new fm.icelink.AudioEncodingConfig();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioEncodingConfig.fromJsonArray = function (encodingConfigsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(encodingConfigsJson, fm.icelink.AudioEncodingConfig.fromJson.bind(fm.icelink.AudioEncodingConfig));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioEncodingConfig.toJson = function (encodingConfig) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(encodingConfig, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioEncodingConfig.toJsonArray = function (encodingConfigs) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(encodingConfigs, fm.icelink.AudioEncodingConfig.toJson.bind(fm.icelink.AudioEncodingConfig));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioEncodingConfig.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.AudioEncodingConfig.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                AudioEncodingConfig.prototype.toString = function () {
                    if (arguments.length == 0) {
                        var flag = false;
                        var list = new Array();
                        var rtpStreamId = _super.prototype.getRtpStreamId.call(this);
                        if ((!fm.icelink.Global.equals(rtpStreamId, null))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("RTP Stream ID: {0}", rtpStreamId));
                        }
                        var synchronizationSource = _super.prototype.getSynchronizationSource.call(this);
                        if ((!fm.icelink.Global.equals(synchronizationSource, -1))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Synchronization Source: {0}", fm.icelink.NumberExtensions.toString(synchronizationSource)));
                        }
                        var deactivated = _super.prototype.getDeactivated.call(this);
                        if (deactivated) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Deactivated: {0}", fm.icelink.BooleanExtensions.toString(deactivated)));
                        }
                        var bitrate = _super.prototype.getBitrate.call(this);
                        if ((!fm.icelink.Global.equals(bitrate, -1))) {
                            flag = true;
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Bitrate: {0}", fm.icelink.NumberExtensions.toString(bitrate)));
                        }
                        var str2 = fm.icelink.StringExtensions.join(", ", fm.icelink.ArrayExtensions.toArray(list));
                        if (!flag) {
                            str2 = fm.icelink.StringExtensions.trim(fm.icelink.StringExtensions.format("{0} [Unrestricted]", str2));
                        }
                        return str2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return AudioEncodingConfig;
            }(fm.icelink.EncodingConfig));
            icelink.AudioEncodingConfig = AudioEncodingConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (dtmf) {
                var Tone =  (function () {
                    function Tone() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            this.fmicelinkdtmfToneInit();
                        }
                        else if (__arguments.length == 1) {
                            var value = __arguments[0];
                            __arguments = new Array(2);
                            __arguments[0] = value;
                            __arguments[1] = 100;
                            {
                                var value_48 = __arguments[0];
                                var duration = __arguments[1];
                                this.fmicelinkdtmfToneInit();
                                this.setValue(value_48);
                                this.setDuration(duration);
                            }
                        }
                        else if (__arguments.length == 2) {
                            var value = __arguments[0];
                            var duration = __arguments[1];
                            this.fmicelinkdtmfToneInit();
                            this.setValue(value);
                            this.setDuration(duration);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    Tone.prototype.getTypeString = function () {
                        return '[fm.icelink.dtmf.Tone]';
                    };
                    Tone.prototype.fmicelinkdtmfToneInit = function () {
                        this._duration = 0;
                        this._end = false;
                        this._sentDuration = 0;
                    };
                    Tone.eventCodeFromValue = function (eventString) {
                        if (arguments.length == 1) {
                            var _var0 = eventString;
                            do {
                                if (_var0 == "0") {
                                    return 0;
                                }
                                else if (_var0 == "1") {
                                    return 1;
                                }
                                else if (_var0 == "2") {
                                    return 2;
                                }
                                else if (_var0 == "3") {
                                    return 3;
                                }
                                else if (_var0 == "4") {
                                    return 4;
                                }
                                else if (_var0 == "5") {
                                    return 5;
                                }
                                else if (_var0 == "6") {
                                    return 6;
                                }
                                else if (_var0 == "7") {
                                    return 7;
                                }
                                else if (_var0 == "8") {
                                    return 8;
                                }
                                else if (_var0 == "9") {
                                    return 9;
                                }
                                else if (_var0 == "*") {
                                    return 10;
                                }
                                else if (_var0 == "#") {
                                    return 11;
                                }
                                else if (_var0 == "A") {
                                    return 12;
                                }
                                else if (_var0 == "B") {
                                    return 13;
                                }
                                else if (_var0 == "C") {
                                    return 14;
                                }
                                else if (_var0 == "D") {
                                    return 15;
                                }
                                else if (_var0 == ",") {
                                    return 99;
                                }
                            } while (false);
                            return -1;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.fromJson = function (toneJson) {
                        if (arguments.length == 1) {
                            return fm.icelink.JsonSerializer.deserializeObject(toneJson, function () {
                                return new fm.icelink.dtmf.Tone();
                            }, function (tone, key, valueJson) {
                                var str = key;
                                if ((!fm.icelink.Global.equals(str, null))) {
                                    if (!(fm.icelink.Global.equals(str, "value"))) {
                                        if ((fm.icelink.Global.equals(str, "duration"))) {
                                            tone.setDuration(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "end"))) {
                                                tone.setEnd(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                            }
                                        }
                                    }
                                    else {
                                        tone.setValue(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                }
                            });
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.fromJsonArray = function (tonesJson) {
                        if (arguments.length == 1) {
                            var list = fm.icelink.JsonSerializer.deserializeObjectArray(tonesJson, fm.icelink.dtmf.Tone.fromJson.bind(fm.icelink.dtmf.Tone));
                            if ((fm.icelink.Global.equals(list, null))) {
                                return null;
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.fromToneString = function () {
                        if (arguments.length == 1) {
                            var toneString = arguments[0];
                            return fm.icelink.dtmf.Tone.fromToneString(toneString, 100, 100);
                        }
                        else if (arguments.length == 2) {
                            var toneString = arguments[0];
                            var duration = fm.icelink.Global.toInt(arguments[1]);
                            return fm.icelink.dtmf.Tone.fromToneString(toneString, duration, 100);
                        }
                        else if (arguments.length == 3) {
                            var toneString = arguments[0];
                            var duration = fm.icelink.Global.toInt(arguments[1]);
                            var interToneGap = fm.icelink.Global.toInt(arguments[2]);
                            duration = fm.icelink.MathAssistant.max(40, fm.icelink.MathAssistant.min(2000, duration));
                            interToneGap = fm.icelink.MathAssistant.max(40, interToneGap);
                            var list = new Array();
                            for (var i = 0; (i < fm.icelink.StringExtensions.getLength(toneString)); i++) {
                                if ((i > 0)) {
                                    fm.icelink.ArrayExtensions.add(list, new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getEmptyValue(), interToneGap));
                                }
                                var str = fm.icelink.StringExtensions.substring(toneString, i, 1);
                                if ((fm.icelink.Global.equals(str, fm.icelink.dtmf.Tone.getPauseValue()))) {
                                    fm.icelink.ArrayExtensions.add(list, new fm.icelink.dtmf.Tone(str, 2000));
                                }
                                else {
                                    fm.icelink.ArrayExtensions.add(list, new fm.icelink.dtmf.Tone(str, duration));
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getA = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getAValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getAValue = function () {
                        if (arguments.length == 0) {
                            return "A";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getB = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getBValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getBValue = function () {
                        if (arguments.length == 0) {
                            return "B";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getC = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getCValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getCValue = function () {
                        if (arguments.length == 0) {
                            return "C";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getD = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getDValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getDValue = function () {
                        if (arguments.length == 0) {
                            return "D";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getEight = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getEightValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getEightValue = function () {
                        if (arguments.length == 0) {
                            return "8";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getEmpty = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getEmptyValue(), 0);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getEmptyValue = function () {
                        if (arguments.length == 0) {
                            return "";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getFive = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getFiveValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getFiveValue = function () {
                        if (arguments.length == 0) {
                            return "5";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getFour = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getFourValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getFourValue = function () {
                        if (arguments.length == 0) {
                            return "4";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getHash = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getHashValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getHashValue = function () {
                        if (arguments.length == 0) {
                            return "#";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getNine = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getNineValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getNineValue = function () {
                        if (arguments.length == 0) {
                            return "9";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getOne = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getOneValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getOneValue = function () {
                        if (arguments.length == 0) {
                            return "1";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getPause = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getPauseValue(), 2000);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getPauseDuration = function () {
                        if (arguments.length == 0) {
                            return 2000;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getPauseValue = function () {
                        if (arguments.length == 0) {
                            return ",";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getSeven = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getSevenValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getSevenValue = function () {
                        if (arguments.length == 0) {
                            return "7";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getSix = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getSixValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getSixValue = function () {
                        if (arguments.length == 0) {
                            return "6";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getStar = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getStarValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getStarValue = function () {
                        if (arguments.length == 0) {
                            return "*";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getThree = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getThreeValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getThreeValue = function () {
                        if (arguments.length == 0) {
                            return "3";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getTwo = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getTwoValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getTwoValue = function () {
                        if (arguments.length == 0) {
                            return "2";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getZero = function () {
                        if (arguments.length == 0) {
                            return new fm.icelink.dtmf.Tone(fm.icelink.dtmf.Tone.getZeroValue(), 100);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.getZeroValue = function () {
                        if (arguments.length == 0) {
                            return "0";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.toJson = function (tone) {
                        if (arguments.length == 1) {
                            return fm.icelink.JsonSerializer.serializeObject(tone, function (obj, jsonObj) {
                                jsonObj["value"] = fm.icelink.JsonSerializer.serializeString(obj.getValue());
                                jsonObj["duration"] = fm.icelink.JsonSerializer.serializeInteger(obj.getDuration());
                                jsonObj["end"] = fm.icelink.JsonSerializer.serializeBoolean(obj.getEnd());
                            });
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.toJsonArray = function (tones) {
                        if (arguments.length == 1) {
                            return fm.icelink.JsonSerializer.serializeObjectArray(tones, fm.icelink.dtmf.Tone.toJson.bind(fm.icelink.dtmf.Tone));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.toToneString = function (tones) {
                        if (arguments.length == 1) {
                            var builder = new fm.icelink.StringBuilder();
                            for (var _i = 0, tones_1 = tones; _i < tones_1.length; _i++) {
                                var tone = tones_1[_i];
                                builder.append(tone.getValue());
                            }
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.valueFromEventCode = function (eventCode) {
                        if (arguments.length == 1) {
                            eventCode = fm.icelink.Global.toInt(arguments[0]);
                            var _var0 = eventCode;
                            do {
                                if (_var0 == 0) {
                                    return "0";
                                }
                                else if (_var0 == 1) {
                                    return "1";
                                }
                                else if (_var0 == 2) {
                                    return "2";
                                }
                                else if (_var0 == 3) {
                                    return "3";
                                }
                                else if (_var0 == 4) {
                                    return "4";
                                }
                                else if (_var0 == 5) {
                                    return "5";
                                }
                                else if (_var0 == 6) {
                                    return "6";
                                }
                                else if (_var0 == 7) {
                                    return "7";
                                }
                                else if (_var0 == 8) {
                                    return "8";
                                }
                                else if (_var0 == 9) {
                                    return "9";
                                }
                                else if (_var0 == 10) {
                                    return "*";
                                }
                                else if (_var0 == 11) {
                                    return "#";
                                }
                                else if (_var0 == 12) {
                                    return "A";
                                }
                                else if (_var0 == 13) {
                                    return "B";
                                }
                                else if (_var0 == 14) {
                                    return "C";
                                }
                                else if (_var0 == 15) {
                                    return "D";
                                }
                                else if (_var0 == 99) {
                                    return ",";
                                }
                            } while (false);
                            return "";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.clone = function () {
                        if (arguments.length == 0) {
                            return this.clone(this.getDuration());
                        }
                        else if (arguments.length == 1) {
                            var duration = fm.icelink.Global.toInt(arguments[0]);
                            return new fm.icelink.dtmf.Tone(this.getValue(), duration);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.getDuration = function () {
                        if (arguments.length == 0) {
                            return this._duration;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.getEnd = function () {
                        if (arguments.length == 0) {
                            return this._end;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.getSentDuration = function () {
                        if (arguments.length == 0) {
                            return this._sentDuration;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.getValue = function () {
                        if (arguments.length == 0) {
                            return this._value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.setDuration = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._duration = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.setEnd = function (value) {
                        if (arguments.length == 1) {
                            this._end = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.setSentDuration = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._sentDuration = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.setValue = function (value) {
                        if (arguments.length == 1) {
                            this._value = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.toJson = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.dtmf.Tone.toJson(this);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Tone.prototype.toString = function () {
                        if (arguments.length == 0) {
                            if ((fm.icelink.Global.equals(this.getValue(), fm.icelink.dtmf.Tone.getEmptyValue()))) {
                                return fm.icelink.StringExtensions.format("[empty] ({0}ms)", fm.icelink.NumberExtensions.toString(this.getDuration()));
                            }
                            if ((fm.icelink.Global.equals(this.getValue(), fm.icelink.dtmf.Tone.getPauseValue()))) {
                                return fm.icelink.StringExtensions.format("[pause] ({0}ms)", fm.icelink.NumberExtensions.toString(this.getDuration()));
                            }
                            if (this.getEnd()) {
                                return fm.icelink.StringExtensions.format("{0} ({1}ms) [end]", this.getValue(), fm.icelink.NumberExtensions.toString(this.getDuration()));
                            }
                            return fm.icelink.StringExtensions.format("{0} ({1}ms)", this.getValue(), fm.icelink.NumberExtensions.toString(this.getDuration()));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Tone;
                }());
                dtmf.Tone = Tone;
            })(icelink.dtmf || (icelink.dtmf = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var Attribute =  (function () {
                    function Attribute() {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) ;
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    Attribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.Attribute]';
                    };
                    Attribute.createAttribute = function (name, value) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 2) {
                            for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__registeredAttributes); _i < _a.length; _i++) {
                                var str = _a[_i];
                                var registration = fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__registeredAttributes[str];
                                if ((fm.icelink.Global.equals(registration.getName(), name))) {
                                    return registration.getCreationDelegate()(new fm.icelink.sdp.AttributeCreationArgs(value));
                                }
                            }
                            return new fm.icelink.sdp.UnknownAttribute(name, value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPBundleOnlyAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.BundleOnlyAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPCandidateAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ice.CandidateAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPCategoryAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.CategoryAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPCharacterSetAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.CharacterSetAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPConferenceTypeAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ConferenceTypeAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPCryptoAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.CryptoAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPExtMapAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.rtp.ExtMapAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPFingerprintAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ice.FingerprintAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPFormatParametersAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.FormatParametersAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPFrameRateAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.FrameRateAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPGroupAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.GroupAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPIceLiteAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ice.LiteAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPIceMismatchAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ice.MismatchAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPIceOptionsAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ice.OptionsAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPIcePasswordAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ice.PasswordAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPIceUfragAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ice.UfragAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPInactiveAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.InactiveAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPKeywordsAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.KeywordsAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPLanguageAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.LanguageAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPMaxPacketTimeAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.MaxPacketTimeAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPMediaStreamIdAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.MediaStreamIdAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPMediaStreamIdSemanticAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.MediaStreamIdSemanticAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPMutedAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.MutedAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPOrientationAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.OrientationAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPPacketTimeAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.PacketTimeAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPQualityAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.QualityAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPReceiveOnlyAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ReceiveOnlyAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPRemoteCandidatesAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ice.RemoteCandidatesAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPRidAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.rtp.RidAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPRtcpAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.rtcp.Attribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPRtcpFeedbackAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.rtcp.FeedbackAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPRtcpMuxAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.rtcp.MuxAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPRtpMapAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.rtp.MapAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPSctpMapAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.sctp.MapAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPSctpMaxMessageSizeAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.sctp.MaxMessageSizeAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPSctpPortAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.sctp.PortAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPSdpLanguageAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.SdpLanguageAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPSendOnlyAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.SendOnlyAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPSendReceiveAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.SendReceiveAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPSetupAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.SetupAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPSimulcastAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.rtp.SimulcastAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPSSRCAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.rtp.SsrcAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPSSRCGroupAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.rtp.SsrcGroupAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.createSDPToolAttribute = function (e) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.sdp.ToolAttribute.fromAttributeValue(e.getValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.getTypeName = function (type) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            var registration = null;
                            var _var0 = new fm.icelink.Holder(registration);
                            var _var1 = fm.icelink.HashExtensions.tryGetValue(fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__registeredAttributes, type.getFullName(), _var0);
                            registration = _var0.getValue();
                            if (_var1) {
                                return registration.getName();
                            }
                            var baseType = type.getBaseType();
                            if ((!fm.icelink.Global.equals(baseType, null))) {
                                return fm.icelink.sdp.Attribute.getTypeName(baseType);
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.isMediaLevel = function (type) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            if ((fm.icelink.Global.equals(type.getFullName(), fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__unknownAttributeTypeName))) {
                                return true;
                            }
                            var registration = null;
                            var _var0 = new fm.icelink.Holder(registration);
                            var _var1 = fm.icelink.HashExtensions.tryGetValue(fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__registeredAttributes, type.getFullName(), _var0);
                            registration = _var0.getValue();
                            if (_var1) {
                                return registration.getMediaLevel();
                            }
                            return false;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.isSessionLevel = function (type) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            if ((fm.icelink.Global.equals(type.getFullName(), fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__unknownAttributeTypeName))) {
                                return true;
                            }
                            var registration = null;
                            var _var0 = new fm.icelink.Holder(registration);
                            var _var1 = fm.icelink.HashExtensions.tryGetValue(fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__registeredAttributes, type.getFullName(), _var0);
                            registration = _var0.getValue();
                            if (_var1) {
                                return registration.getSessionLevel();
                            }
                            return false;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.parse = function (s) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            var str = void 0;
                            var str2 = void 0;
                            s = s.substring(2);
                            var index = fm.icelink.StringExtensions.indexOf(s, ":");
                            if ((fm.icelink.Global.equals(index, -1))) {
                                str = s;
                                str2 = null;
                            }
                            else {
                                str = fm.icelink.StringExtensions.substring(s, 0, index);
                                str2 = s.substring((index + 1));
                            }
                            return fm.icelink.sdp.Attribute.createAttribute(str, str2);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.registerAttribute = function (type, name, sessionLevel, mediaLevel, creationDelegate) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 5) {
                            fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__registeredAttributes[type.getFullName()] = new fm.icelink.sdp.AttributeRegistration(name, sessionLevel, mediaLevel, creationDelegate);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.unregisterAttribute = function (type) {
                        fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
                        if (arguments.length == 1) {
                            return fm.icelink.HashExtensions.remove(fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__registeredAttributes, type.getFullName());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.prototype.getAttributeType = function () {
                        if (arguments.length == 0) {
                            return this._attributeType;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.prototype.getMultiplexingCategory = function () {
                        if (arguments.length == 0) {
                            return this._multiplexingCategory;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.prototype.setAttributeType = function (value) {
                        if (arguments.length == 1) {
                            this._attributeType = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.prototype.setMultiplexingCategory = function (value) {
                        if (arguments.length == 1) {
                            this._multiplexingCategory = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append("a=");
                            var type = new fm.icelink.Type(this.getTypeString());
                            if ((fm.icelink.Global.equals(type.getFullName(), fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__unknownAttributeTypeName))) {
                                builder.append(this.getName());
                            }
                            else {
                                builder.append(fm.icelink.sdp.Attribute.getTypeName(type));
                            }
                            var attributeValue = this.getAttributeValue();
                            if ((!fm.icelink.Global.equals(attributeValue, null))) {
                                builder.append(":");
                                builder.append(attributeValue);
                            }
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Attribute.fmicelinksdpAttributeInitialize = function () {
                        if (!fm.icelink.sdp.Attribute.__fmicelinksdpAttributeInitialized && !fm.icelink.sdp.Attribute.__fmicelinksdpAttributeInitializing) {
                            fm.icelink.sdp.Attribute.__fmicelinksdpAttributeInitializing = true;
                            fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__registeredAttributes = {};
                            fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__registeredAttributesLock = new Object();
                            fm.icelink.sdp.Attribute.fm_icelink_sdp_Attribute__unknownAttributeTypeName = new fm.icelink.Type('[fm.icelink.sdp.UnknownAttribute]').getFullName();
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.GroupAttribute]'), "group", true, false, fm.icelink.sdp.Attribute.createSDPGroupAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.CategoryAttribute]'), "cat", true, false, fm.icelink.sdp.Attribute.createSDPCategoryAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.CharacterSetAttribute]'), "charset", true, false, fm.icelink.sdp.Attribute.createSDPCharacterSetAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ConferenceTypeAttribute]'), "type", true, false, fm.icelink.sdp.Attribute.createSDPConferenceTypeAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.CryptoAttribute]'), "crypto", true, true, fm.icelink.sdp.Attribute.createSDPCryptoAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.FormatParametersAttribute]'), "fmtp", false, true, fm.icelink.sdp.Attribute.createSDPFormatParametersAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.FrameRateAttribute]'), "framerate", false, true, fm.icelink.sdp.Attribute.createSDPFrameRateAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.InactiveAttribute]'), "inactive", true, true, fm.icelink.sdp.Attribute.createSDPInactiveAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.KeywordsAttribute]'), "keywds", true, false, fm.icelink.sdp.Attribute.createSDPKeywordsAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.LanguageAttribute]'), "lang", true, true, fm.icelink.sdp.Attribute.createSDPLanguageAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.MaxPacketTimeAttribute]'), "maxptime", false, true, fm.icelink.sdp.Attribute.createSDPMaxPacketTimeAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.OrientationAttribute]'), "orient", false, true, fm.icelink.sdp.Attribute.createSDPOrientationAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.PacketTimeAttribute]'), "ptime", false, true, fm.icelink.sdp.Attribute.createSDPPacketTimeAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.QualityAttribute]'), "quality", false, true, fm.icelink.sdp.Attribute.createSDPQualityAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ReceiveOnlyAttribute]'), "recvonly", true, true, fm.icelink.sdp.Attribute.createSDPReceiveOnlyAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.SdpLanguageAttribute]'), "sdplang", true, true, fm.icelink.sdp.Attribute.createSDPSdpLanguageAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.SendOnlyAttribute]'), "sendonly", true, true, fm.icelink.sdp.Attribute.createSDPSendOnlyAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.SendReceiveAttribute]'), "sendrecv", true, true, fm.icelink.sdp.Attribute.createSDPSendReceiveAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.SetupAttribute]'), "setup", true, true, fm.icelink.sdp.Attribute.createSDPSetupAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ToolAttribute]'), "tool", true, false, fm.icelink.sdp.Attribute.createSDPToolAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.MediaStreamIdSemanticAttribute]'), "msid-semantic", true, true, fm.icelink.sdp.Attribute.createSDPMediaStreamIdSemanticAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.MediaStreamIdAttribute]'), "mid", true, true, fm.icelink.sdp.Attribute.createSDPMediaStreamIdAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.BundleOnlyAttribute]'), "bundle-only", false, true, fm.icelink.sdp.Attribute.createSDPBundleOnlyAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.MutedAttribute]'), "muted", false, true, fm.icelink.sdp.Attribute.createSDPMutedAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ice.CandidateAttribute]'), "candidate", false, true, fm.icelink.sdp.Attribute.createSDPCandidateAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ice.FingerprintAttribute]'), "fingerprint", true, true, fm.icelink.sdp.Attribute.createSDPFingerprintAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ice.LiteAttribute]'), "ice-lite", true, false, fm.icelink.sdp.Attribute.createSDPIceLiteAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ice.MismatchAttribute]'), "ice-mismatch", true, false, fm.icelink.sdp.Attribute.createSDPIceMismatchAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ice.OptionsAttribute]'), "ice-options", true, true, fm.icelink.sdp.Attribute.createSDPIceOptionsAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ice.PasswordAttribute]'), "ice-pwd", true, true, fm.icelink.sdp.Attribute.createSDPIcePasswordAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ice.UfragAttribute]'), "ice-ufrag", true, true, fm.icelink.sdp.Attribute.createSDPIceUfragAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.ice.RemoteCandidatesAttribute]'), "remote-candidates", false, true, fm.icelink.sdp.Attribute.createSDPRemoteCandidatesAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.rtp.MapAttribute]'), "rtpmap", false, true, fm.icelink.sdp.Attribute.createSDPRtpMapAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.rtp.SsrcAttribute]'), "ssrc", false, true, fm.icelink.sdp.Attribute.createSDPSSRCAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.rtp.SsrcGroupAttribute]'), "ssrc-group", false, true, fm.icelink.sdp.Attribute.createSDPSSRCGroupAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.rtp.ExtMapAttribute]'), "extmap", true, true, fm.icelink.sdp.Attribute.createSDPExtMapAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.rtp.RidAttribute]'), "rid", false, true, fm.icelink.sdp.Attribute.createSDPRidAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.rtp.SimulcastAttribute]'), "simulcast", false, true, fm.icelink.sdp.Attribute.createSDPSimulcastAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.rtcp.Attribute]'), "rtcp", false, true, fm.icelink.sdp.Attribute.createSDPRtcpAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.rtcp.FeedbackAttribute]'), "rtcp-fb", false, true, fm.icelink.sdp.Attribute.createSDPRtcpFeedbackAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.rtcp.MuxAttribute]'), "rtcp-mux", false, true, fm.icelink.sdp.Attribute.createSDPRtcpMuxAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.sctp.PortAttribute]'), "sctp-port", false, true, fm.icelink.sdp.Attribute.createSDPSctpPortAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.sctp.MapAttribute]'), "sctpmap", false, true, fm.icelink.sdp.Attribute.createSDPSctpMapAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.registerAttribute(new fm.icelink.Type('[fm.icelink.sdp.sctp.MaxMessageSizeAttribute]'), "max-message-size", false, true, fm.icelink.sdp.Attribute.createSDPSctpMaxMessageSizeAttribute.bind(fm.icelink.sdp.Attribute));
                            fm.icelink.sdp.Attribute.__fmicelinksdpAttributeInitialized = true;
                            fm.icelink.sdp.Attribute.__fmicelinksdpAttributeInitializing = false;
                        }
                    };
                    Attribute.__fmicelinksdpAttributeInitialized = false;
                    Attribute.__fmicelinksdpAttributeInitializing = false;
                    return Attribute;
                }());
                sdp.Attribute = Attribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var MutedAttribute =  (function (_super) {
                    __extends(MutedAttribute, _super);
                    function MutedAttribute(value) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var value_49 = __arguments[0];
                            _this = _super.call(this) || this;
                            _this.fmicelinksdpMutedAttributeInit();
                            _this.__value = value_49;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.MutedAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    MutedAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.MutedAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    MutedAttribute.prototype.fmicelinksdpMutedAttributeInit = function () {
                        this.__value = false;
                    };
                    MutedAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.MutedAttribute((fm.icelink.Global.equals(value, "true")));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MutedAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.valueToString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MutedAttribute.prototype.valueToString = function () {
                        if (arguments.length == 0) {
                            if (this.__value) {
                                return "true";
                            }
                            return "false";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return MutedAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.MutedAttribute = MutedAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StreamDescription =  (function () {
                function StreamDescription(description) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var description_1 = __arguments[0];
                        this.setMediaDescription(description_1);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                StreamDescription.prototype.getTypeString = function () {
                    return '[fm.icelink.StreamDescription]';
                };
                StreamDescription.prototype.getMediaDescription = function () {
                    if (arguments.length == 0) {
                        return this._mediaDescription;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamDescription.prototype.getMediaDescriptionIdentifier = function () {
                    if (arguments.length == 0) {
                        var mediaDescription = this.getMediaDescription();
                        if ((!fm.icelink.Global.equals(mediaDescription, null))) {
                            var mediaStreamIdentifierAttribute = mediaDescription.getMediaStreamIdentifierAttribute();
                            if ((!fm.icelink.Global.equals(mediaStreamIdentifierAttribute, null))) {
                                return mediaStreamIdentifierAttribute.getIdentificationTag();
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamDescription.prototype.getStreamType = function () {
                    if (arguments.length == 0) {
                        var mediaDescription = this.getMediaDescription();
                        if ((!fm.icelink.Global.equals(mediaDescription, null))) {
                            if (mediaDescription.getIsApplication()) {
                                return fm.icelink.StreamType.Application;
                            }
                            if (mediaDescription.getIsAudio()) {
                                return fm.icelink.StreamType.Audio;
                            }
                            if (mediaDescription.getIsVideo()) {
                                return fm.icelink.StreamType.Video;
                            }
                            if (mediaDescription.getIsMessage()) {
                                return fm.icelink.StreamType.Message;
                            }
                            if (mediaDescription.getIsText()) {
                                return fm.icelink.StreamType.Text;
                            }
                        }
                        throw new fm.icelink.Exception("Could not identify the stream type from the media description.");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamDescription.prototype.setMediaDescription = function (value) {
                    if (arguments.length == 1) {
                        this._mediaDescription = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StreamDescription;
            }());
            icelink.StreamDescription = StreamDescription;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var VideoEncodingConfig =  (function (_super) {
                __extends(VideoEncodingConfig, _super);
                function VideoEncodingConfig() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkVideoEncodingConfigInit();
                        _this.setFrameRate(-1);
                        _this.setScale(-1);
                    }
                    else if (__arguments.length == 1) {
                        var encoding = __arguments[0];
                        _this = _super.call(this, encoding) || this;
                        _this.fmicelinkVideoEncodingConfigInit();
                        _this.setFrameRate(encoding.getFrameRate());
                        _this.setScale(encoding.getScale());
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                VideoEncodingConfig.prototype.getTypeString = function () {
                    return '[fm.icelink.VideoEncodingConfig]' + ',' + _super.prototype.getTypeString.call(this);
                };
                VideoEncodingConfig.prototype.fmicelinkVideoEncodingConfigInit = function () {
                    this._frameRate = 0;
                    this._scale = 0;
                };
                VideoEncodingConfig.fromJson = function (encodingConfigJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(encodingConfigJson, function () {
                            return new fm.icelink.VideoEncodingConfig();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.fromJsonArray = function (encodingConfigsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(encodingConfigsJson, fm.icelink.VideoEncodingConfig.fromJson.bind(fm.icelink.VideoEncodingConfig));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.toJson = function (encodingConfig) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(encodingConfig, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.toJsonArray = function (encodingConfigs) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(encodingConfigs, fm.icelink.VideoEncodingConfig.toJson.bind(fm.icelink.VideoEncodingConfig));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "frameRate"))) {
                                if ((fm.icelink.Global.equals(str, "scale"))) {
                                    this.setScale(fm.icelink.JsonSerializer.deserializeDouble(valueJson));
                                }
                            }
                            else {
                                this.setFrameRate(fm.icelink.JsonSerializer.deserializeDouble(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.prototype.getFrameRate = function () {
                    if (arguments.length == 0) {
                        return this._frameRate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.prototype.getScale = function () {
                    if (arguments.length == 0) {
                        return this._scale;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getFrameRate(), -1))) {
                            jsonObject["frameRate"] = fm.icelink.JsonSerializer.serializeDouble(this.getFrameRate());
                        }
                        if ((!fm.icelink.Global.equals(this.getScale(), -1))) {
                            jsonObject["scale"] = fm.icelink.JsonSerializer.serializeDouble(this.getScale());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.prototype.setFrameRate = function (value) {
                    if (arguments.length == 1) {
                        this._frameRate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.prototype.setScale = function (value) {
                    if (arguments.length == 1) {
                        this._scale = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.VideoEncodingConfig.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoEncodingConfig.prototype.toString = function () {
                    if (arguments.length == 0) {
                        var flag = false;
                        var list = new Array();
                        var rtpStreamId = _super.prototype.getRtpStreamId.call(this);
                        if ((!fm.icelink.Global.equals(rtpStreamId, null))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("RTP Stream ID: {0}", rtpStreamId));
                        }
                        var synchronizationSource = _super.prototype.getSynchronizationSource.call(this);
                        if ((!fm.icelink.Global.equals(synchronizationSource, -1))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Synchronization Source: {0}", fm.icelink.NumberExtensions.toString(synchronizationSource)));
                        }
                        var deactivated = _super.prototype.getDeactivated.call(this);
                        if (deactivated) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Deactivated: {0}", fm.icelink.BooleanExtensions.toString(deactivated)));
                        }
                        var bitrate = _super.prototype.getBitrate.call(this);
                        if ((!fm.icelink.Global.equals(bitrate, -1))) {
                            flag = true;
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Bitrate: {0}", fm.icelink.NumberExtensions.toString(bitrate)));
                        }
                        var frameRate = this.getFrameRate();
                        if ((!fm.icelink.Global.equals(frameRate, -1))) {
                            flag = true;
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Frame Rate: {0}", fm.icelink.NumberExtensions.toString(frameRate)));
                        }
                        var scale = this.getScale();
                        if ((!fm.icelink.Global.equals(scale, -1))) {
                            flag = true;
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Scale: {0}", fm.icelink.NumberExtensions.toString(scale)));
                        }
                        var str2 = fm.icelink.StringExtensions.join(", ", fm.icelink.ArrayExtensions.toArray(list));
                        if (!flag) {
                            str2 = fm.icelink.StringExtensions.trim(fm.icelink.StringExtensions.format("{0} [Unrestricted]", str2));
                        }
                        return str2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return VideoEncodingConfig;
            }(fm.icelink.EncodingConfig));
            icelink.VideoEncodingConfig = VideoEncodingConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var EncryptionModeWrapper =  (function () {
                function EncryptionModeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_50 = __arguments[0];
                        this._value = value_50;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                EncryptionModeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.EncryptionModeWrapper]';
                };
                EncryptionModeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.EncryptionMode.Null)
                            return 'Null';
                        if (this._value == fm.icelink.EncryptionMode.Aes128Strong)
                            return 'Aes128Strong';
                        if (this._value == fm.icelink.EncryptionMode.Aes128Weak)
                            return 'Aes128Weak';
                        if (this._value == fm.icelink.EncryptionMode.NullStrong)
                            return 'NullStrong';
                        if (this._value == fm.icelink.EncryptionMode.NullWeak)
                            return 'NullWeak';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return EncryptionModeWrapper;
            }());
            icelink.EncryptionModeWrapper = EncryptionModeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var FormatInfo =  (function () {
                function FormatInfo() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkFormatInfoInit();
                    }
                    else if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.AudioFormat]'))) {
                        var audioFormat = __arguments[0];
                        __arguments = new Array(3);
                        __arguments[0] = audioFormat.getName();
                        __arguments[1] = audioFormat.getClockRate();
                        __arguments[2] = audioFormat.getChannelCount();
                        {
                            var name_20 = __arguments[0];
                            var clockRate = __arguments[1];
                            var channelCount = __arguments[2];
                            this.fmicelinkFormatInfoInit();
                            this.setName(name_20);
                            this.setClockRate(clockRate);
                            this.setChannelCount(channelCount);
                        }
                    }
                    else if (__arguments.length == 2) {
                        var codecName = __arguments[0];
                        var clockRate = __arguments[1];
                        __arguments = new Array(3);
                        __arguments[0] = codecName;
                        __arguments[1] = clockRate;
                        __arguments[2] = 0;
                        {
                            var name_21 = __arguments[0];
                            var clockRate_4 = __arguments[1];
                            var channelCount = __arguments[2];
                            this.fmicelinkFormatInfoInit();
                            this.setName(name_21);
                            this.setClockRate(clockRate_4);
                            this.setChannelCount(channelCount);
                        }
                    }
                    else if (__arguments.length == 3) {
                        var name_22 = __arguments[0];
                        var clockRate = __arguments[1];
                        var channelCount = __arguments[2];
                        this.fmicelinkFormatInfoInit();
                        this.setName(name_22);
                        this.setClockRate(clockRate);
                        this.setChannelCount(channelCount);
                    }
                    else if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.VideoFormat]'))) {
                        var videoFormat = __arguments[0];
                        __arguments = new Array(2);
                        __arguments[0] = videoFormat.getName();
                        __arguments[1] = videoFormat.getClockRate();
                        {
                            var codecName = __arguments[0];
                            var clockRate = __arguments[1];
                            __arguments = new Array(3);
                            __arguments[0] = codecName;
                            __arguments[1] = clockRate;
                            __arguments[2] = 0;
                            {
                                var name_23 = __arguments[0];
                                var clockRate_5 = __arguments[1];
                                var channelCount = __arguments[2];
                                this.fmicelinkFormatInfoInit();
                                this.setName(name_23);
                                this.setClockRate(clockRate_5);
                                this.setChannelCount(channelCount);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                FormatInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.FormatInfo]';
                };
                FormatInfo.prototype.fmicelinkFormatInfoInit = function () {
                    this._channelCount = 0;
                    this._clockRate = 0;
                };
                FormatInfo.fromJson = function (formatInfoJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(formatInfoJson, function () {
                            return new fm.icelink.FormatInfo();
                        }, function (info, key, value) {
                            var str = key;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "name"))) {
                                    if ((fm.icelink.Global.equals(str, "clockRate"))) {
                                        info.setClockRate(fm.icelink.JsonSerializer.deserializeInteger(value));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "channelCount"))) {
                                            info.setChannelCount(fm.icelink.JsonSerializer.deserializeInteger(value));
                                        }
                                    }
                                }
                                else {
                                    info.setName(fm.icelink.JsonSerializer.deserializeString(value));
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.fromJsonArray = function (formatInfosJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(formatInfosJson, fm.icelink.FormatInfo.fromJson.bind(fm.icelink.FormatInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.fromSdpMediaDescription = function (sdpMediaDescription) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(sdpMediaDescription, null))) {
                            return null;
                        }
                        var list = new Array();
                        for (var _i = 0, _a = sdpMediaDescription.getRtpMapAttributes(); _i < _a.length; _i++) {
                            var attribute = _a[_i];
                            var intResult = 1;
                            if (!fm.icelink.StringExtensions.isNullOrEmpty(attribute.getFormatParameters())) {
                                var _var0 = new fm.icelink.Holder(intResult);
                                fm.icelink.ParseAssistant.tryParseIntegerValue(attribute.getFormatParameters(), _var0);
                                intResult = _var0.getValue();
                            }
                            fm.icelink.ArrayExtensions.add(list, new fm.icelink.FormatInfo(attribute.getFormatName(), attribute.getClockRate(), intResult));
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.toJson = function (formatInfo) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(formatInfo, function (info, dict) {
                            dict["name"] = fm.icelink.JsonSerializer.serializeString(info.getName());
                            dict["clockRate"] = fm.icelink.JsonSerializer.serializeInteger(info.getClockRate());
                            if ((info.getChannelCount() > 0)) {
                                dict["channelCount"] = fm.icelink.JsonSerializer.serializeInteger(info.getChannelCount());
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.toJsonArray = function (formatInfos) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(formatInfos, fm.icelink.FormatInfo.toJson.bind(fm.icelink.FormatInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.getChannelCount = function () {
                    if (arguments.length == 0) {
                        return this._channelCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.getClockRate = function () {
                    if (arguments.length == 0) {
                        return this._clockRate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.getCodecName = function () {
                    if (arguments.length == 0) {
                        return this.getName();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.getName = function () {
                    if (arguments.length == 0) {
                        return this._name;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.isEquivalent = function () {
                    if (arguments.length == 1) {
                        var instance = arguments[0];
                        return ((!fm.icelink.Global.equals(instance, null)) && this.isEquivalent(instance.getName(), instance.getClockRate(), instance.getChannelCount()));
                    }
                    else if (arguments.length == 3) {
                        var name_24 = arguments[0];
                        var clockRate = fm.icelink.Global.toInt(arguments[1]);
                        var channelCount = fm.icelink.Global.toInt(arguments[2]);
                        return (((fm.icelink.Global.equals(name_24, this.getName())) && (fm.icelink.Global.equals(clockRate, this.getClockRate()))) && (fm.icelink.Global.equals(channelCount, this.getChannelCount())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.setChannelCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._channelCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.setClockRate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._clockRate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.setCodecName = function (value) {
                    if (arguments.length == 1) {
                        this.setName(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.setName = function (value) {
                    if (arguments.length == 1) {
                        this._name = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.FormatInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                FormatInfo.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if ((this.getChannelCount() > 1)) {
                            return fm.icelink.StringExtensions.format("{0}/{1}/{2}", this.getName(), fm.icelink.NumberExtensions.toString(this.getClockRate()), fm.icelink.NumberExtensions.toString(this.getChannelCount()));
                        }
                        return fm.icelink.StringExtensions.format("{0}/{1}", this.getName(), fm.icelink.NumberExtensions.toString(this.getClockRate()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return FormatInfo;
            }());
            icelink.FormatInfo = FormatInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LayoutFrame =  (function () {
                function LayoutFrame() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkLayoutFrameInit();
                    }
                    else if (__arguments.length == 4) {
                        var x = __arguments[0];
                        var y = __arguments[1];
                        var width = __arguments[2];
                        var height = __arguments[3];
                        this.fmicelinkLayoutFrameInit();
                        this.setX(x);
                        this.setY(y);
                        this.setWidth(width);
                        this.setHeight(height);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LayoutFrame.prototype.getTypeString = function () {
                    return '[fm.icelink.LayoutFrame]';
                };
                LayoutFrame.prototype.fmicelinkLayoutFrameInit = function () {
                    this._height = 0;
                    this._orientation = 0;
                    this._width = 0;
                    this._x = 0;
                    this._y = 0;
                };
                LayoutFrame.fromJson = function (layoutFrameJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(layoutFrameJson, function () {
                            return new fm.icelink.LayoutFrame();
                        }, function (rectangle, key, valueJson) {
                            var _var0 = key;
                            do {
                                if (_var0 == "x") {
                                    rectangle.setX(fm.icelink.ParseAssistant.parseIntegerValue(valueJson));
                                    break;
                                }
                                else if (_var0 == "y") {
                                    rectangle.setY(fm.icelink.ParseAssistant.parseIntegerValue(valueJson));
                                    break;
                                }
                                else if (_var0 == "w" || _var0 == "width") {
                                    rectangle.setWidth(fm.icelink.ParseAssistant.parseIntegerValue(valueJson));
                                    break;
                                }
                                else if (_var0 == "h" || _var0 == "height") {
                                    rectangle.setHeight(fm.icelink.ParseAssistant.parseIntegerValue(valueJson));
                                    break;
                                }
                                else if (_var0 == "orientation") {
                                    rectangle.setOrientation(fm.icelink.ParseAssistant.parseIntegerValue(valueJson));
                                    break;
                                }
                            } while (false);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.getScaledFrame = function (scale, outerWidth, outerHeight, innerWidth, innerHeight) {
                    if (arguments.length == 5) {
                        outerWidth = fm.icelink.Global.toInt(arguments[1]);
                        outerHeight = fm.icelink.Global.toInt(arguments[2]);
                        innerWidth = fm.icelink.Global.toInt(arguments[3]);
                        innerHeight = fm.icelink.Global.toInt(arguments[4]);
                        var x = 0;
                        var y = 0;
                        var width = outerWidth;
                        var height = outerHeight;
                        if (((((fm.icelink.Global.equals(outerWidth, 0)) || (fm.icelink.Global.equals(outerHeight, 0))) || (fm.icelink.Global.equals(innerWidth, 0))) || (fm.icelink.Global.equals(innerHeight, 0)))) {
                            if (((fm.icelink.Global.equals(outerWidth, 0)) || (fm.icelink.Global.equals(innerWidth, 0)))) {
                                width = 0;
                                x = fm.icelink.MathAssistant.floor(outerWidth / 2);
                            }
                            if (((fm.icelink.Global.equals(outerHeight, 0)) || (fm.icelink.Global.equals(innerHeight, 0)))) {
                                height = 0;
                                y = fm.icelink.MathAssistant.floor(outerHeight / 2);
                            }
                        }
                        else {
                            var num5 = void 0;
                            var num6 = void 0;
                            if ((fm.icelink.Global.equals(scale, fm.icelink.LayoutScale.Contain))) {
                                num5 = (outerWidth / outerHeight);
                                num6 = (innerWidth / innerHeight);
                                if ((num5 > num6)) {
                                    width = (outerHeight * num6);
                                    x = fm.icelink.MathAssistant.floor((outerWidth - width) / 2);
                                }
                                else {
                                    if ((num5 < num6)) {
                                        height = (outerWidth / num6);
                                        y = fm.icelink.MathAssistant.floor((outerHeight - height) / 2);
                                    }
                                }
                            }
                            else {
                                if ((fm.icelink.Global.equals(scale, fm.icelink.LayoutScale.Cover))) {
                                    num5 = (outerWidth / outerHeight);
                                    num6 = (innerWidth / innerHeight);
                                    if ((num5 < num6)) {
                                        width = (outerHeight * num6);
                                        x = fm.icelink.MathAssistant.floor((outerWidth - width) / 2);
                                    }
                                    else {
                                        if ((num5 > num6)) {
                                            height = (outerWidth / num6);
                                            y = fm.icelink.MathAssistant.floor((outerHeight - height) / 2);
                                        }
                                    }
                                }
                            }
                        }
                        return new fm.icelink.LayoutFrame(x, y, width, height);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.toJson = function (layoutFrame) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(layoutFrame, function (r, jsonObject) {
                            jsonObject["x"] = fm.icelink.NumberExtensions.toString(r.getX());
                            jsonObject["y"] = fm.icelink.NumberExtensions.toString(r.getY());
                            jsonObject["width"] = fm.icelink.NumberExtensions.toString(r.getWidth());
                            jsonObject["height"] = fm.icelink.NumberExtensions.toString(r.getHeight());
                            jsonObject["orientation"] = fm.icelink.NumberExtensions.toString(r.getOrientation());
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.getHeight = function () {
                    if (arguments.length == 0) {
                        return this._height;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.getOrientation = function () {
                    if (arguments.length == 0) {
                        return this._orientation;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.getViewId = function () {
                    if (arguments.length == 0) {
                        return this._viewId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.getWidth = function () {
                    if (arguments.length == 0) {
                        return this._width;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.getX = function () {
                    if (arguments.length == 0) {
                        return this._x;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.getY = function () {
                    if (arguments.length == 0) {
                        return this._y;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.isEquivalent = function (layoutFrame) {
                    if (arguments.length == 1) {
                        return ((((fm.icelink.Global.equals(layoutFrame.getX(), this.getX())) && (fm.icelink.Global.equals(layoutFrame.getY(), this.getY()))) && (fm.icelink.Global.equals(layoutFrame.getWidth(), this.getWidth()))) && (fm.icelink.Global.equals(layoutFrame.getHeight(), this.getHeight())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.setHeight = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._height = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.setOrientation = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._orientation = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.setViewId = function (value) {
                    if (arguments.length == 1) {
                        this._viewId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.setWidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._width = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.setX = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._x = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.setY = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._y = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                LayoutFrame.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.LayoutFrame.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LayoutFrame;
            }());
            icelink.LayoutFrame = LayoutFrame;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LayoutScaleWrapper =  (function () {
                function LayoutScaleWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_51 = __arguments[0];
                        this._value = value_51;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                LayoutScaleWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.LayoutScaleWrapper]';
                };
                LayoutScaleWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.LayoutScale.Contain)
                            return 'Contain';
                        if (this._value == fm.icelink.LayoutScale.Cover)
                            return 'Cover';
                        if (this._value == fm.icelink.LayoutScale.Stretch)
                            return 'Stretch';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return LayoutScaleWrapper;
            }());
            icelink.LayoutScaleWrapper = LayoutScaleWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaComponentInfo =  (function (_super) {
                __extends(MediaComponentInfo, _super);
                function MediaComponentInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaComponentInfoInit();
                    }
                    else if (__arguments.length == 2) {
                        var stats = __arguments[0];
                        var lastStats = __arguments[1];
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaComponentInfoInit();
                        _super.prototype.setId.call(_this, stats.getId());
                        var stats2 = ((fm.icelink.Global.equals(lastStats, null)) ? stats.getTrack() : fm.icelink.Info.processObject(stats.getTrack(), lastStats.getTrack()));
                        if ((!fm.icelink.Global.equals(stats2, null))) {
                            var stats3 = ((fm.icelink.Global.equals(lastStats, null)) ? null : lastStats.getTrack());
                            _this.setSynchronizationSource(((fm.icelink.Global.equals(stats3, null)) ? stats2.getSynchronizationSource() : fm.icelink.Info.processLong(stats2.getSynchronizationSource(), stats3.getSynchronizationSource())));
                            _this.setTrack(new fm.icelink.MediaTrackInfo(stats2, stats3));
                        }
                        var stats4 = ((fm.icelink.Global.equals(lastStats, null)) ? stats.getCodec() : fm.icelink.Info.processObject(stats.getCodec(), lastStats.getCodec()));
                        if ((!fm.icelink.Global.equals(stats4, null))) {
                            var stats5 = ((fm.icelink.Global.equals(lastStats, null)) ? null : lastStats.getCodec());
                            var info = new fm.icelink.CodecInfo();
                            info.setId(stats4.getId());
                            info.setChannelCount(((fm.icelink.Global.equals(stats5, null)) ? stats4.getChannelCount() : fm.icelink.Info.processInteger(stats4.getChannelCount(), stats5.getChannelCount())));
                            info.setClockRate(((fm.icelink.Global.equals(stats5, null)) ? stats4.getClockRate() : fm.icelink.Info.processInteger(stats4.getClockRate(), stats5.getClockRate())));
                            info.setName(((fm.icelink.Global.equals(stats5, null)) ? stats4.getName() : fm.icelink.Info.processString(stats4.getName(), stats5.getName())));
                            info.setParameters(((fm.icelink.Global.equals(stats5, null)) ? stats4.getParameters() : fm.icelink.Info.processString(stats4.getParameters(), stats5.getParameters())));
                            info.setPayloadType(((fm.icelink.Global.equals(stats5, null)) ? stats4.getPayloadType() : fm.icelink.Info.processInteger(stats4.getPayloadType(), stats5.getPayloadType())));
                            _this.setCodec(info);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaComponentInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaComponentInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaComponentInfo.prototype.fmicelinkMediaComponentInfoInit = function () {
                    this._synchronizationSource = 0;
                };
                MediaComponentInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "track"))) {
                                if ((fm.icelink.Global.equals(str, "codec"))) {
                                    this.setCodec(fm.icelink.CodecInfo.fromJson(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "synchronizationSource"))) {
                                        this.setSynchronizationSource(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                    }
                                }
                            }
                            else {
                                this.setTrack(fm.icelink.MediaTrackInfo.fromJson(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentInfo.prototype.getCodec = function () {
                    if (arguments.length == 0) {
                        return this._codec;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentInfo.prototype.getSynchronizationSource = function () {
                    if (arguments.length == 0) {
                        return this._synchronizationSource;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentInfo.prototype.getTrack = function () {
                    if (arguments.length == 0) {
                        return this._track;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getTrack(), null))) {
                            jsonObject["track"] = fm.icelink.MediaTrackInfo.toJson(this.getTrack());
                        }
                        if ((!fm.icelink.Global.equals(this.getCodec(), null))) {
                            jsonObject["codec"] = fm.icelink.CodecInfo.toJson(this.getCodec());
                        }
                        if ((this.getSynchronizationSource() != null)) {
                            jsonObject["synchronizationSource"] = fm.icelink.JsonSerializer.serializeLong(this.getSynchronizationSource());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentInfo.prototype.setCodec = function (value) {
                    if (arguments.length == 1) {
                        this._codec = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentInfo.prototype.setSynchronizationSource = function (value) {
                    if (arguments.length == 1) {
                        this._synchronizationSource = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentInfo.prototype.setTrack = function (value) {
                    if (arguments.length == 1) {
                        this._track = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaComponentInfo;
            }(fm.icelink.Info));
            icelink.MediaComponentInfo = MediaComponentInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaComponentStats =  (function (_super) {
                __extends(MediaComponentStats, _super);
                function MediaComponentStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaComponentStatsInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaComponentStats.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaComponentStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaComponentStats.prototype.fmicelinkMediaComponentStatsInit = function () {
                    this._firCount = 0;
                    this._lrrCount = 0;
                    this._nackCount = 0;
                    this._pliCount = 0;
                    this._sliCount = 0;
                    this._synchronizationSource = 0;
                };
                MediaComponentStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var _var0 = key;
                        do {
                            if (_var0 == "ssrc") {
                                this.setSynchronizationSource(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "rid") {
                                this.setRtpStreamId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "rrid") {
                                this.setRepairedRtpStreamId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "track") {
                                this.setTrack(fm.icelink.MediaTrackStats.fromJson(valueJson));
                                break;
                            }
                            else if (_var0 == "codec") {
                                this.setCodec(fm.icelink.CodecStats.fromJson(valueJson));
                                break;
                            }
                            else if (_var0 == "nackCount") {
                                this.setNackCount(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "pliCount") {
                                this.setPliCount(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "firCount") {
                                this.setFirCount(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "lrrCount") {
                                this.setLrrCount(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "sliCount") {
                                this.setSliCount(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.getCodec = function () {
                    if (arguments.length == 0) {
                        return this._codec;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.getFirCount = function () {
                    if (arguments.length == 0) {
                        return this._firCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.getLrrCount = function () {
                    if (arguments.length == 0) {
                        return this._lrrCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.getNackCount = function () {
                    if (arguments.length == 0) {
                        return this._nackCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.getPliCount = function () {
                    if (arguments.length == 0) {
                        return this._pliCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.getRepairedRtpStreamId = function () {
                    if (arguments.length == 0) {
                        return this._repairedRtpStreamId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.getRtpStreamId = function () {
                    if (arguments.length == 0) {
                        return this._rtpStreamId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.getSliCount = function () {
                    if (arguments.length == 0) {
                        return this._sliCount;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.getSynchronizationSource = function () {
                    if (arguments.length == 0) {
                        return this._synchronizationSource;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.getTrack = function () {
                    if (arguments.length == 0) {
                        return this._track;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        jsonObject["ssrc"] = fm.icelink.JsonSerializer.serializeLong(this.getSynchronizationSource());
                        jsonObject["rid"] = fm.icelink.JsonSerializer.serializeString(this.getRtpStreamId());
                        jsonObject["rrid"] = fm.icelink.JsonSerializer.serializeString(this.getRepairedRtpStreamId());
                        if ((!fm.icelink.Global.equals(this.getTrack(), null))) {
                            jsonObject["track"] = fm.icelink.MediaTrackStats.toJson(this.getTrack());
                        }
                        if ((!fm.icelink.Global.equals(this.getCodec(), null))) {
                            jsonObject["codec"] = fm.icelink.CodecStats.toJson(this.getCodec());
                        }
                        jsonObject["nackCount"] = fm.icelink.JsonSerializer.serializeLong(this.getNackCount());
                        jsonObject["pliCount"] = fm.icelink.JsonSerializer.serializeLong(this.getPliCount());
                        jsonObject["firCount"] = fm.icelink.JsonSerializer.serializeLong(this.getFirCount());
                        jsonObject["lrrCount"] = fm.icelink.JsonSerializer.serializeLong(this.getLrrCount());
                        jsonObject["sliCount"] = fm.icelink.JsonSerializer.serializeLong(this.getSliCount());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.setCodec = function (value) {
                    if (arguments.length == 1) {
                        this._codec = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.setFirCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._firCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.setLrrCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._lrrCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.setNackCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._nackCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.setPliCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._pliCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.setRepairedRtpStreamId = function (value) {
                    if (arguments.length == 1) {
                        this._repairedRtpStreamId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.setRtpStreamId = function (value) {
                    if (arguments.length == 1) {
                        this._rtpStreamId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.setSliCount = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._sliCount = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.setSynchronizationSource = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._synchronizationSource = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaComponentStats.prototype.setTrack = function (value) {
                    if (arguments.length == 1) {
                        this._track = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaComponentStats;
            }(fm.icelink.BaseStats));
            icelink.MediaComponentStats = MediaComponentStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaReceiverInfo =  (function (_super) {
                __extends(MediaReceiverInfo, _super);
                function MediaReceiverInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else if (__arguments.length == 2) {
                        var stats = __arguments[0];
                        var lastStats = __arguments[1];
                        _this = _super.call(this, stats, lastStats) || this;
                        var sink = stats.getSink();
                        if ((!fm.icelink.Global.equals(sink, null))) {
                            _this.setSink(new fm.icelink.MediaSinkInfo(sink, ((fm.icelink.Global.equals(lastStats, null)) ? null : lastStats.getSink())));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaReceiverInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaReceiverInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaReceiverInfo.fromJson = function (mediaReceiverJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaReceiverJson, function () {
                            return new fm.icelink.MediaReceiverInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverInfo.fromJsonArray = function (mediaReceiversJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(mediaReceiversJson, fm.icelink.MediaReceiverInfo.fromJson.bind(fm.icelink.MediaReceiverInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverInfo.toJson = function (mediaReceiver) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(mediaReceiver, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverInfo.toJsonArray = function (mediaReceivers) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(mediaReceivers, fm.icelink.MediaReceiverInfo.toJson.bind(fm.icelink.MediaReceiverInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if (((!fm.icelink.Global.equals(str, null)) && (fm.icelink.Global.equals(str, "sink")))) {
                            this.setSink(fm.icelink.MediaSinkInfo.fromJson(valueJson));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverInfo.prototype.getSink = function () {
                    if (arguments.length == 0) {
                        return this._sink;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getSink(), null))) {
                            jsonObject["sink"] = fm.icelink.MediaSinkInfo.toJson(this.getSink());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverInfo.prototype.setSink = function (value) {
                    if (arguments.length == 1) {
                        this._sink = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaReceiverInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaReceiverInfo;
            }(fm.icelink.MediaComponentInfo));
            icelink.MediaReceiverInfo = MediaReceiverInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaReceiverStats =  (function (_super) {
                __extends(MediaReceiverStats, _super);
                function MediaReceiverStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaReceiverStatsInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaReceiverStats.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaReceiverStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaReceiverStats.prototype.fmicelinkMediaReceiverStatsInit = function () {
                    this._bytesReceived = 0;
                    this._jitter = 0;
                    this._packetsDiscarded = 0;
                    this._packetsDuplicated = 0;
                    this._packetsLost = 0;
                    this._packetsReceived = 0;
                    this._packetsRepaired = 0;
                };
                MediaReceiverStats.fromJson = function (mediaReceiverJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaReceiverJson, function () {
                            return new fm.icelink.MediaReceiverStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.fromJsonArray = function (mediaReceiversJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(mediaReceiversJson, fm.icelink.MediaReceiverStats.fromJson.bind(fm.icelink.MediaReceiverStats));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.toJson = function (mediaReceiver) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(mediaReceiver, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.toJsonArray = function (mediaReceivers) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(mediaReceivers, fm.icelink.MediaReceiverStats.toJson.bind(fm.icelink.MediaReceiverStats));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var _var0 = key;
                        do {
                            if (_var0 == "packetsReceived") {
                                this.setPacketsReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "bytesReceived") {
                                this.setBytesReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "packetsLost") {
                                this.setPacketsLost(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "jitter") {
                                this.setJitter(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "packetsDiscarded") {
                                this.setPacketsDiscarded(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "packetsDuplicated") {
                                this.setPacketsDuplicated(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "packetsRepaired") {
                                this.setPacketsRepaired(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "sink") {
                                this.setSink(fm.icelink.MediaSinkStats.fromJson(valueJson));
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.getBytesReceived = function () {
                    if (arguments.length == 0) {
                        return this._bytesReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.getJitter = function () {
                    if (arguments.length == 0) {
                        return this._jitter;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.getPacketsDiscarded = function () {
                    if (arguments.length == 0) {
                        return this._packetsDiscarded;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.getPacketsDuplicated = function () {
                    if (arguments.length == 0) {
                        return this._packetsDuplicated;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.getPacketsLost = function () {
                    if (arguments.length == 0) {
                        return this._packetsLost;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.getPacketsReceived = function () {
                    if (arguments.length == 0) {
                        return this._packetsReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.getPacketsRepaired = function () {
                    if (arguments.length == 0) {
                        return this._packetsRepaired;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.getSink = function () {
                    if (arguments.length == 0) {
                        return this._sink;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.isEquivalent = function (instance) {
                    if (arguments.length == 1) {
                        return ((((((fm.icelink.Global.equals(instance.getSynchronizationSource(), _super.prototype.getSynchronizationSource.call(this))) && ((fm.icelink.Global.equals(instance.getTrack(), _super.prototype.getTrack.call(this))) || ((!fm.icelink.Global.equals(_super.prototype.getTrack.call(this), null)) && _super.prototype.getTrack.call(this).isEquivalent(instance.getTrack())))) && (((fm.icelink.Global.equals(instance.getCodec(), _super.prototype.getCodec.call(this))) || ((!fm.icelink.Global.equals(_super.prototype.getCodec.call(this), null)) && _super.prototype.getCodec.call(this).isEquivalent(instance.getCodec()))) && ((fm.icelink.Global.equals(instance.getNackCount(), _super.prototype.getNackCount.call(this))) && (fm.icelink.Global.equals(instance.getPliCount(), _super.prototype.getPliCount.call(this)))))) && ((((fm.icelink.Global.equals(instance.getFirCount(), _super.prototype.getFirCount.call(this))) && (fm.icelink.Global.equals(instance.getLrrCount(), _super.prototype.getLrrCount.call(this)))) && ((fm.icelink.Global.equals(instance.getSliCount(), _super.prototype.getSliCount.call(this))) && (fm.icelink.Global.equals(instance.getPacketsReceived(), this.getPacketsReceived())))) && (((fm.icelink.Global.equals(instance.getBytesReceived(), this.getBytesReceived())) && (fm.icelink.Global.equals(instance.getPacketsLost(), this.getPacketsLost()))) && ((fm.icelink.Global.equals(instance.getJitter(), this.getJitter())) && (fm.icelink.Global.equals(instance.getPacketsDiscarded(), this.getPacketsDiscarded())))))) && ((fm.icelink.Global.equals(instance.getPacketsDuplicated(), this.getPacketsDuplicated())) && (fm.icelink.Global.equals(instance.getPacketsRepaired(), this.getPacketsRepaired())))) && ((fm.icelink.Global.equals(instance.getSink(), this.getSink())) || ((!fm.icelink.Global.equals(this.getSink(), null)) && this.getSink().isEquivalent(instance.getSink()))));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        jsonObject["packetsReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getPacketsReceived());
                        jsonObject["bytesReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getBytesReceived());
                        jsonObject["packetsLost"] = fm.icelink.JsonSerializer.serializeLong(this.getPacketsLost());
                        jsonObject["jitter"] = fm.icelink.JsonSerializer.serializeInteger(this.getJitter());
                        jsonObject["packetsDiscarded"] = fm.icelink.JsonSerializer.serializeLong(this.getPacketsDiscarded());
                        jsonObject["packetsDuplicated"] = fm.icelink.JsonSerializer.serializeLong(this.getPacketsDuplicated());
                        jsonObject["packetsRepaired"] = fm.icelink.JsonSerializer.serializeLong(this.getPacketsRepaired());
                        if ((!fm.icelink.Global.equals(this.getSink(), null))) {
                            jsonObject["sink"] = fm.icelink.MediaSinkStats.toJson(this.getSink());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.setBytesReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bytesReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.setJitter = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._jitter = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.setPacketsDiscarded = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._packetsDiscarded = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.setPacketsDuplicated = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._packetsDuplicated = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.setPacketsLost = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._packetsLost = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.setPacketsReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._packetsReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.setPacketsRepaired = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._packetsRepaired = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.setSink = function (value) {
                    if (arguments.length == 1) {
                        this._sink = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaReceiverStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaReceiverStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaReceiverStats;
            }(fm.icelink.MediaComponentStats));
            icelink.MediaReceiverStats = MediaReceiverStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaSenderInfo =  (function (_super) {
                __extends(MediaSenderInfo, _super);
                function MediaSenderInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else if (__arguments.length == 2) {
                        var stats = __arguments[0];
                        var lastStats = __arguments[1];
                        _this = _super.call(this, stats, lastStats) || this;
                        var source = stats.getSource();
                        if ((!fm.icelink.Global.equals(source, null))) {
                            _this.setSource(new fm.icelink.MediaSourceInfo(source, ((fm.icelink.Global.equals(lastStats, null)) ? null : lastStats.getSource())));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaSenderInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaSenderInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaSenderInfo.fromJson = function (mediaSenderJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaSenderJson, function () {
                            return new fm.icelink.MediaSenderInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderInfo.fromJsonArray = function (mediaSendersJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(mediaSendersJson, fm.icelink.MediaSenderInfo.fromJson.bind(fm.icelink.MediaSenderInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderInfo.toJson = function (mediaSender) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(mediaSender, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderInfo.toJsonArray = function (mediaSenders) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(mediaSenders, fm.icelink.MediaSenderInfo.toJson.bind(fm.icelink.MediaSenderInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if (((!fm.icelink.Global.equals(str, null)) && (fm.icelink.Global.equals(str, "source")))) {
                            this.setSource(fm.icelink.MediaSourceInfo.fromJson(valueJson));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderInfo.prototype.getSource = function () {
                    if (arguments.length == 0) {
                        return this._source;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getSource(), null))) {
                            jsonObject["source"] = fm.icelink.MediaSourceInfo.toJson(this.getSource());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderInfo.prototype.setSource = function (value) {
                    if (arguments.length == 1) {
                        this._source = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaSenderInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaSenderInfo;
            }(fm.icelink.MediaComponentInfo));
            icelink.MediaSenderInfo = MediaSenderInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaSenderStats =  (function (_super) {
                __extends(MediaSenderStats, _super);
                function MediaSenderStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaSenderStatsInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaSenderStats.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaSenderStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaSenderStats.prototype.fmicelinkMediaSenderStatsInit = function () {
                    this._bytesSent = 0;
                    this._packetsSent = 0;
                    this._roundTripTime = 0;
                };
                MediaSenderStats.fromJson = function (mediaSenderJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaSenderJson, function () {
                            return new fm.icelink.MediaSenderStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.fromJsonArray = function (mediaSendersJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(mediaSendersJson, fm.icelink.MediaSenderStats.fromJson.bind(fm.icelink.MediaSenderStats));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.toJson = function (mediaSender) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(mediaSender, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.toJsonArray = function (mediaSenders) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(mediaSenders, fm.icelink.MediaSenderStats.toJson.bind(fm.icelink.MediaSenderStats));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "packetsSent"))) {
                                if ((fm.icelink.Global.equals(str, "bytesSent"))) {
                                    this.setBytesSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "rtt"))) {
                                        this.setRoundTripTime(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "source"))) {
                                            this.setSource(fm.icelink.MediaSourceStats.fromJson(valueJson));
                                        }
                                    }
                                }
                            }
                            else {
                                this.setPacketsSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.getBytesSent = function () {
                    if (arguments.length == 0) {
                        return this._bytesSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.getPacketsSent = function () {
                    if (arguments.length == 0) {
                        return this._packetsSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.getRoundTripTime = function () {
                    if (arguments.length == 0) {
                        return this._roundTripTime;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.getSource = function () {
                    if (arguments.length == 0) {
                        return this._source;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.isEquivalent = function (instance) {
                    if (arguments.length == 1) {
                        return (((((fm.icelink.Global.equals(instance.getSynchronizationSource(), _super.prototype.getSynchronizationSource.call(this))) && ((fm.icelink.Global.equals(instance.getTrack(), _super.prototype.getTrack.call(this))) || ((!fm.icelink.Global.equals(_super.prototype.getTrack.call(this), null)) && _super.prototype.getTrack.call(this).isEquivalent(instance.getTrack())))) && (((fm.icelink.Global.equals(instance.getCodec(), _super.prototype.getCodec.call(this))) || ((!fm.icelink.Global.equals(_super.prototype.getCodec.call(this), null)) && _super.prototype.getCodec.call(this).isEquivalent(instance.getCodec()))) && ((fm.icelink.Global.equals(instance.getNackCount(), _super.prototype.getNackCount.call(this))) && (fm.icelink.Global.equals(instance.getPliCount(), _super.prototype.getPliCount.call(this)))))) && ((((fm.icelink.Global.equals(instance.getFirCount(), _super.prototype.getFirCount.call(this))) && (fm.icelink.Global.equals(instance.getLrrCount(), _super.prototype.getLrrCount.call(this)))) && ((fm.icelink.Global.equals(instance.getSliCount(), _super.prototype.getSliCount.call(this))) && (fm.icelink.Global.equals(instance.getPacketsSent(), this.getPacketsSent())))) && ((fm.icelink.Global.equals(instance.getBytesSent(), this.getBytesSent())) && (fm.icelink.Global.equals(instance.getRoundTripTime(), this.getRoundTripTime()))))) && ((fm.icelink.Global.equals(instance.getSource(), this.getSource())) || ((!fm.icelink.Global.equals(this.getSource(), null)) && this.getSource().isEquivalent(instance.getSource()))));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        jsonObject["packetsSent"] = fm.icelink.JsonSerializer.serializeLong(this.getPacketsSent());
                        jsonObject["bytesSent"] = fm.icelink.JsonSerializer.serializeLong(this.getBytesSent());
                        jsonObject["rtt"] = fm.icelink.JsonSerializer.serializeInteger(this.getRoundTripTime());
                        if ((!fm.icelink.Global.equals(this.getSource(), null))) {
                            jsonObject["source"] = fm.icelink.MediaSourceStats.toJson(this.getSource());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.setBytesSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bytesSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.setPacketsSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._packetsSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.setRoundTripTime = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._roundTripTime = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.setSource = function (value) {
                    if (arguments.length == 1) {
                        this._source = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSenderStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaSenderStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaSenderStats;
            }(fm.icelink.MediaComponentStats));
            icelink.MediaSenderStats = MediaSenderStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaSinkInfo =  (function (_super) {
                __extends(MediaSinkInfo, _super);
                function MediaSinkInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else if (__arguments.length == 2) {
                        var stats = __arguments[0];
                        var lastStats = __arguments[1];
                        _this = _super.call(this) || this;
                        _super.prototype.setId.call(_this, stats.getId());
                        var flag = (fm.icelink.Global.equals(lastStats, null));
                        _this.setTag((flag ? stats.getTag() : fm.icelink.Info.processString(stats.getTag(), lastStats.getTag())));
                        _this.setLabel((flag ? stats.getLabel() : fm.icelink.Info.processString(stats.getLabel(), lastStats.getLabel())));
                        _this.setOutputId((flag ? stats.getOutputId() : fm.icelink.Info.processString(stats.getOutputId(), lastStats.getOutputId())));
                        _this.setOutputName((flag ? stats.getOutputName() : fm.icelink.Info.processString(stats.getOutputName(), lastStats.getOutputName())));
                        if (((!fm.icelink.Global.equals(stats.getInputFormat(), null)) && (flag || !stats.getInputFormat().isEquivalent(lastStats.getInputFormat())))) {
                            _this.setInputFormat(new fm.icelink.FormatInfo(stats.getInputFormat().getName(), stats.getInputFormat().getClockRate(), stats.getInputFormat().getChannelCount()));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaSinkInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaSinkInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaSinkInfo.fromJson = function (mediaSinkInfoJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaSinkInfoJson, function () {
                            return new fm.icelink.MediaSinkInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.fromJsonArray = function (mediaSinkInfosJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(mediaSinkInfosJson, fm.icelink.MediaSinkInfo.fromJson.bind(fm.icelink.MediaSinkInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.toJson = function (mediaSinkInfo) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(mediaSinkInfo, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.toJsonArray = function (mediaSinkInfos) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(mediaSinkInfos, fm.icelink.MediaSinkInfo.toJson.bind(fm.icelink.MediaSinkInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "tag"))) {
                                if ((fm.icelink.Global.equals(str, "label"))) {
                                    this.setLabel(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "outputId"))) {
                                        this.setOutputId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "outputName"))) {
                                            this.setOutputName(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "inputFormat"))) {
                                                this.setInputFormat(fm.icelink.FormatInfo.fromJson(valueJson));
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                this.setTag(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.getInputFormat = function () {
                    if (arguments.length == 0) {
                        return this._inputFormat;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.getLabel = function () {
                    if (arguments.length == 0) {
                        return this._label;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.getOutputId = function () {
                    if (arguments.length == 0) {
                        return this._outputId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.getOutputName = function () {
                    if (arguments.length == 0) {
                        return this._outputName;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getTag())) {
                            jsonObject["tag"] = fm.icelink.JsonSerializer.serializeString(this.getTag());
                        }
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getLabel())) {
                            jsonObject["label"] = fm.icelink.JsonSerializer.serializeString(this.getLabel());
                        }
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getOutputId())) {
                            jsonObject["outputId"] = fm.icelink.JsonSerializer.serializeString(this.getOutputId());
                        }
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getOutputName())) {
                            jsonObject["outputName"] = fm.icelink.JsonSerializer.serializeString(this.getOutputName());
                        }
                        if ((!fm.icelink.Global.equals(this.getInputFormat(), null))) {
                            jsonObject["inputFormat"] = fm.icelink.FormatInfo.toJson(this.getInputFormat());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.setInputFormat = function (value) {
                    if (arguments.length == 1) {
                        this._inputFormat = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.setLabel = function (value) {
                    if (arguments.length == 1) {
                        this._label = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.setOutputId = function (value) {
                    if (arguments.length == 1) {
                        this._outputId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.setOutputName = function (value) {
                    if (arguments.length == 1) {
                        this._outputName = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaSinkInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaSinkInfo;
            }(fm.icelink.Info));
            icelink.MediaSinkInfo = MediaSinkInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaSinkStats =  (function (_super) {
                __extends(MediaSinkStats, _super);
                function MediaSinkStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaSinkStatsInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaSinkStats.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaSinkStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaSinkStats.prototype.fmicelinkMediaSinkStatsInit = function () {
                    this._muted = false;
                };
                MediaSinkStats.fromJson = function (instanceJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(instanceJson, function () {
                            return new fm.icelink.MediaSinkStats();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.fromJsonArray = function (arrayJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(arrayJson, fm.icelink.MediaSinkStats.fromJson.bind(fm.icelink.MediaSinkStats));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.toJson = function (instance) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(instance, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.toJsonArray = function (array) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(array, fm.icelink.MediaSinkStats.toJson.bind(fm.icelink.MediaSinkStats));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "tag"))) {
                                if ((fm.icelink.Global.equals(str, "label"))) {
                                    this.setLabel(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "muted"))) {
                                        this.setMuted(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "outputId"))) {
                                            this.setOutputId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "outputName"))) {
                                                this.setOutputName(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                            }
                                            else {
                                                if ((fm.icelink.Global.equals(str, "inputFormat"))) {
                                                    this.setInputFormat(fm.icelink.FormatInfo.fromJson(valueJson));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                this.setTag(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.getInputFormat = function () {
                    if (arguments.length == 0) {
                        return this._inputFormat;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.getLabel = function () {
                    if (arguments.length == 0) {
                        return this._label;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.getMuted = function () {
                    if (arguments.length == 0) {
                        return this._muted;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.getOutputId = function () {
                    if (arguments.length == 0) {
                        return this._outputId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.getOutputName = function () {
                    if (arguments.length == 0) {
                        return this._outputName;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.isEquivalent = function (instance) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(instance, null))) {
                            return false;
                        }
                        if (((fm.icelink.Global.equals(instance.getInputFormat(), null)) && (!fm.icelink.Global.equals(this.getInputFormat(), null)))) {
                            return false;
                        }
                        return (((((fm.icelink.Global.equals(instance.getTag(), this.getTag())) && (fm.icelink.Global.equals(instance.getLabel(), this.getLabel()))) && ((fm.icelink.Global.equals(instance.getMuted(), this.getMuted())) && (fm.icelink.Global.equals(instance.getOutputId(), this.getOutputId())))) && (fm.icelink.Global.equals(instance.getOutputName(), this.getOutputName()))) && instance.getInputFormat().isEquivalent(this.getInputFormat()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getTag(), null))) {
                            jsonObject["tag"] = fm.icelink.JsonSerializer.serializeString(this.getTag());
                        }
                        if ((!fm.icelink.Global.equals(this.getLabel(), null))) {
                            jsonObject["label"] = fm.icelink.JsonSerializer.serializeString(this.getLabel());
                        }
                        jsonObject["muted"] = fm.icelink.JsonSerializer.serializeBoolean(this.getMuted());
                        if ((!fm.icelink.Global.equals(this.getOutputId(), null))) {
                            jsonObject["outputId"] = fm.icelink.JsonSerializer.serializeString(this.getOutputId());
                        }
                        if ((!fm.icelink.Global.equals(this.getOutputName(), null))) {
                            jsonObject["outputName"] = fm.icelink.JsonSerializer.serializeString(this.getOutputName());
                        }
                        if ((!fm.icelink.Global.equals(this.getInputFormat(), null))) {
                            jsonObject["inputFormat"] = fm.icelink.FormatInfo.toJson(this.getInputFormat());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.setInputFormat = function (value) {
                    if (arguments.length == 1) {
                        this._inputFormat = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.setLabel = function (value) {
                    if (arguments.length == 1) {
                        this._label = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.setMuted = function (value) {
                    if (arguments.length == 1) {
                        this._muted = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.setOutputId = function (value) {
                    if (arguments.length == 1) {
                        this._outputId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.setOutputName = function (value) {
                    if (arguments.length == 1) {
                        this._outputName = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSinkStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaSinkStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaSinkStats;
            }(fm.icelink.BaseStats));
            icelink.MediaSinkStats = MediaSinkStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaSourceStats =  (function (_super) {
                __extends(MediaSourceStats, _super);
                function MediaSourceStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaSourceStatsInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaSourceStats.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaSourceStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaSourceStats.prototype.fmicelinkMediaSourceStatsInit = function () {
                    this._muted = false;
                };
                MediaSourceStats.fromJson = function (instanceJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(instanceJson, function () {
                            return new fm.icelink.MediaSourceStats();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.toJson = function (instance) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(instance, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "tag"))) {
                                if ((fm.icelink.Global.equals(str, "label"))) {
                                    this.setLabel(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "muted"))) {
                                        this.setMuted(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "inputId"))) {
                                            this.setInputId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "inputName"))) {
                                                this.setInputName(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                            }
                                            else {
                                                if ((fm.icelink.Global.equals(str, "outputFormat"))) {
                                                    this.setOutputFormat(fm.icelink.FormatInfo.fromJson(valueJson));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                this.setTag(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.getInputId = function () {
                    if (arguments.length == 0) {
                        return this._inputId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.getInputName = function () {
                    if (arguments.length == 0) {
                        return this._inputName;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.getLabel = function () {
                    if (arguments.length == 0) {
                        return this._label;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.getMuted = function () {
                    if (arguments.length == 0) {
                        return this._muted;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.getOutputFormat = function () {
                    if (arguments.length == 0) {
                        return this._outputFormat;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.isEquivalent = function (instance) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(instance, null))) {
                            return false;
                        }
                        if (((fm.icelink.Global.equals(instance.getOutputFormat(), null)) && (!fm.icelink.Global.equals(this.getOutputFormat(), null)))) {
                            return false;
                        }
                        return (((((fm.icelink.Global.equals(instance.getTag(), this.getTag())) && (fm.icelink.Global.equals(instance.getLabel(), this.getLabel()))) && ((fm.icelink.Global.equals(instance.getMuted(), this.getMuted())) && (fm.icelink.Global.equals(instance.getInputId(), this.getInputId())))) && (fm.icelink.Global.equals(instance.getInputName(), this.getInputName()))) && instance.getOutputFormat().isEquivalent(this.getOutputFormat()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getTag(), null))) {
                            jsonObject["tag"] = fm.icelink.JsonSerializer.serializeString(this.getTag());
                        }
                        if ((!fm.icelink.Global.equals(this.getLabel(), null))) {
                            jsonObject["label"] = fm.icelink.JsonSerializer.serializeString(this.getLabel());
                        }
                        jsonObject["muted"] = fm.icelink.JsonSerializer.serializeBoolean(this.getMuted());
                        if ((!fm.icelink.Global.equals(this.getInputId(), null))) {
                            jsonObject["inputId"] = fm.icelink.JsonSerializer.serializeString(this.getInputId());
                        }
                        if ((!fm.icelink.Global.equals(this.getInputName(), null))) {
                            jsonObject["inputName"] = fm.icelink.JsonSerializer.serializeString(this.getInputName());
                        }
                        if ((!fm.icelink.Global.equals(this.getOutputFormat(), null))) {
                            jsonObject["outputFormat"] = fm.icelink.FormatInfo.toJson(this.getOutputFormat());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.setInputId = function (value) {
                    if (arguments.length == 1) {
                        this._inputId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.setInputName = function (value) {
                    if (arguments.length == 1) {
                        this._inputName = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.setLabel = function (value) {
                    if (arguments.length == 1) {
                        this._label = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.setMuted = function (value) {
                    if (arguments.length == 1) {
                        this._muted = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.setOutputFormat = function (value) {
                    if (arguments.length == 1) {
                        this._outputFormat = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaSourceStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaSourceStats;
            }(fm.icelink.BaseStats));
            icelink.MediaSourceStats = MediaSourceStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaStats =  (function (_super) {
                __extends(MediaStats, _super);
                function MediaStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaStats.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaStats.fromJson = function (mediaJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaJson, function () {
                            return new fm.icelink.MediaStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStats.toJson = function (media) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(media, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if (((!fm.icelink.Global.equals(str, null)) && (fm.icelink.Global.equals(str, "tracks")))) {
                            this.setTracks(fm.icelink.MediaTrackStats.fromJsonArray(valueJson));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStats.prototype.getTrack = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.firstOrDefault(this.getTracks());
                    }
                    else if (arguments.length == 1) {
                        var trackId = arguments[0];
                        for (var _i = 0, _a = this.getTracks(); _i < _a.length; _i++) {
                            var stats = _a[_i];
                            if ((fm.icelink.Global.equals(stats.getId(), trackId))) {
                                return stats;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStats.prototype.getTracks = function () {
                    if (arguments.length == 0) {
                        return this._tracks;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getTracks(), null))) {
                            jsonObject["tracks"] = fm.icelink.MediaTrackStats.toJsonArray(this.getTracks());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStats.prototype.setTracks = function (value) {
                    if (arguments.length == 1) {
                        this._tracks = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaStats;
            }(fm.icelink.BaseStats));
            icelink.MediaStats = MediaStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var EncodingInfo =  (function (_super) {
                __extends(EncodingInfo, _super);
                function EncodingInfo() {
                    var _this = this;
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkEncodingInfoInit();
                        _this.__synchronizationSource = -1;
                        _this.__bitrate = -1;
                        _this.__frameRate = -1;
                        _this.__scale = -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                EncodingInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.EncodingInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                EncodingInfo.prototype.fmicelinkEncodingInfoInit = function () {
                    this.__bitrate = 0;
                    this.__frameRate = 0;
                    this.__scale = 0;
                    this.__synchronizationSource = 0;
                    this._deactivated = false;
                };
                EncodingInfo.findEncoding = function (encodings, synchronizationSource, rtpStreamId) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 3) {
                        synchronizationSource = fm.icelink.Global.toInt(arguments[1]);
                        if ((synchronizationSource >= 0)) {
                            for (var _i = 0, encodings_1 = encodings; _i < encodings_1.length; _i++) {
                                var info = encodings_1[_i];
                                if ((fm.icelink.Global.equals(info.getSynchronizationSource(), synchronizationSource))) {
                                    return info;
                                }
                            }
                        }
                        if ((!fm.icelink.Global.equals(rtpStreamId, null))) {
                            for (var _a = 0, encodings_2 = encodings; _a < encodings_2.length; _a++) {
                                var info = encodings_2[_a];
                                if ((fm.icelink.Global.equals(info.getRtpStreamId(), rtpStreamId))) {
                                    return info;
                                }
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.fromJson = function (encodingInfoJson) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(encodingInfoJson, function () {
                            return new fm.icelink.EncodingInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.fromJsonArray = function (encodingInfosJson) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(encodingInfosJson, fm.icelink.EncodingInfo.fromJson.bind(fm.icelink.EncodingInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.fromSdpRidAttribute = function (ridAttribute) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(ridAttribute, null))) {
                            return null;
                        }
                        if ((fm.icelink.Global.equals(ridAttribute.getId(), null))) {
                            throw new fm.icelink.Exception("RTP stream ID cannot be null.");
                        }
                        var info2 = new fm.icelink.EncodingInfo();
                        info2.setRtpStreamId(ridAttribute.getId());
                        var info = info2;
                        info.setSdpRidRestrictions(ridAttribute.getRestrictions());
                        return info;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.isEquivalent = function () {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 2) {
                        var encoding1 = arguments[0];
                        var encoding2 = arguments[1];
                        return fm.icelink.EncodingInfo.isEquivalent(encoding1, encoding2, false);
                    }
                    else if (arguments.length == 3) {
                        var encoding1 = arguments[0];
                        var encoding2 = arguments[1];
                        var restrictionsOnly = arguments[2];
                        if ((fm.icelink.Global.equals(encoding1, encoding2))) {
                            return true;
                        }
                        if (((fm.icelink.Global.equals(encoding1, null)) || (fm.icelink.Global.equals(encoding2, null)))) {
                            return false;
                        }
                        return fm.icelink.EncodingInfo.isEquivalentNoCheck(encoding1, encoding2, restrictionsOnly);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.isEquivalentNoCheck = function (encoding1, encoding2, restrictionsOnly) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 3) {
                        return (((((restrictionsOnly || (fm.icelink.Global.equals(encoding1.getRtpStreamId(), encoding2.getRtpStreamId()))) && (restrictionsOnly || (fm.icelink.Global.equals(encoding1.getSynchronizationSource(), encoding2.getSynchronizationSource())))) && ((restrictionsOnly || (fm.icelink.Global.equals(encoding1.getDeactivated(), encoding2.getDeactivated()))) && ((fm.icelink.Global.equals(encoding1.getBitrate(), encoding2.getBitrate())) && (fm.icelink.Global.equals(encoding1.getFrameRate(), encoding2.getFrameRate()))))) && fm.icelink.Size.isEquivalent(encoding1.getSize(), encoding2.getSize())) && (fm.icelink.Global.equals(encoding1.getScale(), encoding2.getScale())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.max = function (encoding1, encoding2) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 2) {
                        var info2 = new fm.icelink.EncodingInfo();
                        info2.setBitrate(fm.icelink.EncodingInfo.maxInteger(encoding1.getBitrate(), encoding2.getBitrate()));
                        info2.setFrameRate(fm.icelink.EncodingInfo.maxDouble(encoding1.getFrameRate(), encoding2.getFrameRate()));
                        var info = info2;
                        var scaledSize = encoding1.getScaledSize();
                        var size2 = encoding2.getScaledSize();
                        if ((fm.icelink.Global.equals(fm.icelink.EncodingInfo.maxSize(scaledSize, size2), scaledSize))) {
                            info.setSize(encoding1.getSize());
                            info.setScale(encoding1.getScale());
                            return info;
                        }
                        info.setSize(encoding2.getSize());
                        info.setScale(encoding2.getScale());
                        return info;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.maxDouble = function (value1, value2) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(value1, -1))) {
                            return value2;
                        }
                        if ((fm.icelink.Global.equals(value2, -1))) {
                            return value1;
                        }
                        return fm.icelink.MathAssistant.max(value1, value2);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.maxInteger = function (value1, value2) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 2) {
                        value1 = fm.icelink.Global.toInt(arguments[0]);
                        value2 = fm.icelink.Global.toInt(arguments[1]);
                        if ((fm.icelink.Global.equals(value1, -1))) {
                            return value2;
                        }
                        if ((fm.icelink.Global.equals(value2, -1))) {
                            return value1;
                        }
                        return fm.icelink.MathAssistant.max(value1, value2);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.maxSize = function (value1, value2) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(value1, null))) {
                            return value2;
                        }
                        if (((!fm.icelink.Global.equals(value2, null)) && ((value2.getWidth() * value2.getHeight()) > (value1.getWidth() * value1.getHeight())))) {
                            return value2;
                        }
                        return value1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.merge = function (encodings) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 1) {
                        var list = new Array();
                        for (var _i = 0, encodings_3 = encodings; _i < encodings_3.length; _i++) {
                            var info = encodings_3[_i];
                            var info2 = fm.icelink.EncodingInfo.findEncoding(list, info.getSynchronizationSource(), info.getRtpStreamId());
                            if ((fm.icelink.Global.equals(info2, null))) {
                                var info3 = new fm.icelink.EncodingInfo();
                                info3.setSynchronizationSource(info.getSynchronizationSource());
                                info3.setRtpStreamId(info.getRtpStreamId());
                                info3.setDeactivated(info.getDeactivated());
                                fm.icelink.ArrayExtensions.add(list, info3.extend(info));
                            }
                            else {
                                info2.extend(info);
                            }
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.min = function (encoding1, encoding2) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 2) {
                        var info2 = new fm.icelink.EncodingInfo();
                        info2.setBitrate(fm.icelink.EncodingInfo.minInteger(encoding1.getBitrate(), encoding2.getBitrate()));
                        info2.setFrameRate(fm.icelink.EncodingInfo.minDouble(encoding1.getFrameRate(), encoding2.getFrameRate()));
                        var info = info2;
                        var scaledSize = encoding1.getScaledSize();
                        var size2 = encoding2.getScaledSize();
                        if ((fm.icelink.Global.equals(fm.icelink.EncodingInfo.minSize(scaledSize, size2), scaledSize))) {
                            info.setSize(encoding1.getSize());
                            info.setScale(encoding1.getScale());
                            return info;
                        }
                        info.setSize(encoding2.getSize());
                        info.setScale(encoding2.getScale());
                        return info;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.minDouble = function (value1, value2) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(value1, -1))) {
                            return value2;
                        }
                        if ((fm.icelink.Global.equals(value2, -1))) {
                            return value1;
                        }
                        return fm.icelink.MathAssistant.min(value1, value2);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.minInteger = function (value1, value2) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 2) {
                        value1 = fm.icelink.Global.toInt(arguments[0]);
                        value2 = fm.icelink.Global.toInt(arguments[1]);
                        if ((fm.icelink.Global.equals(value1, -1))) {
                            return value2;
                        }
                        if ((fm.icelink.Global.equals(value2, -1))) {
                            return value1;
                        }
                        return fm.icelink.MathAssistant.min(value1, value2);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.minSize = function (value1, value2) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(value1, null))) {
                            return value2;
                        }
                        if (((!fm.icelink.Global.equals(value2, null)) && ((value2.getWidth() * value2.getHeight()) < (value1.getWidth() * value1.getHeight())))) {
                            return value2;
                        }
                        return value1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.toJson = function (encodingInfo) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(encodingInfo, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.toJsonArray = function (encodingInfos) {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(encodingInfos, fm.icelink.EncodingInfo.toJson.bind(fm.icelink.EncodingInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.toSdpRidAttribute = function () {
                    fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
                    if (arguments.length == 2) {
                        var encoding = arguments[0];
                        var direction = arguments[1];
                        return fm.icelink.EncodingInfo.toSdpRidAttribute(encoding, direction, true);
                    }
                    else if (arguments.length == 3) {
                        var encoding = arguments[0];
                        var direction = arguments[1];
                        var includeRestrictions = arguments[2];
                        if ((fm.icelink.Global.equals(encoding, null))) {
                            return null;
                        }
                        if ((fm.icelink.Global.equals(encoding.getRtpStreamId(), null))) {
                            throw new fm.icelink.Exception("RTP stream ID cannot be null.");
                        }
                        return new fm.icelink.sdp.rtp.RidAttribute(encoding.getRtpStreamId(), direction, (includeRestrictions ? encoding.getSdpRidRestrictions() : null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var _var0 = key;
                        do {
                            if (_var0 == "rtpStreamId") {
                                this.setRtpStreamId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                break;
                            }
                            else if (_var0 == "synchronizationSource") {
                                this.setSynchronizationSource(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "deactivated") {
                                this.setDeactivated(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                break;
                            }
                            else if (_var0 == "bitrate") {
                                this.setBitrate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "frameRate") {
                                this.setFrameRate(fm.icelink.JsonSerializer.deserializeDouble(valueJson));
                                break;
                            }
                            else if (_var0 == "size") {
                                this.setSize(fm.icelink.Size.fromJson(valueJson));
                                break;
                            }
                            else if (_var0 == "scale") {
                                this.setScale(fm.icelink.JsonSerializer.deserializeDouble(valueJson));
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.extend = function (encoding) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(this.getDeactivated(), encoding.getDeactivated()))) {
                            this.setDeactivated(false);
                        }
                        if (((fm.icelink.Global.equals(this.getBitrate(), -1)) || (encoding.getBitrate() > this.getBitrate()))) {
                            this.setBitrate(encoding.getBitrate());
                        }
                        if (((fm.icelink.Global.equals(this.getFrameRate(), -1)) || (encoding.getFrameRate() > this.getFrameRate()))) {
                            this.setFrameRate(encoding.getFrameRate());
                        }
                        if ((((fm.icelink.Global.equals(this.getWidth(), -1)) && (fm.icelink.Global.equals(this.getHeight(), -1))) || ((encoding.getWidth() > this.getWidth()) && (encoding.getHeight() > this.getHeight())))) {
                            this.setSize(encoding.getSize());
                        }
                        if (((fm.icelink.Global.equals(this.getScale(), -1)) || (encoding.getScale() > this.getScale()))) {
                            this.setScale(encoding.getScale());
                        }
                        return this;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getBitrate = function () {
                    if (arguments.length == 0) {
                        return this.__bitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getDeactivated = function () {
                    if (arguments.length == 0) {
                        return this._deactivated;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getFrameRate = function () {
                    if (arguments.length == 0) {
                        return this.__frameRate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getHeight = function () {
                    if (arguments.length == 0) {
                        var size = this.getSize();
                        if ((fm.icelink.Global.equals(size, null))) {
                            return -1;
                        }
                        return size.getHeight();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getIsEmpty = function () {
                    if (arguments.length == 0) {
                        return (((((fm.icelink.Global.equals(this.getRtpStreamId(), null)) && (fm.icelink.Global.equals(this.getSynchronizationSource(), -1))) && (!this.getDeactivated() && (fm.icelink.Global.equals(this.getBitrate(), -1)))) && ((fm.icelink.Global.equals(this.getFrameRate(), -1)) && (fm.icelink.Global.equals(this.getSize(), null)))) && (fm.icelink.Global.equals(this.getScale(), -1)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getRidRestrictionValue = function (ridRestrictions, ridRestrictionKey) {
                    if (arguments.length == 2) {
                        for (var _i = 0, ridRestrictions_1 = ridRestrictions; _i < ridRestrictions_1.length; _i++) {
                            var restriction = ridRestrictions_1[_i];
                            if ((fm.icelink.Global.equals(restriction.getKey(), ridRestrictionKey))) {
                                return restriction.getValue();
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getRtpStreamId = function () {
                    if (arguments.length == 0) {
                        return this._rtpStreamId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getScale = function () {
                    if (arguments.length == 0) {
                        return this.__scale;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getScaledHeight = function () {
                    if (arguments.length == 0) {
                        var scaledSize = this.getScaledSize();
                        if ((fm.icelink.Global.equals(scaledSize, null))) {
                            return -1;
                        }
                        return scaledSize.getHeight();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getScaledSize = function () {
                    if (arguments.length == 0) {
                        var size = this.getSize();
                        if ((fm.icelink.Global.equals(size, null))) {
                            return null;
                        }
                        var scale = this.getScale();
                        if ((scale > 0)) {
                            return new fm.icelink.Size((size.getWidth() * scale), (size.getHeight() * scale));
                        }
                        return size;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getScaledWidth = function () {
                    if (arguments.length == 0) {
                        var scaledSize = this.getScaledSize();
                        if ((fm.icelink.Global.equals(scaledSize, null))) {
                            return -1;
                        }
                        return scaledSize.getWidth();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getSdpRidRestrictions = function () {
                    if (arguments.length == 0) {
                        var list = new Array();
                        var bitrate = this.getBitrate();
                        if ((bitrate > 0)) {
                            var num6 = (bitrate * 1000);
                            fm.icelink.ArrayExtensions.add(list, new fm.icelink.sdp.rtp.RidRestriction(fm.icelink.sdp.rtp.RidRestriction.getMaxBitrateKey(), fm.icelink.NumberExtensions.toString(num6)));
                        }
                        var frameRate = this.getFrameRate();
                        if ((frameRate > 0)) {
                            fm.icelink.ArrayExtensions.add(list, new fm.icelink.sdp.rtp.RidRestriction(fm.icelink.sdp.rtp.RidRestriction.getMaxFramesPerSecondKey(), fm.icelink.NumberExtensions.toString(frameRate)));
                        }
                        var scale = this.getScale();
                        var width = this.getWidth();
                        if ((width > 0)) {
                            if ((scale > 0)) {
                                width = fm.icelink.MathAssistant.round((width * scale));
                            }
                            fm.icelink.ArrayExtensions.add(list, new fm.icelink.sdp.rtp.RidRestriction(fm.icelink.sdp.rtp.RidRestriction.getMaxWidthKey(), fm.icelink.NumberExtensions.toString(width)));
                        }
                        var height = this.getHeight();
                        if ((height > 0)) {
                            if ((scale > 0)) {
                                height = fm.icelink.MathAssistant.round((height * scale));
                            }
                            fm.icelink.ArrayExtensions.add(list, new fm.icelink.sdp.rtp.RidRestriction(fm.icelink.sdp.rtp.RidRestriction.getMaxHeightKey(), fm.icelink.NumberExtensions.toString(height)));
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getSdpSimulcastStream = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(this.getSdpSimulcastStreamId(), null))) {
                            return null;
                        }
                        return new fm.icelink.sdp.rtp.SimulcastStream(this.getSdpSimulcastStreamId());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getSdpSimulcastStreamId = function () {
                    if (arguments.length == 0) {
                        var rtpStreamId = this.getRtpStreamId();
                        if ((fm.icelink.Global.equals(rtpStreamId, null))) {
                            return null;
                        }
                        return new fm.icelink.sdp.rtp.SimulcastStreamId(rtpStreamId, this.getDeactivated());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getSdpSsrcRestrictionAttributes = function () {
                    if (arguments.length == 0) {
                        var list = new Array();
                        for (var _i = 0, _a = this.getSdpRidRestrictions(); _i < _a.length; _i++) {
                            var restriction = _a[_i];
                            fm.icelink.ArrayExtensions.add(list, new fm.icelink.sdp.rtp.SsrcAttribute(this.getSynchronizationSource(), restriction.getKey(), restriction.getValue()));
                        }
                        if (this.getDeactivated()) {
                            fm.icelink.ArrayExtensions.add(list, new fm.icelink.sdp.rtp.SsrcAttribute(this.getSynchronizationSource(), fm.icelink.EncodingInfo.fm_icelink_EncodingInfo___pausedKey, "1"));
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getSize = function () {
                    if (arguments.length == 0) {
                        return this._size;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getSsrcRestrictionAttributeValue = function (ssrcRestrictionAttributes, ridRestrictionKey) {
                    if (arguments.length == 2) {
                        for (var _i = 0, ssrcRestrictionAttributes_1 = ssrcRestrictionAttributes; _i < ssrcRestrictionAttributes_1.length; _i++) {
                            var attribute = ssrcRestrictionAttributes_1[_i];
                            if (((fm.icelink.Global.equals(attribute.getSynchronizationSource(), this.getSynchronizationSource())) && (fm.icelink.Global.equals(attribute.getName(), ridRestrictionKey)))) {
                                return attribute.getValue();
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getSynchronizationSource = function () {
                    if (arguments.length == 0) {
                        return this.__synchronizationSource;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.getWidth = function () {
                    if (arguments.length == 0) {
                        var size = this.getSize();
                        if ((fm.icelink.Global.equals(size, null))) {
                            return -1;
                        }
                        return size.getWidth();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.isEquivalent = function () {
                    if (arguments.length == 1) {
                        var encoding = arguments[0];
                        return this.isEquivalent(encoding, false);
                    }
                    else if (arguments.length == 2) {
                        var encoding = arguments[0];
                        var restrictionsOnly = arguments[1];
                        return fm.icelink.EncodingInfo.isEquivalent(this, encoding, restrictionsOnly);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.parseBitrate = function (ridRestrictionMaxBitrateValue) {
                    if (arguments.length == 1) {
                        var intResult = 0;
                        var _var0 = new fm.icelink.Holder(intResult);
                        var _var1 = fm.icelink.ParseAssistant.tryParseIntegerValue(ridRestrictionMaxBitrateValue, _var0);
                        intResult = _var0.getValue();
                        if (!((!fm.icelink.Global.equals(ridRestrictionMaxBitrateValue, null)) && _var1)) {
                            return -1;
                        }
                        return fm.icelink.MathAssistant.max(0, fm.icelink.MathAssistant.floor(intResult / 1000));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.parseDeactivated = function (ridRestrictionPausedValue) {
                    if (arguments.length == 1) {
                        var intResult = 0;
                        var _var0 = new fm.icelink.Holder(intResult);
                        var _var1 = fm.icelink.ParseAssistant.tryParseIntegerValue(ridRestrictionPausedValue, _var0);
                        intResult = _var0.getValue();
                        if (!((!fm.icelink.Global.equals(ridRestrictionPausedValue, null)) && _var1)) {
                            return false;
                        }
                        return (fm.icelink.Global.equals(intResult, 1));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.parseFrameRate = function (ridRestrictionMaxFramesPerSecondValue) {
                    if (arguments.length == 1) {
                        var doubleResult = 0;
                        var _var0 = new fm.icelink.Holder(doubleResult);
                        var _var1 = fm.icelink.ParseAssistant.tryParseDoubleValue(ridRestrictionMaxFramesPerSecondValue, _var0);
                        doubleResult = _var0.getValue();
                        if (!((!fm.icelink.Global.equals(ridRestrictionMaxFramesPerSecondValue, null)) && _var1)) {
                            return -1;
                        }
                        return fm.icelink.MathAssistant.max(0, doubleResult);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.parseSize = function (ridRestrictionMaxWidthValue, ridRestrictionMaxHeightValue) {
                    if (arguments.length == 2) {
                        var intResult = 0;
                        var num2 = 0;
                        var _var0 = new fm.icelink.Holder(intResult);
                        var _var1 = fm.icelink.ParseAssistant.tryParseIntegerValue(ridRestrictionMaxWidthValue, _var0);
                        intResult = _var0.getValue();
                        var _var2 = new fm.icelink.Holder(num2);
                        var _var3 = fm.icelink.ParseAssistant.tryParseIntegerValue(ridRestrictionMaxHeightValue, _var2);
                        num2 = _var2.getValue();
                        if (!((((!fm.icelink.Global.equals(ridRestrictionMaxWidthValue, null)) && (!fm.icelink.Global.equals(ridRestrictionMaxHeightValue, null))) && _var1) && _var3)) {
                            return null;
                        }
                        return new fm.icelink.Size(fm.icelink.MathAssistant.max(0, intResult), fm.icelink.MathAssistant.max(0, num2));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getRtpStreamId(), null))) {
                            jsonObject["rtpStreamId"] = fm.icelink.JsonSerializer.serializeString(this.getRtpStreamId());
                        }
                        if ((!fm.icelink.Global.equals(this.getSynchronizationSource(), -1))) {
                            jsonObject["synchronizationSource"] = fm.icelink.JsonSerializer.serializeLong(this.getSynchronizationSource());
                        }
                        if (this.getDeactivated()) {
                            jsonObject["deactivated"] = fm.icelink.JsonSerializer.serializeBoolean(this.getDeactivated());
                        }
                        if ((!fm.icelink.Global.equals(this.getBitrate(), -1))) {
                            jsonObject["bitrate"] = fm.icelink.JsonSerializer.serializeInteger(this.getBitrate());
                        }
                        if ((!fm.icelink.Global.equals(this.getFrameRate(), -1))) {
                            jsonObject["frameRate"] = fm.icelink.JsonSerializer.serializeDouble(this.getFrameRate());
                        }
                        if ((!fm.icelink.Global.equals(this.getSize(), null))) {
                            jsonObject["size"] = fm.icelink.Size.toJson(this.getSize());
                        }
                        if ((!fm.icelink.Global.equals(this.getScale(), -1))) {
                            jsonObject["scale"] = fm.icelink.JsonSerializer.serializeDouble(this.getScale());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.setBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__bitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.setDeactivated = function (value) {
                    if (arguments.length == 1) {
                        this._deactivated = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.setFrameRate = function (value) {
                    if (arguments.length == 1) {
                        this.__frameRate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.setRtpStreamId = function (value) {
                    if (arguments.length == 1) {
                        this._rtpStreamId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.setScale = function (value) {
                    if (arguments.length == 1) {
                        this.__scale = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.setSdpRidRestrictions = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(value, null))) {
                            this.setBitrate(this.parseBitrate(this.getRidRestrictionValue(value, fm.icelink.sdp.rtp.RidRestriction.getMaxBitrateKey())));
                            this.setFrameRate(this.parseFrameRate(this.getRidRestrictionValue(value, fm.icelink.sdp.rtp.RidRestriction.getMaxFramesPerSecondKey())));
                            this.setSize(this.parseSize(this.getRidRestrictionValue(value, fm.icelink.sdp.rtp.RidRestriction.getMaxWidthKey()), this.getRidRestrictionValue(value, fm.icelink.sdp.rtp.RidRestriction.getMaxHeightKey())));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.setSdpSimulcastStreamId = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            this.setRtpStreamId(null);
                            this.setDeactivated(false);
                        }
                        else {
                            this.setRtpStreamId(value.getId());
                            this.setDeactivated(value.getPaused());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.setSdpSsrcRestrictionAttributes = function (value) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(value, null))) {
                            this.setDeactivated(this.parseDeactivated(this.getSsrcRestrictionAttributeValue(value, fm.icelink.EncodingInfo.fm_icelink_EncodingInfo___pausedKey)));
                            this.setBitrate(this.parseBitrate(this.getSsrcRestrictionAttributeValue(value, fm.icelink.sdp.rtp.RidRestriction.getMaxBitrateKey())));
                            this.setFrameRate(this.parseFrameRate(this.getSsrcRestrictionAttributeValue(value, fm.icelink.sdp.rtp.RidRestriction.getMaxFramesPerSecondKey())));
                            this.setSize(this.parseSize(this.getSsrcRestrictionAttributeValue(value, fm.icelink.sdp.rtp.RidRestriction.getMaxWidthKey()), this.getSsrcRestrictionAttributeValue(value, fm.icelink.sdp.rtp.RidRestriction.getMaxHeightKey())));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.setSize = function (value) {
                    if (arguments.length == 1) {
                        this._size = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.setSynchronizationSource = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__synchronizationSource = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.EncodingInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.toSdpRidAttribute = function () {
                    if (arguments.length == 1) {
                        var direction = arguments[0];
                        return this.toSdpRidAttribute(direction, true);
                    }
                    else if (arguments.length == 2) {
                        var direction = arguments[0];
                        var includeRestrictions = arguments[1];
                        return fm.icelink.EncodingInfo.toSdpRidAttribute(this, direction, includeRestrictions);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.prototype.toString = function () {
                    if (arguments.length == 0) {
                        var flag = false;
                        var list = new Array();
                        var rtpStreamId = this.getRtpStreamId();
                        if ((!fm.icelink.Global.equals(rtpStreamId, null))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("RTP Stream ID: {0}", rtpStreamId));
                        }
                        var synchronizationSource = this.getSynchronizationSource();
                        if ((!fm.icelink.Global.equals(synchronizationSource, -1))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Synchronization Source: {0}", fm.icelink.NumberExtensions.toString(synchronizationSource)));
                        }
                        var deactivated = this.getDeactivated();
                        if (deactivated) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Deactivated: {0}", fm.icelink.BooleanExtensions.toString(deactivated)));
                        }
                        var bitrate = this.getBitrate();
                        if ((!fm.icelink.Global.equals(bitrate, -1))) {
                            flag = true;
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Bitrate: {0}", fm.icelink.NumberExtensions.toString(bitrate)));
                        }
                        var frameRate = this.getFrameRate();
                        if ((!fm.icelink.Global.equals(frameRate, -1))) {
                            flag = true;
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Frame Rate: {0}", fm.icelink.NumberExtensions.toString(frameRate)));
                        }
                        var size = this.getSize();
                        if ((!fm.icelink.Global.equals(size, null))) {
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Size: {0}", size.toString()));
                        }
                        var scale = this.getScale();
                        if ((!fm.icelink.Global.equals(scale, -1))) {
                            flag = true;
                            fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Scale: {0}", fm.icelink.NumberExtensions.toString(scale)));
                            if ((!fm.icelink.Global.equals(scale, 1))) {
                                var scaledSize = this.getScaledSize();
                                if ((!fm.icelink.Global.equals(scaledSize, null))) {
                                    fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.format("Scaled Size: {0}", scaledSize.toString()));
                                }
                            }
                        }
                        var str2 = fm.icelink.StringExtensions.join(", ", fm.icelink.ArrayExtensions.toArray(list));
                        if (!flag) {
                            str2 = fm.icelink.StringExtensions.trim(fm.icelink.StringExtensions.format("{0} [Unrestricted]", str2));
                        }
                        return str2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                EncodingInfo.fmicelinkEncodingInfoInitialize = function () {
                    if (!fm.icelink.EncodingInfo.__fmicelinkEncodingInfoInitialized && !fm.icelink.EncodingInfo.__fmicelinkEncodingInfoInitializing) {
                        fm.icelink.EncodingInfo.__fmicelinkEncodingInfoInitializing = true;
                        fm.icelink.EncodingInfo.fm_icelink_EncodingInfo___pausedKey = "paused";
                        fm.icelink.EncodingInfo.__fmicelinkEncodingInfoInitialized = true;
                        fm.icelink.EncodingInfo.__fmicelinkEncodingInfoInitializing = false;
                    }
                };
                EncodingInfo.__fmicelinkEncodingInfoInitialized = false;
                EncodingInfo.__fmicelinkEncodingInfoInitializing = false;
                return EncodingInfo;
            }(fm.icelink.Info));
            icelink.EncodingInfo = EncodingInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaStreamInfo =  (function (_super) {
                __extends(MediaStreamInfo, _super);
                function MediaStreamInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaStreamInfoInit();
                        _this.__localBandwidth = -1;
                        _this.__remoteBandwidth = -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaStreamInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaStreamInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaStreamInfo.prototype.fmicelinkMediaStreamInfoInit = function () {
                    this.__localBandwidth = 0;
                    this.__remoteBandwidth = 0;
                    this._maxFrameHeight = 0;
                    this._maxFrameWidth = 0;
                    this._receiveDisabled = false;
                    this._sendDisabled = false;
                    this._sendMuted = false;
                };
                MediaStreamInfo.fromJson = function (mediaStreamInfoJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaStreamInfoJson, function () {
                            return new fm.icelink.MediaStreamInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.fromJsonArray = function (mediaStreamInfosJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(mediaStreamInfosJson, fm.icelink.MediaStreamInfo.fromJson.bind(fm.icelink.MediaStreamInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.toJson = function (mediaStreamInfo) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(mediaStreamInfo, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.toJsonArray = function (mediaStreamInfos) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(mediaStreamInfos, fm.icelink.MediaStreamInfo.toJson.bind(fm.icelink.MediaStreamInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var _var0 = key;
                        do {
                            if (_var0 == "sendMuted") {
                                this.setSendMuted(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                break;
                            }
                            else if (_var0 == "sendDisabled") {
                                this.setSendDisabled(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                break;
                            }
                            else if (_var0 == "receiveDisabled") {
                                this.setReceiveDisabled(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                break;
                            }
                            else if (_var0 == "sendFormats") {
                                this.setSendFormats(fm.icelink.FormatInfo.fromJsonArray(valueJson));
                                break;
                            }
                            else if (_var0 == "receiveFormats") {
                                this.setReceiveFormats(fm.icelink.FormatInfo.fromJsonArray(valueJson));
                                break;
                            }
                            else if (_var0 == "sendEncodings") {
                                this.setSendEncodings(fm.icelink.EncodingInfo.fromJsonArray(valueJson));
                                break;
                            }
                            else if (_var0 == "receiveEncodings") {
                                this.setReceiveEncodings(fm.icelink.EncodingInfo.fromJsonArray(valueJson));
                                break;
                            }
                            else if (_var0 == "localBandwidth") {
                                this.setLocalBandwidth(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "remoteBandwidth") {
                                this.setRemoteBandwidth(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "maxFrameWidth") {
                                this.setMaxFrameWidth(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "maxFrameHeight") {
                                this.setMaxFrameHeight(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getDirection = function () {
                    if (arguments.length == 0) {
                        var directionString = "inactive";
                        return fm.icelink.StreamDirectionHelper.setReceiveDisabled(fm.icelink.StreamDirectionHelper.setSendDisabled(directionString, this.getSendDisabled()), this.getReceiveDisabled());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getLocalBandwidth = function () {
                    if (arguments.length == 0) {
                        return this.__localBandwidth;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getMaxFrameHeight = function () {
                    if (arguments.length == 0) {
                        return this._maxFrameHeight;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getMaxFrameWidth = function () {
                    if (arguments.length == 0) {
                        return this._maxFrameWidth;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getReceiveDisabled = function () {
                    if (arguments.length == 0) {
                        return this._receiveDisabled;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getReceiveEncodings = function () {
                    if (arguments.length == 0) {
                        return this._receiveEncodings;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getReceiveFormats = function () {
                    if (arguments.length == 0) {
                        return this._receiveFormats;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getRemoteBandwidth = function () {
                    if (arguments.length == 0) {
                        return this.__remoteBandwidth;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getSendDisabled = function () {
                    if (arguments.length == 0) {
                        return this._sendDisabled;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getSendEncodings = function () {
                    if (arguments.length == 0) {
                        return this._sendEncodings;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getSendFormats = function () {
                    if (arguments.length == 0) {
                        return this._sendFormats;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.getSendMuted = function () {
                    if (arguments.length == 0) {
                        return this._sendMuted;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if (this.getSendMuted()) {
                            jsonObject["sendMuted"] = fm.icelink.JsonSerializer.serializeBoolean(this.getSendMuted());
                        }
                        if (this.getSendDisabled()) {
                            jsonObject["sendDisabled"] = fm.icelink.JsonSerializer.serializeBoolean(this.getSendDisabled());
                        }
                        if (this.getReceiveDisabled()) {
                            jsonObject["receiveDisabled"] = fm.icelink.JsonSerializer.serializeBoolean(this.getReceiveDisabled());
                        }
                        if ((!fm.icelink.Global.equals(this.getSendFormats(), null))) {
                            jsonObject["sendFormats"] = fm.icelink.FormatInfo.toJsonArray(this.getSendFormats());
                        }
                        if ((!fm.icelink.Global.equals(this.getReceiveFormats(), null))) {
                            jsonObject["receiveFormats"] = fm.icelink.FormatInfo.toJsonArray(this.getReceiveFormats());
                        }
                        if ((!fm.icelink.Global.equals(this.getSendEncodings(), null))) {
                            jsonObject["sendEncodings"] = fm.icelink.EncodingInfo.toJsonArray(this.getSendEncodings());
                        }
                        if ((!fm.icelink.Global.equals(this.getReceiveEncodings(), null))) {
                            jsonObject["receiveEncodings"] = fm.icelink.EncodingInfo.toJsonArray(this.getReceiveEncodings());
                        }
                        if ((!fm.icelink.Global.equals(this.getLocalBandwidth(), -1))) {
                            jsonObject["localBandwidth"] = fm.icelink.JsonSerializer.serializeInteger(this.getLocalBandwidth());
                        }
                        if ((!fm.icelink.Global.equals(this.getRemoteBandwidth(), -1))) {
                            jsonObject["remoteBandwidth"] = fm.icelink.JsonSerializer.serializeInteger(this.getRemoteBandwidth());
                        }
                        if ((!fm.icelink.Global.equals(this.getMaxFrameWidth(), 0))) {
                            jsonObject["maxFrameWidth"] = fm.icelink.JsonSerializer.serializeInteger(this.getMaxFrameWidth());
                        }
                        if ((!fm.icelink.Global.equals(this.getMaxFrameHeight(), 0))) {
                            jsonObject["maxFrameHeight"] = fm.icelink.JsonSerializer.serializeInteger(this.getMaxFrameHeight());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setDirection = function (value) {
                    if (arguments.length == 1) {
                        this.setSendDisabled(fm.icelink.StreamDirectionHelper.isSendDisabled(value));
                        this.setReceiveDisabled(fm.icelink.StreamDirectionHelper.isReceiveDisabled(value));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setLocalBandwidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__localBandwidth = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setMaxFrameHeight = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._maxFrameHeight = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setMaxFrameWidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._maxFrameWidth = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setReceiveDisabled = function (value) {
                    if (arguments.length == 1) {
                        this._receiveDisabled = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setReceiveEncodings = function (value) {
                    if (arguments.length == 1) {
                        this._receiveEncodings = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setReceiveFormats = function (value) {
                    if (arguments.length == 1) {
                        this._receiveFormats = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setRemoteBandwidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__remoteBandwidth = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setSendDisabled = function (value) {
                    if (arguments.length == 1) {
                        this._sendDisabled = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setSendEncodings = function (value) {
                    if (arguments.length == 1) {
                        this._sendEncodings = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setSendFormats = function (value) {
                    if (arguments.length == 1) {
                        this._sendFormats = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.setSendMuted = function (value) {
                    if (arguments.length == 1) {
                        this._sendMuted = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaStreamInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaStreamInfo;
            }(fm.icelink.StreamInfo));
            icelink.MediaStreamInfo = MediaStreamInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaStreamStats =  (function (_super) {
                __extends(MediaStreamStats, _super);
                function MediaStreamStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaStreamStatsInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaStreamStats.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaStreamStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaStreamStats.prototype.fmicelinkMediaStreamStatsInit = function () {
                    this._maxReceiveBitrate = 0;
                    this._maxSendBitrate = 0;
                };
                MediaStreamStats.fromJson = function (mediaStreamJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaStreamJson, function () {
                            return new fm.icelink.MediaStreamStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.fromJsonArray = function (mediaStreamsJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(mediaStreamsJson, fm.icelink.MediaStreamStats.fromJson.bind(fm.icelink.MediaStreamStats));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.toJson = function (mediaStream) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(mediaStream, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.toJsonArray = function (mediaStreams) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(mediaStreams, fm.icelink.MediaStreamStats.toJson.bind(fm.icelink.MediaStreamStats));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "direction"))) {
                                if ((fm.icelink.Global.equals(str, "maxSendBitrate"))) {
                                    this.setMaxSendBitrate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "maxReceiveBitrate"))) {
                                        this.setMaxReceiveBitrate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "senders"))) {
                                            this.setSenders(fm.icelink.MediaSenderStats.fromJsonArray(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "receivers"))) {
                                                this.setReceivers(fm.icelink.MediaReceiverStats.fromJsonArray(valueJson));
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                this.setDirection(fm.icelink.StreamDirectionHelper.directionFromString(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.getDirection = function () {
                    if (arguments.length == 0) {
                        return this._direction;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.getMaxReceiveBitrate = function () {
                    if (arguments.length == 0) {
                        return this._maxReceiveBitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.getMaxSendBitrate = function () {
                    if (arguments.length == 0) {
                        return this._maxSendBitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.getReceiver = function () {
                    if (arguments.length == 0) {
                        var receivers = this.getReceivers();
                        if (((fm.icelink.Global.equals(receivers, null)) || (fm.icelink.Global.equals(receivers.length, 0)))) {
                            return null;
                        }
                        return receivers[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.getReceivers = function () {
                    if (arguments.length == 0) {
                        return this._receivers;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.getSender = function () {
                    if (arguments.length == 0) {
                        var senders = this.getSenders();
                        if (((fm.icelink.Global.equals(senders, null)) || (fm.icelink.Global.equals(senders.length, 0)))) {
                            return null;
                        }
                        return senders[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.getSenders = function () {
                    if (arguments.length == 0) {
                        return this._senders;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        jsonObject["direction"] = fm.icelink.JsonSerializer.serializeString(fm.icelink.StreamDirectionHelper.directionToString(this.getDirection()));
                        jsonObject["maxSendBitrate"] = fm.icelink.JsonSerializer.serializeInteger(this.getMaxSendBitrate());
                        jsonObject["maxReceiveBitrate"] = fm.icelink.JsonSerializer.serializeInteger(this.getMaxReceiveBitrate());
                        if ((!fm.icelink.Global.equals(this.getSenders(), null))) {
                            jsonObject["senders"] = fm.icelink.MediaSenderStats.toJsonArray(this.getSenders());
                        }
                        if ((!fm.icelink.Global.equals(this.getReceivers(), null))) {
                            jsonObject["receivers"] = fm.icelink.MediaReceiverStats.toJsonArray(this.getReceivers());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.setDirection = function (value) {
                    if (arguments.length == 1) {
                        this._direction = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.setMaxReceiveBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._maxReceiveBitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.setMaxSendBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._maxSendBitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.setReceivers = function (value) {
                    if (arguments.length == 1) {
                        this._receivers = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.setSenders = function (value) {
                    if (arguments.length == 1) {
                        this._senders = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaStreamStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaStreamStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaStreamStats;
            }(fm.icelink.StreamStats));
            icelink.MediaStreamStats = MediaStreamStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaTrackInfo =  (function (_super) {
                __extends(MediaTrackInfo, _super);
                function MediaTrackInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaTrackInfoInit();
                    }
                    else if (__arguments.length == 2) {
                        var stats = __arguments[0];
                        var lastStats = __arguments[1];
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaTrackInfoInit();
                        _super.prototype.setId.call(_this, stats.getId());
                        _this.setDetached(((fm.icelink.Global.equals(lastStats, null)) ? stats.getDetached() : fm.icelink.Info.processBoolean(stats.getDetached(), lastStats.getDetached())));
                        _this.setMuted(((fm.icelink.Global.equals(lastStats, null)) ? stats.getMuted() : fm.icelink.Info.processBoolean(stats.getMuted(), lastStats.getMuted())));
                        _this.setStopped(((fm.icelink.Global.equals(lastStats, null)) ? stats.getStopped() : fm.icelink.Info.processBoolean(stats.getStopped(), lastStats.getStopped())));
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaTrackInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaTrackInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaTrackInfo.prototype.fmicelinkMediaTrackInfoInit = function () {
                    this._detached = false;
                    this._muted = false;
                    this._stopped = false;
                };
                MediaTrackInfo.fromJson = function (mediaTrackInfoJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaTrackInfoJson, function () {
                            return new fm.icelink.MediaTrackInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.fromJsonArray = function (mediaTrackInfosJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(mediaTrackInfosJson, fm.icelink.MediaTrackInfo.fromJson.bind(fm.icelink.MediaTrackInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.toJson = function (mediaTrackInfo) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(mediaTrackInfo, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.toJsonArray = function (mediaTrackInfos) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(mediaTrackInfos, fm.icelink.MediaTrackInfo.toJson.bind(fm.icelink.MediaTrackInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "stopped"))) {
                                if ((fm.icelink.Global.equals(str, "detached"))) {
                                    this.setDetached(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "muted"))) {
                                        this.setMuted(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    }
                                }
                            }
                            else {
                                this.setMuted(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.prototype.getDetached = function () {
                    if (arguments.length == 0) {
                        return this._detached;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.prototype.getMuted = function () {
                    if (arguments.length == 0) {
                        return this._muted;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.prototype.getStopped = function () {
                    if (arguments.length == 0) {
                        return this._stopped;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((this.getStopped() != null)) {
                            jsonObject["stopped"] = fm.icelink.JsonSerializer.serializeBoolean(this.getStopped());
                        }
                        if ((this.getDetached() != null)) {
                            jsonObject["detached"] = fm.icelink.JsonSerializer.serializeBoolean(this.getDetached());
                        }
                        if ((this.getMuted() != null)) {
                            jsonObject["muted"] = fm.icelink.JsonSerializer.serializeBoolean(this.getMuted());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.prototype.setDetached = function (value) {
                    if (arguments.length == 1) {
                        this._detached = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.prototype.setMuted = function (value) {
                    if (arguments.length == 1) {
                        this._muted = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.prototype.setStopped = function (value) {
                    if (arguments.length == 1) {
                        this._stopped = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaTrackInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaTrackInfo;
            }(fm.icelink.Info));
            icelink.MediaTrackInfo = MediaTrackInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaTrackStats =  (function (_super) {
                __extends(MediaTrackStats, _super);
                function MediaTrackStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaTrackStatsInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaTrackStats.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaTrackStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaTrackStats.prototype.fmicelinkMediaTrackStatsInit = function () {
                    this._bitrate = 0;
                    this._detached = false;
                    this._frameHeight = 0;
                    this._frameRate = 0;
                    this._framesCorrupted = 0;
                    this._framesDecoded = 0;
                    this._framesDropped = 0;
                    this._framesEncoded = 0;
                    this._framesReceived = 0;
                    this._framesSent = 0;
                    this._frameWidth = 0;
                    this._maxBitrate = 0;
                    this._minBitrate = 0;
                    this._muted = false;
                    this._stopped = false;
                };
                MediaTrackStats.fromJson = function (mediaTrackJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaTrackJson, function () {
                            return new fm.icelink.MediaTrackStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.fromJsonArray = function (mediaTracksJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(mediaTracksJson, fm.icelink.MediaTrackStats.fromJson.bind(fm.icelink.MediaTrackStats));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.toJson = function (mediaTrack) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(mediaTrack, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.toJsonArray = function (mediaTracks) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(mediaTracks, fm.icelink.MediaTrackStats.toJson.bind(fm.icelink.MediaTrackStats));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var _var0 = key;
                        do {
                            if (_var0 == "stopped") {
                                this.setStopped(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                break;
                            }
                            else if (_var0 == "detached") {
                                this.setDetached(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                break;
                            }
                            else if (_var0 == "muted") {
                                this.setMuted(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                break;
                            }
                            else if (_var0 == "ssrcs") {
                                this.setSynchronizationSources(fm.icelink.JsonSerializer.deserializeLongArray(valueJson));
                                break;
                            }
                            else if (_var0 == "minBitrate") {
                                this.setMinBitrate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "maxBitrate") {
                                this.setMaxBitrate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "bitrate") {
                                this.setBitrate(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "frameWidth") {
                                this.setFrameWidth(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "frameHeight") {
                                this.setFrameHeight(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "frameRate") {
                                this.setFrameRate(fm.icelink.JsonSerializer.deserializeDouble(valueJson));
                                break;
                            }
                            else if (_var0 == "framesSent") {
                                this.setFramesSent(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "framesReceived") {
                                this.setFramesReceived(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "framesDecoded") {
                                this.setFramesDecoded(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "framesDropped") {
                                this.setFramesDropped(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "framesCorrupted") {
                                this.setFramesCorrupted(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                            else if (_var0 == "framesEncoded") {
                                this.setFramesEncoded(fm.icelink.JsonSerializer.deserializeLong(valueJson));
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getBitrate = function () {
                    if (arguments.length == 0) {
                        return this._bitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getDetached = function () {
                    if (arguments.length == 0) {
                        return this._detached;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getFrameHeight = function () {
                    if (arguments.length == 0) {
                        return this._frameHeight;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getFrameRate = function () {
                    if (arguments.length == 0) {
                        return this._frameRate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getFramesCorrupted = function () {
                    if (arguments.length == 0) {
                        return this._framesCorrupted;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getFramesDecoded = function () {
                    if (arguments.length == 0) {
                        return this._framesDecoded;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getFramesDropped = function () {
                    if (arguments.length == 0) {
                        return this._framesDropped;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getFramesEncoded = function () {
                    if (arguments.length == 0) {
                        return this._framesEncoded;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getFramesReceived = function () {
                    if (arguments.length == 0) {
                        return this._framesReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getFramesSent = function () {
                    if (arguments.length == 0) {
                        return this._framesSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getFrameWidth = function () {
                    if (arguments.length == 0) {
                        return this._frameWidth;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getMaxBitrate = function () {
                    if (arguments.length == 0) {
                        return this._maxBitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getMinBitrate = function () {
                    if (arguments.length == 0) {
                        return this._minBitrate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getMuted = function () {
                    if (arguments.length == 0) {
                        return this._muted;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getRepairedRtpStreamId = function () {
                    if (arguments.length == 0) {
                        var repairedRtpStreamIds = this.getRepairedRtpStreamIds();
                        if (((fm.icelink.Global.equals(repairedRtpStreamIds, null)) || (fm.icelink.Global.equals(repairedRtpStreamIds.length, 0)))) {
                            return null;
                        }
                        return repairedRtpStreamIds[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getRepairedRtpStreamIds = function () {
                    if (arguments.length == 0) {
                        return this._repairedRtpStreamIds;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getRtpStreamId = function () {
                    if (arguments.length == 0) {
                        var rtpStreamIds = this.getRtpStreamIds();
                        if (((fm.icelink.Global.equals(rtpStreamIds, null)) || (fm.icelink.Global.equals(rtpStreamIds.length, 0)))) {
                            return null;
                        }
                        return rtpStreamIds[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getRtpStreamIds = function () {
                    if (arguments.length == 0) {
                        return this._rtpStreamIds;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getStopped = function () {
                    if (arguments.length == 0) {
                        return this._stopped;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getSynchronizationSource = function () {
                    if (arguments.length == 0) {
                        var synchronizationSources = this.getSynchronizationSources();
                        if (((fm.icelink.Global.equals(synchronizationSources, null)) || (fm.icelink.Global.equals(synchronizationSources.length, 0)))) {
                            return 0;
                        }
                        return synchronizationSources[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.getSynchronizationSources = function () {
                    if (arguments.length == 0) {
                        return this._synchronizationSources;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.isEquivalent = function (instance) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(instance, null))) {
                            return false;
                        }
                        return ((((((fm.icelink.Global.equals(instance.getStopped(), this.getStopped())) && (fm.icelink.Global.equals(instance.getDetached(), this.getDetached()))) && ((fm.icelink.Global.equals(instance.getMuted(), this.getMuted())) && (fm.icelink.Global.equals(instance.getSynchronizationSources(), this.getSynchronizationSources())))) && (((fm.icelink.Global.equals(instance.getMinBitrate(), this.getMinBitrate())) && (fm.icelink.Global.equals(instance.getMaxBitrate(), this.getMaxBitrate()))) && ((fm.icelink.Global.equals(instance.getBitrate(), this.getBitrate())) && (fm.icelink.Global.equals(instance.getFrameWidth(), this.getFrameWidth()))))) && ((((fm.icelink.Global.equals(instance.getFrameHeight(), this.getFrameHeight())) && (fm.icelink.Global.equals(instance.getFrameRate(), this.getFrameRate()))) && ((fm.icelink.Global.equals(instance.getFramesSent(), this.getFramesSent())) && (fm.icelink.Global.equals(instance.getFramesReceived(), this.getFramesReceived())))) && (((fm.icelink.Global.equals(instance.getFramesDecoded(), this.getFramesDecoded())) && (fm.icelink.Global.equals(instance.getFramesDropped(), this.getFramesDropped()))) && (fm.icelink.Global.equals(instance.getFramesCorrupted(), this.getFramesCorrupted()))))) && (fm.icelink.Global.equals(instance.getFramesEncoded(), this.getFramesEncoded())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        jsonObject["stopped"] = fm.icelink.JsonSerializer.serializeBoolean(this.getStopped());
                        jsonObject["detached"] = fm.icelink.JsonSerializer.serializeBoolean(this.getDetached());
                        jsonObject["muted"] = fm.icelink.JsonSerializer.serializeBoolean(this.getMuted());
                        jsonObject["ssrcs"] = fm.icelink.JsonSerializer.serializeLongArray(this.getSynchronizationSources());
                        jsonObject["minBitrate"] = fm.icelink.JsonSerializer.serializeInteger(this.getMinBitrate());
                        jsonObject["maxBitrate"] = fm.icelink.JsonSerializer.serializeInteger(this.getMaxBitrate());
                        jsonObject["bitrate"] = fm.icelink.JsonSerializer.serializeInteger(this.getBitrate());
                        jsonObject["frameWidth"] = fm.icelink.JsonSerializer.serializeInteger(this.getFrameWidth());
                        jsonObject["frameHeight"] = fm.icelink.JsonSerializer.serializeInteger(this.getFrameHeight());
                        jsonObject["frameRate"] = fm.icelink.JsonSerializer.serializeDouble(this.getFrameRate());
                        jsonObject["framesSent"] = fm.icelink.JsonSerializer.serializeLong(this.getFramesSent());
                        jsonObject["framesReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getFramesReceived());
                        jsonObject["framesDecoded"] = fm.icelink.JsonSerializer.serializeLong(this.getFramesDecoded());
                        jsonObject["framesDropped"] = fm.icelink.JsonSerializer.serializeLong(this.getFramesDropped());
                        jsonObject["framesCorrupted"] = fm.icelink.JsonSerializer.serializeLong(this.getFramesCorrupted());
                        jsonObject["framesEncoded"] = fm.icelink.JsonSerializer.serializeLong(this.getFramesEncoded());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setDetached = function (value) {
                    if (arguments.length == 1) {
                        this._detached = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setFrameHeight = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._frameHeight = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setFrameRate = function (value) {
                    if (arguments.length == 1) {
                        this._frameRate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setFramesCorrupted = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._framesCorrupted = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setFramesDecoded = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._framesDecoded = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setFramesDropped = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._framesDropped = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setFramesEncoded = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._framesEncoded = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setFramesReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._framesReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setFramesSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._framesSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setFrameWidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._frameWidth = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setMaxBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._maxBitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setMinBitrate = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._minBitrate = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setMuted = function (value) {
                    if (arguments.length == 1) {
                        this._muted = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setRepairedRtpStreamIds = function (value) {
                    if (arguments.length == 1) {
                        this._repairedRtpStreamIds = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setRtpStreamIds = function (value) {
                    if (arguments.length == 1) {
                        this._rtpStreamIds = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setStopped = function (value) {
                    if (arguments.length == 1) {
                        this._stopped = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.setSynchronizationSources = function (value) {
                    if (arguments.length == 1) {
                        this._synchronizationSources = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaTrackStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaTrackStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaTrackStats;
            }(fm.icelink.BaseStats));
            icelink.MediaTrackStats = MediaTrackStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaSourceInfo =  (function (_super) {
                __extends(MediaSourceInfo, _super);
                function MediaSourceInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaSourceInfoInit();
                    }
                    else if (__arguments.length == 2) {
                        var stats = __arguments[0];
                        var lastStats = __arguments[1];
                        _this = _super.call(this) || this;
                        _this.fmicelinkMediaSourceInfoInit();
                        var flag = (fm.icelink.Global.equals(lastStats, null));
                        _super.prototype.setId.call(_this, stats.getId());
                        _this.setTag((flag ? stats.getTag() : fm.icelink.Info.processString(stats.getTag(), (flag ? null : lastStats.getTag()))));
                        _this.setLabel((flag ? stats.getLabel() : fm.icelink.Info.processString(stats.getLabel(), (flag ? null : lastStats.getLabel()))));
                        _this.setMuted((flag ? stats.getMuted() : fm.icelink.Info.processBoolean(stats.getMuted(), lastStats.getMuted())));
                        _this.setInputId((flag ? stats.getInputId() : fm.icelink.Info.processString(stats.getInputId(), lastStats.getInputId())));
                        _this.setInputName((flag ? stats.getInputName() : fm.icelink.Info.processString(stats.getInputName(), lastStats.getInputName())));
                        if (((!fm.icelink.Global.equals(stats.getOutputFormat(), null)) && (flag || !stats.getOutputFormat().isEquivalent(lastStats.getOutputFormat())))) {
                            _this.setOutputFormat(new fm.icelink.FormatInfo(stats.getOutputFormat().getName(), stats.getOutputFormat().getClockRate(), stats.getOutputFormat().getChannelCount()));
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                MediaSourceInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaSourceInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaSourceInfo.prototype.fmicelinkMediaSourceInfoInit = function () {
                    this._muted = false;
                };
                MediaSourceInfo.fromJson = function (mediaSourceInfoJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(mediaSourceInfoJson, function () {
                            return new fm.icelink.MediaSourceInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.fromJsonArray = function (mediaSourceInfosJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(mediaSourceInfosJson, fm.icelink.MediaSourceInfo.fromJson.bind(fm.icelink.MediaSourceInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.toJson = function (mediaSourceInfo) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(mediaSourceInfo, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.toJsonArray = function (mediaSourceInfos) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(mediaSourceInfos, fm.icelink.MediaSourceInfo.toJson.bind(fm.icelink.MediaSourceInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "tag"))) {
                                if ((fm.icelink.Global.equals(str, "label"))) {
                                    this.setLabel(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "muted"))) {
                                        this.setMuted(fm.icelink.JsonSerializer.deserializeBoolean(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "inputId"))) {
                                            this.setInputId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "inputName"))) {
                                                this.setInputName(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                            }
                                            else {
                                                if ((fm.icelink.Global.equals(str, "outputFormat"))) {
                                                    this.setOutputFormat(fm.icelink.FormatInfo.fromJson(valueJson));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                this.setTag(fm.icelink.JsonSerializer.deserializeString(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.getInputId = function () {
                    if (arguments.length == 0) {
                        return this._inputId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.getInputName = function () {
                    if (arguments.length == 0) {
                        return this._inputName;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.getLabel = function () {
                    if (arguments.length == 0) {
                        return this._label;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.getMuted = function () {
                    if (arguments.length == 0) {
                        return this._muted;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.getOutputFormat = function () {
                    if (arguments.length == 0) {
                        return this._outputFormat;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.getTag = function () {
                    if (arguments.length == 0) {
                        return this._tag;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getTag())) {
                            jsonObject["tag"] = fm.icelink.JsonSerializer.serializeString(this.getTag());
                        }
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getLabel())) {
                            jsonObject["label"] = fm.icelink.JsonSerializer.serializeString(this.getLabel());
                        }
                        if ((this.getMuted() != null)) {
                            jsonObject["muted"] = fm.icelink.JsonSerializer.serializeBoolean(this.getMuted());
                        }
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getInputId())) {
                            jsonObject["inputId"] = fm.icelink.JsonSerializer.serializeString(this.getInputId());
                        }
                        if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getInputName())) {
                            jsonObject["inputName"] = fm.icelink.JsonSerializer.serializeString(this.getInputName());
                        }
                        if ((!fm.icelink.Global.equals(this.getOutputFormat(), null))) {
                            jsonObject["outputFormat"] = fm.icelink.FormatInfo.toJson(this.getOutputFormat());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.setInputId = function (value) {
                    if (arguments.length == 1) {
                        this._inputId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.setInputName = function (value) {
                    if (arguments.length == 1) {
                        this._inputName = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.setLabel = function (value) {
                    if (arguments.length == 1) {
                        this._label = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.setMuted = function (value) {
                    if (arguments.length == 1) {
                        this._muted = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.setOutputFormat = function (value) {
                    if (arguments.length == 1) {
                        this._outputFormat = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.setTag = function (value) {
                    if (arguments.length == 1) {
                        this._tag = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                MediaSourceInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.MediaSourceInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaSourceInfo;
            }(fm.icelink.Info));
            icelink.MediaSourceInfo = MediaSourceInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Point =  (function () {
                function Point() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkPointInit();
                        this.setX(0);
                        this.setY(0);
                    }
                    else if (__arguments.length == 2) {
                        var x = __arguments[0];
                        var y = __arguments[1];
                        this.fmicelinkPointInit();
                        this.setX(x);
                        this.setY(y);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Point.prototype.getTypeString = function () {
                    return '[fm.icelink.Point]';
                };
                Point.prototype.fmicelinkPointInit = function () {
                    this.__x = 0;
                    this.__y = 0;
                };
                Point.fromJson = function (pointJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(pointJson, function () {
                            return new fm.icelink.Point();
                        }, function (point, name, valueJson) {
                            var str = name;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "x"))) {
                                    if ((fm.icelink.Global.equals(str, "y"))) {
                                        point.setY(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    }
                                }
                                else {
                                    point.setX(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.getEmpty = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(fm.icelink.Point.fm_icelink_Point___empty, null))) {
                            fm.icelink.Point.fm_icelink_Point___empty = new fm.icelink.Point();
                        }
                        return fm.icelink.Point.fm_icelink_Point___empty;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.isEquivalent = function (point1, point2) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(point1, point2))) {
                            return true;
                        }
                        if (((fm.icelink.Global.equals(point1, null)) || (fm.icelink.Global.equals(point2, null)))) {
                            return false;
                        }
                        return fm.icelink.Point.isEquivalentNoCheck(point1, point2);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.isEquivalentNoCheck = function (point1, point2) {
                    if (arguments.length == 2) {
                        return ((fm.icelink.Global.equals(point1.getX(), point2.getX())) && (fm.icelink.Global.equals(point1.getY(), point2.getY())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.toJson = function (point) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(point, function (obj, jsonObj) {
                            if ((!fm.icelink.Global.equals(point.getX(), -1))) {
                                jsonObj["x"] = fm.icelink.JsonSerializer.serializeInteger(point.getX());
                            }
                            if ((!fm.icelink.Global.equals(point.getY(), -1))) {
                                jsonObj["y"] = fm.icelink.JsonSerializer.serializeInteger(point.getY());
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.prototype.getX = function () {
                    if (arguments.length == 0) {
                        return this.__x;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.prototype.getY = function () {
                    if (arguments.length == 0) {
                        return this.__y;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.prototype.isEquivalent = function (point) {
                    if (arguments.length == 1) {
                        return fm.icelink.Point.isEquivalent(this, point);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.prototype.setX = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__x = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.prototype.setY = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this.__y = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Point.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Point.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.format("{0},{1}", fm.icelink.NumberExtensions.toString(this.getX()), fm.icelink.NumberExtensions.toString(this.getY()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Point;
            }());
            icelink.Point = Point;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Rectangle =  (function () {
                function Rectangle() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.setOrigin(fm.icelink.Point.getEmpty());
                        this.setSize(fm.icelink.Size.getEmpty());
                    }
                    else if (__arguments.length == 2) {
                        var origin_3 = __arguments[0];
                        var size = __arguments[1];
                        this.setOrigin(origin_3);
                        this.setSize(size);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Rectangle.prototype.getTypeString = function () {
                    return '[fm.icelink.Rectangle]';
                };
                Rectangle.fromJson = function (rectangleJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(rectangleJson, function () {
                            return new fm.icelink.Rectangle();
                        }, function (rectangle, name, valueJson) {
                            var str = name;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "origin"))) {
                                    if ((fm.icelink.Global.equals(str, "size"))) {
                                        rectangle.setSize(fm.icelink.Size.fromJson(valueJson));
                                    }
                                }
                                else {
                                    rectangle.setOrigin(fm.icelink.Point.fromJson(valueJson));
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.getEmpty = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(fm.icelink.Rectangle.fm_icelink_Rectangle___empty, null))) {
                            fm.icelink.Rectangle.fm_icelink_Rectangle___empty = new fm.icelink.Rectangle();
                        }
                        return fm.icelink.Rectangle.fm_icelink_Rectangle___empty;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.isEquivalent = function (rectangle1, rectangle2) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(rectangle1, rectangle2))) {
                            return true;
                        }
                        if (((fm.icelink.Global.equals(rectangle1, null)) || (fm.icelink.Global.equals(rectangle2, null)))) {
                            return false;
                        }
                        return fm.icelink.Rectangle.isEquivalentNoCheck(rectangle1, rectangle2);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.isEquivalentNoCheck = function (rectangle1, rectangle2) {
                    if (arguments.length == 2) {
                        return (fm.icelink.Point.isEquivalent(rectangle1.getOrigin(), rectangle2.getOrigin()) && fm.icelink.Size.isEquivalent(rectangle1.getSize(), rectangle2.getSize()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.toJson = function (rectangle) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(rectangle, function (obj, jsonObj) {
                            if ((!fm.icelink.Global.equals(rectangle.getOrigin(), null))) {
                                jsonObj["origin"] = fm.icelink.Point.toJson(rectangle.getOrigin());
                            }
                            if ((!fm.icelink.Global.equals(rectangle.getSize(), null))) {
                                jsonObj["size"] = fm.icelink.Size.toJson(rectangle.getSize());
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.getHeight = function () {
                    if (arguments.length == 0) {
                        return this.getSize().getHeight();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.getOrigin = function () {
                    if (arguments.length == 0) {
                        return this.__origin;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.getSize = function () {
                    if (arguments.length == 0) {
                        return this.__size;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.getWidth = function () {
                    if (arguments.length == 0) {
                        return this.getSize().getWidth();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.getX = function () {
                    if (arguments.length == 0) {
                        return this.getOrigin().getX();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.getY = function () {
                    if (arguments.length == 0) {
                        return this.getOrigin().getY();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.isEquivalent = function (rectangle) {
                    if (arguments.length == 1) {
                        return fm.icelink.Rectangle.isEquivalent(this, rectangle);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.setOrigin = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            throw new fm.icelink.Exception("Origin cannot be null.");
                        }
                        this.__origin = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.setSize = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            throw new fm.icelink.Exception("Size cannot be null.");
                        }
                        this.__size = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Rectangle.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Rectangle.prototype.toString = function () {
                    if (arguments.length == 0) {
                        var origin_4 = this.getOrigin();
                        var size = this.getSize();
                        return fm.icelink.StringExtensions.format("{0}/{1}", origin_4.toString(), size.toString());
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Rectangle;
            }());
            icelink.Rectangle = Rectangle;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var AddressType =  (function () {
                    function AddressType() {
                    }
                    AddressType.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.AddressType]';
                    };
                    AddressType.getAddressTypeForAddress = function (ipAddress) {
                        if (arguments.length == 1) {
                            var _var0 = fm.icelink.LocalNetwork.getAddressType(ipAddress);
                            do {
                                if (_var0 == fm.icelink.AddressType.IPv4) {
                                    return fm.icelink.sdp.AddressType.getIP4();
                                }
                                else if (_var0 == fm.icelink.AddressType.IPv6) {
                                    return fm.icelink.sdp.AddressType.getIP6();
                                }
                            } while (false);
                            throw new fm.icelink.Exception("Only IPv4 and IPv6 addresses are supported by SDP.");
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AddressType.getIP4 = function () {
                        if (arguments.length == 0) {
                            return "IP4";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AddressType.getIP6 = function () {
                        if (arguments.length == 0) {
                            return "IP6";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return AddressType;
                }());
                sdp.AddressType = AddressType;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var AttributeCategoryWrapper =  (function () {
                    function AttributeCategoryWrapper(value) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var value_52 = __arguments[0];
                            this._value = value_52;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    AttributeCategoryWrapper.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.AttributeCategoryWrapper]';
                    };
                    AttributeCategoryWrapper.prototype.toString = function () {
                        if (arguments.length == 0) {
                            if (this._value == fm.icelink.sdp.AttributeCategory.Normal)
                                return 'Normal';
                            if (this._value == fm.icelink.sdp.AttributeCategory.Caution)
                                return 'Caution';
                            if (this._value == fm.icelink.sdp.AttributeCategory.Identical)
                                return 'Identical';
                            if (this._value == fm.icelink.sdp.AttributeCategory.Sum)
                                return 'Sum';
                            if (this._value == fm.icelink.sdp.AttributeCategory.Transport)
                                return 'Transport';
                            if (this._value == fm.icelink.sdp.AttributeCategory.Inherit)
                                return 'Inherit';
                            if (this._value == fm.icelink.sdp.AttributeCategory.IdenticalPerPT)
                                return 'IdenticalPerPT';
                            if (this._value == fm.icelink.sdp.AttributeCategory.Special)
                                return 'Special';
                            return '';
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return AttributeCategoryWrapper;
                }());
                sdp.AttributeCategoryWrapper = AttributeCategoryWrapper;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var AttributeCollection =  (function () {
                    function AttributeCollection() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            this.__attributes = {};
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    AttributeCollection.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.AttributeCollection]';
                    };
                    AttributeCollection.prototype.addAttribute = function (attribute) {
                        if (arguments.length == 1) {
                            var key = new fm.icelink.sdp.AttributeTypeWrapper(attribute.getAttributeType()).toString();
                            var list = null;
                            var _var0 = new fm.icelink.Holder(list);
                            var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__attributes, key, _var0);
                            list = _var0.getValue();
                            if (!_var1) {
                                list = new Array();
                                fm.icelink.ArrayExtensions.add(list, attribute);
                                fm.icelink.HashExtensions.add(this.__attributes, key, list);
                            }
                            else {
                                fm.icelink.ArrayExtensions.add(list, attribute);
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeCollection.prototype.remove = function () {
                        if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.sdp.Attribute]'))) {
                            var attribute = arguments[0];
                            var flag = false;
                            var list = null;
                            var _var0 = new fm.icelink.Holder(list);
                            var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__attributes, new fm.icelink.sdp.AttributeTypeWrapper(attribute.getAttributeType()).toString(), _var0);
                            list = _var0.getValue();
                            if (_var1) {
                                if ((fm.icelink.Global.equals(list, null))) {
                                    return flag;
                                }
                                flag = fm.icelink.ArrayExtensions.remove(list, attribute);
                                if ((fm.icelink.Global.equals(fm.icelink.ArrayExtensions.getCount(list), 0))) {
                                    fm.icelink.HashExtensions.remove(this.__attributes, new fm.icelink.sdp.AttributeTypeWrapper(attribute.getAttributeType()).toString());
                                }
                            }
                            return flag;
                        }
                        else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                            var attributeType = arguments[0];
                            return fm.icelink.HashExtensions.remove(this.__attributes, new fm.icelink.sdp.AttributeTypeWrapper(attributeType).toString());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeCollection.prototype.replaceAttribute = function (attribute) {
                        if (arguments.length == 1) {
                            var attributeType = attribute.getAttributeType();
                            fm.icelink.HashExtensions.remove(this.__attributes, new fm.icelink.sdp.AttributeTypeWrapper(attributeType).toString());
                            var list = new Array();
                            fm.icelink.ArrayExtensions.add(list, attribute);
                            fm.icelink.HashExtensions.add(this.__attributes, new fm.icelink.sdp.AttributeTypeWrapper(attributeType).toString(), list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeCollection.prototype.toArray = function () {
                        if (arguments.length == 0) {
                            var list = new Array();
                            for (var _i = 0, _a = fm.icelink.HashExtensions.getValues(this.__attributes); _i < _a.length; _i++) {
                                var list2 = _a[_i];
                                fm.icelink.ArrayExtensions.addRange(list, list2);
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeCollection.prototype.tryGetAttribute = function (type, attribute) {
                        if (arguments.length == 2) {
                            var attributes = null;
                            var _var0 = new fm.icelink.Holder(attributes);
                            var _var1 = this.tryGetAttributes(type, _var0);
                            attributes = _var0.getValue();
                            if (_var1) {
                                if ((attributes.length > 0)) {
                                    attribute.setValue(attributes[0]);
                                    return true;
                                }
                                attribute.setValue(null);
                                return false;
                            }
                            attribute.setValue(null);
                            return false;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeCollection.prototype.tryGetAttributes = function (type, attributes) {
                        if (arguments.length == 2) {
                            var list = null;
                            var _var0 = new fm.icelink.Holder(list);
                            var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__attributes, new fm.icelink.sdp.AttributeTypeWrapper(type).toString(), _var0);
                            list = _var0.getValue();
                            if (_var1) {
                                var count = fm.icelink.ArrayExtensions.getCount(list);
                                attributes.setValue(new Array(count));
                                for (var i = 0; (i < count); i++) {
                                    attributes.getValue()[i] = list[i];
                                }
                                return true;
                            }
                            attributes.setValue(new Array(0));
                            return false;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return AttributeCollection;
                }());
                sdp.AttributeCollection = AttributeCollection;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var AttributeCreationArgs =  (function () {
                    function AttributeCreationArgs(value) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var value_53 = __arguments[0];
                            if ((!fm.icelink.Global.equals(value_53, null))) {
                                value_53 = fm.icelink.StringExtensions.trim(value_53);
                            }
                            this.setValue(value_53);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    AttributeCreationArgs.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.AttributeCreationArgs]';
                    };
                    AttributeCreationArgs.prototype.getValue = function () {
                        if (arguments.length == 0) {
                            return this._value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeCreationArgs.prototype.setValue = function (value) {
                        if (arguments.length == 1) {
                            this._value = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return AttributeCreationArgs;
                }());
                sdp.AttributeCreationArgs = AttributeCreationArgs;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var AttributeRegistration =  (function () {
                    function AttributeRegistration(name, sessionLevel, mediaLevel, creationDelegate) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 4) {
                            var name_25 = __arguments[0];
                            var sessionLevel_1 = __arguments[1];
                            var mediaLevel_1 = __arguments[2];
                            var creationDelegate_1 = __arguments[3];
                            this.fmicelinksdpAttributeRegistrationInit();
                            this.setName(name_25);
                            this.setSessionLevel(sessionLevel_1);
                            this.setMediaLevel(mediaLevel_1);
                            this.setCreationDelegate(creationDelegate_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    AttributeRegistration.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.AttributeRegistration]';
                    };
                    AttributeRegistration.prototype.fmicelinksdpAttributeRegistrationInit = function () {
                        this._mediaLevel = false;
                        this._sessionLevel = false;
                    };
                    AttributeRegistration.prototype.getCreationDelegate = function () {
                        if (arguments.length == 0) {
                            return this._creationDelegate;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeRegistration.prototype.getMediaLevel = function () {
                        if (arguments.length == 0) {
                            return this._mediaLevel;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeRegistration.prototype.getName = function () {
                        if (arguments.length == 0) {
                            return this._name;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeRegistration.prototype.getSessionLevel = function () {
                        if (arguments.length == 0) {
                            return this._sessionLevel;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeRegistration.prototype.setCreationDelegate = function (value) {
                        if (arguments.length == 1) {
                            this._creationDelegate = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeRegistration.prototype.setMediaLevel = function (value) {
                        if (arguments.length == 1) {
                            this._mediaLevel = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeRegistration.prototype.setName = function (value) {
                        if (arguments.length == 1) {
                            this._name = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    AttributeRegistration.prototype.setSessionLevel = function (value) {
                        if (arguments.length == 1) {
                            this._sessionLevel = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return AttributeRegistration;
                }());
                sdp.AttributeRegistration = AttributeRegistration;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var AttributeTypeWrapper =  (function () {
                    function AttributeTypeWrapper(value) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var value_54 = __arguments[0];
                            this._value = value_54;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    AttributeTypeWrapper.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.AttributeTypeWrapper]';
                    };
                    AttributeTypeWrapper.prototype.toString = function () {
                        if (arguments.length == 0) {
                            if (this._value == fm.icelink.sdp.AttributeType.UnknownAttribute)
                                return 'UnknownAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.DirectionAttribute)
                                return 'DirectionAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.CategoryAttribute)
                                return 'CategoryAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.CharacterSetAttribute)
                                return 'CharacterSetAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.ConferenceTypeAttribute)
                                return 'ConferenceTypeAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.CryptoAttribute)
                                return 'CryptoAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.FormatParametersAttribute)
                                return 'FormatParametersAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.FrameRateAttribute)
                                return 'FrameRateAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.KeywordsAttribute)
                                return 'KeywordsAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.LanguageAttribute)
                                return 'LanguageAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.MaxPacketTimeAttribute)
                                return 'MaxPacketTimeAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.OrientationAttribute)
                                return 'OrientationAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.PacketTimeAttribute)
                                return 'PacketTimeAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.QualityAttribute)
                                return 'QualityAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.SdpLanguageAttribute)
                                return 'SdpLanguageAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.SetupAttribute)
                                return 'SetupAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.ToolAttribute)
                                return 'ToolAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.MediaStreamIdSemanticAttribute)
                                return 'MediaStreamIdSemanticAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.MediaStreamIdAttribute)
                                return 'MediaStreamIdAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.BundleOnlyAttribute)
                                return 'BundleOnlyAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.IceCandidateAttribute)
                                return 'IceCandidateAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.IceFingerprintAttribute)
                                return 'IceFingerprintAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.IceLiteAttribute)
                                return 'IceLiteAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.IceMismatchAttribute)
                                return 'IceMismatchAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.IceOptionsAttribute)
                                return 'IceOptionsAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.IcePasswordAttribute)
                                return 'IcePasswordAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.IceUfragAttribute)
                                return 'IceUfragAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.IceRemoteCandidatesAttribute)
                                return 'IceRemoteCandidatesAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.RtpMapAttribute)
                                return 'RtpMapAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.RtpSsrcAttribute)
                                return 'RtpSsrcAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.RtpExtMapAttribute)
                                return 'RtpExtMapAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.RtcpAttribute)
                                return 'RtcpAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.RtcpFeedbackAttribute)
                                return 'RtcpFeedbackAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.RtcpMuxAttribute)
                                return 'RtcpMuxAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.SctpPortAttribute)
                                return 'SctpPortAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.SctpMapAttribute)
                                return 'SctpMapAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.SctpMaxMessageSizeAttribute)
                                return 'SctpMaxMessageSizeAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.GroupAttribute)
                                return 'GroupAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.RtpRidAttribute)
                                return 'RtpRidAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.SimulcastAttribute)
                                return 'SimulcastAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.RtpSsrcGroupAttribute)
                                return 'RtpSsrcGroupAttribute';
                            if (this._value == fm.icelink.sdp.AttributeType.MutedAttribute)
                                return 'MutedAttribute';
                            return '';
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return AttributeTypeWrapper;
                }());
                sdp.AttributeTypeWrapper = AttributeTypeWrapper;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var Bandwidth =  (function () {
                    function Bandwidth(bandwidthType, value) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 2) {
                            var bandwidthType_1 = __arguments[0];
                            var value_55 = __arguments[1];
                            this.fmicelinksdpBandwidthInit();
                            this.setBandwidthType(bandwidthType_1);
                            this.setValue(value_55);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    Bandwidth.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.Bandwidth]';
                    };
                    Bandwidth.prototype.fmicelinksdpBandwidthInit = function () {
                        this._value = 0;
                    };
                    Bandwidth.parse = function (s) {
                        if (arguments.length == 1) {
                            s = s.substring(2);
                            var strArray = fm.icelink.StringExtensions.split(s, [58]);
                            var bandwidthType = strArray[0];
                            return new fm.icelink.sdp.Bandwidth(bandwidthType, fm.icelink.ParseAssistant.parseLongValue(strArray[1]));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Bandwidth.prototype.getBandwidthType = function () {
                        if (arguments.length == 0) {
                            return this._bandwidthType;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Bandwidth.prototype.getValue = function () {
                        if (arguments.length == 0) {
                            return this._value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Bandwidth.prototype.setBandwidthType = function (value) {
                        if (arguments.length == 1) {
                            this._bandwidthType = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Bandwidth.prototype.setValue = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._value = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Bandwidth.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append("b=");
                            builder.append(this.getBandwidthType());
                            builder.append(":");
                            builder.append(fm.icelink.NumberExtensions.toString(this.getValue()));
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Bandwidth;
                }());
                sdp.Bandwidth = Bandwidth;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var BandwidthType =  (function () {
                    function BandwidthType() {
                    }
                    BandwidthType.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.BandwidthType]';
                    };
                    BandwidthType.getApplicationSpecific = function () {
                        if (arguments.length == 0) {
                            return "AS";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BandwidthType.getConferenceTotal = function () {
                        if (arguments.length == 0) {
                            return "CT";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BandwidthType.getRtcpReceivers = function () {
                        if (arguments.length == 0) {
                            return "RR";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BandwidthType.getRtcpSenders = function () {
                        if (arguments.length == 0) {
                            return "RS";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BandwidthType.getTransportIndependentApplicationSpecificMaximum = function () {
                        if (arguments.length == 0) {
                            return "TIAS";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return BandwidthType;
                }());
                sdp.BandwidthType = BandwidthType;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var EncryptionKey =  (function () {
                    function EncryptionKey() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) ;
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    EncryptionKey.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.EncryptionKey]';
                    };
                    EncryptionKey.parse = function (s) {
                        if (arguments.length == 1) {
                            var str = void 0;
                            var str2 = void 0;
                            s = s.substring(2);
                            var index = fm.icelink.StringExtensions.indexOf(s, ":");
                            if ((fm.icelink.Global.equals(index, -1))) {
                                str = s;
                                str2 = null;
                            }
                            else {
                                str = fm.icelink.StringExtensions.substring(s, 0, index);
                                str2 = s.substring((index + 1));
                            }
                            var _var0 = str;
                            do {
                                if (_var0 == "clear") {
                                    return new fm.icelink.sdp.ClearEncryptionKey(str2);
                                }
                                else if (_var0 == "base64") {
                                    return new fm.icelink.sdp.Base64EncryptionKey(str2);
                                }
                                else if (_var0 == "uri") {
                                    try {
                                        return new fm.icelink.sdp.UriEncryptionKey(new fm.icelink.Uri(str2));
                                    }
                                    catch (exception1) {
                                        return null;
                                    }
                                    finally {
                                    }
                                }
                                else if (_var0 == "prompt") {
                                    return new fm.icelink.sdp.PromptEncryptionKey();
                                }
                            } while (false);
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    EncryptionKey.prototype.toString = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.StringExtensions.concat("k=", this.getMethodAndValue());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return EncryptionKey;
                }());
                sdp.EncryptionKey = EncryptionKey;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var Base64EncryptionKey =  (function (_super) {
                    __extends(Base64EncryptionKey, _super);
                    function Base64EncryptionKey(encodedEncryptionKey) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var encodedEncryptionKey_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            if ((fm.icelink.Global.equals(encodedEncryptionKey_1, null))) {
                                throw new fm.icelink.Exception("encodedEncryptionKey cannot be null.");
                            }
                            _this.setEncodedEncryptionKey(encodedEncryptionKey_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    Base64EncryptionKey.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.Base64EncryptionKey]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    Base64EncryptionKey.prototype.getEncodedEncryptionKey = function () {
                        if (arguments.length == 0) {
                            return this._encodedEncryptionKey;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Base64EncryptionKey.prototype.getMethodAndValue = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append("base64:");
                            builder.append(this.getEncodedEncryptionKey());
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Base64EncryptionKey.prototype.setEncodedEncryptionKey = function (value) {
                        if (arguments.length == 1) {
                            this._encodedEncryptionKey = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Base64EncryptionKey;
                }(fm.icelink.sdp.EncryptionKey));
                sdp.Base64EncryptionKey = Base64EncryptionKey;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var BundleOnlyAttribute =  (function (_super) {
                    __extends(BundleOnlyAttribute, _super);
                    function BundleOnlyAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.BundleOnlyAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    BundleOnlyAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.BundleOnlyAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    BundleOnlyAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.BundleOnlyAttribute();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BundleOnlyAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return BundleOnlyAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.BundleOnlyAttribute = BundleOnlyAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var CategoryAttribute =  (function (_super) {
                    __extends(CategoryAttribute, _super);
                    function CategoryAttribute(category) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var category_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.CategoryAttribute);
                            if ((fm.icelink.Global.equals(category_1, null))) {
                                throw new fm.icelink.Exception("category cannot be null.");
                            }
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                            _this.setCategory(category_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    CategoryAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.CategoryAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    CategoryAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.CategoryAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CategoryAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getCategory();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CategoryAttribute.prototype.getCategory = function () {
                        if (arguments.length == 0) {
                            return this._category;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CategoryAttribute.prototype.setCategory = function (value) {
                        if (arguments.length == 1) {
                            this._category = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return CategoryAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.CategoryAttribute = CategoryAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var CharacterSetAttribute =  (function (_super) {
                    __extends(CharacterSetAttribute, _super);
                    function CharacterSetAttribute(characterSet) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var characterSet_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            if ((fm.icelink.Global.equals(characterSet_1, null))) {
                                throw new fm.icelink.Exception("characterSet cannot be null.");
                            }
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.CharacterSetAttribute);
                            _this.setCharacterSet(characterSet_1);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    CharacterSetAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.CharacterSetAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    CharacterSetAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.CharacterSetAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CharacterSetAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getCharacterSet();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CharacterSetAttribute.prototype.getCharacterSet = function () {
                        if (arguments.length == 0) {
                            return this._characterSet;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CharacterSetAttribute.prototype.setCharacterSet = function (value) {
                        if (arguments.length == 1) {
                            this._characterSet = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return CharacterSetAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.CharacterSetAttribute = CharacterSetAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var ClearEncryptionKey =  (function (_super) {
                    __extends(ClearEncryptionKey, _super);
                    function ClearEncryptionKey(encryptionKey) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var encryptionKey_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            if ((fm.icelink.Global.equals(encryptionKey_1, null))) {
                                throw new fm.icelink.Exception("encryptionKey cannot be null.");
                            }
                            _this.setEncryptionKey(encryptionKey_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    ClearEncryptionKey.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.ClearEncryptionKey]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    ClearEncryptionKey.prototype.getEncryptionKey = function () {
                        if (arguments.length == 0) {
                            return this._encryptionKey;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ClearEncryptionKey.prototype.getMethodAndValue = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append("clear:");
                            builder.append(this.getEncryptionKey());
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ClearEncryptionKey.prototype.setEncryptionKey = function (value) {
                        if (arguments.length == 1) {
                            this._encryptionKey = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return ClearEncryptionKey;
                }(fm.icelink.sdp.EncryptionKey));
                sdp.ClearEncryptionKey = ClearEncryptionKey;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var ConferenceType =  (function () {
                    function ConferenceType() {
                    }
                    ConferenceType.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.ConferenceType]';
                    };
                    ConferenceType.getBroadcast = function () {
                        if (arguments.length == 0) {
                            return "broadcast";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConferenceType.getH332 = function () {
                        if (arguments.length == 0) {
                            return "H332";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConferenceType.getMeeting = function () {
                        if (arguments.length == 0) {
                            return "meeting";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConferenceType.getModerated = function () {
                        if (arguments.length == 0) {
                            return "moderated";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConferenceType.getTest = function () {
                        if (arguments.length == 0) {
                            return "test";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return ConferenceType;
                }());
                sdp.ConferenceType = ConferenceType;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var ConferenceTypeAttribute =  (function (_super) {
                    __extends(ConferenceTypeAttribute, _super);
                    function ConferenceTypeAttribute(conferenceType) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var conferenceType_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.ConferenceTypeAttribute);
                            if ((fm.icelink.Global.equals(conferenceType_1, null))) {
                                throw new fm.icelink.Exception("conferenceType cannot be null.");
                            }
                            _this.setConferenceType(conferenceType_1);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    ConferenceTypeAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.ConferenceTypeAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    ConferenceTypeAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.ConferenceTypeAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConferenceTypeAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getConferenceType();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConferenceTypeAttribute.prototype.getConferenceType = function () {
                        if (arguments.length == 0) {
                            return this._conferenceType;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConferenceTypeAttribute.prototype.setConferenceType = function (value) {
                        if (arguments.length == 1) {
                            this._conferenceType = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return ConferenceTypeAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.ConferenceTypeAttribute = ConferenceTypeAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var ConnectionData =  (function () {
                    function ConnectionData(connectionAddress) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var connectionAddress_1 = __arguments[0];
                            if ((fm.icelink.Global.equals(connectionAddress_1, null))) {
                                throw new fm.icelink.Exception("connectionAddress cannot be null.");
                            }
                            this.update(connectionAddress_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    ConnectionData.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.ConnectionData]';
                    };
                    ConnectionData.parse = function (s) {
                        if (arguments.length == 1) {
                            s = s.substring(2);
                            var strArray = fm.icelink.StringExtensions.split(s, [32]);
                            var connectionAddress = strArray[2];
                            var data = new fm.icelink.sdp.ConnectionData(connectionAddress);
                            data.setNetworkType(strArray[0]);
                            data.setAddressType(strArray[1]);
                            return data;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionData.prototype.getAddressType = function () {
                        if (arguments.length == 0) {
                            return this._addressType;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionData.prototype.getConnectionAddress = function () {
                        if (arguments.length == 0) {
                            return this._connectionAddress;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionData.prototype.getNetworkType = function () {
                        if (arguments.length == 0) {
                            return this._networkType;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionData.prototype.setAddressType = function (value) {
                        if (arguments.length == 1) {
                            this._addressType = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionData.prototype.setConnectionAddress = function (value) {
                        if (arguments.length == 1) {
                            this._connectionAddress = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionData.prototype.setNetworkType = function (value) {
                        if (arguments.length == 1) {
                            this._networkType = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionData.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append("c=");
                            builder.append(this.getNetworkType());
                            builder.append(" ");
                            builder.append(this.getAddressType());
                            builder.append(" ");
                            builder.append(this.getConnectionAddress());
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ConnectionData.prototype.update = function (connectionAddress) {
                        if (arguments.length == 1) {
                            this.setNetworkType(fm.icelink.sdp.NetworkType.getInternet());
                            this.setAddressType(fm.icelink.sdp.AddressType.getAddressTypeForAddress(connectionAddress));
                            this.setConnectionAddress(connectionAddress);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return ConnectionData;
                }());
                sdp.ConnectionData = ConnectionData;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var CryptoAttribute =  (function (_super) {
                    __extends(CryptoAttribute, _super);
                    function CryptoAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                            _this.fmicelinksdpCryptoAttributeInit();
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.CryptoAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                        }
                        else if (__arguments.length == 2) {
                            var tag = __arguments[0];
                            var cryptoSuite = __arguments[1];
                            __arguments = new Array(0);
                            {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdpCryptoAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.CryptoAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                            }
                            _this.setTag(tag);
                            _this.setCryptoSuite(cryptoSuite);
                            _this.setKeyParams({});
                            _this.setSessionParams(new Array());
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    CryptoAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.CryptoAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    CryptoAttribute.prototype.fmicelinksdpCryptoAttributeInit = function () {
                        this._tag = 0;
                    };
                    CryptoAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            var strArray = void 0;
                            var index = fm.icelink.StringExtensions.indexOf(value, " ");
                            var num2 = fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring(value, 0, index));
                            value = value.substring((index + 1));
                            index = fm.icelink.StringExtensions.indexOf(value, " ");
                            var str = fm.icelink.StringExtensions.substring(value, 0, index);
                            value = value.substring((index + 1));
                            var dictionary = {};
                            var list = new Array();
                            index = fm.icelink.StringExtensions.indexOf(value, " ");
                            if ((fm.icelink.Global.equals(index, -1))) {
                                strArray = fm.icelink.StringExtensions.split(value, [59]);
                                for (var _i = 0, strArray_1 = strArray; _i < strArray_1.length; _i++) {
                                    var str2 = strArray_1[_i];
                                    var length_42 = fm.icelink.StringExtensions.indexOf(str2, ":");
                                    if ((!fm.icelink.Global.equals(length_42, -1))) {
                                        var str3 = fm.icelink.StringExtensions.substring(str2, 0, length_42);
                                        var str4 = str2.substring((length_42 + 1));
                                        dictionary[str3] = str4;
                                    }
                                }
                            }
                            else {
                                strArray = fm.icelink.StringExtensions.split(fm.icelink.StringExtensions.substring(value, 0, index), [59]);
                                for (var _a = 0, strArray_2 = strArray; _a < strArray_2.length; _a++) {
                                    var str2 = strArray_2[_a];
                                    var strArray2 = fm.icelink.StringExtensions.split(str2, [58]);
                                    if ((fm.icelink.Global.equals(strArray2.length, 2))) {
                                        dictionary[strArray2[0]] = strArray2[1];
                                    }
                                }
                                value = value.substring((index + 1));
                                var strArray3 = fm.icelink.StringExtensions.split(value, [32]);
                                for (var _b = 0, strArray3_1 = strArray3; _b < strArray3_1.length; _b++) {
                                    var str5 = strArray3_1[_b];
                                    fm.icelink.ArrayExtensions.add(list, str5);
                                }
                            }
                            var attribute = new fm.icelink.sdp.CryptoAttribute();
                            attribute.setTag(num2);
                            attribute.setCryptoSuite(str);
                            attribute.setKeyParams(dictionary);
                            attribute.setSessionParams(list);
                            return attribute;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append(fm.icelink.NumberExtensions.toString(this.getTag()));
                            builder.append(" ");
                            builder.append(this.getCryptoSuite());
                            for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(this.getKeyParams()); _i < _a.length; _i++) {
                                var str = _a[_i];
                                builder.append(" ");
                                builder.append(str);
                                builder.append(":");
                                builder.append(this.getKeyParams()[str]);
                            }
                            for (var _b = 0, _c = this.getSessionParams(); _b < _c.length; _b++) {
                                var str2 = _c[_b];
                                builder.append(" ");
                                builder.append(str2);
                            }
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.getCryptoSuite = function () {
                        if (arguments.length == 0) {
                            return this._cryptoSuite;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.getKey = function () {
                        if (arguments.length == 0) {
                            if (((!fm.icelink.Global.equals(this.getCryptoSuite(), fm.icelink.sdp.CryptoSuite.getAesCM128HmacSha180())) && !(fm.icelink.Global.equals(this.getCryptoSuite(), fm.icelink.sdp.CryptoSuite.getAesCm128HmacSha132())))) {
                                throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Unrecognized crypto-suite: {0}.", this.getCryptoSuite()));
                            }
                            var s = this.getKeyParams()[fm.icelink.sdp.CryptoKeyMethod.getInline()];
                            var index = fm.icelink.StringExtensions.indexOf(s, "|");
                            if ((!fm.icelink.Global.equals(index, -1))) {
                                s = fm.icelink.StringExtensions.substring(s, 0, index);
                            }
                            var array = fm.icelink.Base64.decode(s);
                            if ((!fm.icelink.Global.equals(array.length, 30))) {
                                throw new fm.icelink.Exception("Unexpected key/salt length.");
                            }
                            return fm.icelink.DataBuffer.wrap(fm.icelink.BitAssistant.subArray(array, 0, 16));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.getKeyParams = function () {
                        if (arguments.length == 0) {
                            return this._keyParams;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.getSalt = function () {
                        if (arguments.length == 0) {
                            if (((!fm.icelink.Global.equals(this.getCryptoSuite(), fm.icelink.sdp.CryptoSuite.getAesCM128HmacSha180())) && !(fm.icelink.Global.equals(this.getCryptoSuite(), fm.icelink.sdp.CryptoSuite.getAesCm128HmacSha132())))) {
                                throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Unrecognized crypto-suite: {0}.", this.getCryptoSuite()));
                            }
                            var s = this.getKeyParams()[fm.icelink.sdp.CryptoKeyMethod.getInline()];
                            var index = fm.icelink.StringExtensions.indexOf(s, "|");
                            if ((!fm.icelink.Global.equals(index, -1))) {
                                s = fm.icelink.StringExtensions.substring(s, 0, index);
                            }
                            var array = fm.icelink.Base64.decode(s);
                            if ((!fm.icelink.Global.equals(array.length, 30))) {
                                throw new fm.icelink.Exception("Unexpected key/salt length.");
                            }
                            return fm.icelink.DataBuffer.wrap(fm.icelink.BitAssistant.subArray(array, 16, 14));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.getSessionParams = function () {
                        if (arguments.length == 0) {
                            return this._sessionParams;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.getTag = function () {
                        if (arguments.length == 0) {
                            return this._tag;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.setCryptoSuite = function (value) {
                        if (arguments.length == 1) {
                            this._cryptoSuite = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.setKeyParams = function (value) {
                        if (arguments.length == 1) {
                            this._keyParams = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.setKeySalt = function (key, salt) {
                        if (arguments.length == 2) {
                            var num = void 0;
                            var b = new Uint8Array((key.length + salt.length));
                            for (num = 0; (num < key.length); num++) {
                                b[num] = key[num];
                            }
                            for (num = 0; (num < salt.length); num++) {
                                b[(key.length + num)] = salt[num];
                            }
                            this.getKeyParams()[fm.icelink.sdp.CryptoKeyMethod.getInline()] = fm.icelink.Base64.encode(b);
                            return this;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.setSessionParams = function (value) {
                        if (arguments.length == 1) {
                            this._sessionParams = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoAttribute.prototype.setTag = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._tag = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return CryptoAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.CryptoAttribute = CryptoAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var CryptoKeyMethod =  (function () {
                    function CryptoKeyMethod() {
                    }
                    CryptoKeyMethod.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.CryptoKeyMethod]';
                    };
                    CryptoKeyMethod.getInline = function () {
                        if (arguments.length == 0) {
                            return "inline";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return CryptoKeyMethod;
                }());
                sdp.CryptoKeyMethod = CryptoKeyMethod;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var CryptoSessionParam =  (function () {
                    function CryptoSessionParam() {
                    }
                    CryptoSessionParam.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.CryptoSessionParam]';
                    };
                    CryptoSessionParam.getUnauthenticatedSRTP = function () {
                        if (arguments.length == 0) {
                            return "UNAUTHENTICATED_SRTP";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoSessionParam.getUnencryptedSRTCP = function () {
                        if (arguments.length == 0) {
                            return "UNENCRYPTED_SRTCP";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoSessionParam.getUnencryptedSRTP = function () {
                        if (arguments.length == 0) {
                            return "UNENCRYPTED_SRTP";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return CryptoSessionParam;
                }());
                sdp.CryptoSessionParam = CryptoSessionParam;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var CryptoSuite =  (function () {
                    function CryptoSuite() {
                    }
                    CryptoSuite.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.CryptoSuite]';
                    };
                    CryptoSuite.getAesCm128HmacSha132 = function () {
                        if (arguments.length == 0) {
                            return "AES_CM_128_HMAC_SHA1_32";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoSuite.getAesCM128HmacSha180 = function () {
                        if (arguments.length == 0) {
                            return "AES_CM_128_HMAC_SHA1_80";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoSuite.getCryptoSuite = function (encryptionMode) {
                        if (arguments.length == 1) {
                            if ((fm.icelink.Global.equals(encryptionMode, fm.icelink.EncryptionMode.Aes128Strong))) {
                                return fm.icelink.sdp.CryptoSuite.getAesCM128HmacSha180();
                            }
                            if ((fm.icelink.Global.equals(encryptionMode, fm.icelink.EncryptionMode.Aes128Weak))) {
                                return fm.icelink.sdp.CryptoSuite.getAesCm128HmacSha132();
                            }
                            if ((fm.icelink.Global.equals(encryptionMode, fm.icelink.EncryptionMode.NullStrong))) {
                                return fm.icelink.sdp.CryptoSuite.getNullHmacSha180();
                            }
                            if ((fm.icelink.Global.equals(encryptionMode, fm.icelink.EncryptionMode.NullWeak))) {
                                return fm.icelink.sdp.CryptoSuite.getNullHmacSha132();
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoSuite.getEncryptionMode = function (cryptoSuite) {
                        if (arguments.length == 1) {
                            if ((fm.icelink.Global.equals(cryptoSuite, fm.icelink.sdp.CryptoSuite.getAesCM128HmacSha180()))) {
                                return fm.icelink.EncryptionMode.Aes128Strong;
                            }
                            if ((fm.icelink.Global.equals(cryptoSuite, fm.icelink.sdp.CryptoSuite.getAesCm128HmacSha132()))) {
                                return fm.icelink.EncryptionMode.Aes128Weak;
                            }
                            if ((fm.icelink.Global.equals(cryptoSuite, fm.icelink.sdp.CryptoSuite.getNullHmacSha180()))) {
                                return fm.icelink.EncryptionMode.NullStrong;
                            }
                            if ((fm.icelink.Global.equals(cryptoSuite, fm.icelink.sdp.CryptoSuite.getNullHmacSha132()))) {
                                return fm.icelink.EncryptionMode.NullWeak;
                            }
                            return fm.icelink.EncryptionMode.Null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoSuite.getNullHmacSha132 = function () {
                        if (arguments.length == 0) {
                            return "NULL_HMAC_SHA1_32";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    CryptoSuite.getNullHmacSha180 = function () {
                        if (arguments.length == 0) {
                            return "NULL_HMAC_SHA1_80";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return CryptoSuite;
                }());
                sdp.CryptoSuite = CryptoSuite;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var DirectionAttribute =  (function (_super) {
                    __extends(DirectionAttribute, _super);
                    function DirectionAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    DirectionAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.DirectionAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    DirectionAttribute.generateDirectionAttribute = function (direction) {
                        if (arguments.length == 1) {
                            if (((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.Inactive)) || (fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.Unset)))) {
                                if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.Unset))) {
                                    fm.icelink.Log.debug("Attempted to create Sdp Direction attribute with unset direction. Creating Inactive direction attribute instead.");
                                }
                                return new fm.icelink.sdp.InactiveAttribute();
                            }
                            if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.SendOnly))) {
                                return new fm.icelink.sdp.SendOnlyAttribute();
                            }
                            if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.ReceiveOnly))) {
                                return new fm.icelink.sdp.ReceiveOnlyAttribute();
                            }
                            if ((!fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.SendReceive))) {
                                throw new fm.icelink.Exception("Unexpected Sdp.StreamDirection");
                            }
                            return new fm.icelink.sdp.SendReceiveAttribute();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return DirectionAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.DirectionAttribute = DirectionAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var FormatParametersAttribute =  (function (_super) {
                    __extends(FormatParametersAttribute, _super);
                    function FormatParametersAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                            _this.fmicelinksdpFormatParametersAttributeInit();
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.FormatParametersAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                        }
                        else if (__arguments.length == 1) {
                            var format = __arguments[0];
                            __arguments = new Array(2);
                            __arguments[0] = format;
                            __arguments[1] = null;
                            {
                                var format_1 = __arguments[0];
                                var formatSpecificParameters = __arguments[1];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdpFormatParametersAttributeInit();
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.FormatParametersAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                                }
                                _this.setFormat(format_1);
                                _this.setFormatSpecificParameters(formatSpecificParameters);
                            }
                        }
                        else if (__arguments.length == 2) {
                            var format = __arguments[0];
                            var formatSpecificParameters = __arguments[1];
                            __arguments = new Array(0);
                            {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdpFormatParametersAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.FormatParametersAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                            }
                            _this.setFormat(format);
                            _this.setFormatSpecificParameters(formatSpecificParameters);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    FormatParametersAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.FormatParametersAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    FormatParametersAttribute.prototype.fmicelinksdpFormatParametersAttributeInit = function () {
                        this._format = 0;
                    };
                    FormatParametersAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            var index = fm.icelink.StringExtensions.indexOf(value, " ");
                            var num2 = fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring(value, 0, index));
                            var str = value.substring((index + 1));
                            var attribute = new fm.icelink.sdp.FormatParametersAttribute();
                            attribute.setFormat(num2);
                            attribute.setFormatSpecificParameters(str);
                            return attribute;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.deserializeFormatSpecificParameters = function () {
                        if (arguments.length == 0) {
                            var dictionary = {};
                            var formatSpecificParameters = this.getFormatSpecificParameters();
                            if ((!fm.icelink.Global.equals(formatSpecificParameters, null))) {
                                var strArray = fm.icelink.StringExtensions.split(formatSpecificParameters, [59]);
                                for (var _i = 0, strArray_3 = strArray; _i < strArray_3.length; _i++) {
                                    var str2 = strArray_3[_i];
                                    var str3 = fm.icelink.StringExtensions.trim(str2);
                                    var index = fm.icelink.StringExtensions.indexOf(str3, "=");
                                    if ((fm.icelink.Global.equals(index, -1))) {
                                        dictionary[str3] = null;
                                    }
                                    else {
                                        dictionary[fm.icelink.StringExtensions.substring(str3, 0, index)] = str3.substring((index + 1));
                                    }
                                }
                            }
                            return dictionary;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append(fm.icelink.NumberExtensions.toString(this.getFormat()));
                            builder.append(" ");
                            builder.append(this.getFormatSpecificParameters());
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.getFormat = function () {
                        if (arguments.length == 0) {
                            return this._format;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.getFormatSpecificParameter = function (key) {
                        if (arguments.length == 1) {
                            return this.deserializeFormatSpecificParameters()[key];
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.getFormatSpecificParameters = function () {
                        if (arguments.length == 0) {
                            return this._formatSpecificParameters;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.serializeFormatSpecificParameters = function (map) {
                        if (arguments.length == 1) {
                            var list = new Array();
                            for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(map); _i < _a.length; _i++) {
                                var str = _a[_i];
                                if ((fm.icelink.Global.equals(map[str], null))) {
                                    fm.icelink.ArrayExtensions.add(list, str);
                                }
                                else {
                                    fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.join("=", [str, map[str]]));
                                }
                            }
                            this.setFormatSpecificParameters(fm.icelink.StringExtensions.join(";", fm.icelink.ArrayExtensions.toArray(list)));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.setFormat = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._format = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.setFormatSpecificParameter = function (key, value) {
                        if (arguments.length == 2) {
                            var map = this.deserializeFormatSpecificParameters();
                            map[key] = value;
                            this.serializeFormatSpecificParameters(map);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.setFormatSpecificParameters = function (value) {
                        if (arguments.length == 1) {
                            this._formatSpecificParameters = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.tryGetFormatSpecificParameter = function (key, value) {
                        if (arguments.length == 2) {
                            var dictionary = this.deserializeFormatSpecificParameters();
                            value.setValue(null);
                            var _var0 = fm.icelink.HashExtensions.tryGetValue(dictionary, key, value);
                            return _var0;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FormatParametersAttribute.prototype.unsetFormatSpecificParameter = function (key) {
                        if (arguments.length == 1) {
                            var map = this.deserializeFormatSpecificParameters();
                            if (fm.icelink.HashExtensions.remove(map, key)) {
                                this.serializeFormatSpecificParameters(map);
                                return true;
                            }
                            return false;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return FormatParametersAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.FormatParametersAttribute = FormatParametersAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var FrameRateAttribute =  (function (_super) {
                    __extends(FrameRateAttribute, _super);
                    function FrameRateAttribute(frameRate) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var frameRate_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.FrameRateAttribute);
                            if ((fm.icelink.Global.equals(frameRate_1, null))) {
                                throw new fm.icelink.Exception("frameRate cannot be null.");
                            }
                            _this.setFrameRate(frameRate_1);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    FrameRateAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.FrameRateAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    FrameRateAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.FrameRateAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FrameRateAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getFrameRate();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FrameRateAttribute.prototype.getFrameRate = function () {
                        if (arguments.length == 0) {
                            return this._frameRate;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    FrameRateAttribute.prototype.setFrameRate = function (value) {
                        if (arguments.length == 1) {
                            this._frameRate = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return FrameRateAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.FrameRateAttribute = FrameRateAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var BundleGroup =  (function () {
                    function BundleGroup(groupType) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var groupType_1 = __arguments[0];
                            this.fmicelinksdpBundleGroupInit();
                            this.__mediaDescriptions = new Array();
                            this.__mids = new Array();
                            this.setGroupType(groupType_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    BundleGroup.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.BundleGroup]';
                    };
                    BundleGroup.prototype.fmicelinksdpBundleGroupInit = function () {
                        this._bundleOnly = false;
                    };
                    BundleGroup.prototype.addMediaDescription = function (mediaDescription) {
                        if (arguments.length == 1) {
                            fm.icelink.ArrayExtensions.add(this.__mediaDescriptions, mediaDescription);
                            if ((fm.icelink.Global.equals(this.getTaggedMSection(), null))) {
                                this.setTaggedMSection(mediaDescription);
                            }
                            var mediaStreamIdentifierAttribute = mediaDescription.getMediaStreamIdentifierAttribute();
                            if ((fm.icelink.Global.equals(mediaStreamIdentifierAttribute, null))) {
                                throw new fm.icelink.Exception("SDP Media Stream Identifier Attribute missing for media description in bundle group.");
                            }
                            fm.icelink.ArrayExtensions.add(this.__mids, mediaStreamIdentifierAttribute.getIdentificationTag());
                            if (mediaDescription.getBundleOnly()) {
                                this.setBundleOnly(true);
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BundleGroup.prototype.getBundleOnly = function () {
                        if (arguments.length == 0) {
                            return this._bundleOnly;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BundleGroup.prototype.getGroupType = function () {
                        if (arguments.length == 0) {
                            return this._groupType;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BundleGroup.prototype.getMediaDescriptions = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.ArrayExtensions.toArray(this.__mediaDescriptions);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BundleGroup.prototype.getMids = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.ArrayExtensions.toArray(this.__mids);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BundleGroup.prototype.getTaggedMSection = function () {
                        if (arguments.length == 0) {
                            return this._taggedMSection;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BundleGroup.prototype.setBundleOnly = function (value) {
                        if (arguments.length == 1) {
                            this._bundleOnly = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BundleGroup.prototype.setGroupType = function (value) {
                        if (arguments.length == 1) {
                            this._groupType = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    BundleGroup.prototype.setTaggedMSection = function (value) {
                        if (arguments.length == 1) {
                            this._taggedMSection = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return BundleGroup;
                }());
                sdp.BundleGroup = BundleGroup;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var GroupAttribute =  (function (_super) {
                    __extends(GroupAttribute, _super);
                    function GroupAttribute(type, ids) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 2) {
                            var type_6 = __arguments[0];
                            var ids_2 = __arguments[1];
                            _this = _super.call(this) || this;
                            _this.setSemantics(type_6);
                            _this.setIds(ids_2);
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.GroupAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    GroupAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.GroupAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    GroupAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            var strArray = fm.icelink.StringExtensions.split(value, [32]);
                            var str = strArray[0];
                            var unknown = fm.icelink.sdp.GroupSemanticsType.Unknown;
                            var ids = new Array((strArray.length - 1));
                            if ((fm.icelink.Global.equals(str, "BUNDLE"))) {
                                unknown = fm.icelink.sdp.GroupSemanticsType.Bundling;
                            }
                            else {
                                if ((fm.icelink.Global.equals(str, "FID"))) {
                                    unknown = fm.icelink.sdp.GroupSemanticsType.FlowIdentification;
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "LS"))) {
                                        unknown = fm.icelink.sdp.GroupSemanticsType.LipSynchronization;
                                    }
                                    else {
                                        unknown = fm.icelink.sdp.GroupSemanticsType.Unknown;
                                    }
                                }
                            }
                            for (var i = 1; (i < strArray.length); i++) {
                                ids[(i - 1)] = strArray[i];
                            }
                            return new fm.icelink.sdp.GroupAttribute(unknown, ids);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    GroupAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            var str = "";
                            if ((fm.icelink.Global.equals(this.getSemantics(), fm.icelink.sdp.GroupSemanticsType.Bundling))) {
                                str = "BUNDLE";
                            }
                            else {
                                if ((fm.icelink.Global.equals(this.getSemantics(), fm.icelink.sdp.GroupSemanticsType.FlowIdentification))) {
                                    str = "FID";
                                }
                                else {
                                    if ((fm.icelink.Global.equals(this.getSemantics(), fm.icelink.sdp.GroupSemanticsType.LipSynchronization))) {
                                        str = "LS";
                                    }
                                    else {
                                        str = "";
                                    }
                                }
                            }
                            for (var _i = 0, _a = this.getIds(); _i < _a.length; _i++) {
                                var str2 = _a[_i];
                                str = fm.icelink.StringExtensions.concat(str, " ", str2);
                            }
                            return str;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    GroupAttribute.prototype.getIds = function () {
                        if (arguments.length == 0) {
                            return this._ids;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    GroupAttribute.prototype.getSemantics = function () {
                        if (arguments.length == 0) {
                            return this._semantics;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    GroupAttribute.prototype.setIds = function (value) {
                        if (arguments.length == 1) {
                            this._ids = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    GroupAttribute.prototype.setSemantics = function (value) {
                        if (arguments.length == 1) {
                            this._semantics = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return GroupAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.GroupAttribute = GroupAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var GroupSemanticsTypeWrapper =  (function () {
                    function GroupSemanticsTypeWrapper(value) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var value_56 = __arguments[0];
                            this._value = value_56;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    GroupSemanticsTypeWrapper.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.GroupSemanticsTypeWrapper]';
                    };
                    GroupSemanticsTypeWrapper.prototype.toString = function () {
                        if (arguments.length == 0) {
                            if (this._value == fm.icelink.sdp.GroupSemanticsType.LipSynchronization)
                                return 'LipSynchronization';
                            if (this._value == fm.icelink.sdp.GroupSemanticsType.FlowIdentification)
                                return 'FlowIdentification';
                            if (this._value == fm.icelink.sdp.GroupSemanticsType.Bundling)
                                return 'Bundling';
                            if (this._value == fm.icelink.sdp.GroupSemanticsType.Unknown)
                                return 'Unknown';
                            return '';
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return GroupSemanticsTypeWrapper;
                }());
                sdp.GroupSemanticsTypeWrapper = GroupSemanticsTypeWrapper;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var CandidateAttribute =  (function (_super) {
                        __extends(CandidateAttribute, _super);
                        function CandidateAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdpiceCandidateAttributeInit();
                                _this.__foundation = fm.icelink.StringExtensions.empty;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceCandidateAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                            }
                            else if (__arguments.length == 6) {
                                var foundation = __arguments[0];
                                var priority = __arguments[1];
                                var connectionAddress = __arguments[2];
                                var port = __arguments[3];
                                var candidateType = __arguments[4];
                                var componentId = __arguments[5];
                                __arguments = new Array(9);
                                __arguments[0] = foundation;
                                __arguments[1] = priority;
                                __arguments[2] = connectionAddress;
                                __arguments[3] = port;
                                __arguments[4] = candidateType;
                                __arguments[5] = null;
                                __arguments[6] = 0;
                                __arguments[7] = "udp";
                                __arguments[8] = componentId;
                                {
                                    var foundation_1 = __arguments[0];
                                    var priority_1 = __arguments[1];
                                    var connectionAddress_2 = __arguments[2];
                                    var port_1 = __arguments[3];
                                    var candidateType_1 = __arguments[4];
                                    var relatedAddress = __arguments[5];
                                    var relatedPort = __arguments[6];
                                    var protocol = __arguments[7];
                                    var componentId_1 = __arguments[8];
                                    __arguments = new Array(0);
                                    {
                                        _this = _super.call(this) || this;
                                        _this.fmicelinksdpiceCandidateAttributeInit();
                                        _this.__foundation = fm.icelink.StringExtensions.empty;
                                        _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceCandidateAttribute);
                                        _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                                    }
                                    _this.setFoundation(foundation_1);
                                    _this.setProtocol(protocol);
                                    _this.setPriority(priority_1);
                                    _this.setConnectionAddress(connectionAddress_2);
                                    _this.setPort(port_1);
                                    _this.setCandidateType(candidateType_1);
                                    _this.setRelatedAddress(relatedAddress);
                                    _this.setRelatedPort(relatedPort);
                                    _this.setComponentId(componentId_1);
                                    _this.setExtensions({});
                                }
                            }
                            else if (__arguments.length == 9) {
                                var foundation = __arguments[0];
                                var priority = __arguments[1];
                                var connectionAddress = __arguments[2];
                                var port = __arguments[3];
                                var candidateType = __arguments[4];
                                var relatedAddress = __arguments[5];
                                var relatedPort = __arguments[6];
                                var protocol = __arguments[7];
                                var componentId = __arguments[8];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdpiceCandidateAttributeInit();
                                    _this.__foundation = fm.icelink.StringExtensions.empty;
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceCandidateAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                                }
                                _this.setFoundation(foundation);
                                _this.setProtocol(protocol);
                                _this.setPriority(priority);
                                _this.setConnectionAddress(connectionAddress);
                                _this.setPort(port);
                                _this.setCandidateType(candidateType);
                                _this.setRelatedAddress(relatedAddress);
                                _this.setRelatedPort(relatedPort);
                                _this.setComponentId(componentId);
                                _this.setExtensions({});
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        CandidateAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.CandidateAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        CandidateAttribute.prototype.fmicelinksdpiceCandidateAttributeInit = function () {
                            this._componentId = 0;
                            this._port = 0;
                            this._priority = 0;
                            this._relatedPort = 0;
                        };
                        CandidateAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var str = fm.icelink.StringExtensions.substring(value, 0, index);
                                value = value.substring((index + 1));
                                index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var num2 = fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring(value, 0, index));
                                value = value.substring((index + 1));
                                index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var str2 = fm.icelink.StringExtensions.toLower(fm.icelink.StringExtensions.substring(value, 0, index));
                                value = value.substring((index + 1));
                                index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var num3 = fm.icelink.ParseAssistant.parseLongValue(fm.icelink.StringExtensions.substring(value, 0, index));
                                value = value.substring((index + 1));
                                index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var str3 = fm.icelink.StringExtensions.substring(value, 0, index);
                                value = value.substring((index + 1));
                                index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var num4 = fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring(value, 0, index));
                                value = value.substring((index + 1));
                                var dictionary = {};
                                var strArray = fm.icelink.StringExtensions.split(value, [32]);
                                var length_43 = strArray.length;
                                var str4 = null;
                                var str5 = null;
                                var num6 = 0;
                                if ((fm.icelink.Global.equals((length_43 % 2), 1))) {
                                    length_43--;
                                }
                                for (var i = 0; (i < length_43); i = (i + 2)) {
                                    var str6 = strArray[i];
                                    var s = strArray[(i + 1)];
                                    if ((fm.icelink.Global.equals(str6, "typ"))) {
                                        str4 = s;
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str6, "raddr"))) {
                                            str5 = s;
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str6, "rport"))) {
                                                num6 = fm.icelink.ParseAssistant.parseIntegerValue(s);
                                            }
                                            else {
                                                dictionary[str6] = s;
                                            }
                                        }
                                    }
                                }
                                var attribute = new fm.icelink.sdp.ice.CandidateAttribute();
                                attribute.setFoundation(str);
                                attribute.setComponentId(num2);
                                attribute.setProtocol(str2);
                                attribute.setPriority(num3);
                                attribute.setConnectionAddress(str3);
                                attribute.setPort(num4);
                                attribute.setExtensions(dictionary);
                                attribute.setCandidateType(str4);
                                attribute.setRelatedAddress(str5);
                                attribute.setRelatedPort(num6);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(this.getFoundation());
                                builder.append(" ");
                                builder.append(fm.icelink.NumberExtensions.toString(this.getComponentId()));
                                builder.append(" ");
                                builder.append(this.getProtocol());
                                builder.append(" ");
                                builder.append(fm.icelink.NumberExtensions.toString(this.getPriority()));
                                builder.append(" ");
                                builder.append(this.getConnectionAddress());
                                builder.append(" ");
                                builder.append(fm.icelink.NumberExtensions.toString(this.getPort()));
                                builder.append(" ");
                                builder.append("typ");
                                builder.append(" ");
                                builder.append(this.getCandidateType());
                                if (((!fm.icelink.Global.equals(this.getCandidateType(), fm.icelink.sdp.ice.CandidateType.getHost())) && (!fm.icelink.Global.equals(this.getRelatedAddress(), null)))) {
                                    builder.append(" ");
                                    builder.append("raddr");
                                    builder.append(" ");
                                    builder.append(this.getRelatedAddress());
                                    builder.append(" ");
                                    builder.append("rport");
                                    builder.append(" ");
                                    builder.append(fm.icelink.NumberExtensions.toString(this.getRelatedPort()));
                                }
                                for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(this.getExtensions()); _i < _a.length; _i++) {
                                    var str = _a[_i];
                                    builder.append(" ");
                                    builder.append(str);
                                    builder.append(" ");
                                    builder.append(this.getExtensions()[str]);
                                }
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getCandidateType = function () {
                            if (arguments.length == 0) {
                                return this.__candidateType;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getComponentId = function () {
                            if (arguments.length == 0) {
                                return this._componentId;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getConnectionAddress = function () {
                            if (arguments.length == 0) {
                                return this.__connectionAddress;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getExtensions = function () {
                            if (arguments.length == 0) {
                                return this._extensions;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getFoundation = function () {
                            if (arguments.length == 0) {
                                return this.__foundation;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getPort = function () {
                            if (arguments.length == 0) {
                                return this._port;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getPriority = function () {
                            if (arguments.length == 0) {
                                return this._priority;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getProtocol = function () {
                            if (arguments.length == 0) {
                                return this._protocol;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getRelatedAddress = function () {
                            if (arguments.length == 0) {
                                return this._relatedAddress;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.getRelatedPort = function () {
                            if (arguments.length == 0) {
                                return this._relatedPort;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.setCandidateType = function (value) {
                            if (arguments.length == 1) {
                                if ((fm.icelink.Global.equals(value, null))) {
                                    throw new fm.icelink.Exception("Candidate type cannot be null.");
                                }
                                this.__candidateType = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.setComponentId = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._componentId = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.setConnectionAddress = function (value) {
                            if (arguments.length == 1) {
                                if ((fm.icelink.Global.equals(value, null))) {
                                    throw new fm.icelink.Exception("Connection address cannot be null.");
                                }
                                this.__connectionAddress = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.setExtensions = function (value) {
                            if (arguments.length == 1) {
                                this._extensions = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.setFoundation = function (value) {
                            if (arguments.length == 1) {
                                if ((fm.icelink.Global.equals(value, null))) {
                                    throw new fm.icelink.Exception("Foundation cannot be null.");
                                }
                                this.__foundation = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.setPort = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._port = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.setPriority = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._priority = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.setProtocol = function (value) {
                            if (arguments.length == 1) {
                                this._protocol = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.setRelatedAddress = function (value) {
                            if (arguments.length == 1) {
                                this._relatedAddress = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateAttribute.prototype.setRelatedPort = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._relatedPort = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return CandidateAttribute;
                    }(fm.icelink.sdp.Attribute));
                    ice.CandidateAttribute = CandidateAttribute;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var CandidateType =  (function () {
                        function CandidateType() {
                        }
                        CandidateType.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.CandidateType]';
                        };
                        CandidateType.getHost = function () {
                            if (arguments.length == 0) {
                                return "host";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateType.getPeerReflexive = function () {
                            if (arguments.length == 0) {
                                return "prflx";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateType.getRelayed = function () {
                            if (arguments.length == 0) {
                                return "relay";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        CandidateType.getServerReflexive = function () {
                            if (arguments.length == 0) {
                                return "srflx";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return CandidateType;
                    }());
                    ice.CandidateType = CandidateType;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var FingerprintAttribute =  (function (_super) {
                        __extends(FingerprintAttribute, _super);
                        function FingerprintAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceFingerprintAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                            }
                            else if (__arguments.length == 2) {
                                var hashFunction = __arguments[0];
                                var fingerprint = __arguments[1];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceFingerprintAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                                }
                                _this.setHashFunction(hashFunction);
                                if ((fm.icelink.StringExtensions.indexOf(fingerprint, ":") < 0)) {
                                    var list = new Array();
                                    for (var i = 0; (i < fm.icelink.StringExtensions.getLength(fingerprint)); i = (i + 2)) {
                                        fm.icelink.ArrayExtensions.add(list, fm.icelink.StringExtensions.substring(fingerprint, i, 2));
                                    }
                                    fingerprint = fm.icelink.StringExtensions.join(":", fm.icelink.ArrayExtensions.toArray(list));
                                }
                                _this.setFingerprint(fm.icelink.StringExtensions.toUpper(fingerprint));
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        FingerprintAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.FingerprintAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        FingerprintAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var str = fm.icelink.StringExtensions.substring(value, 0, index);
                                value = value.substring((index + 1));
                                var str2 = value;
                                var attribute = new fm.icelink.sdp.ice.FingerprintAttribute();
                                attribute.setHashFunction(str);
                                attribute.setFingerprint(str2);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FingerprintAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(this.getHashFunction());
                                builder.append(" ");
                                builder.append(this.getFingerprint());
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FingerprintAttribute.prototype.getFingerprint = function () {
                            if (arguments.length == 0) {
                                return this._fingerprint;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FingerprintAttribute.prototype.getHashFunction = function () {
                            if (arguments.length == 0) {
                                return this._hashFunction;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FingerprintAttribute.prototype.setFingerprint = function (value) {
                            if (arguments.length == 1) {
                                this._fingerprint = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FingerprintAttribute.prototype.setHashFunction = function (value) {
                            if (arguments.length == 1) {
                                this._hashFunction = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return FingerprintAttribute;
                    }(fm.icelink.sdp.Attribute));
                    ice.FingerprintAttribute = FingerprintAttribute;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var LiteAttribute =  (function (_super) {
                        __extends(LiteAttribute, _super);
                        function LiteAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceLiteAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        LiteAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.LiteAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        LiteAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                return new fm.icelink.sdp.ice.LiteAttribute();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        LiteAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                return null;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return LiteAttribute;
                    }(fm.icelink.sdp.Attribute));
                    ice.LiteAttribute = LiteAttribute;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var MismatchAttribute =  (function (_super) {
                        __extends(MismatchAttribute, _super);
                        function MismatchAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceMismatchAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        MismatchAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.MismatchAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        MismatchAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                return new fm.icelink.sdp.ice.MismatchAttribute();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MismatchAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                return null;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return MismatchAttribute;
                    }(fm.icelink.sdp.Attribute));
                    ice.MismatchAttribute = MismatchAttribute;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var OptionsAttribute =  (function (_super) {
                        __extends(OptionsAttribute, _super);
                        function OptionsAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.__tags = new Array();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceOptionsAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                            }
                            else if (__arguments.length == 1) {
                                var tags = __arguments[0];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.__tags = new Array();
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceOptionsAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                                }
                                if ((fm.icelink.Global.equals(tags, null))) {
                                    tags = new Array();
                                }
                                _this.setTags(tags);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        OptionsAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.OptionsAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        OptionsAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var strArray = fm.icelink.StringExtensions.split(value, [32]);
                                var list = new Array();
                                for (var _i = 0, strArray_4 = strArray; _i < strArray_4.length; _i++) {
                                    var str = strArray_4[_i];
                                    var item = fm.icelink.sdp.ice.OptionTag.parse(str);
                                    if ((!fm.icelink.Global.equals(item, null))) {
                                        fm.icelink.ArrayExtensions.add(list, item);
                                    }
                                }
                                var attribute = new fm.icelink.sdp.ice.OptionsAttribute();
                                attribute.setTags(list);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        OptionsAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                if ((fm.icelink.Global.equals(this.getTags(), null))) {
                                    return "";
                                }
                                var count = fm.icelink.ArrayExtensions.getCount(this.getTags());
                                var strArray = new Array(count);
                                for (var i = 0; (i < count); i++) {
                                    strArray[i] = this.getTags()[i].toString();
                                }
                                return fm.icelink.StringExtensions.join(" ", strArray);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        OptionsAttribute.prototype.getTags = function () {
                            if (arguments.length == 0) {
                                return this.__tags;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        OptionsAttribute.prototype.getTrickleOptionSet = function () {
                            if (arguments.length == 0) {
                                for (var _i = 0, _a = this.getTags(); _i < _a.length; _i++) {
                                    var tag = _a[_i];
                                    if ((fm.icelink.Global.equals(tag.getType(), fm.icelink.sdp.ice.OptionTagType.Trickle))) {
                                        return true;
                                    }
                                }
                                return false;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        OptionsAttribute.prototype.setTags = function (value) {
                            if (arguments.length == 1) {
                                this.__tags = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        OptionsAttribute.prototype.setTrickleOptionSet = function (value) {
                            if (arguments.length == 1) {
                                if (value) {
                                    for (var _i = 0, _a = this.getTags(); _i < _a.length; _i++) {
                                        var tag = _a[_i];
                                        if ((fm.icelink.Global.equals(tag.getType(), fm.icelink.sdp.ice.OptionTagType.Trickle))) {
                                            return;
                                        }
                                    }
                                    fm.icelink.ArrayExtensions.add(this.getTags(), new fm.icelink.sdp.ice.TrickleIceOptionTag());
                                }
                                else {
                                    var item = null;
                                    for (var _b = 0, _c = this.getTags(); _b < _c.length; _b++) {
                                        var tag = _c[_b];
                                        if ((fm.icelink.Global.equals(tag.getType(), fm.icelink.sdp.ice.OptionTagType.Trickle))) {
                                            item = tag;
                                        }
                                    }
                                    fm.icelink.ArrayExtensions.remove(this.getTags(), item);
                                }
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return OptionsAttribute;
                    }(fm.icelink.sdp.Attribute));
                    ice.OptionsAttribute = OptionsAttribute;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var OptionTag =  (function () {
                        function OptionTag() {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) ;
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        OptionTag.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.OptionTag]';
                        };
                        OptionTag.getTrickle = function () {
                            if (arguments.length == 0) {
                                return "trickle";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        OptionTag.parse = function (tagString) {
                            if (arguments.length == 1) {
                                if ((fm.icelink.Global.equals(tagString, fm.icelink.sdp.ice.OptionTag.getTrickle()))) {
                                    return new fm.icelink.sdp.ice.TrickleIceOptionTag();
                                }
                                return new fm.icelink.sdp.ice.UnknownIceOptionTag(tagString);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        OptionTag.prototype.getType = function () {
                            if (arguments.length == 0) {
                                return this._type;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        OptionTag.prototype.setType = function (value) {
                            if (arguments.length == 1) {
                                this._type = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return OptionTag;
                    }());
                    ice.OptionTag = OptionTag;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var OptionTagTypeWrapper =  (function () {
                        function OptionTagTypeWrapper(value) {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 1) {
                                var value_57 = __arguments[0];
                                this._value = value_57;
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        OptionTagTypeWrapper.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.OptionTagTypeWrapper]';
                        };
                        OptionTagTypeWrapper.prototype.toString = function () {
                            if (arguments.length == 0) {
                                if (this._value == fm.icelink.sdp.ice.OptionTagType.Unknown)
                                    return 'Unknown';
                                if (this._value == fm.icelink.sdp.ice.OptionTagType.Trickle)
                                    return 'Trickle';
                                return '';
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return OptionTagTypeWrapper;
                    }());
                    ice.OptionTagTypeWrapper = OptionTagTypeWrapper;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var PasswordAttribute =  (function (_super) {
                        __extends(PasswordAttribute, _super);
                        function PasswordAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                __arguments = new Array(1);
                                __arguments[0] = fm.icelink.sdp.ice.PasswordAttribute.generatePassword();
                                {
                                    var password = __arguments[0];
                                    _this = _super.call(this) || this;
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IcePasswordAttribute);
                                    if (((fm.icelink.StringExtensions.getLength(password) < 22) || (fm.icelink.StringExtensions.getLength(password) > 256))) {
                                        throw new fm.icelink.Exception("password must be at least 22 characters long up to 256 characters.");
                                    }
                                    _this.setPassword(password);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                                }
                            }
                            else if (__arguments.length == 1) {
                                var password = __arguments[0];
                                _this = _super.call(this) || this;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IcePasswordAttribute);
                                if (((fm.icelink.StringExtensions.getLength(password) < 22) || (fm.icelink.StringExtensions.getLength(password) > 256))) {
                                    throw new fm.icelink.Exception("password must be at least 22 characters long up to 256 characters.");
                                }
                                _this.setPassword(password);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        PasswordAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.PasswordAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        PasswordAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                return new fm.icelink.sdp.ice.PasswordAttribute(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        PasswordAttribute.generatePassword = function () {
                            if (arguments.length == 0) {
                                return fm.icelink.StringExtensions.replace(fm.icelink.Guid.newGuid().toString(), "-", "");
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        PasswordAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                return this.getPassword();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        PasswordAttribute.prototype.getPassword = function () {
                            if (arguments.length == 0) {
                                return this._password;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        PasswordAttribute.prototype.setPassword = function (value) {
                            if (arguments.length == 1) {
                                this._password = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return PasswordAttribute;
                    }(fm.icelink.sdp.Attribute));
                    ice.PasswordAttribute = PasswordAttribute;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var RemoteCandidate =  (function () {
                        function RemoteCandidate(componentId, connectionAddress, port) {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 3) {
                                var componentId_2 = __arguments[0];
                                var connectionAddress_3 = __arguments[1];
                                var port_2 = __arguments[2];
                                this.fmicelinksdpiceRemoteCandidateInit();
                                if ((fm.icelink.Global.equals(connectionAddress_3, null))) {
                                    throw new fm.icelink.Exception("connectionAddress cannot be null.");
                                }
                                this.setComponentId(componentId_2);
                                this.setConnectionAddress(connectionAddress_3);
                                this.setPort(port_2);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        RemoteCandidate.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.RemoteCandidate]';
                        };
                        RemoteCandidate.prototype.fmicelinksdpiceRemoteCandidateInit = function () {
                            this._componentId = 0;
                            this._port = 0;
                        };
                        RemoteCandidate.parse = function (s) {
                            if (arguments.length == 1) {
                                var strArray = fm.icelink.StringExtensions.split(s, [32]);
                                var componentId = fm.icelink.ParseAssistant.parseIntegerValue(strArray[0]);
                                var connectionAddress = strArray[1];
                                return new fm.icelink.sdp.ice.RemoteCandidate(componentId, connectionAddress, fm.icelink.ParseAssistant.parseIntegerValue(strArray[2]));
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RemoteCandidate.prototype.getComponentId = function () {
                            if (arguments.length == 0) {
                                return this._componentId;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RemoteCandidate.prototype.getConnectionAddress = function () {
                            if (arguments.length == 0) {
                                return this._connectionAddress;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RemoteCandidate.prototype.getPort = function () {
                            if (arguments.length == 0) {
                                return this._port;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RemoteCandidate.prototype.setComponentId = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._componentId = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RemoteCandidate.prototype.setConnectionAddress = function (value) {
                            if (arguments.length == 1) {
                                this._connectionAddress = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RemoteCandidate.prototype.setPort = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._port = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RemoteCandidate.prototype.toString = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(fm.icelink.NumberExtensions.toString(this.getComponentId()));
                                builder.append(" ");
                                builder.append(this.getConnectionAddress());
                                builder.append(" ");
                                builder.append(fm.icelink.NumberExtensions.toString(this.getPort()));
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return RemoteCandidate;
                    }());
                    ice.RemoteCandidate = RemoteCandidate;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var RemoteCandidatesAttribute =  (function (_super) {
                        __extends(RemoteCandidatesAttribute, _super);
                        function RemoteCandidatesAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceRemoteCandidatesAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                            }
                            else if (__arguments.length == 1) {
                                var candidates = __arguments[0];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceRemoteCandidatesAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                                }
                                if ((fm.icelink.Global.equals(candidates, null))) {
                                    throw new fm.icelink.Exception("candidates cannot be null.");
                                }
                                _this.setCandidates(candidates);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        RemoteCandidatesAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.RemoteCandidatesAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        RemoteCandidatesAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var array = fm.icelink.StringExtensions.split(value, [32]);
                                var list = new Array();
                                for (var i = 0; (i < array.length); i = (i + 3)) {
                                    fm.icelink.ArrayExtensions.add(list, fm.icelink.sdp.ice.RemoteCandidate.parse(fm.icelink.StringExtensions.join(" ", fm.icelink.StringAssistant.subArray(array, i, 3))));
                                }
                                var attribute = new fm.icelink.sdp.ice.RemoteCandidatesAttribute();
                                attribute.setCandidates(fm.icelink.ArrayExtensions.toArray(list));
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RemoteCandidatesAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var strArray = new Array(this.getCandidates().length);
                                for (var i = 0; (i < this.getCandidates().length); i++) {
                                    strArray[i] = this.getCandidates()[i].toString();
                                }
                                return fm.icelink.StringExtensions.join(" ", strArray);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RemoteCandidatesAttribute.prototype.getCandidates = function () {
                            if (arguments.length == 0) {
                                return this._candidates;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RemoteCandidatesAttribute.prototype.setCandidates = function (value) {
                            if (arguments.length == 1) {
                                this._candidates = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return RemoteCandidatesAttribute;
                    }(fm.icelink.sdp.Attribute));
                    ice.RemoteCandidatesAttribute = RemoteCandidatesAttribute;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var TransportProtocol =  (function () {
                        function TransportProtocol() {
                        }
                        TransportProtocol.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.TransportProtocol]';
                        };
                        TransportProtocol.getTcp = function () {
                            if (arguments.length == 0) {
                                return "tcp";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        TransportProtocol.getUdp = function () {
                            if (arguments.length == 0) {
                                return "udp";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return TransportProtocol;
                    }());
                    ice.TransportProtocol = TransportProtocol;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var TrickleIceOptionTag =  (function (_super) {
                        __extends(TrickleIceOptionTag, _super);
                        function TrickleIceOptionTag() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _super.prototype.setType.call(_this, fm.icelink.sdp.ice.OptionTagType.Trickle);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        TrickleIceOptionTag.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.TrickleIceOptionTag]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        TrickleIceOptionTag.prototype.toString = function () {
                            if (arguments.length == 0) {
                                return fm.icelink.sdp.ice.OptionTag.getTrickle();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return TrickleIceOptionTag;
                    }(fm.icelink.sdp.ice.OptionTag));
                    ice.TrickleIceOptionTag = TrickleIceOptionTag;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var UfragAttribute =  (function (_super) {
                        __extends(UfragAttribute, _super);
                        function UfragAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                __arguments = new Array(1);
                                __arguments[0] = fm.icelink.sdp.ice.UfragAttribute.generateUfrag();
                                {
                                    var ufrag = __arguments[0];
                                    _this = _super.call(this) || this;
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceUfragAttribute);
                                    if (((fm.icelink.StringExtensions.getLength(ufrag) < 4) || (fm.icelink.StringExtensions.getLength(ufrag) > 256))) {
                                        throw new fm.icelink.Exception("ufrag must be at least 4 characters long up to 256 characters.");
                                    }
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                                    _this.setUfrag(ufrag);
                                }
                            }
                            else if (__arguments.length == 1) {
                                var ufrag = __arguments[0];
                                _this = _super.call(this) || this;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.IceUfragAttribute);
                                if (((fm.icelink.StringExtensions.getLength(ufrag) < 4) || (fm.icelink.StringExtensions.getLength(ufrag) > 256))) {
                                    throw new fm.icelink.Exception("ufrag must be at least 4 characters long up to 256 characters.");
                                }
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                                _this.setUfrag(ufrag);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        UfragAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.UfragAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        UfragAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                return new fm.icelink.sdp.ice.UfragAttribute(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        UfragAttribute.generateUfrag = function () {
                            if (arguments.length == 0) {
                                return fm.icelink.StringExtensions.substring(fm.icelink.StringExtensions.replace(fm.icelink.Guid.newGuid().toString(), "-", ""), 0, 8);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        UfragAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                return this.getUfrag();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        UfragAttribute.prototype.getUfrag = function () {
                            if (arguments.length == 0) {
                                return this._ufrag;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        UfragAttribute.prototype.setUfrag = function (value) {
                            if (arguments.length == 1) {
                                this._ufrag = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return UfragAttribute;
                    }(fm.icelink.sdp.Attribute));
                    ice.UfragAttribute = UfragAttribute;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (ice) {
                    var UnknownIceOptionTag =  (function (_super) {
                        __extends(UnknownIceOptionTag, _super);
                        function UnknownIceOptionTag(tagString) {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 1) {
                                var tagString_1 = __arguments[0];
                                _this = _super.call(this) || this;
                                _super.prototype.setType.call(_this, fm.icelink.sdp.ice.OptionTagType.Unknown);
                                _this.setTagString(tagString_1);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        UnknownIceOptionTag.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.ice.UnknownIceOptionTag]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        UnknownIceOptionTag.prototype.getTagString = function () {
                            if (arguments.length == 0) {
                                return this._tagString;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        UnknownIceOptionTag.prototype.setTagString = function (value) {
                            if (arguments.length == 1) {
                                this._tagString = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        UnknownIceOptionTag.prototype.toString = function () {
                            if (arguments.length == 0) {
                                return this.getTagString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return UnknownIceOptionTag;
                    }(fm.icelink.sdp.ice.OptionTag));
                    ice.UnknownIceOptionTag = UnknownIceOptionTag;
                })(sdp.ice || (sdp.ice = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var InactiveAttribute =  (function (_super) {
                    __extends(InactiveAttribute, _super);
                    function InactiveAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.DirectionAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    InactiveAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.InactiveAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    InactiveAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.InactiveAttribute();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    InactiveAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    InactiveAttribute.prototype.getStreamDirection = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.StreamDirection.Inactive;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return InactiveAttribute;
                }(fm.icelink.sdp.DirectionAttribute));
                sdp.InactiveAttribute = InactiveAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var KeywordsAttribute =  (function (_super) {
                    __extends(KeywordsAttribute, _super);
                    function KeywordsAttribute(keywords) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var keywords_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.KeywordsAttribute);
                            if ((fm.icelink.Global.equals(keywords_1, null))) {
                                throw new fm.icelink.Exception("keywords cannot be null.");
                            }
                            _this.setKeywords(keywords_1);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    KeywordsAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.KeywordsAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    KeywordsAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.KeywordsAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    KeywordsAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getKeywords();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    KeywordsAttribute.prototype.getKeywords = function () {
                        if (arguments.length == 0) {
                            return this._keywords;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    KeywordsAttribute.prototype.setKeywords = function (value) {
                        if (arguments.length == 1) {
                            this._keywords = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return KeywordsAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.KeywordsAttribute = KeywordsAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var LanguageAttribute =  (function (_super) {
                    __extends(LanguageAttribute, _super);
                    function LanguageAttribute(languageTag) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var languageTag_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.LanguageAttribute);
                            if ((fm.icelink.Global.equals(languageTag_1, null))) {
                                throw new fm.icelink.Exception("languageTag cannot be null.");
                            }
                            _this.setLanguageTag(languageTag_1);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    LanguageAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.LanguageAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    LanguageAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.LanguageAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    LanguageAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getLanguageTag();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    LanguageAttribute.prototype.getLanguageTag = function () {
                        if (arguments.length == 0) {
                            return this._languageTag;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    LanguageAttribute.prototype.setLanguageTag = function (value) {
                        if (arguments.length == 1) {
                            this._languageTag = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return LanguageAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.LanguageAttribute = LanguageAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var MaxPacketTimeAttribute =  (function (_super) {
                    __extends(MaxPacketTimeAttribute, _super);
                    function MaxPacketTimeAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                            _this.fmicelinksdpMaxPacketTimeAttributeInit();
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.MaxPacketTimeAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                        }
                        else if (__arguments.length == 1) {
                            var maxPacketTime = __arguments[0];
                            __arguments = new Array(0);
                            {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdpMaxPacketTimeAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.MaxPacketTimeAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                            }
                            _this.setMaxPacketTime(maxPacketTime);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    MaxPacketTimeAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.MaxPacketTimeAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    MaxPacketTimeAttribute.prototype.fmicelinksdpMaxPacketTimeAttributeInit = function () {
                        this._maxPacketTime = 0;
                    };
                    MaxPacketTimeAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            var attribute = new fm.icelink.sdp.MaxPacketTimeAttribute();
                            attribute.setMaxPacketTime(fm.icelink.ParseAssistant.parseIntegerValue(value));
                            return attribute;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MaxPacketTimeAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.NumberExtensions.toString(this.getMaxPacketTime());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MaxPacketTimeAttribute.prototype.getMaxPacketTime = function () {
                        if (arguments.length == 0) {
                            return this._maxPacketTime;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MaxPacketTimeAttribute.prototype.setMaxPacketTime = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._maxPacketTime = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return MaxPacketTimeAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.MaxPacketTimeAttribute = MaxPacketTimeAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var Media =  (function () {
                    function Media() {
                        fm.icelink.sdp.Media.fmicelinksdpMediaInitialize();
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            this.fmicelinksdpMediaInit();
                        }
                        else if (__arguments.length == 3) {
                            var mediaType = __arguments[0];
                            var transportPort = __arguments[1];
                            var transportProtocol = __arguments[2];
                            __arguments = new Array(4);
                            __arguments[0] = mediaType;
                            __arguments[1] = transportPort;
                            __arguments[2] = transportProtocol;
                            __arguments[3] = null;
                            {
                                var mediaType_1 = __arguments[0];
                                var transportPort_1 = __arguments[1];
                                var transportProtocol_1 = __arguments[2];
                                var formatDescription = __arguments[3];
                                this.fmicelinksdpMediaInit();
                                if ((fm.icelink.Global.equals(mediaType_1, null))) {
                                    throw new fm.icelink.Exception("mediaType cannot be null.");
                                }
                                if ((fm.icelink.Global.equals(transportProtocol_1, null))) {
                                    throw new fm.icelink.Exception("transportProtocol cannot be null.");
                                }
                                this.setMediaType(mediaType_1);
                                this.setTransportPort(transportPort_1);
                                this.setNumberOfPorts(fm.icelink.sdp.Media.fm_icelink_sdp_Media__defaultNumberOfPorts);
                                this.setTransportProtocol(transportProtocol_1);
                                this.setFormatDescription(formatDescription);
                            }
                        }
                        else if (__arguments.length == 4) {
                            var mediaType = __arguments[0];
                            var transportPort = __arguments[1];
                            var transportProtocol = __arguments[2];
                            var formatDescription = __arguments[3];
                            this.fmicelinksdpMediaInit();
                            if ((fm.icelink.Global.equals(mediaType, null))) {
                                throw new fm.icelink.Exception("mediaType cannot be null.");
                            }
                            if ((fm.icelink.Global.equals(transportProtocol, null))) {
                                throw new fm.icelink.Exception("transportProtocol cannot be null.");
                            }
                            this.setMediaType(mediaType);
                            this.setTransportPort(transportPort);
                            this.setNumberOfPorts(fm.icelink.sdp.Media.fm_icelink_sdp_Media__defaultNumberOfPorts);
                            this.setTransportProtocol(transportProtocol);
                            this.setFormatDescription(formatDescription);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    Media.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.Media]';
                    };
                    Media.prototype.fmicelinksdpMediaInit = function () {
                        this._numberOfPorts = 0;
                        this._transportPort = 0;
                    };
                    Media.parse = function (s) {
                        fm.icelink.sdp.Media.fmicelinksdpMediaInitialize();
                        if (arguments.length == 1) {
                            var media = void 0;
                            s = s.substring(2);
                            var array = fm.icelink.StringExtensions.split(s, [32]);
                            var mediaType = array[0];
                            var strArray2 = fm.icelink.StringExtensions.split(array[1], [47]);
                            var transportPort = fm.icelink.ParseAssistant.parseIntegerValue(strArray2[0]);
                            var transportProtocol = array[2];
                            var formatDescription = fm.icelink.StringExtensions.join(" ", fm.icelink.StringAssistant.subArray(array, 3));
                            if ((fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.UdpMedia.getUdpTransportProtocol()))) {
                                media = new fm.icelink.sdp.UdpMedia(mediaType, transportPort, formatDescription);
                            }
                            else {
                                if ((((((fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.rtp.Media.getRtpAvpTransportProtocol())) || (fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.rtp.Media.getRtpSavpTransportProtocol()))) || ((fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.rtp.Media.getRtpAvpfTransportProtocol())) || (fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.rtp.Media.getRtpSavpfTransportProtocol())))) || (fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.rtp.Media.getUdpTlsRtpSavpTransportProtocol()))) || (fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.rtp.Media.getUdpTlsRtpSavpfTransportProtocol())))) {
                                    var rtpPayloadTypeNumbers = new Array(0);
                                    if (!fm.icelink.StringExtensions.isNullOrEmpty(formatDescription)) {
                                        var strArray3 = fm.icelink.StringExtensions.split(formatDescription, [32]);
                                        rtpPayloadTypeNumbers = new Array(strArray3.length);
                                        for (var i = 0; (i < rtpPayloadTypeNumbers.length); i++) {
                                            rtpPayloadTypeNumbers[i] = fm.icelink.ParseAssistant.parseIntegerValue(strArray3[i]);
                                        }
                                    }
                                    media = new fm.icelink.sdp.rtp.Media(mediaType, transportPort, transportProtocol, rtpPayloadTypeNumbers);
                                }
                                else {
                                    if (((((fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.sctp.Media.getDtlsSctpTransportProtocol())) || (fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.sctp.Media.getSctpDtlsTransportProtocol()))) || ((fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.sctp.Media.getSctpTransportProtocol())) || (fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.sctp.Media.getTcpDtlsSctpTransportProtocol())))) || (fm.icelink.Global.equals(transportProtocol, fm.icelink.sdp.sctp.Media.getUdpDtlsSctpTransportProtocol())))) {
                                        media = new fm.icelink.sdp.sctp.Media(mediaType, transportPort, transportProtocol, formatDescription);
                                    }
                                    else {
                                        media = new fm.icelink.sdp.Media(mediaType, transportPort, transportProtocol, formatDescription);
                                    }
                                }
                            }
                            if ((fm.icelink.Global.equals(strArray2.length, 2))) {
                                media.setNumberOfPorts(fm.icelink.ParseAssistant.parseShortValue(strArray2[1]));
                            }
                            return media;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.getFormatDescription = function () {
                        if (arguments.length == 0) {
                            return this._formatDescription;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.getMediaType = function () {
                        if (arguments.length == 0) {
                            return this._mediaType;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.getNumberOfPorts = function () {
                        if (arguments.length == 0) {
                            return this._numberOfPorts;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.getTransportPort = function () {
                        if (arguments.length == 0) {
                            return this._transportPort;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.getTransportProtocol = function () {
                        if (arguments.length == 0) {
                            return this._transportProtocol;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.setFormatDescription = function (value) {
                        if (arguments.length == 1) {
                            this._formatDescription = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.setMediaType = function (value) {
                        if (arguments.length == 1) {
                            this._mediaType = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.setNumberOfPorts = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._numberOfPorts = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.setTransportPort = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._transportPort = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.setTransportProtocol = function (value) {
                        if (arguments.length == 1) {
                            this._transportProtocol = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append("m=");
                            builder.append(this.getMediaType());
                            builder.append(" ");
                            builder.append(fm.icelink.NumberExtensions.toString(this.getTransportPort()));
                            if ((this.getNumberOfPorts() > 1)) {
                                builder.append("/");
                                builder.append(fm.icelink.NumberExtensions.toString(this.getNumberOfPorts()));
                            }
                            builder.append(" ");
                            builder.append(this.getTransportProtocol());
                            if ((!fm.icelink.Global.equals(this.getFormatDescription(), null))) {
                                builder.append(" ");
                                builder.append(this.getFormatDescription());
                            }
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Media.fmicelinksdpMediaInitialize = function () {
                        if (!fm.icelink.sdp.Media.__fmicelinksdpMediaInitialized && !fm.icelink.sdp.Media.__fmicelinksdpMediaInitializing) {
                            fm.icelink.sdp.Media.__fmicelinksdpMediaInitializing = true;
                            Media.fm_icelink_sdp_Media__defaultNumberOfPorts = 0;
                            fm.icelink.sdp.Media.fm_icelink_sdp_Media__defaultNumberOfPorts = 1;
                            fm.icelink.sdp.Media.__fmicelinksdpMediaInitialized = true;
                            fm.icelink.sdp.Media.__fmicelinksdpMediaInitializing = false;
                        }
                    };
                    Media.__fmicelinksdpMediaInitialized = false;
                    Media.__fmicelinksdpMediaInitializing = false;
                    return Media;
                }());
                sdp.Media = Media;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var MediaDescription =  (function () {
                    function MediaDescription(media) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var media_1 = __arguments[0];
                            this.__bandwidths = new Array();
                            this.__mediaAttributes = new fm.icelink.sdp.AttributeCollection();
                            this.__orphanedAttributes = new Array();
                            if ((fm.icelink.Global.equals(media_1, null))) {
                                throw new fm.icelink.Exception("media cannot be null.");
                            }
                            this.setMedia(media_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    MediaDescription.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.MediaDescription]';
                    };
                    MediaDescription.getBundleOnlyAttributeFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attributeArray = null;
                            var _var0 = new fm.icelink.Holder(attributeArray);
                            var _var1 = attributes.tryGetAttributes(fm.icelink.sdp.AttributeType.BundleOnlyAttribute, _var0);
                            attributeArray = _var0.getValue();
                            if ((_var1 && (attributeArray.length > 0))) {
                                return attributeArray[0];
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getBundlingSupportFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attributeArray = null;
                            var _var0 = new fm.icelink.Holder(attributeArray);
                            var _var1 = attributes.tryGetAttributes(fm.icelink.sdp.AttributeType.GroupAttribute, _var0);
                            attributeArray = _var0.getValue();
                            if (_var1) {
                                for (var _i = 0, attributeArray_1 = attributeArray; _i < attributeArray_1.length; _i++) {
                                    var attribute = attributeArray_1[_i];
                                    if ((fm.icelink.Global.equals(attribute.getSemantics(), fm.icelink.sdp.GroupSemanticsType.Bundling))) {
                                        return true;
                                    }
                                }
                            }
                            return false;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getCryptoAttributesFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attributeArray = null;
                            var _var0 = new fm.icelink.Holder(attributeArray);
                            var _var1 = attributes.tryGetAttributes(fm.icelink.sdp.AttributeType.CryptoAttribute, _var0);
                            attributeArray = _var0.getValue();
                            if (_var1) {
                                var attributeArray2 = new Array(attributeArray.length);
                                var index = 0;
                                for (var _i = 0, attributeArray_2 = attributeArray; _i < attributeArray_2.length; _i++) {
                                    var attribute = attributeArray_2[_i];
                                    attributeArray2[index] = attribute;
                                    index++;
                                }
                                return attributeArray2;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getFingerprintAttributeFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = attributes.tryGetAttribute(fm.icelink.sdp.AttributeType.IceFingerprintAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getGroupAttributesFromCollection = function (collection) {
                        if (arguments.length == 1) {
                            var attributes = null;
                            var list = new Array();
                            var _var0 = new fm.icelink.Holder(attributes);
                            var _var1 = collection.tryGetAttributes(fm.icelink.sdp.AttributeType.GroupAttribute, _var0);
                            attributes = _var0.getValue();
                            if (_var1) {
                                for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) {
                                    var attribute = attributes_1[_i];
                                    var item = attribute;
                                    fm.icelink.ArrayExtensions.add(list, item);
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getIceOptionAttributesFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attributeArray = null;
                            var _var0 = new fm.icelink.Holder(attributeArray);
                            var _var1 = attributes.tryGetAttributes(fm.icelink.sdp.AttributeType.IceOptionsAttribute, _var0);
                            attributeArray = _var0.getValue();
                            if (_var1) {
                                return attributeArray;
                            }
                            return new Array(0);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getIcePasswordAttributeFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = attributes.tryGetAttribute(fm.icelink.sdp.AttributeType.IcePasswordAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getIceUfragAttributeFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = attributes.tryGetAttribute(fm.icelink.sdp.AttributeType.IceUfragAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getIsMutedFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = attributes.tryGetAttribute(fm.icelink.sdp.AttributeType.MutedAttribute, _var0);
                            attribute = _var0.getValue();
                            return ((!fm.icelink.Global.equals(attributes, null)) && _var1);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getQualityAttributeFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = attributes.tryGetAttribute(fm.icelink.sdp.AttributeType.QualityAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getRtcpMultiplexingSupportFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = attributes.tryGetAttribute(fm.icelink.sdp.AttributeType.RtcpMuxAttribute, _var0);
                            attribute = _var0.getValue();
                            return _var1;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getRtpExtMapAttributesFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attributeArray = null;
                            var _var0 = new fm.icelink.Holder(attributeArray);
                            var _var1 = attributes.tryGetAttributes(fm.icelink.sdp.AttributeType.RtpExtMapAttribute, _var0);
                            attributeArray = _var0.getValue();
                            if (_var1) {
                                return attributeArray;
                            }
                            return new Array(0);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getSetupAttributeFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = attributes.tryGetAttribute(fm.icelink.sdp.AttributeType.SetupAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getStreamDirectionFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = attributes.tryGetAttribute(fm.icelink.sdp.AttributeType.DirectionAttribute, _var0);
                            attribute = _var0.getValue();
                            if (((!fm.icelink.Global.equals(attributes, null)) && _var1)) {
                                return attribute.getStreamDirection();
                            }
                            return fm.icelink.StreamDirection.Unset;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.getSupportsIceFromCollection = function (attributes) {
                        if (arguments.length == 1) {
                            return ((!fm.icelink.Global.equals(fm.icelink.sdp.MediaDescription.getIceUfragAttributeFromCollection(attributes), null)) && (!fm.icelink.Global.equals(fm.icelink.sdp.MediaDescription.getIcePasswordAttributeFromCollection(attributes), null)));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.parse = function (s) {
                        if (arguments.length == 1) {
                            var strArray = fm.icelink.sdp.Utility.splitAndClean(s);
                            if ((!fm.icelink.Global.equals(strArray[0].charCodeAt(0), 109))) {
                                return null;
                            }
                            var description = new fm.icelink.sdp.MediaDescription(fm.icelink.sdp.Media.parse(strArray[0]));
                            var dictionary = {};
                            var dictionary2 = {};
                            var dictionary3 = {};
                            for (var i = 1; (i < strArray.length); i++) {
                                var str = strArray[i];
                                if ((fm.icelink.Global.equals(str.charCodeAt(0), 97))) {
                                    var str2 = void 0;
                                    var attribute = fm.icelink.sdp.Attribute.parse(str);
                                    if (((!fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.RtcpFeedbackAttribute)) && (!fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.FormatParametersAttribute)))) {
                                        description.addMediaAttribute(attribute);
                                        if ((fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.RtpMapAttribute))) {
                                            var attribute2 = attribute;
                                            str2 = fm.icelink.NumberExtensions.toString(attribute2.getPayloadType());
                                            dictionary2[str2] = attribute2;
                                            var attribute3 = null;
                                            var list = null;
                                            var _var0 = new fm.icelink.Holder(attribute3);
                                            var _var1 = fm.icelink.HashExtensions.tryGetValue(dictionary, str2, _var0);
                                            attribute3 = _var0.getValue();
                                            if (_var1) {
                                                attribute2.setRelatedFormatParametersAttribute(attribute3);
                                            }
                                            var _var2 = new fm.icelink.Holder(list);
                                            var _var3 = fm.icelink.HashExtensions.tryGetValue(dictionary3, str2, _var2);
                                            list = _var2.getValue();
                                            if (_var3) {
                                                attribute2.resetRtcpFeedbackAttributes(fm.icelink.ArrayExtensions.toArray(list));
                                            }
                                        }
                                    }
                                    else {
                                        var attribute5 = void 0;
                                        if ((fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.RtcpFeedbackAttribute))) {
                                            var item = attribute;
                                            str2 = fm.icelink.NumberExtensions.toString(item.getPayloadType());
                                            var list2 = null;
                                            var _var4 = new fm.icelink.Holder(list2);
                                            var _var5 = fm.icelink.HashExtensions.tryGetValue(dictionary3, str2, _var4);
                                            list2 = _var4.getValue();
                                            if (!_var5) {
                                                list2 = new Array();
                                            }
                                            fm.icelink.ArrayExtensions.add(list2, item);
                                            dictionary3[str2] = list2;
                                            if ((fm.icelink.Global.equals(str2, "-1"))) {
                                                for (var _i = 0, _a = fm.icelink.HashExtensions.getKeys(dictionary2); _i < _a.length; _i++) {
                                                    var str3 = _a[_i];
                                                    dictionary2[str3].addRelatedRtcpFeedbackAttribute(item);
                                                }
                                            }
                                            else {
                                                attribute5 = null;
                                                var _var6 = new fm.icelink.Holder(attribute5);
                                                var _var7 = fm.icelink.HashExtensions.tryGetValue(dictionary2, str2, _var6);
                                                attribute5 = _var6.getValue();
                                                if (_var7) {
                                                    attribute5.resetRtcpFeedbackAttributes(fm.icelink.ArrayExtensions.toArray(list2));
                                                }
                                            }
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.FormatParametersAttribute))) {
                                                var attribute6 = attribute;
                                                str2 = fm.icelink.NumberExtensions.toString(attribute6.getFormat());
                                                dictionary[str2] = attribute6;
                                                attribute5 = null;
                                                var _var8 = new fm.icelink.Holder(attribute5);
                                                var _var9 = fm.icelink.HashExtensions.tryGetValue(dictionary2, str2, _var8);
                                                attribute5 = _var8.getValue();
                                                if (_var9) {
                                                    attribute5.setRelatedFormatParametersAttribute(attribute6);
                                                }
                                            }
                                        }
                                    }
                                }
                                if ((fm.icelink.Global.equals(str.charCodeAt(0), 105))) {
                                    description.setMediaTitle(str.substring(2));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str.charCodeAt(0), 99))) {
                                        description.setConnectionData(fm.icelink.sdp.ConnectionData.parse(str));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str.charCodeAt(0), 98))) {
                                            description.addBandwidth(fm.icelink.sdp.Bandwidth.parse(str));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str.charCodeAt(0), 107))) {
                                                description.setEncryptionKey(fm.icelink.sdp.EncryptionKey.parse(str));
                                            }
                                        }
                                    }
                                }
                            }
                            return description;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.addBandwidth = function (bandwidth) {
                        if (arguments.length == 1) {
                            fm.icelink.ArrayExtensions.add(this.__bandwidths, bandwidth);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.addMediaAttribute = function (attribute) {
                        if (arguments.length == 1) {
                            var attribute3 = void 0;
                            var type = new fm.icelink.Type(attribute.getTypeString());
                            var flag = fm.icelink.sdp.Attribute.isMediaLevel(type);
                            var flag2 = fm.icelink.sdp.Attribute.isSessionLevel(type);
                            if (!(flag || flag2)) {
                                throw new fm.icelink.Exception("Attribute is not registered.");
                            }
                            if (!(!flag2 || flag)) {
                                throw new fm.icelink.Exception("Attribute is session-only.");
                            }
                            if (((fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.RtcpFeedbackAttribute)) || (fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.FormatParametersAttribute)))) {
                                var payloadType = -1;
                                var attribute2 = null;
                                attribute3 = null;
                                if ((fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.RtcpFeedbackAttribute))) {
                                    attribute2 = attribute;
                                    payloadType = attribute2.getPayloadType();
                                }
                                else {
                                    attribute3 = attribute;
                                    payloadType = attribute3.getFormat();
                                }
                                var flag3 = false;
                                if ((payloadType > -1)) {
                                    var rtpMapAttributes = this.getRtpMapAttributes();
                                    for (var _i = 0, rtpMapAttributes_1 = rtpMapAttributes; _i < rtpMapAttributes_1.length; _i++) {
                                        var attribute4 = rtpMapAttributes_1[_i];
                                        var attribute5 = attribute4;
                                        if ((fm.icelink.Global.equals(payloadType, attribute5.getPayloadType()))) {
                                            flag3 = true;
                                            if ((!fm.icelink.Global.equals(attribute2, null))) {
                                                attribute5.addRelatedRtcpFeedbackAttribute(attribute2);
                                            }
                                            if ((!fm.icelink.Global.equals(attribute3, null))) {
                                                attribute5.setRelatedFormatParametersAttribute(attribute3);
                                            }
                                        }
                                    }
                                }
                                if (!flag3) {
                                    fm.icelink.ArrayExtensions.add(this.__orphanedAttributes, attribute);
                                }
                            }
                            else {
                                this.__mediaAttributes.addAttribute(attribute);
                            }
                            if ((fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.RtpMapAttribute))) {
                                var attribute6 = attribute;
                                var num2 = attribute6.getPayloadType();
                                var attributeArray2 = fm.icelink.ArrayExtensions.toArray(this.__orphanedAttributes);
                                for (var _a = 0, attributeArray2_1 = attributeArray2; _a < attributeArray2_1.length; _a++) {
                                    var attribute7 = attributeArray2_1[_a];
                                    if ((fm.icelink.Global.equals(attribute7.getAttributeType(), fm.icelink.sdp.AttributeType.RtcpFeedbackAttribute))) {
                                        var attribute8 = attribute7;
                                        if ((fm.icelink.Global.equals(attribute8.getPayloadType(), num2))) {
                                            attribute6.addRelatedRtcpFeedbackAttribute(attribute8);
                                            fm.icelink.ArrayExtensions.remove(this.__orphanedAttributes, attribute7);
                                        }
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(attribute7.getAttributeType(), fm.icelink.sdp.AttributeType.FormatParametersAttribute))) {
                                            attribute3 = attribute7;
                                            if ((fm.icelink.Global.equals(attribute3.getFormat(), num2))) {
                                                attribute6.setRelatedFormatParametersAttribute(attribute3);
                                                fm.icelink.ArrayExtensions.remove(this.__orphanedAttributes, attribute7);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getBandwidths = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.ArrayExtensions.toArray(this.__bandwidths);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getBundleOnly = function () {
                        if (arguments.length == 0) {
                            return (!fm.icelink.Global.equals(fm.icelink.sdp.MediaDescription.getBundleOnlyAttributeFromCollection(this.__mediaAttributes), null));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getCandidateAttributes = function () {
                        if (arguments.length == 0) {
                            var attributes = null;
                            var _var0 = new fm.icelink.Holder(attributes);
                            var _var1 = this.__mediaAttributes.tryGetAttributes(fm.icelink.sdp.AttributeType.IceCandidateAttribute, _var0);
                            attributes = _var0.getValue();
                            if (_var1) {
                                return attributes;
                            }
                            return new Array(0);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getCategoryAttributes = function (category) {
                        if (arguments.length == 1) {
                            var list = new Array();
                            for (var _i = 0, _a = this.__mediaAttributes.toArray(); _i < _a.length; _i++) {
                                var attribute = _a[_i];
                                if ((fm.icelink.Global.equals(attribute.getMultiplexingCategory(), category))) {
                                    fm.icelink.ArrayExtensions.add(list, attribute);
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getCcmFirFeedbackAttribute = function (payloadType) {
                        if (arguments.length == 1) {
                            payloadType = fm.icelink.Global.toInt(arguments[0]);
                            return this.getRtcpFeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getCcm(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getFir());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getCcmLrrFeedbackAttribute = function (payloadType) {
                        if (arguments.length == 1) {
                            payloadType = fm.icelink.Global.toInt(arguments[0]);
                            return this.getRtcpFeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getCcm(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getLrr());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getConnectionData = function () {
                        if (arguments.length == 0) {
                            return this._connectionData;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getCryptoAttributes = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getCryptoAttributesFromCollection(this.__mediaAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getEncryptionKey = function () {
                        if (arguments.length == 0) {
                            return this._encryptionKey;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getFingerprintAttribute = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getFingerprintAttributeFromCollection(this.__mediaAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getFormatParametersAttribute = function (payloadType) {
                        if (arguments.length == 1) {
                            payloadType = fm.icelink.Global.toInt(arguments[0]);
                            var attributes = null;
                            var _var0 = new fm.icelink.Holder(attributes);
                            var _var1 = this.__mediaAttributes.tryGetAttributes(fm.icelink.sdp.AttributeType.RtpMapAttribute, _var0);
                            attributes = _var0.getValue();
                            if ((_var1 && (!fm.icelink.Global.equals(attributes, null)))) {
                                for (var _i = 0, attributes_2 = attributes; _i < attributes_2.length; _i++) {
                                    var attribute = attributes_2[_i];
                                    var attribute2 = attribute;
                                    if ((fm.icelink.Global.equals(attribute2.getPayloadType(), payloadType))) {
                                        return attribute2.getRelatedFormatParametersAttribute();
                                    }
                                }
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getFormatParameterValue = function (payloadType, formatParameterName) {
                        if (arguments.length == 2) {
                            payloadType = fm.icelink.Global.toInt(arguments[0]);
                            var rtpMapAttribute = this.getRtpMapAttribute(payloadType);
                            if ((fm.icelink.Global.equals(rtpMapAttribute, null))) {
                                return null;
                            }
                            var relatedFormatParametersAttribute = rtpMapAttribute.getRelatedFormatParametersAttribute();
                            if ((fm.icelink.Global.equals(relatedFormatParametersAttribute, null))) {
                                relatedFormatParametersAttribute = this.getFormatParametersAttribute(payloadType);
                                if ((fm.icelink.Global.equals(relatedFormatParametersAttribute, null))) {
                                    return null;
                                }
                                rtpMapAttribute.setRelatedFormatParametersAttribute(relatedFormatParametersAttribute);
                            }
                            var str = null;
                            var _var0 = new fm.icelink.Holder(str);
                            relatedFormatParametersAttribute.tryGetFormatSpecificParameter(formatParameterName, _var0);
                            str = _var0.getValue();
                            return str;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getIceOptionAttributes = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getIceOptionAttributesFromCollection(this.__mediaAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getIcePasswordAttribute = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getIcePasswordAttributeFromCollection(this.__mediaAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getIceUfragAttribute = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getIceUfragAttributeFromCollection(this.__mediaAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getIdenticalCategoryAttributes = function () {
                        if (arguments.length == 0) {
                            return this.getCategoryAttributes(fm.icelink.sdp.AttributeCategory.Identical);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getIsApplication = function () {
                        if (arguments.length == 0) {
                            return this.isMediaType(fm.icelink.sdp.MediaType.getApplication());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getIsAudio = function () {
                        if (arguments.length == 0) {
                            return this.isMediaType(fm.icelink.sdp.MediaType.getAudio());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getIsMessage = function () {
                        if (arguments.length == 0) {
                            return this.isMediaType(fm.icelink.sdp.MediaType.getMessage());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getIsMuted = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getIsMutedFromCollection(this.__mediaAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getIsText = function () {
                        if (arguments.length == 0) {
                            return this.isMediaType(fm.icelink.sdp.MediaType.getText());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getIsVideo = function () {
                        if (arguments.length == 0) {
                            return this.isMediaType(fm.icelink.sdp.MediaType.getVideo());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getMaxPacketTimeAttribute = function () {
                        if (arguments.length == 0) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__mediaAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.MaxPacketTimeAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getMedia = function () {
                        if (arguments.length == 0) {
                            return this._media;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getMediaAttributes = function () {
                        if (arguments.length == 0) {
                            var list = new Array();
                            for (var _i = 0, _a = this.__mediaAttributes.toArray(); _i < _a.length; _i++) {
                                var attribute = _a[_i];
                                fm.icelink.ArrayExtensions.add(list, attribute);
                                if ((fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.RtpMapAttribute))) {
                                    var attribute2 = attribute;
                                    var relatedRtcpFeedbackAttributes = attribute2.getRelatedRtcpFeedbackAttributes();
                                    if ((!fm.icelink.Global.equals(relatedRtcpFeedbackAttributes, null))) {
                                        for (var _b = 0, relatedRtcpFeedbackAttributes_1 = relatedRtcpFeedbackAttributes; _b < relatedRtcpFeedbackAttributes_1.length; _b++) {
                                            var attribute3 = relatedRtcpFeedbackAttributes_1[_b];
                                            fm.icelink.ArrayExtensions.add(list, attribute3);
                                        }
                                    }
                                    var relatedFormatParametersAttribute = attribute2.getRelatedFormatParametersAttribute();
                                    if ((!fm.icelink.Global.equals(relatedFormatParametersAttribute, null))) {
                                        fm.icelink.ArrayExtensions.add(list, relatedFormatParametersAttribute);
                                    }
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getMediaStreamIdentifierAttribute = function () {
                        if (arguments.length == 0) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__mediaAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.MediaStreamIdAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getMediaTitle = function () {
                        if (arguments.length == 0) {
                            return this._mediaTitle;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getNackFeedbackAttribute = function (payloadType) {
                        if (arguments.length == 1) {
                            payloadType = fm.icelink.Global.toInt(arguments[0]);
                            return this.getRtcpFeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), null);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getNackPliFeedbackAttribute = function (payloadType) {
                        if (arguments.length == 1) {
                            payloadType = fm.icelink.Global.toInt(arguments[0]);
                            return this.getRtcpFeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getPli());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getNackRpsiFeedbackAttribute = function (payloadType) {
                        if (arguments.length == 1) {
                            payloadType = fm.icelink.Global.toInt(arguments[0]);
                            return this.getRtcpFeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getRpsi());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getNackSliFeedbackAttribute = function (payloadType) {
                        if (arguments.length == 1) {
                            payloadType = fm.icelink.Global.toInt(arguments[0]);
                            return this.getRtcpFeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getSli());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getPacketTimeAttribute = function () {
                        if (arguments.length == 0) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__mediaAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.PacketTimeAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getPreferredRtpMapAttributes = function () {
                        if (arguments.length == 0) {
                            var media = this.getMedia();
                            if ((fm.icelink.Global.equals(media, null))) {
                                return new Array(0);
                            }
                            var list = new Array();
                            var formatDescription = media.getFormatDescription();
                            if ((!fm.icelink.Global.equals(formatDescription, null))) {
                                var strArray = fm.icelink.StringExtensions.split(formatDescription, [32]);
                                for (var _i = 0, strArray_5 = strArray; _i < strArray_5.length; _i++) {
                                    var str2 = strArray_5[_i];
                                    var intResult = 0;
                                    var _var0 = new fm.icelink.Holder(intResult);
                                    var _var1 = fm.icelink.ParseAssistant.tryParseIntegerValue(str2, _var0);
                                    intResult = _var0.getValue();
                                    if (_var1) {
                                        fm.icelink.ArrayExtensions.add(list, this.getRtpMapAttribute(intResult) || fm.icelink.sdp.rtp.MapAttribute.getIanaMapAttribute(intResult));
                                    }
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getQualityAttribute = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getQualityAttributeFromCollection(this.__mediaAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getRidAttribute = function (rid) {
                        if (arguments.length == 1) {
                            var attributes = null;
                            var _var0 = new fm.icelink.Holder(attributes);
                            var _var1 = this.__mediaAttributes.tryGetAttributes(fm.icelink.sdp.AttributeType.RtpRidAttribute, _var0);
                            attributes = _var0.getValue();
                            if (_var1) {
                                for (var _i = 0, attributes_3 = attributes; _i < attributes_3.length; _i++) {
                                    var attribute = attributes_3[_i];
                                    var attribute2 = attribute;
                                    if ((fm.icelink.Global.equals(attribute2.getId(), rid))) {
                                        return attribute2;
                                    }
                                }
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getRidAttributes = function () {
                        if (arguments.length == 0) {
                            var list = new Array();
                            var attributes = null;
                            var _var0 = new fm.icelink.Holder(attributes);
                            var _var1 = this.__mediaAttributes.tryGetAttributes(fm.icelink.sdp.AttributeType.RtpRidAttribute, _var0);
                            attributes = _var0.getValue();
                            if (_var1) {
                                for (var _i = 0, attributes_4 = attributes; _i < attributes_4.length; _i++) {
                                    var attribute = attributes_4[_i];
                                    fm.icelink.ArrayExtensions.add(list, attribute);
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else if (arguments.length == 1) {
                            var direction = arguments[0];
                            var list = new Array();
                            for (var _a = 0, _b = this.getRidAttributes(); _a < _b.length; _a++) {
                                var attribute = _b[_a];
                                if ((fm.icelink.Global.equals(attribute.getDirection(), direction))) {
                                    fm.icelink.ArrayExtensions.add(list, attribute);
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getRtcpAttribute = function () {
                        if (arguments.length == 0) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__mediaAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.RtcpAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getRtcpFeedbackAttribute = function (payloadType, type, subType) {
                        if (arguments.length == 3) {
                            payloadType = fm.icelink.Global.toInt(arguments[0]);
                            var attributes = null;
                            var _var0 = new fm.icelink.Holder(attributes);
                            var _var1 = this.__mediaAttributes.tryGetAttributes(fm.icelink.sdp.AttributeType.RtpMapAttribute, _var0);
                            attributes = _var0.getValue();
                            if (_var1) {
                                for (var _i = 0, attributes_5 = attributes; _i < attributes_5.length; _i++) {
                                    var attribute = attributes_5[_i];
                                    var attribute2 = attribute;
                                    if ((fm.icelink.Global.equals(attribute2.getPayloadType(), payloadType))) {
                                        return attribute2.getRelatedRtcpFeedbackAttribute(payloadType, type, subType);
                                    }
                                }
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getRtcpMultiplexingSupported = function () {
                        if (arguments.length == 0) {
                            var rtcpMultiplexingSupportFromCollection = fm.icelink.sdp.MediaDescription.getRtcpMultiplexingSupportFromCollection(this.__mediaAttributes);
                            if (!rtcpMultiplexingSupportFromCollection) {
                                rtcpMultiplexingSupportFromCollection = (!fm.icelink.Global.equals(fm.icelink.sdp.MediaDescription.getBundleOnlyAttributeFromCollection(this.__mediaAttributes), null));
                            }
                            return rtcpMultiplexingSupportFromCollection;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getRtcpMuxAttribute = function () {
                        if (arguments.length == 0) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__mediaAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.RtcpMuxAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getRtpExtMapAttributes = function () {
                        if (arguments.length == 0) {
                            var attributes = null;
                            var _var0 = new fm.icelink.Holder(attributes);
                            this.__mediaAttributes.tryGetAttributes(fm.icelink.sdp.AttributeType.RtpExtMapAttribute, _var0);
                            attributes = _var0.getValue();
                            return ((fm.icelink.Global.equals(attributes, null)) ? new Array(0) : attributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getRtpMapAttribute = function () {
                        if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0])) && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isNumber(arguments[1]))) {
                            var formatName = arguments[0];
                            var clockRate = fm.icelink.Global.toInt(arguments[1]);
                            return this.getRtpMapAttribute(formatName, clockRate, null);
                        }
                        else if (arguments.length == 3) {
                            var formatName = arguments[0];
                            var clockRate = fm.icelink.Global.toInt(arguments[1]);
                            var formatParameters = arguments[2];
                            var rtpMapAttributeIndex = -1;
                            var _var0 = new fm.icelink.Holder(rtpMapAttributeIndex);
                            var _var1 = this.getRtpMapAttribute(formatName, clockRate, formatParameters, _var0);
                            rtpMapAttributeIndex = _var0.getValue();
                            return _var1;
                        }
                        else if (arguments.length == 4) {
                            var formatName = arguments[0];
                            var clockRate = fm.icelink.Global.toInt(arguments[1]);
                            var formatParameters = arguments[2];
                            var rtpMapAttributeIndex = arguments[3];
                            rtpMapAttributeIndex.setValue(-1);
                            var rtpMapAttributes = this.getRtpMapAttributes();
                            var attribute = null;
                            for (var i = 0; (i < rtpMapAttributes.length); i++) {
                                attribute = rtpMapAttributes[i];
                                if ((((fm.icelink.Global.equals(attribute.getFormatName(), formatName)) && (fm.icelink.Global.equals(attribute.getClockRate(), clockRate))) && (fm.icelink.Global.equals(attribute.getFormatParameters(), formatParameters)))) {
                                    rtpMapAttributeIndex.setValue(i);
                                    return attribute;
                                }
                            }
                            return null;
                        }
                        else if (arguments.length == 1) {
                            var payloadType = fm.icelink.Global.toInt(arguments[0]);
                            var rtpMapAttributeIndex = -1;
                            var _var0 = new fm.icelink.Holder(rtpMapAttributeIndex);
                            var _var1 = this.getRtpMapAttribute(payloadType, _var0);
                            rtpMapAttributeIndex = _var0.getValue();
                            return _var1;
                        }
                        else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0])) && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isObjectType(arguments[1], '[fm.icelink.Holder<number>]'))) {
                            var payloadType = fm.icelink.Global.toInt(arguments[0]);
                            var rtpMapAttributeIndex = arguments[1];
                            rtpMapAttributeIndex.setValue(-1);
                            var rtpMapAttributes = this.getRtpMapAttributes();
                            var attribute = null;
                            for (var i = 0; (i < rtpMapAttributes.length); i++) {
                                attribute = rtpMapAttributes[i];
                                if ((fm.icelink.Global.equals(attribute.getPayloadType(), payloadType))) {
                                    rtpMapAttributeIndex.setValue(i);
                                    return attribute;
                                }
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getRtpMapAttributes = function () {
                        if (arguments.length == 0) {
                            var list = new Array();
                            var attributes = null;
                            var _var0 = new fm.icelink.Holder(attributes);
                            var _var1 = this.__mediaAttributes.tryGetAttributes(fm.icelink.sdp.AttributeType.RtpMapAttribute, _var0);
                            attributes = _var0.getValue();
                            if (_var1) {
                                for (var _i = 0, attributes_6 = attributes; _i < attributes_6.length; _i++) {
                                    var attribute = attributes_6[_i];
                                    fm.icelink.ArrayExtensions.add(list, attribute);
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else if (arguments.length == 3) {
                            var formatName = arguments[0];
                            var clockRate = fm.icelink.Global.toInt(arguments[1]);
                            var formatParameters = arguments[2];
                            var rtpMapAttributeIndices = new Array(0);
                            var _var0 = new fm.icelink.Holder(rtpMapAttributeIndices);
                            var _var1 = this.getRtpMapAttributes(formatName, clockRate, formatParameters, _var0);
                            rtpMapAttributeIndices = _var0.getValue();
                            return _var1;
                        }
                        else if (arguments.length == 4) {
                            var formatName = arguments[0];
                            var clockRate = fm.icelink.Global.toInt(arguments[1]);
                            var formatParameters = arguments[2];
                            var rtpMapAttributeIndices = arguments[3];
                            var num = void 0;
                            var rtpMapAttributes = this.getRtpMapAttributes();
                            var item = null;
                            var list = new Array();
                            var list2 = new Array();
                            for (num = 0; (num < rtpMapAttributes.length); num++) {
                                item = rtpMapAttributes[num];
                                if ((((fm.icelink.Global.equals(item.getFormatName(), formatName)) && (fm.icelink.Global.equals(item.getClockRate(), clockRate))) && (fm.icelink.Global.equals(item.getFormatParameters(), formatParameters)))) {
                                    fm.icelink.ArrayExtensions.add(list, item);
                                    fm.icelink.ArrayExtensions.add(list2, num);
                                }
                            }
                            if ((fm.icelink.Global.equals(fm.icelink.ArrayExtensions.getCount(list2), 0))) {
                                rtpMapAttributeIndices.setValue(new Array(0));
                                return new Array(0);
                            }
                            rtpMapAttributeIndices.setValue(new Array(fm.icelink.ArrayExtensions.getCount(list2)));
                            for (num = 0; (num < fm.icelink.ArrayExtensions.getCount(list2)); num++) {
                                rtpMapAttributeIndices.getValue()[num] = list2[num];
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getSctpMapAttribute = function () {
                        if (arguments.length == 0) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__mediaAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.SctpMapAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getSctpMaxMessageSizeAttribute = function () {
                        if (arguments.length == 0) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__mediaAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.SctpMaxMessageSizeAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getSctpPortAttribute = function () {
                        if (arguments.length == 0) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__mediaAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.SctpPortAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getSetupAttribute = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getSetupAttributeFromCollection(this.__mediaAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getSimulcastAttribute = function () {
                        if (arguments.length == 0) {
                            var attribute = null;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__mediaAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.SimulcastAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                return attribute;
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getSsrcAttribute = function () {
                        if (arguments.length == 2) {
                            var ssrc = fm.icelink.Global.toInt(arguments[0]);
                            var name_26 = arguments[1];
                            var ssrcAttributes = this.getSsrcAttributes(ssrc, name_26);
                            var index = 0;
                            while ((index < ssrcAttributes.length)) {
                                return ssrcAttributes[index];
                            }
                            return null;
                        }
                        else if (arguments.length == 3) {
                            var ssrc = fm.icelink.Global.toInt(arguments[0]);
                            var name_27 = arguments[1];
                            var value = arguments[2];
                            for (var _i = 0, _a = this.getSsrcAttributes(ssrc, name_27); _i < _a.length; _i++) {
                                var attribute = _a[_i];
                                if ((fm.icelink.Global.equals(attribute.getValue(), value))) {
                                    return attribute;
                                }
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getSsrcAttributes = function () {
                        if (arguments.length == 0) {
                            var attributes = null;
                            var _var0 = new fm.icelink.Holder(attributes);
                            this.__mediaAttributes.tryGetAttributes(fm.icelink.sdp.AttributeType.RtpSsrcAttribute, _var0);
                            attributes = _var0.getValue();
                            var list = new Array();
                            for (var _i = 0, attributes_7 = attributes; _i < attributes_7.length; _i++) {
                                var attribute = attributes_7[_i];
                                fm.icelink.ArrayExtensions.add(list, attribute);
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                            var name_28 = arguments[0];
                            var list = new Array();
                            for (var _a = 0, _b = this.getSsrcAttributes(); _a < _b.length; _a++) {
                                var attribute = _b[_a];
                                if ((fm.icelink.Global.equals(attribute.getName(), name_28))) {
                                    fm.icelink.ArrayExtensions.add(list, attribute);
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                            var ssrc = fm.icelink.Global.toInt(arguments[0]);
                            var list = new Array();
                            for (var _c = 0, _d = this.getSsrcAttributes(); _c < _d.length; _c++) {
                                var attribute = _d[_c];
                                if ((fm.icelink.Global.equals(attribute.getSynchronizationSource(), ssrc))) {
                                    fm.icelink.ArrayExtensions.add(list, attribute);
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else if (arguments.length == 2) {
                            var ssrc = fm.icelink.Global.toInt(arguments[0]);
                            var name_29 = arguments[1];
                            var list = new Array();
                            for (var _e = 0, _f = this.getSsrcAttributes(ssrc); _e < _f.length; _e++) {
                                var attribute = _f[_e];
                                if ((fm.icelink.Global.equals(attribute.getName(), name_29))) {
                                    fm.icelink.ArrayExtensions.add(list, attribute);
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getSsrcGroupAttributes = function () {
                        if (arguments.length == 0) {
                            var attributes = null;
                            var _var0 = new fm.icelink.Holder(attributes);
                            this.__mediaAttributes.tryGetAttributes(fm.icelink.sdp.AttributeType.RtpSsrcGroupAttribute, _var0);
                            attributes = _var0.getValue();
                            var list = new Array();
                            for (var _i = 0, attributes_8 = attributes; _i < attributes_8.length; _i++) {
                                var attribute = attributes_8[_i];
                                fm.icelink.ArrayExtensions.add(list, attribute);
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getSsrcGroupSsrcs = function (semantics) {
                        if (arguments.length == 1) {
                            for (var _i = 0, _a = this.getSsrcGroupAttributes(); _i < _a.length; _i++) {
                                var attribute = _a[_i];
                                if ((fm.icelink.Global.equals(attribute.getSemantics(), semantics))) {
                                    return attribute.getSynchronizationSources();
                                }
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getStreamDirection = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getStreamDirectionFromCollection(this.__mediaAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getSupportsIce = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getSupportsIceFromCollection(this.__mediaAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.getTransportCategoryAttributes = function () {
                        if (arguments.length == 0) {
                            return this.getCategoryAttributes(fm.icelink.sdp.AttributeCategory.Transport);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.insertMediaAttribute = function (attribute, index) {
                        if (arguments.length == 2) {
                            index = fm.icelink.Global.toInt(arguments[1]);
                            this.addMediaAttribute(attribute);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.isMediaType = function (mediaType) {
                        if (arguments.length == 1) {
                            var media = this.getMedia();
                            return ((!fm.icelink.Global.equals(media, null)) && (fm.icelink.Global.equals(media.getMediaType(), mediaType)));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.orderFormats = function (names) {
                        if (arguments.length == 1) {
                            var media = this.getMedia();
                            if ((fm.icelink.Global.equals(media, null))) {
                                return false;
                            }
                            var strArray = fm.icelink.StringExtensions.split(media.getFormatDescription(), [32]);
                            var list = new Array();
                            var list2 = new Array();
                            for (var _i = 0, strArray_6 = strArray; _i < strArray_6.length; _i++) {
                                var str = strArray_6[_i];
                                var intResult = 0;
                                var _var0 = new fm.icelink.Holder(intResult);
                                var _var1 = fm.icelink.ParseAssistant.tryParseIntegerValue(str, _var0);
                                intResult = _var0.getValue();
                                if (_var1) {
                                    var rtpMapAttribute = this.getRtpMapAttribute(intResult);
                                    if ((!fm.icelink.Global.equals(rtpMapAttribute, null))) {
                                        fm.icelink.ArrayExtensions.add(list2, rtpMapAttribute);
                                    }
                                }
                            }
                            for (var _a = 0, names_1 = names; _a < names_1.length; _a++) {
                                var str2 = names_1[_a];
                                for (var _b = 0, list2_1 = list2; _b < list2_1.length; _b++) {
                                    var attribute = list2_1[_b];
                                    if (fm.icelink.StringExtensions.isEqual(attribute.getFormatName(), str2, fm.icelink.StringComparison.InvariantCultureIgnoreCase)) {
                                        fm.icelink.ArrayExtensions.add(list, fm.icelink.NumberExtensions.toString(attribute.getPayloadType()));
                                    }
                                }
                            }
                            for (var _c = 0, list2_2 = list2; _c < list2_2.length; _c++) {
                                var attribute = list2_2[_c];
                                var flag = false;
                                for (var _d = 0, list_5 = list; _d < list_5.length; _d++) {
                                    var str3 = list_5[_d];
                                    if ((fm.icelink.Global.equals(str3, fm.icelink.NumberExtensions.toString(attribute.getPayloadType())))) {
                                        flag = true;
                                        break;
                                    }
                                }
                                if (!flag) {
                                    fm.icelink.ArrayExtensions.add(list, fm.icelink.NumberExtensions.toString(attribute.getPayloadType()));
                                }
                            }
                            media.setFormatDescription(fm.icelink.StringExtensions.join(" ", fm.icelink.ArrayExtensions.toArray(list)));
                            return true;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.purgeFormat = function () {
                        if (arguments.length == 1) {
                            var name_30 = arguments[0];
                            return this.purgeFormat(name_30, -1);
                        }
                        else if (arguments.length == 2) {
                            var name_31 = arguments[0];
                            var clockRate = fm.icelink.Global.toInt(arguments[1]);
                            return this.purgeFormat(name_31, clockRate, -1);
                        }
                        else if (arguments.length == 3) {
                            var name_32 = arguments[0];
                            var clockRate = fm.icelink.Global.toInt(arguments[1]);
                            var channelCount = fm.icelink.Global.toInt(arguments[2]);
                            var flag = false;
                            var rtpMapAttributes = this.getRtpMapAttributes();
                            for (var _i = 0, rtpMapAttributes_2 = rtpMapAttributes; _i < rtpMapAttributes_2.length; _i++) {
                                var attribute = rtpMapAttributes_2[_i];
                                if ((((fm.icelink.StringExtensions.isEqual(attribute.getFormatName(), name_32, fm.icelink.StringComparison.InvariantCultureIgnoreCase) && ((fm.icelink.Global.equals(clockRate, -1)) || (fm.icelink.Global.equals(clockRate, attribute.getClockRate())))) && ((fm.icelink.Global.equals(channelCount, -1)) || (fm.icelink.Global.equals(fm.icelink.NumberExtensions.toString(channelCount), attribute.getFormatParameters())))) && this.purgeRtpMapAttribute(attribute))) {
                                    flag = true;
                                }
                            }
                            return flag;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.purgeRtpMapAttribute = function (rtpMapAttribute) {
                        if (arguments.length == 1) {
                            var media = this.getMedia();
                            if ((fm.icelink.Global.equals(media, null))) {
                                return false;
                            }
                            if (!this.removeMediaAttribute(rtpMapAttribute)) {
                                return false;
                            }
                            var str = fm.icelink.NumberExtensions.toString(rtpMapAttribute.getPayloadType());
                            var relatedRtcpFeedbackAttributes = rtpMapAttribute.getRelatedRtcpFeedbackAttributes();
                            if ((!fm.icelink.Global.equals(relatedRtcpFeedbackAttributes, null))) {
                                for (var _i = 0, relatedRtcpFeedbackAttributes_2 = relatedRtcpFeedbackAttributes; _i < relatedRtcpFeedbackAttributes_2.length; _i++) {
                                    var attribute = relatedRtcpFeedbackAttributes_2[_i];
                                    this.removeMediaAttribute(attribute);
                                }
                            }
                            var relatedFormatParametersAttribute = rtpMapAttribute.getRelatedFormatParametersAttribute();
                            if ((!fm.icelink.Global.equals(relatedFormatParametersAttribute, null))) {
                                this.removeMediaAttribute(relatedFormatParametersAttribute);
                            }
                            var formatDescription = media.getFormatDescription();
                            if ((!fm.icelink.Global.equals(formatDescription, null))) {
                                var list = new Array();
                                var strArray = fm.icelink.StringExtensions.split(formatDescription, [32]);
                                for (var _a = 0, strArray_7 = strArray; _a < strArray_7.length; _a++) {
                                    var str3 = strArray_7[_a];
                                    if ((!fm.icelink.Global.equals(str3, str))) {
                                        fm.icelink.ArrayExtensions.add(list, str3);
                                    }
                                }
                                media.setFormatDescription(fm.icelink.StringExtensions.join(" ", fm.icelink.ArrayExtensions.toArray(list)));
                            }
                            for (var _b = 0, _c = this.getRtpMapAttributes(); _b < _c.length; _b++) {
                                var attribute3 = _c[_b];
                                if (fm.icelink.StringExtensions.isEqual(attribute3.getFormatName(), "rtx", fm.icelink.StringComparison.InvariantCultureIgnoreCase)) {
                                    var attribute4 = attribute3.getRelatedFormatParametersAttribute();
                                    if (((!fm.icelink.Global.equals(attribute4, null)) && (fm.icelink.Global.equals(attribute4.getFormatSpecificParameter("apt"), str)))) {
                                        this.purgeRtpMapAttribute(attribute3);
                                    }
                                }
                            }
                            return true;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.removeBandwidth = function (bandwidth) {
                        if (arguments.length == 1) {
                            return fm.icelink.ArrayExtensions.remove(this.__bandwidths, bandwidth);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.removeBundleCategoryAttributes = function () {
                        if (arguments.length == 0) {
                            this.removeTransportCategoryAttributes();
                            this.removeIdenticalCategoryAttributes();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.removeIdenticalCategoryAttributes = function () {
                        if (arguments.length == 0) {
                            var identicalCategoryAttributes = this.getIdenticalCategoryAttributes();
                            for (var _i = 0, identicalCategoryAttributes_1 = identicalCategoryAttributes; _i < identicalCategoryAttributes_1.length; _i++) {
                                var attribute = identicalCategoryAttributes_1[_i];
                                this.__mediaAttributes.remove(attribute);
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.removeMediaAttribute = function (attribute) {
                        if (arguments.length == 1) {
                            var rtpMapAttributes = void 0;
                            var attribute4 = void 0;
                            var flag = void 0;
                            var _var0 = attribute.getAttributeType();
                            do {
                                if (_var0 == fm.icelink.sdp.AttributeType.FormatParametersAttribute) {
                                    var attribute2 = attribute;
                                    rtpMapAttributes = this.getRtpMapAttributes();
                                    for (var _i = 0, rtpMapAttributes_3 = rtpMapAttributes; _i < rtpMapAttributes_3.length; _i++) {
                                        var attribute3 = rtpMapAttributes_3[_i];
                                        attribute4 = attribute3;
                                        if ((!fm.icelink.Global.equals(attribute4.getRelatedFormatParametersAttribute(), null))) {
                                            flag = (fm.icelink.Global.equals(attribute4.getRelatedFormatParametersAttribute().getFormat(), attribute2.getFormat()));
                                            if (flag) {
                                                attribute4.setRelatedFormatParametersAttribute(null);
                                                return flag;
                                            }
                                        }
                                    }
                                    break;
                                }
                                else if (_var0 == fm.icelink.sdp.AttributeType.RtcpFeedbackAttribute) {
                                    var attribute5 = attribute;
                                    rtpMapAttributes = this.getRtpMapAttributes();
                                    for (var _a = 0, rtpMapAttributes_4 = rtpMapAttributes; _a < rtpMapAttributes_4.length; _a++) {
                                        var attribute3 = rtpMapAttributes_4[_a];
                                        attribute4 = attribute3;
                                        if ((!fm.icelink.Global.equals(attribute4.getRelatedRtcpFeedbackAttributes(), null))) {
                                            flag = attribute4.removeRelatedRtcpFeedbackAttribute(attribute5);
                                            if (flag) {
                                                return flag;
                                            }
                                        }
                                    }
                                    break;
                                }
                                else {
                                    return this.__mediaAttributes.remove(attribute);
                                }
                            } while (false);
                            return false;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.removeTransportCategoryAttributes = function () {
                        if (arguments.length == 0) {
                            var transportCategoryAttributes = this.getTransportCategoryAttributes();
                            for (var _i = 0, transportCategoryAttributes_1 = transportCategoryAttributes; _i < transportCategoryAttributes_1.length; _i++) {
                                var attribute = transportCategoryAttributes_1[_i];
                                this.__mediaAttributes.remove(attribute);
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setConnectionData = function (value) {
                        if (arguments.length == 1) {
                            this._connectionData = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setEncryptionKey = function (value) {
                        if (arguments.length == 1) {
                            this._encryptionKey = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setFormatParameterValue = function (payloadType, formatParameterName, formatParameterValue) {
                        if (arguments.length == 3) {
                            payloadType = fm.icelink.Global.toInt(arguments[0]);
                            var rtpMapAttributeIndex = -1;
                            var _var0 = new fm.icelink.Holder(rtpMapAttributeIndex);
                            var _var1 = this.getRtpMapAttribute(payloadType, _var0);
                            rtpMapAttributeIndex = _var0.getValue();
                            var rtpMapAttribute = _var1;
                            if ((fm.icelink.Global.equals(rtpMapAttribute, null))) {
                                return false;
                            }
                            var relatedFormatParametersAttribute = rtpMapAttribute.getRelatedFormatParametersAttribute();
                            if ((fm.icelink.Global.equals(relatedFormatParametersAttribute, null))) {
                                relatedFormatParametersAttribute = this.getFormatParametersAttribute(payloadType);
                                if ((fm.icelink.Global.equals(relatedFormatParametersAttribute, null))) {
                                    relatedFormatParametersAttribute = new fm.icelink.sdp.FormatParametersAttribute(payloadType);
                                    this.insertMediaAttribute(relatedFormatParametersAttribute, (rtpMapAttributeIndex + 1));
                                }
                                rtpMapAttribute.setRelatedFormatParametersAttribute(relatedFormatParametersAttribute);
                            }
                            relatedFormatParametersAttribute.setFormatSpecificParameter(formatParameterName, formatParameterValue);
                            return true;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setIsMuted = function (value) {
                        if (arguments.length == 1) {
                            if (value) {
                                var attribute = new fm.icelink.sdp.MutedAttribute(value);
                                this.__mediaAttributes.replaceAttribute(attribute);
                            }
                            else {
                                var attributes = null;
                                var _var0 = new fm.icelink.Holder(attributes);
                                var _var1 = this.__mediaAttributes.tryGetAttributes(fm.icelink.sdp.AttributeType.MutedAttribute, _var0);
                                attributes = _var0.getValue();
                                if (_var1) {
                                    for (var _i = 0, attributes_9 = attributes; _i < attributes_9.length; _i++) {
                                        var attribute2 = attributes_9[_i];
                                        this.removeMediaAttribute(attribute2);
                                    }
                                }
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setMedia = function (value) {
                        if (arguments.length == 1) {
                            this._media = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setMediaTitle = function (value) {
                        if (arguments.length == 1) {
                            this._mediaTitle = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setQualityAttribute = function (value) {
                        if (arguments.length == 1) {
                            this.__mediaAttributes.replaceAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setRtcpAttribute = function (value) {
                        if (arguments.length == 1) {
                            this.__mediaAttributes.replaceAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setRtcpMultiplexingSupported = function (value) {
                        if (arguments.length == 1) {
                            var rtcpMultiplexingSupportFromCollection = fm.icelink.sdp.MediaDescription.getRtcpMultiplexingSupportFromCollection(this.__mediaAttributes);
                            if (value) {
                                if (!rtcpMultiplexingSupportFromCollection) {
                                    this.addMediaAttribute(new fm.icelink.sdp.rtcp.MuxAttribute());
                                }
                            }
                            else {
                                if (rtcpMultiplexingSupportFromCollection) {
                                    this.__mediaAttributes.remove(fm.icelink.sdp.AttributeType.RtcpMuxAttribute);
                                }
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setSetupAttribute = function (value) {
                        if (arguments.length == 1) {
                            this.__mediaAttributes.replaceAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.setStreamDirection = function (value) {
                        if (arguments.length == 1) {
                            var attribute = fm.icelink.sdp.DirectionAttribute.generateDirectionAttribute(value);
                            this.__mediaAttributes.replaceAttribute(attribute);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append(fm.icelink.StringExtensions.concat(this.getMedia().toString(), "\r\n"));
                            if ((!fm.icelink.Global.equals(this.getMediaTitle(), null))) {
                                builder.append(fm.icelink.StringExtensions.concat("i=", this.getMediaTitle(), "\r\n"));
                            }
                            if ((!fm.icelink.Global.equals(this.getConnectionData(), null))) {
                                builder.append(fm.icelink.StringExtensions.concat(this.getConnectionData().toString(), "\r\n"));
                            }
                            for (var _i = 0, _a = this.getBandwidths(); _i < _a.length; _i++) {
                                var bandwidth = _a[_i];
                                builder.append(fm.icelink.StringExtensions.concat(bandwidth.toString(), "\r\n"));
                            }
                            if ((!fm.icelink.Global.equals(this.getEncryptionKey(), null))) {
                                builder.append(fm.icelink.StringExtensions.concat(this.getEncryptionKey().toString(), "\r\n"));
                            }
                            for (var _b = 0, _c = this.__mediaAttributes.toArray(); _b < _c.length; _b++) {
                                var attribute = _c[_b];
                                builder.append(fm.icelink.StringExtensions.concat(attribute.toString(), "\r\n"));
                                if ((fm.icelink.Global.equals(attribute.getAttributeType(), fm.icelink.sdp.AttributeType.RtpMapAttribute))) {
                                    var attribute2 = attribute;
                                    var relatedRtcpFeedbackAttributes = attribute2.getRelatedRtcpFeedbackAttributes();
                                    if ((!fm.icelink.Global.equals(relatedRtcpFeedbackAttributes, null))) {
                                        for (var _d = 0, relatedRtcpFeedbackAttributes_3 = relatedRtcpFeedbackAttributes; _d < relatedRtcpFeedbackAttributes_3.length; _d++) {
                                            var attribute3 = relatedRtcpFeedbackAttributes_3[_d];
                                            builder.append(fm.icelink.StringExtensions.concat(attribute3.toString(), "\r\n"));
                                        }
                                    }
                                    var relatedFormatParametersAttribute = attribute2.getRelatedFormatParametersAttribute();
                                    if ((!fm.icelink.Global.equals(relatedFormatParametersAttribute, null))) {
                                        builder.append(fm.icelink.StringExtensions.concat(relatedFormatParametersAttribute.toString(), "\r\n"));
                                    }
                                }
                            }
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaDescription.prototype.updateQualityAttributeValue = function (quality) {
                        if (arguments.length == 1) {
                            quality = fm.icelink.Global.toInt(arguments[0]);
                            this.__mediaAttributes.replaceAttribute(new fm.icelink.sdp.QualityAttribute(quality));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return MediaDescription;
                }());
                sdp.MediaDescription = MediaDescription;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var MediaStreamIdAttribute =  (function (_super) {
                    __extends(MediaStreamIdAttribute, _super);
                    function MediaStreamIdAttribute(idValue) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var idValue_3 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.MediaStreamIdAttribute);
                            _this.setIdentificationTag(idValue_3);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    MediaStreamIdAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.MediaStreamIdAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    MediaStreamIdAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.MediaStreamIdAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaStreamIdAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getIdentificationTag();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaStreamIdAttribute.prototype.getIdentificationTag = function () {
                        if (arguments.length == 0) {
                            return this._identificationTag;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaStreamIdAttribute.prototype.setIdentificationTag = function (value) {
                        if (arguments.length == 1) {
                            this._identificationTag = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return MediaStreamIdAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.MediaStreamIdAttribute = MediaStreamIdAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var MediaStreamIdSemanticAttribute =  (function (_super) {
                    __extends(MediaStreamIdSemanticAttribute, _super);
                    function MediaStreamIdSemanticAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var semanticToken = __arguments[0];
                            __arguments = new Array(2);
                            __arguments[0] = semanticToken;
                            __arguments[1] = "*";
                            {
                                var semanticToken_1 = __arguments[0];
                                var msidList = __arguments[1];
                                _this = _super.call(this) || this;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.MediaStreamIdSemanticAttribute);
                                _this.setSemanticToken(semanticToken_1);
                                _this.setMsIdList(msidList);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                            }
                        }
                        else if (__arguments.length == 2) {
                            var semanticToken = __arguments[0];
                            var msidList = __arguments[1];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.MediaStreamIdSemanticAttribute);
                            _this.setSemanticToken(semanticToken);
                            _this.setMsIdList(msidList);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    MediaStreamIdSemanticAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.MediaStreamIdSemanticAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    MediaStreamIdSemanticAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            var strArray = fm.icelink.StringExtensions.split(value, [32]);
                            if ((fm.icelink.Global.equals(strArray.length, 0))) {
                                return new fm.icelink.sdp.MediaStreamIdSemanticAttribute(fm.icelink.sdp.MediaStreamIdSemanticToken.Wms);
                            }
                            var semanticToken = strArray[0];
                            var semanticTokenFromString = fm.icelink.sdp.MediaStreamIdSemanticAttribute.getSemanticTokenFromString(semanticToken);
                            if ((fm.icelink.Global.equals(strArray.length, 1))) {
                                return new fm.icelink.sdp.MediaStreamIdSemanticAttribute(semanticTokenFromString);
                            }
                            return new fm.icelink.sdp.MediaStreamIdSemanticAttribute(semanticTokenFromString, value.substring((fm.icelink.StringExtensions.getLength(semanticToken) + 1)));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaStreamIdSemanticAttribute.getSemanticTokenFromString = function (semanticToken) {
                        if (arguments.length == 1) {
                            var str = semanticToken;
                            if (((!fm.icelink.Global.equals(str, null)) && (fm.icelink.Global.equals(str, "WMS")))) {
                                return fm.icelink.sdp.MediaStreamIdSemanticToken.Wms;
                            }
                            return fm.icelink.sdp.MediaStreamIdSemanticToken.Wms;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaStreamIdSemanticAttribute.getSemanticTokenString = function (semanticToken) {
                        if (arguments.length == 1) {
                            if ((fm.icelink.Global.equals(semanticToken, fm.icelink.sdp.MediaStreamIdSemanticToken.Wms))) {
                                return "WMS";
                            }
                            return "WMS";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaStreamIdSemanticAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            if (fm.icelink.StringExtensions.isNullOrEmpty(this.getMsIdList())) {
                                return fm.icelink.sdp.MediaStreamIdSemanticAttribute.getSemanticTokenString(this.getSemanticToken());
                            }
                            return fm.icelink.StringExtensions.concat(fm.icelink.sdp.MediaStreamIdSemanticAttribute.getSemanticTokenString(this.getSemanticToken()), " ", this.getMsIdList());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaStreamIdSemanticAttribute.prototype.getMsIdList = function () {
                        if (arguments.length == 0) {
                            return this._msIdList;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaStreamIdSemanticAttribute.prototype.getSemanticToken = function () {
                        if (arguments.length == 0) {
                            return this._semanticToken;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaStreamIdSemanticAttribute.prototype.setMsIdList = function (value) {
                        if (arguments.length == 1) {
                            this._msIdList = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaStreamIdSemanticAttribute.prototype.setSemanticToken = function (value) {
                        if (arguments.length == 1) {
                            this._semanticToken = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return MediaStreamIdSemanticAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.MediaStreamIdSemanticAttribute = MediaStreamIdSemanticAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var MediaStreamIdSemanticTokenWrapper =  (function () {
                    function MediaStreamIdSemanticTokenWrapper(value) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var value_58 = __arguments[0];
                            this._value = value_58;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    MediaStreamIdSemanticTokenWrapper.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.MediaStreamIdSemanticTokenWrapper]';
                    };
                    MediaStreamIdSemanticTokenWrapper.prototype.toString = function () {
                        if (arguments.length == 0) {
                            if (this._value == fm.icelink.sdp.MediaStreamIdSemanticToken.Wms)
                                return 'Wms';
                            return '';
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return MediaStreamIdSemanticTokenWrapper;
                }());
                sdp.MediaStreamIdSemanticTokenWrapper = MediaStreamIdSemanticTokenWrapper;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var MediaType =  (function () {
                    function MediaType() {
                    }
                    MediaType.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.MediaType]';
                    };
                    MediaType.fromStreamType = function (streamType) {
                        if (arguments.length == 1) {
                            if ((fm.icelink.Global.equals(streamType, fm.icelink.StreamType.Audio))) {
                                return fm.icelink.sdp.MediaType.getAudio();
                            }
                            if ((fm.icelink.Global.equals(streamType, fm.icelink.StreamType.Video))) {
                                return fm.icelink.sdp.MediaType.getVideo();
                            }
                            if ((!fm.icelink.Global.equals(streamType, fm.icelink.StreamType.Application))) {
                                if ((fm.icelink.Global.equals(streamType, fm.icelink.StreamType.Message))) {
                                    return fm.icelink.sdp.MediaType.getMessage();
                                }
                                if ((fm.icelink.Global.equals(streamType, fm.icelink.StreamType.Text))) {
                                    return fm.icelink.sdp.MediaType.getText();
                                }
                            }
                            return fm.icelink.sdp.MediaType.getApplication();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaType.getApplication = function () {
                        if (arguments.length == 0) {
                            return "application";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaType.getAudio = function () {
                        if (arguments.length == 0) {
                            return "audio";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaType.getMessage = function () {
                        if (arguments.length == 0) {
                            return "message";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaType.getText = function () {
                        if (arguments.length == 0) {
                            return "text";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaType.getVideo = function () {
                        if (arguments.length == 0) {
                            return "video";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    MediaType.toStreamType = function (mediaType) {
                        if (arguments.length == 1) {
                            if ((fm.icelink.Global.equals(mediaType, fm.icelink.sdp.MediaType.getAudio()))) {
                                return fm.icelink.StreamType.Audio;
                            }
                            if ((fm.icelink.Global.equals(mediaType, fm.icelink.sdp.MediaType.getVideo()))) {
                                return fm.icelink.StreamType.Video;
                            }
                            if ((!fm.icelink.Global.equals(mediaType, fm.icelink.sdp.MediaType.getApplication()))) {
                                if ((fm.icelink.Global.equals(mediaType, fm.icelink.sdp.MediaType.getMessage()))) {
                                    return fm.icelink.StreamType.Message;
                                }
                                if ((fm.icelink.Global.equals(mediaType, fm.icelink.sdp.MediaType.getText()))) {
                                    return fm.icelink.StreamType.Text;
                                }
                            }
                            return fm.icelink.StreamType.Application;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return MediaType;
                }());
                sdp.MediaType = MediaType;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var Message =  (function () {
                    function Message() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var origin_5 = __arguments[0];
                            __arguments = new Array(2);
                            __arguments[0] = origin_5;
                            __arguments[1] = null;
                            {
                                var origin_6 = __arguments[0];
                                var sessionName = __arguments[1];
                                __arguments = new Array(3);
                                __arguments[0] = origin_6;
                                __arguments[1] = sessionName;
                                __arguments[2] = null;
                                {
                                    var origin_7 = __arguments[0];
                                    var sessionName_1 = __arguments[1];
                                    var timeDescriptions = __arguments[2];
                                    this.__bandwidths = new Array();
                                    this.__timeDescriptions = new Array();
                                    this.__sessionAttributes = new fm.icelink.sdp.AttributeCollection();
                                    this.__mediaDescriptions = new Array();
                                    if ((fm.icelink.Global.equals(origin_7, null))) {
                                        throw new fm.icelink.Exception("origin cannot be null.");
                                    }
                                    if ((fm.icelink.Global.equals(timeDescriptions, null))) {
                                        timeDescriptions = [new fm.icelink.sdp.TimeDescription(new fm.icelink.sdp.Timing())];
                                    }
                                    if (((fm.icelink.Global.equals(sessionName_1, null)) || fm.icelink.StringExtensions.isNullOrEmpty(fm.icelink.StringExtensions.trim(sessionName_1)))) {
                                        sessionName_1 = "-";
                                    }
                                    this.setProtocolVersion("0");
                                    this.setOrigin(origin_7);
                                    this.setSessionName(fm.icelink.StringExtensions.trim(sessionName_1));
                                    fm.icelink.ArrayExtensions.addRange(this.__timeDescriptions, timeDescriptions);
                                }
                            }
                        }
                        else if (__arguments.length == 2) {
                            var origin_8 = __arguments[0];
                            var sessionName = __arguments[1];
                            __arguments = new Array(3);
                            __arguments[0] = origin_8;
                            __arguments[1] = sessionName;
                            __arguments[2] = null;
                            {
                                var origin_9 = __arguments[0];
                                var sessionName_2 = __arguments[1];
                                var timeDescriptions = __arguments[2];
                                this.__bandwidths = new Array();
                                this.__timeDescriptions = new Array();
                                this.__sessionAttributes = new fm.icelink.sdp.AttributeCollection();
                                this.__mediaDescriptions = new Array();
                                if ((fm.icelink.Global.equals(origin_9, null))) {
                                    throw new fm.icelink.Exception("origin cannot be null.");
                                }
                                if ((fm.icelink.Global.equals(timeDescriptions, null))) {
                                    timeDescriptions = [new fm.icelink.sdp.TimeDescription(new fm.icelink.sdp.Timing())];
                                }
                                if (((fm.icelink.Global.equals(sessionName_2, null)) || fm.icelink.StringExtensions.isNullOrEmpty(fm.icelink.StringExtensions.trim(sessionName_2)))) {
                                    sessionName_2 = "-";
                                }
                                this.setProtocolVersion("0");
                                this.setOrigin(origin_9);
                                this.setSessionName(fm.icelink.StringExtensions.trim(sessionName_2));
                                fm.icelink.ArrayExtensions.addRange(this.__timeDescriptions, timeDescriptions);
                            }
                        }
                        else if (__arguments.length == 3) {
                            var origin_10 = __arguments[0];
                            var sessionName = __arguments[1];
                            var timeDescriptions = __arguments[2];
                            this.__bandwidths = new Array();
                            this.__timeDescriptions = new Array();
                            this.__sessionAttributes = new fm.icelink.sdp.AttributeCollection();
                            this.__mediaDescriptions = new Array();
                            if ((fm.icelink.Global.equals(origin_10, null))) {
                                throw new fm.icelink.Exception("origin cannot be null.");
                            }
                            if ((fm.icelink.Global.equals(timeDescriptions, null))) {
                                timeDescriptions = [new fm.icelink.sdp.TimeDescription(new fm.icelink.sdp.Timing())];
                            }
                            if (((fm.icelink.Global.equals(sessionName, null)) || fm.icelink.StringExtensions.isNullOrEmpty(fm.icelink.StringExtensions.trim(sessionName)))) {
                                sessionName = "-";
                            }
                            this.setProtocolVersion("0");
                            this.setOrigin(origin_10);
                            this.setSessionName(fm.icelink.StringExtensions.trim(sessionName));
                            fm.icelink.ArrayExtensions.addRange(this.__timeDescriptions, timeDescriptions);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    Message.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.Message]';
                    };
                    Message.parse = function (s) {
                        if (arguments.length == 1) {
                            var strArray = fm.icelink.sdp.Utility.splitAndClean(s);
                            if ((((!fm.icelink.Global.equals(strArray[0].charCodeAt(0), 118)) || (!fm.icelink.Global.equals(strArray[1].charCodeAt(0), 111))) || (!fm.icelink.Global.equals(strArray[2].charCodeAt(0), 115)))) {
                                return null;
                            }
                            var origin_11 = fm.icelink.sdp.Origin.parse(strArray[1].substring(2));
                            var sessionName = strArray[2].substring(2);
                            var message = new fm.icelink.sdp.Message(origin_11, sessionName);
                            message.removeTimeDescriptions();
                            for (var i = 3; (i < strArray.length); i++) {
                                var num2 = void 0;
                                var str4 = void 0;
                                var str2 = strArray[i];
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 105))) {
                                    message.setSessionInformation(str2.substring(2));
                                    continue;
                                }
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 117))) {
                                    try {
                                        message.setUri(new fm.icelink.Uri(str2.substring(2)));
                                    }
                                    catch (exception1) {
                                    }
                                    finally {
                                    }
                                    continue;
                                }
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 101))) {
                                    message.setEmailAddress(str2.substring(2));
                                    continue;
                                }
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 112))) {
                                    message.setPhoneNumber(str2.substring(2));
                                    continue;
                                }
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 99))) {
                                    message.setConnectionData(fm.icelink.sdp.ConnectionData.parse(str2));
                                    continue;
                                }
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 98))) {
                                    message.addBandwidth(fm.icelink.sdp.Bandwidth.parse(str2));
                                    continue;
                                }
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 116))) {
                                    var str3 = str2;
                                    num2 = (i + 1);
                                    while ((num2 < strArray.length)) {
                                        str4 = strArray[num2];
                                        if ((!fm.icelink.Global.equals(str4.charCodeAt(0), 114))) {
                                            break;
                                        }
                                        str3 = fm.icelink.StringExtensions.concat(str3, "\n", str4);
                                        i++;
                                        num2++;
                                    }
                                    message.addTimeDescription(fm.icelink.sdp.TimeDescription.parse(str3));
                                    continue;
                                }
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 122))) {
                                    message.setTimeZoneAdjustments(fm.icelink.sdp.TimeZones.parse(str2));
                                    continue;
                                }
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 107))) {
                                    message.setEncryptionKey(fm.icelink.sdp.EncryptionKey.parse(str2));
                                    continue;
                                }
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 97))) {
                                    message.addSessionAttribute(fm.icelink.sdp.Attribute.parse(str2));
                                    continue;
                                }
                                if ((fm.icelink.Global.equals(str2.charCodeAt(0), 109))) {
                                    var str5 = str2;
                                    for (num2 = (i + 1); (num2 < strArray.length); num2++) {
                                        str4 = strArray[num2];
                                        if ((fm.icelink.Global.equals(str4.charCodeAt(0), 109))) {
                                            break;
                                        }
                                        str5 = fm.icelink.StringExtensions.concat(str5, "\n", str4);
                                        i++;
                                    }
                                    message.addMediaDescription(fm.icelink.sdp.MediaDescription.parse(str5));
                                }
                            }
                            return message;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.addBandwidth = function (bandwidth) {
                        if (arguments.length == 1) {
                            fm.icelink.ArrayExtensions.add(this.__bandwidths, bandwidth);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.addMediaDescription = function (mediaDescription) {
                        if (arguments.length == 1) {
                            fm.icelink.ArrayExtensions.add(this.__mediaDescriptions, mediaDescription);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.addSessionAttribute = function (attribute) {
                        if (arguments.length == 1) {
                            if (fm.icelink.sdp.Attribute.isSessionLevel(new fm.icelink.Type(attribute.getTypeString()))) {
                                this.__sessionAttributes.addAttribute(attribute);
                            }
                            else {
                                if (fm.icelink.sdp.Attribute.isMediaLevel(new fm.icelink.Type(attribute.getTypeString()))) {
                                    throw new fm.icelink.Exception("Attribute is media-only.");
                                }
                                throw new fm.icelink.Exception("Attribute is not registered.");
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.addTimeDescription = function (timeDescription) {
                        if (arguments.length == 1) {
                            fm.icelink.ArrayExtensions.add(this.__timeDescriptions, timeDescription);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.findBundleGroups = function () {
                        if (arguments.length == 0) {
                            var bundling = fm.icelink.sdp.GroupSemanticsType.Bundling;
                            var groupAttributesFromCollection = fm.icelink.sdp.MediaDescription.getGroupAttributesFromCollection(this.__sessionAttributes);
                            if ((fm.icelink.Global.equals(groupAttributesFromCollection, null))) {
                                return null;
                            }
                            var groupArray = new Array(groupAttributesFromCollection.length);
                            for (var i = 0; (i < groupArray.length); i++) {
                                var attribute = groupAttributesFromCollection[i];
                                if ((fm.icelink.Global.equals(bundling, attribute.getSemantics()))) {
                                    var group = new fm.icelink.sdp.BundleGroup(bundling);
                                    for (var _i = 0, _a = attribute.getIds(); _i < _a.length; _i++) {
                                        var str = _a[_i];
                                        var mediaDescription = this.findMediaDescription(str);
                                        if ((!fm.icelink.Global.equals(mediaDescription, null))) {
                                            group.addMediaDescription(mediaDescription);
                                        }
                                    }
                                    groupArray[i] = group;
                                }
                            }
                            return groupArray;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.findMediaDescription = function (mid) {
                        if (arguments.length == 1) {
                            for (var _i = 0, _a = this.getMediaDescriptions(); _i < _a.length; _i++) {
                                var description = _a[_i];
                                var mediaStreamIdentifierAttribute = description.getMediaStreamIdentifierAttribute();
                                if (((!fm.icelink.Global.equals(mediaStreamIdentifierAttribute, null)) && (fm.icelink.Global.equals(mediaStreamIdentifierAttribute.getIdentificationTag(), mid)))) {
                                    return description;
                                }
                            }
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.findMediaDescriptions = function (mediaType) {
                        if (arguments.length == 1) {
                            var list = new Array();
                            for (var _i = 0, _a = this.getMediaDescriptions(); _i < _a.length; _i++) {
                                var description = _a[_i];
                                var media = description.getMedia();
                                if (((!fm.icelink.Global.equals(media, null)) && (fm.icelink.Global.equals(media.getMediaType(), mediaType)))) {
                                    fm.icelink.ArrayExtensions.add(list, description);
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getApplicationDescription = function () {
                        if (arguments.length == 0) {
                            return this.getFirstMediaDescription(this.getApplicationDescriptions());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getApplicationDescriptions = function () {
                        if (arguments.length == 0) {
                            return this.findMediaDescriptions(fm.icelink.sdp.MediaType.getApplication());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getAudioDescription = function () {
                        if (arguments.length == 0) {
                            return this.getFirstMediaDescription(this.getAudioDescriptions());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getAudioDescriptions = function () {
                        if (arguments.length == 0) {
                            return this.findMediaDescriptions(fm.icelink.sdp.MediaType.getAudio());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getBandwidths = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.ArrayExtensions.toArray(this.__bandwidths);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getBundleGroups = function () {
                        if (arguments.length == 0) {
                            return this.findBundleGroups();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getBundlingSupport = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getBundlingSupportFromCollection(this.__sessionAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getConnectionData = function () {
                        if (arguments.length == 0) {
                            return this._connectionData;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getEmailAddress = function () {
                        if (arguments.length == 0) {
                            return this._emailAddress;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getEncryptionKey = function () {
                        if (arguments.length == 0) {
                            return this._encryptionKey;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getFirstMediaDescription = function (mediaDescriptions) {
                        if (arguments.length == 1) {
                            if (((fm.icelink.Global.equals(mediaDescriptions, null)) || (fm.icelink.Global.equals(mediaDescriptions.length, 0)))) {
                                return null;
                            }
                            return mediaDescriptions[0];
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getMediaDescriptions = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.ArrayExtensions.toArray(this.__mediaDescriptions);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getMessageDescription = function () {
                        if (arguments.length == 0) {
                            return this.getFirstMediaDescription(this.getMessageDescriptions());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getMessageDescriptions = function () {
                        if (arguments.length == 0) {
                            return this.findMediaDescriptions(fm.icelink.sdp.MediaType.getMessage());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getOrigin = function () {
                        if (arguments.length == 0) {
                            return this._origin;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getPhoneNumber = function () {
                        if (arguments.length == 0) {
                            return this._phoneNumber;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getProtocolVersion = function () {
                        if (arguments.length == 0) {
                            return this._protocolVersion;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionAttributes = function () {
                        if (arguments.length == 0) {
                            return this.__sessionAttributes.toArray();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionInformation = function () {
                        if (arguments.length == 0) {
                            return this._sessionInformation;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionLevelCryptoAttributes = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getCryptoAttributesFromCollection(this.__sessionAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionLevelDirection = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getStreamDirectionFromCollection(this.__sessionAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionLevelFingerprintAttribute = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getFingerprintAttributeFromCollection(this.__sessionAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionLevelIceOptionAttributes = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getIceOptionAttributesFromCollection(this.__sessionAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionLevelIcePasswordAttribute = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getIcePasswordAttributeFromCollection(this.__sessionAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionLevelIceUfragAttribute = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getIceUfragAttributeFromCollection(this.__sessionAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionLevelRtcpMultiplexingSupport = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getRtcpMultiplexingSupportFromCollection(this.__sessionAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionLevelRtpExtMapAttributes = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getRtpExtMapAttributesFromCollection(this.__sessionAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionLevelSetupAttribute = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.sdp.MediaDescription.getSetupAttributeFromCollection(this.__sessionAttributes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSessionName = function () {
                        if (arguments.length == 0) {
                            return this._sessionName;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSupportsRtcpMultiplexing = function () {
                        if (arguments.length == 0) {
                            if (this.getSessionLevelRtcpMultiplexingSupport()) {
                                return true;
                            }
                            if (this.getBundlingSupport()) {
                                return true;
                            }
                            var flag3 = true;
                            for (var _i = 0, _a = this.__mediaDescriptions; _i < _a.length; _i++) {
                                var description = _a[_i];
                                if ((description.getIsAudio() || description.getIsVideo())) {
                                    flag3 = (flag3 && description.getRtcpMultiplexingSupported());
                                }
                            }
                            return flag3;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getSupportsTrickleIce = function () {
                        if (arguments.length == 0) {
                            var attribute = null;
                            var attribute2 = void 0;
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__sessionAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.IceOptionsAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                attribute2 = attribute;
                                if (attribute2.getTrickleOptionSet()) {
                                    return true;
                                }
                            }
                            var flag2 = true;
                            for (var _i = 0, _a = this.getMediaDescriptions(); _i < _a.length; _i++) {
                                var description = _a[_i];
                                var flag3 = false;
                                var iceOptionAttributes = description.getIceOptionAttributes();
                                for (var _b = 0, iceOptionAttributes_1 = iceOptionAttributes; _b < iceOptionAttributes_1.length; _b++) {
                                    var attribute3 = iceOptionAttributes_1[_b];
                                    attribute2 = attribute3;
                                    flag3 = (flag3 || attribute2.getTrickleOptionSet());
                                }
                                flag2 = (flag2 && flag3);
                            }
                            return flag2;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getTextDescription = function () {
                        if (arguments.length == 0) {
                            return this.getFirstMediaDescription(this.getTextDescriptions());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getTextDescriptions = function () {
                        if (arguments.length == 0) {
                            return this.findMediaDescriptions(fm.icelink.sdp.MediaType.getText());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getTimeDescriptions = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.ArrayExtensions.toArray(this.__timeDescriptions);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getTimeZoneAdjustments = function () {
                        if (arguments.length == 0) {
                            return this._timeZoneAdjustments;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getUri = function () {
                        if (arguments.length == 0) {
                            return this._uri;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getVideoDescription = function () {
                        if (arguments.length == 0) {
                            return this.getFirstMediaDescription(this.getVideoDescriptions());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.getVideoDescriptions = function () {
                        if (arguments.length == 0) {
                            return this.findMediaDescriptions(fm.icelink.sdp.MediaType.getVideo());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.insertMediaDescription = function (index, mediaDescription) {
                        if (arguments.length == 2) {
                            index = fm.icelink.Global.toInt(arguments[0]);
                            fm.icelink.ArrayExtensions.insert(this.__mediaDescriptions, index, mediaDescription);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.removeBandwidth = function (bandwidth) {
                        if (arguments.length == 1) {
                            return fm.icelink.ArrayExtensions.remove(this.__bandwidths, bandwidth);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.removeMediaDescription = function (mediaDescription) {
                        if (arguments.length == 1) {
                            return fm.icelink.ArrayExtensions.remove(this.__mediaDescriptions, mediaDescription);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.removeSessionAttribute = function (attributeType) {
                        if (arguments.length == 1) {
                            return this.__sessionAttributes.remove(attributeType);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.removeTimeDescription = function (timeDescription) {
                        if (arguments.length == 1) {
                            return fm.icelink.ArrayExtensions.remove(this.__timeDescriptions, timeDescription);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.removeTimeDescriptions = function () {
                        if (arguments.length == 0) {
                            this.__timeDescriptions = new Array();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setConnectionData = function (value) {
                        if (arguments.length == 1) {
                            this._connectionData = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setEmailAddress = function (value) {
                        if (arguments.length == 1) {
                            this._emailAddress = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setEncryptionKey = function (value) {
                        if (arguments.length == 1) {
                            this._encryptionKey = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setOrigin = function (value) {
                        if (arguments.length == 1) {
                            this._origin = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setPhoneNumber = function (value) {
                        if (arguments.length == 1) {
                            this._phoneNumber = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setProtocolVersion = function (value) {
                        if (arguments.length == 1) {
                            this._protocolVersion = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setSessionInformation = function (value) {
                        if (arguments.length == 1) {
                            this._sessionInformation = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setSessionName = function (value) {
                        if (arguments.length == 1) {
                            this._sessionName = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setSupportsTrickleIce = function (value) {
                        if (arguments.length == 1) {
                            var attribute = null;
                            var attribute3 = void 0;
                            for (var _i = 0, _a = this.getMediaDescriptions(); _i < _a.length; _i++) {
                                var description = _a[_i];
                                var iceOptionAttributes = description.getIceOptionAttributes();
                                var list = new Array();
                                for (var _b = 0, iceOptionAttributes_2 = iceOptionAttributes; _b < iceOptionAttributes_2.length; _b++) {
                                    var attribute2 = iceOptionAttributes_2[_b];
                                    attribute3 = attribute2;
                                    attribute3.setTrickleOptionSet(false);
                                    if ((fm.icelink.Global.equals(fm.icelink.ArrayExtensions.getCount(attribute3.getTags()), 0))) {
                                        fm.icelink.ArrayExtensions.add(list, attribute3);
                                    }
                                }
                                for (var _c = 0, list_6 = list; _c < list_6.length; _c++) {
                                    var attribute4 = list_6[_c];
                                    description.removeMediaAttribute(attribute4);
                                }
                            }
                            var _var0 = new fm.icelink.Holder(attribute);
                            var _var1 = this.__sessionAttributes.tryGetAttribute(fm.icelink.sdp.AttributeType.IceOptionsAttribute, _var0);
                            attribute = _var0.getValue();
                            if (_var1) {
                                attribute3 = attribute;
                                attribute3.setTrickleOptionSet(value);
                                var tags = attribute3.getTags();
                                if (((fm.icelink.Global.equals(tags, null)) || (fm.icelink.Global.equals(fm.icelink.ArrayExtensions.getCount(tags), 0)))) {
                                    this.__sessionAttributes.remove(attribute3);
                                }
                            }
                            else {
                                if (value) {
                                    var list5 = new Array();
                                    fm.icelink.ArrayExtensions.add(list5, new fm.icelink.sdp.ice.TrickleIceOptionTag());
                                    var list4 = list5;
                                    this.addSessionAttribute(new fm.icelink.sdp.ice.OptionsAttribute(list4));
                                }
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setTimeZoneAdjustments = function (value) {
                        if (arguments.length == 1) {
                            this._timeZoneAdjustments = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.setUri = function (value) {
                        if (arguments.length == 1) {
                            this._uri = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append(fm.icelink.StringExtensions.concat("v=", this.getProtocolVersion(), "\r\n"));
                            builder.append(fm.icelink.StringExtensions.concat("o=", this.getOrigin().toString(), "\r\n"));
                            builder.append(fm.icelink.StringExtensions.concat("s=", this.getSessionName(), "\r\n"));
                            if ((!fm.icelink.Global.equals(this.getSessionInformation(), null))) {
                                builder.append(fm.icelink.StringExtensions.concat("i=", this.getSessionInformation(), "\r\n"));
                            }
                            if ((!fm.icelink.Global.equals(this.getUri(), null))) {
                                builder.append(fm.icelink.StringExtensions.concat("u=", this.getUri().toString(), "\r\n"));
                            }
                            if ((!fm.icelink.Global.equals(this.getEmailAddress(), null))) {
                                builder.append(fm.icelink.StringExtensions.concat("e=", this.getEmailAddress(), "\r\n"));
                            }
                            if ((!fm.icelink.Global.equals(this.getPhoneNumber(), null))) {
                                builder.append(fm.icelink.StringExtensions.concat("p=", this.getPhoneNumber(), "\r\n"));
                            }
                            if ((!fm.icelink.Global.equals(this.getConnectionData(), null))) {
                                builder.append(fm.icelink.StringExtensions.concat(this.getConnectionData().toString(), "\r\n"));
                            }
                            for (var _i = 0, _a = this.getBandwidths(); _i < _a.length; _i++) {
                                var bandwidth = _a[_i];
                                builder.append(fm.icelink.StringExtensions.concat(bandwidth.toString(), "\r\n"));
                            }
                            for (var _b = 0, _c = this.getTimeDescriptions(); _b < _c.length; _b++) {
                                var description = _c[_b];
                                builder.append(description.toString());
                            }
                            if ((!fm.icelink.Global.equals(this.getTimeZoneAdjustments(), null))) {
                                builder.append(fm.icelink.StringExtensions.concat(this.getTimeZoneAdjustments().toString(), "\r\n"));
                            }
                            if ((!fm.icelink.Global.equals(this.getEncryptionKey(), null))) {
                                builder.append(fm.icelink.StringExtensions.concat(this.getEncryptionKey().toString(), "\r\n"));
                            }
                            for (var _d = 0, _e = this.getSessionAttributes(); _d < _e.length; _d++) {
                                var attribute = _e[_d];
                                builder.append(fm.icelink.StringExtensions.concat(attribute.toString(), "\r\n"));
                            }
                            for (var _f = 0, _g = this.getMediaDescriptions(); _f < _g.length; _f++) {
                                var description2 = _g[_f];
                                builder.append(description2.toString());
                            }
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Message.prototype.updateSetupValue = function (setupValue) {
                        if (arguments.length == 1) {
                            this.removeSessionAttribute(fm.icelink.sdp.AttributeType.SetupAttribute);
                            var attribute = new fm.icelink.sdp.SetupAttribute(setupValue);
                            this.addSessionAttribute(attribute);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Message;
                }());
                sdp.Message = Message;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var NetworkType =  (function () {
                    function NetworkType() {
                    }
                    NetworkType.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.NetworkType]';
                    };
                    NetworkType.getInternet = function () {
                        if (arguments.length == 0) {
                            return "IN";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return NetworkType;
                }());
                sdp.NetworkType = NetworkType;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var Orientation =  (function () {
                    function Orientation() {
                    }
                    Orientation.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.Orientation]';
                    };
                    Orientation.getLandscape = function () {
                        if (arguments.length == 0) {
                            return "landscape";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Orientation.getPortrait = function () {
                        if (arguments.length == 0) {
                            return "portrait";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Orientation.getSeascape = function () {
                        if (arguments.length == 0) {
                            return "seascape";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Orientation;
                }());
                sdp.Orientation = Orientation;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var OrientationAttribute =  (function (_super) {
                    __extends(OrientationAttribute, _super);
                    function OrientationAttribute(orientation) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var orientation_2 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.OrientationAttribute);
                            _this.setOrientation(orientation_2);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    OrientationAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.OrientationAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    OrientationAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.OrientationAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    OrientationAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getOrientation();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    OrientationAttribute.prototype.getOrientation = function () {
                        if (arguments.length == 0) {
                            return this._orientation;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    OrientationAttribute.prototype.setOrientation = function (value) {
                        if (arguments.length == 1) {
                            this._orientation = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return OrientationAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.OrientationAttribute = OrientationAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var Origin =  (function () {
                    function Origin() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var unicastAddress = __arguments[0];
                            __arguments = new Array(2);
                            __arguments[0] = unicastAddress;
                            __arguments[1] = "-";
                            {
                                var unicastAddress_1 = __arguments[0];
                                var username = __arguments[1];
                                this.fmicelinksdpOriginInit();
                                if ((fm.icelink.Global.equals(unicastAddress_1, null))) {
                                    throw new fm.icelink.Exception("unicastAddress cannot be null.");
                                }
                                this.setUsername(username);
                                this.setSessionId(this.generateSessionId());
                                this.setSessionVersion(this.generateSessionVersion());
                                this.setNetworkType(fm.icelink.sdp.NetworkType.getInternet());
                                this.setAddressType(fm.icelink.sdp.AddressType.getAddressTypeForAddress(unicastAddress_1));
                                this.setUnicastAddress(unicastAddress_1);
                            }
                        }
                        else if (__arguments.length == 2) {
                            var unicastAddress = __arguments[0];
                            var username = __arguments[1];
                            this.fmicelinksdpOriginInit();
                            if ((fm.icelink.Global.equals(unicastAddress, null))) {
                                throw new fm.icelink.Exception("unicastAddress cannot be null.");
                            }
                            this.setUsername(username);
                            this.setSessionId(this.generateSessionId());
                            this.setSessionVersion(this.generateSessionVersion());
                            this.setNetworkType(fm.icelink.sdp.NetworkType.getInternet());
                            this.setAddressType(fm.icelink.sdp.AddressType.getAddressTypeForAddress(unicastAddress));
                            this.setUnicastAddress(unicastAddress);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    Origin.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.Origin]';
                    };
                    Origin.prototype.fmicelinksdpOriginInit = function () {
                        this._sessionId = 0;
                        this._sessionVersion = 0;
                    };
                    Origin.parse = function (s) {
                        if (arguments.length == 1) {
                            var strArray = fm.icelink.StringExtensions.split(s, [32]);
                            var username = strArray[0];
                            var unicastAddress = strArray[5];
                            var origin_12 = new fm.icelink.sdp.Origin(unicastAddress, username);
                            origin_12.setSessionId(fm.icelink.ParseAssistant.parseLongValue(strArray[1]));
                            origin_12.setSessionVersion(fm.icelink.ParseAssistant.parseLongValue(strArray[2]));
                            origin_12.setNetworkType(strArray[3]);
                            origin_12.setAddressType(strArray[4]);
                            return origin_12;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.generateSessionId = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.LockedRandomizer.nextLong();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.generateSessionVersion = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.UnixTimestamp.getUtcNow();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.getAddressType = function () {
                        if (arguments.length == 0) {
                            return this._addressType;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.getNetworkType = function () {
                        if (arguments.length == 0) {
                            return this._networkType;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.getSessionId = function () {
                        if (arguments.length == 0) {
                            return this._sessionId;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.getSessionVersion = function () {
                        if (arguments.length == 0) {
                            return this._sessionVersion;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.getUnicastAddress = function () {
                        if (arguments.length == 0) {
                            return this._unicastAddress;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.getUsername = function () {
                        if (arguments.length == 0) {
                            return this._username;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.setAddressType = function (value) {
                        if (arguments.length == 1) {
                            this._addressType = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.setNetworkType = function (value) {
                        if (arguments.length == 1) {
                            this._networkType = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.setSessionId = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._sessionId = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.setSessionVersion = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._sessionVersion = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.setUnicastAddress = function (value) {
                        if (arguments.length == 1) {
                            this._unicastAddress = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.setUsername = function (value) {
                        if (arguments.length == 1) {
                            this._username = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Origin.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append(this.getUsername());
                            builder.append(" ");
                            builder.append(fm.icelink.NumberExtensions.toString(this.getSessionId()));
                            builder.append(" ");
                            builder.append(fm.icelink.NumberExtensions.toString(this.getSessionVersion()));
                            builder.append(" ");
                            builder.append(this.getNetworkType());
                            builder.append(" ");
                            builder.append(this.getAddressType());
                            builder.append(" ");
                            builder.append(this.getUnicastAddress());
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Origin;
                }());
                sdp.Origin = Origin;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var PacketTimeAttribute =  (function (_super) {
                    __extends(PacketTimeAttribute, _super);
                    function PacketTimeAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                            _this.fmicelinksdpPacketTimeAttributeInit();
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.PacketTimeAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                        }
                        else if (__arguments.length == 1) {
                            var packetTime = __arguments[0];
                            __arguments = new Array(0);
                            {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdpPacketTimeAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.PacketTimeAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                            }
                            _this.setPacketTime(packetTime);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    PacketTimeAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.PacketTimeAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    PacketTimeAttribute.prototype.fmicelinksdpPacketTimeAttributeInit = function () {
                        this._packetTime = 0;
                    };
                    PacketTimeAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            var attribute = new fm.icelink.sdp.PacketTimeAttribute();
                            attribute.setPacketTime(fm.icelink.ParseAssistant.parseIntegerValue(value));
                            return attribute;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    PacketTimeAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.NumberExtensions.toString(this.getPacketTime());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    PacketTimeAttribute.prototype.getPacketTime = function () {
                        if (arguments.length == 0) {
                            return this._packetTime;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    PacketTimeAttribute.prototype.setPacketTime = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._packetTime = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return PacketTimeAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.PacketTimeAttribute = PacketTimeAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var PromptEncryptionKey =  (function (_super) {
                    __extends(PromptEncryptionKey, _super);
                    function PromptEncryptionKey() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    PromptEncryptionKey.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.PromptEncryptionKey]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    PromptEncryptionKey.prototype.getMethodAndValue = function () {
                        if (arguments.length == 0) {
                            return "prompt";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return PromptEncryptionKey;
                }(fm.icelink.sdp.EncryptionKey));
                sdp.PromptEncryptionKey = PromptEncryptionKey;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var QualityAttribute =  (function (_super) {
                    __extends(QualityAttribute, _super);
                    function QualityAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                            _this.fmicelinksdpQualityAttributeInit();
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.QualityAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else if (__arguments.length == 1) {
                            var quality = __arguments[0];
                            __arguments = new Array(0);
                            {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdpQualityAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.QualityAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                            }
                            if (((quality < 0) || (quality > 10))) {
                                throw new fm.icelink.Exception("quality must be a value in the range 0 to 10.");
                            }
                            _this.setQuality(quality);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    QualityAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.QualityAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    QualityAttribute.prototype.fmicelinksdpQualityAttributeInit = function () {
                        this._quality = 0;
                    };
                    QualityAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            var attribute = new fm.icelink.sdp.QualityAttribute();
                            attribute.setQuality(fm.icelink.ParseAssistant.parseByteValue(value));
                            return attribute;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    QualityAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.NumberExtensions.toString(this.getQuality());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    QualityAttribute.prototype.getQuality = function () {
                        if (arguments.length == 0) {
                            return this._quality;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    QualityAttribute.prototype.setQuality = function (value) {
                        if (arguments.length == 1) {
                            value = fm.icelink.Global.toInt(arguments[0]);
                            this._quality = fm.icelink.Global.toInt(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return QualityAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.QualityAttribute = QualityAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var ReceiveOnlyAttribute =  (function (_super) {
                    __extends(ReceiveOnlyAttribute, _super);
                    function ReceiveOnlyAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.DirectionAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    ReceiveOnlyAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.ReceiveOnlyAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    ReceiveOnlyAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.ReceiveOnlyAttribute();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ReceiveOnlyAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ReceiveOnlyAttribute.prototype.getStreamDirection = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.StreamDirection.ReceiveOnly;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return ReceiveOnlyAttribute;
                }(fm.icelink.sdp.DirectionAttribute));
                sdp.ReceiveOnlyAttribute = ReceiveOnlyAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var RepeatTime =  (function () {
                    function RepeatTime() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 2) {
                            var repeatInterval = __arguments[0];
                            var activeDuration = __arguments[1];
                            __arguments = new Array(3);
                            __arguments[0] = repeatInterval;
                            __arguments[1] = activeDuration;
                            __arguments[2] = null;
                            {
                                var repeatInterval_1 = __arguments[0];
                                var activeDuration_1 = __arguments[1];
                                var offsets = __arguments[2];
                                this.__offsets = new Array();
                                this.setRepeatInterval(repeatInterval_1);
                                this.setActiveDuration(activeDuration_1);
                                if ((!fm.icelink.Global.equals(offsets, null))) {
                                    fm.icelink.ArrayExtensions.addRange(this.__offsets, offsets);
                                }
                            }
                        }
                        else if (__arguments.length == 3) {
                            var repeatInterval = __arguments[0];
                            var activeDuration = __arguments[1];
                            var offsets = __arguments[2];
                            this.__offsets = new Array();
                            this.setRepeatInterval(repeatInterval);
                            this.setActiveDuration(activeDuration);
                            if ((!fm.icelink.Global.equals(offsets, null))) {
                                fm.icelink.ArrayExtensions.addRange(this.__offsets, offsets);
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    RepeatTime.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.RepeatTime]';
                    };
                    RepeatTime.parse = function (s) {
                        if (arguments.length == 1) {
                            s = s.substring(2);
                            var strArray = fm.icelink.StringExtensions.split(s, [32]);
                            var repeatInterval = new fm.icelink.TimeSpan(0, 0, fm.icelink.ParseAssistant.parseIntegerValue(strArray[0]));
                            var activeDuration = new fm.icelink.TimeSpan(0, 0, fm.icelink.ParseAssistant.parseIntegerValue(strArray[1]));
                            var time = new fm.icelink.sdp.RepeatTime(repeatInterval, activeDuration);
                            for (var i = 2; (i < strArray.length); i++) {
                                time.addOffset(new fm.icelink.TimeSpan(0, 0, fm.icelink.ParseAssistant.parseIntegerValue(strArray[2])));
                            }
                            return time;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RepeatTime.prototype.addOffset = function (offset) {
                        if (arguments.length == 1) {
                            fm.icelink.ArrayExtensions.add(this.__offsets, offset);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RepeatTime.prototype.getActiveDuration = function () {
                        if (arguments.length == 0) {
                            return this._activeDuration;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RepeatTime.prototype.getOffsets = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.ArrayExtensions.toArray(this.__offsets);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RepeatTime.prototype.getRepeatInterval = function () {
                        if (arguments.length == 0) {
                            return this._repeatInterval;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RepeatTime.prototype.removeOffset = function (offset) {
                        if (arguments.length == 1) {
                            return fm.icelink.ArrayExtensions.remove(this.__offsets, offset);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RepeatTime.prototype.setActiveDuration = function (value) {
                        if (arguments.length == 1) {
                            this._activeDuration = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RepeatTime.prototype.setRepeatInterval = function (value) {
                        if (arguments.length == 1) {
                            this._repeatInterval = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    RepeatTime.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append("r=");
                            builder.append(fm.icelink.NumberExtensions.toString(this.getRepeatInterval().getTotalSeconds()));
                            builder.append(" ");
                            var totalSeconds = this.getActiveDuration().getTotalSeconds();
                            builder.append(fm.icelink.NumberExtensions.toString(totalSeconds));
                            for (var _i = 0, _a = this.getOffsets(); _i < _a.length; _i++) {
                                var span = _a[_i];
                                builder.append(" ");
                                builder.append(fm.icelink.NumberExtensions.toString(span.getTotalSeconds()));
                            }
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return RepeatTime;
                }());
                sdp.RepeatTime = RepeatTime;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtcp) {
                    var Attribute =  (function (_super) {
                        __extends(Attribute, _super);
                        function Attribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdprtcpAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtcpAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                            }
                            else if (__arguments.length == 2) {
                                var port = __arguments[0];
                                var connectionAddress = __arguments[1];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdprtcpAttributeInit();
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtcpAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                                }
                                if ((fm.icelink.Global.equals(connectionAddress, null))) {
                                    throw new fm.icelink.Exception("connectionAddress cannot be null.");
                                }
                                _this.update(port, connectionAddress);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        Attribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtcp.Attribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        Attribute.prototype.fmicelinksdprtcpAttributeInit = function () {
                            this._port = 0;
                        };
                        Attribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var num2 = 0;
                                var str = null;
                                var str2 = null;
                                var str3 = null;
                                if ((fm.icelink.Global.equals(index, -1))) {
                                    num2 = fm.icelink.ParseAssistant.parseIntegerValue(value);
                                }
                                else {
                                    num2 = fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring(value, 0, index));
                                    value = value.substring((index + 1));
                                    index = fm.icelink.StringExtensions.indexOf(value, " ");
                                    str = fm.icelink.StringExtensions.substring(value, 0, index);
                                    value = value.substring((index + 1));
                                    index = fm.icelink.StringExtensions.indexOf(value, " ");
                                    str2 = fm.icelink.StringExtensions.substring(value, 0, index);
                                    value = value.substring((index + 1));
                                    str3 = value;
                                }
                                var attribute = new fm.icelink.sdp.rtcp.Attribute();
                                attribute.setPort(num2);
                                attribute.setNetworkType(str);
                                attribute.setAddressType(str2);
                                attribute.setConnectionAddress(str3);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Attribute.prototype.getAddressType = function () {
                            if (arguments.length == 0) {
                                return this._addressType;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Attribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(fm.icelink.NumberExtensions.toString(this.getPort()));
                                if ((!fm.icelink.Global.equals(this.getConnectionAddress(), null))) {
                                    builder.append(" ");
                                    builder.append(this.getNetworkType());
                                    builder.append(" ");
                                    builder.append(this.getAddressType());
                                    builder.append(" ");
                                    builder.append(this.getConnectionAddress());
                                }
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Attribute.prototype.getConnectionAddress = function () {
                            if (arguments.length == 0) {
                                return this._connectionAddress;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Attribute.prototype.getNetworkType = function () {
                            if (arguments.length == 0) {
                                return this._networkType;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Attribute.prototype.getPort = function () {
                            if (arguments.length == 0) {
                                return this._port;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Attribute.prototype.setAddressType = function (value) {
                            if (arguments.length == 1) {
                                this._addressType = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Attribute.prototype.setConnectionAddress = function (value) {
                            if (arguments.length == 1) {
                                this._connectionAddress = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Attribute.prototype.setNetworkType = function (value) {
                            if (arguments.length == 1) {
                                this._networkType = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Attribute.prototype.setPort = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._port = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Attribute.prototype.update = function (port, connectionAddress) {
                            if (arguments.length == 2) {
                                port = fm.icelink.Global.toInt(arguments[0]);
                                this.setPort(port);
                                this.setNetworkType(fm.icelink.sdp.NetworkType.getInternet());
                                this.setAddressType(fm.icelink.sdp.AddressType.getAddressTypeForAddress(connectionAddress));
                                this.setConnectionAddress(connectionAddress);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return Attribute;
                    }(fm.icelink.sdp.Attribute));
                    rtcp.Attribute = Attribute;
                })(sdp.rtcp || (sdp.rtcp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtcp) {
                    var FeedbackAttribute =  (function (_super) {
                        __extends(FeedbackAttribute, _super);
                        function FeedbackAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdprtcpFeedbackAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtcpFeedbackAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                            }
                            else if (__arguments.length == 2) {
                                var payloadType = __arguments[0];
                                var type = __arguments[1];
                                __arguments = new Array(3);
                                __arguments[0] = payloadType;
                                __arguments[1] = type;
                                __arguments[2] = null;
                                {
                                    var payloadType_1 = __arguments[0];
                                    var type_7 = __arguments[1];
                                    var subtype = __arguments[2];
                                    __arguments = new Array(0);
                                    {
                                        _this = _super.call(this) || this;
                                        _this.fmicelinksdprtcpFeedbackAttributeInit();
                                        _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtcpFeedbackAttribute);
                                        _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                                    }
                                    _this.setPayloadType(payloadType_1);
                                    _this.setType(type_7);
                                    _this.setSubType(subtype);
                                }
                            }
                            else if (__arguments.length == 3) {
                                var payloadType = __arguments[0];
                                var type = __arguments[1];
                                var subtype = __arguments[2];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdprtcpFeedbackAttributeInit();
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtcpFeedbackAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                                }
                                _this.setPayloadType(payloadType);
                                _this.setType(type);
                                _this.setSubType(subtype);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        FeedbackAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtcp.FeedbackAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        FeedbackAttribute.prototype.fmicelinksdprtcpFeedbackAttributeInit = function () {
                            this._payloadType = 0;
                        };
                        FeedbackAttribute.ccmFirAttribute = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                return new fm.icelink.sdp.rtcp.FeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getCcm(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getFir());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.ccmLrrAttribute = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                return new fm.icelink.sdp.rtcp.FeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getCcm(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getLrr());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.ccmTmmbnAttribute = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                return new fm.icelink.sdp.rtcp.FeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getCcm(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getTmmbn());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.ccmTmmbrAttribute = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                return new fm.icelink.sdp.rtcp.FeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getCcm(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getTmmbr());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var wildcardPayloadType = fm.icelink.sdp.rtcp.FeedbackAttribute.getWildcardPayloadType();
                                var index = fm.icelink.StringExtensions.indexOf(value, " ");
                                if ((index < 0)) {
                                    fm.icelink.Log.error(fm.icelink.StringExtensions.concat("Could not parse SDP attribute (RTCP feedback): ", value));
                                    return null;
                                }
                                var s = fm.icelink.StringExtensions.substring(value, 0, index);
                                if ((!fm.icelink.Global.equals(s, "*"))) {
                                    wildcardPayloadType = fm.icelink.ParseAssistant.parseIntegerValue(s);
                                }
                                value = value.substring((index + 1));
                                var str2 = value;
                                var str3 = null;
                                index = fm.icelink.StringExtensions.indexOf(value, " ");
                                if ((index >= 0)) {
                                    str2 = fm.icelink.StringExtensions.substring(value, 0, index);
                                    value = value.substring((index + 1));
                                    str3 = value;
                                }
                                var attribute = new fm.icelink.sdp.rtcp.FeedbackAttribute();
                                attribute.setPayloadType(wildcardPayloadType);
                                attribute.setType(str2);
                                attribute.setSubType(str3);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.getWildcardPayloadType = function () {
                            if (arguments.length == 0) {
                                return -1;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.nackAttribute = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                return new fm.icelink.sdp.rtcp.FeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.nackPliAttribute = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                return new fm.icelink.sdp.rtcp.FeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getPli());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.nackRpsiAttribute = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                return new fm.icelink.sdp.rtcp.FeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getRpsi());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.nackSliAttribute = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                return new fm.icelink.sdp.rtcp.FeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getSli());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.rembAttribute = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                return new fm.icelink.sdp.rtcp.FeedbackAttribute(payloadType, fm.icelink.sdp.rtcp.FeedbackAttributeType.getRemb());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var str = ((fm.icelink.Global.equals(this.getPayloadType(), fm.icelink.sdp.rtcp.FeedbackAttribute.getWildcardPayloadType())) ? "*" : fm.icelink.NumberExtensions.toString(this.getPayloadType()));
                                if ((fm.icelink.Global.equals(this.getSubType(), null))) {
                                    return fm.icelink.StringExtensions.format("{0} {1}", str, this.getType());
                                }
                                return fm.icelink.StringExtensions.format("{0} {1} {2}", str, this.getType(), this.getSubType());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.prototype.getPayloadType = function () {
                            if (arguments.length == 0) {
                                return this._payloadType;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.prototype.getSubType = function () {
                            if (arguments.length == 0) {
                                return this._subType;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.prototype.getType = function () {
                            if (arguments.length == 0) {
                                return this._type;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.prototype.setPayloadType = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._payloadType = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.prototype.setSubType = function (value) {
                            if (arguments.length == 1) {
                                this._subType = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttribute.prototype.setType = function (value) {
                            if (arguments.length == 1) {
                                this._type = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return FeedbackAttribute;
                    }(fm.icelink.sdp.Attribute));
                    rtcp.FeedbackAttribute = FeedbackAttribute;
                })(sdp.rtcp || (sdp.rtcp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtcp) {
                    var FeedbackAttributeSubType =  (function () {
                        function FeedbackAttributeSubType() {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) ;
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        FeedbackAttributeSubType.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtcp.FeedbackAttributeSubType]';
                        };
                        FeedbackAttributeSubType.getFir = function () {
                            if (arguments.length == 0) {
                                return "fir";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeSubType.getLrr = function () {
                            if (arguments.length == 0) {
                                return "lrr";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeSubType.getPli = function () {
                            if (arguments.length == 0) {
                                return "pli";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeSubType.getRpsi = function () {
                            if (arguments.length == 0) {
                                return "rpsi";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeSubType.getSli = function () {
                            if (arguments.length == 0) {
                                return "sli";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeSubType.getTmmbn = function () {
                            if (arguments.length == 0) {
                                return "tmmbn";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeSubType.getTmmbr = function () {
                            if (arguments.length == 0) {
                                return "tmmbr";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return FeedbackAttributeSubType;
                    }());
                    rtcp.FeedbackAttributeSubType = FeedbackAttributeSubType;
                })(sdp.rtcp || (sdp.rtcp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtcp) {
                    var FeedbackAttributeType =  (function () {
                        function FeedbackAttributeType() {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) ;
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        FeedbackAttributeType.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtcp.FeedbackAttributeType]';
                        };
                        FeedbackAttributeType.getAck = function () {
                            if (arguments.length == 0) {
                                return "ack";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeType.getApp = function () {
                            if (arguments.length == 0) {
                                return "app";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeType.getCcm = function () {
                            if (arguments.length == 0) {
                                return "ccm";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeType.getNack = function () {
                            if (arguments.length == 0) {
                                return "nack";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeType.getRemb = function () {
                            if (arguments.length == 0) {
                                return "goog-remb";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return FeedbackAttributeType;
                    }());
                    rtcp.FeedbackAttributeType = FeedbackAttributeType;
                })(sdp.rtcp || (sdp.rtcp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtcp) {
                    var MuxAttribute =  (function (_super) {
                        __extends(MuxAttribute, _super);
                        function MuxAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtcpMuxAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Identical);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        MuxAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtcp.MuxAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        MuxAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                return new fm.icelink.sdp.rtcp.MuxAttribute();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MuxAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                return null;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return MuxAttribute;
                    }(fm.icelink.sdp.Attribute));
                    rtcp.MuxAttribute = MuxAttribute;
                })(sdp.rtcp || (sdp.rtcp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var ExtMapAttribute =  (function (_super) {
                        __extends(ExtMapAttribute, _super);
                        function ExtMapAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdprtpExtMapAttributeInit();
                                _this.__direction = fm.icelink.StreamDirection.Unset;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpExtMapAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Special);
                            }
                            else if (__arguments.length == 2) {
                                var idValue = __arguments[0];
                                var uri = __arguments[1];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdprtpExtMapAttributeInit();
                                    _this.__direction = fm.icelink.StreamDirection.Unset;
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpExtMapAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Special);
                                }
                                _this.setId(idValue);
                                _this.setUri(uri);
                            }
                            else if (__arguments.length == 3) {
                                var idValue = __arguments[0];
                                var uri = __arguments[1];
                                var direction = __arguments[2];
                                __arguments = new Array(2);
                                __arguments[0] = idValue;
                                __arguments[1] = uri;
                                {
                                    var idValue_4 = __arguments[0];
                                    var uri_1 = __arguments[1];
                                    __arguments = new Array(0);
                                    {
                                        _this = _super.call(this) || this;
                                        _this.fmicelinksdprtpExtMapAttributeInit();
                                        _this.__direction = fm.icelink.StreamDirection.Unset;
                                        _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpExtMapAttribute);
                                        _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Special);
                                    }
                                    _this.setId(idValue_4);
                                    _this.setUri(uri_1);
                                }
                                _this.setDirection(direction);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        ExtMapAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.ExtMapAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        ExtMapAttribute.prototype.fmicelinksdprtpExtMapAttributeInit = function () {
                            this._id = 0;
                        };
                        ExtMapAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var num2 = fm.icelink.StringExtensions.indexOf(value, "/");
                                var flag = ((num2 > -1) && (index > num2));
                                var sendReceive = fm.icelink.StreamDirection.SendReceive;
                                var idValue = fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring(value, 0, ((num2 > -1) ? fm.icelink.MathAssistant.min(index, num2) : index)));
                                if (flag) {
                                    sendReceive = fm.icelink.StreamDirectionHelper.directionFromString(fm.icelink.StringExtensions.substring(value, (num2 + 1), ((index - num2) - 1)));
                                }
                                var str2 = value.substring((index + 1));
                                var length_44 = fm.icelink.StringExtensions.indexOf(str2, " ");
                                var uri = "";
                                var str4 = "";
                                if ((fm.icelink.Global.equals(length_44, -1))) {
                                    uri = str2;
                                }
                                else {
                                    uri = fm.icelink.StringExtensions.substring(str2, 0, length_44);
                                    str4 = str2.substring((length_44 + 1));
                                }
                                var attribute = new fm.icelink.sdp.rtp.ExtMapAttribute(idValue, uri);
                                if (flag) {
                                    attribute.setDirection(sendReceive);
                                }
                                if (!fm.icelink.StringExtensions.isNullOrEmpty(str4)) {
                                    attribute.setExtensionAttributes(str4);
                                }
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        ExtMapAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(fm.icelink.NumberExtensions.toString(this.getId()));
                                if ((!fm.icelink.Global.equals(this.getDirection(), fm.icelink.StreamDirection.Unset))) {
                                    var str = fm.icelink.StreamDirectionHelper.directionToString(this.getDirection());
                                    builder.append("/");
                                    builder.append(str);
                                }
                                builder.append(" ");
                                builder.append(this.getUri());
                                if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getExtensionAttributes())) {
                                    builder.append(" ");
                                    builder.append(this.getExtensionAttributes());
                                }
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        ExtMapAttribute.prototype.getDirection = function () {
                            if (arguments.length == 0) {
                                return this.__direction;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        ExtMapAttribute.prototype.getExtensionAttributes = function () {
                            if (arguments.length == 0) {
                                return this._extensionAttributes;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        ExtMapAttribute.prototype.getId = function () {
                            if (arguments.length == 0) {
                                return this._id;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        ExtMapAttribute.prototype.getUri = function () {
                            if (arguments.length == 0) {
                                return this._uri;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        ExtMapAttribute.prototype.setDirection = function (value) {
                            if (arguments.length == 1) {
                                this.__direction = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        ExtMapAttribute.prototype.setExtensionAttributes = function (value) {
                            if (arguments.length == 1) {
                                this._extensionAttributes = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        ExtMapAttribute.prototype.setId = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._id = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        ExtMapAttribute.prototype.setUri = function (value) {
                            if (arguments.length == 1) {
                                this._uri = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return ExtMapAttribute;
                    }(fm.icelink.sdp.Attribute));
                    rtp.ExtMapAttribute = ExtMapAttribute;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var FeedbackAttributeCollection =  (function () {
                        function FeedbackAttributeCollection() {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                this.__attributes = {};
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        FeedbackAttributeCollection.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.FeedbackAttributeCollection]';
                        };
                        FeedbackAttributeCollection.prototype.addAttribute = function (attribute) {
                            if (arguments.length == 1) {
                                var key = this.calculateFeedbackAttributeKey(attribute.getPayloadType(), attribute.getType(), attribute.getSubType());
                                if (!fm.icelink.HashExtensions.containsKey(this.__attributes, key)) {
                                    fm.icelink.HashExtensions.add(this.__attributes, key, attribute);
                                    return true;
                                }
                                return false;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeCollection.prototype.calculateFeedbackAttributeKey = function (payloadType, feedbackAttributeType, subType) {
                            if (arguments.length == 3) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                var str = (fm.icelink.StringExtensions.isNullOrEmpty(feedbackAttributeType) ? "null" : feedbackAttributeType);
                                var str2 = (fm.icelink.StringExtensions.isNullOrEmpty(subType) ? "null" : subType);
                                var str3 = fm.icelink.NumberExtensions.toString(payloadType);
                                return fm.icelink.StringExtensions.concat([str, "&", str2, "&", str3]);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeCollection.prototype.clear = function () {
                            if (arguments.length == 0) {
                                fm.icelink.HashExtensions.clear(this.__attributes);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeCollection.prototype.remove = function (attribute) {
                            if (arguments.length == 1) {
                                var key = this.calculateFeedbackAttributeKey(attribute.getPayloadType(), attribute.getType(), attribute.getSubType());
                                return fm.icelink.HashExtensions.remove(this.__attributes, key);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeCollection.prototype.toArray = function () {
                            if (arguments.length == 0) {
                                var list = new Array();
                                for (var _i = 0, _a = fm.icelink.HashExtensions.getValues(this.__attributes); _i < _a.length; _i++) {
                                    var attribute = _a[_i];
                                    fm.icelink.ArrayExtensions.add(list, attribute);
                                }
                                return fm.icelink.ArrayExtensions.toArray(list);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        FeedbackAttributeCollection.prototype.tryGetFeedbackAttribute = function (payloadType, feedbackAttributeType, subType, feedbackAttribute) {
                            if (arguments.length == 4) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                var attribute = null;
                                var key = this.calculateFeedbackAttributeKey(payloadType, feedbackAttributeType, subType);
                                var _var0 = new fm.icelink.Holder(attribute);
                                var _var1 = fm.icelink.HashExtensions.tryGetValue(this.__attributes, key, _var0);
                                attribute = _var0.getValue();
                                if (_var1) {
                                    feedbackAttribute.setValue(attribute);
                                    return true;
                                }
                                feedbackAttribute.setValue(null);
                                return false;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return FeedbackAttributeCollection;
                    }());
                    rtp.FeedbackAttributeCollection = FeedbackAttributeCollection;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var MapAttribute =  (function (_super) {
                        __extends(MapAttribute, _super);
                        function MapAttribute() {
                            var _this = this;
                            fm.icelink.sdp.rtp.MapAttribute.fmicelinksdprtpMapAttributeInitialize();
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdprtpMapAttributeInit();
                                _this.__relatedRtcpFeedbackAttributes = new fm.icelink.sdp.rtp.FeedbackAttributeCollection();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpMapAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                            }
                            else if (__arguments.length == 3) {
                                var payloadType = __arguments[0];
                                var formatName = __arguments[1];
                                var clockRate = __arguments[2];
                                __arguments = new Array(4);
                                __arguments[0] = payloadType;
                                __arguments[1] = formatName;
                                __arguments[2] = clockRate;
                                __arguments[3] = null;
                                {
                                    var payloadType_2 = __arguments[0];
                                    var formatName_1 = __arguments[1];
                                    var clockRate_6 = __arguments[2];
                                    var formatParameters = __arguments[3];
                                    __arguments = new Array(0);
                                    {
                                        _this = _super.call(this) || this;
                                        _this.fmicelinksdprtpMapAttributeInit();
                                        _this.__relatedRtcpFeedbackAttributes = new fm.icelink.sdp.rtp.FeedbackAttributeCollection();
                                        _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpMapAttribute);
                                        _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                                    }
                                    if ((fm.icelink.Global.equals(formatName_1, null))) {
                                        throw new fm.icelink.Exception("formatName cannot be null.");
                                    }
                                    _this.setPayloadType(payloadType_2);
                                    _this.setFormatName(formatName_1);
                                    _this.setClockRate(clockRate_6);
                                    _this.setFormatParameters(formatParameters);
                                }
                            }
                            else if (__arguments.length == 4) {
                                var payloadType = __arguments[0];
                                var formatName = __arguments[1];
                                var clockRate = __arguments[2];
                                var formatParameters = __arguments[3];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdprtpMapAttributeInit();
                                    _this.__relatedRtcpFeedbackAttributes = new fm.icelink.sdp.rtp.FeedbackAttributeCollection();
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpMapAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.IdenticalPerPT);
                                }
                                if ((fm.icelink.Global.equals(formatName, null))) {
                                    throw new fm.icelink.Exception("formatName cannot be null.");
                                }
                                _this.setPayloadType(payloadType);
                                _this.setFormatName(formatName);
                                _this.setClockRate(clockRate);
                                _this.setFormatParameters(formatParameters);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        MapAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.MapAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        MapAttribute.prototype.fmicelinksdprtpMapAttributeInit = function () {
                            this._clockRate = 0;
                            this._payloadType = 0;
                        };
                        MapAttribute.fromAttributeValue = function (value) {
                            fm.icelink.sdp.rtp.MapAttribute.fmicelinksdprtpMapAttributeInitialize();
                            if (arguments.length == 1) {
                                var index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var num2 = fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring(value, 0, index));
                                value = value.substring((index + 1));
                                var length_45 = fm.icelink.StringExtensions.indexOf(value, "/");
                                var str = fm.icelink.StringExtensions.substring(value, 0, length_45);
                                value = value.substring((length_45 + 1));
                                length_45 = fm.icelink.StringExtensions.indexOf(value, "/");
                                var num4 = 0;
                                var str2 = null;
                                if ((fm.icelink.Global.equals(length_45, -1))) {
                                    num4 = fm.icelink.ParseAssistant.parseIntegerValue(value);
                                }
                                else {
                                    num4 = fm.icelink.ParseAssistant.parseIntegerValue(fm.icelink.StringExtensions.substring(value, 0, length_45));
                                    str2 = value.substring((length_45 + 1));
                                }
                                var attribute = new fm.icelink.sdp.rtp.MapAttribute();
                                attribute.setPayloadType(num2);
                                attribute.setFormatName(str);
                                attribute.setClockRate(num4);
                                attribute.setFormatParameters(str2);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.getIanaMapAttribute = function (payloadType) {
                            fm.icelink.sdp.rtp.MapAttribute.fmicelinksdprtpMapAttributeInitialize();
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                var attribute = null;
                                var _var0 = new fm.icelink.Holder(attribute);
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.tryGetValue(fm.icelink.NumberExtensions.toString(payloadType), _var0);
                                attribute = _var0.getValue();
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.addRelatedRtcpFeedbackAttribute = function (attribute) {
                            if (arguments.length == 1) {
                                this.__relatedRtcpFeedbackAttributes.addAttribute(attribute);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(fm.icelink.NumberExtensions.toString(this.getPayloadType()));
                                builder.append(" ");
                                builder.append(this.getFormatName());
                                builder.append("/");
                                builder.append(fm.icelink.NumberExtensions.toString(this.getClockRate()));
                                if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getFormatParameters())) {
                                    builder.append("/");
                                    builder.append(this.getFormatParameters());
                                }
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getClockRate = function () {
                            if (arguments.length == 0) {
                                return this._clockRate;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getFormatName = function () {
                            if (arguments.length == 0) {
                                return this._formatName;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getFormatParameters = function () {
                            if (arguments.length == 0) {
                                return this._formatParameters;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getPayloadType = function () {
                            if (arguments.length == 0) {
                                return this._payloadType;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedCcmFirFeedbackAttribute = function () {
                            if (arguments.length == 0) {
                                return this.getRelatedRtcpFeedbackAttribute(fm.icelink.sdp.rtcp.FeedbackAttributeType.getCcm(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getFir());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedCcmLrrFeedbackAttribute = function () {
                            if (arguments.length == 0) {
                                return this.getRelatedRtcpFeedbackAttribute(fm.icelink.sdp.rtcp.FeedbackAttributeType.getCcm(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getLrr());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedCcmTmmbnFeedbackAttribute = function () {
                            if (arguments.length == 0) {
                                return this.getRelatedRtcpFeedbackAttribute(fm.icelink.sdp.rtcp.FeedbackAttributeType.getCcm(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getTmmbn());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedCcmTmmbrFeedbackAttribute = function () {
                            if (arguments.length == 0) {
                                return this.getRelatedRtcpFeedbackAttribute(fm.icelink.sdp.rtcp.FeedbackAttributeType.getCcm(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getTmmbr());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedFormatParametersAttribute = function () {
                            if (arguments.length == 0) {
                                return this._relatedFormatParametersAttribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedNackFeedbackAttribute = function () {
                            if (arguments.length == 0) {
                                return this.getRelatedRtcpFeedbackAttribute(fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), null);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedNackPliFeedbackAttribute = function () {
                            if (arguments.length == 0) {
                                return this.getRelatedRtcpFeedbackAttribute(fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getPli());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedNackRpsiFeedbackAttribute = function () {
                            if (arguments.length == 0) {
                                return this.getRelatedRtcpFeedbackAttribute(fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getRpsi());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedNackSliFeedbackAttribute = function () {
                            if (arguments.length == 0) {
                                return this.getRelatedRtcpFeedbackAttribute(fm.icelink.sdp.rtcp.FeedbackAttributeType.getNack(), fm.icelink.sdp.rtcp.FeedbackAttributeSubType.getSli());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedRembFeedbackAttribute = function () {
                            if (arguments.length == 0) {
                                return this.getRelatedRtcpFeedbackAttribute(fm.icelink.sdp.rtcp.FeedbackAttributeType.getRemb(), null);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedRtcpFeedbackAttribute = function () {
                            if (arguments.length == 3) {
                                var payloadType = fm.icelink.Global.toInt(arguments[0]);
                                var type = arguments[1];
                                var subType = arguments[2];
                                for (var _i = 0, _a = this.getRelatedRtcpFeedbackAttributes(); _i < _a.length; _i++) {
                                    var attribute = _a[_i];
                                    if (((((!fm.icelink.Global.equals(attribute, null)) && (fm.icelink.Global.equals(attribute.getType(), type))) && (fm.icelink.Global.equals(attribute.getSubType(), subType))) && (fm.icelink.Global.equals(attribute.getPayloadType(), payloadType)))) {
                                        return attribute;
                                    }
                                }
                                return null;
                            }
                            else if (arguments.length == 2) {
                                var type = arguments[0];
                                var subType = arguments[1];
                                for (var _b = 0, _c = this.getRelatedRtcpFeedbackAttributes(); _b < _c.length; _b++) {
                                    var attribute = _c[_b];
                                    if ((((!fm.icelink.Global.equals(attribute, null)) && (fm.icelink.Global.equals(attribute.getType(), type))) && (fm.icelink.Global.equals(attribute.getSubType(), subType)))) {
                                        return attribute;
                                    }
                                }
                                return null;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getRelatedRtcpFeedbackAttributes = function () {
                            if (arguments.length == 0) {
                                return this.__relatedRtcpFeedbackAttributes.toArray();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.removeRelatedRtcpFeedbackAttribute = function (attribute) {
                            if (arguments.length == 1) {
                                return this.__relatedRtcpFeedbackAttributes.remove(attribute);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.resetRtcpFeedbackAttributes = function (attributes) {
                            if (arguments.length == 1) {
                                this.__relatedRtcpFeedbackAttributes.clear();
                                for (var _i = 0, attributes_10 = attributes; _i < attributes_10.length; _i++) {
                                    var attribute = attributes_10[_i];
                                    this.__relatedRtcpFeedbackAttributes.addAttribute(attribute);
                                }
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.setClockRate = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._clockRate = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.setFormatName = function (value) {
                            if (arguments.length == 1) {
                                this._formatName = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.setFormatParameters = function (value) {
                            if (arguments.length == 1) {
                                this._formatParameters = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.setPayloadType = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._payloadType = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.setRelatedFormatParametersAttribute = function (value) {
                            if (arguments.length == 1) {
                                this._relatedFormatParametersAttribute = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.fmicelinksdprtpMapAttributeInitialize = function () {
                            if (!fm.icelink.sdp.rtp.MapAttribute.__fmicelinksdprtpMapAttributeInitialized && !fm.icelink.sdp.rtp.MapAttribute.__fmicelinksdprtpMapAttributeInitializing) {
                                fm.icelink.sdp.rtp.MapAttribute.__fmicelinksdprtpMapAttributeInitializing = true;
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes = new fm.icelink.ManagedConcurrentDictionary();
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("0", new fm.icelink.sdp.rtp.MapAttribute(0, "PCMU", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("3", new fm.icelink.sdp.rtp.MapAttribute(3, "GSM", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("4", new fm.icelink.sdp.rtp.MapAttribute(4, "G723", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("5", new fm.icelink.sdp.rtp.MapAttribute(5, "DVI4", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("6", new fm.icelink.sdp.rtp.MapAttribute(6, "DVI4", 16000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("7", new fm.icelink.sdp.rtp.MapAttribute(7, "LPC", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("8", new fm.icelink.sdp.rtp.MapAttribute(8, "PCMA", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("9", new fm.icelink.sdp.rtp.MapAttribute(9, "G722", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("10", new fm.icelink.sdp.rtp.MapAttribute(10, "L16", 44100, "2"));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("11", new fm.icelink.sdp.rtp.MapAttribute(11, "L16", 44100));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("12", new fm.icelink.sdp.rtp.MapAttribute(12, "QCELP", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("13", new fm.icelink.sdp.rtp.MapAttribute(13, "CN", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("14", new fm.icelink.sdp.rtp.MapAttribute(14, "MPA", 90000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("15", new fm.icelink.sdp.rtp.MapAttribute(15, "G728", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("16", new fm.icelink.sdp.rtp.MapAttribute(16, "DVI4", 11025));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("17", new fm.icelink.sdp.rtp.MapAttribute(17, "DVI4", 22050));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("18", new fm.icelink.sdp.rtp.MapAttribute(18, "G729", 8000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("25", new fm.icelink.sdp.rtp.MapAttribute(25, "CelB", 90000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("26", new fm.icelink.sdp.rtp.MapAttribute(26, "JPEG", 90000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("28", new fm.icelink.sdp.rtp.MapAttribute(28, "nv", 90000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("31", new fm.icelink.sdp.rtp.MapAttribute(31, "H261", 90000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("32", new fm.icelink.sdp.rtp.MapAttribute(32, "MPV", 90000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("33", new fm.icelink.sdp.rtp.MapAttribute(33, "MP2T", 90000));
                                fm.icelink.sdp.rtp.MapAttribute.fm_icelink_sdp_rtp_MapAttribute___ianaMapAttributes.addOrUpdate("34", new fm.icelink.sdp.rtp.MapAttribute(34, "H263", 90000));
                                fm.icelink.sdp.rtp.MapAttribute.__fmicelinksdprtpMapAttributeInitialized = true;
                                fm.icelink.sdp.rtp.MapAttribute.__fmicelinksdprtpMapAttributeInitializing = false;
                            }
                        };
                        MapAttribute.__fmicelinksdprtpMapAttributeInitialized = false;
                        MapAttribute.__fmicelinksdprtpMapAttributeInitializing = false;
                        return MapAttribute;
                    }(fm.icelink.sdp.Attribute));
                    rtp.MapAttribute = MapAttribute;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var Media =  (function (_super) {
                        __extends(Media, _super);
                        function Media(mediaType, transportPort, transportProtocol, rtpPayloadTypeNumbers) {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 4) {
                                var mediaType_2 = __arguments[0];
                                var transportPort_2 = __arguments[1];
                                var transportProtocol_2 = __arguments[2];
                                var rtpPayloadTypeNumbers_1 = __arguments[3];
                                _this = _super.call(this, mediaType_2, transportPort_2, transportProtocol_2) || this;
                                if ((fm.icelink.Global.equals(rtpPayloadTypeNumbers_1, null))) {
                                    throw new fm.icelink.Exception("rtpPayloadTypeNumbers cannot be null.");
                                }
                                var strArray = new Array(rtpPayloadTypeNumbers_1.length);
                                for (var i = 0; (i < rtpPayloadTypeNumbers_1.length); i++) {
                                    strArray[i] = fm.icelink.NumberExtensions.toString(rtpPayloadTypeNumbers_1[i]);
                                }
                                _super.prototype.setFormatDescription.call(_this, fm.icelink.StringExtensions.join(" ", strArray));
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        Media.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.Media]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        Media.generateRtpProfile = function (type, rtcpFeedbackSupported, useDtls, useEncryption) {
                            if (arguments.length == 4) {
                                if (!(useEncryption || !useDtls)) {
                                    throw new fm.icelink.Exception("Cannot generate RTP Profile for the case when DTLS support is required but encryption is not used. Likely, useEncryption must be set.");
                                }
                                if (((!fm.icelink.Global.equals(type, fm.icelink.StreamType.Video)) && (!fm.icelink.Global.equals(type, fm.icelink.StreamType.Audio)))) {
                                    throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Cannot generate RTP Profile streams of type other than Audio or Video. {0} type supplied.", new fm.icelink.StreamTypeWrapper(type).toString()));
                                }
                                if (useEncryption) {
                                    if (useDtls) {
                                        if (rtcpFeedbackSupported) {
                                            return fm.icelink.sdp.rtp.Media.getUdpTlsRtpSavpfTransportProtocol();
                                        }
                                        return fm.icelink.sdp.rtp.Media.getUdpTlsRtpSavpTransportProtocol();
                                    }
                                    if (rtcpFeedbackSupported) {
                                        return fm.icelink.sdp.rtp.Media.getRtpSavpfTransportProtocol();
                                    }
                                    return fm.icelink.sdp.rtp.Media.getRtpSavpTransportProtocol();
                                }
                                if (rtcpFeedbackSupported) {
                                    return fm.icelink.sdp.rtp.Media.getRtpAvpfTransportProtocol();
                                }
                                return fm.icelink.sdp.rtp.Media.getRtpAvpTransportProtocol();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getPayloadTypes = function (formatDesciption) {
                            if (arguments.length == 1) {
                                if (((!fm.icelink.Global.equals(formatDesciption, null)) && (fm.icelink.StringExtensions.getLength(formatDesciption) > 0))) {
                                    var strArray = fm.icelink.StringExtensions.split(fm.icelink.StringExtensions.trim(formatDesciption), [32]);
                                    var numArray = new Array(strArray.length);
                                    for (var i = 0; (i < strArray.length); i++) {
                                        numArray[i] = fm.icelink.ParseAssistant.parseIntegerValue(strArray[i]);
                                    }
                                    return numArray;
                                }
                                return new Array(0);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getRtpAvpfTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "RTP/AVPF";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getRtpAvpTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "RTP/AVP";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getRtpSavpfTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "RTP/SAVPF";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getRtpSavpTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "RTP/SAVP";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getUdpTlsRtpSavpfTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "UDP/TLS/RTP/SAVPF";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getUdpTlsRtpSavpTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "UDP/TLS/RTP/SAVP";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getWellKnownPayloadClockRate = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                var _var0 = payloadType;
                                do {
                                    if (_var0 == 0 || _var0 == 3 || _var0 == 4 || _var0 == 5) {
                                        return 8000;
                                    }
                                    else if (_var0 == 6) {
                                        return 16000;
                                    }
                                    else if (_var0 == 7 || _var0 == 8 || _var0 == 9) {
                                        return 8000;
                                    }
                                    else if (_var0 == 10 || _var0 == 11) {
                                        return 44100;
                                    }
                                    else if (_var0 == 12 || _var0 == 13) {
                                        return 8000;
                                    }
                                    else if (_var0 == 14) {
                                        return 90000;
                                    }
                                    else if (_var0 == 15) {
                                        return 8000;
                                    }
                                    else if (_var0 == 16) {
                                        return 11025;
                                    }
                                    else if (_var0 == 17) {
                                        return 22050;
                                    }
                                    else if (_var0 == 18) {
                                        return 8000;
                                    }
                                    else if (_var0 == 25 || _var0 == 26 || _var0 == 28 || _var0 == 31 || _var0 == 32 || _var0 == 33 || _var0 == 34) {
                                        return 90000;
                                    }
                                } while (false);
                                return -1;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getWellKnownPayloadName = function (payloadType) {
                            if (arguments.length == 1) {
                                payloadType = fm.icelink.Global.toInt(arguments[0]);
                                var _var0 = payloadType;
                                do {
                                    if (_var0 == 0) {
                                        return "PCMU";
                                    }
                                    else if (_var0 == 3) {
                                        return "GSM";
                                    }
                                    else if (_var0 == 4) {
                                        return "G723";
                                    }
                                    else if (_var0 == 5 || _var0 == 6) {
                                        return "DVI4";
                                    }
                                    else if (_var0 == 7) {
                                        return "LPC";
                                    }
                                    else if (_var0 == 8) {
                                        return "PCMA";
                                    }
                                    else if (_var0 == 9) {
                                        return "G722";
                                    }
                                    else if (_var0 == 10 || _var0 == 11) {
                                        return "L16";
                                    }
                                    else if (_var0 == 12) {
                                        return "QCELP";
                                    }
                                    else if (_var0 == 13) {
                                        return "CN";
                                    }
                                    else if (_var0 == 14) {
                                        return "MPA";
                                    }
                                    else if (_var0 == 15) {
                                        return "G728";
                                    }
                                    else if (_var0 == 16 || _var0 == 17) {
                                        return "DVI4";
                                    }
                                    else if (_var0 == 18) {
                                        return "G729";
                                    }
                                    else if (_var0 == 25) {
                                        return "CelB";
                                    }
                                    else if (_var0 == 26) {
                                        return "JPEG";
                                    }
                                    else if (_var0 == 28) {
                                        return "nv";
                                    }
                                    else if (_var0 == 31) {
                                        return "H261";
                                    }
                                    else if (_var0 == 32) {
                                        return "MPV";
                                    }
                                    else if (_var0 == 33) {
                                        return "MP2T";
                                    }
                                    else if (_var0 == 34) {
                                        return "H263";
                                    }
                                } while (false);
                                return null;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.supportsEncryption = function (protocol) {
                            if (arguments.length == 1) {
                                return ((((fm.icelink.Global.equals(protocol, fm.icelink.sdp.rtp.Media.getUdpTlsRtpSavpTransportProtocol())) || (fm.icelink.Global.equals(protocol, fm.icelink.sdp.rtp.Media.getUdpTlsRtpSavpfTransportProtocol()))) || (fm.icelink.Global.equals(protocol, fm.icelink.sdp.rtp.Media.getRtpSavpTransportProtocol()))) || (fm.icelink.Global.equals(protocol, fm.icelink.sdp.rtp.Media.getRtpSavpfTransportProtocol())));
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.supportsRtcpBasedFeedback = function (protocol) {
                            if (arguments.length == 1) {
                                return (((fm.icelink.Global.equals(protocol, fm.icelink.sdp.rtp.Media.getRtpSavpfTransportProtocol())) || (fm.icelink.Global.equals(protocol, fm.icelink.sdp.rtp.Media.getRtpAvpfTransportProtocol()))) || (fm.icelink.Global.equals(protocol, fm.icelink.sdp.rtp.Media.getUdpTlsRtpSavpfTransportProtocol())));
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return Media;
                    }(fm.icelink.sdp.Media));
                    rtp.Media = Media;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var SimulcastStream =  (function () {
                        function SimulcastStream() {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.sdp.rtp.SimulcastStreamId]'))) {
                                var idValue = __arguments[0];
                                __arguments = new Array(1);
                                __arguments[0] = ((fm.icelink.Global.equals(idValue, null)) ? null : [idValue]);
                                {
                                    var ids = __arguments[0];
                                    if ((fm.icelink.Global.equals(ids, null))) {
                                        throw new fm.icelink.Exception("Simulcast stream 'IDs' cannot be null.");
                                    }
                                    if ((fm.icelink.Global.equals(ids.length, 0))) {
                                        throw new fm.icelink.Exception("Simulcast stream requires at least one ID.");
                                    }
                                    this.setIds(ids);
                                }
                            }
                            else if (__arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || (fm.icelink.Util.isArray(arguments[0]) && (arguments[0].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[0][0]) || fm.icelink.Util.isObjectType(arguments[0][0], '[fm.icelink.sdp.rtp.SimulcastStreamId]')))))) {
                                var ids = __arguments[0];
                                if ((fm.icelink.Global.equals(ids, null))) {
                                    throw new fm.icelink.Exception("Simulcast stream 'IDs' cannot be null.");
                                }
                                if ((fm.icelink.Global.equals(ids.length, 0))) {
                                    throw new fm.icelink.Exception("Simulcast stream requires at least one ID.");
                                }
                                this.setIds(ids);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        SimulcastStream.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.SimulcastStream]';
                        };
                        SimulcastStream.prototype.getIds = function () {
                            if (arguments.length == 0) {
                                return this._ids;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastStream.prototype.setIds = function (value) {
                            if (arguments.length == 1) {
                                this._ids = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return SimulcastStream;
                    }());
                    rtp.SimulcastStream = SimulcastStream;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var SimulcastDirection =  (function () {
                        function SimulcastDirection() {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) ;
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        SimulcastDirection.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.SimulcastDirection]';
                        };
                        SimulcastDirection.getReceive = function () {
                            if (arguments.length == 0) {
                                return "recv";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastDirection.getSend = function () {
                            if (arguments.length == 0) {
                                return "send";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return SimulcastDirection;
                    }());
                    rtp.SimulcastDirection = SimulcastDirection;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var SimulcastStreamDescription =  (function () {
                        function SimulcastStreamDescription(direction, streams) {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 2) {
                                var direction_1 = __arguments[0];
                                var streams_7 = __arguments[1];
                                if ((fm.icelink.Global.equals(direction_1, null))) {
                                    throw new fm.icelink.Exception("Simulcast stream description 'direction' cannot be null.");
                                }
                                if ((fm.icelink.Global.equals(streams_7, null))) {
                                    throw new fm.icelink.Exception("Simulcast stream description 'streams' cannot be null.");
                                }
                                if ((fm.icelink.Global.equals(streams_7.length, 0))) {
                                    throw new fm.icelink.Exception("Simulcast stream description requires at least one stream.");
                                }
                                this.setDirection(direction_1);
                                this.setStreams(streams_7);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        SimulcastStreamDescription.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.SimulcastStreamDescription]';
                        };
                        SimulcastStreamDescription.prototype.directionIsValid = function (direction) {
                            if (arguments.length == 1) {
                                for (var _i = 0, _a = [fm.icelink.sdp.rtp.SimulcastDirection.getSend(), fm.icelink.sdp.rtp.SimulcastDirection.getReceive()]; _i < _a.length; _i++) {
                                    var str = _a[_i];
                                    if ((fm.icelink.Global.equals(direction, str))) {
                                        return true;
                                    }
                                }
                                return false;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastStreamDescription.prototype.getDirection = function () {
                            if (arguments.length == 0) {
                                return this.__direction;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastStreamDescription.prototype.getStreams = function () {
                            if (arguments.length == 0) {
                                return this._streams;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastStreamDescription.prototype.setDirection = function (value) {
                            if (arguments.length == 1) {
                                if (!this.directionIsValid(value)) {
                                    throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Simulcast stream description 'direction' cannot be '{0}'.", value));
                                }
                                this.__direction = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastStreamDescription.prototype.setStreams = function (value) {
                            if (arguments.length == 1) {
                                this._streams = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return SimulcastStreamDescription;
                    }());
                    rtp.SimulcastStreamDescription = SimulcastStreamDescription;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var RidDirection =  (function () {
                        function RidDirection() {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) ;
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        RidDirection.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.RidDirection]';
                        };
                        RidDirection.getReceive = function () {
                            if (arguments.length == 0) {
                                return "recv";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidDirection.getSend = function () {
                            if (arguments.length == 0) {
                                return "send";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return RidDirection;
                    }());
                    rtp.RidDirection = RidDirection;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var RidRestriction =  (function () {
                        function RidRestriction() {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 1) {
                                var key = __arguments[0];
                                __arguments = new Array(2);
                                __arguments[0] = key;
                                __arguments[1] = null;
                                {
                                    var key_1 = __arguments[0];
                                    var value = __arguments[1];
                                    if (fm.icelink.StringExtensions.isNullOrEmpty(key_1)) {
                                        throw new fm.icelink.Exception("RID restriction 'key' cannot be null.");
                                    }
                                    this.setKey(key_1);
                                    this.setValue(value);
                                }
                            }
                            else if (__arguments.length == 2) {
                                var key = __arguments[0];
                                var value = __arguments[1];
                                if (fm.icelink.StringExtensions.isNullOrEmpty(key)) {
                                    throw new fm.icelink.Exception("RID restriction 'key' cannot be null.");
                                }
                                this.setKey(key);
                                this.setValue(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        RidRestriction.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.RidRestriction]';
                        };
                        RidRestriction.getDependKey = function () {
                            if (arguments.length == 0) {
                                return "depend";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.getMaxBitrateKey = function () {
                            if (arguments.length == 0) {
                                return "max-br";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.getMaxBitsPerPixelKey = function () {
                            if (arguments.length == 0) {
                                return "max-bpp";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.getMaxFrameSizeKey = function () {
                            if (arguments.length == 0) {
                                return "max-fs";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.getMaxFramesPerSecondKey = function () {
                            if (arguments.length == 0) {
                                return "max-fps";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.getMaxHeightKey = function () {
                            if (arguments.length == 0) {
                                return "max-height";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.getMaxPixelsPerSecondKey = function () {
                            if (arguments.length == 0) {
                                return "max-pps";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.getMaxWidthKey = function () {
                            if (arguments.length == 0) {
                                return "max-width";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.prototype.getKey = function () {
                            if (arguments.length == 0) {
                                return this._key;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.prototype.getValue = function () {
                            if (arguments.length == 0) {
                                return this._value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.prototype.setKey = function (value) {
                            if (arguments.length == 1) {
                                this._key = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidRestriction.prototype.setValue = function (value) {
                            if (arguments.length == 1) {
                                this._value = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return RidRestriction;
                    }());
                    rtp.RidRestriction = RidRestriction;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var RidAttribute =  (function (_super) {
                        __extends(RidAttribute, _super);
                        function RidAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpRidAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Special);
                            }
                            else if (__arguments.length == 2) {
                                var idValue = __arguments[0];
                                var direction = __arguments[1];
                                __arguments = new Array(4);
                                __arguments[0] = idValue;
                                __arguments[1] = direction;
                                __arguments[2] = null;
                                __arguments[3] = null;
                                {
                                    var idValue_5 = __arguments[0];
                                    var direction_2 = __arguments[1];
                                    var payloadTypes = __arguments[2];
                                    var restrictions = __arguments[3];
                                    __arguments = new Array(0);
                                    {
                                        _this = _super.call(this) || this;
                                        _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpRidAttribute);
                                        _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Special);
                                    }
                                    if (fm.icelink.StringExtensions.isNullOrEmpty(idValue_5)) {
                                        throw new fm.icelink.Exception("RID 'id' cannot be null.");
                                    }
                                    if (fm.icelink.StringExtensions.isNullOrEmpty(direction_2)) {
                                        throw new fm.icelink.Exception("RID 'direction' cannot be null.");
                                    }
                                    if (!fm.icelink.sdp.rtp.RidAttribute.validateId(idValue_5)) {
                                        throw new fm.icelink.Exception("RID 'id' may only conain alphanumeric characters.");
                                    }
                                    _this.setId(idValue_5);
                                    _this.setDirection(direction_2);
                                    _this.setPayloadTypes(payloadTypes);
                                    _this.setRestrictions(restrictions);
                                }
                            }
                            else if (__arguments.length == 3 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || (fm.icelink.Util.isArray(arguments[2]) && (arguments[2].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[2][0]) || fm.icelink.Util.isNumber(arguments[2][0])))))) {
                                var idValue = __arguments[0];
                                var direction = __arguments[1];
                                var payloadTypes = __arguments[2];
                                __arguments = new Array(4);
                                __arguments[0] = idValue;
                                __arguments[1] = direction;
                                __arguments[2] = payloadTypes;
                                __arguments[3] = null;
                                {
                                    var idValue_6 = __arguments[0];
                                    var direction_3 = __arguments[1];
                                    var payloadTypes_1 = __arguments[2];
                                    var restrictions = __arguments[3];
                                    __arguments = new Array(0);
                                    {
                                        _this = _super.call(this) || this;
                                        _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpRidAttribute);
                                        _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Special);
                                    }
                                    if (fm.icelink.StringExtensions.isNullOrEmpty(idValue_6)) {
                                        throw new fm.icelink.Exception("RID 'id' cannot be null.");
                                    }
                                    if (fm.icelink.StringExtensions.isNullOrEmpty(direction_3)) {
                                        throw new fm.icelink.Exception("RID 'direction' cannot be null.");
                                    }
                                    if (!fm.icelink.sdp.rtp.RidAttribute.validateId(idValue_6)) {
                                        throw new fm.icelink.Exception("RID 'id' may only conain alphanumeric characters.");
                                    }
                                    _this.setId(idValue_6);
                                    _this.setDirection(direction_3);
                                    _this.setPayloadTypes(payloadTypes_1);
                                    _this.setRestrictions(restrictions);
                                }
                            }
                            else if (__arguments.length == 4) {
                                var idValue = __arguments[0];
                                var direction = __arguments[1];
                                var payloadTypes = __arguments[2];
                                var restrictions = __arguments[3];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpRidAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Special);
                                }
                                if (fm.icelink.StringExtensions.isNullOrEmpty(idValue)) {
                                    throw new fm.icelink.Exception("RID 'id' cannot be null.");
                                }
                                if (fm.icelink.StringExtensions.isNullOrEmpty(direction)) {
                                    throw new fm.icelink.Exception("RID 'direction' cannot be null.");
                                }
                                if (!fm.icelink.sdp.rtp.RidAttribute.validateId(idValue)) {
                                    throw new fm.icelink.Exception("RID 'id' may only conain alphanumeric characters.");
                                }
                                _this.setId(idValue);
                                _this.setDirection(direction);
                                _this.setPayloadTypes(payloadTypes);
                                _this.setRestrictions(restrictions);
                            }
                            else if (__arguments.length == 3 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || (fm.icelink.Util.isArray(arguments[2]) && (arguments[2].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[2][0]) || fm.icelink.Util.isObjectType(arguments[2][0], '[fm.icelink.sdp.rtp.RidRestriction]')))))) {
                                var idValue = __arguments[0];
                                var direction = __arguments[1];
                                var restrictions = __arguments[2];
                                __arguments = new Array(4);
                                __arguments[0] = idValue;
                                __arguments[1] = direction;
                                __arguments[2] = null;
                                __arguments[3] = restrictions;
                                {
                                    var idValue_7 = __arguments[0];
                                    var direction_4 = __arguments[1];
                                    var payloadTypes = __arguments[2];
                                    var restrictions_1 = __arguments[3];
                                    __arguments = new Array(0);
                                    {
                                        _this = _super.call(this) || this;
                                        _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpRidAttribute);
                                        _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Special);
                                    }
                                    if (fm.icelink.StringExtensions.isNullOrEmpty(idValue_7)) {
                                        throw new fm.icelink.Exception("RID 'id' cannot be null.");
                                    }
                                    if (fm.icelink.StringExtensions.isNullOrEmpty(direction_4)) {
                                        throw new fm.icelink.Exception("RID 'direction' cannot be null.");
                                    }
                                    if (!fm.icelink.sdp.rtp.RidAttribute.validateId(idValue_7)) {
                                        throw new fm.icelink.Exception("RID 'id' may only conain alphanumeric characters.");
                                    }
                                    _this.setId(idValue_7);
                                    _this.setDirection(direction_4);
                                    _this.setPayloadTypes(payloadTypes);
                                    _this.setRestrictions(restrictions_1);
                                }
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        RidAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.RidAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        RidAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var str = fm.icelink.StringExtensions.substring(value, 0, index);
                                value = value.substring((index + 1));
                                var str2 = null;
                                var numArray = null;
                                var restrictionArray = null;
                                index = fm.icelink.StringExtensions.indexOf(value, " ");
                                if ((fm.icelink.Global.equals(index, -1))) {
                                    str2 = value;
                                }
                                else {
                                    var str3 = void 0;
                                    var num3 = void 0;
                                    str2 = fm.icelink.StringExtensions.substring(value, 0, index);
                                    value = value.substring((index + 1));
                                    var strArray = fm.icelink.StringExtensions.split(value, [59]);
                                    var num2 = 0;
                                    if (((strArray.length > num2) && fm.icelink.StringExtensions.startsWith(strArray[num2], "pt="))) {
                                        str3 = strArray[num2++];
                                        var strArray2 = fm.icelink.StringExtensions.split(str3.substring(3), [44]);
                                        numArray = new Array(strArray2.length);
                                        for (num3 = 0; (num3 < numArray.length); num3++) {
                                            numArray[num3] = fm.icelink.ParseAssistant.parseIntegerValue(strArray2[num3]);
                                        }
                                    }
                                    if ((strArray.length > num2)) {
                                        restrictionArray = new Array((strArray.length - num2));
                                        for (num3 = 0; (num3 < restrictionArray.length); num3++) {
                                            str3 = strArray[num2++];
                                            var length_46 = fm.icelink.StringExtensions.indexOf(str3, "=");
                                            if ((fm.icelink.Global.equals(length_46, -1))) {
                                                restrictionArray[num3] = new fm.icelink.sdp.rtp.RidRestriction(str3);
                                            }
                                            else {
                                                var key = fm.icelink.StringExtensions.substring(str3, 0, length_46);
                                                var str5 = str3.substring((length_46 + 1));
                                                restrictionArray[num3] = new fm.icelink.sdp.rtp.RidRestriction(key, str5);
                                            }
                                        }
                                    }
                                }
                                var attribute = new fm.icelink.sdp.rtp.RidAttribute();
                                attribute.setId(str);
                                attribute.setDirection(str2);
                                attribute.setPayloadTypes(numArray);
                                attribute.setRestrictions(restrictionArray);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.validateId = function (idValue) {
                            if (arguments.length == 1) {
                                for (var i = 0; (i < fm.icelink.StringExtensions.getLength(idValue)); i++) {
                                    var ch = idValue.charCodeAt(i);
                                    if ((((((ch < 45) || ((ch > 45) && (ch < 48))) || (((ch > 57) && (ch < 65)) || ((ch > 90) && (ch < 95)))) || ((ch > 95) && (ch < 97))) || (ch > 122))) {
                                        return false;
                                    }
                                }
                                return true;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.directionIsValid = function (direction) {
                            if (arguments.length == 1) {
                                for (var _i = 0, _a = [fm.icelink.sdp.rtp.RidDirection.getSend(), fm.icelink.sdp.rtp.RidDirection.getReceive()]; _i < _a.length; _i++) {
                                    var str = _a[_i];
                                    if ((fm.icelink.Global.equals(direction, str))) {
                                        return true;
                                    }
                                }
                                return false;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(this.getId());
                                builder.append(" ");
                                builder.append(this.getDirection());
                                var num = ((fm.icelink.Global.equals(this.getPayloadTypes(), null)) ? 0 : this.getPayloadTypes().length);
                                var num2 = ((fm.icelink.Global.equals(this.getRestrictions(), null)) ? 0 : this.getRestrictions().length);
                                var strArray = new Array((((fm.icelink.Global.equals(num, 0)) ? 0 : 1) + num2));
                                var num3 = 0;
                                if ((num > 0)) {
                                    var strArray2 = new Array(num);
                                    for (var i = 0; (i < num); i++) {
                                        strArray2[i] = fm.icelink.NumberExtensions.toString(this.getPayloadTypes()[i]);
                                    }
                                    strArray[num3++] = fm.icelink.StringExtensions.format("pt={0}", fm.icelink.StringExtensions.join(",", strArray2));
                                }
                                if ((num2 > 0)) {
                                    for (var _i = 0, _a = this.getRestrictions(); _i < _a.length; _i++) {
                                        var restriction = _a[_i];
                                        if ((fm.icelink.Global.equals(restriction.getValue(), null))) {
                                            strArray[num3++] = restriction.getKey();
                                        }
                                        else {
                                            strArray[num3++] = fm.icelink.StringExtensions.format("{0}={1}", restriction.getKey(), restriction.getValue());
                                        }
                                    }
                                }
                                if ((strArray.length > 0)) {
                                    builder.append(" ");
                                    builder.append(fm.icelink.StringExtensions.join(";", strArray));
                                }
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.getDirection = function () {
                            if (arguments.length == 0) {
                                return this.__direction;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.getId = function () {
                            if (arguments.length == 0) {
                                return this._id;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.getPayloadTypes = function () {
                            if (arguments.length == 0) {
                                return this._payloadTypes;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.getRestrictions = function () {
                            if (arguments.length == 0) {
                                return this._restrictions;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.getRestrictionValue = function (restrictionKey) {
                            if (arguments.length == 1) {
                                if ((!fm.icelink.Global.equals(this.getRestrictions(), null))) {
                                    for (var _i = 0, _a = this.getRestrictions(); _i < _a.length; _i++) {
                                        var restriction = _a[_i];
                                        if ((fm.icelink.Global.equals(restriction.getKey(), restrictionKey))) {
                                            return restriction.getValue();
                                        }
                                    }
                                }
                                return null;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.setDirection = function (value) {
                            if (arguments.length == 1) {
                                if (!this.directionIsValid(value)) {
                                    throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("RID 'direction' cannot be '{0}'.", value));
                                }
                                this.__direction = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.setId = function (value) {
                            if (arguments.length == 1) {
                                this._id = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.setPayloadTypes = function (value) {
                            if (arguments.length == 1) {
                                this._payloadTypes = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        RidAttribute.prototype.setRestrictions = function (value) {
                            if (arguments.length == 1) {
                                this._restrictions = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return RidAttribute;
                    }(fm.icelink.sdp.Attribute));
                    rtp.RidAttribute = RidAttribute;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var SimulcastAttribute =  (function (_super) {
                        __extends(SimulcastAttribute, _super);
                        function SimulcastAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdprtpSimulcastAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SimulcastAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                            }
                            else if (__arguments.length == 1) {
                                var description = __arguments[0];
                                __arguments = new Array(2);
                                __arguments[0] = description;
                                __arguments[1] = null;
                                {
                                    var description1 = __arguments[0];
                                    var description2 = __arguments[1];
                                    __arguments = new Array(0);
                                    {
                                        _this = _super.call(this) || this;
                                        _this.fmicelinksdprtpSimulcastAttributeInit();
                                        _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SimulcastAttribute);
                                        _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                                    }
                                    if ((fm.icelink.Global.equals(description1, null))) {
                                        throw new fm.icelink.Exception("Simulcast attribute 'description1' cannot be null.");
                                    }
                                    if (((!fm.icelink.Global.equals(description2, null)) && (fm.icelink.Global.equals(description1.getDirection(), description2.getDirection())))) {
                                        throw new fm.icelink.Exception("Simulcast attribute 'descriptions' must have different directions.");
                                    }
                                    _this.setDescription1(description1);
                                    _this.setDescription2(description2);
                                }
                            }
                            else if (__arguments.length == 2) {
                                var description1 = __arguments[0];
                                var description2 = __arguments[1];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdprtpSimulcastAttributeInit();
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SimulcastAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                                }
                                if ((fm.icelink.Global.equals(description1, null))) {
                                    throw new fm.icelink.Exception("Simulcast attribute 'description1' cannot be null.");
                                }
                                if (((!fm.icelink.Global.equals(description2, null)) && (fm.icelink.Global.equals(description1.getDirection(), description2.getDirection())))) {
                                    throw new fm.icelink.Exception("Simulcast attribute 'descriptions' must have different directions.");
                                }
                                _this.setDescription1(description1);
                                _this.setDescription2(description2);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        SimulcastAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.SimulcastAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        SimulcastAttribute.prototype.fmicelinksdprtpSimulcastAttributeInit = function () {
                            this._draftVersion = 0;
                        };
                        SimulcastAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var direction = fm.icelink.StringExtensions.substring(value, 0, index);
                                value = value.substring((index + 1));
                                var streams = null;
                                var str2 = null;
                                var streamArray2 = null;
                                index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var draftVersion = -1;
                                if ((fm.icelink.Global.equals(index, -1))) {
                                    var _var0 = new fm.icelink.Holder(draftVersion);
                                    var _var1 = fm.icelink.sdp.rtp.SimulcastAttribute.streamsFromString(value, _var0);
                                    draftVersion = _var0.getValue();
                                    streams = _var1;
                                }
                                else {
                                    var num3 = -1;
                                    var _var2 = new fm.icelink.Holder(num3);
                                    var _var3 = fm.icelink.sdp.rtp.SimulcastAttribute.streamsFromString(fm.icelink.StringExtensions.substring(value, 0, index), _var2);
                                    num3 = _var2.getValue();
                                    streams = _var3;
                                    value = value.substring((index + 1));
                                    index = fm.icelink.StringExtensions.indexOf(value, " ");
                                    str2 = fm.icelink.StringExtensions.substring(value, 0, index);
                                    value = value.substring((index + 1));
                                    var num4 = -1;
                                    var _var4 = new fm.icelink.Holder(num4);
                                    var _var5 = fm.icelink.sdp.rtp.SimulcastAttribute.streamsFromString(value, _var4);
                                    num4 = _var4.getValue();
                                    streamArray2 = _var5;
                                    draftVersion = fm.icelink.MathAssistant.max(num3, num4);
                                }
                                var description = new fm.icelink.sdp.rtp.SimulcastStreamDescription(direction, streams);
                                var description2 = null;
                                if ((!fm.icelink.Global.equals(str2, null))) {
                                    description2 = new fm.icelink.sdp.rtp.SimulcastStreamDescription(str2, streamArray2);
                                }
                                var attribute = new fm.icelink.sdp.rtp.SimulcastAttribute(description, description2);
                                attribute.setDraftVersion(draftVersion);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.streamsFromString = function (streamsString, draftVersion) {
                            if (arguments.length == 2) {
                                draftVersion.setValue(-1);
                                if (fm.icelink.StringExtensions.startsWith(streamsString, "rid=")) {
                                    draftVersion.setValue(3);
                                    streamsString = streamsString.substring(fm.icelink.StringExtensions.getLength("rid="));
                                }
                                else {
                                    if (fm.icelink.StringExtensions.startsWith(streamsString, "pt=")) {
                                        throw new fm.icelink.Exception("Draft version 03 'pt=' parsing is not supported.");
                                    }
                                }
                                var strArray = fm.icelink.StringExtensions.split(streamsString, [59]);
                                var streamArray = new Array(strArray.length);
                                for (var i = 0; (i < streamArray.length); i++) {
                                    var strArray2 = fm.icelink.StringExtensions.split(strArray[i], [44]);
                                    var ids = new Array(strArray2.length);
                                    for (var j = 0; (j < ids.length); j++) {
                                        var idValue = strArray2[j];
                                        if (fm.icelink.StringExtensions.startsWith(idValue, "~")) {
                                            ids[j] = new fm.icelink.sdp.rtp.SimulcastStreamId(idValue.substring(1), true);
                                        }
                                        else {
                                            ids[j] = new fm.icelink.sdp.rtp.SimulcastStreamId(idValue);
                                        }
                                    }
                                    streamArray[i] = new fm.icelink.sdp.rtp.SimulcastStream(ids);
                                }
                                return streamArray;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.streamsToString = function (streams, draftVersion) {
                            if (arguments.length == 2) {
                                draftVersion = fm.icelink.Global.toInt(arguments[1]);
                                var strArray = new Array(streams.length);
                                for (var i = 0; (i < strArray.length); i++) {
                                    var stream = streams[i];
                                    var strArray2 = new Array(stream.getIds().length);
                                    for (var j = 0; (j < strArray2.length); j++) {
                                        var idValue = stream.getIds()[j];
                                        if (idValue.getPaused()) {
                                            strArray2[j] = fm.icelink.StringExtensions.format("~{0}", idValue.getId());
                                        }
                                        else {
                                            strArray2[j] = idValue.getId();
                                        }
                                    }
                                    strArray[i] = fm.icelink.StringExtensions.join(",", strArray2);
                                }
                                var str = fm.icelink.StringExtensions.join(";", strArray);
                                if (((fm.icelink.Global.equals(draftVersion, 2)) || (fm.icelink.Global.equals(draftVersion, 3)))) {
                                    str = fm.icelink.StringExtensions.concat("rid=", str);
                                }
                                return str;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(this.getDescription1().getDirection());
                                builder.append(" ");
                                builder.append(fm.icelink.sdp.rtp.SimulcastAttribute.streamsToString(this.getDescription1().getStreams(), this.getDraftVersion()));
                                if ((!fm.icelink.Global.equals(this.getDescription2(), null))) {
                                    builder.append(" ");
                                    builder.append(this.getDescription2().getDirection());
                                    builder.append(" ");
                                    builder.append(fm.icelink.sdp.rtp.SimulcastAttribute.streamsToString(this.getDescription2().getStreams(), this.getDraftVersion()));
                                }
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.prototype.getDescription = function (direction) {
                            if (arguments.length == 1) {
                                if (((!fm.icelink.Global.equals(this.getDescription1(), null)) && (fm.icelink.Global.equals(this.getDescription1().getDirection(), direction)))) {
                                    return this.getDescription1();
                                }
                                if (((!fm.icelink.Global.equals(this.getDescription2(), null)) && (fm.icelink.Global.equals(this.getDescription2().getDirection(), direction)))) {
                                    return this.getDescription2();
                                }
                                return null;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.prototype.getDescription1 = function () {
                            if (arguments.length == 0) {
                                return this._description1;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.prototype.getDescription2 = function () {
                            if (arguments.length == 0) {
                                return this._description2;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.prototype.getDraftVersion = function () {
                            if (arguments.length == 0) {
                                return this._draftVersion;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.prototype.getReceiveDescription = function () {
                            if (arguments.length == 0) {
                                return this.getDescription(fm.icelink.sdp.rtp.SimulcastDirection.getReceive());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.prototype.getSendDescription = function () {
                            if (arguments.length == 0) {
                                return this.getDescription(fm.icelink.sdp.rtp.SimulcastDirection.getSend());
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.prototype.setDescription1 = function (value) {
                            if (arguments.length == 1) {
                                this._description1 = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.prototype.setDescription2 = function (value) {
                            if (arguments.length == 1) {
                                this._description2 = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastAttribute.prototype.setDraftVersion = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._draftVersion = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return SimulcastAttribute;
                    }(fm.icelink.sdp.Attribute));
                    rtp.SimulcastAttribute = SimulcastAttribute;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var SimulcastStreamId =  (function () {
                        function SimulcastStreamId() {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 1) {
                                var idValue = __arguments[0];
                                __arguments = new Array(2);
                                __arguments[0] = idValue;
                                __arguments[1] = false;
                                {
                                    var idValue_8 = __arguments[0];
                                    var paused = __arguments[1];
                                    this.fmicelinksdprtpSimulcastStreamIdInit();
                                    if ((fm.icelink.Global.equals(idValue_8, null))) {
                                        throw new fm.icelink.Exception("Simulcast stream 'ID' cannot be null.");
                                    }
                                    this.setId(idValue_8);
                                    this.setPaused(paused);
                                }
                            }
                            else if (__arguments.length == 2) {
                                var idValue = __arguments[0];
                                var paused = __arguments[1];
                                this.fmicelinksdprtpSimulcastStreamIdInit();
                                if ((fm.icelink.Global.equals(idValue, null))) {
                                    throw new fm.icelink.Exception("Simulcast stream 'ID' cannot be null.");
                                }
                                this.setId(idValue);
                                this.setPaused(paused);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        SimulcastStreamId.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.SimulcastStreamId]';
                        };
                        SimulcastStreamId.prototype.fmicelinksdprtpSimulcastStreamIdInit = function () {
                            this._paused = false;
                        };
                        SimulcastStreamId.prototype.getId = function () {
                            if (arguments.length == 0) {
                                return this._id;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastStreamId.prototype.getPaused = function () {
                            if (arguments.length == 0) {
                                return this._paused;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastStreamId.prototype.setId = function (value) {
                            if (arguments.length == 1) {
                                this._id = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SimulcastStreamId.prototype.setPaused = function (value) {
                            if (arguments.length == 1) {
                                this._paused = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return SimulcastStreamId;
                    }());
                    rtp.SimulcastStreamId = SimulcastStreamId;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var SsrcGroupAttribute =  (function (_super) {
                        __extends(SsrcGroupAttribute, _super);
                        function SsrcGroupAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpSsrcGroupAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                            }
                            else if (__arguments.length == 2) {
                                var semantics = __arguments[0];
                                var synchronizationSources = __arguments[1];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpSsrcGroupAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                                }
                                if (fm.icelink.StringExtensions.isNullOrEmpty(semantics)) {
                                    throw new fm.icelink.Exception("semantics cannot be null.");
                                }
                                if ((fm.icelink.Global.equals(synchronizationSources, null))) {
                                    throw new fm.icelink.Exception("synchronizationSources cannot be null.");
                                }
                                _this.setSemantics(semantics);
                                _this.setSynchronizationSources(synchronizationSources);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        SsrcGroupAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.SsrcGroupAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        SsrcGroupAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var str = fm.icelink.StringExtensions.substring(value, 0, index);
                                value = value.substring((index + 1));
                                var strArray = fm.icelink.StringExtensions.split(value, [32]);
                                var numArray = new Array(strArray.length);
                                for (var i = 0; (i < numArray.length); i++) {
                                    numArray[i] = fm.icelink.ParseAssistant.parseLongValue(strArray[i]);
                                }
                                var attribute = new fm.icelink.sdp.rtp.SsrcGroupAttribute();
                                attribute.setSemantics(str);
                                attribute.setSynchronizationSources(numArray);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcGroupAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(this.getSemantics());
                                for (var _i = 0, _a = this.getSynchronizationSources(); _i < _a.length; _i++) {
                                    var num = _a[_i];
                                    builder.append(" ");
                                    builder.append(fm.icelink.NumberExtensions.toString(num));
                                }
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcGroupAttribute.prototype.getSemantics = function () {
                            if (arguments.length == 0) {
                                return this._semantics;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcGroupAttribute.prototype.getSynchronizationSources = function () {
                            if (arguments.length == 0) {
                                return this._synchronizationSources;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcGroupAttribute.prototype.setSemantics = function (value) {
                            if (arguments.length == 1) {
                                this._semantics = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcGroupAttribute.prototype.setSynchronizationSources = function (value) {
                            if (arguments.length == 1) {
                                this._synchronizationSources = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return SsrcGroupAttribute;
                    }(fm.icelink.sdp.Attribute));
                    rtp.SsrcGroupAttribute = SsrcGroupAttribute;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var SsrcAttribute =  (function (_super) {
                        __extends(SsrcAttribute, _super);
                        function SsrcAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdprtpSsrcAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpSsrcAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                            }
                            else if (__arguments.length == 2) {
                                var synchronizationSource = __arguments[0];
                                var attributeName = __arguments[1];
                                __arguments = new Array(3);
                                __arguments[0] = synchronizationSource;
                                __arguments[1] = attributeName;
                                __arguments[2] = null;
                                {
                                    var synchronizationSource_1 = __arguments[0];
                                    var attributeName_1 = __arguments[1];
                                    var attributeValue = __arguments[2];
                                    __arguments = new Array(0);
                                    {
                                        _this = _super.call(this) || this;
                                        _this.fmicelinksdprtpSsrcAttributeInit();
                                        _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpSsrcAttribute);
                                        _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                                    }
                                    if (fm.icelink.StringExtensions.isNullOrEmpty(attributeName_1)) {
                                        throw new fm.icelink.Exception("attributeName cannot be null.");
                                    }
                                    _this.setSynchronizationSource(synchronizationSource_1);
                                    _this.setName(attributeName_1);
                                    _this.setValue(attributeValue);
                                }
                            }
                            else if (__arguments.length == 3) {
                                var synchronizationSource = __arguments[0];
                                var attributeName = __arguments[1];
                                var attributeValue = __arguments[2];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdprtpSsrcAttributeInit();
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.RtpSsrcAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                                }
                                if (fm.icelink.StringExtensions.isNullOrEmpty(attributeName)) {
                                    throw new fm.icelink.Exception("attributeName cannot be null.");
                                }
                                _this.setSynchronizationSource(synchronizationSource);
                                _this.setName(attributeName);
                                _this.setValue(attributeValue);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        SsrcAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.SsrcAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        SsrcAttribute.prototype.fmicelinksdprtpSsrcAttributeInit = function () {
                            this._synchronizationSource = 0;
                        };
                        SsrcAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var index = fm.icelink.StringExtensions.indexOf(value, " ");
                                var num2 = fm.icelink.ParseAssistant.parseLongValue(fm.icelink.StringExtensions.substring(value, 0, index));
                                value = value.substring((index + 1));
                                var length_47 = fm.icelink.StringExtensions.indexOf(value, ":");
                                var str = null;
                                var str2 = null;
                                if ((fm.icelink.Global.equals(length_47, -1))) {
                                    str = value;
                                }
                                else {
                                    str = fm.icelink.StringExtensions.substring(value, 0, length_47);
                                    value = value.substring((length_47 + 1));
                                    str2 = value;
                                }
                                var attribute = new fm.icelink.sdp.rtp.SsrcAttribute();
                                attribute.setSynchronizationSource(num2);
                                attribute.setName(str);
                                attribute.setValue(str2);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(fm.icelink.NumberExtensions.toString(this.getSynchronizationSource()));
                                builder.append(" ");
                                builder.append(this.getName());
                                if (!fm.icelink.StringExtensions.isNullOrEmpty(this.getValue())) {
                                    builder.append(":");
                                    builder.append(this.getValue());
                                }
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttribute.prototype.getName = function () {
                            if (arguments.length == 0) {
                                return this._name;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttribute.prototype.getSynchronizationSource = function () {
                            if (arguments.length == 0) {
                                return this._synchronizationSource;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttribute.prototype.getValue = function () {
                            if (arguments.length == 0) {
                                return this._value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttribute.prototype.setName = function (value) {
                            if (arguments.length == 1) {
                                this._name = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttribute.prototype.setSynchronizationSource = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._synchronizationSource = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttribute.prototype.setValue = function (value) {
                            if (arguments.length == 1) {
                                this._value = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return SsrcAttribute;
                    }(fm.icelink.sdp.Attribute));
                    rtp.SsrcAttribute = SsrcAttribute;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    var SsrcAttributeName =  (function () {
                        function SsrcAttributeName() {
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) ;
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                        }
                        SsrcAttributeName.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.rtp.SsrcAttributeName]';
                        };
                        SsrcAttributeName.getCName = function () {
                            if (arguments.length == 0) {
                                return "cname";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttributeName.getFormatParameters = function () {
                            if (arguments.length == 0) {
                                return "fmtp";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttributeName.getLabel = function () {
                            if (arguments.length == 0) {
                                return "label";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttributeName.getMediaStreamId = function () {
                            if (arguments.length == 0) {
                                return "msid";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttributeName.getMediaStreamLabel = function () {
                            if (arguments.length == 0) {
                                return "mslabel";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        SsrcAttributeName.getPreviousSsrc = function () {
                            if (arguments.length == 0) {
                                return "previous-ssrc";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return SsrcAttributeName;
                    }());
                    rtp.SsrcAttributeName = SsrcAttributeName;
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (sctp) {
                    var MapAttribute =  (function (_super) {
                        __extends(MapAttribute, _super);
                        function MapAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdpsctpMapAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SctpMapAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Caution);
                            }
                            else if (__arguments.length == 3) {
                                var port = __arguments[0];
                                var protocol = __arguments[1];
                                var streams = __arguments[2];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdpsctpMapAttributeInit();
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SctpMapAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Caution);
                                }
                                _this.setPort(port);
                                _this.setSctpProtocol(protocol);
                                _this.setStreams(streams);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        MapAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.sctp.MapAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        MapAttribute.prototype.fmicelinksdpsctpMapAttributeInit = function () {
                            this._port = 0;
                            this._streams = 0;
                        };
                        MapAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var strArray = fm.icelink.StringExtensions.split(value, [32]);
                                var num = fm.icelink.ParseAssistant.parseIntegerValue(strArray[0]);
                                var str = strArray[1];
                                var num2 = ((strArray.length > 2) ? fm.icelink.ParseAssistant.parseIntegerValue(strArray[2]) : 16);
                                var attribute = new fm.icelink.sdp.sctp.MapAttribute();
                                attribute.setPort(num);
                                attribute.setSctpProtocol(str);
                                attribute.setStreams(num2);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(fm.icelink.NumberExtensions.toString(this.getPort()));
                                builder.append(" ");
                                builder.append(this.getSctpProtocol());
                                builder.append(" ");
                                builder.append(fm.icelink.NumberExtensions.toString(this.getStreams()));
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getPort = function () {
                            if (arguments.length == 0) {
                                return this._port;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getSctpProtocol = function () {
                            if (arguments.length == 0) {
                                return this._sctpProtocol;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.getStreams = function () {
                            if (arguments.length == 0) {
                                return this._streams;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.setPort = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._port = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.setSctpProtocol = function (value) {
                            if (arguments.length == 1) {
                                this._sctpProtocol = value;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MapAttribute.prototype.setStreams = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._streams = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return MapAttribute;
                    }(fm.icelink.sdp.Attribute));
                    sctp.MapAttribute = MapAttribute;
                })(sdp.sctp || (sdp.sctp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (sctp) {
                    var MaxMessageSizeAttribute =  (function (_super) {
                        __extends(MaxMessageSizeAttribute, _super);
                        function MaxMessageSizeAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdpsctpMaxMessageSizeAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SctpMaxMessageSizeAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Caution);
                            }
                            else if (__arguments.length == 1) {
                                var maxMessageSize = __arguments[0];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdpsctpMaxMessageSizeAttributeInit();
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SctpMaxMessageSizeAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Caution);
                                }
                                _this.setMaxMessageSize(maxMessageSize);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        MaxMessageSizeAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.sctp.MaxMessageSizeAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        MaxMessageSizeAttribute.prototype.fmicelinksdpsctpMaxMessageSizeAttributeInit = function () {
                            this._maxMessageSize = 0;
                        };
                        MaxMessageSizeAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var num = fm.icelink.ParseAssistant.parseLongValue(value);
                                var attribute = new fm.icelink.sdp.sctp.MaxMessageSizeAttribute();
                                attribute.setMaxMessageSize(num);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MaxMessageSizeAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(fm.icelink.NumberExtensions.toString(this.getMaxMessageSize()));
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MaxMessageSizeAttribute.prototype.getMaxMessageSize = function () {
                            if (arguments.length == 0) {
                                return this._maxMessageSize;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        MaxMessageSizeAttribute.prototype.setMaxMessageSize = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._maxMessageSize = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return MaxMessageSizeAttribute;
                    }(fm.icelink.sdp.Attribute));
                    sctp.MaxMessageSizeAttribute = MaxMessageSizeAttribute;
                })(sdp.sctp || (sdp.sctp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (sctp) {
                    var Media =  (function (_super) {
                        __extends(Media, _super);
                        function Media(mediaType, transportPort, transportProtocol, associationUsage) {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 4) {
                                var mediaType_3 = __arguments[0];
                                var transportPort_3 = __arguments[1];
                                var transportProtocol_3 = __arguments[2];
                                var associationUsage_1 = __arguments[3];
                                _this = _super.call(this, mediaType_3, transportPort_3, transportProtocol_3) || this;
                                if ((fm.icelink.Global.equals(associationUsage_1, null))) {
                                    throw new fm.icelink.Exception("associationUsage cannot be null.");
                                }
                                _super.prototype.setFormatDescription.call(_this, associationUsage_1);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        Media.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.sctp.Media]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        Media.getDtlsSctpTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "DTLS/SCTP";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getSctpDtlsTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "SCTP/DTLS";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getSctpTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "SCTP";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getTcpDtlsSctpTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "TCP/DTLS/SCTP";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getUdpDtlsSctpTransportProtocol = function () {
                            if (arguments.length == 0) {
                                return "UDP/DTLS/SCTP";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.getWebRtcDatachannelAssociationUsage = function () {
                            if (arguments.length == 0) {
                                return "webrtc-datachannel";
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.isSupported = function (protocol) {
                            if (arguments.length == 1) {
                                return ((((fm.icelink.Global.equals(protocol, fm.icelink.sdp.sctp.Media.getSctpTransportProtocol())) || (fm.icelink.Global.equals(protocol, fm.icelink.sdp.sctp.Media.getSctpDtlsTransportProtocol()))) || ((fm.icelink.Global.equals(protocol, fm.icelink.sdp.sctp.Media.getDtlsSctpTransportProtocol())) || (fm.icelink.Global.equals(protocol, fm.icelink.sdp.sctp.Media.getUdpDtlsSctpTransportProtocol())))) || (fm.icelink.Global.equals(protocol, fm.icelink.sdp.sctp.Media.getTcpDtlsSctpTransportProtocol())));
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        Media.supportsEncryption = function (protocol) {
                            if (arguments.length == 1) {
                                return (((fm.icelink.Global.equals(protocol, fm.icelink.sdp.sctp.Media.getUdpDtlsSctpTransportProtocol())) || (fm.icelink.Global.equals(protocol, fm.icelink.sdp.sctp.Media.getDtlsSctpTransportProtocol()))) || (fm.icelink.Global.equals(protocol, fm.icelink.sdp.sctp.Media.getTcpDtlsSctpTransportProtocol())));
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return Media;
                    }(fm.icelink.sdp.Media));
                    sctp.Media = Media;
                })(sdp.sctp || (sdp.sctp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (sctp) {
                    var PortAttribute =  (function (_super) {
                        __extends(PortAttribute, _super);
                        function PortAttribute() {
                            var _this = this;
                            var __arguments = new Array(arguments.length);
                            for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                                __arguments[__argumentIndex] = arguments[__argumentIndex];
                            }
                            if (__arguments.length == 0) {
                                _this = _super.call(this) || this;
                                _this.fmicelinksdpsctpPortAttributeInit();
                                _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SctpPortAttribute);
                                _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Caution);
                            }
                            else if (__arguments.length == 1) {
                                var port = __arguments[0];
                                __arguments = new Array(0);
                                {
                                    _this = _super.call(this) || this;
                                    _this.fmicelinksdpsctpPortAttributeInit();
                                    _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SctpPortAttribute);
                                    _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Caution);
                                }
                                _this.setPort(port);
                            }
                            else {
                                throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                            }
                            return _this;
                        }
                        PortAttribute.prototype.getTypeString = function () {
                            return '[fm.icelink.sdp.sctp.PortAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                        };
                        PortAttribute.prototype.fmicelinksdpsctpPortAttributeInit = function () {
                            this._port = 0;
                        };
                        PortAttribute.fromAttributeValue = function (value) {
                            if (arguments.length == 1) {
                                var num = fm.icelink.ParseAssistant.parseIntegerValue(value);
                                var attribute = new fm.icelink.sdp.sctp.PortAttribute();
                                attribute.setPort(num);
                                return attribute;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        PortAttribute.prototype.getAttributeValue = function () {
                            if (arguments.length == 0) {
                                var builder = new fm.icelink.StringBuilder();
                                builder.append(fm.icelink.NumberExtensions.toString(this.getPort()));
                                return builder.toString();
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        PortAttribute.prototype.getPort = function () {
                            if (arguments.length == 0) {
                                return this._port;
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        PortAttribute.prototype.setPort = function (value) {
                            if (arguments.length == 1) {
                                value = fm.icelink.Global.toInt(arguments[0]);
                                this._port = fm.icelink.Global.toInt(value);
                            }
                            else {
                                throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                            }
                        };
                        return PortAttribute;
                    }(fm.icelink.sdp.Attribute));
                    sctp.PortAttribute = PortAttribute;
                })(sdp.sctp || (sdp.sctp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var SdpLanguageAttribute =  (function (_super) {
                    __extends(SdpLanguageAttribute, _super);
                    function SdpLanguageAttribute(languageTag) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var languageTag_2 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SdpLanguageAttribute);
                            if ((fm.icelink.Global.equals(languageTag_2, null))) {
                                throw new fm.icelink.Exception("languageTag cannot be null.");
                            }
                            _this.setLanguageTag(languageTag_2);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    SdpLanguageAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.SdpLanguageAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    SdpLanguageAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.SdpLanguageAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    SdpLanguageAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getLanguageTag();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    SdpLanguageAttribute.prototype.getLanguageTag = function () {
                        if (arguments.length == 0) {
                            return this._languageTag;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    SdpLanguageAttribute.prototype.setLanguageTag = function (value) {
                        if (arguments.length == 1) {
                            this._languageTag = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return SdpLanguageAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.SdpLanguageAttribute = SdpLanguageAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var SendOnlyAttribute =  (function (_super) {
                    __extends(SendOnlyAttribute, _super);
                    function SendOnlyAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.DirectionAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    SendOnlyAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.SendOnlyAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    SendOnlyAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.SendOnlyAttribute();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    SendOnlyAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    SendOnlyAttribute.prototype.getStreamDirection = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.StreamDirection.SendOnly;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return SendOnlyAttribute;
                }(fm.icelink.sdp.DirectionAttribute));
                sdp.SendOnlyAttribute = SendOnlyAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var SendReceiveAttribute =  (function (_super) {
                    __extends(SendReceiveAttribute, _super);
                    function SendReceiveAttribute() {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.DirectionAttribute);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    SendReceiveAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.SendReceiveAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    SendReceiveAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.SendReceiveAttribute();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    SendReceiveAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return null;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    SendReceiveAttribute.prototype.getStreamDirection = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.StreamDirection.SendReceive;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return SendReceiveAttribute;
                }(fm.icelink.sdp.DirectionAttribute));
                sdp.SendReceiveAttribute = SendReceiveAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var Setup =  (function () {
                    function Setup() {
                    }
                    Setup.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.Setup]';
                    };
                    Setup.getActive = function () {
                        if (arguments.length == 0) {
                            return "active";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Setup.getActPass = function () {
                        if (arguments.length == 0) {
                            return "actpass";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Setup.getPassive = function () {
                        if (arguments.length == 0) {
                            return "passive";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Setup;
                }());
                sdp.Setup = Setup;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var SetupAttribute =  (function (_super) {
                    __extends(SetupAttribute, _super);
                    function SetupAttribute(setup) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var setup_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.SetupAttribute);
                            _this.setSetup(setup_1);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Transport);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    SetupAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.SetupAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    SetupAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.SetupAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    SetupAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getSetup();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    SetupAttribute.prototype.getSetup = function () {
                        if (arguments.length == 0) {
                            return this._setup;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    SetupAttribute.prototype.setSetup = function (value) {
                        if (arguments.length == 1) {
                            this._setup = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return SetupAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.SetupAttribute = SetupAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var TimeDescription =  (function () {
                    function TimeDescription(timing) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var timing_1 = __arguments[0];
                            this.__repeatTimes = new Array();
                            if ((fm.icelink.Global.equals(timing_1, null))) {
                                throw new fm.icelink.Exception("timing cannot be null.");
                            }
                            this.setTiming(timing_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    TimeDescription.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.TimeDescription]';
                    };
                    TimeDescription.parse = function (s) {
                        if (arguments.length == 1) {
                            var strArray = fm.icelink.sdp.Utility.splitAndClean(s);
                            if ((!fm.icelink.Global.equals(strArray[0].charCodeAt(0), 116))) {
                                return null;
                            }
                            var description = new fm.icelink.sdp.TimeDescription(fm.icelink.sdp.Timing.parse(strArray[0]));
                            for (var i = 1; (i < strArray.length); i++) {
                                var str = strArray[i];
                                if ((fm.icelink.Global.equals(str.charCodeAt(0), 114))) {
                                    description.addRepeatTime(fm.icelink.sdp.RepeatTime.parse(str));
                                }
                            }
                            return description;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeDescription.prototype.addRepeatTime = function (repeatTime) {
                        if (arguments.length == 1) {
                            fm.icelink.ArrayExtensions.add(this.__repeatTimes, repeatTime);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeDescription.prototype.getRepeatTimes = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.ArrayExtensions.toArray(this.__repeatTimes);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeDescription.prototype.getTiming = function () {
                        if (arguments.length == 0) {
                            return this._timing;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeDescription.prototype.removeRepeatTime = function (repeatTime) {
                        if (arguments.length == 1) {
                            return fm.icelink.ArrayExtensions.remove(this.__repeatTimes, repeatTime);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeDescription.prototype.setTiming = function (value) {
                        if (arguments.length == 1) {
                            this._timing = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeDescription.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append(fm.icelink.StringExtensions.concat(this.getTiming().toString(), "\r\n"));
                            for (var _i = 0, _a = this.getRepeatTimes(); _i < _a.length; _i++) {
                                var time = _a[_i];
                                builder.append(fm.icelink.StringExtensions.concat(time.toString(), "\r\n"));
                            }
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return TimeDescription;
                }());
                sdp.TimeDescription = TimeDescription;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var TimeZone =  (function () {
                    function TimeZone(adjustmentTime, offset) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 2) {
                            var adjustmentTime_1 = __arguments[0];
                            var offset_1 = __arguments[1];
                            this.fmicelinksdpTimeZoneInit();
                            this.setAdjustmentTime(adjustmentTime_1);
                            this.setOffset(offset_1);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    TimeZone.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.TimeZone]';
                    };
                    TimeZone.prototype.fmicelinksdpTimeZoneInit = function () {
                        this._adjustmentTime = 0;
                    };
                    TimeZone.parse = function (s) {
                        if (arguments.length == 1) {
                            var strArray = fm.icelink.StringExtensions.split(s, [32]);
                            var adjustmentTime = fm.icelink.ParseAssistant.parseDoubleValue(strArray[0]);
                            return new fm.icelink.sdp.TimeZone(adjustmentTime, new fm.icelink.TimeSpan(0, 0, fm.icelink.ParseAssistant.parseIntegerValue(strArray[1])));
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeZone.prototype.getAdjustmentTime = function () {
                        if (arguments.length == 0) {
                            return this._adjustmentTime;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeZone.prototype.getOffset = function () {
                        if (arguments.length == 0) {
                            return this._offset;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeZone.prototype.setAdjustmentTime = function (value) {
                        if (arguments.length == 1) {
                            this._adjustmentTime = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeZone.prototype.setOffset = function (value) {
                        if (arguments.length == 1) {
                            this._offset = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeZone.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append(fm.icelink.NumberExtensions.toString(this.getAdjustmentTime()));
                            builder.append(" ");
                            builder.append(fm.icelink.NumberExtensions.toString(this.getOffset().getTotalSeconds()));
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return TimeZone;
                }());
                sdp.TimeZone = TimeZone;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var TimeZones =  (function () {
                    function TimeZones(values) {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var values_5 = __arguments[0];
                            this.__values = new Array();
                            if ((fm.icelink.Global.equals(values_5, null))) {
                                throw new fm.icelink.Exception("timeZones cannot be null.");
                            }
                            fm.icelink.ArrayExtensions.addRange(this.__values, values_5);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    TimeZones.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.TimeZones]';
                    };
                    TimeZones.parse = function (s) {
                        if (arguments.length == 1) {
                            s = s.substring(2);
                            var array = fm.icelink.StringExtensions.split(s, [32]);
                            var zones = new fm.icelink.sdp.TimeZones([fm.icelink.sdp.TimeZone.parse(fm.icelink.StringExtensions.join(" ", fm.icelink.StringAssistant.subArray(array, 0, 2)))]);
                            for (var i = 2; (i < array.length); i = (i + 2)) {
                                zones.addTimeZone(fm.icelink.sdp.TimeZone.parse(fm.icelink.StringExtensions.join(" ", fm.icelink.StringAssistant.subArray(array, i, 2))));
                            }
                            return zones;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeZones.prototype.addTimeZone = function (value) {
                        if (arguments.length == 1) {
                            fm.icelink.ArrayExtensions.add(this.__values, value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeZones.prototype.getValues = function () {
                        if (arguments.length == 0) {
                            return fm.icelink.ArrayExtensions.toArray(this.__values);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeZones.prototype.removeTimeZone = function (value) {
                        if (arguments.length == 1) {
                            return fm.icelink.ArrayExtensions.remove(this.__values, value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    TimeZones.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append("z=");
                            for (var _i = 0, _a = this.getValues(); _i < _a.length; _i++) {
                                var zone = _a[_i];
                                builder.append(" ");
                                builder.append(zone.toString());
                            }
                            return fm.icelink.StringExtensions.trim(builder.toString());
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return TimeZones;
                }());
                sdp.TimeZones = TimeZones;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var Timing =  (function () {
                    function Timing() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) {
                            this.fmicelinksdpTimingInit();
                            this.setStartTime(0);
                            this.setStopTime(0);
                        }
                        else if (__arguments.length == 2) {
                            var startTime = __arguments[0];
                            var stopTime = __arguments[1];
                            this.fmicelinksdpTimingInit();
                            this.setStartTime(startTime);
                            this.setStopTime(stopTime);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    Timing.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.Timing]';
                    };
                    Timing.prototype.fmicelinksdpTimingInit = function () {
                        this._startTime = 0;
                        this._stopTime = 0;
                    };
                    Timing.parse = function (s) {
                        if (arguments.length == 1) {
                            s = s.substring(2);
                            var strArray = fm.icelink.StringExtensions.split(s, [32]);
                            var num = 0;
                            if ((!fm.icelink.Global.equals(strArray[0], "0"))) {
                                num = fm.icelink.ParseAssistant.parseDoubleValue(strArray[0]);
                            }
                            var num2 = 0;
                            if ((!fm.icelink.Global.equals(strArray[1], "0"))) {
                                num2 = fm.icelink.ParseAssistant.parseDoubleValue(strArray[1]);
                            }
                            var timing = new fm.icelink.sdp.Timing();
                            timing.setStartTime(num);
                            timing.setStopTime(num2);
                            return timing;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Timing.prototype.getStartTime = function () {
                        if (arguments.length == 0) {
                            return this._startTime;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Timing.prototype.getStopTime = function () {
                        if (arguments.length == 0) {
                            return this._stopTime;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Timing.prototype.setStartTime = function (value) {
                        if (arguments.length == 1) {
                            this._startTime = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Timing.prototype.setStopTime = function (value) {
                        if (arguments.length == 1) {
                            this._stopTime = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    Timing.prototype.toString = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append("t=");
                            if ((!fm.icelink.Global.equals(this.getStartTime(), 0))) {
                                builder.append(fm.icelink.NumberExtensions.toString(this.getStartTime()));
                            }
                            else {
                                builder.append("0");
                            }
                            builder.append(" ");
                            if ((!fm.icelink.Global.equals(this.getStopTime(), 0))) {
                                builder.append(fm.icelink.NumberExtensions.toString(this.getStopTime()));
                            }
                            else {
                                builder.append("0");
                            }
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Timing;
                }());
                sdp.Timing = Timing;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var ToolAttribute =  (function (_super) {
                    __extends(ToolAttribute, _super);
                    function ToolAttribute(tool) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var tool_1 = __arguments[0];
                            _this = _super.call(this) || this;
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.ToolAttribute);
                            if ((fm.icelink.Global.equals(tool_1, null))) {
                                throw new fm.icelink.Exception("tool cannot be null.");
                            }
                            _this.setTool(tool_1);
                            _super.prototype.setMultiplexingCategory.call(_this, fm.icelink.sdp.AttributeCategory.Normal);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    ToolAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.ToolAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    ToolAttribute.fromAttributeValue = function (value) {
                        if (arguments.length == 1) {
                            return new fm.icelink.sdp.ToolAttribute(value);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ToolAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getTool();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ToolAttribute.prototype.getTool = function () {
                        if (arguments.length == 0) {
                            return this._tool;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    ToolAttribute.prototype.setTool = function (value) {
                        if (arguments.length == 1) {
                            this._tool = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return ToolAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.ToolAttribute = ToolAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var UdpMedia =  (function (_super) {
                    __extends(UdpMedia, _super);
                    function UdpMedia(mediaType, transportPort, formatDescription) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 3) {
                            var mediaType_4 = __arguments[0];
                            var transportPort_4 = __arguments[1];
                            var formatDescription_1 = __arguments[2];
                            _this = _super.call(this, mediaType_4, transportPort_4, fm.icelink.sdp.UdpMedia.getUdpTransportProtocol(), formatDescription_1) || this;
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    UdpMedia.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.UdpMedia]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    UdpMedia.getUdpTransportProtocol = function () {
                        if (arguments.length == 0) {
                            return "udp";
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return UdpMedia;
                }(fm.icelink.sdp.Media));
                sdp.UdpMedia = UdpMedia;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var UnknownAttribute =  (function (_super) {
                    __extends(UnknownAttribute, _super);
                    function UnknownAttribute(name, value) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 2) {
                            var name_33 = __arguments[0];
                            var value_59 = __arguments[1];
                            _this = _super.call(this) || this;
                            _this.setName(name_33);
                            _this.setValue(value_59);
                            _super.prototype.setAttributeType.call(_this, fm.icelink.sdp.AttributeType.UnknownAttribute);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    UnknownAttribute.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.UnknownAttribute]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    UnknownAttribute.prototype.getAttributeValue = function () {
                        if (arguments.length == 0) {
                            return this.getValue();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UnknownAttribute.prototype.getName = function () {
                        if (arguments.length == 0) {
                            return this._name;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UnknownAttribute.prototype.getValue = function () {
                        if (arguments.length == 0) {
                            return this._value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UnknownAttribute.prototype.setName = function (value) {
                        if (arguments.length == 1) {
                            this._name = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UnknownAttribute.prototype.setValue = function (value) {
                        if (arguments.length == 1) {
                            this._value = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return UnknownAttribute;
                }(fm.icelink.sdp.Attribute));
                sdp.UnknownAttribute = UnknownAttribute;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var UriEncryptionKey =  (function (_super) {
                    __extends(UriEncryptionKey, _super);
                    function UriEncryptionKey(uri) {
                        var _this = this;
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 1) {
                            var uri_2 = __arguments[0];
                            _this = _super.call(this) || this;
                            if ((fm.icelink.Global.equals(uri_2, null))) {
                                throw new fm.icelink.Exception("uri cannot be null.");
                            }
                            _this.setUri(uri_2);
                        }
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                        return _this;
                    }
                    UriEncryptionKey.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.UriEncryptionKey]' + ',' + _super.prototype.getTypeString.call(this);
                    };
                    UriEncryptionKey.prototype.getMethodAndValue = function () {
                        if (arguments.length == 0) {
                            var builder = new fm.icelink.StringBuilder();
                            builder.append("uri:");
                            builder.append(this.getUri().toString());
                            return builder.toString();
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UriEncryptionKey.prototype.getUri = function () {
                        if (arguments.length == 0) {
                            return this._uri;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    UriEncryptionKey.prototype.setUri = function (value) {
                        if (arguments.length == 1) {
                            this._uri = value;
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return UriEncryptionKey;
                }(fm.icelink.sdp.EncryptionKey));
                sdp.UriEncryptionKey = UriEncryptionKey;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                var Utility =  (function () {
                    function Utility() {
                        var __arguments = new Array(arguments.length);
                        for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                            __arguments[__argumentIndex] = arguments[__argumentIndex];
                        }
                        if (__arguments.length == 0) ;
                        else {
                            throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                        }
                    }
                    Utility.prototype.getTypeString = function () {
                        return '[fm.icelink.sdp.Utility]';
                    };
                    Utility.splitAndClean = function (s) {
                        if (arguments.length == 1) {
                            var list = fm.icelink.ArrayExtensions.newArray(fm.icelink.StringExtensions.split(s, [10]));
                            for (var i = 0; (i < fm.icelink.ArrayExtensions.getCount(list)); i++) {
                                list[i] = fm.icelink.StringExtensions.trim(list[i]);
                                if (fm.icelink.StringExtensions.isNullOrEmpty(list[i])) {
                                    fm.icelink.ArrayExtensions.removeAt(list, i);
                                    i--;
                                }
                            }
                            return fm.icelink.ArrayExtensions.toArray(list);
                        }
                        else {
                            throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                        }
                    };
                    return Utility;
                }());
                sdp.Utility = Utility;
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SessionDescription =  (function () {
                function SessionDescription() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkSessionDescriptionInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SessionDescription.prototype.getTypeString = function () {
                    return '[fm.icelink.SessionDescription]';
                };
                SessionDescription.prototype.fmicelinkSessionDescriptionInit = function () {
                    this._renegotiation = false;
                };
                SessionDescription.fromJson = function (sessionDescriptionJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(sessionDescriptionJson, function () {
                            return new fm.icelink.SessionDescription();
                        }, function (sessionDescription, name, valueJson) {
                            var str = name;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "sdpMessage"))) {
                                    if ((fm.icelink.Global.equals(str, "tieBreaker"))) {
                                        sessionDescription.setTieBreaker(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "isOffer"))) {
                                            sessionDescription.setType(((fm.icelink.Global.equals(fm.icelink.JsonSerializer.deserializeBoolean(valueJson), true)) ? fm.icelink.SessionDescriptionType.Offer : fm.icelink.SessionDescriptionType.Answer));
                                        }
                                    }
                                }
                                else {
                                    sessionDescription.setSdpMessage(fm.icelink.sdp.Message.parse(fm.icelink.JsonSerializer.deserializeString(valueJson)));
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.toJson = function (sessionDescription) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(sessionDescription, function (sd, jsonObject) {
                            if ((!fm.icelink.Global.equals(sessionDescription.getSdpMessage(), null))) {
                                jsonObject["sdpMessage"] = fm.icelink.JsonSerializer.serializeString(sessionDescription.getSdpMessage().toString());
                            }
                            if ((!fm.icelink.Global.equals(sessionDescription.getTieBreaker(), null))) {
                                jsonObject["tieBreaker"] = fm.icelink.JsonSerializer.serializeString(sessionDescription.getTieBreaker());
                            }
                            jsonObject["isOffer"] = fm.icelink.JsonSerializer.serializeBoolean(sessionDescription.getIsOffer());
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.getHasAudio = function () {
                    if (arguments.length == 0) {
                        var sdpMessage = this.getSdpMessage();
                        if ((fm.icelink.Global.equals(sdpMessage, null))) {
                            return false;
                        }
                        return (!fm.icelink.Global.equals(sdpMessage.getAudioDescription(), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.getHasData = function () {
                    if (arguments.length == 0) {
                        var sdpMessage = this.getSdpMessage();
                        if ((fm.icelink.Global.equals(sdpMessage, null))) {
                            return false;
                        }
                        return (((!fm.icelink.Global.equals(sdpMessage.getApplicationDescription(), null)) || (!fm.icelink.Global.equals(sdpMessage.getTextDescription(), null))) || (!fm.icelink.Global.equals(sdpMessage.getMessageDescription(), null)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.getHasVideo = function () {
                    if (arguments.length == 0) {
                        var sdpMessage = this.getSdpMessage();
                        if ((fm.icelink.Global.equals(sdpMessage, null))) {
                            return false;
                        }
                        return (!fm.icelink.Global.equals(sdpMessage.getVideoDescription(), null));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.getIsOffer = function () {
                    if (arguments.length == 0) {
                        return (fm.icelink.Global.equals(this.getType(), fm.icelink.SessionDescriptionType.Offer));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.getRenegotiation = function () {
                    if (arguments.length == 0) {
                        return this._renegotiation;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.getSdpMessage = function () {
                    if (arguments.length == 0) {
                        return this._sdpMessage;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.getSessionId = function () {
                    if (arguments.length == 0) {
                        if ((!fm.icelink.Global.equals(this.getSdpMessage(), null))) {
                            var origin_13 = this.getSdpMessage().getOrigin();
                            if ((!fm.icelink.Global.equals(origin_13, null))) {
                                return origin_13.getSessionId();
                            }
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.getSessionVersion = function () {
                    if (arguments.length == 0) {
                        if ((!fm.icelink.Global.equals(this.getSdpMessage(), null))) {
                            var origin_14 = this.getSdpMessage().getOrigin();
                            if ((!fm.icelink.Global.equals(origin_14, null))) {
                                return origin_14.getSessionVersion();
                            }
                        }
                        return -1;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.getTieBreaker = function () {
                    if (arguments.length == 0) {
                        return this._tieBreaker;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.getType = function () {
                    if (arguments.length == 0) {
                        return this._type;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.setRenegotiation = function (value) {
                    if (arguments.length == 1) {
                        this._renegotiation = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.setSdpMessage = function (value) {
                    if (arguments.length == 1) {
                        this._sdpMessage = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.setTieBreaker = function (value) {
                    if (arguments.length == 1) {
                        this._tieBreaker = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.setType = function (value) {
                    if (arguments.length == 1) {
                        this._type = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                SessionDescription.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.SessionDescription.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SessionDescription;
            }());
            icelink.SessionDescription = SessionDescription;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SessionDescriptionTypeWrapper =  (function () {
                function SessionDescriptionTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_60 = __arguments[0];
                        this._value = value_60;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                SessionDescriptionTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.SessionDescriptionTypeWrapper]';
                };
                SessionDescriptionTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.SessionDescriptionType.Offer)
                            return 'Offer';
                        if (this._value == fm.icelink.SessionDescriptionType.Answer)
                            return 'Answer';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return SessionDescriptionTypeWrapper;
            }());
            icelink.SessionDescriptionTypeWrapper = SessionDescriptionTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Size =  (function () {
                function Size() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        this.fmicelinkSizeInit();
                        this.setWidth(0);
                        this.setHeight(0);
                    }
                    else if (__arguments.length == 2) {
                        var width = __arguments[0];
                        var height = __arguments[1];
                        this.fmicelinkSizeInit();
                        this.setWidth(width);
                        this.setHeight(height);
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Size.prototype.getTypeString = function () {
                    return '[fm.icelink.Size]';
                };
                Size.prototype.fmicelinkSizeInit = function () {
                    this.__height = 0;
                    this.__width = 0;
                };
                Size.fromJson = function (sizeJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(sizeJson, function () {
                            return new fm.icelink.Size();
                        }, function (size, name, valueJson) {
                            var str = name;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "width"))) {
                                    if ((fm.icelink.Global.equals(str, "height"))) {
                                        size.setHeight(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                    }
                                }
                                else {
                                    size.setWidth(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                }
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.getEmpty = function () {
                    if (arguments.length == 0) {
                        if ((fm.icelink.Global.equals(fm.icelink.Size.fm_icelink_Size___empty, null))) {
                            fm.icelink.Size.fm_icelink_Size___empty = new fm.icelink.Size();
                        }
                        return fm.icelink.Size.fm_icelink_Size___empty;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.isEquivalent = function (size1, size2) {
                    if (arguments.length == 2) {
                        if ((fm.icelink.Global.equals(size1, size2))) {
                            return true;
                        }
                        if (((fm.icelink.Global.equals(size1, null)) || (fm.icelink.Global.equals(size2, null)))) {
                            return false;
                        }
                        return fm.icelink.Size.isEquivalentNoCheck(size1, size2);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.isEquivalentNoCheck = function (size1, size2) {
                    if (arguments.length == 2) {
                        return ((fm.icelink.Global.equals(size1.getWidth(), size2.getWidth())) && (fm.icelink.Global.equals(size1.getHeight(), size2.getHeight())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.toJson = function (size) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(size, function (obj, jsonObj) {
                            if ((!fm.icelink.Global.equals(size.getWidth(), -1))) {
                                jsonObj["width"] = fm.icelink.JsonSerializer.serializeInteger(size.getWidth());
                            }
                            if ((!fm.icelink.Global.equals(size.getHeight(), -1))) {
                                jsonObj["height"] = fm.icelink.JsonSerializer.serializeInteger(size.getHeight());
                            }
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.prototype.getHeight = function () {
                    if (arguments.length == 0) {
                        return this.__height;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.prototype.getWidth = function () {
                    if (arguments.length == 0) {
                        return this.__width;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.prototype.isEquivalent = function (size) {
                    if (arguments.length == 1) {
                        return fm.icelink.Size.isEquivalent(this, size);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.prototype.setHeight = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        if ((value < 0)) {
                            throw new fm.icelink.Exception("Height cannot be less than 0.");
                        }
                        this.__height = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.prototype.setWidth = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        if ((value < 0)) {
                            throw new fm.icelink.Exception("Width cannot be less than 0.");
                        }
                        this.__width = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Size.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Size.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.format("{0}x{1}", fm.icelink.NumberExtensions.toString(this.getWidth()), fm.icelink.NumberExtensions.toString(this.getHeight()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Size;
            }());
            icelink.Size = Size;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StreamDirectionWrapper =  (function () {
                function StreamDirectionWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_61 = __arguments[0];
                        this._value = value_61;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                StreamDirectionWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.StreamDirectionWrapper]';
                };
                StreamDirectionWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.StreamDirection.SendReceive)
                            return 'SendReceive';
                        if (this._value == fm.icelink.StreamDirection.SendOnly)
                            return 'SendOnly';
                        if (this._value == fm.icelink.StreamDirection.ReceiveOnly)
                            return 'ReceiveOnly';
                        if (this._value == fm.icelink.StreamDirection.Inactive)
                            return 'Inactive';
                        if (this._value == fm.icelink.StreamDirection.Unset)
                            return 'Unset';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StreamDirectionWrapper;
            }());
            icelink.StreamDirectionWrapper = StreamDirectionWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StreamDirectionHelper =  (function () {
                function StreamDirectionHelper() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                StreamDirectionHelper.prototype.getTypeString = function () {
                    return '[fm.icelink.StreamDirectionHelper]';
                };
                StreamDirectionHelper.directionFromString = function (directionString) {
                    if (arguments.length == 1) {
                        if ((!fm.icelink.Global.equals(directionString, null))) {
                            var str = directionString;
                            if ((!fm.icelink.Global.equals(str, null))) {
                                if (!(fm.icelink.Global.equals(str, "sendrecv"))) {
                                    if ((fm.icelink.Global.equals(str, "sendonly"))) {
                                        return fm.icelink.StreamDirection.SendOnly;
                                    }
                                    if ((fm.icelink.Global.equals(str, "recvonly"))) {
                                        return fm.icelink.StreamDirection.ReceiveOnly;
                                    }
                                    if ((fm.icelink.Global.equals(str, "inactive"))) {
                                        return fm.icelink.StreamDirection.Inactive;
                                    }
                                }
                                else {
                                    return fm.icelink.StreamDirection.SendReceive;
                                }
                            }
                        }
                        return fm.icelink.StreamDirection.Unset;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamDirectionHelper.directionToString = function (direction) {
                    if (arguments.length == 1) {
                        var _var0 = direction;
                        do {
                            if (_var0 == fm.icelink.StreamDirection.SendReceive) {
                                return "sendrecv";
                            }
                            else if (_var0 == fm.icelink.StreamDirection.SendOnly) {
                                return "sendonly";
                            }
                            else if (_var0 == fm.icelink.StreamDirection.ReceiveOnly) {
                                return "recvonly";
                            }
                            else if (_var0 == fm.icelink.StreamDirection.Inactive) {
                                return "inactive";
                            }
                        } while (false);
                        return "unset";
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamDirectionHelper.isReceiveDisabled = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                        var direction = arguments[0];
                        return ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.Inactive)) || (fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.SendOnly)));
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var directionString = arguments[0];
                        return fm.icelink.StreamDirectionHelper.isReceiveDisabled(fm.icelink.StreamDirectionHelper.directionFromString(directionString));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamDirectionHelper.isSendDisabled = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                        var direction = arguments[0];
                        return ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.Inactive)) || (fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.ReceiveOnly)));
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var directionString = arguments[0];
                        return fm.icelink.StreamDirectionHelper.isSendDisabled(fm.icelink.StreamDirectionHelper.directionFromString(directionString));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamDirectionHelper.setReceiveDisabled = function () {
                    if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                        var direction = arguments[0];
                        var disabled = arguments[1];
                        return ((fm.icelink.Global.equals(disabled, fm.icelink.StreamDirectionHelper.isReceiveDisabled(direction))) ? direction : fm.icelink.StreamDirectionHelper.toggleReceive(direction));
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var directionString = arguments[0];
                        var disabled = arguments[1];
                        return fm.icelink.StreamDirectionHelper.directionToString(fm.icelink.StreamDirectionHelper.setReceiveDisabled(fm.icelink.StreamDirectionHelper.directionFromString(directionString), disabled));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamDirectionHelper.setSendDisabled = function () {
                    if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                        var direction = arguments[0];
                        var disabled = arguments[1];
                        return ((fm.icelink.Global.equals(disabled, fm.icelink.StreamDirectionHelper.isSendDisabled(direction))) ? direction : fm.icelink.StreamDirectionHelper.toggleSend(direction));
                    }
                    else if (arguments.length == 2 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var directionString = arguments[0];
                        var disabled = arguments[1];
                        return fm.icelink.StreamDirectionHelper.directionToString(fm.icelink.StreamDirectionHelper.setSendDisabled(fm.icelink.StreamDirectionHelper.directionFromString(directionString), disabled));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamDirectionHelper.toggleReceive = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                        var direction = arguments[0];
                        if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.Inactive))) {
                            return fm.icelink.StreamDirection.ReceiveOnly;
                        }
                        if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.ReceiveOnly))) {
                            return fm.icelink.StreamDirection.Inactive;
                        }
                        if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.SendReceive))) {
                            return fm.icelink.StreamDirection.SendOnly;
                        }
                        if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.SendOnly))) {
                            return fm.icelink.StreamDirection.SendReceive;
                        }
                        return fm.icelink.StreamDirection.Unset;
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var directionString = arguments[0];
                        return fm.icelink.StreamDirectionHelper.directionToString(fm.icelink.StreamDirectionHelper.toggleReceive(fm.icelink.StreamDirectionHelper.directionFromString(directionString)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                StreamDirectionHelper.toggleSend = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                        var direction = arguments[0];
                        if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.Inactive))) {
                            return fm.icelink.StreamDirection.SendOnly;
                        }
                        if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.SendOnly))) {
                            return fm.icelink.StreamDirection.Inactive;
                        }
                        if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.SendReceive))) {
                            return fm.icelink.StreamDirection.ReceiveOnly;
                        }
                        if ((fm.icelink.Global.equals(direction, fm.icelink.StreamDirection.ReceiveOnly))) {
                            return fm.icelink.StreamDirection.SendReceive;
                        }
                        return fm.icelink.StreamDirection.Unset;
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isString(arguments[0]))) {
                        var directionString = arguments[0];
                        return fm.icelink.StreamDirectionHelper.directionToString(fm.icelink.StreamDirectionHelper.toggleSend(fm.icelink.StreamDirectionHelper.directionFromString(directionString)));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StreamDirectionHelper;
            }());
            icelink.StreamDirectionHelper = StreamDirectionHelper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StreamStateWrapper =  (function () {
                function StreamStateWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_62 = __arguments[0];
                        this._value = value_62;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                StreamStateWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.StreamStateWrapper]';
                };
                StreamStateWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.StreamState.New)
                            return 'New';
                        if (this._value == fm.icelink.StreamState.Initializing)
                            return 'Initializing';
                        if (this._value == fm.icelink.StreamState.Connecting)
                            return 'Connecting';
                        if (this._value == fm.icelink.StreamState.Connected)
                            return 'Connected';
                        if (this._value == fm.icelink.StreamState.Failing)
                            return 'Failing';
                        if (this._value == fm.icelink.StreamState.Failed)
                            return 'Failed';
                        if (this._value == fm.icelink.StreamState.Closing)
                            return 'Closing';
                        if (this._value == fm.icelink.StreamState.Closed)
                            return 'Closed';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StreamStateWrapper;
            }());
            icelink.StreamStateWrapper = StreamStateWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var StreamTypeWrapper =  (function () {
                function StreamTypeWrapper(value) {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 1) {
                        var value_63 = __arguments[0];
                        this._value = value_63;
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                StreamTypeWrapper.prototype.getTypeString = function () {
                    return '[fm.icelink.StreamTypeWrapper]';
                };
                StreamTypeWrapper.prototype.toString = function () {
                    if (arguments.length == 0) {
                        if (this._value == fm.icelink.StreamType.Audio)
                            return 'Audio';
                        if (this._value == fm.icelink.StreamType.Video)
                            return 'Video';
                        if (this._value == fm.icelink.StreamType.Application)
                            return 'Application';
                        if (this._value == fm.icelink.StreamType.Message)
                            return 'Message';
                        if (this._value == fm.icelink.StreamType.Text)
                            return 'Text';
                        return '';
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return StreamTypeWrapper;
            }());
            icelink.StreamTypeWrapper = StreamTypeWrapper;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var TransportInfo =  (function (_super) {
                __extends(TransportInfo, _super);
                function TransportInfo() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                    }
                    else if (__arguments.length == 2) {
                        var stats = __arguments[0];
                        var lastStats = __arguments[1];
                        _this = _super.call(this) || this;
                        var num = void 0;
                        _super.prototype.setId.call(_this, stats.getId());
                        var flag = (fm.icelink.Global.equals(lastStats, null));
                        if ((!fm.icelink.Global.equals(stats.getLocalCertificate(), null))) {
                            _this.setLocalCertificate(new fm.icelink.CertificateInfo(stats.getLocalCertificate(), (flag ? null : lastStats.getLocalCertificate())));
                        }
                        if ((!fm.icelink.Global.equals(stats.getRemoteCertificate(), null))) {
                            _this.setRemoteCertificate(new fm.icelink.CertificateInfo(stats.getRemoteCertificate(), (flag ? null : lastStats.getRemoteCertificate())));
                        }
                        if ((!fm.icelink.Global.equals(stats.getLocalCandidates(), null))) {
                            _this.setLocalCandidates(new Array(stats.getLocalCandidates().length));
                            for (num = 0; (num < stats.getLocalCandidates().length); num++) {
                                var stats2 = stats.getLocalCandidates()[num];
                                var stats3 = null;
                                if (!flag) {
                                    stats3 = _this.findMatchingCandidate(lastStats.getLocalCandidates(), stats2.getId());
                                }
                                _this.getLocalCandidates()[num] = new fm.icelink.CandidateInfo(stats2, stats3);
                            }
                        }
                        if ((!fm.icelink.Global.equals(stats.getRemoteCandidates(), null))) {
                            _this.setRemoteCandidates(new Array(stats.getRemoteCandidates().length));
                            for (num = 0; (num < stats.getRemoteCandidates().length); num++) {
                                var stats4 = stats.getRemoteCandidates()[num];
                                var stats5 = null;
                                if (!flag) {
                                    stats5 = _this.findMatchingCandidate(lastStats.getRemoteCandidates(), stats4.getId());
                                }
                                _this.getRemoteCandidates()[num] = new fm.icelink.CandidateInfo(stats4, stats5);
                            }
                        }
                        if ((!fm.icelink.Global.equals(stats.getCandidatePairs(), null))) {
                            _this.setCandidatePairs(new Array(stats.getCandidatePairs().length));
                            for (num = 0; (num < stats.getCandidatePairs().length); num++) {
                                var stats6 = stats.getCandidatePairs()[num];
                                var stats7 = null;
                                if (!flag) {
                                    stats7 = _this.findMatchingCandidatePair(lastStats.getCandidatePairs(), stats6.getId());
                                }
                                _this.getCandidatePairs()[num] = new fm.icelink.CandidatePairInfo(stats6, stats7);
                            }
                        }
                        _this.setActiveCandidatePairId(((fm.icelink.Global.equals(stats.getActiveCandidatePair(), null)) ? null : stats.getActiveCandidatePair().getId()));
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                TransportInfo.prototype.getTypeString = function () {
                    return '[fm.icelink.TransportInfo]' + ',' + _super.prototype.getTypeString.call(this);
                };
                TransportInfo.fromJson = function (transportReportJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(transportReportJson, function () {
                            return new fm.icelink.TransportInfo();
                        }, function (info, key, value) {
                            info.deserializeProperties(key, value);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.fromJsonArray = function (transportInfosJson) {
                    if (arguments.length == 1) {
                        var list = fm.icelink.JsonSerializer.deserializeObjectArray(transportInfosJson, fm.icelink.TransportInfo.fromJson.bind(fm.icelink.TransportInfo));
                        if ((fm.icelink.Global.equals(list, null))) {
                            return null;
                        }
                        return fm.icelink.ArrayExtensions.toArray(list);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.toJson = function (transportReport) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(transportReport, function (info, dict) {
                            info.serializeProperties(dict);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.toJsonArray = function (transportInfos) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObjectArray(transportInfos, fm.icelink.TransportInfo.toJson.bind(fm.icelink.TransportInfo));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var str = key;
                        if ((!fm.icelink.Global.equals(str, null))) {
                            if (!(fm.icelink.Global.equals(str, "localCertificate"))) {
                                if ((fm.icelink.Global.equals(str, "remoteCertificate"))) {
                                    this.setRemoteCertificate(fm.icelink.CertificateInfo.fromJson(valueJson));
                                }
                                else {
                                    if ((fm.icelink.Global.equals(str, "localCandidates"))) {
                                        this.setLocalCandidates(fm.icelink.CandidateInfo.fromJsonArray(valueJson));
                                    }
                                    else {
                                        if ((fm.icelink.Global.equals(str, "remoteCandidates"))) {
                                            this.setRemoteCandidates(fm.icelink.CandidateInfo.fromJsonArray(valueJson));
                                        }
                                        else {
                                            if ((fm.icelink.Global.equals(str, "candidatePairs"))) {
                                                this.setCandidatePairs(fm.icelink.CandidatePairInfo.fromJsonArray(valueJson));
                                            }
                                            else {
                                                if ((fm.icelink.Global.equals(str, "activeCandidatePairId"))) {
                                                    this.setActiveCandidatePairId(fm.icelink.JsonSerializer.deserializeString(valueJson));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else {
                                this.setLocalCertificate(fm.icelink.CertificateInfo.fromJson(valueJson));
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.findMatchingCandidate = function (candidates, idValue) {
                    if (arguments.length == 2) {
                        if ((!fm.icelink.Global.equals(candidates, null))) {
                            for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
                                var stats = candidates_1[_i];
                                if ((fm.icelink.Global.equals(stats.getId(), idValue))) {
                                    return stats;
                                }
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.findMatchingCandidatePair = function (candidatePairs, idValue) {
                    if (arguments.length == 2) {
                        if ((!fm.icelink.Global.equals(candidatePairs, null))) {
                            for (var _i = 0, candidatePairs_1 = candidatePairs; _i < candidatePairs_1.length; _i++) {
                                var stats = candidatePairs_1[_i];
                                if ((fm.icelink.Global.equals(stats.getId(), idValue))) {
                                    return stats;
                                }
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.getActiveCandidatePairId = function () {
                    if (arguments.length == 0) {
                        return this._activeCandidatePairId;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.getCandidatePairs = function () {
                    if (arguments.length == 0) {
                        return this._candidatePairs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.getLocalCandidates = function () {
                    if (arguments.length == 0) {
                        return this._localCandidates;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.getLocalCertificate = function () {
                    if (arguments.length == 0) {
                        return this._localCertificate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.getRemoteCandidates = function () {
                    if (arguments.length == 0) {
                        return this._remoteCandidates;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.getRemoteCertificate = function () {
                    if (arguments.length == 0) {
                        return this._remoteCertificate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        if ((!fm.icelink.Global.equals(this.getLocalCertificate(), null))) {
                            jsonObject["localCertificate"] = fm.icelink.CertificateInfo.toJson(this.getLocalCertificate());
                        }
                        if ((!fm.icelink.Global.equals(this.getRemoteCertificate(), null))) {
                            jsonObject["remoteCertificate"] = fm.icelink.CertificateInfo.toJson(this.getRemoteCertificate());
                        }
                        if ((!fm.icelink.Global.equals(this.getLocalCandidates(), null))) {
                            jsonObject["localCandidates"] = fm.icelink.CandidateInfo.toJsonArray(this.getLocalCandidates());
                        }
                        if ((!fm.icelink.Global.equals(this.getRemoteCandidates(), null))) {
                            jsonObject["remoteCandidates"] = fm.icelink.CandidateInfo.toJsonArray(this.getRemoteCandidates());
                        }
                        if ((!fm.icelink.Global.equals(this.getCandidatePairs(), null))) {
                            jsonObject["candidatePairs"] = fm.icelink.CandidatePairInfo.toJsonArray(this.getCandidatePairs());
                        }
                        if ((!fm.icelink.Global.equals(this.getActiveCandidatePairId(), null))) {
                            jsonObject["activeCandidatePairId"] = fm.icelink.JsonSerializer.serializeString(this.getActiveCandidatePairId());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.setActiveCandidatePairId = function (value) {
                    if (arguments.length == 1) {
                        this._activeCandidatePairId = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.setCandidatePairs = function (value) {
                    if (arguments.length == 1) {
                        this._candidatePairs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.setLocalCandidates = function (value) {
                    if (arguments.length == 1) {
                        this._localCandidates = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.setLocalCertificate = function (value) {
                    if (arguments.length == 1) {
                        this._localCertificate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.setRemoteCandidates = function (value) {
                    if (arguments.length == 1) {
                        this._remoteCandidates = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.setRemoteCertificate = function (value) {
                    if (arguments.length == 1) {
                        this._remoteCertificate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportInfo.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.TransportInfo.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return TransportInfo;
            }(fm.icelink.Info));
            icelink.TransportInfo = TransportInfo;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var TransportStats =  (function (_super) {
                __extends(TransportStats, _super);
                function TransportStats() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) {
                        _this = _super.call(this) || this;
                        _this.fmicelinkTransportStatsInit();
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                TransportStats.prototype.getTypeString = function () {
                    return '[fm.icelink.TransportStats]' + ',' + _super.prototype.getTypeString.call(this);
                };
                TransportStats.prototype.fmicelinkTransportStatsInit = function () {
                    this._bytesReceived = 0;
                    this._bytesSent = 0;
                };
                TransportStats.fromJson = function (transportJson) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.deserializeObject(transportJson, function () {
                            return new fm.icelink.TransportStats();
                        }, function (obj, key, valueJson) {
                            obj.deserializeProperties(key, valueJson);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.toJson = function (transport) {
                    if (arguments.length == 1) {
                        return fm.icelink.JsonSerializer.serializeObject(transport, function (obj, jsonObject) {
                            obj.serializeProperties(jsonObject);
                        });
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.deserializeProperties = function (key, valueJson) {
                    if (arguments.length == 2) {
                        _super.prototype.deserializeProperties.call(this, key, valueJson);
                        var _var0 = key;
                        do {
                            if (_var0 == "bytesSent") {
                                this.setBytesSent(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "bytesReceived") {
                                this.setBytesReceived(fm.icelink.JsonSerializer.deserializeInteger(valueJson));
                                break;
                            }
                            else if (_var0 == "rtcpTransport") {
                                this.setRtcpTransport(fm.icelink.TransportStats.fromJson(valueJson));
                                break;
                            }
                            else if (_var0 == "localCandidates") {
                                this.setLocalCandidates(fm.icelink.CandidateStats.fromJsonArray(valueJson));
                                break;
                            }
                            else if (_var0 == "remoteCandidates") {
                                this.setRemoteCandidates(fm.icelink.CandidateStats.fromJsonArray(valueJson));
                                break;
                            }
                            else if (_var0 == "candidatePairs") {
                                this.setCandidatePairs(fm.icelink.CandidatePairStats.fromJsonArray(valueJson));
                                break;
                            }
                            else if (_var0 == "activeCandidatePair") {
                                this.setActiveCandidatePair(fm.icelink.CandidatePairStats.fromJson(valueJson));
                                break;
                            }
                            else if (_var0 == "localCertificate") {
                                this.setLocalCertificate(fm.icelink.CertificateStats.fromJson(valueJson));
                                break;
                            }
                            else if (_var0 == "remoteCertificate") {
                                this.setRemoteCertificate(fm.icelink.CertificateStats.fromJson(valueJson));
                                break;
                            }
                        } while (false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getActiveCandidatePair = function () {
                    if (arguments.length == 0) {
                        return this._activeCandidatePair;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getBytesReceived = function () {
                    if (arguments.length == 0) {
                        return this._bytesReceived;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getBytesSent = function () {
                    if (arguments.length == 0) {
                        return this._bytesSent;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getCandidatePair = function (candidatePairId) {
                    if (arguments.length == 1) {
                        for (var _i = 0, _a = this.getCandidatePairs(); _i < _a.length; _i++) {
                            var stats = _a[_i];
                            if ((fm.icelink.Global.equals(stats.getId(), candidatePairId))) {
                                return stats;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getCandidatePairs = function () {
                    if (arguments.length == 0) {
                        return this._candidatePairs;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getIsHost = function () {
                    if (arguments.length == 0) {
                        var activeCandidatePair = this.getActiveCandidatePair();
                        if ((fm.icelink.Global.equals(activeCandidatePair, null))) {
                            return false;
                        }
                        var localCandidate = this.getLocalCandidate(activeCandidatePair.getLocalCandidateId());
                        var remoteCandidate = this.getRemoteCandidate(activeCandidatePair.getRemoteCandidateId());
                        return (((!fm.icelink.Global.equals(localCandidate, null)) && localCandidate.getIsHost()) || ((!fm.icelink.Global.equals(remoteCandidate, null)) && remoteCandidate.getIsHost()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getIsReflexive = function () {
                    if (arguments.length == 0) {
                        var activeCandidatePair = this.getActiveCandidatePair();
                        if ((fm.icelink.Global.equals(activeCandidatePair, null))) {
                            return false;
                        }
                        var localCandidate = this.getLocalCandidate(activeCandidatePair.getLocalCandidateId());
                        var remoteCandidate = this.getRemoteCandidate(activeCandidatePair.getRemoteCandidateId());
                        return (((!fm.icelink.Global.equals(localCandidate, null)) && localCandidate.getIsReflexive()) || ((!fm.icelink.Global.equals(remoteCandidate, null)) && remoteCandidate.getIsReflexive()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getIsRelayed = function () {
                    if (arguments.length == 0) {
                        var activeCandidatePair = this.getActiveCandidatePair();
                        if ((fm.icelink.Global.equals(activeCandidatePair, null))) {
                            return false;
                        }
                        var localCandidate = this.getLocalCandidate(activeCandidatePair.getLocalCandidateId());
                        var remoteCandidate = this.getRemoteCandidate(activeCandidatePair.getRemoteCandidateId());
                        return (((!fm.icelink.Global.equals(localCandidate, null)) && localCandidate.getIsRelayed()) || ((!fm.icelink.Global.equals(remoteCandidate, null)) && remoteCandidate.getIsRelayed()));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getLocalCandidate = function (candidateId) {
                    if (arguments.length == 1) {
                        for (var _i = 0, _a = this.getLocalCandidates(); _i < _a.length; _i++) {
                            var stats = _a[_i];
                            if ((fm.icelink.Global.equals(stats.getId(), candidateId))) {
                                return stats;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getLocalCandidates = function () {
                    if (arguments.length == 0) {
                        return this._localCandidates;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getLocalCertificate = function () {
                    if (arguments.length == 0) {
                        return this._localCertificate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getRemoteCandidate = function (candidateId) {
                    if (arguments.length == 1) {
                        for (var _i = 0, _a = this.getRemoteCandidates(); _i < _a.length; _i++) {
                            var stats = _a[_i];
                            if ((fm.icelink.Global.equals(stats.getId(), candidateId))) {
                                return stats;
                            }
                        }
                        return null;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getRemoteCandidates = function () {
                    if (arguments.length == 0) {
                        return this._remoteCandidates;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getRemoteCertificate = function () {
                    if (arguments.length == 0) {
                        return this._remoteCertificate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.getRtcpTransport = function () {
                    if (arguments.length == 0) {
                        return this._rtcpTransport;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.serializeProperties = function (jsonObject) {
                    if (arguments.length == 1) {
                        _super.prototype.serializeProperties.call(this, jsonObject);
                        jsonObject["bytesSent"] = fm.icelink.JsonSerializer.serializeLong(this.getBytesSent());
                        jsonObject["bytesReceived"] = fm.icelink.JsonSerializer.serializeLong(this.getBytesReceived());
                        if ((!fm.icelink.Global.equals(this.getRtcpTransport(), null))) {
                            jsonObject["rtcpTransport"] = fm.icelink.TransportStats.toJson(this.getRtcpTransport());
                        }
                        if ((!fm.icelink.Global.equals(this.getLocalCandidates(), null))) {
                            jsonObject["localCandidates"] = fm.icelink.CandidateStats.toJsonArray(this.getLocalCandidates());
                        }
                        if ((!fm.icelink.Global.equals(this.getRemoteCandidates(), null))) {
                            jsonObject["remoteCandidates"] = fm.icelink.CandidateStats.toJsonArray(this.getRemoteCandidates());
                        }
                        if ((!fm.icelink.Global.equals(this.getCandidatePairs(), null))) {
                            jsonObject["candidatePairs"] = fm.icelink.CandidatePairStats.toJsonArray(this.getCandidatePairs());
                        }
                        if ((!fm.icelink.Global.equals(this.getActiveCandidatePair(), null))) {
                            jsonObject["activeCandidatePair"] = fm.icelink.CandidatePairStats.toJson(this.getActiveCandidatePair());
                        }
                        if ((!fm.icelink.Global.equals(this.getLocalCertificate(), null))) {
                            jsonObject["localCertificate"] = fm.icelink.CertificateStats.toJson(this.getLocalCertificate());
                        }
                        if ((!fm.icelink.Global.equals(this.getRemoteCertificate(), null))) {
                            jsonObject["remoteCertificate"] = fm.icelink.CertificateStats.toJson(this.getRemoteCertificate());
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.setActiveCandidatePair = function (value) {
                    if (arguments.length == 1) {
                        this._activeCandidatePair = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.setBytesReceived = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bytesReceived = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.setBytesSent = function (value) {
                    if (arguments.length == 1) {
                        value = fm.icelink.Global.toInt(arguments[0]);
                        this._bytesSent = fm.icelink.Global.toInt(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.setCandidatePairs = function (value) {
                    if (arguments.length == 1) {
                        this._candidatePairs = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.setLocalCandidates = function (value) {
                    if (arguments.length == 1) {
                        this._localCandidates = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.setLocalCertificate = function (value) {
                    if (arguments.length == 1) {
                        this._localCertificate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.setRemoteCandidates = function (value) {
                    if (arguments.length == 1) {
                        this._remoteCandidates = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.setRemoteCertificate = function (value) {
                    if (arguments.length == 1) {
                        this._remoteCertificate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.setRtcpTransport = function (value) {
                    if (arguments.length == 1) {
                        this._rtcpTransport = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                TransportStats.prototype.toJson = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.TransportStats.toJson(this);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return TransportStats;
            }(fm.icelink.BaseStats));
            icelink.TransportStats = TransportStats;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Utility =  (function () {
                function Utility() {
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 0) ;
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                }
                Utility.prototype.getTypeString = function () {
                    return '[fm.icelink.Utility]';
                };
                Utility.clone = function (list) {
                    if (arguments.length == 1) {
                        var list2 = new Array();
                        fm.icelink.ArrayExtensions.addRange(list2, list);
                        return list2;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.cloneIntArray = function (intArray) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(intArray, null))) {
                            return null;
                        }
                        var numArray = new Array(intArray.length);
                        for (var i = 0; (i < intArray.length); i++) {
                            numArray[i] = intArray[i];
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.cloneLongArray = function (longArray) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(longArray, null))) {
                            return null;
                        }
                        var numArray = new Array(longArray.length);
                        for (var i = 0; (i < longArray.length); i++) {
                            numArray[i] = longArray[i];
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.cloneStringArray = function (stringArray) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(stringArray, null))) {
                            return null;
                        }
                        var strArray = new Array(stringArray.length);
                        for (var i = 0; (i < stringArray.length); i++) {
                            strArray[i] = stringArray[i];
                        }
                        return strArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.firstOrDefault = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || (fm.icelink.Util.isArray(arguments[0]) && (arguments[0].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[0][0]) || fm.icelink.Util.isObject(arguments[0][0])))))) {
                        var array = arguments[0];
                        if (((fm.icelink.Global.equals(array, null)) || (fm.icelink.Global.equals(array.length, 0)))) {
                            return null;
                        }
                        return array[0];
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObject(arguments[0]))) {
                        var list = arguments[0];
                        if (((fm.icelink.Global.equals(list, null)) || (fm.icelink.Global.equals(fm.icelink.ArrayExtensions.getCount(list), 0)))) {
                            return null;
                        }
                        return list[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.formatDoubleAsPercent = function (value, decimalPlaces) {
                    if (arguments.length == 2) {
                        decimalPlaces = fm.icelink.Global.toInt(arguments[1]);
                        var num = void 0;
                        if ((decimalPlaces < 0)) {
                            decimalPlaces = 0;
                        }
                        var str = fm.icelink.NumberExtensions.toString((value * 100));
                        var strArray = fm.icelink.StringExtensions.split(str, [46]);
                        if ((fm.icelink.Global.equals(strArray.length, 1))) {
                            if ((decimalPlaces > 0)) {
                                str = fm.icelink.StringExtensions.concat(str, ".");
                            }
                            for (num = 0; (num < decimalPlaces); num++) {
                                str = fm.icelink.StringExtensions.concat(str, "0");
                            }
                            return str;
                        }
                        var str2 = strArray[0];
                        if ((fm.icelink.Global.equals(fm.icelink.StringExtensions.getLength(str2), 0))) {
                            str2 = "0";
                        }
                        if ((fm.icelink.Global.equals(decimalPlaces, 0))) {
                            return str2;
                        }
                        var str3 = strArray[1];
                        if ((fm.icelink.StringExtensions.getLength(str3) > decimalPlaces)) {
                            str3 = fm.icelink.StringExtensions.substring(str3, 0, decimalPlaces);
                        }
                        else {
                            if ((fm.icelink.StringExtensions.getLength(str3) < decimalPlaces)) {
                                var num2 = (decimalPlaces - fm.icelink.StringExtensions.getLength(str3));
                                for (num = 0; (num < num2); num++) {
                                    str3 = fm.icelink.StringExtensions.concat(str3, "0");
                                }
                            }
                        }
                        return fm.icelink.StringExtensions.concat(str2, ".", str3);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.generateId = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.replace(fm.icelink.Guid.newGuid().toString(), "-", "");
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.generateSynchronizationSource = function () {
                    if (arguments.length == 0) {
                        var buffer = new Uint8Array(4);
                        fm.icelink.LockedRandomizer.nextBytes(buffer);
                        return fm.icelink.Binary.fromBytes32(buffer, 0, false);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.generateTieBreaker = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.Utility.generateId();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.getRtpSequenceNumberDelta = function (rtpSequenceNumber, lastRtpSequenceNumber) {
                    if (arguments.length == 2) {
                        rtpSequenceNumber = fm.icelink.Global.toInt(arguments[0]);
                        lastRtpSequenceNumber = fm.icelink.Global.toInt(arguments[1]);
                        var num = (rtpSequenceNumber - lastRtpSequenceNumber);
                        if ((num < -32768)) {
                            return (num + 65536);
                        }
                        if ((num >= 32768)) {
                            num = (num - 65536);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.getRtpTimestampDelta = function (rtpTimestamp, lastRtpTimestamp) {
                    if (arguments.length == 2) {
                        rtpTimestamp = fm.icelink.Global.toInt(arguments[0]);
                        lastRtpTimestamp = fm.icelink.Global.toInt(arguments[1]);
                        var num = (rtpTimestamp - lastRtpTimestamp);
                        if ((num < -2147483648)) {
                            return (num + 4294967296);
                        }
                        if ((num >= 2147483648)) {
                            num = (num - 4294967296);
                        }
                        return num;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.lastOrDefault = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || (fm.icelink.Util.isArray(arguments[0]) && (arguments[0].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[0][0]) || fm.icelink.Util.isObject(arguments[0][0])))))) {
                        var array = arguments[0];
                        if (((fm.icelink.Global.equals(array, null)) || (fm.icelink.Global.equals(array.length, 0)))) {
                            return null;
                        }
                        return array[(array.length - 1)];
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObject(arguments[0]))) {
                        var list = arguments[0];
                        if (((fm.icelink.Global.equals(list, null)) || (fm.icelink.Global.equals(fm.icelink.ArrayExtensions.getCount(list), 0)))) {
                            return null;
                        }
                        return list[(fm.icelink.ArrayExtensions.getCount(list) - 1)];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.singleOrDefault = function () {
                    if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || (fm.icelink.Util.isArray(arguments[0]) && (arguments[0].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[0][0]) || fm.icelink.Util.isObject(arguments[0][0])))))) {
                        var array = arguments[0];
                        if (((fm.icelink.Global.equals(array, null)) || (!fm.icelink.Global.equals(array.length, 1)))) {
                            return null;
                        }
                        return array[0];
                    }
                    else if (arguments.length == 1 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObject(arguments[0]))) {
                        var list = arguments[0];
                        if (((fm.icelink.Global.equals(list, null)) || (!fm.icelink.Global.equals(fm.icelink.ArrayExtensions.getCount(list), 1)))) {
                            return null;
                        }
                        return list[0];
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.splice = function () {
                    if (arguments.length == 4 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || (fm.icelink.Util.isArray(arguments[2]) && (arguments[2].length == 0 || (fm.icelink.Util.isNullOrUndefined(arguments[2][0]) || fm.icelink.Util.isObject(arguments[2][0])))))) {
                        var array = arguments[0];
                        var index = fm.icelink.Global.toInt(arguments[1]);
                        var addItems = arguments[2];
                        var createArray = arguments[3];
                        return fm.icelink.Utility.splice(array, index, 0, addItems, createArray);
                    }
                    else if (arguments.length == 5) {
                        var array = arguments[0];
                        var index = fm.icelink.Global.toInt(arguments[1]);
                        var removeCount = fm.icelink.Global.toInt(arguments[2]);
                        var addItems = arguments[3];
                        var createArray = arguments[4];
                        if (((index < 0) && ((array.length + index) >= 0))) {
                            index = (array.length + index);
                        }
                        if ((((index < 0) || (removeCount < 0)) || ((index + removeCount) > array.length))) {
                            var length_48 = array.length;
                            throw new fm.icelink.Exception(fm.icelink.StringExtensions.format("Cannot splice {0} items at index {1} from an array of length {2}.", fm.icelink.NumberExtensions.toString(removeCount), fm.icelink.NumberExtensions.toString(index), fm.icelink.NumberExtensions.toString(length_48)));
                        }
                        var num = ((fm.icelink.Global.equals(addItems, null)) ? 0 : addItems.length);
                        var localArray = createArray(((array.length - removeCount) + num));
                        var num2 = 0;
                        var num3 = 0;
                        var num4 = 0;
                        while ((num3 < index)) {
                            localArray[num2++] = array[num3++];
                        }
                        while ((num4 < num)) {
                            localArray[num2++] = addItems[num4++];
                        }
                        num3 = (num3 + removeCount);
                        while ((num3 < array.length)) {
                            localArray[num2++] = array[num3++];
                        }
                        return localArray;
                    }
                    else if (arguments.length == 4 && (fm.icelink.Util.isNullOrUndefined(arguments[2]) || fm.icelink.Util.isNumber(arguments[2]))) {
                        var array = arguments[0];
                        var index = fm.icelink.Global.toInt(arguments[1]);
                        var removeCount = fm.icelink.Global.toInt(arguments[2]);
                        var createArray = arguments[3];
                        return fm.icelink.Utility.splice(array, index, removeCount, null, createArray);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.toIntArray = function (intList) {
                    if (arguments.length == 1) {
                        var numArray = new Array(fm.icelink.ArrayExtensions.getCount(intList));
                        for (var i = 0; (i < numArray.length); i++) {
                            numArray[i] = intList[i];
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.toList = function (array) {
                    if (arguments.length == 1) {
                        var list = new Array();
                        for (var i = 0; (i < array.length); i++) {
                            fm.icelink.ArrayExtensions.add(list, array[i]);
                        }
                        return list;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.toLongArray = function (longList) {
                    if (arguments.length == 1) {
                        var numArray = new Array(fm.icelink.ArrayExtensions.getCount(longList));
                        for (var i = 0; (i < numArray.length); i++) {
                            numArray[i] = longList[i];
                        }
                        return numArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.toStringArray = function (stringList) {
                    if (arguments.length == 1) {
                        var strArray = new Array(fm.icelink.ArrayExtensions.getCount(stringList));
                        for (var i = 0; (i < strArray.length); i++) {
                            strArray[i] = stringList[i];
                        }
                        return strArray;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.treeFindLeaves = function (root, childrenCallback, nodeCallback) {
                    if (arguments.length == 3) {
                        var localArray = childrenCallback(root);
                        if ((!fm.icelink.Global.equals(localArray, null))) {
                            for (var _i = 0, localArray_3 = localArray; _i < localArray_3.length; _i++) {
                                var local = localArray_3[_i];
                                fm.icelink.Utility.treeSearch(local, childrenCallback, nodeCallback);
                            }
                        }
                        else {
                            nodeCallback(root);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                Utility.treeSearch = function (root, childrenCallback, nodeCallback) {
                    if (arguments.length == 3) {
                        nodeCallback(root);
                        var localArray = childrenCallback(root);
                        if ((!fm.icelink.Global.equals(localArray, null))) {
                            for (var _i = 0, localArray_4 = localArray; _i < localArray_4.length; _i++) {
                                var local = localArray_4[_i];
                                fm.icelink.Utility.treeSearch(local, childrenCallback, nodeCallback);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return Utility;
            }());
            icelink.Utility = Utility;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var ScreenConfig =  (function (_super) {
                __extends(ScreenConfig, _super);
                function ScreenConfig() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 3 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.Point]')) && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isObjectType(arguments[1], '[fm.icelink.Size]'))) {
                        var origin_15 = __arguments[0];
                        var size = __arguments[1];
                        var frameRate = __arguments[2];
                        __arguments = new Array(2);
                        __arguments[0] = new fm.icelink.Rectangle(origin_15, size);
                        __arguments[1] = frameRate;
                        {
                            var region = __arguments[0];
                            var frameRate_2 = __arguments[1];
                            __arguments = new Array(3);
                            __arguments[0] = region;
                            __arguments[1] = frameRate_2;
                            __arguments[2] = 90000;
                            {
                                var region_1 = __arguments[0];
                                var frameRate_3 = __arguments[1];
                                var clockRate = __arguments[2];
                                _this = _super.call(this, clockRate) || this;
                                _this.fmicelinkScreenConfigInit();
                                _this.setRegion(region_1);
                                _this.setFrameRate(frameRate_3);
                            }
                        }
                    }
                    else if (__arguments.length == 4) {
                        var origin_16 = __arguments[0];
                        var size = __arguments[1];
                        var frameRate = __arguments[2];
                        var clockRate = __arguments[3];
                        __arguments = new Array(3);
                        __arguments[0] = new fm.icelink.Rectangle(origin_16, size);
                        __arguments[1] = frameRate;
                        __arguments[2] = clockRate;
                        {
                            var region = __arguments[0];
                            var frameRate_4 = __arguments[1];
                            var clockRate_7 = __arguments[2];
                            _this = _super.call(this, clockRate_7) || this;
                            _this.fmicelinkScreenConfigInit();
                            _this.setRegion(region);
                            _this.setFrameRate(frameRate_4);
                        }
                    }
                    else if (__arguments.length == 2) {
                        var region = __arguments[0];
                        var frameRate = __arguments[1];
                        __arguments = new Array(3);
                        __arguments[0] = region;
                        __arguments[1] = frameRate;
                        __arguments[2] = 90000;
                        {
                            var region_2 = __arguments[0];
                            var frameRate_5 = __arguments[1];
                            var clockRate = __arguments[2];
                            _this = _super.call(this, clockRate) || this;
                            _this.fmicelinkScreenConfigInit();
                            _this.setRegion(region_2);
                            _this.setFrameRate(frameRate_5);
                        }
                    }
                    else if (__arguments.length == 3 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.Rectangle]')) && (fm.icelink.Util.isNullOrUndefined(arguments[1]) || fm.icelink.Util.isNumber(arguments[1]))) {
                        var region = __arguments[0];
                        var frameRate = __arguments[1];
                        var clockRate = __arguments[2];
                        _this = _super.call(this, clockRate) || this;
                        _this.fmicelinkScreenConfigInit();
                        _this.setRegion(region);
                        _this.setFrameRate(frameRate);
                    }
                    else if (__arguments.length == 5) {
                        var x = __arguments[0];
                        var y = __arguments[1];
                        var width = __arguments[2];
                        var height = __arguments[3];
                        var frameRate = __arguments[4];
                        __arguments = new Array(3);
                        __arguments[0] = new fm.icelink.Point(x, y);
                        __arguments[1] = new fm.icelink.Size(width, height);
                        __arguments[2] = frameRate;
                        {
                            var origin_17 = __arguments[0];
                            var size = __arguments[1];
                            var frameRate_6 = __arguments[2];
                            __arguments = new Array(2);
                            __arguments[0] = new fm.icelink.Rectangle(origin_17, size);
                            __arguments[1] = frameRate_6;
                            {
                                var region = __arguments[0];
                                var frameRate_7 = __arguments[1];
                                __arguments = new Array(3);
                                __arguments[0] = region;
                                __arguments[1] = frameRate_7;
                                __arguments[2] = 90000;
                                {
                                    var region_3 = __arguments[0];
                                    var frameRate_8 = __arguments[1];
                                    var clockRate = __arguments[2];
                                    _this = _super.call(this, clockRate) || this;
                                    _this.fmicelinkScreenConfigInit();
                                    _this.setRegion(region_3);
                                    _this.setFrameRate(frameRate_8);
                                }
                            }
                        }
                    }
                    else if (__arguments.length == 6) {
                        var x = __arguments[0];
                        var y = __arguments[1];
                        var width = __arguments[2];
                        var height = __arguments[3];
                        var frameRate = __arguments[4];
                        var clockRate = __arguments[5];
                        __arguments = new Array(4);
                        __arguments[0] = new fm.icelink.Point(x, y);
                        __arguments[1] = new fm.icelink.Size(width, height);
                        __arguments[2] = frameRate;
                        __arguments[3] = clockRate;
                        {
                            var origin_18 = __arguments[0];
                            var size = __arguments[1];
                            var frameRate_9 = __arguments[2];
                            var clockRate_8 = __arguments[3];
                            __arguments = new Array(3);
                            __arguments[0] = new fm.icelink.Rectangle(origin_18, size);
                            __arguments[1] = frameRate_9;
                            __arguments[2] = clockRate_8;
                            {
                                var region = __arguments[0];
                                var frameRate_10 = __arguments[1];
                                var clockRate_9 = __arguments[2];
                                _this = _super.call(this, clockRate_9) || this;
                                _this.fmicelinkScreenConfigInit();
                                _this.setRegion(region);
                                _this.setFrameRate(frameRate_10);
                            }
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                ScreenConfig.prototype.getTypeString = function () {
                    return '[fm.icelink.ScreenConfig]' + ',' + _super.prototype.getTypeString.call(this);
                };
                ScreenConfig.prototype.fmicelinkScreenConfigInit = function () {
                    this.__frameRate = 0;
                };
                ScreenConfig.prototype.getFrameRate = function () {
                    if (arguments.length == 0) {
                        return this.__frameRate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.getHeight = function () {
                    if (arguments.length == 0) {
                        return this.getSize().getHeight();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.getOrigin = function () {
                    if (arguments.length == 0) {
                        return this.getRegion().getOrigin();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.getRegion = function () {
                    if (arguments.length == 0) {
                        return this.__region;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.getSize = function () {
                    if (arguments.length == 0) {
                        return this.getRegion().getSize();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.getWidth = function () {
                    if (arguments.length == 0) {
                        return this.getSize().getWidth();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.getX = function () {
                    if (arguments.length == 0) {
                        return this.getOrigin().getX();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.getY = function () {
                    if (arguments.length == 0) {
                        return this.getOrigin().getY();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.isEquivalent = function (config) {
                    if (arguments.length == 1) {
                        if (!_super.prototype.isEquivalent.call(this, config)) {
                            return false;
                        }
                        return ((((fm.icelink.Global.equals(this.getX(), config.getX())) && (fm.icelink.Global.equals(this.getY(), config.getY()))) && ((fm.icelink.Global.equals(this.getWidth(), config.getWidth())) && (fm.icelink.Global.equals(this.getHeight(), config.getHeight())))) && (fm.icelink.Global.equals(this.getFrameRate(), config.getFrameRate())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.setFrameRate = function (value) {
                    if (arguments.length == 1) {
                        if ((value <= 0)) {
                            throw new fm.icelink.Exception("Frame-rate must be greater than 0.");
                        }
                        this.__frameRate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.setOrigin = function (value) {
                    if (arguments.length == 1) {
                        this.getRegion().setOrigin(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.setRegion = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            throw new fm.icelink.Exception("Region cannot be null.");
                        }
                        this.__region = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.setSize = function (value) {
                    if (arguments.length == 1) {
                        this.getRegion().setSize(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                ScreenConfig.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.format("Clock Rate: {0}, X: {1}, Y: {2} Width: {3}, Height: {4}, Frame Rate: {5}", [fm.icelink.NumberExtensions.toString(_super.prototype.getClockRate.call(this)), fm.icelink.NumberExtensions.toString(this.getX()), fm.icelink.NumberExtensions.toString(this.getY()), fm.icelink.NumberExtensions.toString(this.getWidth()), fm.icelink.NumberExtensions.toString(this.getHeight()), fm.icelink.NumberExtensions.toString(this.getFrameRate())]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return ScreenConfig;
            }(fm.icelink.MediaConfig));
            icelink.ScreenConfig = ScreenConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var VideoConfig =  (function (_super) {
                __extends(VideoConfig, _super);
                function VideoConfig() {
                    var _this = this;
                    var __arguments = new Array(arguments.length);
                    for (var __argumentIndex = 0; __argumentIndex < __arguments.length; ++__argumentIndex) {
                        __arguments[__argumentIndex] = arguments[__argumentIndex];
                    }
                    if (__arguments.length == 2) {
                        var size = __arguments[0];
                        var frameRate = __arguments[1];
                        __arguments = new Array(3);
                        __arguments[0] = size;
                        __arguments[1] = frameRate;
                        __arguments[2] = 90000;
                        {
                            var size_1 = __arguments[0];
                            var frameRate_11 = __arguments[1];
                            var clockRate = __arguments[2];
                            _this = _super.call(this, clockRate) || this;
                            _this.fmicelinkVideoConfigInit();
                            _this.setSize(size_1);
                            _this.setFrameRate(frameRate_11);
                        }
                    }
                    else if (__arguments.length == 3 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.Size]'))) {
                        var size = __arguments[0];
                        var frameRate = __arguments[1];
                        var clockRate = __arguments[2];
                        _this = _super.call(this, clockRate) || this;
                        _this.fmicelinkVideoConfigInit();
                        _this.setSize(size);
                        _this.setFrameRate(frameRate);
                    }
                    else if (__arguments.length == 3 && (fm.icelink.Util.isNullOrUndefined(arguments[0]) || fm.icelink.Util.isNumber(arguments[0]))) {
                        var width = __arguments[0];
                        var height = __arguments[1];
                        var frameRate = __arguments[2];
                        __arguments = new Array(2);
                        __arguments[0] = new fm.icelink.Size(width, height);
                        __arguments[1] = frameRate;
                        {
                            var size = __arguments[0];
                            var frameRate_12 = __arguments[1];
                            __arguments = new Array(3);
                            __arguments[0] = size;
                            __arguments[1] = frameRate_12;
                            __arguments[2] = 90000;
                            {
                                var size_2 = __arguments[0];
                                var frameRate_13 = __arguments[1];
                                var clockRate = __arguments[2];
                                _this = _super.call(this, clockRate) || this;
                                _this.fmicelinkVideoConfigInit();
                                _this.setSize(size_2);
                                _this.setFrameRate(frameRate_13);
                            }
                        }
                    }
                    else if (__arguments.length == 4) {
                        var width = __arguments[0];
                        var height = __arguments[1];
                        var frameRate = __arguments[2];
                        var clockRate = __arguments[3];
                        __arguments = new Array(3);
                        __arguments[0] = new fm.icelink.Size(width, height);
                        __arguments[1] = frameRate;
                        __arguments[2] = clockRate;
                        {
                            var size = __arguments[0];
                            var frameRate_14 = __arguments[1];
                            var clockRate_10 = __arguments[2];
                            _this = _super.call(this, clockRate_10) || this;
                            _this.fmicelinkVideoConfigInit();
                            _this.setSize(size);
                            _this.setFrameRate(frameRate_14);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    return _this;
                }
                VideoConfig.prototype.getTypeString = function () {
                    return '[fm.icelink.VideoConfig]' + ',' + _super.prototype.getTypeString.call(this);
                };
                VideoConfig.prototype.fmicelinkVideoConfigInit = function () {
                    this.__frameRate = 0;
                };
                VideoConfig.prototype.getFrameDuration = function () {
                    if (arguments.length == 0) {
                        var frameRate = this.getFrameRate();
                        if ((frameRate <= 0)) {
                            return -1;
                        }
                        return (1000 / frameRate);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoConfig.prototype.getFrameRate = function () {
                    if (arguments.length == 0) {
                        return this.__frameRate;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoConfig.prototype.getHeight = function () {
                    if (arguments.length == 0) {
                        return this.getSize().getHeight();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoConfig.prototype.getSize = function () {
                    if (arguments.length == 0) {
                        return this.__size;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoConfig.prototype.getWidth = function () {
                    if (arguments.length == 0) {
                        return this.getSize().getWidth();
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoConfig.prototype.isEquivalent = function (config) {
                    if (arguments.length == 1) {
                        if (!_super.prototype.isEquivalent.call(this, config)) {
                            return false;
                        }
                        return (((fm.icelink.Global.equals(this.getWidth(), config.getWidth())) && (fm.icelink.Global.equals(this.getHeight(), config.getHeight()))) && (fm.icelink.Global.equals(this.getFrameRate(), config.getFrameRate())));
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoConfig.prototype.setFrameRate = function (value) {
                    if (arguments.length == 1) {
                        if ((value <= 0)) {
                            throw new fm.icelink.Exception("Frame-rate must be greater than 0.");
                        }
                        this.__frameRate = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoConfig.prototype.setSize = function (value) {
                    if (arguments.length == 1) {
                        if ((fm.icelink.Global.equals(value, null))) {
                            throw new fm.icelink.Exception("Size cannot be null.");
                        }
                        this.__size = value;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                VideoConfig.prototype.toString = function () {
                    if (arguments.length == 0) {
                        return fm.icelink.StringExtensions.format("Clock Rate: {0}, Width: {1}, Height: {2}, Frame Rate: {3}", [fm.icelink.NumberExtensions.toString(_super.prototype.getClockRate.call(this)), fm.icelink.NumberExtensions.toString(this.getWidth()), fm.icelink.NumberExtensions.toString(this.getHeight()), fm.icelink.NumberExtensions.toString(this.getFrameRate())]);
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return VideoConfig;
            }(fm.icelink.MediaConfig));
            icelink.VideoConfig = VideoConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Stream =  (function (_super) {
                __extends(Stream, _super);
                function Stream() {
                    return _super !== null && _super.apply(this, arguments) || this;
                }
                Stream.prototype.getTypeString = function () {
                    return '[fm.icelink.Stream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                Stream.prototype.getState = function () {
                    return this._getInternal().getState();
                };
                Stream.prototype.addOnStateChange = function (value) {
                    this._getInternal().addOnStateChange(value);
                };
                Stream.prototype.removeOnStateChange = function (value) {
                    this._getInternal().removeOnStateChange(value);
                };
                Stream.prototype.changeDirection = function (newDirection) {
                    return this._getInternal().changeDirection(newDirection);
                };
                Stream.prototype.getDirection = function () {
                    return this._getInternal().getDirection();
                };
                Stream.prototype.getLocalReceive = function () {
                    return this._getInternal().getLocalReceive();
                };
                Stream.prototype.setLocalReceive = function (receiveEnabled) {
                    return this._getInternal().setLocalReceive(receiveEnabled);
                };
                Stream.prototype.getLocalSend = function () {
                    return this._getInternal().getLocalSend();
                };
                Stream.prototype.setLocalSend = function (sendEnabled) {
                    return this._getInternal().setLocalSend(sendEnabled);
                };
                Stream.prototype.getRemoteReceive = function () {
                    return this._getInternal().getRemoteReceive();
                };
                Stream.prototype.getRemoteSend = function () {
                    return this._getInternal().getRemoteSend();
                };
                Stream.prototype.getRemoteDirection = function () {
                    return this._getInternal().getRemoteDirection();
                };
                Stream.prototype.getId = function () {
                    return this._getInternal().getId();
                };
                Stream.prototype.getExternalId = function () {
                    return this._getInternal().getExternalId();
                };
                Stream.prototype.getLabel = function () {
                    return this._getInternal().getId();
                };
                Stream.prototype.getLocalDirection = function () {
                    return this._getInternal().getLocalDirection();
                };
                Stream.prototype.getMediaDescriptionId = function () {
                    return this._getInternal().getMediaDescriptionId();
                };
                Stream.prototype.getTag = function () {
                    return this._getInternal().getTag();
                };
                Stream.prototype.getType = function () {
                    return this._getInternal().getType();
                };
                Stream.prototype.setExternalId = function (value) {
                    this._getInternal().setExternalId(value);
                };
                Stream.prototype.setLocalDirection = function (value) {
                    this._getInternal().setLocalDirection(value);
                };
                Stream.prototype.setTag = function (value) {
                    this._getInternal().setTag(value);
                };
                Stream.prototype.addOnDirectionChange = function (value) {
                    this._getInternal().addOnDirectionChange(value);
                };
                Stream.prototype.removeOnDirectionChange = function (value) {
                    this._getInternal().removeOnDirectionChange(value);
                };
                Stream.prototype.getTransportInfo = function () {
                    return this._getInternal().getTransportInfo();
                };
                return Stream;
            }(fm.icelink.Dynamic));
            icelink.Stream = Stream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaStream =  (function (_super) {
                __extends(MediaStream, _super);
                function MediaStream(localTrack, remoteTrack) {
                    var _this = _super.call(this) || this;
                    _this.localTrack = localTrack;
                    _this.remoteTrack = remoteTrack;
                    return _this;
                }
                MediaStream.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaStream.prototype.getLocalTrack = function () {
                    return this.localTrack;
                };
                MediaStream.prototype.getRemoteTrack = function () {
                    return this.remoteTrack;
                };
                MediaStream.prototype.getLocalBandwidth = function () {
                    return this._getInternal().getLocalBandwidth();
                };
                MediaStream.prototype.getLocalMuted = function () {
                    return this.getMuted();
                };
                MediaStream.prototype.setLocalMuted = function (value) {
                    return this.setMuted(value);
                };
                MediaStream.prototype.getRemoteMuted = function () {
                    return this._getInternal().getRemoteMuted();
                };
                MediaStream.prototype.setRemoteMuted = function (value) {
                    return this._getInternal().setRemoteMuted(value);
                };
                MediaStream.prototype.getMuted = function () {
                    return this.getInputMuted();
                };
                MediaStream.prototype.getInputMuted = function () {
                    return this._getInternal().getInputMuted();
                };
                MediaStream.prototype.getOutputMuted = function () {
                    return this._getInternal().getOutputMuted();
                };
                MediaStream.prototype.getRemoteBandwidth = function () {
                    return this._getInternal().getRemoteBandwidth();
                };
                MediaStream.prototype.setLocalBandwidth = function (value) {
                    this._getInternal().setLocalBandwidth(value);
                };
                MediaStream.prototype.setMuted = function (value) {
                    this.setInputMuted(value);
                };
                MediaStream.prototype.setInputMuted = function (value) {
                    this._getInternal().setInputMuted(value);
                };
                MediaStream.prototype.setOutputMuted = function (value) {
                    this._getInternal().setOutputMuted(value);
                };
                MediaStream.prototype.getPreferredCodecs = function () {
                    return this._getInternal().getPreferredCodecs();
                };
                MediaStream.prototype.setPreferredCodecs = function (names) {
                    this._getInternal().setPreferredCodecs(names);
                };
                MediaStream.prototype.getCodecDisabled = function (name) {
                    return this._getInternal().getCodecDisabled(name);
                };
                MediaStream.prototype.setCodecDisabled = function (name, disabled) {
                    this._getInternal().setCodecDisabled(name, disabled);
                };
                MediaStream.prototype.getRemoteEncoding = function () {
                    return this._getInternal().getRemoteEncoding();
                };
                MediaStream.prototype.setRemoteEncoding = function (value) {
                    this._getInternal().setRemoteEncoding(value);
                };
                MediaStream.prototype.getSimulcastMode = function () {
                    return this._getInternal().getSimulcastMode();
                };
                MediaStream.prototype.setSimulcastMode = function (value) {
                    this._getInternal().setSimulcastMode(value);
                };
                MediaStream.prototype.getInfo = function () {
                    return this._getInternal().getInfo();
                };
                MediaStream.prototype.getControlTransportInfo = function () {
                    return this._getInternal().getControlTransportInfo();
                };
                MediaStream.prototype.getLocalCanonicalName = function () {
                    return this._getInternal().getLocalCanonicalName();
                };
                MediaStream.prototype.getRemoteCanonicalName = function () {
                    return this._getInternal().getRemoteCanonicalName();
                };
                MediaStream.prototype.addOnLocalEncodingDisabled = function (value) {
                    this._getInternal().addOnLocalEncodingDisabled(value);
                };
                MediaStream.prototype.addOnLocalEncodingEnabled = function (value) {
                    this._getInternal().addOnLocalEncodingEnabled(value);
                };
                MediaStream.prototype.removeOnLocalEncodingDisabled = function (value) {
                    this._getInternal().removeOnLocalEncodingDisabled(value);
                };
                MediaStream.prototype.removeOnLocalEncodingEnabled = function (value) {
                    this._getInternal().removeOnLocalEncodingEnabled(value);
                };
                MediaStream.prototype.addOnDiscardBitrateRequest = function (value) {
                    this._getInternal().addOnDiscardBitrateRequest(value);
                };
                MediaStream.prototype.removeOnDiscardBitrateRequest = function (value) {
                    this._getInternal().removeOnDiscardBitrateRequest(value);
                };
                MediaStream.prototype.raiseBitrateRequest = function (bitrateRequest) {
                    return this._getInternal().raiseBitrateRequest(bitrateRequest);
                };
                MediaStream.prototype.addOnDiscardBitrateNotification = function (value) {
                    this._getInternal().addOnDiscardBitrateNotification(value);
                };
                MediaStream.prototype.removeOnDiscardBitrateNotification = function (value) {
                    this._getInternal().removeOnDiscardBitrateNotification(value);
                };
                MediaStream.prototype.raiseBitrateNotification = function (bitrateNotification) {
                    return this._getInternal().raiseBitrateNotification(bitrateNotification);
                };
                MediaStream.prototype.getMaxSendBitrate = function () {
                    return this._getInternal().getMaxSendBitrate();
                };
                MediaStream.prototype.setMaxSendBitrate = function (value) {
                    this._getInternal().setMaxSendBitrate(value);
                };
                MediaStream.prototype.getMaxReceiveBitrate = function () {
                    return this._getInternal().getMaxReceiveBitrate();
                };
                MediaStream.prototype.setMaxReceiveBitrate = function (value) {
                    this._getInternal().setMaxReceiveBitrate(value);
                };
                return MediaStream;
            }(fm.icelink.Stream));
            icelink.MediaStream = MediaStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AudioStream =  (function (_super) {
                __extends(AudioStream, _super);
                function AudioStream() {
                    var _this = this;
                    if (arguments.length == 0) {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    var localTrack = null;
                    var localMedia = null;
                    var remoteTrack = null;
                    var remoteMedia = null;
                    if (arguments.length >= 1 && fm.icelink.Util.isNullOrUndefined(arguments[0])) ;
                    else if (arguments.length >= 1 && fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.AudioTrack]')) {
                        localTrack = arguments[0];
                    }
                    else if (arguments.length >= 1 && fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.LocalMedia]')) {
                        localMedia = arguments[0];
                        localTrack = localMedia.getAudioTrack();
                    }
                    else if (arguments.length >= 1 && fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.RemoteMedia]')) {
                        remoteMedia = arguments[0];
                        remoteTrack = remoteMedia.getAudioTrack();
                    }
                    else if (arguments.length >= 1) {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    if (arguments.length >= 2 && fm.icelink.Util.isNullOrUndefined(arguments[1])) ;
                    else if (arguments.length >= 2 && fm.icelink.Util.isObjectType(arguments[1], '[fm.icelink.AudioTrack]')) {
                        remoteTrack = arguments[1];
                    }
                    else if (arguments.length >= 2 && fm.icelink.Util.isObjectType(arguments[1], '[fm.icelink.RemoteMedia]')) {
                        remoteMedia = arguments[1];
                        remoteTrack = remoteMedia.getAudioTrack();
                    }
                    else if (arguments.length >= 2) {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    _this = _super.call(this, localTrack, remoteTrack) || this;
                    _this.localMedia = localMedia;
                    _this.remoteMedia = remoteMedia;
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginAudioStream(_this, (localTrack == null ? null : localTrack._getInternal()), (remoteTrack == null ? null : remoteTrack._getInternal()));
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcAudioStream(_this, (localTrack == null ? null : localTrack._getInternal()), (remoteTrack == null ? null : remoteTrack._getInternal()));
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    return _this;
                }
                AudioStream.prototype.getTypeString = function () {
                    return '[fm.icelink.AudioStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                AudioStream.prototype._getInternal = function () {
                    return this._internal;
                };
                AudioStream.prototype.getLocalMedia = function () {
                    return this.localMedia;
                };
                AudioStream.prototype.getRemoteMedia = function () {
                    return this.remoteMedia;
                };
                AudioStream.prototype.getDiscardDtmfTones = function () {
                    if (!fm.icelink.Plugin.useActiveX() && fm.icelink.Plugin.useNative()) {
                        return this._internal.getDiscardDtmfTones();
                    }
                    return false;
                };
                AudioStream.prototype.setDiscardDtmfTones = function (value) {
                    if (!fm.icelink.Plugin.useActiveX() && fm.icelink.Plugin.useNative()) {
                        this._internal.setDiscardDtmfTones(value);
                    }
                };
                AudioStream.prototype.addOnReceiveDtmfTone = function (value) {
                    this._getInternal().addOnReceiveDtmfTone(value);
                };
                AudioStream.prototype.addOnReceiveDtmfToneChange = function (value) {
                    this._getInternal().addOnReceiveDtmfToneChange(value);
                };
                AudioStream.prototype.addOnSendDtmfTone = function (value) {
                    this._getInternal().addOnSendDtmfTone(value);
                };
                AudioStream.prototype.addOnSendDtmfToneChange = function (value) {
                    this._getInternal().addOnSendDtmfToneChange(value);
                };
                AudioStream.prototype.insertDtmfTone = function (dtmfTone) {
                    return this._getInternal().insertDtmfTone(dtmfTone);
                };
                AudioStream.prototype.insertDtmfTones = function (dtmfTones) {
                    return this._getInternal().insertDtmfTones(dtmfTones);
                };
                AudioStream.prototype.removeOnReceiveDtmfTone = function (value) {
                    this._getInternal().removeOnReceiveDtmfTone(value);
                };
                AudioStream.prototype.removeOnReceiveDtmfToneChange = function (value) {
                    this._getInternal().removeOnReceiveDtmfToneChange(value);
                };
                AudioStream.prototype.removeOnSendDtmfTone = function (value) {
                    this._getInternal().removeOnSendDtmfTone(value);
                };
                AudioStream.prototype.removeOnSendDtmfToneChange = function (value) {
                    this._getInternal().removeOnSendDtmfToneChange(value);
                };
                AudioStream.prototype.getOpusDisabled = function () {
                    return this._getInternal().getOpusDisabled();
                };
                AudioStream.prototype.getG722Disabled = function () {
                    return this._getInternal().getG722Disabled();
                };
                AudioStream.prototype.getPcmuDisabled = function () {
                    return this._getInternal().getPcmuDisabled();
                };
                AudioStream.prototype.getPcmaDisabled = function () {
                    return this._getInternal().getPcmaDisabled();
                };
                AudioStream.prototype.setOpusDisabled = function (value) {
                    return this._getInternal().setOpusDisabled(value);
                };
                AudioStream.prototype.setG722Disabled = function (value) {
                    return this._getInternal().setG722Disabled(value);
                };
                AudioStream.prototype.setPcmuDisabled = function (value) {
                    return this._getInternal().setPcmuDisabled(value);
                };
                AudioStream.prototype.setPcmaDisabled = function (value) {
                    return this._getInternal().setPcmaDisabled(value);
                };
                AudioStream.prototype.addOnDiscardOutboundDtmfTones = function (value) {
                    if (!fm.icelink.Plugin.useActiveX() && fm.icelink.Plugin.useNative()) {
                        this._internal.addOnDiscardOutboundDtmfTones(value);
                    }
                };
                AudioStream.prototype.removeOnDiscardOutboundDtmfTones = function (value) {
                    if (!fm.icelink.Plugin.useActiveX() && fm.icelink.Plugin.useNative()) {
                        this._internal.removeOnDiscardOutboundDtmfTones(value);
                    }
                };
                return AudioStream;
            }(fm.icelink.MediaStream));
            icelink.AudioStream = AudioStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaTrack =  (function (_super) {
                __extends(MediaTrack, _super);
                function MediaTrack(media) {
                    var _this = _super.call(this) || this;
                    _this.media = media;
                    return _this;
                }
                MediaTrack.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaTrack]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaTrack.prototype.getMedia = function () {
                    return this.media;
                };
                MediaTrack.prototype.addOnStarted = function (value) {
                    return this._getInternal().addOnStarted(value);
                };
                MediaTrack.prototype.addOnStopped = function (value) {
                    return this._getInternal().addOnStopped(value);
                };
                MediaTrack.prototype.addOnDestroyed = function (value) {
                    return this._getInternal().addOnDestroyed(value);
                };
                MediaTrack.prototype.removeOnStarted = function (value) {
                    return this._getInternal().removeOnStarted(value);
                };
                MediaTrack.prototype.removeOnStopped = function (value) {
                    return this._getInternal().removeOnStopped(value);
                };
                MediaTrack.prototype.removeOnDestroyed = function (value) {
                    return this._getInternal().removeOnDestroyed(value);
                };
                MediaTrack.prototype.changeSinkOutput = function (sinkOutput) {
                    return this._getInternal().changeSinkOutput(sinkOutput);
                };
                MediaTrack.prototype.changeSourceInput = function (sourceInput) {
                    return this._getInternal().changeSourceInput(sourceInput);
                };
                MediaTrack.prototype.destroy = function () {
                    return this._getInternal().destroy();
                };
                MediaTrack.prototype.getMuted = function () {
                    return this._getInternal().getMuted();
                };
                MediaTrack.prototype.getSinkOutput = function () {
                    return this._getInternal().getSinkOutput();
                };
                MediaTrack.prototype.getSinkOutputs = function () {
                    return this._getInternal().getSinkOutputs();
                };
                MediaTrack.prototype.getSourceInput = function () {
                    return this._getInternal().getSourceInput();
                };
                MediaTrack.prototype.getSourceInputs = function () {
                    return this._getInternal().getSourceInputs();
                };
                MediaTrack.prototype.setMuted = function (value) {
                    this._getInternal().setMuted(value);
                };
                MediaTrack.prototype.setSinkOutput = function (value) {
                    this._getInternal().setSinkOutput(value);
                };
                MediaTrack.prototype.setSourceInput = function (value) {
                    this._getInternal().setSourceInput(value);
                };
                return MediaTrack;
            }(fm.icelink.Dynamic));
            icelink.MediaTrack = MediaTrack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var AudioTrack =  (function (_super) {
                __extends(AudioTrack, _super);
                function AudioTrack(media, internalMedia) {
                    var _this = _super.call(this, media) || this;
                    if (fm.icelink.Util.isNullOrUndefined(media)) {
                        throw new fm.icelink.Exception('Media cannot be null.');
                    }
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginAudioTrack(_this, (media._getInternal() || internalMedia));
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcAudioTrack(_this, (media._getInternal() || internalMedia));
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    return _this;
                }
                AudioTrack.prototype.getTypeString = function () {
                    return '[fm.icelink.AudioTrack]' + ',' + _super.prototype.getTypeString.call(this);
                };
                AudioTrack.prototype._getInternal = function () {
                    return this._internal;
                };
                AudioTrack.prototype.addOnLevel = function (value) {
                    return this._internal.addOnLevel(value);
                };
                AudioTrack.prototype.getGain = function () {
                    return this._internal.getGain();
                };
                AudioTrack.prototype.getVolume = function () {
                    return this._internal.getVolume();
                };
                AudioTrack.prototype.removeOnLevel = function (value) {
                    return this._internal.removeOnLevel(value);
                };
                AudioTrack.prototype.setGain = function (value) {
                    this._internal.setGain(value);
                };
                AudioTrack.prototype.setVolume = function (value) {
                    this._internal.setVolume(value);
                };
                return AudioTrack;
            }(fm.icelink.MediaTrack));
            icelink.AudioTrack = AudioTrack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Connection =  (function (_super) {
                __extends(Connection, _super);
                function Connection() {
                    var _this = _super.call(this) || this;
                    _this._onGatheringStateChangeValues = [];
                    _this._onIceConnectionStateChangeValues = [];
                    _this._onLocalCandidateValues = [];
                    _this._onLocalDescriptionValues = [];
                    _this._onRemoteCandidateValues = [];
                    _this._onRemoteDescriptionValues = [];
                    _this._onSignallingStateChangeValues = [];
                    _this._onStateChangeValues = [];
                    _this._onExternalIdChangeValues = [];
                    var streams = null;
                    if (arguments.length == 0 || (arguments.length >= 1 && fm.icelink.Util.isNullOrUndefined(arguments[0]))) {
                        throw new fm.icelink.Exception('Stream(s) cannot be null.');
                    }
                    else if (arguments.length >= 1 && fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.Stream]')) {
                        streams = [arguments[0]];
                    }
                    else if (arguments.length >= 1 && fm.icelink.Util.isArrayType(arguments[0], '[fm.icelink.Stream]')) {
                        streams = arguments[0];
                    }
                    else if (arguments.length >= 1) {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    var remoteMedia = null;
                    for (var _i = 0, streams_8 = streams; _i < streams_8.length; _i++) {
                        var stream = streams_8[_i];
                        if (fm.icelink.Util.isObjectType(stream, '[fm.icelink.AudioStream]')) {
                            var audioStream = stream;
                            var remoteAudioTrack = audioStream.getRemoteTrack();
                            if (remoteAudioTrack) {
                                var remoteAudioMedia = remoteAudioTrack.getMedia();
                                if (remoteMedia == null) {
                                    remoteMedia = remoteAudioMedia;
                                }
                                else if (remoteMedia != remoteAudioMedia) {
                                    throw new fm.icelink.Exception('Remote media for streams does not match.');
                                }
                            }
                        }
                        else if (fm.icelink.Util.isObjectType(stream, '[fm.icelink.VideoStream]')) {
                            var videoStream = stream;
                            var remoteVideoTrack = videoStream.getRemoteTrack();
                            if (remoteVideoTrack) {
                                var remoteVideoMedia = remoteVideoTrack.getMedia();
                                if (remoteMedia == null) {
                                    remoteMedia = remoteVideoMedia;
                                }
                                else if (remoteMedia != remoteVideoMedia) {
                                    throw new fm.icelink.Exception('Remote media for streams does not match.');
                                }
                            }
                        }
                    }
                    if (remoteMedia == null) {
                        remoteMedia = new fm.icelink.RemoteMedia();
                    }
                    _this._remoteMedia = remoteMedia;
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginConnection(_this, _this.externalsToInternals(streams));
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcConnection(_this, _this.externalsToInternals(streams), _this._remoteMedia._getInternal());
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    _this._internal.addOnExternalIdChange(function (id1, id2) {
                        for (var _i = 0, _a = _this._onExternalIdChangeValues; _i < _a.length; _i++) {
                            var onExternalIdChangeValue = _a[_i];
                            onExternalIdChangeValue(id1, id2);
                        }
                    });
                    _this._internal.addOnGatheringStateChange(function (c) {
                        for (var _i = 0, _a = _this._onGatheringStateChangeValues; _i < _a.length; _i++) {
                            var onGatheringStateChangeValue = _a[_i];
                            onGatheringStateChangeValue(_this);
                        }
                    });
                    _this._internal.addOnIceConnectionStateChange(function (c) {
                        for (var _i = 0, _a = _this._onIceConnectionStateChangeValues; _i < _a.length; _i++) {
                            var onIceConnectionStateChangeValue = _a[_i];
                            onIceConnectionStateChangeValue(_this);
                        }
                    });
                    _this._internal.addOnLocalCandidate(function (c, candidate) {
                        for (var _i = 0, _a = _this._onLocalCandidateValues; _i < _a.length; _i++) {
                            var onLocalCandidateValue = _a[_i];
                            onLocalCandidateValue(_this, candidate);
                        }
                    });
                    _this._internal.addOnLocalDescription(function (c, sessionDescription) {
                        for (var _i = 0, _a = _this._onLocalDescriptionValues; _i < _a.length; _i++) {
                            var onLocalDescriptionValue = _a[_i];
                            onLocalDescriptionValue(_this, sessionDescription);
                        }
                    });
                    _this._internal.addOnRemoteCandidate(function (c, candidate) {
                        for (var _i = 0, _a = _this._onRemoteCandidateValues; _i < _a.length; _i++) {
                            var onRemoteCandidateValue = _a[_i];
                            onRemoteCandidateValue(_this, candidate);
                        }
                    });
                    _this._internal.addOnRemoteDescription(function (c, sessionDescription) {
                        for (var _i = 0, _a = _this._onRemoteDescriptionValues; _i < _a.length; _i++) {
                            var onRemoteDescriptionValue = _a[_i];
                            onRemoteDescriptionValue(_this, sessionDescription);
                        }
                    });
                    _this._internal.addOnSignallingStateChange(function (c) {
                        for (var _i = 0, _a = _this._onSignallingStateChangeValues; _i < _a.length; _i++) {
                            var onSignallingStateChangeValue = _a[_i];
                            onSignallingStateChangeValue(_this);
                        }
                    });
                    _this._internal.addOnStateChange(function (c) {
                        for (var _i = 0, _a = _this._onStateChangeValues; _i < _a.length; _i++) {
                            var onStateChangeValue = _a[_i];
                            onStateChangeValue(_this);
                        }
                    });
                    return _this;
                }
                Connection.prototype.getTypeString = function () {
                    return '[fm.icelink.Connection]' + ',' + _super.prototype.getTypeString.call(this);
                };
                Connection.prototype._getInternal = function () {
                    return this._internal;
                };
                Connection.prototype.addIceServer = function (iceServer) {
                    this._internal.addIceServer(iceServer);
                };
                Connection.prototype.addIceServers = function (iceServers) {
                    this._internal.addIceServers(iceServers);
                };
                Connection.prototype.addOnGatheringStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onGatheringStateChangeValues, value);
                };
                Connection.prototype.addOnIceConnectionStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onIceConnectionStateChangeValues, value);
                };
                Connection.prototype.addOnLocalCandidate = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onLocalCandidateValues, value);
                };
                Connection.prototype.addOnLocalDescription = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onLocalDescriptionValues, value);
                };
                Connection.prototype.addOnRemoteCandidate = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onRemoteCandidateValues, value);
                };
                Connection.prototype.addOnRemoteDescription = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onRemoteDescriptionValues, value);
                };
                Connection.prototype.addOnSignallingStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onSignallingStateChangeValues, value);
                };
                Connection.prototype.addOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onStateChangeValues, value);
                };
                Connection.prototype.addRemoteCandidate = function (remoteCandidate) {
                    return this._internal.addRemoteCandidate(remoteCandidate);
                };
                Connection.prototype.close = function () {
                    return this._internal.close();
                };
                Connection.prototype.createAnswer = function () {
                    return this._internal.createAnswer();
                };
                Connection.prototype.createOffer = function () {
                    return this._internal.createOffer();
                };
                Connection.prototype.getDeadStreamTimeout = function () {
                    return this._internal.getDeadStreamTimeout();
                };
                Connection.prototype.getError = function () {
                    return this._internal.getError();
                };
                Connection.prototype.getExternalId = function () {
                    return this._internal.getExternalId();
                };
                Connection.prototype.getBundlePolicy = function () {
                    return this._internal.getBundlePolicy();
                };
                Connection.prototype.getIceGatherPolicy = function () {
                    return this._internal.getIceGatherPolicy();
                };
                Connection.prototype.getIceServer = function () {
                    return this._internal.getIceServer();
                };
                Connection.prototype.getGatheringState = function () {
                    return this._internal.getGatheringState();
                };
                Connection.prototype.getIceConnectionState = function () {
                    return this._internal.getIceConnectionState();
                };
                Connection.prototype.getIceServers = function () {
                    return this._internal.getIceServers();
                };
                Connection.prototype.getId = function () {
                    return this._internal.getId();
                };
                Connection.prototype.getCanonicalName = function () {
                    return this._internal.getCanonicalName();
                };
                Connection.prototype.getLocalDescription = function () {
                    return this._internal.getLocalDescription();
                };
                Connection.prototype.getRemoteDescription = function () {
                    return this._internal.getRemoteDescription();
                };
                Connection.prototype.getSignallingState = function () {
                    return this._internal.getSignallingState();
                };
                Connection.prototype.getState = function () {
                    return this._internal.getState();
                };
                Connection.prototype.getStats = function () {
                    return this._internal.getStats();
                };
                Connection.prototype.getStreams = function () {
                    return this.internalsToExternals(this._internal.getStreams());
                };
                Connection.prototype.getTieBreaker = function () {
                    return this._internal.getTieBreaker();
                };
                Connection.prototype.getLegacyTimeout = function () {
                    return this._internal.getLegacyTimeout();
                };
                Connection.prototype.getTimeout = function () {
                    return this._internal.getTimeout();
                };
                Connection.prototype.getTrickleIcePolicy = function () {
                    return this._internal.getTrickleIcePolicy();
                };
                Connection.prototype.getHasAudio = function () {
                    return this._internal.getHasAudio();
                };
                Connection.prototype.getHasVideo = function () {
                    return this._internal.getHasVideo();
                };
                Connection.prototype.getHasData = function () {
                    return this._internal.getHasData();
                };
                Connection.prototype.getAudioStream = function () {
                    return this.internalToExternal(this._internal.getAudioStream());
                };
                Connection.prototype.getAudioStreams = function () {
                    return this.internalsToExternals(this._internal.getAudioStreams());
                };
                Connection.prototype.getVideoStream = function () {
                    return this.internalToExternal(this._internal.getVideoStream());
                };
                Connection.prototype.getVideoStreams = function () {
                    return this.internalsToExternals(this._internal.getVideoStreams());
                };
                Connection.prototype.getDataStream = function () {
                    return this.internalToExternal(this._internal.getDataStream());
                };
                Connection.prototype.getDataStreams = function () {
                    return this.internalsToExternals(this._internal.getDataStreams());
                };
                Connection.prototype.removeIceServer = function (iceServer) {
                    this._internal.removeIceServer(iceServer);
                };
                Connection.prototype.removeIceServers = function (iceServers) {
                    this._internal.removeIceServers(iceServers);
                };
                Connection.prototype.removeOnGatheringStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onGatheringStateChangeValues, value);
                };
                Connection.prototype.removeOnIceConnectionStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onIceConnectionStateChangeValues, value);
                };
                Connection.prototype.removeOnLocalCandidate = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onLocalCandidateValues, value);
                };
                Connection.prototype.removeOnLocalDescription = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onLocalDescriptionValues, value);
                };
                Connection.prototype.removeOnRemoteCandidate = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onRemoteCandidateValues, value);
                };
                Connection.prototype.removeOnRemoteDescription = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onRemoteDescriptionValues, value);
                };
                Connection.prototype.removeOnSignallingStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onSignallingStateChangeValues, value);
                };
                Connection.prototype.removeOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onStateChangeValues, value);
                };
                Connection.prototype.setDeadStreamTimeout = function (value) {
                    this._internal.setDeadStreamTimeout(value);
                };
                Connection.prototype.setExternalId = function (value) {
                    this._internal.setExternalId(value);
                };
                Connection.prototype.setError = function (value) {
                    this._internal.setError(value);
                };
                Connection.prototype.addOnExternalIdChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onExternalIdChangeValues, value);
                };
                Connection.prototype.removeOnExternalIdChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onExternalIdChangeValues, value);
                };
                Connection.prototype.setBundlePolicy = function (value) {
                    this._internal.setBundlePolicy(value);
                };
                Connection.prototype.setIceGatherPolicy = function (value) {
                    this._internal.setIceGatherPolicy(value);
                };
                Connection.prototype.setIceServer = function (value) {
                    this._internal.setIceServer(value);
                };
                Connection.prototype.setIceServers = function (value) {
                    this._internal.setIceServers(value);
                };
                Connection.prototype.setLocalDescription = function (localDescription) {
                    return this._internal.setLocalDescription(localDescription);
                };
                Connection.prototype.setLegacyTimeout = function (legacyTimeout) {
                    return this._internal.setLegacyTimeout(legacyTimeout);
                };
                Connection.prototype.setRemoteDescription = function (remoteDescription) {
                    return this._internal.setRemoteDescription(remoteDescription);
                };
                Connection.prototype.setTimeout = function (value) {
                    this._internal.setTimeout(value);
                };
                Connection.prototype.setTrickleIcePolicy = function (value) {
                    this._internal.setTrickleIcePolicy(value);
                };
                Connection.prototype.setTieBreaker = function (value) {
                    this._internal.setTieBreaker(value);
                };
                Connection.prototype.getRemoteMedia = function () {
                    return this._remoteMedia;
                };
                Connection.prototype.externalsToInternals = function (externals) {
                    var _this = this;
                    return fm.icelink.ArrayExtensions.map(externals, function (external) {
                        return _this.externalToInternal(external);
                    });
                };
                Connection.prototype.externalToInternal = function (external) {
                    return external._getInternal();
                };
                Connection.prototype.internalsToExternals = function (internals) {
                    var _this = this;
                    return fm.icelink.ArrayExtensions.map(internals, function (internal) {
                        return _this.internalToExternal(internal);
                    });
                };
                Connection.prototype.internalToExternal = function (internal) {
                    if (internal == null) {
                        return null;
                    }
                    return internal._getExternal();
                };
                return Connection;
            }(fm.icelink.Dynamic));
            icelink.Connection = Connection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataChannel =  (function (_super) {
                __extends(DataChannel, _super);
                function DataChannel(label, ordered, subprotocol) {
                    var _this = _super.call(this) || this;
                    _this._onStateChangeValues = [];
                    if (fm.icelink.Util.isNullOrUndefined(ordered)) {
                        ordered = true;
                    }
                    if (fm.icelink.Util.isNullOrUndefined(subprotocol)) {
                        subprotocol = '';
                    }
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginDataChannel(_this, label, ordered, subprotocol);
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcDataChannel(_this, label, ordered, subprotocol);
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    _this._internal.addOnStateChange(function (c) {
                        for (var _i = 0, _a = _this._onStateChangeValues; _i < _a.length; _i++) {
                            var onStateChangeValue = _a[_i];
                            onStateChangeValue(_this);
                        }
                    });
                    return _this;
                }
                DataChannel.prototype.getTypeString = function () {
                    return '[fm.icelink.DataChannel]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DataChannel.prototype._getInternal = function () {
                    return this._internal;
                };
                DataChannel.prototype.getInfo = function () {
                    return this._getInternal().getInfo();
                };
                DataChannel.prototype.setGetRemoteConnectionInfo = function (value) {
                    if (fm.icelink.Plugin.useActiveX()) {
                        var ch = this._getInternal();
                        ch.setGetRemoteConnectionInfo(value);
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        var ch = this._getInternal();
                        ch.setGetRemoteConnectionInfo(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                };
                DataChannel.prototype.setOnReceive = function (value) {
                    return this._getInternal().setOnReceive(value);
                };
                DataChannel.prototype.getSubprotocol = function () {
                    return this._getInternal().getSubprotocol();
                };
                DataChannel.prototype.getOnReceive = function () {
                    return this._getInternal().getOnReceive();
                };
                DataChannel.prototype.sendDataString = function (dataString) {
                    return this._getInternal().sendDataString(dataString);
                };
                DataChannel.prototype.sendDataBytes = function (dataBytes) {
                    return this._getInternal().sendDataBytes(dataBytes);
                };
                DataChannel.prototype.getState = function () {
                    return this._getInternal().getState();
                };
                DataChannel.prototype.getLabel = function () {
                    return this._getInternal().getLabel();
                };
                DataChannel.prototype.getId = function () {
                    return this._getInternal().getId();
                };
                DataChannel.prototype.getOrdered = function () {
                    return this._getInternal().getOrdered();
                };
                DataChannel.prototype.addOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onStateChangeValues, value);
                };
                DataChannel.prototype.removeOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onStateChangeValues, value);
                };
                return DataChannel;
            }(fm.icelink.Dynamic));
            icelink.DataChannel = DataChannel;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DataStream =  (function (_super) {
                __extends(DataStream, _super);
                function DataStream() {
                    var _this = _super.call(this) || this;
                    if (arguments.length == 0) {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    var channels = null;
                    if (arguments.length >= 1 && fm.icelink.Util.isNullOrUndefined(arguments[0])) {
                        throw new fm.icelink.Exception('Data channels(s) cannot be null.');
                    }
                    else if (arguments.length >= 1 && fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.DataChannel]')) {
                        channels = [arguments[0]];
                    }
                    else if (arguments.length >= 1 && fm.icelink.Util.isArrayType(arguments[0], '[fm.icelink.DataChannel]')) {
                        channels = arguments[0];
                    }
                    else if (arguments.length >= 1) {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    var channelsInternal = fm.icelink.ArrayExtensions.map(channels, function (channel) {
                        return channel._getInternal();
                    });
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginDataStream(_this, channelsInternal);
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcDataStream(_this, channelsInternal);
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    return _this;
                }
                DataStream.prototype.getTypeString = function () {
                    return '[fm.icelink.DataStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DataStream.prototype._getInternal = function () {
                    return this._internal;
                };
                DataStream.prototype.getInfo = function () {
                    return this._getInternal().getInfo();
                };
                DataStream.prototype.setGetRemoteConnectionInfo = function (value) {
                    if (fm.icelink.Plugin.useActiveX()) {
                        var pluginDataStream = this._internal;
                        pluginDataStream.setGetRemoteConnectionInfo(value);
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        var webRtcDataStream = this._internal;
                        webRtcDataStream.setGetRemoteConnectionInfo(value);
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                };
                DataStream.prototype.getChannels = function () {
                    return this.internalsToExternals(this._getInternal().getChannels());
                };
                DataStream.prototype.externalToInternal = function (external) {
                    return external._getInternal();
                };
                DataStream.prototype.externalsToInternals = function (externals) {
                    return fm.icelink.ArrayExtensions.map(externals, function (external) {
                        return external._getInternal();
                    });
                };
                DataStream.prototype.internalToExternal = function (internal) {
                    return internal._getExternal();
                };
                DataStream.prototype.internalsToExternals = function (internals) {
                    return fm.icelink.ArrayExtensions.map(internals, function (internal) {
                        return internal._getExternal();
                    });
                };
                return DataStream;
            }(fm.icelink.Stream));
            icelink.DataStream = DataStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DomAudioSink =  (function (_super) {
                __extends(DomAudioSink, _super);
                function DomAudioSink(track) {
                    var _this = _super.call(this) || this;
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginDomAudioSink(_this, (track == null ? null : track._getInternal()));
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcDomAudioSink(_this, (track == null ? null : track._getInternal()));
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    return _this;
                }
                DomAudioSink.prototype.getTypeString = function () {
                    return '[fm.icelink.DomAudioSink]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DomAudioSink.prototype._getInternal = function () {
                    return this._internal;
                };
                DomAudioSink.prototype.getAudio = function () {
                    return this._getInternal().getAudio();
                };
                return DomAudioSink;
            }(fm.icelink.Dynamic));
            icelink.DomAudioSink = DomAudioSink;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DomLayoutManager =  (function (_super) {
                __extends(DomLayoutManager, _super);
                function DomLayoutManager(container, preset) {
                    var _this = this;
                    if (typeof preset === 'undefined') {
                        preset = null;
                    }
                    _this = _super.call(this, preset) || this;
                    _this._id = fm.icelink.Utility.generateId();
                    _this._parentMissing = 0;
                    _this._parentMissingMax = 16;
                    _this._lastWidth = 0;
                    _this._lastHeight = 0;
                    _this._verticalScrollBarWidth = -1;
                    _this._horizontalScrollBarHeight = -1;
                    _this._retryTimeout = 0;
                    _this._viewCleanups = {};
                    _this._container = container;
                    return _this;
                }
                DomLayoutManager.prototype.getTypeString = function () {
                    return '[fm.icelink.DomLayoutManager]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DomLayoutManager.prototype.getContainer = function () {
                    return this._container;
                };
                DomLayoutManager.prototype.initializeInnerContainer = function () {
                    var _this = this;
                    if (this._innerContainer) {
                        return;
                    }
                    this.destroyInnerContainer();
                    this._innerContainer = document.createElement('div');
                    this._innerContainer.style.position = 'relative';
                    this._innerContainer.style.width = '100%';
                    this._innerContainer.style.height = '100%';
                    this._innerContainer.setAttribute('data-fm-webrtc-inner-container', 'true');
                    this._container.appendChild(this._innerContainer);
                    this._resizeInterval = window.setInterval(function () {
                        if (!_this._container.parentNode) {
                            _this._parentMissing = _this._parentMissing + 1;
                            if (_this._parentMissing > _this._parentMissingMax) {
                                window.clearInterval(_this._resizeInterval);
                            }
                        }
                        else {
                            _this._parentMissing = 0;
                            var width = _this._innerContainer.offsetWidth;
                            var height = _this._innerContainer.offsetHeight;
                            if (width != _this._lastWidth || height != _this._lastHeight) {
                                _this.layout();
                                _this._lastWidth = width;
                                _this._lastHeight = height;
                            }
                        }
                    }, 250);
                };
                DomLayoutManager.prototype.destroyInnerContainer = function () {
                    for (var _i = 0, _a = this.collectionToArray(this._container.getElementsByTagName('div')); _i < _a.length; _i++) {
                        var child = _a[_i];
                        if (child.getAttribute('data-fm-webrtc-inner-container') == 'true') {
                            this._container.removeChild(child);
                        }
                    }
                };
                DomLayoutManager.prototype.destroy = function () {
                    this.destroyInnerContainer();
                    clearInterval(this._resizeInterval);
                };
                DomLayoutManager.prototype.addView = function (view) {
                    var _this = this;
                    this.initializeInnerContainer();
                    var viewId = fm.icelink.Utility.generateId();
                    view.setAttribute('data-fm-webrtc-layout-' + this._id + '-view-id', viewId);
                    this._viewCleanups[viewId] = this.addOnVideoSizeChange(view, function () {
                        _this.layout();
                    });
                    this._innerContainer.appendChild(view);
                };
                DomLayoutManager.prototype.removeView = function (view) {
                    this.initializeInnerContainer();
                    if (view.parentNode == this._innerContainer) {
                        this._innerContainer.removeChild(view);
                    }
                    var viewId = view.getAttribute('data-fm-webrtc-layout-' + this._id + '-view-id');
                    if (viewId) {
                        var cleanup = this._viewCleanups[viewId];
                        if (cleanup) {
                            cleanup();
                        }
                        delete this._viewCleanups[viewId];
                    }
                };
                DomLayoutManager.prototype.dispatchToMainThread = function (action, arg1, arg2) {
                    action(arg1, arg2);
                };
                DomLayoutManager.prototype.doGetLocalView = function () {
                    if (this._innerContainer) {
                        return _super.prototype.doGetLocalView.call(this);
                    }
                    var localViews = this.getViewsByClassName('fm-video-local');
                    if (localViews.length == 0) {
                        return null;
                    }
                    return localViews[localViews.length - 1];
                };
                DomLayoutManager.prototype.doGetRemoteViewsIds = function () {
                    if (this._innerContainer) {
                        return _super.prototype.doGetRemoteViewsIds.call(this);
                    }
                    var remoteViewIds = [];
                    for (var _i = 0, _a = this.getViewsByClassName('fm-video-remote'); _i < _a.length; _i++) {
                        var remoteView = _a[_i];
                        remoteViewIds.push(remoteView.id);
                    }
                    return remoteViewIds;
                };
                DomLayoutManager.prototype.doGetRemoteViews = function (idValue) {
                    if (this._innerContainer) {
                        return _super.prototype.doGetRemoteViews.call(this, idValue);
                    }
                    var remoteViews = [];
                    for (var _i = 0, _a = this.getViewsByClassName('fm-video-remote'); _i < _a.length; _i++) {
                        var remoteView = _a[_i];
                        if (remoteView.id == idValue) {
                            remoteViews.push(remoteView);
                        }
                    }
                    return remoteViews;
                };
                DomLayoutManager.prototype.getViewsByClassName = function (className) {
                    return this.getParentViews(this.collectionToArray(this._container.getElementsByClassName(className)));
                };
                DomLayoutManager.prototype.getParentViews = function (views) {
                    var parentViews = [];
                    for (var _i = 0, views_1 = views; _i < views_1.length; _i++) {
                        var view = views_1[_i];
                        parentViews.push(this.getParentView(view));
                    }
                    return parentViews;
                };
                DomLayoutManager.prototype.getParentView = function (view) {
                    var parentView = view;
                    while (parentView.parentElement != this._container) {
                        parentView = parentView.parentElement;
                    }
                    return parentView;
                };
                DomLayoutManager.prototype.collectionToArray = function (collection) {
                    var elements = [];
                    for (var i = 0; i < collection.length; i++) {
                        elements.push(collection[i]);
                    }
                    return elements;
                };
                DomLayoutManager.prototype.layout = function () {
                    var _this = this;
                    if (this._retryTimeout) {
                        clearTimeout(this._retryTimeout);
                    }
                    var localView = this.getLocalView();
                    var remoteViewIds = this.getRemoteViewIds();
                    var remoteViews = this.getRemoteViews(remoteViewIds);
                    var localVideoSize = null;
                    var remoteVideoSizes = [];
                    if (this.getMode() == fm.icelink.LayoutMode.InlineOverflow) {
                        var retry = false;
                        if (localView != null) {
                            localVideoSize = this.getVideoSize(localView);
                            if (localVideoSize == null) {
                                localVideoSize = new fm.icelink.Size(0, 0);
                                retry = true;
                            }
                        }
                        for (var i = 0; i < remoteViews.length; i++) {
                            var remoteVideoSize = this.getVideoSize(remoteViews[i]);
                            if (remoteVideoSize == null) {
                                remoteVideoSize = new fm.icelink.Size(0, 0);
                                retry = true;
                            }
                            remoteVideoSizes.push(remoteVideoSize);
                        }
                        if (retry) {
                            this._retryTimeout = setTimeout(function () {
                                _this._retryTimeout = 0;
                                _this.layout();
                            }, 250);
                        }
                    }
                    var container = this._innerContainer || this._container;
                    var containerWidth = container.offsetWidth;
                    var containerHeight = container.offsetHeight;
                    var layout = this.getLayout(containerWidth, containerHeight, localView != null, remoteViews.length, remoteViewIds, localVideoSize, remoteVideoSizes);
                    var verticalScrollVisible = false;
                    var horizontalScrollVisible = false;
                    if (this.getMode() == fm.icelink.LayoutMode.InlineOverflow) {
                        if (this.getDirection() == fm.icelink.LayoutDirection.Horizontal) {
                            if (layout.getWidth() > containerWidth) {
                                containerHeight -= this.getHorizontalScrollbarHeight();
                                layout = this.getLayout(containerWidth, containerHeight, localView != null, remoteViews.length, remoteViewIds, localVideoSize, remoteVideoSizes);
                                horizontalScrollVisible = true;
                            }
                        }
                        else {
                            if (layout.getHeight() > containerHeight) {
                                containerWidth -= this.getVerticalScrollbarWidth();
                                layout = this.getLayout(containerWidth, containerHeight, localView != null, remoteViews.length, remoteViewIds, localVideoSize, remoteVideoSizes);
                                verticalScrollVisible = true;
                            }
                        }
                    }
                    if (localView != null) {
                        var localFrame = layout.getLocalFrame();
                        localView.style.position = 'absolute';
                        localView.style.left = localFrame.getX() + 'px';
                        localView.style.top = localFrame.getY() + 'px';
                        localView.style.width = localFrame.getWidth() + 'px';
                        localView.style.height = localFrame.getHeight() + 'px';
                        if (this.getMode() == fm.icelink.LayoutMode.FloatLocal) {
                            localView.style.zIndex = remoteViews.length.toString();
                        }
                        else if (this.getMode() == fm.icelink.LayoutMode.FloatRemote) {
                            localView.style.zIndex = '0';
                        }
                    }
                    var remoteFrames = layout.getRemoteFrames();
                    for (var i = 0; i < remoteFrames.length; i++) {
                        var remoteFrame = remoteFrames[i];
                        var remoteView = remoteViews[i];
                        remoteView.style.position = 'absolute';
                        remoteView.style.left = remoteFrame.getX() + 'px';
                        remoteView.style.top = remoteFrame.getY() + 'px';
                        remoteView.style.width = remoteFrame.getWidth() + 'px';
                        remoteView.style.height = remoteFrame.getHeight() + 'px';
                        if (this.getMode() == fm.icelink.LayoutMode.FloatLocal) {
                            remoteView.style.zIndex = i.toString();
                        }
                        else if (this.getMode() == fm.icelink.LayoutMode.FloatRemote) {
                            remoteView.style.zIndex = (i + 1).toString();
                        }
                    }
                    if (this.getMode() == fm.icelink.LayoutMode.InlineOverflow) {
                        container.style.overflowX = horizontalScrollVisible ? 'scroll' : 'hidden';
                        container.style.overflowY = verticalScrollVisible ? 'scroll' : 'hidden';
                    }
                };
                DomLayoutManager.prototype.getVideoSize = function (view) {
                    if (fm.icelink.Plugin.useActiveX()) {
                        return this.getPluginVideoSize(view);
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        return this.getWebRtcVideoSize(view);
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                };
                DomLayoutManager.prototype.getWebRtcVideoSize = function (view) {
                    if (view == null) {
                        return null;
                    }
                    if (view.nodeName.toLowerCase() == 'video') {
                        var video = view;
                        var videoWidth = video.videoWidth;
                        var videoHeight = video.videoHeight;
                        if (videoWidth && videoHeight) {
                            return new fm.icelink.Size(videoWidth, videoHeight);
                        }
                    }
                    var children = view.children;
                    if (children) {
                        for (var i = 0; i < children.length; i++) {
                            var videoSize = this.getWebRtcVideoSize(children[i]);
                            if (videoSize != null) {
                                return videoSize;
                            }
                        }
                    }
                    return null;
                };
                DomLayoutManager.prototype.getPluginVideoSize = function (view) {
                    if (view == null) {
                        return null;
                    }
                    if (view.nodeName.toLowerCase() == 'object' && view.getAttribute('CLASSID') == 'clsid:' + fm.icelink.PluginConstants.getDomVideoSinkClassId()) {
                        var axo = view;
                        var videoWidth = axo.GetWidth();
                        var videoHeight = axo.GetHeight();
                        if (videoWidth && videoHeight) {
                            return new fm.icelink.Size(videoWidth, videoHeight);
                        }
                    }
                    var children = view.children;
                    if (children) {
                        for (var i = 0; i < children.length; i++) {
                            var videoSize = this.getPluginVideoSize(children[i]);
                            if (videoSize != null) {
                                return videoSize;
                            }
                        }
                    }
                    return null;
                };
                DomLayoutManager.prototype.addOnVideoSizeChange = function (view, handler) {
                    if (fm.icelink.Plugin.useActiveX()) {
                        return this.addOnPluginVideoSizeChange(view, handler);
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        return this.addOnWebRtcVideoSizeChange(view, handler);
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                };
                DomLayoutManager.prototype.addOnWebRtcVideoSizeChange = function (view, handler) {
                    if (view == null) {
                        return null;
                    }
                    if (view.nodeName.toLowerCase() == 'video') {
                        var video_1 = view;
                        var listener_1 = function (event) {
                            handler(new fm.icelink.Size(video_1.videoWidth, video_1.videoHeight));
                        };
                        video_1.addEventListener('resize', listener_1);
                        return function () {
                            video_1.removeEventListener('resize', listener_1);
                        };
                    }
                    var children = view.children;
                    if (children) {
                        for (var i = 0; i < children.length; i++) {
                            var cleanup = this.addOnWebRtcVideoSizeChange(children[i], handler);
                            if (cleanup) {
                                return cleanup;
                            }
                        }
                    }
                    return null;
                };
                DomLayoutManager.prototype.addOnPluginVideoSizeChange = function (view, handler) {
                    if (view == null) {
                        return null;
                    }
                    if (view.nodeName.toLowerCase() == 'object' && view.getAttribute('CLASSID') == 'clsid:' + fm.icelink.PluginConstants.getDomVideoSinkClassId()) {
                        var axo_1 = view;
                        var listener = function () {
                            handler(new fm.icelink.Size(axo_1.GetVideoWidth(), axo_1.GetVideoHeight()));
                        };
                        axo_1.SetOnVideoResize(listener);
                        return function () {
                            axo_1.SetOnVideoResize(null);
                        };
                    }
                    var children = view.children;
                    if (children) {
                        for (var i = 0; i < children.length; i++) {
                            var cleanup = this.addOnPluginVideoSizeChange(children[i], handler);
                            if (cleanup) {
                                return cleanup;
                            }
                        }
                    }
                    return null;
                };
                DomLayoutManager.prototype.getVerticalScrollbarWidth = function () {
                    if (this._verticalScrollBarWidth == -1) {
                        var outer = document.createElement('div');
                        outer.style.visibility = 'hidden';
                        outer.style.overflow = 'scroll';
                        outer.style.msOverflowStyle = 'scrollbar';
                        document.body.appendChild(outer);
                        var inner = document.createElement('div');
                        outer.appendChild(inner);
                        this._verticalScrollBarWidth = outer.offsetWidth - outer.clientWidth;
                        outer.parentNode.removeChild(outer);
                    }
                    return this._verticalScrollBarWidth;
                };
                DomLayoutManager.prototype.getHorizontalScrollbarHeight = function () {
                    if (this._horizontalScrollBarHeight == -1) {
                        var outer = document.createElement('div');
                        outer.style.visibility = 'hidden';
                        outer.style.overflow = 'scroll';
                        outer.style.msOverflowStyle = 'scrollbar';
                        document.body.appendChild(outer);
                        var inner = document.createElement('div');
                        outer.appendChild(inner);
                        this._horizontalScrollBarHeight = outer.offsetHeight - outer.clientHeight;
                        outer.parentNode.removeChild(outer);
                    }
                    return this._horizontalScrollBarHeight;
                };
                return DomLayoutManager;
            }(fm.icelink.LayoutManager));
            icelink.DomLayoutManager = DomLayoutManager;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var DomVideoSink =  (function (_super) {
                __extends(DomVideoSink, _super);
                function DomVideoSink(track) {
                    var _this = _super.call(this) || this;
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginDomVideoSink(_this, (track == null ? null : track._getInternal()));
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcDomVideoSink(_this, (track == null ? null : track._getInternal()));
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    return _this;
                }
                DomVideoSink.prototype.getTypeString = function () {
                    return '[fm.icelink.DomVideoSink]' + ',' + _super.prototype.getTypeString.call(this);
                };
                DomVideoSink.prototype._getInternal = function () {
                    return this._internal;
                };
                DomVideoSink.prototype.getVideo = function () {
                    return this._getInternal().getVideo();
                };
                DomVideoSink.prototype.getView = function () {
                    return this._getInternal().getView();
                };
                DomVideoSink.prototype.getViewScale = function () {
                    return this._getInternal().getViewScale();
                };
                DomVideoSink.prototype.setViewScale = function (viewScale) {
                    this._getInternal().setViewScale(viewScale);
                };
                DomVideoSink.prototype.getViewMirror = function () {
                    return this._getInternal().getViewMirror();
                };
                DomVideoSink.prototype.setViewMirror = function (viewMirror) {
                    this._getInternal().setViewMirror(viewMirror);
                };
                return DomVideoSink;
            }(fm.icelink.Dynamic));
            icelink.DomVideoSink = DomVideoSink;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Factory =  (function () {
                function Factory() {
                }
                Factory.prototype.getTypeString = function () {
                    return '[fm.icelink.Factory]';
                };
                Factory.createConnection = function (streams) {
                    return new fm.icelink.Connection(streams);
                };
                Factory.createAudioStream = function (localMedia) {
                    return new fm.icelink.AudioStream(localMedia);
                };
                Factory.createVideoStream = function (localMedia) {
                    return new fm.icelink.VideoStream(localMedia);
                };
                Factory.createDataChannel = function (label) {
                    return new fm.icelink.DataChannel(label);
                };
                Factory.createDataStream = function (channel) {
                    return new fm.icelink.DataStream(channel);
                };
                Factory.createDomVideoSink = function (track) {
                    return new fm.icelink.DomVideoSink(track);
                };
                Factory.createLocalMedia = function (audio, video, screen) {
                    return new fm.icelink.LocalMedia(audio, video, screen);
                };
                return Factory;
            }());
            icelink.Factory = Factory;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Media =  (function (_super) {
                __extends(Media, _super);
                function Media() {
                    return _super !== null && _super.apply(this, arguments) || this;
                }
                Media.prototype.getTypeString = function () {
                    return '[fm.icelink.Media]' + ',' + _super.prototype.getTypeString.call(this);
                };
                Media.prototype.addOnAudioDestroyed = function (value) {
                    return this._getInternal().addOnAudioDestroyed(value);
                };
                Media.prototype.addOnVideoDestroyed = function (value) {
                    return this._getInternal().addOnVideoDestroyed(value);
                };
                Media.prototype.removeOnAudioDestroyed = function (value) {
                    return this._getInternal().removeOnAudioDestroyed(value);
                };
                Media.prototype.removeOnVideoDestroyed = function (value) {
                    return this._getInternal().removeOnVideoDestroyed(value);
                };
                Media.prototype.addOnAudioLevel = function (value) {
                    this._getInternal().addOnAudioLevel(value);
                };
                Media.prototype.addOnVideoSize = function (value) {
                    this._getInternal().addOnVideoSize(value);
                };
                Media.prototype.getAudioGain = function () {
                    return this._getInternal().getAudioGain();
                };
                Media.prototype.getAudioMuted = function () {
                    return this._getInternal().getAudioMuted();
                };
                Media.prototype.getAudioTrack = function () {
                    return this.internalToExternal(this._getInternal().getAudioTrack());
                };
                Media.prototype.getAudioTracks = function () {
                    return this.internalsToExternals(this._getInternal().getAudioTracks());
                };
                Media.prototype.getAudioVolume = function () {
                    return this._getInternal().getAudioVolume();
                };
                Media.prototype.getId = function () {
                    return this._getInternal().getId();
                };
                Media.prototype.getVideoMuted = function () {
                    return this._getInternal().getVideoMuted();
                };
                Media.prototype.getVideoSize = function () {
                    return this._getInternal().getVideoSize();
                };
                Media.prototype.getVideoTrack = function () {
                    return this.internalToExternal(this._getInternal().getVideoTrack());
                };
                Media.prototype.getVideoTracks = function () {
                    return this.internalsToExternals(this._getInternal().getVideoTracks());
                };
                Media.prototype.grabVideoFrame = function () {
                    return this._getInternal().grabVideoFrame();
                };
                Media.prototype.removeOnAudioLevel = function (value) {
                    this._getInternal().removeOnAudioLevel(value);
                };
                Media.prototype.removeOnVideoSize = function (value) {
                    this._getInternal().removeOnVideoSize(value);
                };
                Media.prototype.setAudioGain = function (value) {
                    this._getInternal().setAudioGain(value);
                };
                Media.prototype.setAudioMuted = function (value) {
                    this._getInternal().setAudioMuted(value);
                };
                Media.prototype.setAudioVolume = function (value) {
                    this._getInternal().setAudioVolume(value);
                };
                Media.prototype.setId = function (value) {
                    return this._getInternal().setId(value);
                };
                Media.prototype.setVideoMuted = function (value) {
                    this._getInternal().setVideoMuted(value);
                };
                Media.prototype.destroy = function () {
                    this._getInternal().destroy();
                };
                Media.prototype.getAudioSink = function () {
                    var internalAudioSink = this._getInternal().getAudioSink();
                    if (internalAudioSink == null) {
                        return null;
                    }
                    return internalAudioSink._getExternal();
                };
                Media.prototype.getVideoSink = function () {
                    var internalViewSink = this._getInternal().getVideoSink();
                    if (internalViewSink == null) {
                        return null;
                    }
                    return internalViewSink._getExternal();
                };
                Media.prototype.getView = function () {
                    return this._getInternal().getView();
                };
                Media.prototype.getViewSink = function () {
                    var internalViewSink = this._getInternal().getViewSink();
                    if (internalViewSink == null) {
                        return null;
                    }
                    return internalViewSink._getExternal();
                };
                Media.prototype.externalsToInternals = function (externals) {
                    var _this = this;
                    return fm.icelink.ArrayExtensions.map(externals, function (external) {
                        return _this.externalToInternal(external);
                    });
                };
                Media.prototype.externalToInternal = function (external) {
                    return external._getInternal();
                };
                Media.prototype.internalsToExternals = function (internals) {
                    var _this = this;
                    return fm.icelink.ArrayExtensions.map(internals, function (internal) {
                        return _this.internalToExternal(internal);
                    });
                };
                Media.prototype.internalToExternal = function (internal) {
                    if (internal == null) {
                        return null;
                    }
                    return internal._getExternal();
                };
                return Media;
            }(fm.icelink.Dynamic));
            icelink.Media = Media;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LocalMedia =  (function (_super) {
                __extends(LocalMedia, _super);
                function LocalMedia(audio, video, screen) {
                    var _this = _super.call(this) || this;
                    if (typeof audio == 'undefined') {
                        audio = true;
                    }
                    if (typeof video == 'undefined') {
                        video = true;
                    }
                    if (typeof screen == 'undefined') {
                        screen = false;
                    }
                    if (screen && !video) {
                        screen = false;
                    }
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginLocalMedia(_this, audio, video, screen);
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcLocalMedia(_this, audio, video, screen);
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    return _this;
                }
                LocalMedia.prototype.getTypeString = function () {
                    return '[fm.icelink.LocalMedia]' + ',' + _super.prototype.getTypeString.call(this);
                };
                LocalMedia.prototype._getInternal = function () {
                    return this._internal;
                };
                LocalMedia.prototype.addOnAudioStarted = function (value) {
                    return this._getInternal().addOnAudioStarted(value);
                };
                LocalMedia.prototype.addOnAudioStopped = function (value) {
                    return this._getInternal().addOnAudioStopped(value);
                };
                LocalMedia.prototype.addOnVideoStarted = function (value) {
                    return this._getInternal().addOnVideoStarted(value);
                };
                LocalMedia.prototype.addOnVideoStopped = function (value) {
                    return this._getInternal().addOnVideoStopped(value);
                };
                LocalMedia.prototype.removeOnAudioStarted = function (value) {
                    return this._getInternal().removeOnAudioStarted(value);
                };
                LocalMedia.prototype.removeOnAudioStopped = function (value) {
                    return this._getInternal().removeOnAudioStopped(value);
                };
                LocalMedia.prototype.removeOnVideoStarted = function (value) {
                    return this._getInternal().removeOnVideoStarted(value);
                };
                LocalMedia.prototype.removeOnVideoStopped = function (value) {
                    return this._getInternal().removeOnVideoStopped(value);
                };
                LocalMedia.prototype.getAudioEncoding = function () {
                    return this._getInternal().getAudioEncoding();
                };
                LocalMedia.prototype.getAudioEncodings = function () {
                    return this._getInternal().getAudioEncodings();
                };
                LocalMedia.prototype.setAudioEncodings = function (value) {
                    return this._getInternal().setAudioEncodings(value);
                };
                LocalMedia.prototype.getVideoEncoding = function () {
                    return this._getInternal().getVideoEncoding();
                };
                LocalMedia.prototype.getVideoEncodings = function () {
                    return this._getInternal().getVideoEncodings();
                };
                LocalMedia.prototype.setVideoEncodings = function (value) {
                    return this._getInternal().setVideoEncodings(value);
                };
                LocalMedia.getChromeExtensionId = function () {
                    return fm.icelink.WebRtcLocalMedia.getChromeExtensionId();
                };
                LocalMedia.setChromeExtensionId = function (chromeExtensionId) {
                    fm.icelink.WebRtcLocalMedia.setChromeExtensionId(chromeExtensionId);
                };
                LocalMedia.getChromeExtensionUrl = function () {
                    return fm.icelink.WebRtcLocalMedia.getChromeExtensionUrl();
                };
                LocalMedia.getChromeExtensionInstalled = function () {
                    return fm.icelink.WebRtcLocalMedia.getChromeExtensionInstalled();
                };
                LocalMedia.getChromeExtensionRequiresUserGesture = function () {
                    return fm.icelink.WebRtcLocalMedia.getChromeExtensionRequiresUserGesture();
                };
                LocalMedia.setChromeExtensionRequiresUserGesture = function (chromeExtensionRequiresUserGesture) {
                    fm.icelink.WebRtcLocalMedia.setChromeExtensionRequiresUserGesture(chromeExtensionRequiresUserGesture);
                };
                LocalMedia.canScreenShare = function () {
                    return fm.icelink.Plugin.hasGetDisplayMedia() || fm.icelink.Util.isIE();
                };
                LocalMedia.prototype.changeAudioSourceInput = function (audioSourceInput) {
                    return this._getInternal().changeAudioSourceInput(audioSourceInput);
                };
                LocalMedia.prototype.changeVideoSourceInput = function (videoSourceInput) {
                    return this._getInternal().changeVideoSourceInput(videoSourceInput);
                };
                LocalMedia.prototype.getAudioSourceInput = function () {
                    return this._getInternal().getAudioSourceInput();
                };
                LocalMedia.prototype.getAudioSourceInputs = function () {
                    return this._getInternal().getAudioSourceInputs();
                };
                LocalMedia.prototype.getVideoSourceInput = function () {
                    return this._getInternal().getVideoSourceInput();
                };
                LocalMedia.prototype.getVideoSourceInputs = function () {
                    return this._getInternal().getVideoSourceInputs();
                };
                LocalMedia.prototype.setAudioSourceInput = function (value) {
                    this._getInternal().setAudioSourceInput(value);
                };
                LocalMedia.prototype.setVideoSourceInput = function (value) {
                    this._getInternal().setVideoSourceInput(value);
                };
                LocalMedia.prototype.start = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    this._getInternal().start().then(function (lm) {
                        promise.resolve(_this);
                    }, function (ex) {
                        promise.reject(ex);
                    });
                    return promise;
                };
                LocalMedia.prototype.stop = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    this._getInternal().stop().then(function (lm) {
                        promise.resolve(_this);
                    }, function (ex) {
                        promise.reject(ex);
                    });
                    return promise;
                };
                LocalMedia.prototype.changeAudioInput = function (audioInput) {
                    fm.icelink.Log.warn('LocalMedia.changeAudioInput is deprecated. Use LocalMedia.changeAudioSourceInput instead.');
                    return this.changeAudioSourceInput(audioInput);
                };
                LocalMedia.prototype.changeVideoInput = function (videoInput) {
                    fm.icelink.Log.warn('LocalMedia.changeVideoInput is deprecated. Use LocalMedia.changeVideoSourceInput instead.');
                    return this.changeVideoSourceInput(videoInput);
                };
                LocalMedia.prototype.getAudioInput = function () {
                    fm.icelink.Log.warn('LocalMedia.getAudioInput is deprecated. Use LocalMedia.getAudioSourceInput instead.');
                    return this.getAudioSourceInput();
                };
                LocalMedia.prototype.getAudioInputs = function () {
                    fm.icelink.Log.warn('LocalMedia.getAudioInputs is deprecated. Use LocalMedia.getAudioSourceInputs instead.');
                    return this.getAudioSourceInputs();
                };
                LocalMedia.prototype.getVideoInput = function () {
                    fm.icelink.Log.warn('LocalMedia.getVideoInput is deprecated. Use LocalMedia.getVideoSourceInput instead.');
                    return this.getVideoSourceInput();
                };
                LocalMedia.prototype.getVideoInputs = function () {
                    fm.icelink.Log.warn('LocalMedia.getVideoInputs is deprecated. Use LocalMedia.getVideoSourceInputs instead.');
                    return this.getVideoSourceInputs();
                };
                LocalMedia.prototype.setAudioInput = function (audioInput) {
                    fm.icelink.Log.warn('LocalMedia.setAudioInput is deprecated. Use LocalMedia.setAudioSourceInput instead.');
                    return this.setAudioSourceInput(audioInput);
                };
                LocalMedia.prototype.setVideoInput = function (videoInput) {
                    fm.icelink.Log.warn('LocalMedia.setVideoInput is deprecated. Use LocalMedia.setVideoSourceInput instead.');
                    return this.setVideoSourceInput(videoInput);
                };
                LocalMedia.prototype.getState = function () {
                    return this._getInternal().getState();
                };
                LocalMedia.prototype.getAudioSimulcastDisabled = function () {
                    return this._getInternal().getAudioSimulcastDisabled();
                };
                LocalMedia.prototype.setAudioSimulcastDisabled = function (value) {
                    this._getInternal().setAudioSimulcastDisabled(value);
                };
                LocalMedia.prototype.getAudioSimulcastEncodingCount = function () {
                    return this._getInternal().getAudioSimulcastEncodingCount();
                };
                LocalMedia.prototype.setAudioSimulcastEncodingCount = function (value) {
                    this._getInternal().setAudioSimulcastEncodingCount(value);
                };
                LocalMedia.prototype.getAudioSimulcastPreferredBitrate = function () {
                    return this._getInternal().getAudioSimulcastPreferredBitrate();
                };
                LocalMedia.prototype.setAudioSimulcastPreferredBitrate = function (value) {
                    this._getInternal().setAudioSimulcastPreferredBitrate(value);
                };
                LocalMedia.prototype.getVideoSimulcastDisabled = function () {
                    return this._getInternal().getVideoSimulcastDisabled();
                };
                LocalMedia.prototype.setVideoSimulcastDisabled = function (value) {
                    this._getInternal().setVideoSimulcastDisabled(value);
                };
                LocalMedia.prototype.getVideoSimulcastEncodingCount = function () {
                    return this._getInternal().getVideoSimulcastEncodingCount();
                };
                LocalMedia.prototype.setVideoSimulcastEncodingCount = function (value) {
                    this._getInternal().setVideoSimulcastEncodingCount(value);
                };
                LocalMedia.prototype.getVideoSimulcastPreferredBitrate = function () {
                    return this._getInternal().getVideoSimulcastPreferredBitrate();
                };
                LocalMedia.prototype.setVideoSimulcastPreferredBitrate = function (value) {
                    this._getInternal().setVideoSimulcastPreferredBitrate(value);
                };
                LocalMedia.prototype.getVideoSimulcastBitsPerPixel = function () {
                    return this._getInternal().getVideoSimulcastBitsPerPixel();
                };
                LocalMedia.prototype.setVideoSimulcastBitsPerPixel = function (value) {
                    this._getInternal().setVideoSimulcastBitsPerPixel(value);
                };
                LocalMedia.prototype.getVideoSimulcastDegradationPreference = function () {
                    return this._getInternal().getVideoSimulcastDegradationPreference();
                };
                LocalMedia.prototype.setVideoSimulcastDegradationPreference = function (value) {
                    this._getInternal().setVideoSimulcastDegradationPreference(value);
                };
                return LocalMedia;
            }(fm.icelink.Media));
            icelink.LocalMedia = LocalMedia;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var LocalNetwork =  (function () {
                function LocalNetwork() {
                }
                LocalNetwork.prototype.getTypeString = function () {
                    return '[fm.icelink.LocalNetwork]';
                };
                LocalNetwork.getAddressType = function (ipAddress) {
                    if (ipAddress.indexOf(':') > -1) {
                        return fm.icelink.AddressType.IPv6;
                    }
                    return fm.icelink.AddressType.IPv4;
                };
                return LocalNetwork;
            }());
            icelink.LocalNetwork = LocalNetwork;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaDescriptionManager =  (function (_super) {
                __extends(MediaDescriptionManager, _super);
                function MediaDescriptionManager() {
                    var _this = _super.call(this) || this;
                    _this._MediaStreamMediaDescriptionManagerUtility = null;
                    _this.localMuted = false;
                    _this.remoteMuted = false;
                    _this._MediaStreamMediaDescriptionManagerUtility = new fm.icelink.MediaStreamMediaDescriptionManagerUtility();
                    return _this;
                }
                MediaDescriptionManager.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaDescriptionManager]' + ',' + _super.prototype.getTypeString.call(this);
                };
                MediaDescriptionManager.prototype.processSdpMediaDescription = function (mediaRequirements, sdpMessage, index, isLocalDescription, isRenegotiation, isOffer) {
                    if (arguments.length == 6) {
                        var error = _super.prototype.processSdpMediaDescription.call(this, mediaRequirements, sdpMessage, index, isLocalDescription, isRenegotiation, isOffer);
                        var mediaDescription = sdpMessage.getMediaDescriptions()[index];
                        if (this._MediaStreamMediaDescriptionManagerUtility.checkIfMuted(mediaDescription)) {
                            if (isLocalDescription) {
                                this.localMuted = true;
                            }
                            else {
                                this.remoteMuted = true;
                            }
                        }
                        return error;
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return MediaDescriptionManager;
            }(fm.icelink.MediaDescriptionManagerBase));
            icelink.MediaDescriptionManager = MediaDescriptionManager;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var MediaDescriptionRequirements =  (function (_super) {
                __extends(MediaDescriptionRequirements, _super);
                function MediaDescriptionRequirements() {
                    return _super.call(this) || this;
                }
                MediaDescriptionRequirements.prototype.getTypeString = function () {
                    return '[fm.icelink.MediaDescriptionRequirements]' + ',' + _super.prototype.getTypeString.call(this);
                };
                return MediaDescriptionRequirements;
            }(fm.icelink.MediaDescriptionRequirementsBase));
            icelink.MediaDescriptionRequirements = MediaDescriptionRequirements;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginConstants =  (function () {
                function PluginConstants() {
                }
                PluginConstants.getLoaderClassId = function () {
                    return '9327AFE3-192F-3BFF-8D72-8F5B9288512E';
                };
                PluginConstants.getDomVideoSinkClassId = function () {
                    return '9ECF1ED2-3BBA-34DB-8723-1DB39449CD6A';
                };
                return PluginConstants;
            }());
            icelink.PluginConstants = PluginConstants;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var Plugin =  (function () {
                function Plugin() {
                }
                Plugin.install = function (pluginConfig) {
                    var promise = new fm.icelink.Promise();
                    this._pluginConfig = pluginConfig;
                    if (fm.icelink.Util.hasActiveX() && this._pluginConfig && this._pluginConfig.getActiveXPath()) {
                        var object = document.createElement('object');
                        object.id = 'activex.loader';
                        object.setAttribute('codebase', this._pluginConfig.getActiveXPath());
                        object.setAttribute('CLASSID', 'clsid:' + fm.icelink.PluginConstants.getLoaderClassId());
                        object.style.width = '0px';
                        object.style.height = '0px';
                        object.style.position = 'absolute';
                        var body = document.getElementsByTagName('body')[0];
                        body.appendChild(object);
                        this.checkForActiveX(promise, object, new Date().getTime());
                    }
                    else {
                        promise.resolve(null);
                    }
                    return promise;
                };
                Plugin.getPluginConfig = function () {
                    return this._pluginConfig;
                };
                Plugin.hasRtcPeerConnection = function () {
                    return (typeof RTCPeerConnection !== 'undefined');
                };
                Plugin.hasRtcDataChannel = function () {
                    return (typeof RTCDataChannel !== 'undefined' || typeof window.DataChannel !== 'undefined');
                };
                Plugin.hasGetUserMedia = function () {
                    return (typeof navigator.fmGetUserMedia !== 'undefined');
                };
                Plugin.hasGetDisplayMedia = function () {
                    return navigator && navigator.mediaDevices && typeof navigator.mediaDevices.getDisplayMedia !== 'undefined';
                };
                Plugin.hasRtcIceGatherer = function () {
                    return (typeof RTCIceGatherer !== 'undefined');
                };
                Plugin.hasRtcIceTransport = function () {
                    return (typeof RTCIceTransport !== 'undefined');
                };
                Plugin.hasRtcDtlsTransport = function () {
                    return (typeof RTCDtlsTransport !== 'undefined');
                };
                Plugin.hasRtcRtpSender = function () {
                    return (typeof RTCRtpSender !== 'undefined');
                };
                Plugin.hasRtcRtpReceiver = function () {
                    return (typeof RTCRtpReceiver !== 'undefined');
                };
                Plugin.hasWebRtc = function (localMedia, dataChannels) {
                    return ((localMedia ? this.hasGetUserMedia() : true) && (dataChannels ? this.hasRtcDataChannel() : true) && this.hasRtcPeerConnection());
                };
                Plugin.hasOrtc = function (localMedia, dataChannels) {
                    return ((localMedia ? this.hasGetUserMedia() : true) && (dataChannels ? this.hasRtcDataChannel() : true) && this.hasRtcIceGatherer() && this.hasRtcIceTransport() && this.hasRtcDtlsTransport() && this.hasRtcRtpSender() && this.hasRtcRtpReceiver());
                };
                Plugin.hasNative = function (localMedia, dataChannels) {
                    return (this.hasWebRtc(localMedia, dataChannels) || this.hasOrtc(localMedia, dataChannels));
                };
                Plugin.hasActiveX = function () {
                    return this._hasActiveX;
                };
                Plugin.isReady = function (localMedia, dataChannels) {
                    return (this.hasActiveX() || this.hasNative(localMedia, dataChannels));
                };
                Plugin.isSupported = function (localMedia, dataChannels) {
                    return (this.isReady(localMedia, dataChannels));
                };
                Plugin.useActiveX = function (localMedia, dataChannels) {
                    if (this._pluginConfig && this._pluginConfig.getPreferActiveX()) {
                        return this.hasActiveX();
                    }
                    else {
                        return (this.hasActiveX() && !this.hasNative(localMedia, dataChannels));
                    }
                };
                Plugin.useNative = function (localMedia, dataChannels) {
                    return (!this.useActiveX(localMedia, dataChannels) && this.hasNative(localMedia, dataChannels));
                };
                Plugin.checkForActiveX = function (promise, object, startTime) {
                    var _this = this;
                    var loaded = false;
                    try {
                        if (!fm.icelink.Util.isNullOrUndefined(object.GetIsLoaded)) {
                            loaded = object.GetIsLoaded();
                        }
                    }
                    catch (ex) {
                        loaded = false;
                    }
                    if (loaded) {
                        this._hasActiveX = true;
                        promise.resolve(null);
                    }
                    else if ((new Date().getTime() - startTime) > this._pluginConfig.getActiveXTimeout()) {
                        promise.reject(new fm.icelink.Exception('ActiveX install timed out.'));
                    }
                    else {
                        window.setTimeout(function () {
                            _this.checkForActiveX(promise, object, startTime);
                        }, 10);
                    }
                };
                Plugin.getChromeExtensionId = function () {
                    return fm.icelink.WebRtcLocalMedia.getChromeExtensionId();
                };
                Plugin.setChromeExtensionId = function (chromeExtensionId) {
                    fm.icelink.WebRtcLocalMedia.setChromeExtensionId(chromeExtensionId);
                };
                Plugin.getChromeExtensionUrl = function () {
                    return fm.icelink.WebRtcLocalMedia.getChromeExtensionUrl();
                };
                Plugin.getChromeExtensionInstalled = function () {
                    return fm.icelink.WebRtcLocalMedia.getChromeExtensionInstalled();
                };
                Plugin.getChromeExtensionRequiresUserGesture = function () {
                    return fm.icelink.WebRtcLocalMedia.getChromeExtensionRequiresUserGesture();
                };
                Plugin.setChromeExtensionRequiresUserGesture = function (chromeExtensionRequiresUserGesture) {
                    fm.icelink.WebRtcLocalMedia.setChromeExtensionRequiresUserGesture(chromeExtensionRequiresUserGesture);
                };
                Plugin.getChromeExtensionRequired = function () {
                    return fm.icelink.WebRtcLocalMedia.getChromeExtensionRequired();
                };
                Plugin._hasActiveX = false;
                return Plugin;
            }());
            icelink.Plugin = Plugin;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginStream =  (function (_super) {
                __extends(PluginStream, _super);
                function PluginStream() {
                    return _super !== null && _super.apply(this, arguments) || this;
                }
                PluginStream.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                return PluginStream;
            }(fm.icelink.Dynamic));
            icelink.PluginStream = PluginStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginMediaStream =  (function (_super) {
                __extends(PluginMediaStream, _super);
                function PluginMediaStream(localTrack, remoteTrack) {
                    var _this = _super.call(this) || this;
                    _this._localTrack = localTrack;
                    _this._remoteTrack = remoteTrack;
                    return _this;
                }
                PluginMediaStream.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginMediaStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginMediaStream.prototype.getLocalTrack = function () {
                    return this._localTrack;
                };
                PluginMediaStream.prototype.getRemoteTrack = function () {
                    return this._remoteTrack;
                };
                return PluginMediaStream;
            }(fm.icelink.PluginStream));
            icelink.PluginMediaStream = PluginMediaStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginAudioStream =  (function (_super) {
                __extends(PluginAudioStream, _super);
                function PluginAudioStream(external, localTrack, remoteTrack) {
                    var _this = _super.call(this, localTrack, remoteTrack) || this;
                    _this._onDirectionChangeValues = [];
                    _this._onStateChangeValues = [];
                    _this._onReceiveDtmfToneValues = [];
                    _this._onReceiveDtmfToneChangeValues = [];
                    _this._onSendDtmfToneValues = [];
                    _this._onSendDtmfToneChangeValues = [];
                    _this._onLocalEncodingDisabledValues = [];
                    _this._onLocalEncodingEnabledValues = [];
                    _this._onDiscardBitrateRequestValues = [];
                    _this._onDiscardBitrateNotificationValues = [];
                    _this._state = fm.icelink.StreamState.New;
                    _this._external = external;
                    _this._axo = new ActiveXObject("fm.icelink.AudioStream");
                    _this._axo.Initialize(_this.getLocalTrack() == null ? 0 : _this.getLocalTrack().getMedia().getHandle(), remoteTrack == null ? 0 : remoteTrack.getMedia().getHandle());
                    _this._axo.SetOnDirectionChange(function () {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onDirectionChangeValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value();
                            }
                        }, 1);
                    });
                    _this._axo.SetOnStateChange(function (state) {
                        _this._state = state;
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onStateChangeValues; _i < _a.length; _i++) {
                                var onStateChangeValue = _a[_i];
                                onStateChangeValue();
                            }
                        }, 1);
                    });
                    _this._axo.SetOnReceiveDtmfTone(function (toneJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onReceiveDtmfToneValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.dtmf.Tone.fromJson(toneJson));
                            }
                        }, 1);
                    });
                    _this._axo.SetOnReceiveDtmfToneChange(function (toneJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onReceiveDtmfToneChangeValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.dtmf.Tone.fromJson(toneJson));
                            }
                        }, 1);
                    });
                    _this._axo.SetOnSendDtmfTone(function (toneJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onSendDtmfToneValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.dtmf.Tone.fromJson(toneJson));
                            }
                        }, 1);
                    });
                    _this._axo.SetOnSendDtmfToneChange(function (toneJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onSendDtmfToneChangeValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.dtmf.Tone.fromJson(toneJson));
                            }
                        }, 1);
                    });
                    _this._axo.SetOnLocalEncodingDisabled(function (encodingJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onLocalEncodingDisabledValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.EncodingInfo.fromJson(encodingJson));
                            }
                        }, 1);
                    });
                    _this._axo.SetOnLocalEncodingEnabled(function (encodingJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onLocalEncodingEnabledValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.EncodingInfo.fromJson(encodingJson));
                            }
                        }, 1);
                    });
                    _this._axo.SetOnDiscardBitrateRequest(function (bitrateRequestJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onDiscardBitrateRequestValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.BitrateRequest.fromJson(bitrateRequestJson));
                            }
                        }, 1);
                    });
                    _this._axo.SetOnDiscardBitrateNotification(function (bitrateNotificationJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onDiscardBitrateNotificationValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.BitrateNotification.fromJson(bitrateNotificationJson));
                            }
                        }, 1);
                    });
                    return _this;
                }
                PluginAudioStream.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginAudioStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginAudioStream.prototype._getExternal = function () {
                    return this._external;
                };
                PluginAudioStream.prototype._getAxo = function () {
                    return this._axo;
                };
                PluginAudioStream.prototype.getState = function () {
                    return this._state;
                };
                PluginAudioStream.prototype.addOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onStateChangeValues, value);
                };
                PluginAudioStream.prototype.removeOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onStateChangeValues, value);
                };
                PluginAudioStream.prototype.getInfo = function () {
                    return fm.icelink.MediaStreamInfo.fromJson(this._getAxo().GetInfo());
                };
                PluginAudioStream.prototype.getLocalReceive = function () {
                    return this._getAxo().GetLocalReceive();
                };
                PluginAudioStream.prototype.getLocalSend = function () {
                    return this._getAxo().GetLocalSend();
                };
                PluginAudioStream.prototype.getRemoteReceive = function () {
                    return this._getAxo().GetRemoteReceive();
                };
                PluginAudioStream.prototype.getRemoteSend = function () {
                    return this._getAxo().GetRemoteSend();
                };
                PluginAudioStream.prototype.setLocalReceive = function (value) {
                    return this._getAxo().SetLocalReceive(value);
                };
                PluginAudioStream.prototype.setLocalSend = function (value) {
                    return this._getAxo().SetLocalSend(value);
                };
                PluginAudioStream.prototype.getRemoteDirection = function () {
                    return this._getAxo().GetRemoteDirection();
                };
                PluginAudioStream.prototype.getHandle = function () {
                    return this._getAxo().GetHandle();
                };
                PluginAudioStream.prototype.changeDirection = function (newDirection) {
                    return fm.icelink.Error.fromJson(this._getAxo().ChangeDirection(newDirection));
                };
                PluginAudioStream.prototype.getDirection = function () {
                    return this._getAxo().GetDirection();
                };
                PluginAudioStream.prototype.getId = function () {
                    return this._getAxo().GetId();
                };
                PluginAudioStream.prototype.getExternalId = function () {
                    return this._getAxo().GetExternalId();
                };
                PluginAudioStream.prototype.setExternalId = function (value) {
                    this._getAxo().SetExternalId(value);
                };
                PluginAudioStream.prototype.getLabel = function () {
                    return this._getAxo().GetLabel();
                };
                PluginAudioStream.prototype.getLocalBandwidth = function () {
                    return this._getAxo().GetLocalBandwidth();
                };
                PluginAudioStream.prototype.getLocalDirection = function () {
                    return this._getAxo().GetLocalDirection();
                };
                PluginAudioStream.prototype.getLocalMuted = function () {
                    return this.getInputMuted();
                };
                PluginAudioStream.prototype.setLocalMuted = function (value) {
                    return this.setInputMuted(value);
                };
                PluginAudioStream.prototype.getRemoteMuted = function () {
                    return this._getAxo().GetRemoteMuted();
                };
                PluginAudioStream.prototype.setRemoteMuted = function (value) {
                    return this._getAxo().SetRemoteMuted(value);
                };
                PluginAudioStream.prototype.getInputMuted = function () {
                    return this._getAxo().GetInputMuted();
                };
                PluginAudioStream.prototype.getLocalCanonicalName = function () {
                    return this._getAxo().GetLocalCanonicalName();
                };
                PluginAudioStream.prototype.getOutputMuted = function () {
                    return this._getAxo().GetOutputMuted();
                };
                PluginAudioStream.prototype.getMediaDescriptionId = function () {
                    return this._getAxo().GetMediaDescriptionId();
                };
                PluginAudioStream.prototype.getRemoteCanonicalName = function () {
                    return this._getAxo().GetRemoteCanonicalName();
                };
                PluginAudioStream.prototype.getRemoteBandwidth = function () {
                    return this._getAxo().GetRemoteBandwidth();
                };
                PluginAudioStream.prototype.getTag = function () {
                    return this._getAxo().GetTag();
                };
                PluginAudioStream.prototype.getType = function () {
                    return fm.icelink.StreamType.Audio;
                };
                PluginAudioStream.prototype.setLocalDirection = function (value) {
                    this._getAxo().SetLocalDirection(value);
                };
                PluginAudioStream.prototype.setLocalBandwidth = function (value) {
                    this._getAxo().SetLocalBandwidth(value);
                };
                PluginAudioStream.prototype.setInputMuted = function (value) {
                    this._getAxo().SetInputMuted(value);
                };
                PluginAudioStream.prototype.setOutputMuted = function (value) {
                    this._getAxo().SetOutputMuted(value);
                };
                PluginAudioStream.prototype.setTag = function (value) {
                    this._getAxo().SetTag(value);
                };
                PluginAudioStream.prototype.addOnDirectionChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onDirectionChangeValues, value);
                };
                PluginAudioStream.prototype.removeOnDirectionChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onDirectionChangeValues, value);
                };
                PluginAudioStream.prototype.addOnReceiveDtmfTone = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onReceiveDtmfToneValues, value);
                };
                PluginAudioStream.prototype.addOnReceiveDtmfToneChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onReceiveDtmfToneChangeValues, value);
                };
                PluginAudioStream.prototype.addOnSendDtmfTone = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onSendDtmfToneValues, value);
                };
                PluginAudioStream.prototype.addOnSendDtmfToneChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onSendDtmfToneChangeValues, value);
                };
                PluginAudioStream.prototype.insertDtmfTone = function (dtmfTone) {
                    return this._getAxo().InsertDtmfTone(fm.icelink.dtmf.Tone.toJson(dtmfTone));
                };
                PluginAudioStream.prototype.insertDtmfTones = function (dtmfTones) {
                    return this._getAxo().InsertDtmfTones(fm.icelink.dtmf.Tone.toJsonArray(dtmfTones));
                };
                PluginAudioStream.prototype.removeOnReceiveDtmfTone = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onReceiveDtmfToneValues, value);
                };
                PluginAudioStream.prototype.removeOnReceiveDtmfToneChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onReceiveDtmfToneChangeValues, value);
                };
                PluginAudioStream.prototype.removeOnSendDtmfTone = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onSendDtmfToneValues, value);
                };
                PluginAudioStream.prototype.removeOnSendDtmfToneChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onSendDtmfToneChangeValues, value);
                };
                PluginAudioStream.prototype.getPreferredCodecs = function () {
                    return this._getAxo().GetPreferredCodecs();
                };
                PluginAudioStream.prototype.setPreferredCodecs = function (names) {
                    this._getAxo().SetPreferredCodecs(names);
                };
                PluginAudioStream.prototype.getCodecDisabled = function (name) {
                    return this._getAxo().GetCodecDisabled(name);
                };
                PluginAudioStream.prototype.setCodecDisabled = function (name, disabled) {
                    this._getAxo().SetCodecDisabled(name, disabled);
                };
                PluginAudioStream.prototype.getOpusDisabled = function () {
                    return this._getAxo().GetOpusDisabled();
                };
                PluginAudioStream.prototype.getG722Disabled = function () {
                    return this._getAxo().GetG722Disabled();
                };
                PluginAudioStream.prototype.getPcmuDisabled = function () {
                    return this._getAxo().GetPcmuDisabled();
                };
                PluginAudioStream.prototype.getPcmaDisabled = function () {
                    return this._getAxo().GetPcmaDisabled();
                };
                PluginAudioStream.prototype.setOpusDisabled = function (value) {
                    return this._getAxo().SetOpusDisabled(value);
                };
                PluginAudioStream.prototype.setG722Disabled = function (value) {
                    return this._getAxo().SetG722Disabled(value);
                };
                PluginAudioStream.prototype.setPcmuDisabled = function (value) {
                    return this._getAxo().SetPcmuDisabled(value);
                };
                PluginAudioStream.prototype.setPcmaDisabled = function (value) {
                    return this._getAxo().SetPcmaDisabled(value);
                };
                PluginAudioStream.prototype.getRemoteEncoding = function () {
                    return fm.icelink.EncodingInfo.fromJson(this._getAxo().GetRemoteEncoding());
                };
                PluginAudioStream.prototype.setRemoteEncoding = function (value) {
                    this._getAxo().SetRemoteEncoding(fm.icelink.EncodingInfo.toJson(value));
                };
                PluginAudioStream.prototype.getSimulcastMode = function () {
                    return this._getAxo().GetSimulcastMode();
                };
                PluginAudioStream.prototype.setSimulcastMode = function (value) {
                    this._getAxo().SetSimulcastMode(value);
                };
                PluginAudioStream.prototype.getTransportInfo = function () {
                    return fm.icelink.TransportInfo.fromJson(this._getAxo().GetTransportInfo());
                };
                PluginAudioStream.prototype.getControlTransportInfo = function () {
                    return fm.icelink.TransportInfo.fromJson(this._getAxo().GetControlTransportInfo());
                };
                PluginAudioStream.prototype.addOnLocalEncodingDisabled = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onLocalEncodingDisabledValues, value);
                };
                PluginAudioStream.prototype.addOnLocalEncodingEnabled = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onLocalEncodingEnabledValues, value);
                };
                PluginAudioStream.prototype.removeOnLocalEncodingDisabled = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onLocalEncodingDisabledValues, value);
                };
                PluginAudioStream.prototype.removeOnLocalEncodingEnabled = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onLocalEncodingEnabledValues, value);
                };
                PluginAudioStream.prototype.addOnDiscardBitrateRequest = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onDiscardBitrateRequestValues, value);
                };
                PluginAudioStream.prototype.removeOnDiscardBitrateRequest = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onDiscardBitrateRequestValues, value);
                };
                PluginAudioStream.prototype.raiseBitrateRequest = function (bitrateRequest) {
                    return this._axo.RaiseBitrateRequest(fm.icelink.BitrateRequest.toJson(bitrateRequest));
                };
                PluginAudioStream.prototype.addOnDiscardBitrateNotification = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onDiscardBitrateNotificationValues, value);
                };
                PluginAudioStream.prototype.removeOnDiscardBitrateNotification = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onDiscardBitrateNotificationValues, value);
                };
                PluginAudioStream.prototype.raiseBitrateNotification = function (bitrateNotification) {
                    return this._axo.RaiseBitrateNotification(fm.icelink.BitrateNotification.toJson(bitrateNotification));
                };
                PluginAudioStream.prototype.getMaxSendBitrate = function () {
                    return this._getAxo().GetMaxSendBitrate();
                };
                PluginAudioStream.prototype.setMaxSendBitrate = function (value) {
                    this._getAxo().SetMaxSendBitrate(value);
                };
                PluginAudioStream.prototype.getMaxReceiveBitrate = function () {
                    return this._getAxo().GetMaxReceiveBitrate();
                };
                PluginAudioStream.prototype.setMaxReceiveBitrate = function (value) {
                    this._getAxo().SetMaxReceiveBitrate(value);
                };
                return PluginAudioStream;
            }(fm.icelink.PluginMediaStream));
            icelink.PluginAudioStream = PluginAudioStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginMediaTrack =  (function (_super) {
                __extends(PluginMediaTrack, _super);
                function PluginMediaTrack(media) {
                    var _this = _super.call(this) || this;
                    _this._media = media;
                    return _this;
                }
                PluginMediaTrack.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginMediaTrack]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginMediaTrack.prototype.getMedia = function () {
                    return this._media;
                };
                PluginMediaTrack.prototype.destroy = function () {
                    return true;
                };
                return PluginMediaTrack;
            }(fm.icelink.Dynamic));
            icelink.PluginMediaTrack = PluginMediaTrack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginAudioTrack =  (function (_super) {
                __extends(PluginAudioTrack, _super);
                function PluginAudioTrack(external, media) {
                    var _this = _super.call(this, media) || this;
                    _this._external = external;
                    return _this;
                }
                PluginAudioTrack.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginAudioTrack]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginAudioTrack.prototype._getExternal = function () {
                    return this._external;
                };
                PluginAudioTrack.prototype.isLocal = function () {
                    return (fm.icelink.Util.isObjectType(this.getMedia(), '[fm.icelink.PluginLocalMedia]'));
                };
                PluginAudioTrack.prototype.addOnStarted = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.addOnStarted on a remote track.');
                    }
                    this.getMedia().addOnAudioStarted(value);
                };
                PluginAudioTrack.prototype.addOnStopped = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.addOnStopped on a remote track.');
                    }
                    this.getMedia().addOnAudioStopped(value);
                };
                PluginAudioTrack.prototype.addOnDestroyed = function (value) {
                    this.getMedia().addOnAudioDestroyed(value);
                };
                PluginAudioTrack.prototype.removeOnStarted = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.removeOnStarted on a remote track.');
                    }
                    this.getMedia().removeOnAudioStarted(value);
                };
                PluginAudioTrack.prototype.removeOnStopped = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.removeOnStopped on a remote track.');
                    }
                    this.getMedia().removeOnAudioStopped(value);
                };
                PluginAudioTrack.prototype.removeOnDestroyed = function (value) {
                    this.getMedia().removeOnAudioDestroyed(value);
                };
                PluginAudioTrack.prototype.changeSinkOutput = function (sinkOutput) {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.changeSinkOutput on a local track.');
                    }
                    return this.getMedia().changeAudioSinkOutput(sinkOutput);
                };
                PluginAudioTrack.prototype.getSinkOutput = function () {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.getSinkOutput on a local track.');
                    }
                    return this.getMedia().getAudioSinkOutput();
                };
                PluginAudioTrack.prototype.getSinkOutputs = function () {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.getSinkOutputs on a local track.');
                    }
                    return this.getMedia().getAudioSinkOutputs();
                };
                PluginAudioTrack.prototype.setSinkOutput = function (value) {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.setSinkOutput on a local track.');
                    }
                    this.getMedia().setAudioSinkOutput(value);
                };
                PluginAudioTrack.prototype.changeSourceInput = function (sourceInput) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.changeSourceInput on a remote track.');
                    }
                    return this.getMedia().changeAudioSourceInput(sourceInput);
                };
                PluginAudioTrack.prototype.getSourceInput = function () {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.getSourceInput on a remote track.');
                    }
                    return this.getMedia().getAudioSourceInput();
                };
                PluginAudioTrack.prototype.getSourceInputs = function () {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.getSourceInputs on a remote track.');
                    }
                    return this.getMedia().getAudioSourceInputs();
                };
                PluginAudioTrack.prototype.setSourceInput = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.setSourceInput on a remote track.');
                    }
                    this.getMedia().setAudioSourceInput(value);
                };
                PluginAudioTrack.prototype.addOnLevel = function (value) {
                    this.getMedia().addOnAudioLevel(value);
                };
                PluginAudioTrack.prototype.getGain = function () {
                    return this.getMedia().getAudioGain();
                };
                PluginAudioTrack.prototype.getMuted = function () {
                    return this.getMedia().getAudioMuted();
                };
                PluginAudioTrack.prototype.getVolume = function () {
                    return this.getMedia().getAudioVolume();
                };
                PluginAudioTrack.prototype.removeOnLevel = function (value) {
                    this.getMedia().removeOnAudioLevel(value);
                };
                PluginAudioTrack.prototype.setGain = function (value) {
                    this.getMedia().setAudioGain(value);
                };
                PluginAudioTrack.prototype.setMuted = function (value) {
                    this.getMedia().setAudioMuted(value);
                };
                PluginAudioTrack.prototype.setVolume = function (value) {
                    this.getMedia().setAudioVolume(value);
                };
                return PluginAudioTrack;
            }(fm.icelink.PluginMediaTrack));
            icelink.PluginAudioTrack = PluginAudioTrack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginConfig =  (function () {
                function PluginConfig() {
                    this._activeXTimeout = 30000;
                    this._preferActiveX = false;
                }
                PluginConfig.prototype.getActiveXPath = function () {
                    return this._activeXPath;
                };
                PluginConfig.prototype.setActiveXPath = function (activeXPath) {
                    this._activeXPath = activeXPath;
                };
                PluginConfig.prototype.getActiveXTimeout = function () {
                    return this._activeXTimeout;
                };
                PluginConfig.prototype.setActiveXTimeout = function (activeXTimeout) {
                    this._activeXTimeout = activeXTimeout;
                };
                PluginConfig.prototype.getPreferActiveX = function () {
                    return this._preferActiveX;
                };
                PluginConfig.prototype.setPreferActiveX = function (preferActiveX) {
                    this._preferActiveX = preferActiveX;
                };
                return PluginConfig;
            }());
            icelink.PluginConfig = PluginConfig;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginConnection =  (function (_super) {
                __extends(PluginConnection, _super);
                function PluginConnection(external, streams) {
                    var _this = _super.call(this) || this;
                    _this._onLocalCandidateValues = [];
                    _this._onLocalDescriptionValues = [];
                    _this._onRemoteCandidateValues = [];
                    _this._onRemoteDescriptionValues = [];
                    _this._onSignallingStateChangeValues = [];
                    _this._onIceConnectionStateChangeValues = [];
                    _this._onStateChangeValues = [];
                    _this._onGatheringStateChangeValues = [];
                    _this._onExternalIdChangeValues = [];
                    _this._gatheringState = fm.icelink.IceGatheringState.New;
                    _this._iceConnectionState = fm.icelink.IceConnectionState.New;
                    _this._signallingState = fm.icelink.SignallingState.New;
                    _this._state = fm.icelink.ConnectionState.New;
                    _this._external = external;
                    _this._streams = streams;
                    _this._axo = new ActiveXObject("fm.icelink.Connection");
                    _this._axo.Initialize(fm.icelink.ArrayExtensions.map(_this._streams, function (stream) {
                        return stream.getHandle();
                    }));
                    _this._axo.SetOnLocalCandidate(function (candidate) {
                        setTimeout(function () {
                            var localCandidate = fm.icelink.Candidate.fromJson(candidate);
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local candidate for stream {0}:\r\n{1}", fm.icelink.NumberExtensions.toString(localCandidate.getSdpMediaIndex()), localCandidate.getSdpCandidateAttribute().toString()));
                            for (var _i = 0, _a = _this._onLocalCandidateValues; _i < _a.length; _i++) {
                                var onLocalCandidateValue = _a[_i];
                                onLocalCandidateValue(_this, localCandidate);
                            }
                        }, 1);
                    });
                    _this._axo.SetOnIceConnectionStateChange(function (iceConnectionState) {
                        _this._iceConnectionState = iceConnectionState;
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onIceConnectionStateChangeValues; _i < _a.length; _i++) {
                                var onIceConnectionStateChangeValue = _a[_i];
                                onIceConnectionStateChangeValue(_this);
                            }
                        }, 1);
                    });
                    _this._axo.SetOnGatheringStateChange(function (gatheringState) {
                        _this._gatheringState = gatheringState;
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onGatheringStateChangeValues; _i < _a.length; _i++) {
                                var onGatheringStateChangeValue = _a[_i];
                                onGatheringStateChangeValue(_this);
                            }
                        }, 1);
                    });
                    _this._axo.SetOnLocalDescription(function (sessionDescription) {
                        setTimeout(function () {
                            var localDescription = fm.icelink.SessionDescription.fromJson(sessionDescription);
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Local session description ({0}):\r\n{1}", fm.icelink.StringExtensions.toLower(new fm.icelink.SessionDescriptionTypeWrapper(localDescription.getType()).toString()), localDescription.getSdpMessage().toString()));
                            for (var _i = 0, _a = _this._onLocalDescriptionValues; _i < _a.length; _i++) {
                                var onLocalDescriptionValue = _a[_i];
                                onLocalDescriptionValue(_this, localDescription);
                            }
                        }, 1);
                    });
                    _this._axo.SetOnRemoteCandidate(function (candidate) {
                        setTimeout(function () {
                            var remoteCandidate = fm.icelink.Candidate.fromJson(candidate);
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Remote candidate for stream {0}:\r\n{1}", fm.icelink.NumberExtensions.toString(remoteCandidate.getSdpMediaIndex()), remoteCandidate.getSdpCandidateAttribute().toString()));
                            for (var _i = 0, _a = _this._onRemoteCandidateValues; _i < _a.length; _i++) {
                                var onRemoteCandidateValue = _a[_i];
                                onRemoteCandidateValue(_this, remoteCandidate);
                            }
                        }, 1);
                    });
                    _this._axo.SetOnRemoteDescription(function (sessionDescription) {
                        setTimeout(function () {
                            var remoteDescription = fm.icelink.SessionDescription.fromJson(sessionDescription);
                            fm.icelink.Log.debug(fm.icelink.StringExtensions.format("Remote session description ({0}):\r\n{1}", fm.icelink.StringExtensions.toLower(new fm.icelink.SessionDescriptionTypeWrapper(remoteDescription.getType()).toString()), remoteDescription.getSdpMessage().toString()));
                            for (var _i = 0, _a = _this._onRemoteDescriptionValues; _i < _a.length; _i++) {
                                var onRemoteDescriptionValue = _a[_i];
                                onRemoteDescriptionValue(_this, remoteDescription);
                            }
                        }, 1);
                    });
                    _this._axo.SetOnSignallingStateChange(function (signallingState) {
                        _this._signallingState = signallingState;
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onSignallingStateChangeValues; _i < _a.length; _i++) {
                                var onSignallingStateChangeValue = _a[_i];
                                onSignallingStateChangeValue(_this);
                            }
                        }, 1);
                    });
                    _this._axo.SetOnStateChange(function (state) {
                        _this._state = state;
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onStateChangeValues; _i < _a.length; _i++) {
                                var onStateChangeValue = _a[_i];
                                onStateChangeValue(_this);
                            }
                        }, 1);
                    });
                    _this._axo.SetOnExternalIdChange(function (id1, id2) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onExternalIdChangeValues; _i < _a.length; _i++) {
                                var onExternalIdChangeValue = _a[_i];
                                onExternalIdChangeValue(id1, id2);
                            }
                        }, 1);
                    });
                    return _this;
                }
                PluginConnection.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginConnection]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginConnection.prototype._getExternal = function () {
                    return this._external;
                };
                PluginConnection.prototype._getAxo = function () {
                    return this._axo;
                };
                PluginConnection.prototype.addIceServer = function (iceServer) {
                    this._getAxo().AddIceServer(fm.icelink.IceServer.toJson(iceServer));
                };
                PluginConnection.prototype.addIceServers = function (iceServers) {
                    this._getAxo().AddIceServers(fm.icelink.IceServer.toJsonArray(iceServers));
                };
                PluginConnection.prototype.addOnLocalCandidate = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onLocalCandidateValues, value);
                };
                PluginConnection.prototype.addOnExternalIdChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onExternalIdChangeValues, value);
                };
                PluginConnection.prototype.addOnIceConnectionStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onIceConnectionStateChangeValues, value);
                };
                PluginConnection.prototype.addOnGatheringStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onGatheringStateChangeValues, value);
                };
                PluginConnection.prototype.addOnLocalDescription = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onLocalDescriptionValues, value);
                };
                PluginConnection.prototype.addOnRemoteCandidate = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onRemoteCandidateValues, value);
                };
                PluginConnection.prototype.addOnRemoteDescription = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onRemoteDescriptionValues, value);
                };
                PluginConnection.prototype.addOnSignallingStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onSignallingStateChangeValues, value);
                };
                PluginConnection.prototype.addOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onStateChangeValues, value);
                };
                PluginConnection.prototype.addRemoteCandidate = function (remoteCandidate) {
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    innerPromise.then(function (remoteCandidateJson) {
                        promise.resolve(fm.icelink.Candidate.fromJson(remoteCandidateJson));
                    }, function (error) {
                        promise.reject(new fm.icelink.Exception(error));
                    });
                    this._getAxo().AddRemoteCandidate(fm.icelink.Candidate.toJson(remoteCandidate), innerPromise);
                    return promise;
                };
                PluginConnection.prototype.close = function () {
                    return this._getAxo().Close();
                };
                PluginConnection.prototype.createAnswer = function () {
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    innerPromise.then(function (answerJson) {
                        promise.resolve(fm.icelink.SessionDescription.fromJson(answerJson));
                    }, function (error) {
                        promise.reject(new fm.icelink.Exception(error));
                    });
                    this._getAxo().CreateAnswer(innerPromise);
                    return promise;
                };
                PluginConnection.prototype.createOffer = function () {
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    innerPromise.then(function (offerJson) {
                        promise.resolve(fm.icelink.SessionDescription.fromJson(offerJson));
                    }, function (error) {
                        promise.reject(new fm.icelink.Exception(error));
                    });
                    this._getAxo().CreateOffer(innerPromise);
                    return promise;
                };
                PluginConnection.prototype.getHasAudio = function () {
                    return (this.getAudioStream() != null);
                };
                PluginConnection.prototype.getHasVideo = function () {
                    return (this.getVideoStream() != null);
                };
                PluginConnection.prototype.getHasData = function () {
                    return (this.getDataStream() != null);
                };
                PluginConnection.prototype.getAudioStream = function () {
                    return fm.icelink.Utility.firstOrDefault(this.getAudioStreams());
                };
                PluginConnection.prototype.getAudioStreams = function () {
                    var streams = [];
                    for (var _i = 0, _a = this._streams; _i < _a.length; _i++) {
                        var stream = _a[_i];
                        if (stream.getType() == fm.icelink.StreamType.Audio) {
                            streams.push(stream);
                        }
                    }
                    return streams;
                };
                PluginConnection.prototype.getVideoStream = function () {
                    return fm.icelink.Utility.firstOrDefault(this.getVideoStreams());
                };
                PluginConnection.prototype.getVideoStreams = function () {
                    var streams = [];
                    for (var _i = 0, _a = this._streams; _i < _a.length; _i++) {
                        var stream = _a[_i];
                        if (stream.getType() == fm.icelink.StreamType.Video) {
                            streams.push(stream);
                        }
                    }
                    return streams;
                };
                PluginConnection.prototype.getDataStream = function () {
                    return fm.icelink.Utility.firstOrDefault(this.getDataStreams());
                };
                PluginConnection.prototype.getDataStreams = function () {
                    var streams = [];
                    for (var _i = 0, _a = this._streams; _i < _a.length; _i++) {
                        var stream = _a[_i];
                        if (stream.getType() == fm.icelink.StreamType.Application) {
                            streams.push(stream);
                        }
                    }
                    return streams;
                };
                PluginConnection.prototype.getDeadStreamTimeout = function () {
                    return this._getAxo().GetDeadStreamTimeout();
                };
                PluginConnection.prototype.getExternalId = function () {
                    return this._getAxo().GetExternalId();
                };
                PluginConnection.prototype.getError = function () {
                    return fm.icelink.Error.fromJson(this._getAxo().GetError());
                };
                PluginConnection.prototype.getIceGatherPolicy = function () {
                    return this._getAxo().GetIceGatherPolicy();
                };
                PluginConnection.prototype.getBundlePolicy = function () {
                    return this._getAxo().GetBundlePolicy();
                };
                PluginConnection.prototype.getIceServer = function () {
                    return fm.icelink.IceServer.fromJson(this._getAxo().GetIceServer());
                };
                PluginConnection.prototype.getIceServers = function () {
                    return fm.icelink.IceServer.fromJsonArray(this._getAxo().GetIceServers());
                };
                PluginConnection.prototype.getId = function () {
                    return this._getAxo().GetId();
                };
                PluginConnection.prototype.getCanonicalName = function () {
                    return this._getAxo().GetCanonicalName();
                };
                PluginConnection.prototype.getLocalDescription = function () {
                    return fm.icelink.SessionDescription.fromJson(this._getAxo().GetLocalDescription());
                };
                PluginConnection.prototype.getRemoteDescription = function () {
                    return fm.icelink.SessionDescription.fromJson(this._getAxo().GetRemoteDescription());
                };
                PluginConnection.prototype.getSignallingState = function () {
                    return this._signallingState;
                };
                PluginConnection.prototype.getState = function () {
                    return this._state;
                };
                PluginConnection.prototype.getStats = function () {
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    innerPromise.then(function (statsJson) {
                        promise.resolve(fm.icelink.ConnectionStats.fromJson(statsJson));
                    }, function (error) {
                        promise.reject(new fm.icelink.Exception(error));
                    });
                    this._getAxo().GetStats(innerPromise);
                    return promise;
                };
                PluginConnection.prototype.getStreams = function () {
                    return this._streams;
                };
                PluginConnection.prototype.getTieBreaker = function () {
                    return this._getAxo().GetTieBreaker();
                };
                PluginConnection.prototype.getTimeout = function () {
                    return this._getAxo().GetTimeout();
                };
                PluginConnection.prototype.getLegacyTimeout = function () {
                    return this._getAxo().GetLegacyTimeout();
                };
                PluginConnection.prototype.getTrickleIcePolicy = function () {
                    return this._getAxo().GetTrickleIcePolicy();
                };
                PluginConnection.prototype.getIceConnectionState = function () {
                    return this._iceConnectionState;
                };
                PluginConnection.prototype.getGatheringState = function () {
                    return this._gatheringState;
                };
                PluginConnection.prototype.removeIceServer = function (iceServer) {
                    this._getAxo().RemoveIceServer(fm.icelink.IceServer.toJson(iceServer));
                };
                PluginConnection.prototype.removeIceServers = function (iceServers) {
                    this._getAxo().RemoveIceServers(fm.icelink.IceServer.toJsonArray(iceServers));
                };
                PluginConnection.prototype.removeOnLocalCandidate = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onLocalCandidateValues, value);
                };
                PluginConnection.prototype.removeOnIceConnectionStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onIceConnectionStateChangeValues, value);
                };
                PluginConnection.prototype.removeOnExternalIdChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onExternalIdChangeValues, value);
                };
                PluginConnection.prototype.removeOnGatheringStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onGatheringStateChangeValues, value);
                };
                PluginConnection.prototype.removeOnLocalDescription = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onLocalDescriptionValues, value);
                };
                PluginConnection.prototype.removeOnRemoteCandidate = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onRemoteCandidateValues, value);
                };
                PluginConnection.prototype.removeOnRemoteDescription = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onRemoteDescriptionValues, value);
                };
                PluginConnection.prototype.removeOnSignallingStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onSignallingStateChangeValues, value);
                };
                PluginConnection.prototype.removeOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onStateChangeValues, value);
                };
                PluginConnection.prototype.setDeadStreamTimeout = function (value) {
                    this._getAxo().SetDeadStreamTimeout(value);
                };
                PluginConnection.prototype.setExternalId = function (value) {
                    this._getAxo().SetExternalId(value);
                };
                PluginConnection.prototype.setError = function (value) {
                    this._getAxo().SetError(fm.icelink.Error.toJson(value));
                };
                PluginConnection.prototype.setIceGatherPolicy = function (value) {
                    this._getAxo().SetIceGatherPolicy(value);
                };
                PluginConnection.prototype.setBundlePolicy = function (value) {
                    this._getAxo().SetBundlePolicy(value);
                };
                PluginConnection.prototype.setIceServer = function (value) {
                    this._getAxo().SetIceServer(fm.icelink.IceServer.toJson(value));
                };
                PluginConnection.prototype.setIceServers = function (value) {
                    this._getAxo().SetIceServers(fm.icelink.IceServer.toJsonArray(value));
                };
                PluginConnection.prototype.setLegacyTimeout = function (value) {
                    this._getAxo().SetLegacyTimeout(value);
                };
                PluginConnection.prototype.setTieBreaker = function (value) {
                    this._getAxo().SetTieBreaker(value);
                };
                PluginConnection.prototype.setLocalDescription = function (localDescription) {
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    innerPromise.then(function (localDescriptionJson) {
                        promise.resolve(fm.icelink.SessionDescription.fromJson(localDescriptionJson));
                    }, function (error) {
                        promise.reject(new fm.icelink.Exception(error));
                    });
                    this._getAxo().SetLocalDescription(fm.icelink.SessionDescription.toJson(localDescription), innerPromise);
                    return promise;
                };
                PluginConnection.prototype.setRemoteDescription = function (remoteDescription) {
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    innerPromise.then(function (remoteDescriptionJson) {
                        promise.resolve(fm.icelink.SessionDescription.fromJson(remoteDescriptionJson));
                    }, function (error) {
                        promise.reject(new fm.icelink.Exception(error));
                    });
                    this._getAxo().SetRemoteDescription(fm.icelink.SessionDescription.toJson(remoteDescription), innerPromise);
                    return promise;
                };
                PluginConnection.prototype.setTimeout = function (value) {
                    this._getAxo().SetTimeout(value);
                };
                PluginConnection.prototype.setTrickleIcePolicy = function (value) {
                    this._getAxo().SetTrickleIcePolicy(value);
                };
                return PluginConnection;
            }(fm.icelink.Dynamic));
            icelink.PluginConnection = PluginConnection;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginDataChannel =  (function (_super) {
                __extends(PluginDataChannel, _super);
                function PluginDataChannel(external, label, ordered, subprotocol) {
                    var _this = _super.call(this) || this;
                    _this._onStateChangeValues = [];
                    _this._onReceive = null;
                    _this._state = fm.icelink.DataChannelState.New;
                    _this._getRemoteConnectionInfo = null;
                    _this._external = external;
                    _this._axo = new ActiveXObject("fm.icelink.DataChannel");
                    _this._axo.Initialize(label, ordered, subprotocol);
                    _this._axo.SetOnStateChange(function (state) {
                        _this._state = state;
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onStateChangeValues; _i < _a.length; _i++) {
                                var onStateChangeValue = _a[_i];
                                onStateChangeValue(_this);
                            }
                        }, 1);
                    });
                    _this._axo.SetOnReceive(function (data, connectionId, isByte) {
                        setTimeout(function () {
                            var e = new fm.icelink.DataChannelReceiveArgs();
                            if (isByte) {
                                e.setDataBytes(fm.icelink.DataBuffer.wrap(fm.icelink.Base64.decode(data)));
                            }
                            else {
                                e.setDataString(data);
                            }
                            if (connectionId != null && _this._getRemoteConnectionInfo != null) {
                                e.setRemoteConnectionInfo(_this._getRemoteConnectionInfo(connectionId));
                            }
                            if (_this._onReceive) {
                                _this._onReceive(e);
                            }
                        }, 1);
                    });
                    return _this;
                }
                PluginDataChannel.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginDataChannel]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginDataChannel.prototype._getExternal = function () {
                    return this._external;
                };
                PluginDataChannel.prototype._getAxo = function () {
                    return this._axo;
                };
                PluginDataChannel.prototype.getHandle = function () {
                    return this._axo.GetHandle();
                };
                PluginDataChannel.prototype.setGetRemoteConnectionInfo = function (value) {
                    this._getRemoteConnectionInfo = value;
                };
                PluginDataChannel.prototype.getInfo = function () {
                    return fm.icelink.DataChannelInfo.fromJson(this._getAxo().GetInfo());
                };
                PluginDataChannel.prototype.addOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onStateChangeValues, value);
                };
                PluginDataChannel.prototype.getLabel = function () {
                    return this._getAxo().GetLabel();
                };
                PluginDataChannel.prototype.getOnReceive = function () {
                    return this._onReceive;
                };
                PluginDataChannel.prototype.getOrdered = function () {
                    return this._getAxo().GetOrdered();
                };
                PluginDataChannel.prototype.getId = function () {
                    return this._getAxo().GetId();
                };
                PluginDataChannel.prototype.getState = function () {
                    return this._state;
                };
                PluginDataChannel.prototype.getSubprotocol = function () {
                    return this._getAxo().GetSubprotocol();
                };
                PluginDataChannel.prototype.removeOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onStateChangeValues, value);
                };
                PluginDataChannel.prototype.sendDataBytes = function (dataBytes) {
                    var promise = new fm.icelink.Promise();
                    var strDataBytes = fm.icelink.Base64.encodeBuffer(dataBytes);
                    this._getAxo().PrepareAndSendBytes(strDataBytes, promise);
                    return promise;
                };
                PluginDataChannel.prototype.sendDataString = function (dataString) {
                    var promise = new fm.icelink.Promise();
                    this._getAxo().PrepareAndSendString(dataString, promise);
                    return promise;
                };
                PluginDataChannel.prototype.setOnReceive = function (value) {
                    this._onReceive = value;
                };
                return PluginDataChannel;
            }(fm.icelink.Dynamic));
            icelink.PluginDataChannel = PluginDataChannel;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginDataStream =  (function (_super) {
                __extends(PluginDataStream, _super);
                function PluginDataStream(external, channels) {
                    var _this = _super.call(this) || this;
                    _this._onDirectionChangeValues = [];
                    _this._onStateChangeValues = [];
                    _this._state = fm.icelink.StreamState.New;
                    _this._external = external;
                    _this._channels = channels;
                    _this._axo = new ActiveXObject("fm.icelink.DataStream");
                    _this._axo.Initialize(fm.icelink.ArrayExtensions.map(channels, function (channel) {
                        return channel.getHandle();
                    }));
                    _this._axo.SetOnDirectionChange(function () {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onDirectionChangeValues; _i < _a.length; _i++) {
                                var onDirectionChangeValue = _a[_i];
                                onDirectionChangeValue();
                            }
                        }, 1);
                    });
                    _this._axo.SetOnStateChange(function (state) {
                        _this._state = state;
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onStateChangeValues; _i < _a.length; _i++) {
                                var onStateChangeValue = _a[_i];
                                onStateChangeValue();
                            }
                        }, 1);
                    });
                    return _this;
                }
                PluginDataStream.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginDataStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginDataStream.prototype._getExternal = function () {
                    return this._external;
                };
                PluginDataStream.prototype._getAxo = function () {
                    return this._axo;
                };
                PluginDataStream.prototype.getState = function () {
                    return this._state;
                };
                PluginDataStream.prototype.addOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onStateChangeValues, value);
                };
                PluginDataStream.prototype.removeOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onStateChangeValues, value);
                };
                PluginDataStream.prototype.getInfo = function () {
                    return fm.icelink.DataStreamInfo.fromJson(this._getAxo().GetInfo());
                };
                PluginDataStream.prototype.getLocalReceive = function () {
                    return this._getAxo().GetLocalReceive();
                };
                PluginDataStream.prototype.getLocalSend = function () {
                    return this._getAxo().GetLocalSend();
                };
                PluginDataStream.prototype.getRemoteReceive = function () {
                    return this._getAxo().GetRemoteReceive();
                };
                PluginDataStream.prototype.getRemoteSend = function () {
                    return this._getAxo().GetRemoteSend();
                };
                PluginDataStream.prototype.setLocalReceive = function (value) {
                    return this._getAxo().SetLocalReceive(value);
                };
                PluginDataStream.prototype.setLocalSend = function (value) {
                    return this._getAxo().SetLocalSend(value);
                };
                PluginDataStream.prototype.getRemoteDirection = function () {
                    return this._getAxo().GetRemoteDirection();
                };
                PluginDataStream.prototype.getHandle = function () {
                    return this._getAxo().GetHandle();
                };
                PluginDataStream.prototype.changeDirection = function (newDirection) {
                    return fm.icelink.Error.fromJson(this._getAxo().ChangeDirection(newDirection));
                };
                PluginDataStream.prototype.getDirection = function () {
                    return this._getAxo().GetDirection();
                };
                PluginDataStream.prototype.getId = function () {
                    return this._getAxo().GetId();
                };
                PluginDataStream.prototype.getExternalId = function () {
                    return this._getAxo().GetExternalId();
                };
                PluginDataStream.prototype.setExternalId = function (value) {
                    this._getAxo().SetExternalId(value);
                };
                PluginDataStream.prototype.getLabel = function () {
                    return this._getAxo().GetLabel();
                };
                PluginDataStream.prototype.getLocalDirection = function () {
                    return this._getAxo().GetLocalDirection();
                };
                PluginDataStream.prototype.getMediaDescriptionId = function () {
                    return this._getAxo().GetMediaDescriptionId();
                };
                PluginDataStream.prototype.getTag = function () {
                    return this._getAxo().GetTag();
                };
                PluginDataStream.prototype.getType = function () {
                    return fm.icelink.StreamType.Application;
                };
                PluginDataStream.prototype.setLocalDirection = function (value) {
                    this._getAxo().SetLocalDirection(value);
                };
                PluginDataStream.prototype.setTag = function (value) {
                    this._getAxo().SetTag(value);
                };
                PluginDataStream.prototype.addOnDirectionChange = function (callback) {
                    fm.icelink.ArrayExtensions.add(this._onDirectionChangeValues, callback);
                };
                PluginDataStream.prototype.removeOnDirectionChange = function (callback) {
                    fm.icelink.ArrayExtensions.remove(this._onDirectionChangeValues, callback);
                };
                PluginDataStream.prototype.getChannels = function () {
                    return this._channels;
                };
                PluginDataStream.prototype.getTransportInfo = function () {
                    return fm.icelink.TransportInfo.fromJson(this._getAxo().GetTransportInfo());
                };
                PluginDataStream.prototype.setGetRemoteConnectionInfo = function (value) {
                    if (arguments.length == 1) {
                        for (var _i = 0, _a = this.getChannels(); _i < _a.length; _i++) {
                            var local = _a[_i];
                            local.setGetRemoteConnectionInfo(value);
                        }
                    }
                    else {
                        throw new fm.icelink.Exception('Method overload does not exist with specified parameter count/type combination.');
                    }
                };
                return PluginDataStream;
            }(fm.icelink.PluginStream));
            icelink.PluginDataStream = PluginDataStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginDomAudioSink =  (function (_super) {
                __extends(PluginDomAudioSink, _super);
                function PluginDomAudioSink(external, track) {
                    var _this = _super.call(this) || this;
                    _this._external = external;
                    _this.setTrack(track);
                    return _this;
                }
                PluginDomAudioSink.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginDomAudioSink]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginDomAudioSink.prototype._getExternal = function () {
                    return this._external;
                };
                PluginDomAudioSink.prototype.getTrack = function () {
                    return this._track;
                };
                PluginDomAudioSink.prototype.getLocal = function () {
                    return this._local;
                };
                PluginDomAudioSink.prototype.getAudio = function () {
                    return null;
                };
                PluginDomAudioSink.prototype.setTrack = function (track) {
                    if (!track) {
                        return false;
                    }
                    this._track = track;
                    this._local = fm.icelink.Util.isObjectType(track.getMedia(), '[fm.icelink.PluginLocalMedia]');
                    return true;
                };
                return PluginDomAudioSink;
            }(fm.icelink.Dynamic));
            icelink.PluginDomAudioSink = PluginDomAudioSink;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginDomVideoSink =  (function (_super) {
                __extends(PluginDomVideoSink, _super);
                function PluginDomVideoSink(external, track) {
                    var _this = _super.call(this) || this;
                    _this._axoLoaded = false;
                    _this._external = external;
                    _this.setTrack(track);
                    return _this;
                }
                PluginDomVideoSink.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginDomVideoSink]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginDomVideoSink.prototype._getExternal = function () {
                    return this._external;
                };
                PluginDomVideoSink.prototype._getAxo = function () {
                    return this._axo;
                };
                PluginDomVideoSink.prototype.getTrack = function () {
                    return this._track;
                };
                PluginDomVideoSink.prototype.getLocal = function () {
                    return this._local;
                };
                PluginDomVideoSink.prototype.getVideo = function () {
                    return null;
                };
                PluginDomVideoSink.prototype.getView = function () {
                    return this._container;
                };
                PluginDomVideoSink.prototype.getViewScale = function () {
                    if (this._axoLoaded) {
                        return this._axo.GetViewScale();
                    }
                    return fm.icelink.LayoutScale.Contain;
                };
                PluginDomVideoSink.prototype.setViewScale = function (viewScale) {
                    if (this._axoLoaded) {
                        this._axo.SetViewScale(viewScale);
                    }
                };
                PluginDomVideoSink.prototype.getVideoWidth = function () {
                    if (this._axoLoaded) {
                        return this._axo.GetWidth();
                    }
                    return 0;
                };
                PluginDomVideoSink.prototype.getVideoHeight = function () {
                    if (this._axoLoaded) {
                        return this._axo.GetHeight();
                    }
                    return 0;
                };
                PluginDomVideoSink.prototype.getViewMirror = function () {
                    if (this._axoLoaded) {
                        return this._axo.GetViewMirror();
                    }
                    return false;
                };
                PluginDomVideoSink.prototype.setViewMirror = function (viewMirror) {
                    if (this._axoLoaded) {
                        this._axo.SetViewMirror(viewMirror);
                    }
                };
                PluginDomVideoSink.prototype.setTrack = function (track) {
                    var _this = this;
                    if (!track) {
                        return false;
                    }
                    this._track = track;
                    this._local = fm.icelink.Util.isObjectType(track.getMedia(), '[fm.icelink.PluginLocalMedia]');
                    this._container = document.createElement('div');
                    if (this._local) {
                        this._container.className = 'fm-video fm-video-local';
                    }
                    else {
                        this._container.className = 'fm-video fm-video-remote';
                    }
                    this._underlay = document.createElement('iframe');
                    this._underlay.src = 'about:blank';
                    this._underlay.setAttribute('allowTransparency', 'true');
                    this._underlay.setAttribute('frameBorder', '0');
                    this._underlay.style.border = '0';
                    this._underlay.style.backgroundColor = '#000';
                    this._underlay.style.position = 'absolute';
                    this._underlay.style.top = '0';
                    this._underlay.style.left = '0';
                    this._underlay.style.width = '100%';
                    this._underlay.style.height = '100%';
                    this._container.appendChild(this._underlay);
                    this._axo = document.createElement('object');
                    this._axo.id = fm.icelink.Guid.newGuid().toString();
                    this._axo.setAttribute('codebase', fm.icelink.Plugin.getPluginConfig().getActiveXPath());
                    this._axo.setAttribute('CLASSID', 'clsid:' + fm.icelink.PluginConstants.getDomVideoSinkClassId());
                    this._axo.style.position = 'absolute';
                    this._axo.style.top = '0';
                    this._axo.style.left = '0';
                    this._axo.style.width = '100%';
                    this._axo.style.height = '100%';
                    window.setTimeout(function () {
                        _this._container.appendChild(_this._axo);
                    }, 1);
                    return this.checkifLoaded(this._axo);
                };
                PluginDomVideoSink.prototype.checkifLoaded = function (object) {
                    var _this = this;
                    var loaded = false;
                    try {
                        if (!fm.icelink.Util.isNullOrUndefined(object.GetIsLoaded)) {
                            loaded = object.GetIsLoaded();
                        }
                    }
                    catch (ex) {
                        loaded = false;
                    }
                    if (loaded) {
                        this._axoLoaded = true;
                        this.setViewScale(fm.icelink.LayoutScale.Contain);
                        return true;
                    }
                    else {
                        window.setTimeout(function () {
                            _this.checkifLoaded(object);
                        }, 10);
                    }
                };
                return PluginDomVideoSink;
            }(fm.icelink.Dynamic));
            icelink.PluginDomVideoSink = PluginDomVideoSink;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginMedia =  (function (_super) {
                __extends(PluginMedia, _super);
                function PluginMedia(external) {
                    var _this = _super.call(this) || this;
                    _this._onAudioLevelValues = [];
                    _this._onVideoSizeValues = [];
                    _this._audioTrack = null;
                    _this._videoTrack = null;
                    _this._videoSink = null;
                    var externalAudioTrack = new fm.icelink.AudioTrack(external, _this);
                    var externalVideoTrack = new fm.icelink.VideoTrack(external, _this);
                    var externalVideoSink = new fm.icelink.DomVideoSink(externalVideoTrack);
                    _this._audioTrack = externalAudioTrack._getInternal();
                    _this._videoTrack = externalVideoTrack._getInternal();
                    _this._videoSink = externalVideoSink._getInternal();
                    return _this;
                }
                PluginMedia.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginMedia]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginMedia.prototype.getHandle = function () {
                    return this._getAxo().GetHandle();
                };
                PluginMedia.prototype.destroy = function () {
                    this._getAxo().Destroy();
                };
                PluginMedia.prototype.addOnAudioLevel = function (value) {
                    var _this = this;
                    fm.icelink.ArrayExtensions.add(this._onAudioLevelValues, value);
                    if (this._onAudioLevelValues.length == 1) {
                        this._getAxo().SetOnAudioLevel(function (level) {
                            for (var _i = 0, _a = _this._onAudioLevelValues; _i < _a.length; _i++) {
                                var onAudioLevelValue = _a[_i];
                                onAudioLevelValue(level);
                            }
                        });
                    }
                };
                PluginMedia.prototype.addOnVideoSize = function (value) {
                    var _this = this;
                    fm.icelink.ArrayExtensions.add(this._onVideoSizeValues, value);
                    if (this._onVideoSizeValues.length == 1) {
                        this._getAxo().SetOnVideoSize(function (sizeJson) {
                            var size = fm.icelink.Size.fromJson(sizeJson);
                            for (var _i = 0, _a = _this._onVideoSizeValues; _i < _a.length; _i++) {
                                var onVideoSizeValue = _a[_i];
                                onVideoSizeValue(size);
                            }
                        });
                    }
                };
                PluginMedia.prototype.getAudioGain = function () {
                    return this._getAxo().GetAudioGain();
                };
                PluginMedia.prototype.getAudioMuted = function () {
                    return this._getAxo().GetAudioMuted();
                };
                PluginMedia.prototype.getAudioTrack = function () {
                    if (!this._audio) {
                        return null;
                    }
                    return this._audioTrack;
                };
                PluginMedia.prototype.getAudioTracks = function () {
                    if (!this._audio) {
                        return [];
                    }
                    return [this.getAudioTrack()];
                };
                PluginMedia.prototype.getAudioVolume = function () {
                    return this._getAxo().GetAudioVolume();
                };
                PluginMedia.prototype.getId = function () {
                    return this._getAxo().GetId();
                };
                PluginMedia.prototype.getVideoMuted = function () {
                    return this._getAxo().GetVideoMuted();
                };
                PluginMedia.prototype.getVideoSize = function () {
                    return fm.icelink.Size.fromJson(this._getAxo().GetVideoSize());
                };
                PluginMedia.prototype.getVideoTrack = function () {
                    if (!this._video) {
                        return null;
                    }
                    return this._videoTrack;
                };
                PluginMedia.prototype.getVideoTracks = function () {
                    if (!this._video) {
                        return [];
                    }
                    return [this.getVideoTrack()];
                };
                PluginMedia.prototype.grabVideoFrame = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    innerPromise.then(function (videoBufferJson) {
                        promise.resolve(fm.icelink.VideoBuffer.fromJson(videoBufferJson));
                    }, function (error) {
                        promise.reject(new fm.icelink.Exception(error));
                    });
                    window.setTimeout(function () {
                        _this._getAxo().GrabVideoFrame(innerPromise);
                    }, 1);
                    return promise;
                };
                PluginMedia.prototype.removeOnAudioLevel = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onAudioLevelValues, value);
                    if (this._onAudioLevelValues.length == 0) {
                        this._getAxo().SetOnAudioLevel(null);
                    }
                };
                PluginMedia.prototype.removeOnVideoSize = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onVideoSizeValues, value);
                    if (this._onVideoSizeValues.length == 0) {
                        this._getAxo().SetOnVideoSize(null);
                    }
                };
                PluginMedia.prototype.setAudioGain = function (value) {
                    this._getAxo().SetAudioGain(value);
                };
                PluginMedia.prototype.setAudioMuted = function (value) {
                    this._getAxo().SetAudioMuted(value);
                };
                PluginMedia.prototype.setAudioVolume = function (value) {
                    this._getAxo().SetAudioVolume(value);
                };
                PluginMedia.prototype.setId = function (value) {
                    return this._getAxo().SetId(value);
                };
                PluginMedia.prototype.setVideoMuted = function (value) {
                    this._getAxo().SetVideoMuted(value);
                };
                PluginMedia.prototype.getAudioSink = function () {
                    if (!this._audio) {
                        return null;
                    }
                    return null;
                };
                PluginMedia.prototype.getVideoSink = function () {
                    if (!this._video) {
                        return null;
                    }
                    return this._videoSink;
                };
                PluginMedia.prototype.getView = function () {
                    if (!this._video) {
                        return null;
                    }
                    return this._videoSink.getView();
                };
                PluginMedia.prototype.getViewSink = function () {
                    if (!this._video) {
                        return null;
                    }
                    return this._videoSink;
                };
                PluginMedia.prototype.getAudio = function () {
                    return this._audio;
                };
                PluginMedia.prototype.setAudio = function (audio) {
                    this._audio = audio;
                };
                PluginMedia.prototype.getVideo = function () {
                    return this._video;
                };
                PluginMedia.prototype.setVideo = function (video) {
                    this._video = video;
                };
                return PluginMedia;
            }(fm.icelink.Dynamic));
            icelink.PluginMedia = PluginMedia;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginLocalMedia =  (function (_super) {
                __extends(PluginLocalMedia, _super);
                function PluginLocalMedia(external, audio, video, screen) {
                    var _this = _super.call(this, external) || this;
                    _this._onAudioStartedValues = [];
                    _this._onVideoStartedValues = [];
                    _this._onAudioStoppedValues = [];
                    _this._onVideoStoppedValues = [];
                    _this._onAudioDestroyedValues = [];
                    _this._onVideoDestroyedValues = [];
                    _this._external = external;
                    _this._audio = audio;
                    _this._video = video;
                    _this._screen = fm.icelink.Util.isNullOrUndefined(screen) ? false : screen;
                    _this._axo = new ActiveXObject("fm.icelink.LocalMedia");
                    _this._axo.Initialize((audio === false), (video === false), _this._screen);
                    _this._axo.SetOnAudioStarted(function () {
                        for (var _i = 0, _a = _this._onAudioStartedValues; _i < _a.length; _i++) {
                            var onAudioStartedValue = _a[_i];
                            onAudioStartedValue();
                        }
                    });
                    _this._axo.SetOnVideoStarted(function () {
                        for (var _i = 0, _a = _this._onVideoStartedValues; _i < _a.length; _i++) {
                            var onVideoStartedValue = _a[_i];
                            onVideoStartedValue();
                        }
                    });
                    _this._axo.SetOnAudioStopped(function () {
                        for (var _i = 0, _a = _this._onAudioStoppedValues; _i < _a.length; _i++) {
                            var onAudioStoppedValue = _a[_i];
                            onAudioStoppedValue();
                        }
                    });
                    _this._axo.SetOnVideoStopped(function () {
                        for (var _i = 0, _a = _this._onVideoStoppedValues; _i < _a.length; _i++) {
                            var onVideoStoppedValue = _a[_i];
                            onVideoStoppedValue();
                        }
                    });
                    _this._axo.SetOnAudioDestroyed(function () {
                        for (var _i = 0, _a = _this._onAudioDestroyedValues; _i < _a.length; _i++) {
                            var onAudioDestroyedValue = _a[_i];
                            onAudioDestroyedValue();
                        }
                    });
                    _this._axo.SetOnVideoDestroyed(function () {
                        for (var _i = 0, _a = _this._onVideoDestroyedValues; _i < _a.length; _i++) {
                            var onVideoDestroyedValue = _a[_i];
                            onVideoDestroyedValue();
                        }
                    });
                    if (video) {
                        _this.checkifLoaded(_this._axo);
                    }
                    return _this;
                }
                PluginLocalMedia.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginLocalMedia]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginLocalMedia.prototype._getExternal = function () {
                    return this._external;
                };
                PluginLocalMedia.prototype._getAxo = function () {
                    return this._axo;
                };
                PluginLocalMedia.prototype.getScreen = function () {
                    return this._screen;
                };
                PluginLocalMedia.prototype.setScreen = function (screen) {
                    this._screen = screen;
                };
                PluginLocalMedia.prototype.getState = function () {
                    return this._axo.GetState();
                };
                PluginLocalMedia.prototype.start = function () {
                    var _this = this;
                    if (!this.unloadHandler) {
                        this.unloadHandler = function (evt) {
                            _this._axo.Stop(new fm.icelink.Promise());
                        };
                    }
                    var promise = new fm.icelink.Promise();
                    window.setTimeout(function () {
                        _this._axo.Start(promise);
                        fm.icelink.Util.observe(window, 'unload', _this.unloadHandler);
                    }, 1);
                    return promise;
                };
                PluginLocalMedia.prototype.stop = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    window.setTimeout(function () {
                        fm.icelink.Util.unobserve(window, 'unload', _this.unloadHandler);
                        _this._axo.Stop(promise);
                    }, 1);
                    return promise;
                };
                PluginLocalMedia.prototype.getHandle = function () {
                    return this._getAxo().GetHandle();
                };
                PluginLocalMedia.prototype.addOnAudioStarted = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onAudioStartedValues, value);
                };
                PluginLocalMedia.prototype.addOnVideoStarted = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onVideoStartedValues, value);
                };
                PluginLocalMedia.prototype.addOnAudioStopped = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onAudioStoppedValues, value);
                };
                PluginLocalMedia.prototype.addOnVideoStopped = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onVideoStoppedValues, value);
                };
                PluginLocalMedia.prototype.addOnAudioDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onAudioDestroyedValues, value);
                };
                PluginLocalMedia.prototype.addOnVideoDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onVideoDestroyedValues, value);
                };
                PluginLocalMedia.prototype.removeOnAudioStarted = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onAudioStartedValues, value);
                };
                PluginLocalMedia.prototype.removeOnVideoStarted = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onVideoStartedValues, value);
                };
                PluginLocalMedia.prototype.removeOnAudioStopped = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onAudioStoppedValues, value);
                };
                PluginLocalMedia.prototype.removeOnVideoStopped = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onVideoStoppedValues, value);
                };
                PluginLocalMedia.prototype.removeOnAudioDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onAudioDestroyedValues, value);
                };
                PluginLocalMedia.prototype.removeOnVideoDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onVideoDestroyedValues, value);
                };
                PluginLocalMedia.prototype.getAudioEncoding = function () {
                    return fm.icelink.AudioEncodingConfig.fromJson(this._getAxo().GetAudioEncoding());
                };
                PluginLocalMedia.prototype.getAudioEncodings = function () {
                    return fm.icelink.AudioEncodingConfig.fromJsonArray(this._getAxo().GetAudioEncodings());
                };
                PluginLocalMedia.prototype.setAudioEncodings = function (value) {
                    return this._getAxo().SetAudioEncodings(fm.icelink.AudioEncodingConfig.toJsonArray(value));
                };
                PluginLocalMedia.prototype.getVideoEncoding = function () {
                    return fm.icelink.VideoEncodingConfig.fromJson(this._getAxo().GetVideoEncoding());
                };
                PluginLocalMedia.prototype.getVideoEncodings = function () {
                    return fm.icelink.VideoEncodingConfig.fromJsonArray(this._getAxo().GetVideoEncodings());
                };
                PluginLocalMedia.prototype.setVideoEncodings = function (value) {
                    return this._getAxo().SetVideoEncodings(fm.icelink.VideoEncodingConfig.toJsonArray(value));
                };
                PluginLocalMedia.prototype.changeAudioSourceInput = function (audioSourceInput) {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    window.setTimeout(function () {
                        _this._getAxo().ChangeAudioSourceInput(promise, fm.icelink.SourceInput.toJson(audioSourceInput));
                    }, 1);
                    return promise;
                };
                PluginLocalMedia.prototype.changeVideoSourceInput = function (videoSourceInput) {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    window.setTimeout(function () {
                        _this._getAxo().ChangeVideoSourceInput(promise, fm.icelink.SourceInput.toJson(videoSourceInput));
                    }, 1);
                    return promise;
                };
                PluginLocalMedia.prototype.getAudioSourceInput = function () {
                    return fm.icelink.SourceInput.fromJson(this._getAxo().GetAudioSourceInput());
                };
                PluginLocalMedia.prototype.getAudioSourceInputs = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    window.setTimeout(function () {
                        _this._getAxo().GetAudioSourceInputs(innerPromise);
                    }, 1);
                    innerPromise.then(function (sourceInputsJson) {
                        promise.resolve(fm.icelink.SourceInput.fromJsonArray(sourceInputsJson));
                    });
                    return promise;
                };
                PluginLocalMedia.prototype.getVideoSourceInput = function () {
                    return fm.icelink.SourceInput.fromJson(this._getAxo().GetVideoSourceInput());
                };
                PluginLocalMedia.prototype.getVideoSourceInputs = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    window.setTimeout(function () {
                        _this._getAxo().GetVideoSourceInputs(innerPromise);
                    }, 1);
                    innerPromise.then(function (sourceInputsJson) {
                        promise.resolve(fm.icelink.SourceInput.fromJsonArray(sourceInputsJson));
                    });
                    return promise;
                };
                PluginLocalMedia.prototype.setAudioSourceInput = function (value) {
                    this._getAxo().SetAudioSourceInput(fm.icelink.SourceInput.toJson(value));
                };
                PluginLocalMedia.prototype.setVideoSourceInput = function (value) {
                    this._getAxo().SetVideoSourceInput(fm.icelink.SourceInput.toJson(value));
                };
                PluginLocalMedia.prototype.destroy = function () {
                };
                PluginLocalMedia.prototype.getAudioGain = function () {
                    return this._getAxo().GetAudioGain();
                };
                PluginLocalMedia.prototype.getAudioMuted = function () {
                    return this._getAxo().GetAudioMuted();
                };
                PluginLocalMedia.prototype.getId = function () {
                    return this._getAxo().GetId();
                };
                PluginLocalMedia.prototype.getVideoMuted = function () {
                    return this._getAxo().GetVideoMuted();
                };
                PluginLocalMedia.prototype.setAudioGain = function (value) {
                    this._getAxo().SetAudioGain(value);
                };
                PluginLocalMedia.prototype.setAudioMuted = function (value) {
                    this._getAxo().SetAudioMuted(value);
                };
                PluginLocalMedia.prototype.setVideoMuted = function (value) {
                    this._getAxo().SetVideoMuted(value);
                };
                PluginLocalMedia.prototype.getAudioSimulcastDisabled = function () {
                    return this._getAxo().GetAudioSimulcastDisabled();
                };
                PluginLocalMedia.prototype.setAudioSimulcastDisabled = function (value) {
                    this._getAxo().SetAudioSimulcastDisabled(value);
                };
                PluginLocalMedia.prototype.getAudioSimulcastEncodingCount = function () {
                    return this._getAxo().GetAudioSimulcastEncodingCount();
                };
                PluginLocalMedia.prototype.setAudioSimulcastEncodingCount = function (value) {
                    this._getAxo().SetAudioSimulcastEncodingCount(value);
                };
                PluginLocalMedia.prototype.getAudioSimulcastPreferredBitrate = function () {
                    return this._getAxo().GetAudioSimulcastPreferredBitrate();
                };
                PluginLocalMedia.prototype.setAudioSimulcastPreferredBitrate = function (value) {
                    this._getAxo().SetAudioSimulcastPreferredBitrate(value);
                };
                PluginLocalMedia.prototype.getVideoSimulcastDisabled = function () {
                    return this._getAxo().GetVideoSimulcastDisabled();
                };
                PluginLocalMedia.prototype.setVideoSimulcastDisabled = function (value) {
                    this._getAxo().SetVideoSimulcastDisabled(value);
                };
                PluginLocalMedia.prototype.getVideoSimulcastEncodingCount = function () {
                    return this._getAxo().GetVideoSimulcastEncodingCount();
                };
                PluginLocalMedia.prototype.setVideoSimulcastEncodingCount = function (value) {
                    this._getAxo().SetVideoSimulcastEncodingCount(value);
                };
                PluginLocalMedia.prototype.getVideoSimulcastPreferredBitrate = function () {
                    return this._getAxo().GetVideoSimulcastPreferredBitrate();
                };
                PluginLocalMedia.prototype.setVideoSimulcastPreferredBitrate = function (value) {
                    this._getAxo().SetVideoSimulcastPreferredBitrate(value);
                };
                PluginLocalMedia.prototype.getVideoSimulcastBitsPerPixel = function () {
                    return this._getAxo().GetVideoSimulcastBitsPerPixel();
                };
                PluginLocalMedia.prototype.setVideoSimulcastBitsPerPixel = function (value) {
                    this._getAxo().SetVideoSimulcastBitsPerPixel(value);
                };
                PluginLocalMedia.prototype.getVideoSimulcastDegradationPreference = function () {
                    return this._getAxo().GetVideoSimulcastDegradationPreference();
                };
                PluginLocalMedia.prototype.setVideoSimulcastDegradationPreference = function (value) {
                    this._getAxo().SetVideoSimulcastDegradationPreference(value);
                };
                PluginLocalMedia.prototype.checkifLoaded = function (object) {
                    var _this = this;
                    var loaded = false;
                    try {
                        if (!fm.icelink.Util.isNullOrUndefined(this._videoSink._getAxo().GetIsLoaded)) {
                            loaded = this._videoSink._getAxo().GetIsLoaded();
                        }
                    }
                    catch (ex) {
                        loaded = false;
                    }
                    if (loaded) {
                        object.AttachView(this._videoSink._getAxo().GetHandle());
                    }
                    else {
                        window.setTimeout(function () {
                            _this.checkifLoaded(object);
                        }, 10);
                    }
                };
                return PluginLocalMedia;
            }(fm.icelink.PluginMedia));
            icelink.PluginLocalMedia = PluginLocalMedia;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginRemoteMedia =  (function (_super) {
                __extends(PluginRemoteMedia, _super);
                function PluginRemoteMedia(external, audio, video) {
                    var _this = _super.call(this, external) || this;
                    _this._onAudioDestroyedValues = [];
                    _this._onVideoDestroyedValues = [];
                    _this._external = external;
                    _this._audio = audio;
                    _this._video = video;
                    _this._axo = new ActiveXObject("fm.icelink.RemoteMedia");
                    _this._axo.Initialize(false, false);
                    _this._axo.SetOnAudioDestroyed(function () {
                        for (var _i = 0, _a = _this._onAudioDestroyedValues; _i < _a.length; _i++) {
                            var onAudioDestroyedValue = _a[_i];
                            onAudioDestroyedValue();
                        }
                    });
                    _this._axo.SetOnVideoDestroyed(function () {
                        for (var _i = 0, _a = _this._onVideoDestroyedValues; _i < _a.length; _i++) {
                            var onVideoDestroyedValue = _a[_i];
                            onVideoDestroyedValue();
                        }
                    });
                    _this.checkifLoaded(_this._axo);
                    return _this;
                }
                PluginRemoteMedia.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginRemoteMedia]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginRemoteMedia.prototype._getExternal = function () {
                    return this._external;
                };
                PluginRemoteMedia.prototype._getAxo = function () {
                    return this._axo;
                };
                PluginRemoteMedia.prototype.checkifLoaded = function (object) {
                    var _this = this;
                    var loaded = false;
                    try {
                        if (!fm.icelink.Util.isNullOrUndefined(this._videoSink._getAxo().GetIsLoaded)) {
                            loaded = this._videoSink._getAxo().GetIsLoaded();
                        }
                    }
                    catch (ex) {
                        loaded = false;
                    }
                    if (loaded) {
                        object.AttachView(this._videoSink._getAxo().GetHandle());
                    }
                    else {
                        window.setTimeout(function () {
                            _this.checkifLoaded(object);
                        }, 10);
                    }
                };
                PluginRemoteMedia.prototype.getHandle = function () {
                    return this._getAxo().GetHandle();
                };
                PluginRemoteMedia.prototype.addOnAudioDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onAudioDestroyedValues, value);
                };
                PluginRemoteMedia.prototype.addOnVideoDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onVideoDestroyedValues, value);
                };
                PluginRemoteMedia.prototype.removeOnAudioDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onAudioDestroyedValues, value);
                };
                PluginRemoteMedia.prototype.removeOnVideoDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onVideoDestroyedValues, value);
                };
                PluginRemoteMedia.prototype.changeAudioSinkOutput = function (audioSinkOutput) {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    window.setTimeout(function () {
                        _this._getAxo().ChangeAudioSinkOutput(promise, fm.icelink.SinkOutput.toJson(audioSinkOutput));
                    }, 1);
                    return promise;
                };
                PluginRemoteMedia.prototype.changeVideoSinkOutput = function (videoSinkOutput) {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    window.setTimeout(function () {
                        _this._getAxo().ChangeVideoSinkOutput(promise, fm.icelink.SinkOutput.toJson(videoSinkOutput));
                    }, 1);
                    return promise;
                };
                PluginRemoteMedia.prototype.getAudioSinkOutput = function () {
                    return fm.icelink.SinkOutput.fromJson(this._getAxo().GetAudioSinkOutput());
                };
                PluginRemoteMedia.prototype.getAudioSinkOutputs = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    window.setTimeout(function () {
                        _this._getAxo().GetAudioSinkOutputs(innerPromise);
                    }, 1);
                    innerPromise.then(function (sinkOutputsJson) {
                        promise.resolve(fm.icelink.SinkOutput.fromJsonArray(sinkOutputsJson));
                    });
                    return promise;
                };
                PluginRemoteMedia.prototype.getVideoSinkOutput = function () {
                    return fm.icelink.SinkOutput.fromJson(this._getAxo().GetVideoSinkOutput());
                };
                PluginRemoteMedia.prototype.getVideoSinkOutputs = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    var innerPromise = new fm.icelink.Promise();
                    window.setTimeout(function () {
                        _this._getAxo().GetVideoSinkOutputs(innerPromise);
                    }, 1);
                    innerPromise.then(function (sinkOutputsJson) {
                        promise.resolve(fm.icelink.SinkOutput.fromJsonArray(sinkOutputsJson));
                    });
                    return promise;
                };
                PluginRemoteMedia.prototype.setAudioSinkOutput = function (value) {
                    this._getAxo().SetAudioSinkOutput(fm.icelink.SinkOutput.toJson(value));
                };
                PluginRemoteMedia.prototype.setVideoSinkOutput = function (value) {
                    this._getAxo().SetVideoSinkOutput(fm.icelink.SinkOutput.toJson(value));
                };
                PluginRemoteMedia.prototype.destroy = function () {
                    return this._getAxo().Destroy();
                };
                PluginRemoteMedia.prototype.getAudioGain = function () {
                    return this._getAxo().GetAudioGain();
                };
                PluginRemoteMedia.prototype.getAudioMuted = function () {
                    return this._getAxo().GetAudioMuted();
                };
                PluginRemoteMedia.prototype.getId = function () {
                    return this._getAxo().GetId();
                };
                PluginRemoteMedia.prototype.getVideoMuted = function () {
                    return this._getAxo().GetVideoMuted();
                };
                PluginRemoteMedia.prototype.setAudioGain = function (value) {
                    this._getAxo().SetAudioGain(value);
                };
                PluginRemoteMedia.prototype.setAudioMuted = function (value) {
                    this._getAxo().SetAudioMuted(value);
                };
                PluginRemoteMedia.prototype.setVideoMuted = function (value) {
                    this._getAxo().SetVideoMuted(value);
                };
                return PluginRemoteMedia;
            }(fm.icelink.PluginMedia));
            icelink.PluginRemoteMedia = PluginRemoteMedia;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginVideoStream =  (function (_super) {
                __extends(PluginVideoStream, _super);
                function PluginVideoStream(external, localTrack, remoteTrack) {
                    var _this = _super.call(this, localTrack, remoteTrack) || this;
                    _this._onDirectionChangeValues = [];
                    _this._onStateChangeValues = [];
                    _this._onLocalEncodingDisabledValues = [];
                    _this._onLocalEncodingEnabledValues = [];
                    _this._onDiscardKeyFrameRequestValues = [];
                    _this._onDiscardBitrateRequestValues = [];
                    _this._onDiscardBitrateNotificationValues = [];
                    _this._state = fm.icelink.StreamState.New;
                    _this._external = external;
                    _this._axo = new ActiveXObject("fm.icelink.VideoStream");
                    _this._axo.Initialize(_this.getLocalTrack() == null ? 0 : _this.getLocalTrack().getMedia().getHandle(), remoteTrack == null ? 0 : remoteTrack.getMedia().getHandle());
                    _this._axo.SetOnDirectionChange(function () {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onDirectionChangeValues; _i < _a.length; _i++) {
                                var onDirectionChangeValue = _a[_i];
                                onDirectionChangeValue();
                            }
                        }, 1);
                    });
                    _this._axo.SetOnStateChange(function (state) {
                        _this._state = state;
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onStateChangeValues; _i < _a.length; _i++) {
                                var onStateChangeValue = _a[_i];
                                onStateChangeValue();
                            }
                        }, 1);
                    });
                    _this._axo.SetOnLocalEncodingDisabled(function (encodingJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onLocalEncodingDisabledValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.EncodingInfo.fromJson(encodingJson));
                            }
                        }, 1);
                    });
                    _this._axo.SetOnLocalEncodingEnabled(function (encodingJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onLocalEncodingEnabledValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.EncodingInfo.fromJson(encodingJson));
                            }
                        }, 1);
                    });
                    _this._axo.SetOnDiscardKeyFrameRequest(function (synchronizationSources) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onDiscardKeyFrameRequestValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(synchronizationSources);
                            }
                        }, 1);
                    });
                    _this._axo.SetOnDiscardBitrateRequest(function (bitrateRequestJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onDiscardBitrateRequestValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.BitrateRequest.fromJson(bitrateRequestJson));
                            }
                        }, 1);
                    });
                    _this._axo.SetOnDiscardBitrateNotification(function (bitrateNotificationJson) {
                        setTimeout(function () {
                            for (var _i = 0, _a = _this._onDiscardBitrateNotificationValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value(fm.icelink.BitrateNotification.fromJson(bitrateNotificationJson));
                            }
                        }, 1);
                    });
                    return _this;
                }
                PluginVideoStream.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginVideoStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginVideoStream.prototype._getExternal = function () {
                    return this._external;
                };
                PluginVideoStream.prototype._getAxo = function () {
                    return this._axo;
                };
                PluginVideoStream.prototype.getState = function () {
                    return this._state;
                };
                PluginVideoStream.prototype.addOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onStateChangeValues, value);
                };
                PluginVideoStream.prototype.removeOnStateChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onStateChangeValues, value);
                };
                PluginVideoStream.prototype.getInfo = function () {
                    return fm.icelink.MediaStreamInfo.fromJson(this._getAxo().GetInfo());
                };
                PluginVideoStream.prototype.getLocalReceive = function () {
                    return this._getAxo().GetLocalReceive();
                };
                PluginVideoStream.prototype.getLocalSend = function () {
                    return this._getAxo().GetLocalSend();
                };
                PluginVideoStream.prototype.getRemoteReceive = function () {
                    return this._getAxo().GetRemoteReceive();
                };
                PluginVideoStream.prototype.getRemoteSend = function () {
                    return this._getAxo().GetRemoteSend();
                };
                PluginVideoStream.prototype.setLocalReceive = function (value) {
                    return this._getAxo().SetLocalReceive(value);
                };
                PluginVideoStream.prototype.setLocalSend = function (value) {
                    return this._getAxo().SetLocalSend(value);
                };
                PluginVideoStream.prototype.getRemoteDirection = function () {
                    return this._getAxo().GetRemoteDirection();
                };
                PluginVideoStream.prototype.getHandle = function () {
                    return this._getAxo().GetHandle();
                };
                PluginVideoStream.prototype.changeDirection = function (newDirection) {
                    return fm.icelink.Error.fromJson(this._getAxo().ChangeDirection(newDirection));
                };
                PluginVideoStream.prototype.getDirection = function () {
                    return this._getAxo().GetDirection();
                };
                PluginVideoStream.prototype.getLocalCanonicalName = function () {
                    return this._getAxo().GetLocalCanonicalName();
                };
                PluginVideoStream.prototype.getRemoteCanonicalName = function () {
                    return this._getAxo().GetRemoteCanonicalName();
                };
                PluginVideoStream.prototype.getId = function () {
                    return this._getAxo().GetId();
                };
                PluginVideoStream.prototype.getExternalId = function () {
                    return this._getAxo().GetExternalId();
                };
                PluginVideoStream.prototype.setExternalId = function (value) {
                    this._getAxo().SetExternalId(value);
                };
                PluginVideoStream.prototype.getLabel = function () {
                    return this._getAxo().GetLabel();
                };
                PluginVideoStream.prototype.getLocalBandwidth = function () {
                    return this._getAxo().GetLocalBandwidth();
                };
                PluginVideoStream.prototype.getLocalDirection = function () {
                    return this._getAxo().GetLocalDirection();
                };
                PluginVideoStream.prototype.getLocalMuted = function () {
                    return this.getInputMuted();
                };
                PluginVideoStream.prototype.setLocalMuted = function (value) {
                    return this.setInputMuted(value);
                };
                PluginVideoStream.prototype.getRemoteMuted = function () {
                    return this._getAxo().GetRemoteMuted();
                };
                PluginVideoStream.prototype.setRemoteMuted = function (value) {
                    return this._getAxo().SetRemoteMuted(value);
                };
                PluginVideoStream.prototype.getInputMuted = function () {
                    return this._getAxo().GetInputMuted();
                };
                PluginVideoStream.prototype.getMediaDescriptionId = function () {
                    return this._getAxo().GetMediaDescriptionId();
                };
                PluginVideoStream.prototype.getOutputMuted = function () {
                    return this._getAxo().GetOutputMuted();
                };
                PluginVideoStream.prototype.getRemoteBandwidth = function () {
                    return this._getAxo().GetRemoteBandwidth();
                };
                PluginVideoStream.prototype.getTag = function () {
                    return this._getAxo().GetTag();
                };
                PluginVideoStream.prototype.getType = function () {
                    return fm.icelink.StreamType.Video;
                };
                PluginVideoStream.prototype.setLocalDirection = function (value) {
                    this._getAxo().SetLocalDirection(value);
                };
                PluginVideoStream.prototype.setLocalBandwidth = function (value) {
                    this._getAxo().SetLocalBandwidth(value);
                };
                PluginVideoStream.prototype.setInputMuted = function (value) {
                    this._getAxo().SetInputMuted(value);
                };
                PluginVideoStream.prototype.setOutputMuted = function (value) {
                    this._getAxo().SetOutputMuted(value);
                };
                PluginVideoStream.prototype.setTag = function (value) {
                    this._getAxo().SetTag(value);
                };
                PluginVideoStream.prototype.addOnDirectionChange = function (callback) {
                    fm.icelink.ArrayExtensions.add(this._onDirectionChangeValues, callback);
                };
                PluginVideoStream.prototype.removeOnDirectionChange = function (callback) {
                    fm.icelink.ArrayExtensions.remove(this._onDirectionChangeValues, callback);
                };
                PluginVideoStream.prototype.getPreferredCodecs = function () {
                    return this._getAxo().GetPreferredCodecs();
                };
                PluginVideoStream.prototype.setPreferredCodecs = function (names) {
                    this._getAxo().SetPreferredCodecs(names);
                };
                PluginVideoStream.prototype.getCodecDisabled = function (name) {
                    return this._getAxo().GetCodecDisabled(name);
                };
                PluginVideoStream.prototype.setCodecDisabled = function (name, disabled) {
                    this._getAxo().SetCodecDisabled(name, disabled);
                };
                PluginVideoStream.prototype.getVp8Disabled = function () {
                    return this._getAxo().GetVp8Disabled();
                };
                PluginVideoStream.prototype.getVp9Disabled = function () {
                    return this._getAxo().GetVp9Disabled();
                };
                PluginVideoStream.prototype.getH264Disabled = function () {
                    return this._getAxo().GetH264Disabled();
                };
                PluginVideoStream.prototype.getH265Disabled = function () {
                    return this._getAxo().GetH265Disabled();
                };
                PluginVideoStream.prototype.setVp8Disabled = function (value) {
                    return this._getAxo().SetVp8Disabled(value);
                };
                PluginVideoStream.prototype.setVp9Disabled = function (value) {
                    return this._getAxo().SetVp9Disabled(value);
                };
                PluginVideoStream.prototype.setH264Disabled = function (value) {
                    return this._getAxo().SetH264Disabled(value);
                };
                PluginVideoStream.prototype.setH265Disabled = function (value) {
                    return this._getAxo().SetH265Disabled(value);
                };
                PluginVideoStream.prototype.getRemoteEncoding = function () {
                    return fm.icelink.EncodingInfo.fromJson(this._getAxo().GetRemoteEncoding());
                };
                PluginVideoStream.prototype.setRemoteEncoding = function (value) {
                    this._getAxo().SetRemoteEncoding(fm.icelink.EncodingInfo.toJson(value));
                };
                PluginVideoStream.prototype.getSimulcastMode = function () {
                    return this._getAxo().GetSimulcastMode();
                };
                PluginVideoStream.prototype.setSimulcastMode = function (value) {
                    this._getAxo().SetSimulcastMode(value);
                };
                PluginVideoStream.prototype.getTransportInfo = function () {
                    return fm.icelink.TransportInfo.fromJson(this._getAxo().GetTransportInfo());
                };
                PluginVideoStream.prototype.getControlTransportInfo = function () {
                    return fm.icelink.TransportInfo.fromJson(this._getAxo().GetControlTransportInfo());
                };
                PluginVideoStream.prototype.addOnLocalEncodingDisabled = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onLocalEncodingDisabledValues, value);
                };
                PluginVideoStream.prototype.addOnLocalEncodingEnabled = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onLocalEncodingEnabledValues, value);
                };
                PluginVideoStream.prototype.removeOnLocalEncodingDisabled = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onLocalEncodingDisabledValues, value);
                };
                PluginVideoStream.prototype.removeOnLocalEncodingEnabled = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onLocalEncodingEnabledValues, value);
                };
                PluginVideoStream.prototype.addOnDiscardKeyFrameRequest = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onDiscardKeyFrameRequestValues, value);
                };
                PluginVideoStream.prototype.removeOnDiscardKeyFrameRequest = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onDiscardKeyFrameRequestValues, value);
                };
                PluginVideoStream.prototype.raiseKeyFrameRequest = function (synchronizationSources) {
                    this._axo.RaiseKeyFrameRequest(synchronizationSources);
                };
                PluginVideoStream.prototype.addOnDiscardBitrateRequest = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onDiscardBitrateRequestValues, value);
                };
                PluginVideoStream.prototype.removeOnDiscardBitrateRequest = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onDiscardBitrateRequestValues, value);
                };
                PluginVideoStream.prototype.raiseBitrateRequest = function (bitrateRequest) {
                    return this._axo.RaiseBitrateRequest(fm.icelink.BitrateRequest.toJson(bitrateRequest));
                };
                PluginVideoStream.prototype.addOnDiscardBitrateNotification = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onDiscardBitrateNotificationValues, value);
                };
                PluginVideoStream.prototype.removeOnDiscardBitrateNotification = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onDiscardBitrateNotificationValues, value);
                };
                PluginVideoStream.prototype.raiseBitrateNotification = function (bitrateNotification) {
                    return this._axo.RaiseBitrateNotification(fm.icelink.BitrateNotification.toJson(bitrateNotification));
                };
                PluginVideoStream.prototype.getMaxSendBitrate = function () {
                    return this._getAxo().GetMaxSendBitrate();
                };
                PluginVideoStream.prototype.setMaxSendBitrate = function (value) {
                    this._getAxo().SetMaxSendBitrate(value);
                };
                PluginVideoStream.prototype.getMaxReceiveBitrate = function () {
                    return this._getAxo().GetMaxReceiveBitrate();
                };
                PluginVideoStream.prototype.setMaxReceiveBitrate = function (value) {
                    this._getAxo().SetMaxReceiveBitrate(value);
                };
                return PluginVideoStream;
            }(fm.icelink.PluginMediaStream));
            icelink.PluginVideoStream = PluginVideoStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var PluginVideoTrack =  (function (_super) {
                __extends(PluginVideoTrack, _super);
                function PluginVideoTrack(external, media) {
                    var _this = _super.call(this, media) || this;
                    _this._external = external;
                    return _this;
                }
                PluginVideoTrack.prototype.getTypeString = function () {
                    return '[fm.icelink.PluginVideoTrack]' + ',' + _super.prototype.getTypeString.call(this);
                };
                PluginVideoTrack.prototype._getExternal = function () {
                    return this._external;
                };
                PluginVideoTrack.prototype.isLocal = function () {
                    return (fm.icelink.Util.isObjectType(this.getMedia(), '[fm.icelink.PluginLocalMedia]'));
                };
                PluginVideoTrack.prototype.addOnStarted = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.addOnStarted on a remote track.');
                    }
                    this.getMedia().addOnVideoStarted(value);
                };
                PluginVideoTrack.prototype.addOnStopped = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.addOnStopped on a remote track.');
                    }
                    this.getMedia().addOnVideoStopped(value);
                };
                PluginVideoTrack.prototype.addOnDestroyed = function (value) {
                    this.getMedia().addOnVideoDestroyed(value);
                };
                PluginVideoTrack.prototype.removeOnStarted = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.removeOnStarted on a remote track.');
                    }
                    this.getMedia().removeOnVideoStarted(value);
                };
                PluginVideoTrack.prototype.removeOnStopped = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.removeOnStopped on a remote track.');
                    }
                    this.getMedia().removeOnVideoStopped(value);
                };
                PluginVideoTrack.prototype.removeOnDestroyed = function (value) {
                    this.getMedia().removeOnVideoDestroyed(value);
                };
                PluginVideoTrack.prototype.changeSinkOutput = function (sinkOutput) {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.changeSinkOutput on a local track.');
                    }
                    return this.getMedia().changeVideoSinkOutput(sinkOutput);
                };
                PluginVideoTrack.prototype.getSinkOutput = function () {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.getSinkOutput on a local track.');
                    }
                    return this.getMedia().getVideoSinkOutput();
                };
                PluginVideoTrack.prototype.getSinkOutputs = function () {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.getSinkOutputs on a local track.');
                    }
                    return this.getMedia().getVideoSinkOutputs();
                };
                PluginVideoTrack.prototype.setSinkOutput = function (value) {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.setSinkOutput on a local track.');
                    }
                    this.getMedia().setVideoSinkOutput(value);
                };
                PluginVideoTrack.prototype.changeSourceInput = function (sourceInput) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.changeSourceInput on a remote track.');
                    }
                    return this.getMedia().changeVideoSourceInput(sourceInput);
                };
                PluginVideoTrack.prototype.getSourceInput = function () {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.getSourceInput on a remote track.');
                    }
                    return this.getMedia().getVideoSourceInput();
                };
                PluginVideoTrack.prototype.getSourceInputs = function () {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.getSourceInputs on a remote track.');
                    }
                    return this.getMedia().getVideoSourceInputs();
                };
                PluginVideoTrack.prototype.setSourceInput = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.setSourceInput on a remote track.');
                    }
                    this.getMedia().setVideoSourceInput(value);
                };
                PluginVideoTrack.prototype.addOnSize = function (value) {
                    this.getMedia().addOnVideoSize(value);
                };
                PluginVideoTrack.prototype.getMuted = function () {
                    return this.getMedia().getVideoMuted();
                };
                PluginVideoTrack.prototype.getSize = function () {
                    return this.getMedia().getVideoSize();
                };
                PluginVideoTrack.prototype.grabFrame = function () {
                    return this.getMedia().grabVideoFrame();
                };
                PluginVideoTrack.prototype.setMuted = function (value) {
                    this.getMedia().setVideoMuted(value);
                };
                PluginVideoTrack.prototype.removeOnSize = function (value) {
                    this.getMedia().removeOnVideoSize(value);
                };
                return PluginVideoTrack;
            }(fm.icelink.PluginMediaTrack));
            icelink.PluginVideoTrack = PluginVideoTrack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var RemoteMedia =  (function (_super) {
                __extends(RemoteMedia, _super);
                function RemoteMedia(audio, video) {
                    var _this = _super.call(this) || this;
                    if (typeof audio == 'undefined') {
                        audio = true;
                    }
                    if (typeof video == 'undefined') {
                        video = true;
                    }
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginRemoteMedia(_this, audio, video);
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcRemoteMedia(_this, audio, video);
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    return _this;
                }
                RemoteMedia.prototype.getTypeString = function () {
                    return '[fm.icelink.RemoteMedia]' + ',' + _super.prototype.getTypeString.call(this);
                };
                RemoteMedia.prototype._getInternal = function () {
                    return this._internal;
                };
                RemoteMedia.prototype.changeAudioSinkOutput = function (audioSinkOutput) {
                    return this._getInternal().changeAudioSinkOutput(audioSinkOutput);
                };
                RemoteMedia.prototype.changeVideoSinkOutput = function (videoSinkOutput) {
                    return this._getInternal().changeVideoSinkOutput(videoSinkOutput);
                };
                RemoteMedia.prototype.getAudioSinkOutput = function () {
                    return this._getInternal().getAudioSinkOutput();
                };
                RemoteMedia.prototype.getAudioSinkOutputs = function () {
                    return this._getInternal().getAudioSinkOutputs();
                };
                RemoteMedia.prototype.getVideoSinkOutput = function () {
                    return this._getInternal().getVideoSinkOutput();
                };
                RemoteMedia.prototype.getVideoSinkOutputs = function () {
                    return this._getInternal().getVideoSinkOutputs();
                };
                RemoteMedia.prototype.setAudioSinkOutput = function (value) {
                    this._getInternal().setAudioSinkOutput(value);
                };
                RemoteMedia.prototype.setVideoSinkOutput = function (value) {
                    this._getInternal().setVideoSinkOutput(value);
                };
                return RemoteMedia;
            }(fm.icelink.Media));
            icelink.RemoteMedia = RemoteMedia;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var SessionDescriptionManager =  (function (_super) {
                __extends(SessionDescriptionManager, _super);
                function SessionDescriptionManager() {
                    var _this = _super.call(this) || this;
                    _this._streams = {};
                    return _this;
                }
                SessionDescriptionManager.prototype.getTypeString = function () {
                    return '[fm.icelink.SessionDescriptionManager]' + ',' + _super.prototype.getTypeString.call(this);
                };
                SessionDescriptionManager.prototype.getStreams = function () {
                    return this._streams;
                };
                SessionDescriptionManager.prototype.getAudioStreams = function () {
                    var audioStreams = [];
                    this.__streamIndex.forEach(function (stream) {
                        if (stream.getType() == fm.icelink.StreamType.Audio) {
                            audioStreams.push(stream);
                        }
                    });
                    return audioStreams;
                };
                SessionDescriptionManager.prototype.getVideoStreams = function () {
                    var videoStreams = [];
                    this.__streamIndex.forEach(function (stream) {
                        if (stream.getType() == fm.icelink.StreamType.Video) {
                            videoStreams.push(stream);
                        }
                    });
                    return videoStreams;
                };
                SessionDescriptionManager.prototype.getDataStreams = function () {
                    var dataStreams = [];
                    this.__streamIndex.forEach(function (stream) {
                        if (stream.getType() == fm.icelink.StreamType.Application) {
                            dataStreams.push(stream);
                        }
                    });
                    return dataStreams;
                };
                SessionDescriptionManager.prototype.processSdpMediaDescriptionForStream = function (stream, sdpMediaDescription, sdpMediaIndex, isLocalDescription, isRenegotiation) {
                    return null;
                };
                return SessionDescriptionManager;
            }(fm.icelink.SessionDescriptionManagerBase));
            icelink.SessionDescriptionManager = SessionDescriptionManager;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var VideoStream =  (function (_super) {
                __extends(VideoStream, _super);
                function VideoStream() {
                    var _this = this;
                    if (arguments.length == 0) {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    var localTrack = null;
                    var localMedia = null;
                    var remoteTrack = null;
                    var remoteMedia = null;
                    if (arguments.length >= 1 && fm.icelink.Util.isNullOrUndefined(arguments[0])) ;
                    else if (arguments.length >= 1 && fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.VideoTrack]')) {
                        localTrack = arguments[0];
                    }
                    else if (arguments.length >= 1 && fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.LocalMedia]')) {
                        localMedia = arguments[0];
                        localTrack = localMedia.getVideoTrack();
                    }
                    else if (arguments.length >= 1 && fm.icelink.Util.isObjectType(arguments[0], '[fm.icelink.RemoteMedia]')) {
                        remoteMedia = arguments[0];
                        remoteTrack = remoteMedia.getVideoTrack();
                    }
                    else if (arguments.length >= 1) {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    if (arguments.length >= 2 && fm.icelink.Util.isNullOrUndefined(arguments[1])) ;
                    else if (arguments.length >= 2 && fm.icelink.Util.isObjectType(arguments[1], '[fm.icelink.VideoTrack]')) {
                        remoteTrack = arguments[1];
                    }
                    else if (arguments.length >= 2 && fm.icelink.Util.isObjectType(arguments[1], '[fm.icelink.RemoteMedia]')) {
                        remoteMedia = arguments[1];
                        remoteTrack = remoteMedia.getVideoTrack();
                    }
                    else if (arguments.length >= 2) {
                        throw new fm.icelink.Exception('Constructor overload does not exist with specified parameter count/type combination.');
                    }
                    _this = _super.call(this, localTrack, remoteTrack) || this;
                    _this.localMedia = localMedia;
                    _this.remoteMedia = remoteMedia;
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginVideoStream(_this, (localTrack == null ? null : localTrack._getInternal()), (remoteTrack == null ? null : remoteTrack._getInternal()));
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcVideoStream(_this, (localTrack == null ? null : localTrack._getInternal()), (remoteTrack == null ? null : remoteTrack._getInternal()));
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    return _this;
                }
                VideoStream.prototype.getTypeString = function () {
                    return '[fm.icelink.VideoStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                VideoStream.prototype._getInternal = function () {
                    return this._internal;
                };
                VideoStream.prototype.getLocalMedia = function () {
                    return this.localMedia;
                };
                VideoStream.prototype.getRemoteMedia = function () {
                    return this.remoteMedia;
                };
                VideoStream.prototype.getVp8Disabled = function () {
                    return this._getInternal().getVp8Disabled();
                };
                VideoStream.prototype.getVp9Disabled = function () {
                    return this._getInternal().getVp9Disabled();
                };
                VideoStream.prototype.getH264Disabled = function () {
                    return this._getInternal().getH264Disabled();
                };
                VideoStream.prototype.getH265Disabled = function () {
                    return this._getInternal().getH265Disabled();
                };
                VideoStream.prototype.setVp8Disabled = function (value) {
                    return this._getInternal().setVp8Disabled(value);
                };
                VideoStream.prototype.setVp9Disabled = function (value) {
                    return this._getInternal().setVp9Disabled(value);
                };
                VideoStream.prototype.setH264Disabled = function (value) {
                    return this._getInternal().setH264Disabled(value);
                };
                VideoStream.prototype.setH265Disabled = function (value) {
                    return this._getInternal().setH265Disabled(value);
                };
                VideoStream.prototype.addOnDiscardKeyFrameRequest = function (value) {
                    this._getInternal().addOnDiscardKeyFrameRequest(value);
                };
                VideoStream.prototype.removeOnDiscardKeyFrameRequest = function (value) {
                    this._getInternal().removeOnDiscardKeyFrameRequest(value);
                };
                VideoStream.prototype.raiseKeyFrameRequest = function (synchronizationSources) {
                    this._getInternal().raiseKeyFrameRequest(synchronizationSources);
                };
                return VideoStream;
            }(fm.icelink.MediaStream));
            icelink.VideoStream = VideoStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var VideoTrack =  (function (_super) {
                __extends(VideoTrack, _super);
                function VideoTrack(media, internalMedia) {
                    var _this = _super.call(this, media) || this;
                    if (fm.icelink.Util.isNullOrUndefined(media)) {
                        throw new fm.icelink.Exception('Media cannot be null.');
                    }
                    if (fm.icelink.Plugin.useActiveX()) {
                        _this._internal = new fm.icelink.PluginVideoTrack(_this, (media._getInternal() || internalMedia));
                    }
                    else if (fm.icelink.Plugin.useNative()) {
                        _this._internal = new fm.icelink.WebRtcVideoTrack(_this, (media._getInternal() || internalMedia));
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support WebRTC/ORTC and no plugin found.');
                    }
                    return _this;
                }
                VideoTrack.prototype.getTypeString = function () {
                    return '[fm.icelink.VideoTrack]' + ',' + _super.prototype.getTypeString.call(this);
                };
                VideoTrack.prototype._getInternal = function () {
                    return this._internal;
                };
                VideoTrack.prototype.addOnSize = function (value) {
                    return this._internal.addOnSize(value);
                };
                VideoTrack.prototype.getSize = function () {
                    return this._internal.getSize();
                };
                VideoTrack.prototype.grabFrame = function () {
                    return this._internal.grabFrame();
                };
                VideoTrack.prototype.removeOnSize = function (value) {
                    return this._internal.removeOnSize(value);
                };
                return VideoTrack;
            }(fm.icelink.MediaTrack));
            icelink.VideoTrack = VideoTrack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcMediaStream =  (function (_super) {
                __extends(WebRtcMediaStream, _super);
                function WebRtcMediaStream(external, localTrack, remoteTrack, type) {
                    var _this = _super.call(this, type) || this;
                    _this._onDiscardBitrateRequestValues = [];
                    _this._onDiscardBitrateNotificationValues = [];
                    _this._deactivatedByServer = null;
                    _this._maxVideoSize = new fm.icelink.Size();
                    _this._sender = null;
                    _this._receiver = null;
                    _this._singleSendBitrate = -1;
                    _this._sendEncodings = null;
                    _this._receiveEncodings = null;
                    _this._simulcastMode = fm.icelink.SimulcastMode.Disabled;
                    if (localTrack == null) {
                        _this.setLocalDirection(fm.icelink.StreamDirection.ReceiveOnly);
                    }
                    else {
                        _this.setLocalDirection(fm.icelink.StreamDirection.SendReceive);
                    }
                    _this.setRemoteDirection(fm.icelink.StreamDirection.SendReceive);
                    _this.setLocalTrack(localTrack);
                    _this.setRemoteTrack(remoteTrack);
                    if (localTrack) {
                        localTrack.addOutput(_this);
                    }
                    if (remoteTrack) {
                        remoteTrack.addInput(_this);
                    }
                    _this.addOnStateChange(function () {
                        if (_this.getState() == fm.icelink.StreamState.Closed || _this.getState() == fm.icelink.StreamState.Failed) {
                            if (localTrack) {
                                localTrack.removeOutput(_this);
                            }
                            if (remoteTrack) {
                                remoteTrack.removeInput(_this);
                            }
                        }
                    });
                    return _this;
                }
                WebRtcMediaStream.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcMediaStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcMediaStream.prototype.getLocalTrack = function () {
                    return this._localTrack;
                };
                WebRtcMediaStream.prototype.setLocalTrack = function (localTrack) {
                    this._localTrack = localTrack;
                };
                WebRtcMediaStream.prototype.getRemoteTrack = function () {
                    return this._remoteTrack;
                };
                WebRtcMediaStream.prototype.setRemoteTrack = function (remoteTrack) {
                    this._remoteTrack = remoteTrack;
                };
                WebRtcMediaStream.prototype.setInputMuted = function (muted) {
                    if (this._localTrack) {
                        this._localTrack.setMuted(muted);
                    }
                };
                WebRtcMediaStream.prototype.getInputMuted = function () {
                    if (this._localTrack) {
                        return this._localTrack.getMuted();
                    }
                    return false;
                };
                WebRtcMediaStream.prototype.setOutputMuted = function (muted) {
                    if (this._remoteTrack) {
                        this._remoteTrack.setMuted(muted);
                    }
                };
                WebRtcMediaStream.prototype.getOutputMuted = function () {
                    if (this._remoteTrack) {
                        return this._remoteTrack.getMuted();
                    }
                    return false;
                };
                WebRtcMediaStream.prototype.setMaxWidthAndHeight = function (width, height) {
                    if (width > 0 && height > 0) {
                        if (width < height) {
                            var temp = width;
                            width = height;
                            height = temp;
                        }
                        if (this._maxVideoSize.getWidth() * this._maxVideoSize.getHeight() < width * height) {
                            this._maxVideoSize.setWidth(width);
                            this._maxVideoSize.setHeight(height);
                        }
                    }
                };
                WebRtcMediaStream.prototype.populateInfo = function (info) {
                    info.setMaxFrameWidth(this._maxVideoSize.getWidth());
                    info.setMaxFrameHeight(this._maxVideoSize.getHeight());
                    if (this._sender && this._sender.getParameters) {
                        var params = this._sender.getParameters();
                        if (params) {
                            var codecs = params.codecs;
                            if (codecs) {
                                info.setSendFormats(this.toFormatInfos(codecs));
                            }
                        }
                    }
                    var sendEncodings = this.getSendEncodingInfos();
                    if (sendEncodings) {
                        info.setSendEncodings(sendEncodings);
                    }
                    if (this._receiver && this._receiver.getParameters) {
                        var params = this._receiver.getParameters();
                        if (params) {
                            var codecs = params.codecs;
                            if (codecs) {
                                info.setReceiveFormats(this.toFormatInfos(codecs));
                            }
                        }
                    }
                    var receiveEncodings = this.getReceiveEncodingInfos();
                    if (receiveEncodings) {
                        info.setReceiveEncodings(receiveEncodings);
                    }
                };
                WebRtcMediaStream.prototype.toFormatInfos = function (codecs) {
                    var formatInfos = [];
                    for (var _i = 0, codecs_1 = codecs; _i < codecs_1.length; _i++) {
                        var codec = codecs_1[_i];
                        var name_34 = codec.mimeType;
                        if (!name_34) {
                            continue;
                        }
                        if (name_34.indexOf('/') != -1) {
                            name_34 = name_34.split('/')[1];
                        }
                        var formatInfo = null;
                        if (this.getType() == fm.icelink.StreamType.Audio) {
                            formatInfo = new fm.icelink.FormatInfo(name_34, codec.clockRate, codec.channels);
                        }
                        else {
                            formatInfo = new fm.icelink.FormatInfo(name_34, codec.clockRate);
                        }
                        formatInfos.push(formatInfo);
                    }
                    return formatInfos;
                };
                WebRtcMediaStream.prototype.getSender = function () {
                    return this._sender;
                };
                WebRtcMediaStream.prototype.setSender = function (value, applySendEncodings) {
                    this._sender = value;
                    if (applySendEncodings) {
                        this.applySendEncodings();
                    }
                };
                WebRtcMediaStream.prototype.getReceiver = function () {
                    return this._receiver;
                };
                WebRtcMediaStream.prototype.setReceiver = function (value) {
                    this._receiver = value;
                };
                WebRtcMediaStream.prototype.getSingleSendBitrate = function () {
                    return this._singleSendBitrate;
                };
                WebRtcMediaStream.prototype.getSendEncodings = function () {
                    return this._sendEncodings;
                };
                WebRtcMediaStream.prototype.setSendEncodings = function (sendEncodings) {
                    this._sendEncodings = sendEncodings;
                    if (this._deactivatedByServer == null) {
                        this._deactivatedByServer = [];
                        for (var i = 0; i < sendEncodings.length; i++) {
                            this._deactivatedByServer.push(false);
                        }
                    }
                    this.applySendEncodings();
                };
                WebRtcMediaStream.prototype.applySendEncodings = function (sendEncodingIndex) {
                    var _this = this;
                    if (this.getSimulcastMode() == fm.icelink.SimulcastMode.Disabled) {
                        return null;
                    }
                    var sendEncodings = this._sendEncodings;
                    if (!sendEncodings || sendEncodings.length == 0) {
                        return null;
                    }
                    var sender = this._sender;
                    if (!sender || !sender.getParameters) {
                        return null;
                    }
                    var params = sender.getParameters();
                    if (!params) {
                        return null;
                    }
                    var nativeSendEncodings = params.encodings;
                    if (nativeSendEncodings && nativeSendEncodings.length > 0) {
                        if (nativeSendEncodings.length <= sendEncodings.length) {
                            for (var i = 0; i < nativeSendEncodings.length; i++) {
                                if (sendEncodingIndex != undefined && sendEncodingIndex != i) {
                                    continue;
                                }
                                if (!this.updateNativeEncoding(nativeSendEncodings[i], sendEncodings[i], this._deactivatedByServer[i])) {
                                    continue;
                                }
                                var encodingInfo = new fm.icelink.EncodingInfo();
                                this.updateEncodingInfo(encodingInfo, sendEncodings[i], true);
                                var rid = 'rid' in nativeSendEncodings[i] ? nativeSendEncodings[i].rid : null;
                                if (rid != null) {
                                    encodingInfo.setRtpStreamId(rid);
                                }
                                var ssrc = 'ssrc' in nativeSendEncodings[i] ? nativeSendEncodings[i].ssrc : -1;
                                if (ssrc != -1) {
                                    encodingInfo.setSynchronizationSource(ssrc);
                                }
                                if (!nativeSendEncodings[i].active) {
                                    this.raiseLocalEncodingDisabled(encodingInfo);
                                    if (ssrc == -1 && rid == null) {
                                        fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding has paused.');
                                    }
                                    else if (ssrc == -1) {
                                        fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding with RTP stream ID ' + rid + ' has paused.');
                                    }
                                    else if (rid == null) {
                                        fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding with SSRC ' + ssrc + ' has paused.');
                                    }
                                    else {
                                        fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding with SSRC ' + ssrc + ' and RTP stream ID ' + rid + ' has paused.');
                                    }
                                    var bitrateNotification = new fm.icelink.BitrateNotification();
                                    bitrateNotification.setBitrate(0);
                                    if (rid != null) {
                                        bitrateNotification.setRtpStreamId(rid);
                                    }
                                    if (ssrc != -1) {
                                        bitrateNotification.setSynchronizationSource(ssrc);
                                    }
                                    this.processBitrateNotification(bitrateNotification);
                                }
                                else {
                                    this.raiseLocalEncodingEnabled(encodingInfo);
                                    if (ssrc == -1 && rid == null) {
                                        fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding has resumed.');
                                    }
                                    else if (ssrc == -1) {
                                        fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding with RTP stream ID ' + rid + ' has resumed.');
                                    }
                                    else if (rid == null) {
                                        fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding with SSRC ' + ssrc + ' has resumed.');
                                    }
                                    else {
                                        fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding with SSRC ' + ssrc + ' and RTP stream ID ' + rid + ' has resumed.');
                                    }
                                }
                            }
                        }
                        else {
                            fm.icelink.Log.error('Could not set local ' + new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' send encodings.', new fm.icelink.Exception('Cannot change the number of send encodings.'));
                        }
                    }
                    else {
                        nativeSendEncodings = this.getNativeSendEncodings();
                        var rtpStreamIndex = 0;
                        for (var _i = 0, nativeSendEncodings_1 = nativeSendEncodings; _i < nativeSendEncodings_1.length; _i++) {
                            var nativeSendEncoding = nativeSendEncodings_1[_i];
                            nativeSendEncoding.rid = (rtpStreamIndex++).toString();
                        }
                        params.encodings = nativeSendEncodings;
                    }
                    this._sender.setParameters(params).catch(function (error) {
                        fm.icelink.Log.error('Could not set local ' + new fm.icelink.StreamTypeWrapper(_this.getType()).toString() + ' send encodings.', new fm.icelink.Exception('' + error));
                    });
                    return params;
                };
                WebRtcMediaStream.prototype.getReceiveEncodings = function () {
                    return this._receiveEncodings;
                };
                WebRtcMediaStream.prototype.setReceiveEncodings = function (receiveEncodings) {
                    this._receiveEncodings = receiveEncodings;
                };
                WebRtcMediaStream.prototype.getNativeSendEncodings = function () {
                    if (this.getSimulcastMode() == fm.icelink.SimulcastMode.Disabled) {
                        return null;
                    }
                    if (!this._sendEncodings) {
                        return null;
                    }
                    var nativeEncodings = [];
                    for (var _i = 0, _a = this._sendEncodings; _i < _a.length; _i++) {
                        var sendEncoding = _a[_i];
                        var nativeEncoding = {};
                        this.updateNativeEncoding(nativeEncoding, sendEncoding, false);
                        nativeEncodings.push(nativeEncoding);
                    }
                    return nativeEncodings;
                };
                WebRtcMediaStream.prototype.getSendEncodingInfos = function () {
                    var sendEncodings = this._sendEncodings;
                    if (!sendEncodings) {
                        var localTrack = this.getLocalTrack();
                        if (localTrack) {
                            var media = localTrack.getMedia();
                            if (media && media instanceof fm.icelink.WebRtcLocalMedia) {
                                var localMedia = media;
                                if (localMedia) {
                                    if (this.getType() == fm.icelink.StreamType.Audio) {
                                        sendEncodings = localMedia.getAudioEncodings();
                                    }
                                    else if (this.getType() == fm.icelink.StreamType.Video) {
                                        sendEncodings = localMedia.getVideoEncodings();
                                    }
                                }
                            }
                        }
                    }
                    if (!sendEncodings) {
                        return [];
                    }
                    var encodingInfos = [];
                    for (var _i = 0, sendEncodings_1 = sendEncodings; _i < sendEncodings_1.length; _i++) {
                        var sendEncoding = sendEncodings_1[_i];
                        var encodingInfo = new fm.icelink.EncodingInfo();
                        this.updateEncodingInfo(encodingInfo, sendEncoding, true);
                        encodingInfos.push(encodingInfo);
                    }
                    return encodingInfos;
                };
                WebRtcMediaStream.prototype.getReceiveEncodingInfos = function () {
                    if (!this._receiveEncodings) {
                        return [];
                    }
                    var encodingInfos = [];
                    for (var _i = 0, _a = this._receiveEncodings; _i < _a.length; _i++) {
                        var receiveEncoding = _a[_i];
                        var encodingInfo = new fm.icelink.EncodingInfo();
                        this.updateEncodingInfo(encodingInfo, receiveEncoding, false);
                        encodingInfos.push(encodingInfo);
                    }
                    return encodingInfos;
                };
                WebRtcMediaStream.prototype.updateNativeEncoding = function (nativeEncoding, encoding, deactivatedByServer) {
                    var newActive = !(encoding.getDeactivated() || deactivatedByServer);
                    var oldActive = nativeEncoding.active;
                    nativeEncoding.active = newActive;
                    var bitrate = encoding.getBitrate();
                    if (bitrate > 0) {
                        nativeEncoding.maxBitrate = bitrate * 1000;
                    }
                    if (this.getType() == fm.icelink.StreamType.Video) {
                        var videoEncoding = encoding;
                        var frameRate = videoEncoding.getFrameRate();
                        if (frameRate > 0) {
                            nativeEncoding.maxFramerate = frameRate;
                        }
                        var scale = videoEncoding.getScale();
                        if (scale > 0) {
                            nativeEncoding.scaleResolutionDownBy = 1 / scale;
                        }
                    }
                    return oldActive != newActive;
                };
                WebRtcMediaStream.prototype.updateEncodingInfo = function (encodingInfo, encoding, send) {
                    encodingInfo.setDeactivated(encoding.getDeactivated());
                    encodingInfo.setBitrate(encoding.getBitrate());
                    encodingInfo.setRtpStreamId(encoding.getRtpStreamId());
                    encodingInfo.setSynchronizationSource(encoding.getSynchronizationSource());
                    if (this.getType() == fm.icelink.StreamType.Video) {
                        var videoEncoding = encoding;
                        encodingInfo.setFrameRate(videoEncoding.getFrameRate());
                        encodingInfo.setScale(videoEncoding.getScale());
                        var sourceEncoding = this.getSourceEncoding();
                        if (sourceEncoding) {
                            var sourceSize = sourceEncoding.getSize();
                            if (sourceSize) {
                                var sourceWidth = sourceSize.getWidth();
                                var sourceHeight = sourceSize.getHeight();
                                if (sourceWidth > 0 && sourceHeight > 0) {
                                    encodingInfo.setSize(new fm.icelink.Size(sourceSize.getWidth(), sourceSize.getHeight()));
                                }
                            }
                            var sourceFrameRate = sourceEncoding.getFrameRate();
                            if (sourceFrameRate > 0) {
                                encodingInfo.setFrameRate(sourceFrameRate);
                            }
                        }
                    }
                };
                WebRtcMediaStream.prototype.getNativeTrack = function (send) {
                    var track = send ? this._localTrack : this._remoteTrack;
                    if (track) {
                        var nativeTrack = track._getMediaStreamTrack();
                        if (nativeTrack) {
                            return nativeTrack;
                        }
                    }
                    if (send) {
                        var sender = this._sender;
                        if (sender) {
                            var nativeTrack = sender.track;
                            if (nativeTrack) {
                                return nativeTrack;
                            }
                        }
                    }
                    else {
                        var receiver = this._receiver;
                        if (receiver) {
                            var nativeTrack = receiver.track;
                            if (nativeTrack) {
                                return nativeTrack;
                            }
                        }
                    }
                    return null;
                };
                WebRtcMediaStream.prototype.getSourceEncoding = function () {
                    var encodingInfo = new fm.icelink.EncodingInfo();
                    if (this.getType() == fm.icelink.StreamType.Video) {
                        var nativeTrack = this.getNativeTrack(true);
                        if (nativeTrack && nativeTrack.getSettings) {
                            var settings = nativeTrack.getSettings();
                            if (settings) {
                                if (settings.width > 0 && settings.height > 0) {
                                    encodingInfo.setSize(new fm.icelink.Size(settings.width, settings.height));
                                }
                                if (settings.frameRate > 0) {
                                    encodingInfo.setFrameRate(settings.frameRate);
                                }
                            }
                        }
                    }
                    return encodingInfo;
                };
                WebRtcMediaStream.prototype.replaceLocalTrack = function (localTrack) {
                    var connection = this.getConnection();
                    if (!connection) {
                        return fm.icelink.Promise.rejectNow(new fm.icelink.Exception('Not connected.'));
                    }
                    return connection.replaceLocalTrack(localTrack, this);
                };
                WebRtcMediaStream.prototype.replaceRemoteTrack = function (remoteTrack) {
                    var connection = this.getConnection();
                    if (!connection) {
                        return fm.icelink.Promise.rejectNow(new fm.icelink.Exception('Not connected.'));
                    }
                    return connection.replaceRemoteTrack(remoteTrack, this);
                };
                WebRtcMediaStream.prototype.processCachedChanges = function () {
                    if (this.getRenegotiationPending()) {
                        var direction = this.getPendingLocalDirection();
                        this.setLocalDirection(direction);
                    }
                };
                WebRtcMediaStream.prototype.resetRemoteDirection = function () {
                    this.setRemoteDirection(fm.icelink.StreamDirection.SendReceive);
                };
                WebRtcMediaStream.prototype.processSdpMediaDescription = function (sdpMessage, sdpMediaDescription, index, isLocalDescription, isOffer, isRenegotiation) {
                    var manager = this.getMediaDescriptionManager();
                    var requirements = new fm.icelink.MediaDescriptionRequirements();
                    var error = manager.processSdpMediaDescription(requirements, sdpMessage, index, isLocalDescription, isRenegotiation, isOffer);
                    if (error != null) {
                        return error;
                    }
                    if (isLocalDescription) {
                        this.setLocalMuted(manager.localMuted);
                    }
                    else {
                        this.setRemoteMuted(manager.remoteMuted);
                    }
                    if (!isLocalDescription) {
                        for (var _i = 0, _a = sdpMediaDescription.getMediaAttributes(); _i < _a.length; _i++) {
                            var sdpMediaAttribute = _a[_i];
                            if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.SendReceiveAttribute]')) {
                                this.setRemoteDirection(fm.icelink.StreamDirection.SendReceive);
                            }
                            else if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.SendOnlyAttribute]')) {
                                this.setRemoteDirection(fm.icelink.StreamDirection.SendOnly);
                            }
                            else if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.ReceiveOnlyAttribute]')) {
                                this.setRemoteDirection(fm.icelink.StreamDirection.ReceiveOnly);
                            }
                            else if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.InactiveAttribute]')) {
                                this.setRemoteDirection(fm.icelink.StreamDirection.Inactive);
                            }
                        }
                    }
                    this.extractCanonicalName(sdpMediaDescription, isLocalDescription);
                    return null;
                };
                WebRtcMediaStream.prototype.getDirectionCapabilities = function () {
                    return fm.icelink.StreamDirection.SendReceive;
                };
                WebRtcMediaStream.prototype.setControlTransportInfo = function (info) {
                    this._controlTransportInfo = info;
                };
                WebRtcMediaStream.prototype.getControlTransportInfo = function () {
                    return this._controlTransportInfo;
                };
                WebRtcMediaStream.prototype.getSimulcastMode = function () {
                    return this._simulcastMode;
                };
                WebRtcMediaStream.prototype.setSimulcastMode = function (value) {
                    this._simulcastMode = value;
                };
                WebRtcMediaStream.prototype.addOnDiscardBitrateRequest = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onDiscardBitrateRequestValues, value);
                };
                WebRtcMediaStream.prototype.removeOnDiscardBitrateRequest = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onDiscardBitrateRequestValues, value);
                };
                WebRtcMediaStream.prototype.raiseOnDiscardBitrateRequest = function (bitrateNotification) {
                    for (var _i = 0, _a = this._onDiscardBitrateRequestValues; _i < _a.length; _i++) {
                        var onDiscardBitrateRequestValue = _a[_i];
                        onDiscardBitrateRequestValue(bitrateNotification);
                    }
                };
                WebRtcMediaStream.prototype.processBitrateRequest = function (bitrateRequest) {
                    bitrateRequest.setMediaDescriptionId(this.getMediaDescriptionId() || new fm.icelink.StreamTypeWrapper(this.getType()).toString().toLowerCase());
                    this.raiseOnDiscardBitrateRequest(bitrateRequest);
                };
                WebRtcMediaStream.prototype.raiseBitrateRequest = function (bitrateRequest) {
                    var _this = this;
                    if (this.getSimulcastMode() == fm.icelink.SimulcastMode.Disabled ||
                        this._sendEncodings == null ||
                        this._sendEncodings.length == 0 ||
                        (this._sendEncodings.length == 1 &&
                            this._sendEncodings[0].getSynchronizationSource() == -1 &&
                            this._sendEncodings[0].getRtpStreamId() == null &&
                            this._sendEncodings[0].getBitrate() == -1)) {
                        var connection = this.getConnection();
                        if (!connection) {
                            return false;
                        }
                        connection.setMaxSendBitrate(bitrateRequest.getBitrate(), this.getType()).then(function () {
                            _this._singleSendBitrate = bitrateRequest.getBitrate();
                            var bitrateNotification = new fm.icelink.BitrateNotification();
                            bitrateNotification.setBitrate(bitrateRequest.getBitrate());
                            bitrateNotification.setRtpStreamId(bitrateRequest.getRtpStreamId());
                            bitrateNotification.setSynchronizationSource(bitrateRequest.getSynchronizationSource());
                            _this.processBitrateNotification(bitrateNotification);
                        }, function (ex) {
                            fm.icelink.Log.error('Could not process bitrate request for ' + new fm.icelink.StreamTypeWrapper(_this.getType()).toString() + ' stream.', ex);
                        });
                        return true;
                    }
                    var sendEncodingIndex = this.findSendEncodingIndex(bitrateRequest);
                    if (sendEncodingIndex == -1) {
                        return false;
                    }
                    var rid = bitrateRequest.getRtpStreamId();
                    var ssrc = bitrateRequest.getSynchronizationSource();
                    var requestBitrate = bitrateRequest.getBitrate();
                    var remoteRequestedDeactivate = requestBitrate == 0;
                    if (remoteRequestedDeactivate) {
                        var disabled = this.remoteRequestedMaxSendBitrate(sendEncodingIndex, requestBitrate);
                        if (disabled) ;
                        else {
                            var bitrateNotification = new fm.icelink.BitrateNotification();
                            bitrateNotification.setBitrate(this._sendEncodings[sendEncodingIndex].getBitrate());
                            bitrateNotification.setRtpStreamId(bitrateRequest.getRtpStreamId());
                            bitrateNotification.setSynchronizationSource(bitrateRequest.getSynchronizationSource());
                            this.processBitrateNotification(bitrateNotification);
                        }
                    }
                    else {
                        var oldBitrate = this._sendEncodings[sendEncodingIndex].getBitrate();
                        var disabled = this.remoteRequestedMaxSendBitrate(sendEncodingIndex, requestBitrate);
                        if (disabled) {
                            var bitrateNotification = new fm.icelink.BitrateNotification();
                            bitrateNotification.setBitrate(0);
                            bitrateNotification.setRtpStreamId(bitrateRequest.getRtpStreamId());
                            bitrateNotification.setSynchronizationSource(bitrateRequest.getSynchronizationSource());
                            this.processBitrateNotification(bitrateNotification);
                        }
                        else {
                            var bitrate = this._sendEncodings[sendEncodingIndex].getBitrate();
                            if (oldBitrate != bitrate) {
                                var bitrateNotification = new fm.icelink.BitrateNotification();
                                bitrateNotification.setBitrate(bitrate);
                                bitrateNotification.setRtpStreamId(bitrateRequest.getRtpStreamId());
                                bitrateNotification.setSynchronizationSource(bitrateRequest.getSynchronizationSource());
                                this.processBitrateNotification(bitrateNotification);
                                if (ssrc == -1 && rid == null) {
                                    fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding has maximum bitrate ' + bitrate + 'kbps.');
                                }
                                else if (ssrc == -1) {
                                    fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding with RTP stream ID ' + rid + ' has maximum bitrate ' + bitrate + 'kbps.');
                                }
                                else if (rid == null) {
                                    fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding with SSRC ' + ssrc + ' has maximum bitrate ' + bitrate + 'kbps.');
                                }
                                else {
                                    fm.icelink.Log.debug(new fm.icelink.StreamTypeWrapper(this.getType()).toString() + ' stream encoding with SSRC ' + ssrc + ' and RTP stream ID ' + rid + ' has maximum bitrate ' + bitrate + 'kbps.');
                                }
                            }
                        }
                    }
                    return true;
                };
                WebRtcMediaStream.prototype.remoteRequestedMaxSendBitrate = function (sendEncodingIndex, maxBitrate) {
                    var sendEncodings = this._sendEncodings;
                    if (!sendEncodings || sendEncodings.length == 0) {
                        return null;
                    }
                    var sender = this._sender;
                    if (!sender || !sender.getParameters) {
                        return false;
                    }
                    var params = sender.getParameters();
                    if (!params || !params.encodings) {
                        return false;
                    }
                    this._deactivatedByServer[sendEncodingIndex] = (maxBitrate == 0);
                    if (maxBitrate != 0) {
                        sendEncodings[sendEncodingIndex].setBitrate(maxBitrate);
                    }
                    params = this.applySendEncodings(sendEncodingIndex);
                    return !params.encodings[sendEncodingIndex].active;
                };
                WebRtcMediaStream.prototype.findSendEncodingIndex = function (bitrateRequest) {
                    var sender = this._sender;
                    if (sender && sender.getParameters) {
                        var params = sender.getParameters();
                        if (params && params.encodings) {
                            for (var i = 0; i < params.encodings.length; i++) {
                                var rid = 'rid' in params.encodings[i] ? params.encodings[i].rid : null;
                                if (rid != null && rid == bitrateRequest.getRtpStreamId()) {
                                    return i;
                                }
                                var ssrc = 'ssrc' in params.encodings[i] ? params.encodings[i].ssrc : -1;
                                if (ssrc != -1 && ssrc == bitrateRequest.getSynchronizationSource()) {
                                    return i;
                                }
                            }
                        }
                    }
                    return -1;
                };
                WebRtcMediaStream.prototype.addOnDiscardBitrateNotification = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onDiscardBitrateNotificationValues, value);
                };
                WebRtcMediaStream.prototype.removeOnDiscardBitrateNotification = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onDiscardBitrateNotificationValues, value);
                };
                WebRtcMediaStream.prototype._raiseOnDiscardBitrateNotification = function (bitrateNotification) {
                    for (var _i = 0, _a = this._onDiscardBitrateNotificationValues; _i < _a.length; _i++) {
                        var onDiscardBitrateNotificationValue = _a[_i];
                        onDiscardBitrateNotificationValue(bitrateNotification);
                    }
                };
                WebRtcMediaStream.prototype.processBitrateNotification = function (bitrateNotification) {
                    bitrateNotification.setMediaDescriptionId(this.getMediaDescriptionId() || new fm.icelink.StreamTypeWrapper(this.getType()).toString().toLowerCase());
                    this._raiseOnDiscardBitrateNotification(bitrateNotification);
                };
                WebRtcMediaStream.prototype.raiseBitrateNotification = function (bitrateNotification) {
                    return true;
                };
                WebRtcMediaStream.prototype.setMaxSendBitrate = function (value) {
                    var _this = this;
                    _super.prototype.setMaxSendBitrate.call(this, value);
                    var connection = this.getConnection();
                    if (!connection) {
                        return fm.icelink.Promise.rejectNow(new fm.icelink.Exception('Media stream is not attached to a connection.'));
                    }
                    var promise = new fm.icelink.Promise();
                    connection.setMaxSendBitrate(_super.prototype.getMaxSendBitrate.call(this), this.getType()).then(function (o) {
                        _this.applySendEncodings();
                        promise.resolve(o);
                    }, function (ex) {
                        promise.reject(ex);
                    });
                    return promise;
                };
                WebRtcMediaStream.prototype.setMaxReceiveBitrate = function (value) {
                    _super.prototype.setMaxReceiveBitrate.call(this, value);
                    var bitrateRequest = new fm.icelink.BitrateRequest();
                    bitrateRequest.setBitrate(_super.prototype.getMaxReceiveBitrate.call(this));
                    this.processBitrateRequest(bitrateRequest);
                };
                return WebRtcMediaStream;
            }(fm.icelink.WebRtcMediaStreamBase));
            icelink.WebRtcMediaStream = WebRtcMediaStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcAudioStream =  (function (_super) {
                __extends(WebRtcAudioStream, _super);
                function WebRtcAudioStream(external, localTrack, remoteTrack) {
                    var _this = _super.call(this, external, localTrack, remoteTrack, fm.icelink.StreamType.Audio) || this;
                    _this._dtmfSender = null;
                    _this._onSendDtmfToneValues = [];
                    _this._onSendDtmfToneChangeValues = [];
                    _this._onDiscardOutboundDtmfTonesValues = [];
                    _this._external = external;
                    return _this;
                }
                WebRtcAudioStream.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcAudioStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcAudioStream.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcAudioStream.prototype.getDiscardDtmfTones = function () {
                    return this._discardDtmfTones;
                };
                WebRtcAudioStream.prototype.setDiscardDtmfTones = function (value) {
                    this._discardDtmfTones = value;
                };
                WebRtcAudioStream.prototype.addOnDiscardOutboundDtmfTones = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onDiscardOutboundDtmfTonesValues, value);
                };
                WebRtcAudioStream.prototype.removeOnDiscardOutboundDtmfTones = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onDiscardOutboundDtmfTonesValues, value);
                };
                WebRtcAudioStream.prototype.raiseOnDiscardOutboundDtmfTones = function (dtmfTones) {
                    for (var _i = 0, _a = this._onDiscardOutboundDtmfTonesValues; _i < _a.length; _i++) {
                        var onDiscardOutboundDtmfTonesValue = _a[_i];
                        onDiscardOutboundDtmfTonesValue(dtmfTones);
                    }
                };
                WebRtcAudioStream.prototype.addOnReceiveDtmfTone = function (value) {
                    throw new fm.icelink.Exception('DTMF receive-tone events are not supported by WebRTC.');
                };
                WebRtcAudioStream.prototype.addOnReceiveDtmfToneChange = function (value) {
                    throw new fm.icelink.Exception('DTMF receive-tone-change events are not supported by WebRTC.');
                };
                WebRtcAudioStream.prototype.addOnSendDtmfTone = function (value) {
                    throw new fm.icelink.Exception('DTMF send-tone events are not supported by WebRTC.');
                };
                WebRtcAudioStream.prototype.addOnSendDtmfToneChange = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onSendDtmfToneChangeValues, value);
                };
                WebRtcAudioStream.prototype.insertDtmfTone = function (dtmfTone) {
                    return this.insertDtmfTones([dtmfTone]);
                };
                WebRtcAudioStream.prototype.insertDtmfTones = function (dtmfTones) {
                    var _this = this;
                    if (this._discardDtmfTones) {
                        this.raiseOnDiscardOutboundDtmfTones(dtmfTones);
                        return true;
                    }
                    if (this._dtmfSender == null) {
                        var connection = this.getConnection();
                        if (!connection) {
                            this.raiseOnDiscardOutboundDtmfTones(dtmfTones);
                            return false;
                        }
                        this._dtmfSender = connection.getDtmfSender();
                        if (this._dtmfSender == null) {
                            this.raiseOnDiscardOutboundDtmfTones(dtmfTones);
                            return false;
                        }
                        this._dtmfSender.ontonechange = function (ev) {
                            var tones = fm.icelink.dtmf.Tone.fromToneString(ev.tone);
                            for (var _i = 0, _a = _this._onSendDtmfToneChangeValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                for (var _b = 0, tones_2 = tones; _b < tones_2.length; _b++) {
                                    var tone = tones_2[_b];
                                    value(tone);
                                }
                            }
                        };
                    }
                    this._dtmfSender.insertDTMF(fm.icelink.dtmf.Tone.toToneString(dtmfTones));
                    return true;
                };
                WebRtcAudioStream.prototype.removeOnReceiveDtmfTone = function (value) {
                    throw new fm.icelink.Exception('DTMF receive-tone events are not supported by WebRTC.');
                };
                WebRtcAudioStream.prototype.removeOnReceiveDtmfToneChange = function (value) {
                    throw new fm.icelink.Exception('DTMF receive-tone-change events are not supported by WebRTC.');
                };
                WebRtcAudioStream.prototype.removeOnSendDtmfTone = function (value) {
                    throw new fm.icelink.Exception('DTMF send-tone events are not supported by WebRTC.');
                };
                WebRtcAudioStream.prototype.removeOnSendDtmfToneChange = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onSendDtmfToneChangeValues, value);
                };
                WebRtcAudioStream.prototype.getOpusDisabled = function () {
                    return this.getCodecDisabled(fm.icelink.AudioFormat.getOpusName());
                };
                WebRtcAudioStream.prototype.getG722Disabled = function () {
                    return this.getCodecDisabled(fm.icelink.AudioFormat.getG722Name());
                };
                WebRtcAudioStream.prototype.getPcmuDisabled = function () {
                    return this.getCodecDisabled(fm.icelink.AudioFormat.getPcmuName());
                };
                WebRtcAudioStream.prototype.getPcmaDisabled = function () {
                    return this.getCodecDisabled(fm.icelink.AudioFormat.getPcmaName());
                };
                WebRtcAudioStream.prototype.setOpusDisabled = function (value) {
                    return this.setCodecDisabled(fm.icelink.AudioFormat.getOpusName(), value);
                };
                WebRtcAudioStream.prototype.setG722Disabled = function (value) {
                    return this.setCodecDisabled(fm.icelink.AudioFormat.getG722Name(), value);
                };
                WebRtcAudioStream.prototype.setPcmuDisabled = function (value) {
                    return this.setCodecDisabled(fm.icelink.AudioFormat.getPcmuName(), value);
                };
                WebRtcAudioStream.prototype.setPcmaDisabled = function (value) {
                    return this.setCodecDisabled(fm.icelink.AudioFormat.getPcmaName(), value);
                };
                return WebRtcAudioStream;
            }(fm.icelink.WebRtcMediaStream));
            icelink.WebRtcAudioStream = WebRtcAudioStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcMediaTrack =  (function (_super) {
                __extends(WebRtcMediaTrack, _super);
                function WebRtcMediaTrack(external, media) {
                    var _this = _super.call(this) || this;
                    _this._onStartedValues = [];
                    _this._onStoppedValues = [];
                    _this._onDestroyedValues = [];
                    _this._outputs = [];
                    _this._inputs = [];
                    _this._mediaStreamTrackDisabled = false;
                    _this._muted = false;
                    _this._media = media;
                    return _this;
                }
                WebRtcMediaTrack.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcMediaTrack]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcMediaTrack.prototype.getOutputs = function () {
                    return this._outputs;
                };
                WebRtcMediaTrack.prototype.addOutput = function (output) {
                    fm.icelink.ArrayExtensions.add(this._outputs, output);
                };
                WebRtcMediaTrack.prototype.removeOutput = function (output) {
                    return fm.icelink.ArrayExtensions.remove(this._outputs, output);
                };
                WebRtcMediaTrack.prototype.getInputs = function () {
                    return this._inputs;
                };
                WebRtcMediaTrack.prototype.addInput = function (input) {
                    fm.icelink.ArrayExtensions.add(this._inputs, input);
                };
                WebRtcMediaTrack.prototype.removeInput = function (input) {
                    return fm.icelink.ArrayExtensions.remove(this._inputs, input);
                };
                WebRtcMediaTrack.prototype._getMediaStreamTrack = function () {
                    return this._mediaStreamTrack;
                };
                WebRtcMediaTrack.prototype._setMediaStreamTrack = function (mediaStreamTrack) {
                    var _this = this;
                    if (mediaStreamTrack) {
                        if (mediaStreamTrack != this._mediaStreamTrack) {
                            mediaStreamTrack.onended = function (e) {
                                _this.raiseOnStopped();
                            };
                            for (var _i = 0, _a = this._onStartedValues; _i < _a.length; _i++) {
                                var value = _a[_i];
                                value();
                            }
                        }
                    }
                    else {
                        this._mediaStreamTrackDisabled = true;
                        if (this._mediaStreamTrack) {
                            this._mediaStreamTrack.onended = null;
                        }
                    }
                    this._mediaStreamTrack = mediaStreamTrack;
                    this.setMuted(this._muted);
                    var _loop_1 = function (output) {
                        output.replaceLocalTrack(this_1).fail(function (ex) {
                            fm.icelink.Log.error('Could not replace local track attached to ' + output.getType() + ' stream for connection ' + output.getConnectionId() + '.', ex);
                        });
                    };
                    var this_1 = this;
                    for (var _b = 0, _c = this.getOutputs(); _b < _c.length; _b++) {
                        var output = _c[_b];
                        _loop_1(output);
                    }
                };
                WebRtcMediaTrack.prototype._getMediaStreamTrackDisabled = function () {
                    return this._mediaStreamTrackDisabled;
                };
                WebRtcMediaTrack.prototype.addOnStarted = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onStartedValues, value);
                };
                WebRtcMediaTrack.prototype.addOnStopped = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onStoppedValues, value);
                };
                WebRtcMediaTrack.prototype.addOnDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onDestroyedValues, value);
                };
                WebRtcMediaTrack.prototype.removeOnStarted = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onStartedValues, value);
                };
                WebRtcMediaTrack.prototype.removeOnStopped = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onStoppedValues, value);
                };
                WebRtcMediaTrack.prototype.removeOnDestroyed = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onDestroyedValues, value);
                };
                WebRtcMediaTrack.prototype.getMedia = function () {
                    return this._media;
                };
                WebRtcMediaTrack.prototype.getMuted = function () {
                    var mediaStreamTrack = this._getMediaStreamTrack();
                    if (mediaStreamTrack) {
                        return !mediaStreamTrack.enabled;
                    }
                    return false;
                };
                WebRtcMediaTrack.prototype.setMuted = function (muted) {
                    this._muted = muted;
                    var mediaStreamTrack = this._getMediaStreamTrack();
                    if (mediaStreamTrack) {
                        mediaStreamTrack.enabled = !muted;
                    }
                };
                WebRtcMediaTrack.prototype.stop = function () {
                    var mediaStreamTrack = this._getMediaStreamTrack();
                    if (mediaStreamTrack) {
                        mediaStreamTrack.stop();
                        if (this.getMedia() instanceof fm.icelink.WebRtcLocalMedia) {
                            this.raiseOnStopped();
                        }
                    }
                };
                WebRtcMediaTrack.prototype.destroy = function () {
                    if (this._mediaStreamTrack) {
                        for (var _i = 0, _a = this._onDestroyedValues; _i < _a.length; _i++) {
                            var value = _a[_i];
                            value();
                        }
                        return true;
                    }
                    return false;
                };
                WebRtcMediaTrack.prototype.raiseOnStopped = function () {
                    for (var _i = 0, _a = this._onStoppedValues; _i < _a.length; _i++) {
                        var value = _a[_i];
                        value();
                    }
                };
                return WebRtcMediaTrack;
            }(fm.icelink.WebRtcMediaTrackBase));
            icelink.WebRtcMediaTrack = WebRtcMediaTrack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcAudioTrack =  (function (_super) {
                __extends(WebRtcAudioTrack, _super);
                function WebRtcAudioTrack(external, media) {
                    var _this = _super.call(this, external, media) || this;
                    _this._external = external;
                    return _this;
                }
                WebRtcAudioTrack.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcAudioTrack]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcAudioTrack.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcAudioTrack.prototype.isLocal = function () {
                    return (fm.icelink.Util.isObjectType(this.getMedia(), '[fm.icelink.WebRtcLocalMedia]'));
                };
                WebRtcAudioTrack.prototype.changeSinkOutput = function (sinkOutput) {
                    if (this.isLocal()) {
                        var promise = new fm.icelink.Promise();
                        promise.reject(new fm.icelink.Exception('Cannot call AudioTrack.changeSinkOutput on a local track.'));
                        return promise;
                    }
                    return this.getMedia().changeAudioSinkOutput(sinkOutput);
                };
                WebRtcAudioTrack.prototype.getSinkOutput = function () {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.getSinkOutput on a local track.');
                    }
                    return this.getMedia().getAudioSinkOutput();
                };
                WebRtcAudioTrack.prototype.getSinkOutputs = function () {
                    if (this.isLocal()) {
                        var promise = new fm.icelink.Promise();
                        promise.reject(new fm.icelink.Exception('Cannot call AudioTrack.getSinkOutputs on a local track.'));
                        return promise;
                    }
                    return this.getMedia().getAudioSinkOutputs();
                };
                WebRtcAudioTrack.prototype.setSinkOutput = function (value) {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.setSinkOutput on a local track.');
                    }
                    this.getMedia().setAudioSinkOutput(value);
                };
                WebRtcAudioTrack.prototype.changeSourceInput = function (sourceInput) {
                    if (!this.isLocal()) {
                        var promise = new fm.icelink.Promise();
                        promise.reject(new fm.icelink.Exception('Cannot call AudioTrack.changeSourceInput on a remote track.'));
                        return promise;
                    }
                    return this.getMedia().changeAudioSourceInput(sourceInput);
                };
                WebRtcAudioTrack.prototype.getSourceInput = function () {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.getSourceInput on a remote track.');
                    }
                    return this.getMedia().getAudioSourceInput();
                };
                WebRtcAudioTrack.prototype.getSourceInputs = function () {
                    if (!this.isLocal()) {
                        var promise = new fm.icelink.Promise();
                        promise.reject(new fm.icelink.Exception('Cannot call AudioTrack.getSourceInputs on a remote track.'));
                        return promise;
                    }
                    return this.getMedia().getAudioSourceInputs();
                };
                WebRtcAudioTrack.prototype.setSourceInput = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call AudioTrack.setSourceInput on a remote track.');
                    }
                    this.getMedia().setAudioSourceInput(value);
                };
                WebRtcAudioTrack.prototype.addOnLevel = function (value) {
                    return this.getMedia().addOnAudioLevel(value);
                };
                WebRtcAudioTrack.prototype.getGain = function () {
                    return this.getMedia().getAudioGain();
                };
                WebRtcAudioTrack.prototype.getVolume = function () {
                    return this.getMedia().getAudioVolume();
                };
                WebRtcAudioTrack.prototype.removeOnLevel = function (value) {
                    return this.getMedia().removeOnAudioLevel(value);
                };
                WebRtcAudioTrack.prototype.setGain = function (value) {
                    this.getMedia().setAudioGain(value);
                };
                WebRtcAudioTrack.prototype.setVolume = function (value) {
                    this.getMedia().setAudioVolume(value);
                };
                return WebRtcAudioTrack;
            }(fm.icelink.WebRtcMediaTrack));
            icelink.WebRtcAudioTrack = WebRtcAudioTrack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    function fmicelinkWebRtcConnection_makeMediaStream() {
        return new MediaStream();
    }
    (function (fm) {
        (function (icelink) {
            var WebRtcConnection =  (function (_super) {
                __extends(WebRtcConnection, _super);
                function WebRtcConnection(external, streams, remoteMedia) {
                    var _this = _super.call(this, new Object()) || this;
                    _this._remoteMediaTrackCount = 0;
                    _this._dataStreamsReady = false;
                    _this._mediaStreamsReady = false;
                    _this._lastMediaComponentFrameStatsCollection = {};
                    _this._iceCandidateProcessingTimeout = 2000;
                    _this.dtmfSender = null;
                    _this._setMaxSendBitrateQueue = [];
                    _this._processingMaxSendBitrate = false;
                    _this._external = external;
                    _this._remoteMedia = remoteMedia;
                    if (!fm.icelink.Plugin.hasWebRtc() && !fm.icelink.Plugin.hasOrtc()) {
                        throw new fm.icelink.Exception('Native browser support for WebRTC/ORTC could not be found.');
                    }
                    _this._streams = [];
                    _this._mediaStreams = [];
                    _this._audioStreams = [];
                    _this._videoStreams = [];
                    _this._dataStreams = [];
                    _this._isRenegotiation = false;
                    _this._initialized = false;
                    _this._localDescription = null;
                    _this._remoteDescription = null;
                    _this._sessionDescriptionManager = new fm.icelink.SessionDescriptionManager();
                    _this.addStreamsInternal(streams);
                    for (var _i = 0, streams_9 = streams; _i < streams_9.length; _i++) {
                        var stream = streams_9[_i];
                        stream.setConnectionId(_this.getId());
                        stream.setStateLock(_this._connectionLock);
                    }
                    return _this;
                }
                WebRtcConnection.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcConnection]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcConnection.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcConnection.prototype.getRemoteMedia = function () {
                    return this._remoteMedia;
                };
                WebRtcConnection.prototype.getNativePeerConnection = function () {
                    return this._nativePeerConnection;
                };
                WebRtcConnection.prototype.getNativeIceGatherers = function () {
                    return this._nativeIceGatherers;
                };
                WebRtcConnection.prototype.getNativeIceTransports = function () {
                    return this._nativeIceTransports;
                };
                WebRtcConnection.prototype.getNativeDtlsTransports = function () {
                    return this._nativeDtlsTransports;
                };
                WebRtcConnection.prototype.getNativeRtpSenders = function () {
                    return this._nativeRtpSenders;
                };
                WebRtcConnection.prototype.getNativeRtpReceivers = function () {
                    return this._nativeRtpReceivers;
                };
                WebRtcConnection.prototype.getInstance = function () {
                    return this;
                };
                WebRtcConnection.prototype.addStreamInternal = function (stream) {
                    stream.setConnection(this);
                    if (stream.getType() == fm.icelink.StreamType.Application) {
                        fm.icelink.ArrayExtensions.add(this._dataStreams, stream);
                    }
                    else {
                        if (stream.getType() == fm.icelink.StreamType.Audio) {
                            fm.icelink.ArrayExtensions.add(this._audioStreams, stream);
                        }
                        else if (stream.getType() == fm.icelink.StreamType.Video) {
                            fm.icelink.ArrayExtensions.add(this._videoStreams, stream);
                        }
                        else {
                            throw new fm.icelink.Exception('Unsupported stream type.');
                        }
                        fm.icelink.ArrayExtensions.add(this._mediaStreams, stream);
                    }
                    fm.icelink.ArrayExtensions.add(this._streams, stream);
                    this.registerStreamWithSessionDescriptionManager(stream);
                };
                WebRtcConnection.prototype.addStreamsInternal = function (streams) {
                    for (var _i = 0, streams_10 = streams; _i < streams_10.length; _i++) {
                        var stream = streams_10[_i];
                        this.addStreamInternal(stream);
                    }
                };
                WebRtcConnection.prototype.processStateChange = function () {
                    _super.prototype.processStateChange.call(this);
                    if ((!this.getLegacyTimeout() && this.getState() == fm.icelink.ConnectionState.Connecting) || (this.getLegacyTimeout() && this.getState() == fm.icelink.ConnectionState.Initializing)) {
                        this.startConnectionTimeout();
                    }
                };
                WebRtcConnection.prototype.startConnectionTimeout = function () {
                    var _this = this;
                    window.setTimeout(function () {
                        if (_this.getState() == fm.icelink.ConnectionState.Connecting || _this.getState() == fm.icelink.ConnectionState.Initializing) {
                            if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionNotEstablished, new fm.icelink.Exception('Could not establish connectivity with remote peer. Shutting down connection.')))) {
                                _this.doClose();
                                _this.setState(fm.icelink.ConnectionState.Failed);
                            }
                        }
                    }, this.getTimeout());
                };
                WebRtcConnection.prototype.getStreams = function () {
                    return this._streams;
                };
                WebRtcConnection.prototype.getMediaStreams = function () {
                    return this._mediaStreams;
                };
                WebRtcConnection.prototype.getAudioStreams = function () {
                    return this._audioStreams;
                };
                WebRtcConnection.prototype.getVideoStreams = function () {
                    return this._videoStreams;
                };
                WebRtcConnection.prototype.getDataStreams = function () {
                    return this._dataStreams;
                };
                WebRtcConnection.prototype.constraintMin = function (num1, num2) {
                    if (num1 == -1) {
                        return num2;
                    }
                    if (num2 == -1) {
                        return num1;
                    }
                    return Math.min(num1, num2);
                };
                WebRtcConnection.prototype.constraintMax = function (num1, num2) {
                    if (num1 == -1) {
                        return num2;
                    }
                    if (num2 == -1) {
                        return num1;
                    }
                    return Math.max(num1, num2);
                };
                WebRtcConnection.prototype.getStats = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    try {
                        var timestamp_1 = fm.icelink.DateTime.getUtcNow();
                        var stats_1 = new fm.icelink.ConnectionStats();
                        stats_1.setId(this.getId());
                        stats_1.setTimestamp(timestamp_1);
                        var successCallback = function (result) {
                            if (fm.icelink.Util.isFunction(result.result)) {
                                result = result.result();
                            }
                            var report = {};
                            if (fm.icelink.Util.isFunction(result.forEach)) {
                                result.forEach(function (stat) {
                                    if (fm.icelink.Util.isFunction(stat.names)) {
                                        var record_1 = stat;
                                        stat = {
                                            id: record_1.id,
                                            type: record_1.type
                                        };
                                        record_1.names().forEach(function (name) {
                                            stat[name] = record_1.stat(name);
                                        });
                                    }
                                    report[stat.id] = stat;
                                });
                            }
                            var audioMediaSenderIds = null;
                            var audioMediaReceiverIds = null;
                            var audioTransportId = null;
                            var videoMediaSenderIds = null;
                            var videoMediaReceiverIds = null;
                            var videoTransportId = null;
                            for (var key in report) {
                                var stat = report[key];
                                switch (stat.type) {
                                    case 'inboundrtp':
                                    case 'inbound-rtp':
                                        if (stat.mediaType == 'audio') {
                                            if (audioMediaReceiverIds == null) {
                                                audioMediaReceiverIds = [];
                                            }
                                            audioMediaReceiverIds.push(stat.id);
                                            audioTransportId = stat.transportId;
                                        }
                                        else {
                                            if (videoMediaReceiverIds == null) {
                                                videoMediaReceiverIds = [];
                                            }
                                            videoMediaReceiverIds.push(stat.id);
                                            videoTransportId = stat.transportId;
                                        }
                                        break;
                                    case 'outboundrtp':
                                    case 'outbound-rtp':
                                        if (stat.mediaType == 'audio') {
                                            if (audioMediaSenderIds == null) {
                                                audioMediaSenderIds = [];
                                            }
                                            audioMediaSenderIds.push(stat.id);
                                            audioTransportId = stat.transportId;
                                        }
                                        else {
                                            if (videoMediaSenderIds == null) {
                                                videoMediaSenderIds = [];
                                            }
                                            videoMediaSenderIds.push(stat.id);
                                            videoTransportId = stat.transportId;
                                        }
                                        break;
                                }
                            }
                            stats_1.setMediaStreams([]);
                            for (var _i = 0, _a = _this.getStreams(); _i < _a.length; _i++) {
                                var stream = _a[_i];
                                if (stream.getType() == fm.icelink.StreamType.Audio || stream.getType() == fm.icelink.StreamType.Video) {
                                    var mediaStream = stream;
                                    var mediaStreamStats = new fm.icelink.MediaStreamStats();
                                    mediaStreamStats.setId(stream.getId());
                                    mediaStreamStats.setTimestamp(timestamp_1);
                                    mediaStreamStats.setType(stream.getType());
                                    mediaStreamStats.setDirection(stream.getDirection());
                                    mediaStreamStats.setMaxSendBitrate(_this.constraintMin(mediaStream.getMaxSendBitrate(), mediaStream.getRemoteBandwidth()));
                                    mediaStreamStats.setMaxReceiveBitrate(_this.constraintMin(mediaStream.getMaxReceiveBitrate(), mediaStream.getLocalBandwidth()));
                                    var mediaSenderIds = void 0, mediaReceiverIds = void 0, transportId = void 0;
                                    if (stream.getType() == fm.icelink.StreamType.Audio) {
                                        mediaSenderIds = audioMediaSenderIds;
                                        mediaReceiverIds = audioMediaReceiverIds;
                                        transportId = audioTransportId;
                                    }
                                    else {
                                        mediaSenderIds = videoMediaSenderIds;
                                        mediaReceiverIds = videoMediaReceiverIds;
                                        transportId = videoTransportId;
                                    }
                                    if (mediaStream.getDirection() == fm.icelink.StreamDirection.SendReceive || mediaStream.getDirection() == fm.icelink.StreamDirection.SendOnly) {
                                        if (mediaSenderIds != null) {
                                            var senders = [];
                                            for (var _b = 0, mediaSenderIds_1 = mediaSenderIds; _b < mediaSenderIds_1.length; _b++) {
                                                var mediaSenderId = mediaSenderIds_1[_b];
                                                var sender = _this.getMediaSenderStats(mediaSenderId, report, mediaStream);
                                                if (sender != null) {
                                                    senders.push(sender);
                                                }
                                            }
                                            senders.sort(function (s1, s2) {
                                                var rid1 = s1.getRtpStreamId();
                                                var rid2 = s2.getRtpStreamId();
                                                if (!rid1 && !rid2) {
                                                    return 0;
                                                }
                                                if (!rid1) {
                                                    return -1;
                                                }
                                                if (!rid2) {
                                                    return 1;
                                                }
                                                return rid1.localeCompare(rid2);
                                            });
                                            mediaStreamStats.setSenders(senders);
                                        }
                                    }
                                    if (mediaStream.getDirection() == fm.icelink.StreamDirection.SendReceive || mediaStream.getDirection() == fm.icelink.StreamDirection.ReceiveOnly) {
                                        if (mediaReceiverIds != null) {
                                            var receivers = [];
                                            for (var _c = 0, mediaReceiverIds_1 = mediaReceiverIds; _c < mediaReceiverIds_1.length; _c++) {
                                                var mediaReceiverId = mediaReceiverIds_1[_c];
                                                var receiver = _this.getMediaReceiverStats(mediaReceiverId, report, mediaStream);
                                                if (receiver != null) {
                                                    receivers.push(receiver);
                                                }
                                            }
                                            receivers.sort(function (r1, r2) {
                                                var rid1 = r1.getRtpStreamId();
                                                var rid2 = r2.getRtpStreamId();
                                                if (!rid1 && !rid2) {
                                                    return 0;
                                                }
                                                if (!rid1) {
                                                    return -1;
                                                }
                                                if (!rid2) {
                                                    return 1;
                                                }
                                                return rid1.localeCompare(rid2);
                                            });
                                            mediaStreamStats.setReceivers(receivers);
                                        }
                                    }
                                    mediaStreamStats.setTransport(_this.getTransportStats(transportId, report, mediaStreamStats.getSender(), mediaStreamStats.getReceiver()));
                                    if (mediaStreamStats.getTransport()) {
                                        var transportInfo = new fm.icelink.TransportInfo(mediaStreamStats.getTransport(), null);
                                        mediaStream.setTransportInfo(transportInfo);
                                        var rtcpTransport = mediaStreamStats.getTransport().getRtcpTransport();
                                        if (rtcpTransport != null) {
                                            var rtcpTransportInfo = new fm.icelink.TransportInfo(rtcpTransport, null);
                                            mediaStream.setControlTransportInfo(rtcpTransportInfo);
                                        }
                                    }
                                    stats_1.getMediaStreams().push(mediaStreamStats);
                                }
                                else {
                                    var dataStream = stream;
                                    var dataStreamStats = new fm.icelink.DataStreamStats();
                                    dataStreamStats.setId(stream.getId());
                                    dataStreamStats.setTimestamp(timestamp_1);
                                    dataStreamStats.setType(stream.getType());
                                    dataStreamStats.setChannels([]);
                                    for (var _d = 0, _e = dataStream.getChannels(); _d < _e.length; _d++) {
                                        var dataChannel = _e[_d];
                                        var dataChannelStats = new fm.icelink.DataChannelStats();
                                        dataChannelStats.setId(dataChannel.getId());
                                        dataChannelStats.setTimestamp(timestamp_1);
                                        dataChannelStats.setBytesSent(dataChannel.getBytesSent());
                                        dataChannelStats.setBytesReceived(dataChannel.getBytesReceived());
                                        dataChannelStats.setMessagesSent(dataChannel.getMessagesSent());
                                        dataChannelStats.setMessagesReceived(dataChannel.getMessagesReceived());
                                        dataChannelStats.setLabel(dataChannel.getLabel());
                                        dataChannelStats.setOrdered(dataChannel.getOrdered());
                                        dataChannelStats.setProtocol(dataChannel.getSubprotocol());
                                        dataChannelStats.setState(dataChannel.getState());
                                        dataStreamStats.getChannels().push(dataChannelStats);
                                    }
                                    if (dataStreamStats.getTransport()) {
                                        var transportInfo = new fm.icelink.TransportInfo(dataStreamStats.getTransport(), null);
                                        dataStream.setTransportInfo(transportInfo);
                                    }
                                    stats_1.setDataStream(dataStreamStats);
                                }
                            }
                            promise.resolve(stats_1);
                        };
                        var failureCallback = function (ex) {
                            promise.reject(ex);
                        };
                        if (this._nativePeerConnection && fm.icelink.Util.isFunction(this._nativePeerConnection.getStats) && this.getState() != fm.icelink.ConnectionState.Closing && this.getState() != fm.icelink.ConnectionState.Closed && this.getState() != fm.icelink.ConnectionState.Failing && this.getState() != fm.icelink.ConnectionState.Failed) {
                            try {
                                this._nativePeerConnection.getStats().then(successCallback, failureCallback);
                            }
                            catch (ex) {
                                try {
                                    this._nativePeerConnection.getStats(null, successCallback, failureCallback);
                                }
                                catch (ex) {
                                    try {
                                        this._nativePeerConnection.getStats(successCallback, null, failureCallback);
                                    }
                                    catch (ex) {
                                        successCallback({});
                                    }
                                }
                            }
                        }
                        else {
                            successCallback({});
                        }
                    }
                    catch (ex) {
                        promise.reject(ex);
                    }
                    return promise;
                };
                WebRtcConnection.prototype.getMediaSenderStats = function (mediaSenderId, report, _mediaStream) {
                    if (!mediaSenderId) {
                        return null;
                    }
                    var mediaSender = report[mediaSenderId];
                    if (!mediaSender) {
                        return null;
                    }
                    var mediaSenderStats = new fm.icelink.MediaSenderStats();
                    mediaSenderStats.setId(mediaSenderId);
                    mediaSenderStats.setTimestamp(fm.icelink.DateTime.getUtcNow());
                    mediaSenderStats.setBytesSent(mediaSender.bytesSent || 0);
                    mediaSenderStats.setCodec(this.getCodecStats(mediaSender.codecId, report, true));
                    mediaSenderStats.setFirCount(mediaSender.firCount || 0);
                    mediaSenderStats.setNackCount(mediaSender.nackCount || 0);
                    mediaSenderStats.setPacketsSent(mediaSender.packetsSent || 0);
                    mediaSenderStats.setPliCount(mediaSender.pliCount || 0);
                    mediaSenderStats.setRoundTripTime(Math.round((mediaSender.roundTripTime || 0) * 1000));
                    mediaSenderStats.setSynchronizationSource(mediaSender.ssrc || 0);
                    mediaSenderStats.setRtpStreamId(mediaSender.rid || mediaSender.rtpStreamId || null);
                    mediaSenderStats.setRepairedRtpStreamId(mediaSender.rrid || mediaSender.repairedRtpStreamId || null);
                    mediaSenderStats.setTrack(this.getMediaTrackStats(mediaSender.trackId || mediaSender.mediaTrackId, report, _mediaStream.getLocalTrack(), mediaSender, _mediaStream, true));
                    return mediaSenderStats;
                };
                WebRtcConnection.prototype.getMediaReceiverStats = function (mediaReceiverId, report, _mediaStream) {
                    if (!mediaReceiverId) {
                        return null;
                    }
                    var mediaReceiver = report[mediaReceiverId];
                    if (!mediaReceiver) {
                        return null;
                    }
                    var mediaReceiverStats = new fm.icelink.MediaReceiverStats();
                    mediaReceiverStats.setId(mediaReceiverId);
                    mediaReceiverStats.setTimestamp(fm.icelink.DateTime.getUtcNow());
                    mediaReceiverStats.setBytesReceived(mediaReceiver.bytesReceived || 0);
                    mediaReceiverStats.setCodec(this.getCodecStats(mediaReceiver.codecId, report, false));
                    mediaReceiverStats.setFirCount(mediaReceiver.firCount || 0);
                    mediaReceiverStats.setJitter(Math.round((mediaReceiver.jitter || 0) * 1000));
                    mediaReceiverStats.setNackCount(mediaReceiver.nackCount || 0);
                    mediaReceiverStats.setPacketsDiscarded(mediaReceiver.packetsDiscarded || 0);
                    mediaReceiverStats.setPacketsDuplicated(mediaReceiver.packetsDuplicated || 0);
                    mediaReceiverStats.setPacketsLost(mediaReceiver.packetsLost || 0);
                    mediaReceiverStats.setPacketsReceived(mediaReceiver.packetsReceived || 0);
                    mediaReceiverStats.setPacketsRepaired(mediaReceiver.packetsRepaired || 0);
                    mediaReceiverStats.setPliCount(mediaReceiver.pliCount || 0);
                    mediaReceiverStats.setSynchronizationSource(mediaReceiver.ssrc || 0);
                    mediaReceiverStats.setRtpStreamId(mediaReceiver.rid || mediaReceiver.rtpStreamId || null);
                    mediaReceiverStats.setRepairedRtpStreamId(mediaReceiver.rrid || mediaReceiver.repairedRtpStreamId || null);
                    mediaReceiverStats.setTrack(this.getMediaTrackStats(mediaReceiver.trackId || mediaReceiver.mediaTrackId, report, _mediaStream.getRemoteTrack(), mediaReceiver, _mediaStream, false));
                    return mediaReceiverStats;
                };
                WebRtcConnection.prototype.getTransportStats = function (transportId, report, mediaSenderStats, mediaReceiverStats) {
                    var transportStats = new fm.icelink.TransportStats();
                    transportStats.setId(transportId || null);
                    transportStats.setTimestamp(fm.icelink.DateTime.getUtcNow());
                    var localCandidateIds = [];
                    var remoteCandidateIds = [];
                    var candidatePairIds = [];
                    var selectedCandidatePairId = null;
                    for (var key in report) {
                        var stat = report[key];
                        switch (stat.type) {
                            case 'localcandidate':
                            case 'local-candidate':
                                localCandidateIds.push(stat.id);
                                break;
                            case 'remotecandidate':
                            case 'remote-candidate':
                                remoteCandidateIds.push(stat.id);
                                break;
                            case 'candidatepair':
                            case 'candidate-pair':
                                if (stat.selected) {
                                    selectedCandidatePairId = stat.id;
                                }
                                candidatePairIds.push(stat.id);
                                break;
                        }
                    }
                    transportStats.setCandidatePairs([]);
                    for (var _i = 0, candidatePairIds_1 = candidatePairIds; _i < candidatePairIds_1.length; _i++) {
                        var candidatePairId = candidatePairIds_1[_i];
                        transportStats.getCandidatePairs().push(this.getCandidatePairStats(candidatePairId, report));
                    }
                    transportStats.setLocalCandidates([]);
                    for (var _a = 0, localCandidateIds_1 = localCandidateIds; _a < localCandidateIds_1.length; _a++) {
                        var localCandidateId = localCandidateIds_1[_a];
                        transportStats.getLocalCandidates().push(this.getCandidateStats(localCandidateId, report));
                    }
                    transportStats.setRemoteCandidates([]);
                    for (var _b = 0, remoteCandidateIds_1 = remoteCandidateIds; _b < remoteCandidateIds_1.length; _b++) {
                        var remoteCandidateId = remoteCandidateIds_1[_b];
                        transportStats.getRemoteCandidates().push(this.getCandidateStats(remoteCandidateId, report));
                    }
                    var transport = report[transportId];
                    if (transport) {
                        transportStats.setActiveCandidatePair(this.getCandidatePairStats(transport.selectedCandidatePairId || selectedCandidatePairId, report));
                        transportStats.setBytesReceived(transport.bytesReceived || 0);
                        transportStats.setBytesSent(transport.bytesSent || 0);
                        transportStats.setLocalCertificate(this.getCertificateStats(transport.localCertificateId, report));
                        transportStats.setRemoteCertificate(this.getCertificateStats(transport.remoteCertificateId, report));
                        if (transport.rtcpTransportStatsId) {
                            transportStats.setRtcpTransport(this.getTransportStats(transport.rtcpTransportStatsId, report, mediaSenderStats, mediaReceiverStats));
                        }
                        else {
                            transportStats.setRtcpTransport(null);
                        }
                    }
                    else {
                        transportStats.setActiveCandidatePair(this.getCandidatePairStats(selectedCandidatePairId, report));
                        transportStats.setBytesReceived(0);
                        if (mediaReceiverStats) {
                            transportStats.setBytesReceived(mediaReceiverStats.getBytesReceived());
                        }
                        transportStats.setBytesSent(0);
                        if (mediaSenderStats) {
                            transportStats.setBytesSent(mediaSenderStats.getBytesSent());
                        }
                        transportStats.setLocalCertificate(null);
                        transportStats.setRemoteCertificate(null);
                        transportStats.setRtcpTransport(null);
                    }
                    return transportStats;
                };
                WebRtcConnection.prototype.getCertificateStats = function (certificateId, report) {
                    if (!certificateId) {
                        return null;
                    }
                    var certificate = report[certificateId];
                    if (!certificate) {
                        return null;
                    }
                    var certificateStats = new fm.icelink.CertificateStats();
                    certificateStats.setId(certificateId);
                    certificateStats.setTimestamp(fm.icelink.DateTime.getUtcNow());
                    certificateStats.setCertificateBase64(certificate.base64Certificate || null);
                    certificateStats.setFingerprint(certificate.fingerprint || null);
                    certificateStats.setFingerprintAlgorithm(certificate.fingerprintAlgorithm || null);
                    return certificateStats;
                };
                WebRtcConnection.prototype.getCandidateStats = function (candidateId, report) {
                    if (!candidateId) {
                        return null;
                    }
                    var candidate = report[candidateId];
                    if (!candidate) {
                        return null;
                    }
                    var candidateStats = new fm.icelink.CandidateStats();
                    candidateStats.setId(candidateId);
                    candidateStats.setTimestamp(fm.icelink.DateTime.getUtcNow());
                    candidateStats.setIPAddress(candidate.ip || candidate.ipAddress || null);
                    candidateStats.setPort(candidate.port || candidate.portNumber || -1);
                    candidateStats.setPriority(candidate.priority || -1);
                    candidateStats.setProtocol(fm.icelink.ProtocolType.Unknown);
                    switch (candidate.protocol || candidate.transport) {
                        case 'UDP':
                        case 'udp':
                            candidateStats.setProtocol(fm.icelink.ProtocolType.Udp);
                            break;
                        case 'TCP':
                        case 'tcp':
                            candidateStats.setProtocol(fm.icelink.ProtocolType.Tcp);
                            break;
                    }
                    candidateStats.setRelatedIPAddress(candidate.relatedIP || candidate.relatedIPAddress || null);
                    candidateStats.setRelatedPort(candidate.relatedPort || candidate.relatedPortNumber || -1);
                    candidateStats.setType(fm.icelink.CandidateType.Unknown);
                    switch (candidate.candidateType) {
                        case 'host':
                            candidateStats.setType(fm.icelink.CandidateType.Host);
                            break;
                        case 'srflx':
                            candidateStats.setType(fm.icelink.CandidateType.ServerReflexive);
                            break;
                        case 'relay':
                            candidateStats.setType(fm.icelink.CandidateType.Relayed);
                            break;
                        case 'prflx':
                            candidateStats.setType(fm.icelink.CandidateType.PeerReflexive);
                            break;
                    }
                    return candidateStats;
                };
                WebRtcConnection.prototype.getCandidatePairStats = function (candidatePairId, report) {
                    if (!candidatePairId) {
                        return null;
                    }
                    var candidatePair = report[candidatePairId];
                    if (!candidatePair) {
                        return null;
                    }
                    var candidatePairStats = new fm.icelink.CandidatePairStats();
                    candidatePairStats.setId(candidatePairId);
                    candidatePairStats.setTimestamp(fm.icelink.DateTime.getUtcNow());
                    candidatePairStats.setBytesReceived(candidatePair.bytesReceived || 0);
                    candidatePairStats.setBytesSent(candidatePair.bytesSent || 0);
                    candidatePairStats.setCurrentRoundTripTime(Math.round((candidatePair.currentRoundTripTime || 0) * 1000));
                    candidatePairStats.setLocalCandidateId(candidatePair.localCandidateId || null);
                    candidatePairStats.setNominated(candidatePair.nominated || false);
                    candidatePairStats.setPriority(candidatePair.priority || -1);
                    candidatePairStats.setRemoteCandidateId(candidatePair.remoteCandidateId || null);
                    candidatePairStats.setState(fm.icelink.CandidatePairState.New);
                    switch (candidatePair.state) {
                        case 'frozen':
                            candidatePairStats.setState(fm.icelink.CandidatePairState.New);
                            break;
                        case 'waiting':
                            candidatePairStats.setState(fm.icelink.CandidatePairState.Waiting);
                            break;
                        case 'inprogress':
                            candidatePairStats.setState(fm.icelink.CandidatePairState.InProgress);
                            break;
                        case 'failed':
                            candidatePairStats.setState(fm.icelink.CandidatePairState.Failed);
                            break;
                        case 'succeeded':
                            candidatePairStats.setState(fm.icelink.CandidatePairState.Succeeded);
                            break;
                        case 'cancelled':
                            candidatePairStats.setState(fm.icelink.CandidatePairState.Closed);
                            break;
                    }
                    candidatePairStats.setTotalRoundTripTime(Math.round((candidatePair.totalRoundTripTime || 0) * 1000));
                    candidatePairStats.setTransportId(candidatePair.transportId || null);
                    return candidatePairStats;
                };
                WebRtcConnection.prototype.getCodecStats = function (codecId, report, sender) {
                    if (!codecId) {
                        return null;
                    }
                    var codec = report[codecId];
                    if (!codec) {
                        return null;
                    }
                    var name = codec.codec || codec.mimeType || codec.name;
                    if (name && (name.indexOf('audio/') == 0 || name.indexOf('video/') == 0)) {
                        name = name.substr(6);
                    }
                    var codecStats = new fm.icelink.CodecStats();
                    codecStats.setId(codecId);
                    if (sender) {
                        codecStats.setCodecType(fm.icelink.CodecType.Encode);
                    }
                    else {
                        codecStats.setCodecType(fm.icelink.CodecType.Decode);
                    }
                    codecStats.setTimestamp(fm.icelink.DateTime.getUtcNow());
                    codecStats.setChannelCount(codec.channels || codec.channelCount || 0);
                    codecStats.setClockRate(codec.clockRate || 0);
                    codecStats.setName(name || null);
                    codecStats.setParameters(codec.parameters || null);
                    codecStats.setPayloadType(codec.payloadType || -1);
                    if (codecStats.getName() == 'opus' && codecStats.getChannelCount() == 0) {
                        codecStats.setChannelCount(2);
                    }
                    return codecStats;
                };
                WebRtcConnection.prototype.getWebRTCBundlePolicyString = function () {
                    var bundlePolicy = this.getBundlePolicy();
                    if (bundlePolicy == fm.icelink.BundlePolicy.Balanced) {
                        return "balanced";
                    }
                    else if (bundlePolicy == fm.icelink.BundlePolicy.MaxBundle) {
                        return "max-bundle";
                    }
                    else if (bundlePolicy == fm.icelink.BundlePolicy.MaxCompatibility) {
                        return "max-compat";
                    }
                    else {
                        return "max-compat";
                    }
                };
                WebRtcConnection.prototype.getMediaTrackStats = function (mediaTrackId, report, _mediaTrack, mediaComponent, _mediaStream, local) {
                    var _this = this;
                    if (!mediaTrackId) {
                        return null;
                    }
                    var mediaTrack = report[mediaTrackId];
                    if (!mediaTrack) {
                        return null;
                    }
                    var lastMediaComponentFrameStats = this._lastMediaComponentFrameStatsCollection[mediaComponent.id];
                    if (!lastMediaComponentFrameStats) {
                        lastMediaComponentFrameStats = this._lastMediaComponentFrameStatsCollection[mediaComponent.id] = {};
                    }
                    if (mediaComponent.hasOwnProperty('frameWidth')) {
                        lastMediaComponentFrameStats.frameWidth = mediaComponent.frameWidth;
                    }
                    if (mediaComponent.hasOwnProperty('frameHeight')) {
                        lastMediaComponentFrameStats.frameHeight = mediaComponent.frameHeight;
                    }
                    if (mediaComponent.hasOwnProperty('framesPerSecond')) {
                        lastMediaComponentFrameStats.framesPerSecond = mediaComponent.framesPerSecond;
                    }
                    if (mediaComponent.hasOwnProperty('framesCorrupted')) {
                        lastMediaComponentFrameStats.framesCorrupted = mediaComponent.framesCorrupted;
                    }
                    if (mediaComponent.hasOwnProperty('framesDecoded')) {
                        lastMediaComponentFrameStats.framesDecoded = mediaComponent.framesDecoded;
                    }
                    if (mediaComponent.hasOwnProperty('framesDropped')) {
                        lastMediaComponentFrameStats.framesDropped = mediaComponent.framesDropped;
                    }
                    if (mediaComponent.hasOwnProperty('framesEncoded')) {
                        lastMediaComponentFrameStats.framesEncoded = mediaComponent.framesEncoded;
                    }
                    if (mediaComponent.hasOwnProperty('framesReceived')) {
                        lastMediaComponentFrameStats.framesReceived = mediaComponent.framesReceived;
                    }
                    if (mediaComponent.hasOwnProperty('framesSent')) {
                        lastMediaComponentFrameStats.framesSent = mediaComponent.framesSent;
                    }
                    if (mediaComponent.hasOwnProperty('targetBitrate')) {
                        lastMediaComponentFrameStats.targetBitrate = mediaComponent.targetBitrate;
                    }
                    var mediaTrackStats = new fm.icelink.MediaTrackStats();
                    mediaTrackStats.setId(mediaTrackId);
                    mediaTrackStats.setTimestamp(fm.icelink.DateTime.getUtcNow());
                    mediaTrackStats.setDetached(mediaTrack.detached || false);
                    mediaTrackStats.setFrameWidth(lastMediaComponentFrameStats.frameWidth || mediaTrack.frameWidth || 0);
                    mediaTrackStats.setFrameHeight(lastMediaComponentFrameStats.frameHeight || mediaTrack.frameHeight || 0);
                    mediaTrackStats.setFrameRate(lastMediaComponentFrameStats.framesPerSecond || mediaTrack.framesPerSecond || mediaTrack.frameRate || 0);
                    mediaTrackStats.setFramesCorrupted(lastMediaComponentFrameStats.framesCorrupted || mediaTrack.framesCorrupted || 0);
                    mediaTrackStats.setFramesDecoded(lastMediaComponentFrameStats.framesDecoded || mediaTrack.framesDecoded || 0);
                    mediaTrackStats.setFramesDropped(lastMediaComponentFrameStats.framesDropped || mediaTrack.framesDropped || 0);
                    mediaTrackStats.setFramesEncoded(lastMediaComponentFrameStats.framesEncoded || mediaTrack.framesEncoded || 0);
                    mediaTrackStats.setFramesReceived(lastMediaComponentFrameStats.framesReceived || mediaTrack.framesReceived || 0);
                    mediaTrackStats.setFramesSent(lastMediaComponentFrameStats.framesSent || mediaTrack.framesSent || 0);
                    mediaTrackStats.setMuted(_mediaTrack ? _mediaTrack.getMuted() : false);
                    mediaTrackStats.setStopped(mediaTrack.ended || mediaTrack.stopped || false);
                    mediaTrackStats.setSynchronizationSources(mediaTrack.ssrcIds || []);
                    if (local) {
                        var bitrate_1 = -1;
                        if (lastMediaComponentFrameStats.hasOwnProperty('targetBitrate')) {
                            bitrate_1 = lastMediaComponentFrameStats.targetBitrate / 1000;
                        }
                        var minBitrate = -1;
                        var maxBitrate_1 = _mediaStream.getSingleSendBitrate();
                        var frameRate_15 = mediaTrackStats.getFrameRate();
                        maxBitrate_1 = this.constraintMin(maxBitrate_1, _mediaStream.getMaxSendBitrate());
                        maxBitrate_1 = this.constraintMin(maxBitrate_1, _mediaStream.getRemoteBandwidth());
                        var sendEncodings = _mediaStream.getSendEncodings();
                        if (sendEncodings && sendEncodings.length > 0) {
                            var applySendEncoding = function (sendEncoding) {
                                bitrate_1 = sendEncoding.getBitrate();
                                maxBitrate_1 = _this.constraintMax(maxBitrate_1, sendEncoding.getBitrate());
                                if (sendEncoding instanceof fm.icelink.VideoEncodingConfig) {
                                    var videoSendEncoding = sendEncoding;
                                    if (videoSendEncoding.getFrameRate() > 0) {
                                        frameRate_15 = videoSendEncoding.getFrameRate();
                                    }
                                }
                            };
                            for (var _i = 0, sendEncodings_2 = sendEncodings; _i < sendEncodings_2.length; _i++) {
                                var sendEncoding = sendEncodings_2[_i];
                                if ((mediaComponent.rid && mediaComponent.rid == sendEncoding.getRtpStreamId()) ||
                                    (mediaComponent.ssrc && mediaComponent.ssrc == sendEncoding.getSynchronizationSource())) {
                                    applySendEncoding(sendEncoding);
                                }
                            }
                            if (bitrate_1 == -1) {
                                for (var i = 0; i < sendEncodings.length; i++) {
                                    if (mediaComponent.rid) {
                                        var index = parseInt(mediaComponent.rid);
                                        if (!isNaN(index) && index == i) {
                                            applySendEncoding(sendEncodings[i]);
                                        }
                                    }
                                }
                            }
                        }
                        mediaTrackStats.setBitrate(bitrate_1);
                        mediaTrackStats.setMinBitrate(this.constraintMax(minBitrate, _mediaStream.getType() == fm.icelink.StreamType.Audio ? 6 : 100));
                        mediaTrackStats.setMaxBitrate(this.constraintMin(maxBitrate_1, _mediaStream.getType() == fm.icelink.StreamType.Audio ? 510 : 100000));
                        mediaTrackStats.setFrameRate(frameRate_15);
                    }
                    return mediaTrackStats;
                };
                WebRtcConnection.prototype.initialize = function () {
                    var _this = this;
                    this.setState(fm.icelink.ConnectionState.Initializing);
                    var allowTcp = (this._ortcSupportsTcp || (fm.icelink.Plugin.hasWebRtc() && !fm.icelink.Plugin.hasOrtc()));
                    var servers = [];
                    for (var _i = 0, _a = this.getIceServers(); _i < _a.length; _i++) {
                        var server = _a[_i];
                        if (fm.icelink.StringExtensions.endsWith(server.getUrl(), '?transport=udp')) {
                            servers.push(server);
                        }
                        else if (fm.icelink.StringExtensions.endsWith(server.getUrl(), '?transport=tcp')) {
                            if (allowTcp) {
                                servers.push(server);
                            }
                        }
                        else {
                            if (server.getIsStun()) {
                                servers.push(new fm.icelink.IceServer(server.getUrl() + '?transport=udp'));
                            }
                            else {
                                servers.push(new fm.icelink.IceServer(server.getUrl() + '?transport=udp', server.getUsername(), server.getPassword()));
                                if (allowTcp) {
                                    servers.push(new fm.icelink.IceServer(server.getUrl() + '?transport=tcp', server.getUsername(), server.getPassword()));
                                }
                            }
                        }
                    }
                    var rtcServers = [];
                    for (var _b = 0, servers_1 = servers; _b < servers_1.length; _b++) {
                        var server = servers_1[_b];
                        fm.icelink.Log.debug('Using ' + server.getUrl() + '.');
                        var rtcServer = {};
                        rtcServer.urls = [server.getUrl()];
                        if (server.getIsTurn()) {
                            rtcServer.username = server.getUsername();
                            rtcServer.credential = server.getPassword();
                        }
                        rtcServers.push(rtcServer);
                    }
                    var mediaStreamCount = this._mediaStreams.length;
                    var dataChannelCount = 0;
                    for (var _c = 0, _d = this._dataStreams; _c < _d.length; _c++) {
                        var dataStream = _d[_c];
                        dataChannelCount += dataStream.getChannels().length;
                    }
                    if (fm.icelink.Plugin.hasOrtc()) {
                        if (dataChannelCount > 0) {
                            throw new fm.icelink.Exception('ORTC does not currently support data channels.');
                        }
                        this._remoteNativeMediaStream = fmicelinkWebRtcConnection_makeMediaStream();
                        this._nativeIceGatherers = [];
                        this._nativeIceTransports = [];
                        this._nativeDtlsTransports = [];
                        this._nativeRtpSenders = [];
                        this._nativeRtpReceivers = [];
                        this._rtpKinds = [];
                        this._localDescription = null;
                        this._remoteDescription = null;
                        this._gatheringState = fm.icelink.IceGatheringState.New;
                        this._iceConnectionState = fm.icelink.IceConnectionState.New;
                        this._transportsRemaining = 0;
                        if (mediaStreamCount > 0) {
                            var mediaStreams = this.getMediaStreams();
                            var elements = [];
                            var index = 0;
                            for (var _e = 0, mediaStreams_4 = mediaStreams; _e < mediaStreams_4.length; _e++) {
                                var mediaStream = mediaStreams_4[_e];
                                var streamType = mediaStream.getType();
                                var localTrack = mediaStream.getLocalTrack();
                                var mediaStreamTrack = (localTrack == null) ? null : localTrack._getMediaStreamTrack();
                                var streamKind = (streamType == fm.icelink.StreamType.Audio) ? 'audio' : 'video';
                                if (streamType == fm.icelink.StreamType.Audio || streamType == fm.icelink.StreamType.Video) {
                                    elements.push({
                                        track: mediaStreamTrack,
                                        kind: streamKind,
                                        index: index++
                                    });
                                }
                            }
                            for (var _f = 0, elements_1 = elements; _f < elements_1.length; _f++) {
                                var element = elements_1[_f];
                                this._remoteNativeMediaStream.addTrack(this.initializeTrack(element, rtcServers));
                            }
                        }
                    }
                    else {
                        this._discoveredCandidates = [];
                        this._gatheringState = fm.icelink.IceGatheringState.New;
                        this._iceConnectionState = fm.icelink.IceConnectionState.New;
                        var webRtcBundlePolicy = this.getWebRTCBundlePolicyString();
                        try {
                            this._nativePeerConnection = new RTCPeerConnection({
                                iceServers: rtcServers,
                                bundlePolicy: webRtcBundlePolicy
                            });
                        }
                        catch (ex) {
                            try {
                                for (var _g = 0, rtcServers_1 = rtcServers; _g < rtcServers_1.length; _g++) {
                                    var rtcServer_1 = rtcServers_1[_g];
                                    if (rtcServer_1.urls) {
                                        rtcServer_1.urls = rtcServer_1.urls[0];
                                    }
                                }
                                this._nativePeerConnection = new RTCPeerConnection({
                                    iceServers: rtcServers,
                                    bundlePolicy: webRtcBundlePolicy
                                });
                            }
                            catch (ex) {
                                try {
                                    for (var _h = 0, rtcServers_2 = rtcServers; _h < rtcServers_2.length; _h++) {
                                        var rtcServer_2 = rtcServers_2[_h];
                                        if (rtcServer_2.urls) {
                                            rtcServer_2.url = rtcServer_2.urls;
                                        }
                                    }
                                    delete rtcServer.urls;
                                    this._nativePeerConnection = new RTCPeerConnection({
                                        iceServers: rtcServers,
                                        bundlePolicy: webRtcBundlePolicy
                                    });
                                }
                                catch (ex) {
                                    if (ex.message == "") {
                                        throw new fm.icelink.Exception("Unable to create internal RTCPeerConnection.");
                                    }
                                    else {
                                        throw ex;
                                    }
                                }
                            }
                        }
                        this._nativePeerConnection.onicegatheringstatechange = function (event) {
                            switch (_this._nativePeerConnection.iceGatheringState) {
                                case "new":
                                    _this.setGatheringState(fm.icelink.IceGatheringState.New);
                                    break;
                                case "complete":
                                    _this.setGatheringState(fm.icelink.IceGatheringState.Complete);
                                    break;
                                case "gathering":
                                    _this.setGatheringState(fm.icelink.IceGatheringState.Gathering);
                                    break;
                            }
                        };
                        this._nativePeerConnection.oniceconnectionstatechange = function (event) {
                            switch (_this._nativePeerConnection.iceConnectionState) {
                                case "new":
                                    _this.setIceConnectionState(fm.icelink.IceConnectionState.New);
                                    break;
                                case "checking":
                                    _this.setIceConnectionState(fm.icelink.IceConnectionState.Checking);
                                    break;
                                case "connected":
                                    _this.setIceConnectionState(fm.icelink.IceConnectionState.Connected);
                                    break;
                                case "completed":
                                    _this.setIceConnectionState(fm.icelink.IceConnectionState.Completed);
                                    break;
                                case "failed":
                                    _this.setIceConnectionState(fm.icelink.IceConnectionState.Failed);
                                    break;
                                case "disconnected":
                                    _this.setIceConnectionState(fm.icelink.IceConnectionState.Disconnected);
                                    break;
                                case "closed":
                                    _this.setIceConnectionState(fm.icelink.IceConnectionState.Closed);
                                    break;
                            }
                        };
                        this._nativePeerConnection.onicecandidate = function (event) {
                            if (event.candidate) {
                                var sdpCandidateString = event.candidate.candidate;
                                if (sdpCandidateString && sdpCandidateString.length > 0) {
                                    if (!fm.icelink.StringExtensions.startsWith(sdpCandidateString, 'a=')) {
                                        sdpCandidateString = 'a=' + sdpCandidateString;
                                    }
                                    var localCandidate = new fm.icelink.Candidate();
                                    localCandidate.setSdpMediaIndex(event.candidate.sdpMLineIndex);
                                    localCandidate.setSdpCandidateAttribute(fm.icelink.sdp.Attribute.parse(sdpCandidateString));
                                    var trickleIceSupported = _this.getUseTrickleIce();
                                    if (!trickleIceSupported) {
                                        if (_this.validateCandidate(localCandidate)) {
                                            _this._discoveredCandidates.push(localCandidate);
                                        }
                                    }
                                    else {
                                        if (_this.validateCandidate(localCandidate)) {
                                            _this.raiseLocalCandidate(localCandidate);
                                        }
                                    }
                                }
                            }
                        };
                        var dataChannelsConnected_1 = 0;
                        this._dataStreamsReady = (dataChannelsConnected_1 == dataChannelCount);
                        var processDataChannelStateChange_1 = function (dataChannel) {
                            var dataChannelState = dataChannel.getState();
                            if (dataChannelState == fm.icelink.DataChannelState.Connected) {
                                dataChannelsConnected_1++;
                            }
                            else if (dataChannelState == fm.icelink.DataChannelState.Closed) {
                                dataChannelsConnected_1--;
                                if (dataChannelsConnected_1 == 0 && mediaStreamCount == 0) {
                                    if (_this.setState(fm.icelink.ConnectionState.Closing)) {
                                        _this.doClose();
                                        _this.setState(fm.icelink.ConnectionState.Closed);
                                    }
                                }
                            }
                            else if (dataChannelState == fm.icelink.DataChannelState.Failed) {
                                dataChannelsConnected_1--;
                                if (dataChannelsConnected_1 == 0 && mediaStreamCount == 0) {
                                    if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.ReliableDataChannelSendError, new fm.icelink.Exception('Data channel failed.')))) {
                                        _this.doClose();
                                        _this.setState(fm.icelink.ConnectionState.Failed);
                                    }
                                }
                            }
                            _this._dataStreamsReady = (dataChannelsConnected_1 == dataChannelCount);
                            if (_this._dataStreamsReady && _this._mediaStreamsReady && _this.getState() == fm.icelink.ConnectionState.Connecting) {
                                _this.setState(fm.icelink.ConnectionState.Connected);
                            }
                        };
                        var _loop_2 = function (dataStream) {
                            if (this_2._offerer) {
                                for (var _i = 0, _a = dataStream.getChannels(); _i < _a.length; _i++) {
                                    var dataChannel = _a[_i];
                                    var rtcDataChannel = this_2._nativePeerConnection.createDataChannel(dataChannel.getLabel(), {
                                        ordered: dataChannel.getOrdered(),
                                        negotiated: false,
                                    });
                                    dataChannel.setNativeDataChannel(rtcDataChannel);
                                    dataChannel.addOnStateChange(processDataChannelStateChange_1);
                                }
                            }
                            else {
                                this_2._nativePeerConnection.ondatachannel = function (event) {
                                    var rtcDataChannel = event.channel;
                                    for (var _i = 0, _a = dataStream.getChannels(); _i < _a.length; _i++) {
                                        var dataChannel = _a[_i];
                                        if (dataChannel.getLabel() == rtcDataChannel.label) {
                                            dataChannel.setNativeDataChannel(rtcDataChannel);
                                            dataChannel.addOnStateChange(processDataChannelStateChange_1);
                                        }
                                    }
                                };
                            }
                        };
                        var this_2 = this;
                        for (var _j = 0, _k = this._dataStreams; _j < _k.length; _j++) {
                            var dataStream = _k[_j];
                            _loop_2(dataStream);
                        }
                        this._mediaStreamsReady = (mediaStreamCount == 0);
                        if (mediaStreamCount > 0) {
                            var pendingNativeMediaStreams_1 = [];
                            var processNativeMediaStream_1 = function (nativeMediaStreams) {
                                pendingNativeMediaStreams_1 = pendingNativeMediaStreams_1.concat(nativeMediaStreams);
                                var remainingTracks = _this._remoteMediaTrackCount;
                                var nativeAudioStream = null;
                                var nativeVideoStream = null;
                                for (var _i = 0, pendingNativeMediaStreams_2 = pendingNativeMediaStreams_1; _i < pendingNativeMediaStreams_2.length; _i++) {
                                    var pendingNativeMediaStream = pendingNativeMediaStreams_2[_i];
                                    var nativeAudioTracks = pendingNativeMediaStream.getAudioTracks();
                                    if (nativeAudioTracks.length) {
                                        nativeAudioStream = pendingNativeMediaStream;
                                        remainingTracks -= nativeAudioTracks.length;
                                    }
                                    var nativeVideoTracks = pendingNativeMediaStream.getVideoTracks();
                                    if (nativeVideoTracks.length > 0) {
                                        nativeVideoStream = pendingNativeMediaStream;
                                        remainingTracks -= nativeVideoTracks.length;
                                    }
                                    if (remainingTracks == 0) {
                                        _this._remoteMedia._setMediaStreams(nativeAudioStream, nativeVideoStream);
                                        var remoteAudioTracks = _this._remoteMedia.getAudioTracks();
                                        for (var i = 0; i < remoteAudioTracks.length; i++) {
                                            if (i < _this._audioStreams.length) {
                                                var audioStream = _this._audioStreams[i];
                                                if (!audioStream.getRemoteTrack()) {
                                                    audioStream.setRemoteTrack(remoteAudioTracks[i]);
                                                }
                                            }
                                        }
                                        var remoteVideoTracks = _this._remoteMedia.getVideoTracks();
                                        for (var i = 0; i < remoteVideoTracks.length; i++) {
                                            if (i < _this._videoStreams.length) {
                                                var videoStream = _this._videoStreams[i];
                                                if (!videoStream.getRemoteTrack()) {
                                                    videoStream.setRemoteTrack(remoteVideoTracks[i]);
                                                }
                                            }
                                        }
                                        _this._mediaStreamsReady = true;
                                        if (_this._dataStreamsReady && _this._mediaStreamsReady && _this.getState() == fm.icelink.ConnectionState.Connecting) {
                                            _this.setState(fm.icelink.ConnectionState.Connected);
                                        }
                                    }
                                }
                            };
                            if ('ontrack' in this._nativePeerConnection) {
                                this._nativePeerConnection.ontrack = function (event) {
                                    processNativeMediaStream_1(event.streams);
                                };
                            }
                            else {
                                this._nativePeerConnection.onaddstream = function (event) {
                                    processNativeMediaStream_1([event.stream]);
                                };
                            }
                        }
                        var useAddTrack = fm.icelink.Util.isFunction(this._nativePeerConnection.addTrack);
                        var useAddTransceiver = fm.icelink.Util.isFunction(this._nativePeerConnection.addTransceiver);
                        var addedStreams = [];
                        var _loop_3 = function (mediaStream) {
                            var localMediaTrack = mediaStream.getLocalTrack();
                            if (localMediaTrack) {
                                var localMedia_1 = localMediaTrack.getMedia();
                                var nativeMediaStreamTrack = localMediaTrack._getMediaStreamTrack();
                                if (nativeMediaStreamTrack) {
                                    var kind = nativeMediaStreamTrack.kind;
                                    var nativeMediaStream = (kind == 'audio' ? localMedia_1._getAudioMediaStream() : localMedia_1._getVideoMediaStream());
                                    if (nativeMediaStream) {
                                        if (kind == 'audio') {
                                            localMedia_1.addAudioStream(mediaStream);
                                            this_3.addOnStateChange(function (c) {
                                                if (c.getIsTerminating()) {
                                                    localMedia_1.removeAudioStream(mediaStream);
                                                }
                                            });
                                        }
                                        else {
                                            localMedia_1.addVideoStream(mediaStream);
                                            this_3.addOnStateChange(function (c) {
                                                if (c.getIsTerminating()) {
                                                    localMedia_1.removeVideoStream(mediaStream);
                                                }
                                            });
                                        }
                                        if (!useAddTransceiver && !useAddTrack) {
                                            if (!fm.icelink.ArrayExtensions.contains(addedStreams, nativeMediaStream)) {
                                                this_3._nativePeerConnection.addStream(nativeMediaStream);
                                                addedStreams.push(nativeMediaStream);
                                            }
                                        }
                                        else if (this_3.getSignallingState() == fm.icelink.SignallingState.New && this_3._offerer) {
                                            this_3.setupTransceivers(useAddTransceiver, useAddTrack, nativeMediaStreamTrack, nativeMediaStream, mediaStream);
                                        }
                                    }
                                }
                            }
                        };
                        var this_3 = this;
                        for (var _l = 0, _m = this._mediaStreams; _l < _m.length; _l++) {
                            var mediaStream = _m[_l];
                            _loop_3(mediaStream);
                        }
                        var deadStreamTimer_1 = 0;
                        this._nativePeerConnection.oniceconnectionstatechange = function (event) {
                            if (_this._nativePeerConnection.iceConnectionState == 'connected' || _this._nativePeerConnection.iceConnectionState == 'completed') {
                                if (deadStreamTimer_1) {
                                    fm.icelink.Log.debug('Connectivity checks have restored.');
                                    window.clearTimeout(deadStreamTimer_1);
                                    deadStreamTimer_1 = null;
                                }
                                if (_this.getState() == fm.icelink.ConnectionState.Initializing) {
                                    fm.icelink.Log.debug('Transitioning Connection from Initializing to Connecting state because inner iceConnectionState state is Connected.');
                                    _this.setState(fm.icelink.ConnectionState.Connecting);
                                }
                                if (_this._dataStreamsReady && _this._mediaStreamsReady && _this.getState() == fm.icelink.ConnectionState.Connecting) {
                                    _this.setState(fm.icelink.ConnectionState.Connected);
                                }
                            }
                            if (_this._nativePeerConnection.iceConnectionState == 'disconnected' && _this.getState() == fm.icelink.ConnectionState.Connected) {
                                fm.icelink.Log.debug('Some connectivity checks have failed. Monitoring for dead stream.');
                                if (!deadStreamTimer_1) {
                                    deadStreamTimer_1 = window.setTimeout(function () {
                                        deadStreamTimer_1 = null;
                                        if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionDeadStream, new fm.icelink.Exception('Dead stream detected.')))) {
                                            _this.doClose();
                                            _this.setState(fm.icelink.ConnectionState.Failed);
                                        }
                                    }, _this.getDeadStreamTimeout());
                                }
                            }
                        };
                    }
                    this._initialized = true;
                };
                WebRtcConnection.prototype.setupTransceivers = function (useAddTransceiver, useAddTrack, nativeMediaStreamTrack, nativeMediaStream, mediaStream) {
                    var nativeSendEncodings = mediaStream.getNativeSendEncodings();
                    var useSimulcast = nativeSendEncodings && nativeSendEncodings.length > 1;
                    if (useSimulcast) {
                        var simulcastMode = mediaStream.getSimulcastMode();
                        if (simulcastMode == fm.icelink.SimulcastMode.Disabled) {
                            throw new fm.icelink.Exception('Multiple send encodings were specified, but the SimulcastMode is Disabled. Choose a different SimulcastMode for the stream or reduce the number of encodings to one.');
                        }
                        else if (simulcastMode == fm.icelink.SimulcastMode.RtpStreamId) {
                            var rtpStreamIndex = 0;
                            for (var _i = 0, nativeSendEncodings_2 = nativeSendEncodings; _i < nativeSendEncodings_2.length; _i++) {
                                var nativeSendEncoding = nativeSendEncodings_2[_i];
                                nativeSendEncoding.rid = (rtpStreamIndex++).toString();
                            }
                        }
                        else {
                            throw new fm.icelink.Exception('Multiple send encodings were specified, but the SimulcastMode ' + new fm.icelink.SimulcastModeWrapper(simulcastMode).toString() + ' was not recognized.');
                        }
                    }
                    if (useAddTransceiver && useSimulcast) {
                        var nativeDirection = void 0;
                        var direction = mediaStream.getDirection();
                        if (direction != fm.icelink.StreamDirection.Unset) {
                            nativeDirection = fm.icelink.StreamDirectionHelper.directionToString(direction);
                        }
                        var nativeTransceiverInit = {};
                        if (nativeDirection) {
                            nativeTransceiverInit.direction = nativeDirection;
                        }
                        if (nativeSendEncodings) {
                            nativeTransceiverInit.sendEncodings = nativeSendEncodings;
                        }
                        var transceiver = this._nativePeerConnection.addTransceiver(nativeMediaStreamTrack.kind, nativeTransceiverInit);
                        this._nativePeerConnection.addTrack(nativeMediaStreamTrack, nativeMediaStream);
                        if (transceiver.sender) {
                            mediaStream.setSender(transceiver.sender, true);
                        }
                        if (transceiver.receiver) {
                            mediaStream.setReceiver(transceiver.receiver);
                        }
                    }
                    else {
                        if (useSimulcast) {
                            fm.icelink.Log.warn('Multiple send encodings were specified, but this browser does not support simulcast. The default encoding will be sent.');
                        }
                        if (useAddTrack) {
                            var sender = this._nativePeerConnection.addTrack(nativeMediaStreamTrack, nativeMediaStream);
                            if (sender) {
                                mediaStream.setSender(sender, false);
                            }
                        }
                    }
                };
                WebRtcConnection.prototype.initializeTrack = function (element, rtcServers) {
                    var _this = this;
                    var iceGatherer = this.createIceGatherer(rtcServers);
                    this._nativeIceGatherers.push(iceGatherer);
                    iceGatherer.onlocalcandidate = function (event) {
                        var rtcCandidate = event.candidate;
                        if (Object.keys(rtcCandidate).length > 0) {
                            var localCandidate = new fm.icelink.Candidate();
                            localCandidate.setSdpMediaIndex(element.index);
                            localCandidate.setSdpCandidateAttribute(_this.rtcCandidateToSdpCandidateAttribute(rtcCandidate));
                            if (_this.validateCandidate(localCandidate)) {
                                _this.raiseLocalCandidate(localCandidate);
                            }
                        }
                    };
                    var iceTransport = new RTCIceTransport();
                    this._nativeIceTransports.push(iceTransport);
                    var dtlsTransport = new window.RTCDtlsTransport(iceTransport);
                    this._nativeDtlsTransports.push(dtlsTransport);
                    if (element.track && element.track.readyState != 'ended') {
                        var rtpSender = new window.RTCRtpSender(element.track, dtlsTransport);
                        this._nativeRtpSenders.push(rtpSender);
                    }
                    else {
                        this._nativeRtpSenders.push(null);
                    }
                    var rtpReceiver = new window.RTCRtpReceiver(dtlsTransport, element.kind);
                    this._nativeRtpReceivers.push(rtpReceiver);
                    this._rtpKinds.push(element.kind);
                    return rtpReceiver.track;
                };
                WebRtcConnection.prototype.validateCandidate = function (candidate) {
                    if (this.getIceGatherPolicy() == fm.icelink.IceGatherPolicy.NoHost) {
                        return (candidate.getSdpCandidateAttribute().getCandidateType() !== fm.icelink.sdp.ice.CandidateType.getHost());
                    }
                    else if (this.getIceGatherPolicy() == fm.icelink.IceGatherPolicy.Relay) {
                        return (candidate.getSdpCandidateAttribute().getCandidateType() === fm.icelink.sdp.ice.CandidateType.getRelayed());
                    }
                    return true;
                };
                WebRtcConnection.prototype.createIceGatherer = function (rtcServers) {
                    rtcServers = rtcServers.slice(0);
                    var iceGatherer;
                    if (this.getIceGatherPolicy() == fm.icelink.IceGatherPolicy.NoHost) ;
                    else if (this.getIceGatherPolicy() == fm.icelink.IceGatherPolicy.Relay) ;
                    try {
                        for (var _i = 0, rtcServers_3 = rtcServers; _i < rtcServers_3.length; _i++) {
                            var rtcServer = rtcServers_3[_i];
                            if (fm.icelink.Util.isArray(rtcServer.urls)) {
                                rtcServer.urls = rtcServer.urls[0];
                            }
                        }
                        iceGatherer = new RTCIceGatherer({
                            gatherPolicy: 'all',
                            iceServers: rtcServers
                        });
                    }
                    catch (ex) {
                        try {
                            var i = rtcServers.length;
                            while (i--) {
                                if (fm.icelink.StringExtensions.startsWith(rtcServers[i].urls, 'stun:')) {
                                    fm.icelink.Log.info(fm.icelink.StringExtensions.format("ORTC currently does not support STUN protocol. Removing {0} from the list of ICE servers.", rtcServers[i].urls));
                                    rtcServers.splice(i, 1);
                                }
                                else if (fm.icelink.StringExtensions.startsWith(rtcServers[i].urls, 'turns:')) {
                                    fm.icelink.Log.info(fm.icelink.StringExtensions.format("ORTC currently does not support TURNS protocol. Removing {0} from the list of ICE servers.", rtcServers[i].urls));
                                    rtcServers.splice(i, 1);
                                }
                            }
                            iceGatherer = new RTCIceGatherer({
                                gatherPolicy: 'all',
                                iceServers: rtcServers
                            });
                        }
                        catch (ex) {
                            try {
                                for (var _a = 0, rtcServers_4 = rtcServers; _a < rtcServers_4.length; _a++) {
                                    var rtcServer = rtcServers_4[_a];
                                    if (rtcServer.username == '') {
                                        rtcServer.username = 'unspecified';
                                    }
                                    if (rtcServer.credential == '') {
                                        rtcServer.credential = 'unspecified';
                                    }
                                }
                                iceGatherer = new RTCIceGatherer({
                                    gatherPolicy: 'all',
                                    iceServers: rtcServers
                                });
                            }
                            catch (ex) {
                                try {
                                    if (rtcServers.length > 1) {
                                        var server = rtcServers[0];
                                        rtcServers = new Array(1);
                                        rtcServers[0] = server;
                                        iceGatherer = new RTCIceGatherer({
                                            gatherPolicy: 'all',
                                            iceServers: rtcServers
                                        });
                                    }
                                    else {
                                        fm.icelink.Log.error('Could not create ORTC IceGatherer.', ex);
                                        throw ex;
                                    }
                                }
                                catch (ex) {
                                    fm.icelink.Log.error('Could not create ORTC IceGatherer.', ex);
                                    throw ex;
                                }
                            }
                        }
                    }
                    return iceGatherer;
                };
                WebRtcConnection.prototype.sessionDescriptionTypeToString = function (typeEnum) {
                    return (typeEnum == fm.icelink.SessionDescriptionType.Offer ? 'offer' : 'answer');
                };
                WebRtcConnection.prototype.sessionDescriptionTypeToEnum = function (typeString) {
                    return (typeString == 'offer' ? fm.icelink.SessionDescriptionType.Offer : fm.icelink.SessionDescriptionType.Answer);
                };
                WebRtcConnection.prototype.webrtcCandidateToCandidate = function (webrtcCandidate) {
                    var candidate = new fm.icelink.Candidate();
                    candidate.setSdpCandidateAttribute(fm.icelink.sdp.Attribute.parse(webrtcCandidate.candidate));
                    candidate.setSdpMediaIndex(webrtcCandidate.sdpMLineIndex);
                    return candidate;
                };
                WebRtcConnection.prototype.webrtcCandidateFromCandidate = function (candidate) {
                    return new RTCIceCandidate({
                        candidate: candidate.getSdpCandidateAttribute().toString(),
                        sdpMLineIndex: candidate.getSdpMediaIndex()
                    });
                };
                WebRtcConnection.prototype.webrtcSessionDescriptionToSessionDescription = function (webrtcSessionDescription) {
                    var sessionDescription = new fm.icelink.SessionDescription();
                    sessionDescription.setSdpMessage(fm.icelink.sdp.Message.parse(webrtcSessionDescription.sessionDescription.sdp));
                    sessionDescription.setType(this.sessionDescriptionTypeToEnum(webrtcSessionDescription.sessionDescription.type));
                    sessionDescription.setTieBreaker(webrtcSessionDescription.tieBreaker);
                    return sessionDescription;
                };
                WebRtcConnection.prototype.webrtcSessionDescriptionFromSessionDescription = function (sessionDescription) {
                    return {
                        sessionDescription: new RTCSessionDescription({
                            sdp: sessionDescription.getSdpMessage().toString(),
                            type: this.sessionDescriptionTypeToString(sessionDescription.getType())
                        }),
                        tieBreaker: sessionDescription.getTieBreaker()
                    };
                };
                WebRtcConnection.prototype.rtcCandidateToSdpCandidateAttribute = function (rtcCandidate) {
                    var sdpCandidateAttribute = new fm.icelink.sdp.ice.CandidateAttribute();
                    sdpCandidateAttribute.setFoundation(rtcCandidate.foundation);
                    sdpCandidateAttribute.setComponentId(1);
                    sdpCandidateAttribute.setProtocol(rtcCandidate.protocol);
                    sdpCandidateAttribute.setPriority(rtcCandidate.priority);
                    sdpCandidateAttribute.setConnectionAddress(rtcCandidate.ip);
                    sdpCandidateAttribute.setPort(rtcCandidate.port);
                    sdpCandidateAttribute.setCandidateType(rtcCandidate.type);
                    if (rtcCandidate.relatedAddress) {
                        sdpCandidateAttribute.setRelatedAddress(rtcCandidate.relatedAddress);
                        sdpCandidateAttribute.setRelatedPort(rtcCandidate.relatedPort);
                    }
                    return sdpCandidateAttribute;
                };
                WebRtcConnection.prototype.rtcCandidateFromSdpCandidateAttribute = function (sdpCandidateAttribute) {
                    return {
                        foundation: sdpCandidateAttribute.getFoundation(),
                        protocol: sdpCandidateAttribute.getProtocol(),
                        priority: sdpCandidateAttribute.getPriority(),
                        ip: sdpCandidateAttribute.getConnectionAddress(),
                        port: sdpCandidateAttribute.getPort(),
                        type: sdpCandidateAttribute.getCandidateType(),
                        relatedAddress: sdpCandidateAttribute.getRelatedAddress(),
                        relatedPort: sdpCandidateAttribute.getRelatedPort(),
                        tcpType: (sdpCandidateAttribute.getProtocol() == fm.icelink.sdp.ice.TransportProtocol.getTcp() ? 'active' : undefined)
                    };
                };
                WebRtcConnection.prototype.ortcCandidateToCandidate = function (ortcCandidate) {
                    var candidate = new fm.icelink.Candidate();
                    candidate.setSdpCandidateAttribute(this.rtcCandidateToSdpCandidateAttribute(ortcCandidate.candidate));
                    candidate.setSdpMediaIndex(ortcCandidate.mediaIndex);
                    return candidate;
                };
                WebRtcConnection.prototype.ortcCandidateFromCandidate = function (candidate) {
                    return {
                        candidate: this.rtcCandidateFromSdpCandidateAttribute(candidate.getSdpCandidateAttribute()),
                        mediaIndex: candidate.getSdpMediaIndex()
                    };
                };
                WebRtcConnection.prototype.ortcSessionDescriptionToSessionDescription = function (ortcSessionDescription) {
                    var sdpMessage = new fm.icelink.sdp.Message(new fm.icelink.sdp.Origin('127.0.0.1'), 'Frozen Mountain ORTC');
                    var mediaDescriptions = new Array(ortcSessionDescription.mediaDescriptions.length);
                    var index = 0;
                    for (var _i = 0, _a = ortcSessionDescription.mediaDescriptions; _i < _a.length; _i++) {
                        var ortcMediaDescription = _a[_i];
                        var transportPort = 9;
                        var connectionAddress = "0.0.0.0";
                        var codecPayloadTypes = [];
                        for (var _b = 0, _c = ortcMediaDescription.codecCaps; _b < _c.length; _b++) {
                            var ortcCodecCap = _c[_b];
                            codecPayloadTypes.push(ortcCodecCap.preferredPayloadType);
                        }
                        var sdpMediaDescription = new fm.icelink.sdp.MediaDescription(new fm.icelink.sdp.Media(ortcMediaDescription.kind, transportPort, 'RTP/SAVPF', codecPayloadTypes.join(' ')));
                        sdpMediaDescription.setConnectionData(new fm.icelink.sdp.ConnectionData(connectionAddress));
                        sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.rtcp.Attribute(transportPort, connectionAddress));
                        sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.ice.UfragAttribute(ortcMediaDescription.iceParams.usernameFragment));
                        sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.ice.PasswordAttribute(ortcMediaDescription.iceParams.password));
                        for (var _d = 0, _e = ortcMediaDescription.dtlsParams.fingerprints; _d < _e.length; _d++) {
                            var fingerprint = _e[_d];
                            sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.ice.FingerprintAttribute(fingerprint.algorithm, fingerprint.value));
                        }
                        if (ortcMediaDescription.dtlsParams.role == 'auto') {
                            sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.SetupAttribute(fm.icelink.sdp.Setup.getActPass()));
                        }
                        else if (ortcMediaDescription.dtlsParams.role == 'client') {
                            sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.SetupAttribute(fm.icelink.sdp.Setup.getActive()));
                        }
                        else if (ortcMediaDescription.dtlsParams.role == 'server') {
                            sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.SetupAttribute(fm.icelink.sdp.Setup.getPassive()));
                        }
                        if (ortcMediaDescription.direction == fm.icelink.StreamDirection.SendReceive) {
                            sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.SendReceiveAttribute());
                        }
                        else if (ortcMediaDescription.direction == fm.icelink.StreamDirection.SendOnly) {
                            sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.SendOnlyAttribute());
                        }
                        else if (ortcMediaDescription.direction == fm.icelink.StreamDirection.ReceiveOnly) {
                            sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.ReceiveOnlyAttribute());
                        }
                        else {
                            sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.InactiveAttribute());
                        }
                        sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.rtcp.MuxAttribute());
                        for (var _f = 0, _g = ortcMediaDescription.codecCaps; _f < _g.length; _f++) {
                            var ortcCodecCap = _g[_f];
                            if (ortcCodecCap.numChannels > 1) {
                                sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.rtp.MapAttribute(ortcCodecCap.preferredPayloadType, ortcCodecCap.name, ortcCodecCap.clockRate, ortcCodecCap.numChannels.toString()));
                            }
                            else {
                                sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.rtp.MapAttribute(ortcCodecCap.preferredPayloadType, ortcCodecCap.name, ortcCodecCap.clockRate));
                            }
                            if (ortcCodecCap.parameters && fm.icelink.HashExtensions.getCount(ortcCodecCap.parameters) > 0) {
                                var sdpFormatParametersAttribute = new fm.icelink.sdp.FormatParametersAttribute(ortcCodecCap.preferredPayloadType);
                                for (var key in ortcCodecCap.parameters) {
                                    sdpFormatParametersAttribute.setFormatSpecificParameter(key, ortcCodecCap.parameters[key]);
                                }
                                sdpMediaDescription.addMediaAttribute(sdpFormatParametersAttribute);
                            }
                            if (ortcCodecCap.rtcpFeedback) {
                                for (var _h = 0, _j = ortcCodecCap.rtcpFeedback; _h < _j.length; _h++) {
                                    var rtcpFeedback = _j[_h];
                                    if (fm.icelink.StringExtensions.isNullOrEmpty(rtcpFeedback.parameter)) {
                                        sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.rtcp.FeedbackAttribute(ortcCodecCap.preferredPayloadType, rtcpFeedback.type));
                                    }
                                    else {
                                        sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.rtcp.FeedbackAttribute(ortcCodecCap.preferredPayloadType, rtcpFeedback.type, rtcpFeedback.parameter));
                                    }
                                }
                            }
                        }
                        for (var _k = 0, _l = ortcMediaDescription.candidates; _k < _l.length; _k++) {
                            var ortcCandidate = _l[_k];
                            sdpMediaDescription.addMediaAttribute(this.rtcCandidateToSdpCandidateAttribute(ortcCandidate));
                        }
                        if (ortcMediaDescription.ssrc != 0) {
                            sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.rtp.SsrcAttribute(ortcMediaDescription.ssrc, fm.icelink.sdp.rtp.SsrcAttributeName.getCName(), ortcMediaDescription.cname));
                        }
                        mediaDescriptions[index] = sdpMediaDescription;
                        index++;
                    }
                    this.getSessionDescriptionManager().addMediaDescriptions(sdpMessage, mediaDescriptions);
                    var sessionDescription = new fm.icelink.SessionDescription();
                    sessionDescription.setSdpMessage(sdpMessage);
                    sessionDescription.setTieBreaker(ortcSessionDescription.tieBreaker);
                    sessionDescription.setType(ortcSessionDescription.type);
                    return sessionDescription;
                };
                WebRtcConnection.prototype.ortcSessionDescriptionFromSessionDescription = function (sessionDescription) {
                    var sdpMessage = sessionDescription.getSdpMessage();
                    var sdpOrigin = sdpMessage.getOrigin();
                    var ortcSessionDescription = {
                        sessionId: sdpOrigin.getSessionId(),
                        sessionVersion: sdpOrigin.getSessionVersion(),
                        mediaDescriptions: [],
                        tieBreaker: sessionDescription.getTieBreaker(),
                        type: sessionDescription.getType()
                    };
                    var sessionUfragAttribute = null;
                    var sessionPasswordAttribute = null;
                    var sessionFingerprintAttributes = [];
                    for (var _i = 0, _a = sdpMessage.getSessionAttributes(); _i < _a.length; _i++) {
                        var sdpSessionAttribute = _a[_i];
                        if (fm.icelink.Util.isObjectType(sdpSessionAttribute, '[fm.icelink.sdp.ice.UfragAttribute]')) {
                            sessionUfragAttribute = (sdpSessionAttribute);
                        }
                        else if (fm.icelink.Util.isObjectType(sdpSessionAttribute, '[fm.icelink.sdp.ice.PasswordAttribute]')) {
                            sessionPasswordAttribute = (sdpSessionAttribute);
                        }
                        else if (fm.icelink.Util.isObjectType(sdpSessionAttribute, '[fm.icelink.sdp.ice.FingerprintAttribute]')) {
                            sessionFingerprintAttributes.push((sdpSessionAttribute));
                        }
                    }
                    for (var _b = 0, _c = sdpMessage.getMediaDescriptions(); _b < _c.length; _b++) {
                        var sdpMediaDescription = _c[_b];
                        var ortcMediaDescription = {
                            kind: sdpMediaDescription.getMedia().getMediaType(),
                            direction: fm.icelink.StreamDirection.SendReceive,
                            iceParams: {},
                            dtlsParams: {
                                fingerprints: []
                            },
                            codecCaps: [],
                            candidates: [],
                            ssrc: 0,
                            cname: null
                        };
                        if (sessionUfragAttribute != null) {
                            ortcMediaDescription.iceParams.usernameFragment = sessionUfragAttribute.getUfrag();
                        }
                        if (sessionPasswordAttribute != null) {
                            ortcMediaDescription.iceParams.password = sessionPasswordAttribute.getPassword();
                        }
                        for (var _d = 0, sessionFingerprintAttributes_1 = sessionFingerprintAttributes; _d < sessionFingerprintAttributes_1.length; _d++) {
                            var sessionFingerprintAttribute = sessionFingerprintAttributes_1[_d];
                            ortcMediaDescription.dtlsParams.fingerprints.push({
                                algorithm: sessionFingerprintAttribute.getHashFunction(),
                                value: sessionFingerprintAttribute.getFingerprint(),
                            });
                        }
                        var mediaFormatParametersHash = {};
                        var mediaFeedbackAttributeHash = {};
                        for (var _e = 0, _f = sdpMediaDescription.getMediaAttributes(); _e < _f.length; _e++) {
                            var sdpMediaAttribute = _f[_e];
                            if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.FormatParametersAttribute]')) {
                                var mediaFormatParametersAttribute = (sdpMediaAttribute);
                                var key = mediaFormatParametersAttribute.getFormat().toString();
                                var mediaFormatParametersList = mediaFormatParametersHash[key];
                                if (!mediaFormatParametersList) {
                                    mediaFormatParametersHash[key] = mediaFormatParametersList = [];
                                }
                                mediaFormatParametersList.push(mediaFormatParametersAttribute);
                            }
                            else if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.rtcp.FeedbackAttribute]')) {
                                var mediaFeedbackAttribute = (sdpMediaAttribute);
                                var key = mediaFeedbackAttribute.getPayloadType().toString();
                                var mediaFeedbackAttributeList = mediaFeedbackAttributeHash[key];
                                if (!mediaFeedbackAttributeList) {
                                    mediaFeedbackAttributeHash[key] = mediaFeedbackAttributeList = [];
                                }
                                mediaFeedbackAttributeList.push(mediaFeedbackAttribute);
                            }
                        }
                        for (var _g = 0, _h = sdpMediaDescription.getMediaAttributes(); _g < _h.length; _g++) {
                            var sdpMediaAttribute = _h[_g];
                            if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.ice.UfragAttribute]')) {
                                var mediaUfragAttribute = (sdpMediaAttribute);
                                ortcMediaDescription.iceParams.usernameFragment = mediaUfragAttribute.getUfrag();
                            }
                            else if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.ice.PasswordAttribute]')) {
                                var mediaPasswordAttribute = (sdpMediaAttribute);
                                ortcMediaDescription.iceParams.password = mediaPasswordAttribute.getPassword();
                            }
                            else if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.ice.FingerprintAttribute]')) {
                                var mediaFingerprintAttribute = (sdpMediaAttribute);
                                ortcMediaDescription.dtlsParams.fingerprints.push({
                                    algorithm: mediaFingerprintAttribute.getHashFunction(),
                                    value: mediaFingerprintAttribute.getFingerprint(),
                                });
                            }
                            else if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.SetupAttribute]')) {
                                var mediaSetupAttribute = (sdpMediaAttribute);
                                if (mediaSetupAttribute.getSetup() == fm.icelink.sdp.Setup.getActPass()) {
                                    ortcMediaDescription.dtlsParams.role = 'auto';
                                }
                                else if (mediaSetupAttribute.getSetup() == fm.icelink.sdp.Setup.getActive()) {
                                    ortcMediaDescription.dtlsParams.role = 'client';
                                }
                                else if (mediaSetupAttribute.getSetup() == fm.icelink.sdp.Setup.getPassive()) {
                                    ortcMediaDescription.dtlsParams.role = 'server';
                                }
                            }
                            else if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.rtp.MapAttribute]')) {
                                var mediaRtpMapAttribute = (sdpMediaAttribute);
                                var formatParameters = mediaRtpMapAttribute.getFormatParameters();
                                var codecCap = {
                                    preferredPayloadType: mediaRtpMapAttribute.getPayloadType(),
                                    name: mediaRtpMapAttribute.getFormatName(),
                                    clockRate: mediaRtpMapAttribute.getClockRate(),
                                    numChannels: fm.icelink.StringExtensions.isNullOrEmpty(formatParameters) ? 1 : fm.icelink.ParseAssistant.parseIntegerValue(formatParameters),
                                    parameters: {},
                                    rtcpFeedback: []
                                };
                                var payloadTypeKey = mediaRtpMapAttribute.getPayloadType().toString();
                                this.applyMediaFormatParametersAttributes(codecCap, mediaFormatParametersHash[payloadTypeKey]);
                                this.applyMediaFeedbackAttributes(codecCap, mediaFeedbackAttributeHash[payloadTypeKey]);
                                this.applyMediaFeedbackAttributes(codecCap, mediaFeedbackAttributeHash['-1']);
                                ortcMediaDescription.codecCaps.push(codecCap);
                            }
                            else if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.ice.CandidateAttribute]')) {
                                var mediaCandidateAttribute = (sdpMediaAttribute);
                                if (mediaCandidateAttribute.getProtocol() != fm.icelink.sdp.ice.TransportProtocol.getTcp() || this._ortcSupportsTcp) {
                                    ortcMediaDescription.candidates.push(this.rtcCandidateFromSdpCandidateAttribute(mediaCandidateAttribute));
                                }
                            }
                            else if (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.rtp.SsrcAttribute]')) {
                                var mediaSsrcAttribute = (sdpMediaAttribute);
                                if (ortcMediaDescription.ssrc == 0) {
                                    ortcMediaDescription.ssrc = mediaSsrcAttribute.getSynchronizationSource();
                                }
                                if (mediaSsrcAttribute.getName() == fm.icelink.sdp.rtp.SsrcAttributeName.getCName() && ortcMediaDescription.ssrc == mediaSsrcAttribute.getSynchronizationSource()) {
                                    ortcMediaDescription.cname = mediaSsrcAttribute.getValue();
                                }
                            }
                        }
                        ortcSessionDescription.mediaDescriptions.push(ortcMediaDescription);
                    }
                    return ortcSessionDescription;
                };
                WebRtcConnection.prototype.applyMediaFormatParametersAttributes = function (codecCap, mediaFormatParametersList) {
                    if (mediaFormatParametersList) {
                        for (var _i = 0, mediaFormatParametersList_1 = mediaFormatParametersList; _i < mediaFormatParametersList_1.length; _i++) {
                            var mediaFormatParameters = mediaFormatParametersList_1[_i];
                            var params = mediaFormatParameters.deserializeFormatSpecificParameters();
                            for (var key in params) {
                                codecCap.parameters[key] = params[key];
                            }
                        }
                    }
                };
                WebRtcConnection.prototype.applyMediaFeedbackAttributes = function (codecCap, mediaFeedbackAttributeList) {
                    if (mediaFeedbackAttributeList) {
                        for (var _i = 0, mediaFeedbackAttributeList_1 = mediaFeedbackAttributeList; _i < mediaFeedbackAttributeList_1.length; _i++) {
                            var mediaFeedbackAttribute = mediaFeedbackAttributeList_1[_i];
                            codecCap.rtcpFeedback.push({
                                type: mediaFeedbackAttribute.getType(),
                                parameter: mediaFeedbackAttribute.getSubType() || ''
                            });
                        }
                    }
                };
                WebRtcConnection.prototype.getIceCandidateProcessingTimeout = function () {
                    return this._iceCandidateProcessingTimeout;
                };
                WebRtcConnection.prototype.setIceCandidateProcessingTimeout = function (value) {
                    if (value > 0) {
                        this._iceCandidateProcessingTimeout = value;
                    }
                    else {
                        throw new fm.icelink.Exception("");
                    }
                };
                WebRtcConnection.prototype.doCreateOffer = function (promise) {
                    this._offerer = true;
                    this.doCreate(promise);
                    return true;
                };
                WebRtcConnection.prototype.doCreateAnswer = function (promise) {
                    this._offerer = false;
                    this.doCreate(promise);
                };
                WebRtcConnection.prototype.processIceGatheringStateComplete = function () {
                    this._iceGatheringComplete = true;
                    if (!this.getUseTrickleIce() && !this._isRenegotiation && this._originalSetNativeDescriptionComplete) {
                        this.injectDiscoveredCandidatesIntoSdp();
                    }
                };
                WebRtcConnection.prototype.injectDiscoveredCandidatesIntoSdp = function () {
                    if (this._injectingCandidates) ;
                    else if (this._localSessionDescriptionPromise == null || this._localSessionDescription == null) {
                        this._injectingCandidates = true;
                        var errorMsg = "Local Session Description not ready when trying to inject local candidates into session description.";
                        if (this._localSessionDescriptionPromise == null) {
                            errorMsg = "Local Session Description Promise not set when trying to inject local candidates into session description.";
                        }
                        var error = new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInternalError, errorMsg);
                        if (this.setState(fm.icelink.ConnectionState.Failing, error)) {
                            this.doClose();
                            this.setState(fm.icelink.ConnectionState.Failed);
                        }
                        if (this._localSessionDescriptionPromise != null) {
                            this._localSessionDescriptionPromise.reject(new fm.icelink.Exception(errorMsg));
                        }
                    }
                    else {
                        this._injectingCandidates = true;
                        var sdpMessage = this._localSessionDescription.getSdpMessage();
                        var medias = sdpMessage.getMediaDescriptions();
                        if (medias != null) {
                            for (var _i = 0, _a = this._discoveredCandidates; _i < _a.length; _i++) {
                                var candidate = _a[_i];
                                var index = candidate.getSdpMediaIndex();
                                var media = medias[index];
                                var candidateAttribute = candidate.getSdpCandidateAttribute();
                                media.addMediaAttribute(candidateAttribute);
                                var connectionData = media.getConnectionData();
                                var existingIp = connectionData.getConnectionAddress();
                                var candidatePort = candidateAttribute.getPort();
                                var candidateIp = candidateAttribute.getConnectionAddress();
                                var candidateComponent = candidateAttribute.getComponentId();
                                if (candidateComponent == 2) {
                                    var rtcpAttribute = media.getRtcpAttribute();
                                    if (rtcpAttribute == null) {
                                        rtcpAttribute = new fm.icelink.sdp.rtcp.Attribute(candidatePort, candidateIp);
                                        media.setRtcpAttribute(rtcpAttribute);
                                    }
                                    else {
                                        rtcpAttribute.update(candidatePort, candidateIp);
                                    }
                                }
                                var existingIpBlank = (existingIp == "0.0.0.0" || existingIp == "::" || existingIp == "0:0:0:0:0:0:0:0");
                                var candidateIpBlank = (candidateIp == "0.0.0.0" || candidateIp == "::" || existingIp == "0:0:0:0:0:0:0:0");
                                var isUdpCandidate = (candidateAttribute.getProtocol().toLowerCase() == fm.icelink.sdp.ice.TransportProtocol.getUdp().toLowerCase());
                                if (candidateComponent == 1 && isUdpCandidate && existingIpBlank && !candidateIpBlank && candidatePort > 0) {
                                    connectionData.update(candidateIp);
                                    var sdpMedia = media.getMedia();
                                    sdpMedia.setTransportPort(candidatePort);
                                }
                            }
                        }
                        this._localSessionDescriptionPromise.resolve(this._localSessionDescription);
                    }
                };
                WebRtcConnection.prototype.setNativeDescriptionSuccess = function (sessionDescription, promise) {
                    var _this = this;
                    this._originalSetNativeDescriptionComplete = true;
                    this._localSessionDescriptionPromise = promise;
                    this._localSessionDescription = sessionDescription;
                    if (!this.getUseTrickleIce() && !this._isRenegotiation) {
                        if (this._iceGatheringComplete) {
                            this.injectDiscoveredCandidatesIntoSdp();
                        }
                        else {
                            window.setTimeout(function () {
                                _this.injectDiscoveredCandidatesIntoSdp();
                            }, this.getIceCandidateProcessingTimeout());
                        }
                    }
                    else {
                        promise.resolve(sessionDescription);
                    }
                };
                WebRtcConnection.prototype.modifyExtRtpMapId = function (newId, oldId, sdpMessage) {
                    var slExtAttrbutes = sdpMessage.getSessionLevelRtpExtMapAttributes();
                    var extAttrbutes = slExtAttrbutes.filter(function (x) { return x.getId() == oldId; });
                    sdpMessage.getMediaDescriptions().forEach(function (md) {
                        var mdExtAttrbutes = md.getRtpExtMapAttributes();
                        extAttrbutes = extAttrbutes.concat(mdExtAttrbutes.filter(function (x) { return x.getId() == oldId; }));
                    });
                    extAttrbutes.forEach(function (x) { return x.setId(newId); });
                };
                WebRtcConnection.prototype.getExtRtpMapAttributesWithNoDuplicateUri = function (newList, sessionDescription) {
                    if (sessionDescription != null && sessionDescription.getSdpMessage() != null) {
                        sessionDescription.getSdpMessage().getMediaDescriptions().forEach(function (ms) {
                            var mediaDescriptionAttributes = ms.getRtpExtMapAttributes();
                            var _loop_5 = function (i) {
                                var found = false;
                                newList.forEach(function (attribute) {
                                    if (mediaDescriptionAttributes[i].getUri() != null && attribute.getUri() != null) {
                                        if (mediaDescriptionAttributes[i].getUri() == attribute.getUri()) {
                                            found = true;
                                        }
                                    }
                                });
                                if (!found) {
                                    newList.push(mediaDescriptionAttributes[i]);
                                }
                            };
                            for (var i = 0; i < mediaDescriptionAttributes.length; i++) {
                                _loop_5(i);
                            }
                        });
                        var sessionLevelAttributes_1 = sessionDescription.getSdpMessage().getSessionLevelRtpExtMapAttributes();
                        var _loop_4 = function (i) {
                            var found = false;
                            newList.forEach(function (attribute) {
                                if (sessionLevelAttributes_1[i].getUri() != null && attribute.getUri() != null) {
                                    if (sessionLevelAttributes_1[i].getUri() == attribute.getUri()) {
                                        found = true;
                                    }
                                }
                            });
                            if (!found) {
                                newList.push(sessionLevelAttributes_1[i]);
                            }
                        };
                        for (var i = 0; i < sessionLevelAttributes_1.length; i++) {
                            _loop_4(i);
                        }
                    }
                    return newList;
                };
                WebRtcConnection.prototype.reallocateRtpExtMapId = function (id, sdpMessage, extMapAttributes, extMapReservedIds) {
                    var indexOfId = -1;
                    for (var i = 0; i < extMapAttributes.length; i++) {
                        if (id == extMapAttributes[i].getId()) {
                            indexOfId = i;
                            break;
                        }
                    }
                    if (indexOfId != -1) {
                        var allIds_1 = new Array();
                        extMapAttributes.forEach(function (id) {
                            allIds_1.push(id.getId());
                        });
                        extMapReservedIds.forEach(function (id) {
                            allIds_1.push(id.getId());
                        });
                        allIds_1.sort();
                        var newId = allIds_1[allIds_1.length - 1] + 1;
                        for (var i = 0; i < allIds_1.length - 1; i++) {
                            if (allIds_1[i] != allIds_1[i + 1] && allIds_1[i] + 1 != allIds_1[i + 1]) {
                                newId = allIds_1[i] + 1;
                                break;
                            }
                        }
                        this.modifyExtRtpMapId(newId, id, sdpMessage);
                        extMapAttributes[indexOfId].setId(newId);
                    }
                };
                WebRtcConnection.prototype.reorderExtRtpMapIdsOnRenegotiationOffer = function (newOffer, lastLocalDescription, lastRemoteDescription) {
                    var extRtpMapAttrtibutesFromLastTime = new Array();
                    extRtpMapAttrtibutesFromLastTime = this.getExtRtpMapAttributesWithNoDuplicateUri(extRtpMapAttrtibutesFromLastTime, lastLocalDescription);
                    extRtpMapAttrtibutesFromLastTime = this.getExtRtpMapAttributesWithNoDuplicateUri(extRtpMapAttrtibutesFromLastTime, lastRemoteDescription);
                    var offerExtRtpMapAttrtibutes = new Array();
                    offerExtRtpMapAttrtibutes = this.getExtRtpMapAttributesWithNoDuplicateUri(offerExtRtpMapAttrtibutes, newOffer);
                    for (var i = 0; i < extRtpMapAttrtibutesFromLastTime.length; i++) {
                        var found = false;
                        for (var j = 0; j < offerExtRtpMapAttrtibutes.length; j++) {
                            if (offerExtRtpMapAttrtibutes[j].getUri() == extRtpMapAttrtibutesFromLastTime[i].getUri()) {
                                found = true;
                                break;
                            }
                        }
                        if (!found) {
                            extRtpMapAttrtibutesFromLastTime.splice(i, 1);
                        }
                    }
                    if (newOffer != null && newOffer.getSdpMessage() != null) {
                        for (var i = 0; i < offerExtRtpMapAttrtibutes.length; i++) {
                            for (var j = 0; j < extRtpMapAttrtibutesFromLastTime.length; j++) {
                                if (offerExtRtpMapAttrtibutes[i].getUri() == extRtpMapAttrtibutesFromLastTime[j].getUri()) {
                                    if (offerExtRtpMapAttrtibutes[i].getId() != extRtpMapAttrtibutesFromLastTime[j].getId()) {
                                        this.reallocateRtpExtMapId(extRtpMapAttrtibutesFromLastTime[j].getId(), newOffer.getSdpMessage(), offerExtRtpMapAttrtibutes, extRtpMapAttrtibutesFromLastTime);
                                        this.modifyExtRtpMapId(extRtpMapAttrtibutesFromLastTime[j].getId(), offerExtRtpMapAttrtibutes[i].getId(), newOffer.getSdpMessage());
                                    }
                                }
                            }
                        }
                    }
                };
                WebRtcConnection.prototype.doCreate = function (promise) {
                    var _this = this;
                    fm.icelink.ManagedThread.dispatch(function () {
                        try {
                            if (!_this._initialized) {
                                _this.initialize();
                            }
                            if (fm.icelink.Plugin.hasOrtc()) {
                                _this._ortcLocalDescription = {
                                    sessionId: Math.floor(Math.random() * 9223372036854775807),
                                    sessionVersion: Math.floor(Math.random() * 2147483647),
                                    mediaDescriptions: [],
                                    tieBreaker: _this.getTieBreaker(),
                                    type: _this._offerer ? fm.icelink.SessionDescriptionType.Offer : fm.icelink.SessionDescriptionType.Answer
                                };
                                var cname = fm.icelink.Guid.newGuid().toString().replace('-', '').substr(0, 8);
                                for (var i = 0; i < _this._nativeIceGatherers.length; i++) {
                                    var localMediaDescription = {
                                        kind: _this._rtpKinds[i],
                                        direction: _this._mediaStreams[i].getDirection(),
                                        iceParams: _this._nativeIceGatherers[i].getLocalParameters(),
                                        dtlsParams: _this._nativeDtlsTransports[i].getLocalParameters(),
                                        codecCaps: [],
                                        candidates: [],
                                        ssrc: (_this._nativeRtpSenders[i] == null ? 0 : Math.floor(Math.random() * 4294967296)),
                                        cname: cname
                                    };
                                    var send = RTCRtpSender.getCapabilities(_this._rtpKinds[i]);
                                    var receive = RTCRtpReceiver.getCapabilities(_this._rtpKinds[i]);
                                    var receiveCodecs = {};
                                    for (var _i = 0, _a = receive.codecs; _i < _a.length; _i++) {
                                        var codec = _a[_i];
                                        var encodingName = [codec.name, codec.clockRate, codec.numChannels, codec.preferredPayloadType].join('/').toLowerCase();
                                        receiveCodecs[encodingName] = codec;
                                        if (codec.name.toLowerCase() == 'h264' && codec.parameters['level-asymmetry-allowed'] == undefined) {
                                            codec.parameters['level-asymmetry-allowed'] = '1';
                                        }
                                    }
                                    for (var _b = 0, _c = send.codecs; _b < _c.length; _b++) {
                                        var codec = _c[_b];
                                        var encodingName = [codec.name, codec.clockRate, codec.numChannels, codec.preferredPayloadType].join('/').toLowerCase();
                                        if (receiveCodecs[encodingName]) {
                                            localMediaDescription.codecCaps.push(codec);
                                        }
                                        if (codec.name.toLowerCase() == 'h264' && codec.parameters['level-asymmetry-allowed'] == undefined) {
                                            codec.parameters['level-asymmetry-allowed'] = '1';
                                        }
                                    }
                                    localMediaDescription.codecCaps.sort(function (a, b) {
                                        if (a.clockRate == b.clockRate) {
                                            return b.numChannels - a.numChannels;
                                        }
                                        return b.clockRate - a.clockRate;
                                    });
                                    if (_this._ortcRemoteDescription) {
                                        var remoteMediaDescription = _this._ortcRemoteDescription.mediaDescriptions[i];
                                        if (remoteMediaDescription.dtlsParams.role == 'auto' || remoteMediaDescription.dtlsParams.role == 'server') {
                                            localMediaDescription.dtlsParams.role = 'client';
                                        }
                                        else {
                                            localMediaDescription.dtlsParams.role = 'server';
                                        }
                                        var localCodecs = [];
                                        for (var _d = 0, _e = remoteMediaDescription.codecCaps; _d < _e.length; _d++) {
                                            var remoteCodec = _e[_d];
                                            if (remoteCodec.name == 'rtx') {
                                                continue;
                                            }
                                            var skip = false;
                                            for (var _f = 0, _g = localMediaDescription.codecCaps; _f < _g.length; _f++) {
                                                var localCodec = _g[_f];
                                                if (localCodec.name.toLowerCase() == remoteCodec.name.toLowerCase() &&
                                                    localCodec.clockRate == remoteCodec.clockRate &&
                                                    localCodec.numChannels == remoteCodec.numChannels) {
                                                    for (var _h = 0, _j = localCodecs; _h < _j.length; _h++) {
                                                        var negotiatedCodec = _j[_h];
                                                        if (remoteCodec.name.toLowerCase() == negotiatedCodec.name.toLowerCase() &&
                                                            remoteCodec.clockRate == negotiatedCodec.clockRate &&
                                                            remoteCodec.numChannels == negotiatedCodec.numChannels) {
                                                            skip = true;
                                                            break;
                                                        }
                                                    }
                                                    if (!skip) {
                                                        localCodec.name = remoteCodec.name;
                                                        localCodec.preferredPayloadType = remoteCodec.preferredPayloadType;
                                                        localCodecs.push(localCodec);
                                                    }
                                                    break;
                                                }
                                            }
                                        }
                                        localMediaDescription.codecCaps = localCodecs;
                                    }
                                    _this._ortcLocalDescription.mediaDescriptions.push(localMediaDescription);
                                }
                                promise.resolve(_this.ortcSessionDescriptionToSessionDescription(_this._ortcLocalDescription));
                            }
                            else {
                                for (var _k = 0, _l = _this.getStreams(); _k < _l.length; _k++) {
                                    var stream = _l[_k];
                                    var streamType = stream.getType();
                                    if (_this._offerer && (_this.getState() == fm.icelink.ConnectionState.Connected)) {
                                        if (streamType == fm.icelink.StreamType.Audio) {
                                            stream.processCachedChanges();
                                            stream.resetRemoteDirection();
                                        }
                                        else if (streamType == fm.icelink.StreamType.Video) {
                                            stream.processCachedChanges();
                                            stream.resetRemoteDirection();
                                        }
                                    }
                                }
                                var createSuccess = function (rtcSessionDescription) {
                                    var sessionDescription = _this.webrtcSessionDescriptionToSessionDescription({
                                        sessionDescription: rtcSessionDescription,
                                        tieBreaker: _this.getTieBreaker()
                                    });
                                    var audioDirections = [];
                                    var videoDirections = [];
                                    for (var _i = 0, _a = _this.getStreams(); _i < _a.length; _i++) {
                                        var stream = _a[_i];
                                        var streamDirection = stream.getLocalDirection();
                                        if (streamDirection == fm.icelink.StreamDirection.Unset) {
                                            streamDirection = stream.getDirectionCapabilities();
                                        }
                                        var streamType = stream.getType();
                                        if (streamType === fm.icelink.StreamType.Audio) {
                                            audioDirections.push(streamDirection);
                                        }
                                        else if (streamType === fm.icelink.StreamType.Video) {
                                            videoDirections.push(streamDirection);
                                        }
                                    }
                                    var audioDirectionIndex = 0;
                                    var videoDirectionIndex = 0;
                                    for (var _b = 0, _c = sessionDescription.getSdpMessage().getMediaDescriptions(); _b < _c.length; _b++) {
                                        var sdpMediaDescription = _c[_b];
                                        var streamDirection = fm.icelink.StreamDirection.Unset;
                                        if (sdpMediaDescription.getMedia().getMediaType() == fm.icelink.sdp.MediaType.getAudio()) {
                                            streamDirection = audioDirections[audioDirectionIndex++];
                                        }
                                        else if (sdpMediaDescription.getMedia().getMediaType() == fm.icelink.sdp.MediaType.getVideo()) {
                                            streamDirection = videoDirections[videoDirectionIndex++];
                                        }
                                        else {
                                            continue;
                                        }
                                        if (sdpMediaDescription.getIsAudio()) {
                                            if (_this.getAudioStream() != null && _this.getAudioStream().getLocalMuted()) {
                                                sdpMediaDescription.setIsMuted(true);
                                            }
                                        }
                                        if (sdpMediaDescription.getIsVideo()) {
                                            if (_this.getVideoStream() != null && _this.getVideoStream().getLocalMuted()) {
                                                sdpMediaDescription.setIsMuted(true);
                                            }
                                        }
                                        var needsDirectionAttribute = false;
                                        for (var _d = 0, _e = sdpMediaDescription.getMediaAttributes(); _d < _e.length; _d++) {
                                            var sdpMediaAttribute = _e[_d];
                                            if ((fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.SendReceiveAttribute]') && streamDirection != fm.icelink.StreamDirection.SendReceive) ||
                                                (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.SendOnlyAttribute]') && streamDirection != fm.icelink.StreamDirection.SendOnly) ||
                                                (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.ReceiveOnlyAttribute]') && streamDirection != fm.icelink.StreamDirection.ReceiveOnly) ||
                                                (fm.icelink.Util.isObjectType(sdpMediaAttribute, '[fm.icelink.sdp.InactiveAttribute]') && streamDirection != fm.icelink.StreamDirection.Inactive)) {
                                                sdpMediaDescription.removeMediaAttribute(sdpMediaAttribute);
                                                needsDirectionAttribute = true;
                                                break;
                                            }
                                        }
                                        if (needsDirectionAttribute) {
                                            switch (streamDirection) {
                                                case fm.icelink.StreamDirection.SendReceive:
                                                    sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.SendReceiveAttribute());
                                                    break;
                                                case fm.icelink.StreamDirection.SendOnly:
                                                    sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.SendOnlyAttribute());
                                                    break;
                                                case fm.icelink.StreamDirection.ReceiveOnly:
                                                    sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.ReceiveOnlyAttribute());
                                                    break;
                                                case fm.icelink.StreamDirection.Inactive:
                                                    sdpMediaDescription.addMediaAttribute(new fm.icelink.sdp.InactiveAttribute());
                                                    break;
                                            }
                                        }
                                    }
                                    fm.icelink.SessionDescriptionManager.updateTrickleIcePolicy(sessionDescription.getSdpMessage(), _this.getTrickleIcePolicy());
                                    if (_this.getSignallingState() == fm.icelink.SignallingState.Stable) {
                                        _this._isRenegotiation = true;
                                    }
                                    promise.resolve(sessionDescription);
                                };
                                var createFailure = function (domError) {
                                    var ex = new fm.icelink.Exception('Could not create ' + (_this._offerer ? 'offer' : 'answer') + ' (' + domError + ').');
                                    if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, ex))) {
                                        _this.doClose();
                                        _this.setState(fm.icelink.ConnectionState.Failed);
                                    }
                                    promise.reject(ex);
                                };
                                var audioStreamCount = (_this.getAudioStreams().length);
                                var videoStreamCount = (_this.getVideoStreams().length);
                                try {
                                    if (_this._offerer) {
                                        var transceivers = _this._nativePeerConnection.getTransceivers();
                                        var videoTransceiverCount = 0;
                                        var audioTransceiverCount = 0;
                                        for (var _m = 0, transceivers_1 = transceivers; _m < transceivers_1.length; _m++) {
                                            var transceiver = transceivers_1[_m];
                                            if ((transceiver.sender.track && transceiver.sender.track.kind == 'video') || (transceiver.receiver.track && transceiver.receiver.track.kind == 'video')) {
                                                videoTransceiverCount++;
                                            }
                                            if ((transceiver.sender.track && transceiver.sender.track.kind == 'audio') || (transceiver.receiver.track && transceiver.receiver.track.kind == 'audio')) {
                                                audioTransceiverCount++;
                                            }
                                        }
                                        var addAudioTransceivers = audioStreamCount - audioTransceiverCount;
                                        var addVideoTransceivers = videoStreamCount - videoTransceiverCount;
                                        for (var j = 0; j < addAudioTransceivers; j++) {
                                            _this._nativePeerConnection.addTransceiver('audio');
                                        }
                                        for (var j = 0; j < addVideoTransceivers; j++) {
                                            _this._nativePeerConnection.addTransceiver('video');
                                        }
                                        _this._nativePeerConnection.createOffer().then(createSuccess, createFailure);
                                    }
                                    else {
                                        _this._nativePeerConnection.createAnswer().then(createSuccess, createFailure);
                                    }
                                }
                                catch (ex) {
                                    try {
                                        if (_this._offerer) {
                                            _this._nativePeerConnection.createOffer({
                                                offerToReceiveAudio: audioStreamCount,
                                                offerToReceiveVideo: videoStreamCount
                                            }).then(createSuccess, createFailure);
                                        }
                                        else {
                                            _this._nativePeerConnection.createAnswer().then(createSuccess, createFailure);
                                        }
                                    }
                                    catch (ex) {
                                        try {
                                            if (_this._offerer) {
                                                _this._nativePeerConnection.createOffer(createSuccess, createFailure, {
                                                    offerToReceiveAudio: audioStreamCount,
                                                    offerToReceiveVideo: videoStreamCount
                                                });
                                            }
                                            else {
                                                _this._nativePeerConnection.createAnswer(createSuccess, createFailure);
                                            }
                                        }
                                        catch (ex) {
                                            if (_this._offerer) {
                                                _this._nativePeerConnection.createOffer(createSuccess, createFailure, {
                                                    optional: [],
                                                    mandatory: {
                                                        OfferToReceiveAudio: audioStreamCount,
                                                        OfferToReceiveVideo: videoStreamCount
                                                    }
                                                });
                                            }
                                            else {
                                                _this._nativePeerConnection.createAnswer(createSuccess, createFailure);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (ex) {
                            if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, ex))) {
                                _this.doClose();
                                _this.setState(fm.icelink.ConnectionState.Failed);
                            }
                            promise.reject(ex);
                        }
                    });
                };
                WebRtcConnection.prototype.getLocalDescription = function () {
                    return this._localDescription;
                };
                WebRtcConnection.prototype.getGatheringState = function () {
                    return this._gatheringState;
                };
                WebRtcConnection.prototype.getIceConnectionState = function () {
                    return this._iceConnectionState;
                };
                WebRtcConnection.prototype.setGatheringState = function (state) {
                    if (this._gatheringState != state) {
                        this._gatheringState = state;
                        if (state == fm.icelink.IceGatheringState.Complete) {
                            this.processIceGatheringStateComplete();
                        }
                        this.raiseGatheringStateChange(this);
                    }
                };
                WebRtcConnection.prototype.setIceConnectionState = function (state) {
                    if (this._iceConnectionState != state) {
                        this._iceConnectionState = state;
                        this.raiseIceConnectionStateChange(this);
                    }
                };
                WebRtcConnection.prototype.getRemoteDescription = function () {
                    return this._remoteDescription;
                };
                WebRtcConnection.prototype.getSessionDescriptionManager = function () {
                    return this._sessionDescriptionManager;
                };
                WebRtcConnection.prototype.setSessionDescriptionManager = function (manager) {
                    this._sessionDescriptionManager = manager;
                };
                WebRtcConnection.prototype.updateLocalDescription = function (localDescription) {
                    var msg = localDescription.getSdpMessage();
                    var mediaDescriptions = msg.getMediaDescriptions();
                    var streamDirection = fm.icelink.StreamDirection.Inactive;
                    var updatedStreamDirection = false;
                    if (mediaDescriptions != null) {
                        var mediaIndex = -1;
                        var streams = this.getStreams();
                        for (var _i = 0, mediaDescriptions_2 = mediaDescriptions; _i < mediaDescriptions_2.length; _i++) {
                            var mediaDescription = mediaDescriptions_2[_i];
                            mediaIndex++;
                            if (fm.icelink.Util.isSafari() && mediaDescription.getRtpMapAttribute('VP8', 90000)) {
                                mediaDescription.purgeFormat('H264');
                            }
                            if (mediaIndex < streams.length) {
                                var stream_1 = streams[mediaIndex];
                                if (stream_1.getType() == fm.icelink.StreamType.Audio || stream_1.getType() == fm.icelink.StreamType.Video) {
                                    var mediaStream = stream_1;
                                    var usedRtpStreamIds = [];
                                    var midAttribute = mediaDescription.getMediaStreamIdentifierAttribute();
                                    if (midAttribute) {
                                        mediaStream.setMediaStreamIdentification(midAttribute.getIdentificationTag());
                                    }
                                    var ridAttributes = mediaDescription.getRidAttributes();
                                    if (ridAttributes && ridAttributes.length > 0) {
                                        var sendEncodings = mediaStream.getSendEncodingInfos();
                                        if (sendEncodings && sendEncodings.length <= ridAttributes.length) {
                                            for (var i = 0; i < sendEncodings.length; i++) {
                                                ridAttributes[i].setRestrictions(sendEncodings[i].getSdpRidRestrictions());
                                            }
                                        }
                                        for (var _a = 0, ridAttributes_1 = ridAttributes; _a < ridAttributes_1.length; _a++) {
                                            var ridAttribute = ridAttributes_1[_a];
                                            usedRtpStreamIds.push(ridAttribute.getId());
                                        }
                                    }
                                    else if (stream_1.getType() == fm.icelink.StreamType.Video) {
                                        var sourceEncoding = mediaStream.getSourceEncoding();
                                        if (sourceEncoding) {
                                            var ssrcAttributes = mediaDescription.getSsrcAttributes(fm.icelink.sdp.rtp.SsrcAttributeName.getCName());
                                            if (ssrcAttributes.length > 0) {
                                                sourceEncoding.setSynchronizationSource(ssrcAttributes[0].getSynchronizationSource());
                                                for (var _b = 0, _c = sourceEncoding.getSdpSsrcRestrictionAttributes(); _b < _c.length; _b++) {
                                                    var ssrcRestrictionAttribute = _c[_b];
                                                    mediaDescription.addMediaAttribute(ssrcRestrictionAttribute);
                                                }
                                            }
                                        }
                                    }
                                    if (mediaStream.getSimulcastMode() != fm.icelink.SimulcastMode.Disabled) {
                                        var sendEncodings = mediaStream.getSendEncodingInfos();
                                        if (sendEncodings.length > 1) {
                                            mediaDescription.purgeFormat('VP9');
                                        }
                                    }
                                    var remoteEncoding = mediaStream.getRemoteEncoding();
                                    if (remoteEncoding) {
                                        var remoteRtpStreamIndex = 0;
                                        while (true) {
                                            if (!fm.icelink.ArrayExtensions.contains(usedRtpStreamIds, remoteRtpStreamIndex.toString())) {
                                                break;
                                            }
                                            remoteRtpStreamIndex++;
                                        }
                                        var remoteRtpStreamId = remoteRtpStreamIndex.toString();
                                        var ridAttribute = new fm.icelink.sdp.rtp.RidAttribute(remoteRtpStreamId, fm.icelink.sdp.rtp.RidDirection.getReceive(), remoteEncoding.getSdpRidRestrictions());
                                        mediaDescription.addMediaAttribute(ridAttribute);
                                    }
                                }
                            }
                            updatedStreamDirection = false;
                            var media = mediaDescription.getMedia();
                            var mediaType = media.getMediaType();
                            var streamType = fm.icelink.sdp.MediaType.toStreamType(mediaType);
                            if (streamType == fm.icelink.StreamType.Audio) {
                                var audioStreams = this.getAudioStreams();
                                if (audioStreams != null && audioStreams.length > 0) {
                                    var stream_2 = audioStreams[0];
                                    streamDirection = stream_2.getDirection();
                                    updatedStreamDirection = true;
                                    for (var _d = 0, _e = mediaDescription.getBandwidths(); _d < _e.length; _d++) {
                                        var bandwidth = _e[_d];
                                        if (bandwidth.getBandwidthType().toLowerCase() == "tias" ||
                                            bandwidth.getBandwidthType().toLowerCase() == "as") {
                                            mediaDescription.removeBandwidth(bandwidth);
                                            break;
                                        }
                                    }
                                    if (stream_2.getLocalBandwidth() > 0) {
                                        mediaDescription.addBandwidth(new fm.icelink.sdp.Bandwidth("TIAS", stream_2.getLocalBandwidth() * 1000));
                                        mediaDescription.addBandwidth(new fm.icelink.sdp.Bandwidth("AS", stream_2.getLocalBandwidth()));
                                    }
                                }
                            }
                            else if (streamType == fm.icelink.StreamType.Video) {
                                var videoStreams = this.getVideoStreams();
                                if (videoStreams != null && videoStreams.length > 0) {
                                    var stream = videoStreams[0];
                                    streamDirection = stream.getDirection();
                                    updatedStreamDirection = true;
                                    for (var _f = 0, _g = mediaDescription.getBandwidths(); _f < _g.length; _f++) {
                                        var bandwidth = _g[_f];
                                        if (bandwidth.getBandwidthType().toLowerCase() == "tias" ||
                                            bandwidth.getBandwidthType().toLowerCase() == "as") {
                                            mediaDescription.removeBandwidth(bandwidth);
                                            break;
                                        }
                                    }
                                    if (stream.getLocalBandwidth() > 0) {
                                        mediaDescription.addBandwidth(new fm.icelink.sdp.Bandwidth("TIAS", stream.getLocalBandwidth() * 1000));
                                        mediaDescription.addBandwidth(new fm.icelink.sdp.Bandwidth("AS", stream.getLocalBandwidth()));
                                    }
                                }
                            }
                            if (updatedStreamDirection) {
                                mediaDescription.setStreamDirection(streamDirection);
                            }
                        }
                    }
                    return localDescription;
                };
                WebRtcConnection.prototype.doSetLocalDescription = function (promise, localDescription) {
                    var _this = this;
                    fm.icelink.ManagedThread.dispatch(function () {
                        try {
                            if (!_this._initialized) {
                                _this.initialize();
                            }
                            localDescription = _this.updateLocalDescription(localDescription);
                            var error = _this.processDescription(localDescription, true);
                            if (error == null) {
                                var signallingState = _this.getSignallingState();
                                if (signallingState == fm.icelink.SignallingState.New) {
                                    _this.setSignallingState(fm.icelink.SignallingState.HaveLocalOffer);
                                }
                                else if (signallingState == fm.icelink.SignallingState.HaveRemoteOffer) {
                                    _this.setSignallingState(fm.icelink.SignallingState.Stable);
                                }
                                else if (signallingState == fm.icelink.SignallingState.Stable) {
                                    _this.setSignallingState(fm.icelink.SignallingState.HaveLocalOffer);
                                }
                                if (fm.icelink.Plugin.hasOrtc()) {
                                    _this._ortcLocalDescription = _this.ortcSessionDescriptionFromSessionDescription(localDescription);
                                    _this._localDescription = localDescription;
                                    if (_this.getRemoteDescription()) {
                                        if (_this.getState() != fm.icelink.ConnectionState.Connected) {
                                            _this.setState(fm.icelink.ConnectionState.Connecting);
                                            _this.startOrtc();
                                        }
                                    }
                                    promise.resolve(localDescription);
                                }
                                else {
                                    if (_this._offerer && _this._isRenegotiation) {
                                        if (fm.icelink.Util.isFirefox()) {
                                            _this.reorderExtRtpMapIdsOnRenegotiationOffer(localDescription, _this._localDescription, _this._remoteDescription);
                                        }
                                    }
                                    var webrtcSessionDescription = _this.webrtcSessionDescriptionFromSessionDescription(localDescription);
                                    var successCallback = function () {
                                        _this._localDescription = localDescription;
                                        if (_this.getRemoteDescription()) {
                                            if (_this.getState() != fm.icelink.ConnectionState.Connected) {
                                                _this.setState(fm.icelink.ConnectionState.Connecting);
                                            }
                                        }
                                        _this.setNativeDescriptionSuccess(localDescription, promise);
                                    };
                                    var failureCallback = function (ex) {
                                        if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, ex))) {
                                            _this.doClose();
                                            _this.setState(fm.icelink.ConnectionState.Failed);
                                        }
                                        promise.reject(ex);
                                    };
                                    try {
                                        _this._nativePeerConnection.setLocalDescription(webrtcSessionDescription.sessionDescription).then(successCallback, failureCallback);
                                    }
                                    catch (ex) {
                                        _this._nativePeerConnection.setLocalDescription(webrtcSessionDescription.sessionDescription, successCallback, failureCallback);
                                    }
                                }
                                var canonicalName = _this.getConnectionWideCanonicalName();
                                var streams = _this.getStreams();
                                for (var _i = 0, streams_11 = streams; _i < streams_11.length; _i++) {
                                    var stream = streams_11[_i];
                                    if (stream.getType() == fm.icelink.StreamType.Application) {
                                        stream.setCanonicalName(canonicalName);
                                    }
                                }
                            }
                            else {
                                if (_this.setState(fm.icelink.ConnectionState.Failing, error)) {
                                    _this.doClose();
                                    _this.setState(fm.icelink.ConnectionState.Failed);
                                }
                                promise.reject(error.getException());
                            }
                        }
                        catch (ex) {
                            if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, ex))) {
                                _this.doClose();
                                _this.setState(fm.icelink.ConnectionState.Failed);
                            }
                            promise.reject(ex);
                        }
                    });
                };
                WebRtcConnection.prototype.processRemoteDescriptionOnRenegotiation = function (promise, remoteDescription) {
                    if (this._localDescription == null || this._remoteDescription == null) {
                        return;
                    }
                    var localMessage = this._localDescription.getSdpMessage();
                    var descriptions = localMessage.getMediaDescriptions();
                    var description = descriptions[0];
                    var localSetupAttribute = description.getSetupAttribute();
                    var localRole = localSetupAttribute.getSetup();
                    var remoteRole = fm.icelink.sdp.Setup.getPassive();
                    var currentRemoteMessage = this._remoteDescription.getSdpMessage();
                    fm.icelink.Log.info("Current remote description:");
                    fm.icelink.Log.info(currentRemoteMessage.toString());
                    var currentRemoteDescriptions = currentRemoteMessage.getMediaDescriptions();
                    if (localRole == fm.icelink.sdp.Setup.getActive()) {
                        remoteRole = fm.icelink.sdp.Setup.getPassive();
                    }
                    else if (localRole == fm.icelink.sdp.Setup.getPassive()) {
                        remoteRole = fm.icelink.sdp.Setup.getActive();
                    }
                    else {
                        description = currentRemoteDescriptions[0];
                        var remoteSetupAttribute = description.getSetupAttribute();
                        remoteRole = remoteSetupAttribute.getSetup();
                    }
                    var newRemoteMessage = remoteDescription.getSdpMessage();
                    var newRemoteDescriptions = newRemoteMessage.getMediaDescriptions();
                    for (var _i = 0, newRemoteDescriptions_1 = newRemoteDescriptions; _i < newRemoteDescriptions_1.length; _i++) {
                        var mediaDescription = newRemoteDescriptions_1[_i];
                        mediaDescription.setSetupAttribute(remoteSetupAttribute);
                    }
                    newRemoteMessage.updateSetupValue(remoteRole);
                    newRemoteMessage.updateSetupValue(remoteRole);
                    this._remoteDescription = remoteDescription;
                    this.doCreateAnswer(promise);
                };
                WebRtcConnection.prototype.removeSdesAttributesIfNeeded = function (remoteDescription) {
                    if (remoteDescription.getIsOffer()) {
                        var message = remoteDescription.getSdpMessage();
                        var sessionFingerprint = message.getSessionLevelFingerprintAttribute();
                        var sessionCryptos = message.getSessionLevelCryptoAttributes();
                        var mediaDescriptions = message.getMediaDescriptions();
                        var removeSessionCryptos = false;
                        for (var _i = 0, mediaDescriptions_3 = mediaDescriptions; _i < mediaDescriptions_3.length; _i++) {
                            var mediaDescription = mediaDescriptions_3[_i];
                            var cryptoAttributes = mediaDescription.getCryptoAttributes();
                            var fingerprintAttribute = mediaDescription.getFingerprintAttribute();
                            if (fingerprintAttribute != null || sessionFingerprint != null) {
                                if (cryptoAttributes != null) {
                                    for (var _a = 0, cryptoAttributes_1 = cryptoAttributes; _a < cryptoAttributes_1.length; _a++) {
                                        var cryptoAttribute = cryptoAttributes_1[_a];
                                        mediaDescription.removeMediaAttribute(cryptoAttribute);
                                    }
                                }
                                removeSessionCryptos = true;
                            }
                        }
                        if (removeSessionCryptos) {
                            if (sessionCryptos != null) {
                                message.removeSessionAttribute(fm.icelink.sdp.AttributeType.CryptoAttribute);
                            }
                        }
                    }
                };
                WebRtcConnection.prototype.doSetRemoteDescription = function (promise, remoteDescription) {
                    var _this = this;
                    fm.icelink.ManagedThread.dispatch(function () {
                        try {
                            if (!_this._initialized) {
                                _this.initialize();
                            }
                            var error = _this.processDescription(remoteDescription, false);
                            if (error == null) {
                                if (fm.icelink.Plugin.hasOrtc()) {
                                    _this._ortcRemoteDescription = _this.ortcSessionDescriptionFromSessionDescription(remoteDescription);
                                    for (var i = 0; i < _this._ortcRemoteDescription.mediaDescriptions.length; i++) {
                                        var remoteMediaDescription = _this._ortcRemoteDescription.mediaDescriptions[i];
                                        if (!remoteMediaDescription.ssrc) {
                                            remoteMediaDescription.ssrc = 0;
                                        }
                                        if (!remoteMediaDescription.cname) {
                                            remoteMediaDescription.cname = '';
                                        }
                                        if (remoteMediaDescription.candidates.length > 0) {
                                            for (var j = 0; j < remoteMediaDescription.candidates.length; j++) {
                                                if (_this._nativeIceTransports[i].state != "closed") {
                                                    _this._nativeIceTransports[i].addRemoteCandidate(remoteMediaDescription.candidates[j]);
                                                }
                                            }
                                        }
                                    }
                                    _this.setRemoteCandidatesDoneTimer();
                                    _this._remoteDescription = remoteDescription;
                                    var signallingState = _this.getSignallingState();
                                    if (signallingState == fm.icelink.SignallingState.New) {
                                        _this.setSignallingState(fm.icelink.SignallingState.HaveRemoteOffer);
                                    }
                                    else if (signallingState == fm.icelink.SignallingState.HaveLocalOffer) {
                                        _this.setSignallingState(fm.icelink.SignallingState.Stable);
                                    }
                                    else if (signallingState == fm.icelink.SignallingState.Stable) {
                                        _this.setSignallingState(fm.icelink.SignallingState.HaveRemoteOffer);
                                    }
                                    if (_this.getLocalDescription()) {
                                        if (_this.getState() != fm.icelink.ConnectionState.Connected) {
                                            _this.setState(fm.icelink.ConnectionState.Connecting);
                                            _this.startOrtc();
                                        }
                                    }
                                    promise.resolve(remoteDescription);
                                }
                                else {
                                    _this._remoteMediaTrackCount = 0;
                                    for (var _i = 0, _a = remoteDescription.getSdpMessage().getMediaDescriptions(); _i < _a.length; _i++) {
                                        var sdpMediaDescription = _a[_i];
                                        var direction = sdpMediaDescription.getStreamDirection();
                                        if (sdpMediaDescription.getSsrcAttributes().length > 0 && (direction == fm.icelink.StreamDirection.SendReceive || direction == fm.icelink.StreamDirection.SendOnly)) {
                                            _this._remoteMediaTrackCount++;
                                        }
                                    }
                                    if (_this._remoteMediaTrackCount == 0) {
                                        _this._mediaStreamsReady = true;
                                    }
                                    _this.removeSdesAttributesIfNeeded(remoteDescription);
                                    var webrtcSessionDescription = _this.webrtcSessionDescriptionFromSessionDescription(remoteDescription);
                                    var successCallback = function () {
                                        _this._remoteDescription = remoteDescription;
                                        var remoteMedia = _this.getRemoteMedia();
                                        remoteMedia._setMediaStreams(remoteMedia._getAudioMediaStream(), remoteMedia._getVideoMediaStream());
                                        var remoteVideoTrack = remoteMedia.getVideoTrack();
                                        for (var _i = 0, _a = _this.getVideoStreams(); _i < _a.length; _i++) {
                                            var videoStream = _a[_i];
                                            if (videoStream.getRemoteTrack() == null) {
                                                videoStream.setRemoteTrack(remoteVideoTrack);
                                            }
                                        }
                                        var remoteAudioTrack = remoteMedia.getAudioTrack();
                                        for (var _b = 0, _c = _this.getAudioStreams(); _b < _c.length; _b++) {
                                            var audioStream = _c[_b];
                                            if (audioStream.getRemoteTrack() == null) {
                                                audioStream.setRemoteTrack(remoteAudioTrack);
                                            }
                                        }
                                        var signallingState = _this.getSignallingState();
                                        if (signallingState == fm.icelink.SignallingState.New) {
                                            _this.setSignallingState(fm.icelink.SignallingState.HaveRemoteOffer);
                                        }
                                        else if (signallingState == fm.icelink.SignallingState.HaveLocalOffer) {
                                            _this.setSignallingState(fm.icelink.SignallingState.Stable);
                                        }
                                        else if (signallingState == fm.icelink.SignallingState.Stable) {
                                            _this.setSignallingState(fm.icelink.SignallingState.HaveRemoteOffer);
                                        }
                                        if (_this.getSignallingState() == fm.icelink.SignallingState.Stable) {
                                            _this._isRenegotiation = true;
                                        }
                                        if (_this.getLocalDescription()) {
                                            if (_this.getState() != fm.icelink.ConnectionState.Connected) {
                                                _this.setState(fm.icelink.ConnectionState.Connecting);
                                            }
                                        }
                                        if (_this.getSignallingState() == fm.icelink.SignallingState.HaveRemoteOffer && !_this._offerer && !_this._isRenegotiation) {
                                            var useAddTrack = fm.icelink.Util.isFunction(_this._nativePeerConnection.addTrack);
                                            var useAddTransceiver = fm.icelink.Util.isFunction(_this._nativePeerConnection.addTransceiver);
                                            if (useAddTransceiver || useAddTrack) {
                                                for (var _d = 0, _e = _this._mediaStreams; _d < _e.length; _d++) {
                                                    var mediaStream = _e[_d];
                                                    var localMediaTrack = mediaStream.getLocalTrack();
                                                    if (localMediaTrack) {
                                                        var localMedia = localMediaTrack.getMedia();
                                                        var nativeMediaStreamTrack = localMediaTrack._getMediaStreamTrack();
                                                        if (nativeMediaStreamTrack) {
                                                            var kind = nativeMediaStreamTrack.kind;
                                                            var nativeMediaStream = (kind == 'audio' ? localMedia._getAudioMediaStream() : localMedia._getVideoMediaStream());
                                                            if (nativeMediaStream) {
                                                                _this.setupTransceivers(useAddTransceiver, useAddTrack, nativeMediaStreamTrack, nativeMediaStream, mediaStream);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        promise.resolve(remoteDescription);
                                    };
                                    var failureCallback = function (ex) {
                                        if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, ex))) {
                                            _this.doClose();
                                            _this.setState(fm.icelink.ConnectionState.Failed);
                                        }
                                        promise.reject(ex);
                                    };
                                    try {
                                        _this._nativePeerConnection.setRemoteDescription(webrtcSessionDescription.sessionDescription).then(successCallback, failureCallback);
                                    }
                                    catch (ex) {
                                        _this._nativePeerConnection.setRemoteDescription(webrtcSessionDescription.sessionDescription, successCallback, failureCallback);
                                    }
                                }
                            }
                            else {
                                if (_this.setState(fm.icelink.ConnectionState.Failing, error)) {
                                    _this.doClose();
                                    _this.setState(fm.icelink.ConnectionState.Failed);
                                }
                                promise.reject(error.getException());
                            }
                        }
                        catch (ex) {
                            if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.ConnectionInvalidArchitecture, ex))) {
                                _this.doClose();
                                _this.setState(fm.icelink.ConnectionState.Failed);
                            }
                            promise.reject(ex);
                        }
                    });
                };
                WebRtcConnection.prototype.doSendCachedLocalCandidates = function () { };
                WebRtcConnection.prototype.startOrtc = function () {
                    this._transportsRemaining = this._nativeDtlsTransports.length;
                    for (var i = 0; i < this._nativeIceGatherers.length; i++) {
                        this.startOrtcTrack(this._nativeIceGatherers[i], this._nativeIceTransports[i], this._nativeDtlsTransports[i], this._ortcLocalDescription.mediaDescriptions[i], this._ortcRemoteDescription.mediaDescriptions[i]);
                    }
                    for (var i = 0; i < this._nativeRtpReceivers.length; i++) {
                        var remoteMediaDescription = this._ortcRemoteDescription.mediaDescriptions[i];
                        if (remoteMediaDescription.ssrc > 0 && this._nativeRtpReceivers[i]) {
                            this._nativeRtpReceivers[i].receive({
                                muxId: '',
                                codecs: this.selectCodecs(i),
                                headerExtensions: [],
                                encodings: this.selectEncodings(i, false),
                                rtcp: this.selectRtcp(i, false)
                            });
                        }
                    }
                    for (var i = 0; i < this._nativeRtpSenders.length; i++) {
                        var localMediaDescription = this._ortcLocalDescription.mediaDescriptions[i];
                        if (localMediaDescription.ssrc > 0 && this._nativeRtpSenders[i]) {
                            this._nativeRtpSenders[i].send({
                                muxId: '',
                                codecs: this.selectCodecs(i),
                                headerExtensions: [],
                                encodings: this.selectEncodings(i, true),
                                rtcp: this.selectRtcp(i, true)
                            });
                        }
                    }
                    this._remoteMedia._setMediaStream(this._remoteNativeMediaStream);
                };
                WebRtcConnection.prototype.startOrtcTrack = function (iceGatherer, iceTransport, dtlsTransport, localMediaDescription, remoteMediaDescription) {
                    var _this = this;
                    var iceRole = 'controlling';
                    if (localMediaDescription.dtlsParams.role == 'client' ||
                        remoteMediaDescription.dtlsParams.role == 'server') {
                        iceRole = 'controlled';
                    }
                    iceGatherer.onerror = function (evt) {
                        if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.IceStartError, new fm.icelink.Exception('An ICE gatherer error occurred.')))) {
                            _this.doClose();
                            _this.setState(fm.icelink.ConnectionState.Failed);
                        }
                    };
                    dtlsTransport.onerror = function (evt) {
                        if (_this.setState(fm.icelink.ConnectionState.Failing, new fm.icelink.Error(fm.icelink.ErrorCode.DtlsInternalError, new fm.icelink.Exception('A DTLS transport error occurred.')))) {
                            _this.doClose();
                            _this.setState(fm.icelink.ConnectionState.Failed);
                        }
                    };
                    iceTransport.onicestatechange = function (evt) {
                        fm.icelink.Log.debug('ORTC ICE transport state has changed to ' + iceTransport.state);
                        if (iceTransport.state == "new") {
                            _this.setIceConnectionState(fm.icelink.IceConnectionState.New);
                            _this.setGatheringState(fm.icelink.IceGatheringState.New);
                        }
                        else if (iceTransport.state == "checking") {
                            _this.setIceConnectionState(fm.icelink.IceConnectionState.Checking);
                            _this.setGatheringState(fm.icelink.IceGatheringState.Gathering);
                        }
                        else if (iceTransport.state == "connected") {
                            _this.setIceConnectionState(fm.icelink.IceConnectionState.Connected);
                        }
                        else if (iceTransport.state == "completed") {
                            _this.setIceConnectionState(fm.icelink.IceConnectionState.Completed);
                            _this.setGatheringState(fm.icelink.IceGatheringState.Complete);
                        }
                        else if (iceTransport.state == "disconnected") {
                            _this.setIceConnectionState(fm.icelink.IceConnectionState.Disconnected);
                        }
                        else if (iceTransport.state == "closed") {
                            _this.setIceConnectionState(fm.icelink.IceConnectionState.Closed);
                        }
                    };
                    dtlsTransport.ondtlsstatechange = function (evt) {
                        fm.icelink.Log.debug('ORTC DTLS transport state has changed to ' + dtlsTransport.state);
                        if (dtlsTransport.state == 'connected') {
                            _this._transportsRemaining--;
                            if (_this._transportsRemaining == 0) {
                                _this.setState(fm.icelink.ConnectionState.Connected);
                            }
                        }
                    };
                    iceTransport.start(iceGatherer, remoteMediaDescription.iceParams, iceRole);
                    dtlsTransport.start(remoteMediaDescription.dtlsParams);
                };
                WebRtcConnection.prototype.selectCodecs = function (mediaIndex) {
                    var localMediaDescription = this._ortcLocalDescription.mediaDescriptions[mediaIndex];
                    var remoteMediaDescription = this._ortcRemoteDescription.mediaDescriptions[mediaIndex];
                    var selectedCodecs = [];
                    for (var _i = 0, _a = localMediaDescription.codecCaps; _i < _a.length; _i++) {
                        var localCodec = _a[_i];
                        for (var _b = 0, _c = remoteMediaDescription.codecCaps; _b < _c.length; _b++) {
                            var remoteCodec = _c[_b];
                            if (localCodec.name.toLowerCase() == remoteCodec.name.toLowerCase() &&
                                localCodec.clockRate == remoteCodec.clockRate &&
                                localCodec.numChannels == remoteCodec.numChannels &&
                                localCodec.preferredPayloadType == remoteCodec.preferredPayloadType) {
                                selectedCodecs.push({
                                    name: localCodec.name,
                                    payloadType: localCodec.preferredPayloadType,
                                    clockRate: localCodec.clockRate,
                                    numChannels: localCodec.numChannels,
                                    rtcpFeedback: localCodec.rtcpFeedback,
                                    parameters: localCodec.parameters
                                });
                                break;
                            }
                        }
                    }
                    return selectedCodecs;
                };
                WebRtcConnection.prototype.selectEncodings = function (mediaIndex, send) {
                    var localMediaDescription = this._ortcLocalDescription.mediaDescriptions[mediaIndex];
                    var remoteMediaDescription = this._ortcRemoteDescription.mediaDescriptions[mediaIndex];
                    return [{
                            active: true,
                            codecPayloadType: 0,
                            fec: 0,
                            framerateBias: 0.5,
                            framerateScale: 1,
                            maxBitrate: 2000000,
                            minQuality: 0,
                            priority: 1,
                            resolutionScale: 1,
                            rtx: 0,
                            ssrc: send ? localMediaDescription.ssrc : remoteMediaDescription.ssrc
                        }];
                };
                WebRtcConnection.prototype.selectRtcp = function (mediaIndex, send) {
                    this._ortcLocalDescription.mediaDescriptions[mediaIndex];
                    this._ortcRemoteDescription.mediaDescriptions[mediaIndex];
                    return {
                        cname: '',
                        mux: true,
                        reducedSize: false,
                        ssrc: 0
                    };
                };
                WebRtcConnection.prototype.doAddRemoteCandidate = function (promise, remoteCandidate) {
                    var _this = this;
                    fm.icelink.ManagedThread.dispatch(function () {
                        try {
                            if (fm.icelink.Plugin.hasOrtc()) {
                                if (_this._remoteCandidatesDone) {
                                    throw new fm.icelink.Exception('Could not add remote candidate. End of candidates has been signalled.');
                                }
                                var ortcCandidate = _this.ortcCandidateFromCandidate(remoteCandidate);
                                if (ortcCandidate.candidate.protocol == fm.icelink.sdp.ice.TransportProtocol.getTcp() && !_this._ortcSupportsTcp) {
                                    throw new fm.icelink.Exception('ORTC does not currently support the TCP protocol.');
                                }
                                if (_this._nativeIceTransports[ortcCandidate.mediaIndex].state != "closed") {
                                    _this._nativeIceTransports[ortcCandidate.mediaIndex].addRemoteCandidate(ortcCandidate.candidate);
                                }
                                _this.setRemoteCandidatesDoneTimer();
                                promise.resolve(remoteCandidate);
                            }
                            else {
                                var successCallback = function () {
                                    promise.resolve(remoteCandidate);
                                };
                                var failureCallback = function (ex) {
                                    promise.reject(ex);
                                };
                                try {
                                    _this._nativePeerConnection.addIceCandidate(_this.webrtcCandidateFromCandidate(remoteCandidate)).then(successCallback, failureCallback);
                                }
                                catch (ex) {
                                    _this._nativePeerConnection.addIceCandidate(_this.webrtcCandidateFromCandidate(remoteCandidate), successCallback, failureCallback);
                                }
                            }
                        }
                        catch (ex) {
                            promise.reject(ex);
                        }
                    });
                };
                WebRtcConnection.prototype.setRemoteCandidatesDoneTimer = function () {
                    var _this = this;
                    if (this._remoteCandidatesTimer) {
                        clearTimeout(this._remoteCandidatesTimer);
                    }
                    this._remoteCandidatesTimer = setTimeout(function () {
                        if (_this.getState() != fm.icelink.ConnectionState.Connected) {
                            for (var i = 0; i < _this._nativeIceTransports.length; i++) {
                                var iceTransport = _this._nativeIceTransports[i];
                                if (iceTransport.state === "new" && iceTransport.getRemoteCandidates().length > 0) {
                                    iceTransport.addRemoteCandidate({});
                                }
                            }
                            _this._remoteCandidatesDone = true;
                        }
                    }, 1500);
                };
                WebRtcConnection.prototype.assignRemoteDescriptionInternal = function (sessionDescription) {
                    throw new fm.icelink.Exception('assignRemoteDescriptionInternal');
                };
                WebRtcConnection.prototype.close = function () {
                    if (this.setState(fm.icelink.ConnectionState.Closing)) {
                        this.doClose();
                        this.setState(fm.icelink.ConnectionState.Closed);
                        return true;
                    }
                    return false;
                };
                WebRtcConnection.prototype.doClose = function () {
                    if (fm.icelink.Plugin.hasOrtc()) {
                        if (this._nativeRtpSenders) {
                            for (var _i = 0, _a = this._nativeRtpSenders; _i < _a.length; _i++) {
                                var rtpSender = _a[_i];
                                try {
                                    rtpSender.stop();
                                }
                                catch (ex) { }
                            }
                            this._nativeRtpSenders = [];
                        }
                        if (this._nativeRtpReceivers) {
                            for (var _b = 0, _c = this._nativeRtpReceivers; _b < _c.length; _b++) {
                                var rtpReceiver = _c[_b];
                                try {
                                    rtpReceiver.stop();
                                }
                                catch (ex) { }
                            }
                            this._nativeRtpReceivers = [];
                        }
                        if (this._nativeIceTransports) {
                            for (var _d = 0, _e = this._nativeIceTransports; _d < _e.length; _d++) {
                                var iceTransport = _e[_d];
                                try {
                                    iceTransport.stop();
                                }
                                catch (ex) { }
                            }
                            this._nativeIceTransports = [];
                        }
                        if (this._nativeDtlsTransports) {
                            for (var _f = 0, _g = this._nativeDtlsTransports; _f < _g.length; _f++) {
                                var dtlsTransport = _g[_f];
                                try {
                                    dtlsTransport.stop();
                                }
                                catch (ex) { }
                            }
                            this._nativeDtlsTransports = [];
                        }
                    }
                    else {
                        if (this._nativePeerConnection) {
                            try {
                                this._nativePeerConnection.close();
                            }
                            catch (ex) { }
                        }
                    }
                };
                WebRtcConnection.prototype.getDtmfSender = function () {
                    if (!this.dtmfSender) {
                        if (fm.icelink.Plugin.hasOrtc()) {
                            if (!this._nativeRtpSenders) {
                                return null;
                            }
                            var senders = this._nativeRtpSenders;
                            var audioSender = null;
                            for (var _i = 0, senders_1 = senders; _i < senders_1.length; _i++) {
                                var sender = senders_1[_i];
                                if (sender.track && sender.track.kind == 'audio') {
                                    audioSender = sender;
                                }
                            }
                            if (!audioSender) {
                                return null;
                            }
                            this.dtmfSender = new RTCDtmfSender(audioSender);
                        }
                        else {
                            if (!this._nativePeerConnection) {
                                return null;
                            }
                            if (this._nativePeerConnection.createDTMFSender) {
                                var mediaStreams = this._mediaStreams;
                                var audioStream = null;
                                for (var _a = 0, mediaStreams_5 = mediaStreams; _a < mediaStreams_5.length; _a++) {
                                    var mediaStream = mediaStreams_5[_a];
                                    if (mediaStream.getType() == fm.icelink.StreamType.Audio) {
                                        audioStream = mediaStream;
                                    }
                                }
                                if (!audioStream) {
                                    return null;
                                }
                                var localAudioTrack = audioStream.getLocalTrack();
                                if (!localAudioTrack) {
                                    return null;
                                }
                                var nativeAudioTrack = localAudioTrack._getMediaStreamTrack();
                                if (!nativeAudioTrack) {
                                    return null;
                                }
                                this.dtmfSender = this._nativePeerConnection.createDTMFSender(nativeAudioTrack);
                            }
                            else {
                                if (!this._nativePeerConnection.getSenders) {
                                    return null;
                                }
                                var senders = this._nativePeerConnection.getSenders();
                                var audioSender = null;
                                for (var _b = 0, senders_2 = senders; _b < senders_2.length; _b++) {
                                    var sender = senders_2[_b];
                                    if (sender.track && sender.track.kind == 'audio') {
                                        audioSender = sender;
                                    }
                                }
                                if (!audioSender) {
                                    return null;
                                }
                                if (!audioSender.dtmf) {
                                    return null;
                                }
                                this.dtmfSender = audioSender.dtmf;
                            }
                        }
                    }
                    return this.dtmfSender;
                };
                WebRtcConnection.prototype.replaceLocalTrack = function (localTrack, mediaStream) {
                    var promise = new fm.icelink.Promise();
                    try {
                        var mediaStreamIndex = 0;
                        var mediaStreams = this.getMediaStreams();
                        for (var _i = 0, mediaStreams_6 = mediaStreams; _i < mediaStreams_6.length; _i++) {
                            var ms = mediaStreams_6[_i];
                            if (ms == mediaStream) {
                                break;
                            }
                            mediaStreamIndex++;
                        }
                        if (mediaStreamIndex == mediaStreams.length) {
                            throw new fm.icelink.Exception('Media stream is not attached to this connection.');
                        }
                        var rtpSender = this.getRtpSender(mediaStreamIndex);
                        if (!rtpSender.replaceTrack) {
                            throw new fm.icelink.Exception('Browser does not support replaceTrack.');
                        }
                        rtpSender.replaceTrack(localTrack._getMediaStreamTrack() ).then(function () {
                            promise.resolve(null);
                        }, function (ex) {
                            promise.reject(ex);
                        });
                    }
                    catch (ex) {
                        promise.reject(ex);
                    }
                    return promise;
                };
                WebRtcConnection.prototype.replaceRemoteTrack = function (remoteTrack, mediaStream) {
                    return fm.icelink.Promise.rejectNow(new fm.icelink.Exception('Replacing the remote track is not supported.'));
                };
                WebRtcConnection.prototype.getRtpSender = function (mediaStreamIndex) {
                    var rtpSenders = [];
                    if (fm.icelink.Plugin.hasOrtc()) {
                        if (!this._nativeRtpSenders) {
                            throw new fm.icelink.Exception('ORTC peer connection not initialized.');
                        }
                        rtpSenders = this._nativeRtpSenders;
                    }
                    else {
                        if (!this._nativePeerConnection) {
                            throw new fm.icelink.Exception('WebRTC peer connection not initialized.');
                        }
                        if (!this._nativePeerConnection.getSenders) {
                            throw new fm.icelink.Exception('WebRTC browser does not support getSenders.');
                        }
                        rtpSenders = this._nativePeerConnection.getSenders();
                    }
                    if (mediaStreamIndex >= rtpSenders.length) {
                        throw new fm.icelink.Exception('Media stream index exceeds RTP senders count.');
                    }
                    return rtpSenders[mediaStreamIndex];
                };
                WebRtcConnection.prototype.tryGetRtpSender = function (mediaStreamIndex) {
                    var rtpSenders = [];
                    if (fm.icelink.Plugin.hasOrtc()) {
                        if (!this._nativeRtpSenders) {
                            return null;
                        }
                        rtpSenders = this._nativeRtpSenders;
                    }
                    else {
                        if (!this._nativePeerConnection) {
                            return null;
                        }
                        if (!this._nativePeerConnection.getSenders) {
                            return null;
                        }
                        rtpSenders = this._nativePeerConnection.getSenders();
                    }
                    if (mediaStreamIndex >= rtpSenders.length) {
                        return null;
                    }
                    return rtpSenders[mediaStreamIndex];
                };
                WebRtcConnection.prototype.setMaxSendBitrate = function (bitrate, streamType) {
                    var promise = new fm.icelink.Promise();
                    if (this._processingMaxSendBitrate) {
                        this._setMaxSendBitrateQueue.push({
                            bitrate: bitrate,
                            streamType: streamType,
                            promise: promise
                        });
                        return promise;
                    }
                    this.doSetMaxSendBitrate(bitrate, streamType, promise);
                    return promise;
                };
                WebRtcConnection.prototype.processNextSetMaxSendBitrate = function () {
                    if (this._setMaxSendBitrateQueue.length > 0) {
                        var next = this._setMaxSendBitrateQueue[0];
                        this._setMaxSendBitrateQueue.splice(0, 1);
                        this.doSetMaxSendBitrate(next.bitrate, next.streamType, next.promise);
                    }
                };
                WebRtcConnection.prototype.doSetMaxSendBitrate = function (bitrate, streamType, promise) {
                    var _this = this;
                    this._processingMaxSendBitrate = true;
                    try {
                        if (!fm.icelink.Plugin.hasWebRtc()) {
                            throw new fm.icelink.Exception('Browser not supported.');
                        }
                        var nativePeerConnection_1 = this._nativePeerConnection;
                        if (!nativePeerConnection_1) {
                            throw new fm.icelink.Exception('No connection.');
                        }
                        var localDescription = this.getLocalDescription();
                        if (!localDescription) {
                            throw new fm.icelink.Exception('No local description.');
                        }
                        var remoteDescription = this.getRemoteDescription();
                        if (!remoteDescription) {
                            throw new fm.icelink.Exception('No remote description.');
                        }
                        var sdpMessage = remoteDescription.getSdpMessage();
                        if (!this.updateMaxBitrateSdpMessage(bitrate, streamType, sdpMessage)) {
                            throw new fm.icelink.Exception('No ' + new fm.icelink.StreamTypeWrapper(streamType).toString().toLowerCase() + ' description.');
                        }
                        var nativeLocalDescription_1 = this.webrtcSessionDescriptionFromSessionDescription(localDescription).sessionDescription;
                        var nativeRemoteDescription_1 = this.webrtcSessionDescriptionFromSessionDescription(remoteDescription).sessionDescription;
                        var successCallback_1 = function () {
                            try {
                                promise.resolve(null);
                            }
                            finally {
                                _this._processingMaxSendBitrate = false;
                                _this.processNextSetMaxSendBitrate();
                            }
                        };
                        var failureCallback_1 = function (ex) {
                            try {
                                promise.reject(ex);
                            }
                            finally {
                                _this._processingMaxSendBitrate = false;
                                _this.processNextSetMaxSendBitrate();
                            }
                        };
                        nativePeerConnection_1.createOffer().then(function () {
                            nativePeerConnection_1.setLocalDescription(nativeLocalDescription_1).then(function () {
                                nativePeerConnection_1.setRemoteDescription(nativeRemoteDescription_1).then(successCallback_1, failureCallback_1);
                            }, failureCallback_1);
                        }, failureCallback_1);
                    }
                    catch (ex) {
                        promise.reject(ex);
                        this._processingMaxSendBitrate = false;
                        this.processNextSetMaxSendBitrate();
                    }
                };
                WebRtcConnection.prototype.updateMaxBitrateSdpMessage = function (bitrate, streamType, sdpMessage) {
                    if (streamType == fm.icelink.StreamType.Audio) {
                        var sdpAudioDescription = sdpMessage.getAudioDescription();
                        if (sdpAudioDescription) {
                            this.updateMaxBitrateSdpMediaDescription(bitrate, sdpAudioDescription);
                            return true;
                        }
                    }
                    if (streamType == fm.icelink.StreamType.Video) {
                        var sdpVideoDescription = sdpMessage.getVideoDescription();
                        if (sdpVideoDescription) {
                            this.updateMaxBitrateSdpMediaDescription(bitrate, sdpVideoDescription);
                            return true;
                        }
                    }
                    return false;
                };
                WebRtcConnection.prototype.updateMaxBitrateSdpMediaDescription = function (bitrate, sdpMediaDescription) {
                    for (var _i = 0, _a = sdpMediaDescription.getBandwidths(); _i < _a.length; _i++) {
                        var bandwidth = _a[_i];
                        if (bandwidth.getBandwidthType().toLowerCase() == "tias" ||
                            bandwidth.getBandwidthType().toLowerCase() == "as") {
                            sdpMediaDescription.removeBandwidth(bandwidth);
                            break;
                        }
                    }
                    if (bitrate > 0) {
                        sdpMediaDescription.addBandwidth(new fm.icelink.sdp.Bandwidth("TIAS", bitrate * 1000));
                        sdpMediaDescription.addBandwidth(new fm.icelink.sdp.Bandwidth("AS", bitrate));
                    }
                };
                WebRtcConnection.webRtcConnectionInitialize = function () {
                    if (!this.__webRtcConnectionInitialized) {
                        window.RTCPeerConnection = window.RTCPeerConnection ||
                            window.webkitRTCPeerConnection ||
                            window.mozRTCPeerConnection ||
                            window.msRTCPeerConnection;
                        window.RTCDataChannel = window.RTCDataChannel ||
                            window.webkitRTCDataChannel ||
                            window.mozRTCDataChannel ||
                            window.msRTCDataChannel;
                        window.RTCSessionDescription = window.RTCSessionDescription ||
                            window.webkitRTCSessionDescription ||
                            window.mozRTCSessionDescription ||
                            window.msRTCPeerConnection;
                        window.RTCIceCandidate = window.RTCIceCandidate ||
                            window.webkitRTCIceCandidate ||
                            window.mozRTCIceCandidate ||
                            window.msRTCIceCandidate;
                    }
                    fm.icelink.WebRtcConnection.__webRtcConnectionInitialized = true;
                };
                WebRtcConnection.__webRtcConnectionInitialized = false;
                return WebRtcConnection;
            }(fm.icelink.WebRtcConnectionBase));
            icelink.WebRtcConnection = WebRtcConnection;
            fm.icelink.WebRtcConnection.webRtcConnectionInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcDataChannel =  (function (_super) {
                __extends(WebRtcDataChannel, _super);
                function WebRtcDataChannel(external, label, ordered, subprotocol) {
                    var _this = this;
                    if (fm.icelink.Util.isNullOrUndefined(ordered)) {
                        ordered = true;
                    }
                    if (fm.icelink.Util.isNullOrUndefined(subprotocol)) {
                        subprotocol = '';
                    }
                    _this = _super.call(this, label, ordered, subprotocol) || this;
                    _this._external = external;
                    _this.sendQueue = [];
                    return _this;
                }
                WebRtcDataChannel.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcDataChannel]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcDataChannel.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcDataChannel.prototype.getNativeDataChannel = function () {
                    return this._nativeDataChannel;
                };
                WebRtcDataChannel.prototype.setNativeDataChannel = function (nativeDataChannel) {
                    var _this = this;
                    if (nativeDataChannel != this._nativeDataChannel) {
                        if (this._nativeDataChannel) {
                            this._nativeDataChannel.onmessage = null;
                        }
                        this._nativeDataChannel = nativeDataChannel;
                        if (this._nativeDataChannel) {
                            this._nativeDataChannel.onmessage = function (event) {
                                if (fm.icelink.Util.isString(event.data)) {
                                    _this.raiseDataString(event.data);
                                }
                                else {
                                    _this.raiseDataBytes(fm.icelink.DataBuffer.wrap(new Uint8Array(event.data)));
                                }
                            };
                            this.setState(fm.icelink.DataChannelState.Connecting);
                            this._nativeDataChannel.onopen = function (event) {
                                _this.setState(fm.icelink.DataChannelState.Connected);
                                _this._nativeDataChannel.binaryType = 'arraybuffer';
                                _this.sendQueue.forEach(function (o) {
                                    if (o.dataBytes) {
                                        _this._nativeDataChannel.send(o.dataBytes);
                                        _this.registerDataSent(o.dataLength);
                                    }
                                    else if (o.dataString) {
                                        _this._nativeDataChannel.send(o.dataString);
                                        _this.registerDataSent(o.dataLength);
                                    }
                                });
                            };
                            this._nativeDataChannel.onerror = function (event) {
                                _this.setState(fm.icelink.DataChannelState.Failed);
                            };
                            this._nativeDataChannel.onclose = function (event) {
                                if (_this.setState(fm.icelink.DataChannelState.Closing)) {
                                    _this.setState(fm.icelink.DataChannelState.Closed);
                                }
                            };
                        }
                    }
                };
                WebRtcDataChannel.prototype.getInstance = function () {
                    return this;
                };
                WebRtcDataChannel.prototype.sendDataString = function (dataString) {
                    var promise = new fm.icelink.Promise();
                    this.prepareAndSendMessage(dataString, promise);
                    return promise;
                };
                WebRtcDataChannel.prototype.promisedSendDataBytes = function (dataBytes, dataLength, promise) {
                    var nativeDataChannel = this.getNativeDataChannel();
                    if (nativeDataChannel) {
                        var state = nativeDataChannel.readyState;
                        if (state === 'open') {
                            nativeDataChannel.send(dataBytes.toArray());
                            this.registerDataSent(dataLength);
                            promise.resolve(dataBytes);
                        }
                        else if (state == 'connecting') {
                            this.sendQueue.push({
                                dataBytes: dataBytes,
                                dataLength: dataLength
                            });
                            promise.resolve(dataBytes);
                        }
                        else {
                            var errorStr = 'Attempt to communicate on a data channel that is not open or connecting.';
                            fm.icelink.Log.debug(errorStr);
                            promise.reject(new fm.icelink.Exception(errorStr));
                        }
                    }
                    else {
                        var errorStr = 'Attempt to communicate on a data channel that has not been prepared.';
                        fm.icelink.Log.debug(errorStr);
                        promise.reject(new fm.icelink.Exception(errorStr));
                    }
                };
                WebRtcDataChannel.prototype.promisedSendDataString = function (dataString, dataLength, promise) {
                    var nativeDataChannel = this.getNativeDataChannel();
                    if (nativeDataChannel) {
                        var state = nativeDataChannel.readyState;
                        if (state === 'open') {
                            nativeDataChannel.send(dataString);
                            this.registerDataSent(dataLength);
                            promise.resolve(dataString);
                        }
                        else if (state == 'connecting') {
                            this.sendQueue.push({
                                dataString: dataString,
                                dataLength: dataLength
                            });
                            promise.resolve(dataString);
                        }
                        else {
                            var errorStr = 'Attempt to communicate on a data channel that is not open or connecting.';
                            fm.icelink.Log.debug(errorStr);
                            promise.reject(new fm.icelink.Exception(errorStr));
                        }
                    }
                    else {
                        var errorStr = 'Attempt to communicate on a data channel that has not been prepared.';
                        fm.icelink.Log.debug(errorStr);
                        promise.reject(new fm.icelink.Exception(errorStr));
                    }
                };
                WebRtcDataChannel.prototype.sendDataBytes = function (dataBytes) {
                    var promise = new fm.icelink.Promise();
                    this.prepareAndSendMessage(dataBytes, promise);
                    return promise;
                };
                return WebRtcDataChannel;
            }(fm.icelink.WebRtcDataChannelBase));
            icelink.WebRtcDataChannel = WebRtcDataChannel;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcDataStream =  (function (_super) {
                __extends(WebRtcDataStream, _super);
                function WebRtcDataStream(external, channels) {
                    var _this = _super.call(this) || this;
                    _this._external = external;
                    _this._channels = channels;
                    return _this;
                }
                WebRtcDataStream.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcDataStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcDataStream.prototype.processSdpMediaDescription = function (sdpMessage, sdpMediaDescription, index, isLocalDescription, isOffer, isRenegotiation) {
                    var manager = this.getMediaDescriptionManager();
                    var requirements = new fm.icelink.MediaDescriptionRequirements();
                    return manager.processSdpMediaDescription(requirements, sdpMessage, index, isLocalDescription, isRenegotiation, isOffer);
                };
                WebRtcDataStream.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcDataStream.prototype.getChannels = function () {
                    return this._channels;
                };
                return WebRtcDataStream;
            }(fm.icelink.WebRtcDataStreamBase));
            icelink.WebRtcDataStream = WebRtcDataStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcDomAudioSink =  (function (_super) {
                __extends(WebRtcDomAudioSink, _super);
                function WebRtcDomAudioSink(external, track) {
                    var _this = _super.call(this) || this;
                    _this._external = external;
                    _this._audio = document.createElement('audio');
                    _this._audio.setAttribute('autoplay', 'autoplay');
                    _this.setTrack(track);
                    return _this;
                }
                WebRtcDomAudioSink.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcDomAudioSink]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcDomAudioSink.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcDomAudioSink.prototype.getTrack = function () {
                    return this._track;
                };
                WebRtcDomAudioSink.prototype.getLocal = function () {
                    return this._local;
                };
                WebRtcDomAudioSink.prototype.getAudio = function () {
                    return this._audio;
                };
                WebRtcDomAudioSink.prototype.getVolume = function () {
                    return this._audio.volume;
                };
                WebRtcDomAudioSink.prototype.setVolume = function (volume) {
                    this._audio.volume = volume;
                };
                WebRtcDomAudioSink.prototype.getMuted = function () {
                    return this._audio.muted;
                };
                WebRtcDomAudioSink.prototype.setMuted = function (muted) {
                    this._audio.muted = muted;
                };
                WebRtcDomAudioSink.prototype.setTrack = function (track) {
                    var _this = this;
                    if (!track) {
                        return false;
                    }
                    this._track = track;
                    this._local = fm.icelink.Util.isObjectType(track.getMedia(), '[fm.icelink.WebRtcLocalMedia]');
                    this.setMuted(this.getLocal());
                    fm.icelink.ManagedThread.dispatch(function () {
                        var nativeMediaStream = track.getMedia()._getAudioMediaStream();
                        try {
                            if (typeof _this._audio.srcObject != 'undefined') {
                                _this._audio.srcObject = nativeMediaStream;
                            }
                            else if (typeof _this._audio.mozSrcObject != 'undefined') {
                                _this._audio.mozSrcObject = nativeMediaStream;
                            }
                            else if (typeof window.attachMediaStream != 'undefined') {
                                window.attachMediaStream(_this._audio, nativeMediaStream);
                            }
                            else {
                                URL = window.URL || window.webkitURL;
                                _this._audio.src = URL.createObjectURL(nativeMediaStream);
                            }
                        }
                        catch (error) {
                            fm.icelink.Log.error('Could not attach ' + (_this.getLocal() ? 'local' : 'remote') + ' media stream to audio element.', error);
                        }
                        if (navigator.mozGetUserMedia) {
                            _this.playAudio();
                        }
                    });
                    return true;
                };
                WebRtcDomAudioSink.prototype.playAudio = function () {
                    var _this = this;
                    var playPromise = this.getAudio().play();
                    if (playPromise !== undefined) {
                        playPromise.then(function () {
                            fm.icelink.Log.debug("Audio playback started.");
                        })
                            .catch(function () {
                            setTimeout(function () {
                                _this.getAudio().play().catch(function (error) {
                                    fm.icelink.Log.error('Audio playback failed to start.', error);
                                });
                            }, 100);
                        });
                    }
                };
                return WebRtcDomAudioSink;
            }(fm.icelink.Dynamic));
            icelink.WebRtcDomAudioSink = WebRtcDomAudioSink;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcDomVideoSink =  (function (_super) {
                __extends(WebRtcDomVideoSink, _super);
                function WebRtcDomVideoSink(external, track) {
                    var _this = _super.call(this) || this;
                    _this._external = external;
                    _this._container = document.createElement('div');
                    _this._container.style.position = 'relative';
                    _this._container.style.overflow = 'hidden';
                    _this._container.className = 'fm-video';
                    _this._video = document.createElement('video');
                    _this._video.style.position = 'absolute';
                    _this._video.setAttribute('autoplay', 'autoplay');
                    _this._video.setAttribute('playsinline', 'playsinline');
                    _this._video.setAttribute('webkit-playsinline', 'webkit-playsinline');
                    _this._video.muted = true;
                    _this._video.addEventListener('resize', function (event) {
                        var track = _this.getTrack();
                        if (track) {
                            if (_this._local) {
                                for (var _i = 0, _a = track.getOutputs(); _i < _a.length; _i++) {
                                    var videoStream = _a[_i];
                                    videoStream.setMaxWidthAndHeight(_this._video.videoWidth, _this._video.videoHeight);
                                }
                            }
                            else {
                                for (var _b = 0, _c = track.getInputs(); _b < _c.length; _b++) {
                                    var videoStream = _c[_b];
                                    videoStream.setMaxWidthAndHeight(_this._video.videoWidth, _this._video.videoHeight);
                                }
                            }
                        }
                    });
                    if (!fm.icelink.WebRtcDomVideoSink._observer) {
                        fm.icelink.WebRtcDomVideoSink._observer = new MutationObserver(function (mutationList) {
                            mutationList.forEach(function (mutation) {
                                if (mutation.type == 'childList') {
                                    mutation.addedNodes.forEach(function (node) {
                                        for (var i = 0; i < fm.icelink.WebRtcDomVideoSink._videoSinks.length; i++) {
                                            var sink = fm.icelink.WebRtcDomVideoSink._videoSinks[i];
                                            if (node.contains(sink.getVideo())) {
                                                sink.playVideo();
                                            }
                                        }
                                    });
                                }
                            });
                        });
                        fm.icelink.WebRtcDomVideoSink._observer.observe(document.body, { childList: true, subtree: true });
                    }
                    fm.icelink.WebRtcDomVideoSink._videoSinks.push(_this);
                    _this._container.appendChild(_this._video);
                    _this.setTrack(track);
                    return _this;
                }
                WebRtcDomVideoSink.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcDomVideoSink]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcDomVideoSink.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcDomVideoSink.prototype.getTrack = function () {
                    return this._track;
                };
                WebRtcDomVideoSink.prototype.getLocal = function () {
                    return this._local;
                };
                WebRtcDomVideoSink.prototype.getView = function () {
                    return this._container;
                };
                WebRtcDomVideoSink.prototype.getViewScale = function () {
                    return this._viewScale;
                };
                WebRtcDomVideoSink.prototype.setViewScale = function (viewScale) {
                    this.applyScale(viewScale);
                    this._viewScale = viewScale;
                };
                WebRtcDomVideoSink.prototype.getViewMirror = function () {
                    return this._viewMirror;
                };
                WebRtcDomVideoSink.prototype.setViewMirror = function (viewMirror) {
                    if (viewMirror) {
                        this._container.style.transform = 'scale(-1,1)';
                    }
                    else {
                        this._container.style.transform = '';
                    }
                    this._viewMirror = viewMirror;
                };
                WebRtcDomVideoSink.prototype.getVideo = function () {
                    return this._video;
                };
                WebRtcDomVideoSink.prototype.getVideoWidth = function () {
                    if (this._video) {
                        return this._video.videoWidth;
                    }
                    return 0;
                };
                WebRtcDomVideoSink.prototype.getVideoHeight = function () {
                    if (this._video) {
                        return this._video.videoHeight;
                    }
                    return 0;
                };
                WebRtcDomVideoSink.prototype.getVolume = function () {
                    return this._video.volume;
                };
                WebRtcDomVideoSink.prototype.setVolume = function (volume) {
                    this._video.volume = volume;
                };
                WebRtcDomVideoSink.prototype.getMuted = function () {
                    return this._video.muted;
                };
                WebRtcDomVideoSink.prototype.setMuted = function (muted) {
                    this._video.muted = muted;
                };
                WebRtcDomVideoSink.prototype.destroy = function () {
                    var sinkCount = fm.icelink.WebRtcDomVideoSink._videoSinks.length;
                    if (sinkCount > 0) {
                        while (sinkCount--) {
                            if (fm.icelink.WebRtcDomVideoSink._videoSinks[sinkCount] == this) {
                                fm.icelink.WebRtcDomVideoSink._videoSinks.splice(sinkCount, 1);
                                break;
                            }
                        }
                        if (fm.icelink.WebRtcDomVideoSink._videoSinks.length === 0 && WebRtcDomVideoSink._observer) {
                            fm.icelink.WebRtcDomVideoSink._observer.disconnect();
                            fm.icelink.WebRtcDomVideoSink._observer = null;
                        }
                    }
                };
                WebRtcDomVideoSink.prototype.setTrack = function (track) {
                    var _this = this;
                    if (!track) {
                        return false;
                    }
                    this._track = track;
                    this._local = fm.icelink.Util.isObjectType(this._track.getMedia(), '[fm.icelink.WebRtcLocalMedia]');
                    if (this._local) {
                        this._container.className = 'fm-video fm-video-local';
                    }
                    else {
                        this._container.className = 'fm-video fm-video-remote';
                    }
                    if (this.getLocal()) {
                        var localMedia = this.getTrack().getMedia();
                        var videoConstraints = localMedia.getVideoConstraints();
                        if (localMedia.getScreen()) {
                            this.setViewMirror(false);
                        }
                        else if (videoConstraints) {
                            var facingMode = videoConstraints.facingMode;
                            if (facingMode && facingMode.exact) {
                                facingMode = facingMode.exact;
                            }
                            else if (facingMode && facingMode.ideal) {
                                facingMode = facingMode.ideal;
                            }
                            this.setViewMirror(facingMode == 'user');
                        }
                        else {
                            this.setViewMirror(true);
                        }
                    }
                    else {
                        this.setViewMirror(false);
                    }
                    fm.icelink.ManagedThread.dispatch(function () {
                        var nativeMediaStream = _this.getTrack().getMedia()._getVideoMediaStream();
                        try {
                            _this._video.audioVolume = 0;
                            _this._video.muted = true;
                        }
                        catch (error) {
                            fm.icelink.Log.error('Could not set ' + (_this.getLocal() ? 'local' : 'remote') + ' video element audio volume.', error);
                        }
                        try {
                            if (typeof _this._video.srcObject !== 'undefined') {
                                _this._video.srcObject = nativeMediaStream;
                            }
                            else if (typeof _this._video.mozSrcObject !== 'undefined') {
                                _this._video.mozSrcObject = nativeMediaStream;
                            }
                            else if (typeof window.attachMediaStream !== 'undefined') {
                                var detached = _this._container.parentNode == null;
                                if (detached) {
                                    document.body.appendChild(_this._container);
                                }
                                window.attachMediaStream(_this._video, nativeMediaStream);
                                _this._video = _this._container.firstChild;
                                if (detached) {
                                    document.body.removeChild(_this._container);
                                }
                            }
                            else {
                                URL = window.URL || window.webkitURL;
                                _this._video.src = URL.createObjectURL(nativeMediaStream);
                            }
                        }
                        catch (error) {
                            fm.icelink.Log.error('Could not attach ' + (_this.getLocal() ? 'local' : 'remote') + ' media stream to video element.', error);
                        }
                        _this.playVideo();
                        _this.setViewScale(_this.getViewScale() || fm.icelink.LayoutScale.Contain);
                    });
                    return true;
                };
                WebRtcDomVideoSink.prototype.playVideo = function () {
                    var _this = this;
                    var playPromise = this.getVideo().play();
                    if (playPromise !== undefined) {
                        playPromise.then(function () {
                            fm.icelink.Log.debug("Video playback started.");
                        })
                            .catch(function () {
                            setTimeout(function () {
                                try {
                                    _this.getVideo().play().catch(function (error) {
                                        fm.icelink.Log.error('Video playback failed to start.', error);
                                    });
                                }
                                catch (error) {
                                    fm.icelink.Log.error('Video playback failed to start.', error);
                                }
                            }, 100);
                        });
                    }
                };
                WebRtcDomVideoSink.prototype.applyScale = function (scale) {
                    var _this = this;
                    if (this._video.style.hasOwnProperty('objectFit')) {
                        this._video.style.width = '100%';
                        this._video.style.height = '100%';
                        switch (scale) {
                            case fm.icelink.LayoutScale.Contain: {
                                this._video.style.objectFit = 'contain';
                                break;
                            }
                            case fm.icelink.LayoutScale.Cover: {
                                this._video.style.objectFit = 'cover';
                                break;
                            }
                            case fm.icelink.LayoutScale.Stretch: {
                                this._video.style.objectFit = 'fill';
                                break;
                            }
                        }
                    }
                    else {
                        switch (scale) {
                            case fm.icelink.LayoutScale.Contain: {
                                this._video.style.width = '100%';
                                this._video.style.height = '100%';
                                break;
                            }
                            case fm.icelink.LayoutScale.Cover: {
                                this._container.style.display = 'inline-block';
                                this._video.style.left = '-100%';
                                this._video.style.right = '-100%';
                                this._video.style.top = '-100%';
                                this._video.style.bottom = '-100%';
                                this._video.style.margin = 'auto';
                                this._video.style.maxWidth = 'none';
                                this._video.style.maxHeight = 'none';
                                var rescale_1 = function () {
                                    var containerWidth = _this._container.clientWidth;
                                    var containerHeight = _this._container.clientHeight;
                                    var videoWidth = _this._video.clientWidth;
                                    var videoHeight = _this._video.clientHeight;
                                    if (!videoHeight || videoWidth / videoHeight > containerWidth / containerHeight) {
                                        _this._video.style.width = 'auto';
                                        _this._video.style.height = '100%';
                                        _this._video.style.maxWidth = 'none';
                                    }
                                    else {
                                        _this._video.style.width = '100%';
                                        _this._video.style.height = 'auto';
                                        _this._video.style.maxWidth = 'none';
                                    }
                                };
                                fm.icelink.Util.observe(this._video, 'loadeddata', function () {
                                    rescale_1();
                                });
                                fm.icelink.Util.observeAttr(this._container, function (attrName) {
                                    if (attrName == 'width' || attrName == 'height' || attrName == 'style') {
                                        rescale_1();
                                    }
                                });
                                rescale_1();
                                break;
                            }
                            case fm.icelink.LayoutScale.Stretch: {
                                this._video.style.transformOrigin = '0px 0px';
                                var lastContainerWidth_1 = 0;
                                var lastContainerHeight_1 = 0;
                                var lastVideoWidth_1 = 0;
                                var lastVideoHeight_1 = 0;
                                var rescale_2 = function () {
                                    var containerWidth = _this._container.clientWidth;
                                    var containerHeight = _this._container.clientHeight;
                                    var videoWidth = _this._video.clientWidth;
                                    var videoHeight = _this._video.clientHeight;
                                    if (containerWidth != lastContainerWidth_1 || containerHeight != lastContainerHeight_1 || videoWidth != lastVideoWidth_1 || videoHeight != lastVideoHeight_1) {
                                        if (videoWidth && videoHeight) {
                                            _this._video.style.transform = 'scale(' + (containerWidth / videoWidth) + ', ' + (containerHeight / videoHeight) + ')';
                                            lastContainerWidth_1 = containerWidth;
                                            lastContainerHeight_1 = containerHeight;
                                            lastVideoWidth_1 = videoWidth;
                                            lastVideoHeight_1 = videoHeight;
                                        }
                                    }
                                };
                                fm.icelink.Util.observe(this._video, 'loadeddata', function () {
                                    rescale_2();
                                });
                                fm.icelink.Util.observeAttr(this._container, function (attrName) {
                                    if (attrName == 'width' || attrName == 'height' || attrName == 'style') {
                                        rescale_2();
                                    }
                                });
                                rescale_2();
                                break;
                            }
                        }
                    }
                };
                WebRtcDomVideoSink._videoSinks = [];
                return WebRtcDomVideoSink;
            }(fm.icelink.Dynamic));
            icelink.WebRtcDomVideoSink = WebRtcDomVideoSink;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcGetUserMediaResult =  (function () {
                function WebRtcGetUserMediaResult() {
                }
                return WebRtcGetUserMediaResult;
            }());
            var WebRtcLocalMedia =  (function (_super) {
                __extends(WebRtcLocalMedia, _super);
                function WebRtcLocalMedia(external, audio, video, screen) {
                    var _this = _super.call(this, external) || this;
                    _this._onAudioStartedValues = [];
                    _this._onAudioStoppedValues = [];
                    _this._onVideoStartedValues = [];
                    _this._onVideoStoppedValues = [];
                    _this._audioStreams = [];
                    _this._videoStreams = [];
                    _this._audioEncodings = [];
                    _this._videoEncodings = [];
                    _this._external = external;
                    _this._audio = audio;
                    _this._video = video;
                    _this._screen = fm.icelink.Util.isNullOrUndefined(screen) ? false : screen;
                    if (!audio) {
                        _this._audioTrack._setMediaStreamTrack(null);
                    }
                    if (!video) {
                        _this._videoTrack._setMediaStreamTrack(null);
                    }
                    _this._audioTrack.addOnStarted(function () {
                        for (var _i = 0, _a = _this._onAudioStartedValues; _i < _a.length; _i++) {
                            var value = _a[_i];
                            value();
                        }
                    });
                    _this._audioTrack.addOnStopped(function () {
                        for (var _i = 0, _a = _this._onAudioStoppedValues; _i < _a.length; _i++) {
                            var value = _a[_i];
                            value();
                        }
                    });
                    _this._videoTrack.addOnStarted(function () {
                        for (var _i = 0, _a = _this._onVideoStartedValues; _i < _a.length; _i++) {
                            var value = _a[_i];
                            value();
                        }
                    });
                    _this._videoTrack.addOnStopped(function () {
                        for (var _i = 0, _a = _this._onVideoStoppedValues; _i < _a.length; _i++) {
                            var value = _a[_i];
                            value();
                        }
                    });
                    return _this;
                }
                WebRtcLocalMedia.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcLocalMedia]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcLocalMedia.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcLocalMedia.getChromeExtensionId = function () {
                    return this._chromeExtensionId;
                };
                WebRtcLocalMedia.setChromeExtensionId = function (chromeExtensionId) {
                    this._chromeExtensionId = chromeExtensionId;
                    this._chromeExtensionUrl = 'https://chrome.google.com/webstore/detail/' + chromeExtensionId;
                    var head = document.getElementsByTagName('head')[0];
                    var linkExists = false;
                    for (var i = 0; i < head.childNodes.length; i++) {
                        var child = head.childNodes[i];
                        if (child.tagName == 'LINK' && child.href == this._chromeExtensionUrl) {
                            linkExists = true;
                        }
                        break;
                    }
                    if (!linkExists) {
                        var link = document.createElement('link');
                        link.rel = 'chrome-webstore-item';
                        link.href = this._chromeExtensionUrl;
                        head.appendChild(link);
                    }
                };
                WebRtcLocalMedia.getChromeExtensionUrl = function () {
                    return this._chromeExtensionUrl;
                };
                WebRtcLocalMedia.getChromeExtensionInstalled = function () {
                    return this._chromeExtensionInstalled;
                };
                WebRtcLocalMedia.getChromeExtensionRequiresUserGesture = function () {
                    return this._chromeExtensionRequiresUserGesture;
                };
                WebRtcLocalMedia.setChromeExtensionRequiresUserGesture = function (chromeExtensionRequiresUserGesture) {
                    this._chromeExtensionRequiresUserGesture = chromeExtensionRequiresUserGesture;
                };
                WebRtcLocalMedia.getChromeExtensionRequired = function () {
                    if (window.navigator) {
                        return navigator.webkitGetUserMedia && (this._chromeExtensionId != null || (!navigator.getDisplayMedia && !navigator.mediaDevices.getDisplayMedia));
                    }
                    else {
                        return false;
                    }
                };
                WebRtcLocalMedia.prototype.addOnAudioStarted = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onAudioStartedValues, value);
                };
                WebRtcLocalMedia.prototype.addOnAudioStopped = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onAudioStoppedValues, value);
                };
                WebRtcLocalMedia.prototype.addOnVideoStarted = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onVideoStartedValues, value);
                };
                WebRtcLocalMedia.prototype.addOnVideoStopped = function (value) {
                    fm.icelink.ArrayExtensions.add(this._onVideoStoppedValues, value);
                };
                WebRtcLocalMedia.prototype.removeOnAudioStarted = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onAudioStartedValues, value);
                };
                WebRtcLocalMedia.prototype.removeOnAudioStopped = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onAudioStoppedValues, value);
                };
                WebRtcLocalMedia.prototype.removeOnVideoStarted = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onVideoStartedValues, value);
                };
                WebRtcLocalMedia.prototype.removeOnVideoStopped = function (value) {
                    fm.icelink.ArrayExtensions.remove(this._onVideoStoppedValues, value);
                };
                WebRtcLocalMedia.prototype.getAudioSourceInputs = function () {
                    return this.getSourceInputs('audio');
                };
                WebRtcLocalMedia.prototype.getVideoSourceInputs = function () {
                    return this.getSourceInputs('video');
                };
                WebRtcLocalMedia.prototype.getSourceInputs = function (kind) {
                    var promise = new fm.icelink.Promise();
                    if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
                        try {
                            navigator.mediaDevices.enumerateDevices().then(function (mediaDeviceInfos) {
                                var inputs = [];
                                var index = -1;
                                for (var _i = 0, mediaDeviceInfos_1 = mediaDeviceInfos; _i < mediaDeviceInfos_1.length; _i++) {
                                    var mediaDeviceInfo = mediaDeviceInfos_1[_i];
                                    if (mediaDeviceInfo.kind == kind || mediaDeviceInfo.kind == kind + 'input') {
                                        index++;
                                        var id = mediaDeviceInfo.deviceId;
                                        if (!id) {
                                            id = 'audio-' + index;
                                        }
                                        var name_35 = mediaDeviceInfo.label;
                                        if (!name_35) {
                                            name_35 = id;
                                        }
                                        inputs.push(new fm.icelink.SourceInput(id, name_35));
                                    }
                                }
                                promise.resolve(inputs);
                            }).catch(function (ex) {
                                promise.reject(ex);
                            });
                        }
                        catch (error) {
                            promise.reject(error);
                        }
                    }
                    else if (MediaStreamTrack && MediaStreamTrack.getSources) {
                        try {
                            MediaStreamTrack.getSources(function (sources) {
                                var inputs = [];
                                var index = -1;
                                for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
                                    var source = sources_1[_i];
                                    if (source.kind == kind || source.kind == kind + 'input') {
                                        index++;
                                        var id = source.deviceId;
                                        if (!id) {
                                            id = 'audio-' + index;
                                        }
                                        var name_36 = source.label;
                                        if (!name_36) {
                                            name_36 = id;
                                        }
                                        inputs.push(new fm.icelink.SourceInput(id, name_36));
                                    }
                                }
                                promise.resolve(inputs);
                            });
                        }
                        catch (error) {
                            promise.reject(error);
                        }
                    }
                    else {
                        promise.reject(new fm.icelink.Exception('Browser does not support media device enumeration.'));
                    }
                    return promise;
                };
                WebRtcLocalMedia.prototype.getAudioSourceInput = function () {
                    return this._audioSourceInput;
                };
                WebRtcLocalMedia.prototype.setAudioSourceInput = function (audioInput) {
                    if (this.getState() == fm.icelink.LocalMediaState.Started) {
                        throw new fm.icelink.Exception("Cannot set audio source input while the local media is started. Use 'changeAudioSourceInput' instead or stop the local media first.");
                    }
                    this._audioSourceInput = audioInput;
                };
                WebRtcLocalMedia.prototype.getVideoSourceInput = function () {
                    return this._videoSourceInput;
                };
                WebRtcLocalMedia.prototype.setVideoSourceInput = function (videoInput) {
                    if (this.getState() == fm.icelink.LocalMediaState.Started) {
                        throw new fm.icelink.Exception("Cannot set video source input while the local media is started. Use 'changeVideoSourceInput' instead or stop the local media first.");
                    }
                    this._videoSourceInput = videoInput;
                };
                WebRtcLocalMedia.prototype.getScreen = function () {
                    return this._screen;
                };
                WebRtcLocalMedia.prototype.setScreen = function (screen) {
                    this._screen = screen;
                };
                WebRtcLocalMedia.prototype.getAudioConstraints = function () {
                    return this._audioConstraints;
                };
                WebRtcLocalMedia.prototype.getVideoConstraints = function () {
                    return this._videoConstraints;
                };
                WebRtcLocalMedia.prototype.changeAudioConstraints = function (audioConstraints) {
                    var promise = new fm.icelink.Promise();
                    try {
                        var audioTrack = this.getAudioTrack();
                        if (audioTrack == null) {
                            throw new fm.icelink.Exception('No audio track.');
                        }
                        var nativeAudioTrack = this.getAudioTrack()._getMediaStreamTrack();
                        if (nativeAudioTrack == null) {
                            throw new fm.icelink.Exception('No active audio track.');
                        }
                        if (typeof nativeAudioTrack.applyConstraints !== 'undefined') {
                            nativeAudioTrack.applyConstraints(audioConstraints).then(function () {
                                promise.resolve(null);
                            }, function (ex) {
                                promise.reject(ex);
                            });
                        }
                        else {
                            throw new fm.icelink.Exception('Browser does not support changing audio constraints.');
                        }
                    }
                    catch (ex) {
                        promise.reject(ex);
                    }
                    return promise;
                };
                WebRtcLocalMedia.prototype.changeVideoConstraints = function (videoConstraints) {
                    var promise = new fm.icelink.Promise();
                    try {
                        var videoTrack = this.getVideoTrack();
                        if (videoTrack == null) {
                            throw new fm.icelink.Exception('No video track.');
                        }
                        var nativeVideoTrack = this.getVideoTrack()._getMediaStreamTrack();
                        if (nativeVideoTrack == null) {
                            throw new fm.icelink.Exception('No active video track.');
                        }
                        if (typeof nativeVideoTrack.applyConstraints !== 'undefined') {
                            nativeVideoTrack.applyConstraints(videoConstraints).then(function () {
                                promise.resolve(null);
                            }, function (ex) {
                                promise.reject(ex);
                            });
                        }
                        else {
                            throw new fm.icelink.Exception('Browser does not support changing video constraints.');
                        }
                    }
                    catch (ex) {
                        promise.reject(ex);
                    }
                    return promise;
                };
                WebRtcLocalMedia.prototype.changeAudioSourceInput = function (audioSourceInput) {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    if (audioSourceInput == this.getAudioSourceInput()) {
                        fm.icelink.ManagedThread.dispatch(function () {
                            promise.resolve(null);
                        });
                    }
                    else if (this.getState() == fm.icelink.LocalMediaState.Started) {
                        if (fm.icelink.Plugin.hasRtcRtpSender() && RTCRtpSender.prototype.replaceTrack) {
                            this.doStopAudio();
                            this._audioSourceInput = audioSourceInput;
                            this.doGetUserMedia(this.getAudio(), null).then(function (result) {
                                _this._audioConstraints = result.audioConstraints;
                                _this._setAudioMediaStream(result.audioMediaStream);
                                promise.resolve(null);
                            }, function (ex) {
                                promise.reject(ex);
                            });
                        }
                        else if (fm.icelink.Plugin.hasRtcRtpSender()) {
                            this.doStopAudio();
                            this._audioSourceInput = audioSourceInput;
                            this.doGetUserMedia(this.getAudio(), null).then(function (result) {
                                _this._audioConstraints = result.audioConstraints;
                                _this._setAudioMediaStream(result.audioMediaStream);
                                promise.resolve(null);
                            }, function (ex) {
                                promise.reject(ex);
                            });
                        }
                    }
                    else {
                        fm.icelink.ManagedThread.dispatch(function () {
                            _this.setAudioSourceInput(audioSourceInput);
                            promise.resolve(null);
                        });
                    }
                    return promise;
                };
                WebRtcLocalMedia.prototype.changeVideoSourceInput = function (videoSourceInput) {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    if (videoSourceInput == this.getVideoSourceInput()) {
                        fm.icelink.ManagedThread.dispatch(function () {
                            promise.resolve(null);
                        });
                    }
                    else if (this.getState() == fm.icelink.LocalMediaState.Started) {
                        if (fm.icelink.Plugin.hasRtcRtpSender() && RTCRtpSender.prototype.replaceTrack) {
                            this.doStopVideo();
                            this._videoSourceInput = videoSourceInput;
                            this.doGetUserMedia(null, this.getVideo()).then(function (result) {
                                _this._videoConstraints = result.videoConstraints;
                                _this._setVideoMediaStream(result.videoMediaStream);
                                promise.resolve(null);
                            }, function (ex) {
                                promise.reject(ex);
                            });
                        }
                        else if (fm.icelink.Plugin.hasRtcRtpSender()) {
                            this.doStopVideo();
                            this._videoSourceInput = videoSourceInput;
                            this.doGetUserMedia(null, this.getVideo()).then(function (result) {
                                _this._videoConstraints = result.videoConstraints;
                                _this._setVideoMediaStream(result.videoMediaStream);
                                promise.resolve(null);
                            }, function (ex) {
                                promise.reject(ex);
                            });
                        }
                    }
                    else {
                        fm.icelink.ManagedThread.dispatch(function () {
                            _this.setVideoSourceInput(videoSourceInput);
                            promise.resolve(null);
                        });
                    }
                    return promise;
                };
                WebRtcLocalMedia.prototype.doStart = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    fm.icelink.ManagedThread.dispatch(function () {
                        if (_this._screen && fm.icelink.WebRtcLocalMedia.getChromeExtensionRequired()) {
                            if (!fm.icelink.WebRtcLocalMedia.getChromeExtensionInstalled()) {
                                var chrome = window.chrome;
                                if (chrome && chrome.webstore && chrome.webstore.install) {
                                    try {
                                        chrome.webstore.install(fm.icelink.WebRtcLocalMedia.getChromeExtensionUrl(), function () {
                                            location.reload();
                                        }, function (error) {
                                            fm.icelink.WebRtcLocalMedia.setChromeExtensionRequiresUserGesture(false);
                                            promise.reject(new fm.icelink.Exception('Chrome extension is not installed and inline installation failed. ' + error));
                                        });
                                    }
                                    catch (error) {
                                        fm.icelink.WebRtcLocalMedia.setChromeExtensionRequiresUserGesture(true);
                                        promise.reject(new fm.icelink.Exception('Chrome extension is not installed and inline installation could not be started. ' + error));
                                    }
                                }
                                else {
                                    fm.icelink.WebRtcLocalMedia.setChromeExtensionRequiresUserGesture(false);
                                    promise.reject(new fm.icelink.Exception('Chrome extension is not installed.'));
                                }
                            }
                            else {
                                _this._chromeScreenEventListener = function (event) {
                                    if (event.origin == window.location.origin) {
                                        var message = event.data;
                                        if (message.namespace && message.namespace == 'fm.icelink.chrome') {
                                            if (message.type == 'chooseDesktopMediaSuccess') {
                                                _this._chromeScreenStreamId = message.streamId;
                                                _this.doStartInternal(promise);
                                            }
                                            else if (message.type == 'chooseDesktopMediaFailure') {
                                                if (_this._chromeScreenEventListener) {
                                                    window.removeEventListener('message', _this._chromeScreenEventListener);
                                                    _this._chromeScreenEventListener = null;
                                                }
                                                if (message.audioUnavailable) {
                                                    promise.reject(new fm.icelink.Exception('Chrome 50+ is required to allow audio with screen-sharing. Please update your browser and try again.'));
                                                }
                                                else {
                                                    promise.reject(new fm.icelink.Exception('Request for screen sharing access was denied.'));
                                                }
                                            }
                                        }
                                    }
                                };
                                window.addEventListener('message', _this._chromeScreenEventListener);
                                window.postMessage({
                                    namespace: 'fm.icelink.chrome',
                                    type: 'chooseDesktopMedia',
                                    origin: window.location.origin,
                                    audio: _this._audio ? true : false
                                }, '*');
                            }
                        }
                        else {
                            _this.doStartInternal(promise);
                        }
                    });
                    return promise;
                };
                WebRtcLocalMedia.prototype.doStartInternal = function (promise) {
                    var _this = this;
                    this.doGetUserMedia(this.getAudio(), this.getVideo()).then(function (result) {
                        _this._audioConstraints = result.audioConstraints;
                        _this._videoConstraints = result.videoConstraints;
                        _this._setMediaStreams(result.audioMediaStream, result.videoMediaStream);
                        promise.resolve(_this);
                    }, function (ex) {
                        promise.reject(ex);
                    });
                };
                WebRtcLocalMedia.prototype.doGetUserMedia = function (audio, video, deprecated) {
                    var _this = this;
                    if (arguments.length == 2) {
                        try {
                            deprecated = (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia);
                            return this.doGetUserMedia(audio, video, deprecated);
                        }
                        catch (error) {
                            return this.doGetUserMedia(audio, video, !deprecated);
                        }
                    }
                    var promise = new fm.icelink.Promise();
                    try {
                        var result_2 = new WebRtcGetUserMediaResult();
                        var audioIsMediaStream_1 = audio && (typeof audio.getAudioTracks !== 'undefined');
                        var videoIsMediaStream_1 = video && (typeof video.getVideoTracks !== 'undefined');
                        var getUserMediaSuccess_1 = function (nativeMediaStream) {
                            if (audioIsMediaStream_1) {
                                result_2.audioMediaStream = audio;
                            }
                            else {
                                result_2.audioMediaStream = nativeMediaStream;
                            }
                            if (videoIsMediaStream_1) {
                                result_2.videoMediaStream = video;
                            }
                            else {
                                result_2.videoMediaStream = nativeMediaStream;
                            }
                            if (audio) {
                                var mediaStream = result_2.audioMediaStream;
                                if (mediaStream) {
                                    var audioTracks = mediaStream.getAudioTracks();
                                    if (audioTracks && audioTracks.length > 0) {
                                        var audioTrack = audioTracks[0];
                                        if (audioTrack) {
                                            _this.lockAudioEncodings();
                                        }
                                    }
                                }
                            }
                            if (video) {
                                var mediaStream = result_2.videoMediaStream;
                                if (mediaStream) {
                                    var videoTracks = mediaStream.getVideoTracks();
                                    if (videoTracks && videoTracks.length > 0) {
                                        var videoTrack = videoTracks[0];
                                        if (videoTrack) {
                                            var sourceType = _this.getScreen() ? fm.icelink.VideoType.Screen : fm.icelink.VideoType.Camera;
                                            var sourceWidth = -1;
                                            var sourceHeight = -1;
                                            var sourceFrameRate = -1;
                                            if (videoTrack.getSettings) {
                                                var videoSettings = videoTrack.getSettings();
                                                if (videoSettings) {
                                                    if (videoSettings.width) {
                                                        sourceWidth = videoSettings.width;
                                                    }
                                                    if (videoSettings.height) {
                                                        sourceHeight = videoSettings.height;
                                                    }
                                                    if (videoSettings.frameRate) {
                                                        sourceFrameRate = videoSettings.frameRate;
                                                    }
                                                }
                                            }
                                            _this.lockVideoEncodings(sourceType, sourceWidth, sourceHeight, sourceFrameRate);
                                        }
                                    }
                                }
                            }
                            promise.resolve(result_2);
                        };
                        var getUserMediaFailure = function (error) {
                            if (_this.getScreen()) {
                                if (document.location.protocol == 'https:') {
                                    fm.icelink.Log.error('Local screen access denied.', error);
                                }
                                else {
                                    fm.icelink.Log.error('Local screen access denied. (The page may need to be loaded using HTTPS.)', error);
                                }
                            }
                            else {
                                if (document.location.protocol == 'file:') {
                                    fm.icelink.Log.error('Local media access denied. (The media source may be unavailable/locked or you may need to access this page through a webserver instead of the file system.)', error);
                                }
                                else {
                                    fm.icelink.Log.error('Local media access denied. (The media source may be unavailable/locked.)', error);
                                }
                            }
                            promise.reject(error);
                        };
                        if (audio && !audioIsMediaStream_1) {
                            result_2.audioConstraints = this.createAudioConstraints(audio, deprecated);
                        }
                        if (video && !videoIsMediaStream_1) {
                            result_2.videoConstraints = this.createVideoConstraints(video, deprecated);
                        }
                        if (result_2.audioConstraints || result_2.videoConstraints) {
                            var getUserMediaArgs = {};
                            if (result_2.audioConstraints) {
                                getUserMediaArgs.audio = result_2.audioConstraints;
                            }
                            if (result_2.videoConstraints) {
                                getUserMediaArgs.video = result_2.videoConstraints;
                            }
                            var getMedia = navigator.fmGetUserMedia;
                            var getDisplayMedia = !fm.icelink.WebRtcLocalMedia.getChromeExtensionRequired() && (navigator.getDisplayMedia || navigator.mediaDevices.getDisplayMedia);
                            if (this.getScreen() && getDisplayMedia) {
                                getMedia = function (constraints, success, failure) {
                                    var result = null;
                                    if (navigator.getDisplayMedia) {
                                        result = navigator.getDisplayMedia(constraints);
                                    }
                                    else if (navigator.mediaDevices.getDisplayMedia) {
                                        result = navigator.mediaDevices.getDisplayMedia(constraints);
                                    }
                                    else {
                                        result = navigator.mediaDevices.getUserMedia(constraints);
                                    }
                                    result.then(success).catch(failure);
                                };
                            }
                            getMedia(getUserMediaArgs, function (nativeMediaStream) {
                                _this.updateAudioSourceInput(nativeMediaStream.getAudioTracks());
                                _this.updateVideoSourceInput(nativeMediaStream.getVideoTracks());
                                if (result_2.videoConstraints) {
                                    _this.updateFacingMode(result_2.videoConstraints);
                                }
                                getUserMediaSuccess_1(nativeMediaStream);
                            }, getUserMediaFailure);
                        }
                        else {
                            getUserMediaSuccess_1(null);
                        }
                    }
                    catch (ex) {
                        promise.reject(ex);
                    }
                    return promise;
                };
                WebRtcLocalMedia.prototype.updateAudioSourceInput = function (nativeAudioTracks) {
                    if (nativeAudioTracks.length > 0) {
                        var nativeAudioTrack = nativeAudioTracks[0];
                        this._audioSourceInput;
                        if (this._audioSourceInput == null) {
                            if (typeof nativeAudioTrack.getSettings !== 'undefined') {
                                var settings = nativeAudioTrack.getSettings();
                                if (settings != null) {
                                    this._audioSourceInput = new fm.icelink.SourceInput(settings.deviceId, nativeAudioTrack.label);
                                }
                            }
                        }
                        else {
                            this._audioSourceInput.setName(nativeAudioTrack.label);
                        }
                    }
                };
                WebRtcLocalMedia.prototype.updateVideoSourceInput = function (nativeVideoTracks) {
                    if (nativeVideoTracks.length > 0) {
                        var nativeVideoTrack = nativeVideoTracks[0];
                        this._videoSourceInput;
                        if (this._videoSourceInput == null) {
                            if (typeof nativeVideoTrack.getSettings !== 'undefined') {
                                var settings = nativeVideoTrack.getSettings();
                                if (settings != null) {
                                    this._videoSourceInput = new fm.icelink.SourceInput(settings.deviceId, nativeVideoTrack.label);
                                }
                            }
                        }
                        else {
                            this._videoSourceInput.setName(nativeVideoTrack.label);
                        }
                    }
                };
                WebRtcLocalMedia.prototype.updateFacingMode = function (videoConstraints) {
                    if (!this.getScreen()) {
                        var videoSourceInput = this.getVideoSourceInput();
                        if (!videoConstraints.facingMode) {
                            videoConstraints.facingMode = 'user';
                        }
                        if (videoConstraints.deviceId && videoSourceInput != null) {
                            var name_37 = videoSourceInput.getName();
                            if (fm.icelink.StringExtensions.startsWith(name_37, 'back', fm.icelink.StringComparison.InvariantCultureIgnoreCase) ||
                                fm.icelink.StringExtensions.endsWith(name_37, 'back', fm.icelink.StringComparison.InvariantCultureIgnoreCase) ||
                                fm.icelink.StringExtensions.startsWith(name_37, 'rear', fm.icelink.StringComparison.InvariantCultureIgnoreCase) ||
                                fm.icelink.StringExtensions.endsWith(name_37, 'rear', fm.icelink.StringComparison.InvariantCultureIgnoreCase) ||
                                fm.icelink.StringExtensions.startsWith(name_37, 'environment', fm.icelink.StringComparison.InvariantCultureIgnoreCase) ||
                                fm.icelink.StringExtensions.endsWith(name_37, 'environment', fm.icelink.StringComparison.InvariantCultureIgnoreCase)) {
                                videoConstraints.facingMode = 'environment';
                            }
                        }
                    }
                };
                WebRtcLocalMedia.prototype.createAudioConstraints = function (audio, deprecated) {
                    var audioSourceInput = this.getAudioSourceInput();
                    if (deprecated) {
                        var audioConstraints_1 = {
                            optional: [],
                            mandatory: {}
                        };
                        if (this.getScreen()) {
                            if (this._chromeScreenStreamId) {
                                audioConstraints_1.mandatory.chromeMediaSource = 'desktop';
                                audioConstraints_1.mandatory.chromeMediaSourceId = this._chromeScreenStreamId;
                            }
                        }
                        if (audioSourceInput) {
                            audioConstraints_1.optional.push({ sourceId: audioSourceInput.getId() });
                        }
                        if (fm.icelink.Util.isPlainObject(audio)) {
                            if (audio.mandatory) {
                                for (var key in audio.mandatory) {
                                    audioConstraints_1.mandatory[key] = audio.mandatory[key];
                                }
                            }
                            if (audio.optional) {
                                for (var _i = 0, _a = audio.optional; _i < _a.length; _i++) {
                                    var value = _a[_i];
                                    audioConstraints_1.optional.push(value);
                                }
                            }
                        }
                        return audioConstraints_1;
                    }
                    var audioConstraints = {
                        echoCancellation: true
                    };
                    if (this.getScreen()) {
                        if (this._chromeScreenStreamId) {
                            audioConstraints.chromeMediaSource = 'desktop';
                            audioConstraints.chromeMediaSourceId = this._chromeScreenStreamId;
                        }
                    }
                    if (audioSourceInput) {
                        audioConstraints.deviceId = { exact: audioSourceInput.getId() };
                    }
                    if (fm.icelink.Util.isPlainObject(audio)) {
                        for (var key in audio) {
                            if (key !== 'mandatory' && key !== 'optional') {
                                audioConstraints[key] = audio[key];
                            }
                        }
                    }
                    return audioConstraints;
                };
                WebRtcLocalMedia.prototype.createVideoConstraints = function (video, deprecated) {
                    var videoSourceInput = this.getVideoSourceInput();
                    if (deprecated) {
                        var videoConstraints_1 = {
                            optional: [],
                            mandatory: {}
                        };
                        if (video.getTypeString) {
                            var videoConfig = video;
                            videoConstraints_1.mandatory.maxWidth = videoConfig.getWidth();
                            videoConstraints_1.mandatory.maxHeight = videoConfig.getHeight();
                            videoConstraints_1.mandatory.maxFrameRate = videoConfig.getFrameRate();
                        }
                        if (this.getScreen()) {
                            if (this._chromeScreenStreamId) {
                                videoConstraints_1.mandatory.chromeMediaSource = 'desktop';
                                videoConstraints_1.mandatory.chromeMediaSourceId = this._chromeScreenStreamId;
                            }
                            else {
                                videoConstraints_1.mandatory.mediaSource = 'screen';
                            }
                        }
                        else if (videoSourceInput) {
                            videoConstraints_1.optional.push({ sourceId: videoSourceInput.getId() });
                        }
                        if (fm.icelink.Util.isPlainObject(video)) {
                            if (video.mandatory) {
                                for (var key in video.mandatory) {
                                    videoConstraints_1.mandatory[key] = video.mandatory[key];
                                }
                            }
                            if (video.optional) {
                                for (var _i = 0, _a = video.optional; _i < _a.length; _i++) {
                                    var value = _a[_i];
                                    videoConstraints_1.optional.push(value);
                                }
                            }
                        }
                        return videoConstraints_1;
                    }
                    var videoConstraints = {};
                    if (video.getTypeString) {
                        var videoConfig = video;
                        videoConstraints.width = videoConfig.getWidth();
                        videoConstraints.height = videoConfig.getHeight();
                        videoConstraints.frameRate = videoConfig.getFrameRate();
                    }
                    if (this.getScreen()) {
                        if (this._chromeScreenStreamId) {
                            videoConstraints.chromeMediaSource = 'desktop';
                            videoConstraints.chromeMediaSourceId = this._chromeScreenStreamId;
                        }
                        else {
                            videoConstraints.mediaSource = 'screen';
                        }
                    }
                    else if (videoSourceInput) {
                        videoConstraints.deviceId = { exact: videoSourceInput.getId() };
                    }
                    if (fm.icelink.Util.isPlainObject(video)) {
                        for (var key in video) {
                            if (key !== 'mandatory' && key !== 'optional') {
                                videoConstraints[key] = video[key];
                            }
                        }
                    }
                    if (fm.icelink.Util.isMobile()) {
                        this.updateFacingMode(videoConstraints);
                    }
                    return videoConstraints;
                };
                WebRtcLocalMedia.prototype.doStop = function () {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    fm.icelink.ManagedThread.dispatch(function () {
                        try {
                            if (_this._chromeScreenEventListener) {
                                window.removeEventListener('message', _this._chromeScreenEventListener);
                                _this._chromeScreenEventListener = null;
                            }
                            if (_this._chromeScreenStreamId) {
                                window.postMessage({
                                    namespace: 'fm.icelink.chrome',
                                    type: 'cancelChooseDesktopMedia'
                                }, '*');
                            }
                            _this.doStopAudio();
                            _this.doStopVideo();
                            promise.resolve(_this);
                        }
                        catch (error) {
                            promise.reject(error);
                        }
                    });
                    return promise;
                };
                WebRtcLocalMedia.prototype.doStopAudio = function () {
                    try {
                        for (var _i = 0, _a = this.getAudioTracks(); _i < _a.length; _i++) {
                            var audioTrack = _a[_i];
                            audioTrack.stop();
                        }
                    }
                    catch (error) {
                        try {
                            var audioMediaStream = this._getAudioMediaStream();
                            if (audioMediaStream) {
                                audioMediaStream.stop();
                            }
                        }
                        catch (error) { }
                    }
                    this.destroyAudioContext();
                };
                WebRtcLocalMedia.prototype.doStopVideo = function () {
                    try {
                        for (var _i = 0, _a = this.getVideoTracks(); _i < _a.length; _i++) {
                            var videoTrack = _a[_i];
                            videoTrack.stop();
                        }
                    }
                    catch (error) {
                        try {
                            var videoMediaStream = this._getVideoMediaStream();
                            if (videoMediaStream) {
                                videoMediaStream.stop();
                            }
                        }
                        catch (error) { }
                    }
                };
                WebRtcLocalMedia.prototype.doGetAudioEncodings = function () {
                    return this._audioEncodings;
                };
                WebRtcLocalMedia.prototype.doSetAudioEncodings = function (encodings) {
                    this._audioEncodings = encodings;
                    for (var _i = 0, _a = this._audioStreams; _i < _a.length; _i++) {
                        var audioStream = _a[_i];
                        audioStream.setSendEncodings(encodings);
                    }
                };
                WebRtcLocalMedia.prototype.doGetVideoEncodings = function () {
                    return this._videoEncodings;
                };
                WebRtcLocalMedia.prototype.doSetVideoEncodings = function (encodings) {
                    this._videoEncodings = encodings;
                    for (var _i = 0, _a = this._videoStreams; _i < _a.length; _i++) {
                        var videoStream = _a[_i];
                        videoStream.setSendEncodings(encodings);
                    }
                };
                WebRtcLocalMedia.prototype.addAudioStream = function (value) {
                    if (value) {
                        value.setSendEncodings(this._audioEncodings);
                        fm.icelink.ArrayExtensions.add(this._audioStreams, value);
                    }
                };
                WebRtcLocalMedia.prototype.removeAudioStream = function (value) {
                    if (value && fm.icelink.ArrayExtensions.remove(this._audioStreams, value)) {
                        value.setSendEncodings(null);
                        return true;
                    }
                    return false;
                };
                WebRtcLocalMedia.prototype.addVideoStream = function (value) {
                    if (value) {
                        value.setSendEncodings(this._videoEncodings);
                        fm.icelink.ArrayExtensions.add(this._videoStreams, value);
                    }
                };
                WebRtcLocalMedia.prototype.removeVideoStream = function (value) {
                    if (value && fm.icelink.ArrayExtensions.remove(this._videoStreams, value)) {
                        value.setSendEncodings(null);
                        return true;
                    }
                    return false;
                };
                WebRtcLocalMedia.webRtcLocalMediaInitialize = function () {
                    var _this = this;
                    if (!this.__webRtcLocalMediaInitialized) {
                        if (window.navigator) {
                            navigator.fmGetUserMedia = navigator.getUserMedia ||
                                navigator.webkitGetUserMedia ||
                                navigator.mozGetUserMedia ||
                                navigator.msGetUserMedia;
                            if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
                                navigator.fmGetUserMedia = function (constraints, success, failure) {
                                    navigator.mediaDevices.getUserMedia(constraints).then(success).catch(failure);
                                };
                            }
                        }
                        if (window.navigator && navigator.webkitGetUserMedia) {
                            window.addEventListener('message', function (event) {
                                if (event.origin == window.location.origin) {
                                    var message = event.data;
                                    if (message.namespace && message.namespace == 'fm.icelink.chrome' && message.type == 'active') {
                                        _this._chromeExtensionInstalled = true;
                                    }
                                }
                            });
                            window.postMessage({
                                namespace: 'fm.icelink.chrome',
                                type: 'testActive'
                            }, '*');
                        }
                    }
                    fm.icelink.WebRtcLocalMedia.__webRtcLocalMediaInitialized = true;
                };
                WebRtcLocalMedia.__webRtcLocalMediaInitialized = false;
                return WebRtcLocalMedia;
            }(fm.icelink.WebRtcLocalMediaBase));
            icelink.WebRtcLocalMedia = WebRtcLocalMedia;
            fm.icelink.WebRtcLocalMedia.webRtcLocalMediaInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcRemoteMedia =  (function (_super) {
                __extends(WebRtcRemoteMedia, _super);
                function WebRtcRemoteMedia(external, audio, video) {
                    var _this = _super.call(this, external) || this;
                    _this._external = external;
                    _this._audio = audio;
                    _this._video = video;
                    return _this;
                }
                WebRtcRemoteMedia.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcRemoteMedia]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcRemoteMedia.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcRemoteMedia.prototype.getAudioSinkOutputs = function () {
                    return this.getSinkOutputs('audio');
                };
                WebRtcRemoteMedia.prototype.getVideoSinkOutputs = function () {
                    return this.getSinkOutputs('video');
                };
                WebRtcRemoteMedia.prototype.getSinkOutputs = function (kind) {
                    var promise = new fm.icelink.Promise();
                    if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
                        try {
                            navigator.mediaDevices.enumerateDevices().then(function (mediaDeviceInfos) {
                                var outputs = [];
                                var index = -1;
                                for (var _i = 0, mediaDeviceInfos_2 = mediaDeviceInfos; _i < mediaDeviceInfos_2.length; _i++) {
                                    var mediaDeviceInfo = mediaDeviceInfos_2[_i];
                                    if (mediaDeviceInfo.kind == kind || mediaDeviceInfo.kind == kind + 'output') {
                                        index++;
                                        var id = mediaDeviceInfo.deviceId;
                                        if (!id) {
                                            id = 'audio-' + index;
                                        }
                                        var name_38 = mediaDeviceInfo.label;
                                        if (!name_38) {
                                            name_38 = id;
                                        }
                                        outputs.push(new fm.icelink.SinkOutput(id, name_38));
                                    }
                                }
                                promise.resolve(outputs);
                            }).catch(function (ex) {
                                promise.reject(ex);
                            });
                        }
                        catch (error) {
                            promise.reject(error);
                        }
                    }
                    else if (MediaStreamTrack && MediaStreamTrack.getSources) {
                        try {
                            MediaStreamTrack.getSources(function (sources) {
                                var outputs = [];
                                var index = -1;
                                for (var _i = 0, sources_2 = sources; _i < sources_2.length; _i++) {
                                    var source = sources_2[_i];
                                    if (source.kind == kind || source.kind == kind + 'output') {
                                        index++;
                                        var id = source.deviceId;
                                        if (!id) {
                                            id = 'audio-' + index;
                                        }
                                        var name_39 = source.label;
                                        if (!name_39) {
                                            name_39 = id;
                                        }
                                        outputs.push(new fm.icelink.SinkOutput(id, name_39));
                                    }
                                }
                                promise.resolve(outputs);
                            });
                        }
                        catch (error) {
                            promise.reject(error);
                        }
                    }
                    else {
                        promise.reject(new fm.icelink.Exception('Browser does not support media device enumeration.'));
                    }
                    return promise;
                };
                WebRtcRemoteMedia.prototype.getAudioSinkOutput = function () {
                    return this._audioSinkOutput;
                };
                WebRtcRemoteMedia.prototype.setAudioSinkOutput = function (audioSinkOutput) {
                    if (this._audioSinkOutput != audioSinkOutput) {
                        if (this._audioSink.getTrack()) {
                            this.attachAudioSinkOutput(audioSinkOutput, this._audioSink.getAudio());
                        }
                        else if (this._videoSink.getTrack()) {
                            this.attachAudioSinkOutput(audioSinkOutput, this._videoSink.getVideo());
                        }
                        this._audioSinkOutput = audioSinkOutput;
                    }
                };
                WebRtcRemoteMedia.prototype.attachAudioSinkOutput = function (audioSinkOutput, element) {
                    if (typeof element.setSinkId !== 'undefined') {
                        element.setSinkId(audioSinkOutput.getId());
                    }
                    else {
                        throw new fm.icelink.Exception('Browser does not support changing audio sink output.');
                    }
                };
                WebRtcRemoteMedia.prototype.getVideoSinkOutput = function () {
                    return this._videoSinkOutput;
                };
                WebRtcRemoteMedia.prototype.setVideoSinkOutput = function (videoSinkOutput) {
                    if (this._videoSinkOutput != videoSinkOutput) {
                        this._videoSinkOutput = videoSinkOutput;
                    }
                };
                WebRtcRemoteMedia.prototype.changeAudioSinkOutput = function (audioInput) {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    if (audioInput == this.getAudioSinkOutput()) {
                        fm.icelink.ManagedThread.dispatch(function () {
                            promise.resolve(null);
                        });
                    }
                    else {
                        fm.icelink.ManagedThread.dispatch(function () {
                            try {
                                _this.setAudioSinkOutput(audioInput);
                                promise.resolve(null);
                            }
                            catch (ex) {
                                promise.reject(ex);
                            }
                        });
                    }
                    return promise;
                };
                WebRtcRemoteMedia.prototype.changeVideoSinkOutput = function (videoInput) {
                    var _this = this;
                    var promise = new fm.icelink.Promise();
                    if (videoInput == this.getVideoSinkOutput()) {
                        fm.icelink.ManagedThread.dispatch(function () {
                            promise.resolve(null);
                        });
                    }
                    else {
                        fm.icelink.ManagedThread.dispatch(function () {
                            try {
                                _this.setVideoSinkOutput(videoInput);
                                promise.resolve(null);
                            }
                            catch (ex) {
                                promise.reject(ex);
                            }
                        });
                    }
                    return promise;
                };
                return WebRtcRemoteMedia;
            }(fm.icelink.WebRtcMedia));
            icelink.WebRtcRemoteMedia = WebRtcRemoteMedia;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcVideoStream =  (function (_super) {
                __extends(WebRtcVideoStream, _super);
                function WebRtcVideoStream(external, localTrack, remoteTrack) {
                    var _this = _super.call(this, external, localTrack, remoteTrack, fm.icelink.StreamType.Video) || this;
                    _this._external = external;
                    return _this;
                }
                WebRtcVideoStream.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcVideoStream]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcVideoStream.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcVideoStream.prototype.getVp8Disabled = function () {
                    return this.getCodecDisabled(fm.icelink.VideoFormat.getVp8Name());
                };
                WebRtcVideoStream.prototype.getVp9Disabled = function () {
                    return this.getCodecDisabled(fm.icelink.VideoFormat.getVp9Name());
                };
                WebRtcVideoStream.prototype.getH264Disabled = function () {
                    return this.getCodecDisabled(fm.icelink.VideoFormat.getH264Name());
                };
                WebRtcVideoStream.prototype.getH265Disabled = function () {
                    return this.getCodecDisabled(fm.icelink.VideoFormat.getH265Name());
                };
                WebRtcVideoStream.prototype.setVp8Disabled = function (value) {
                    return this.setCodecDisabled(fm.icelink.VideoFormat.getVp8Name(), value);
                };
                WebRtcVideoStream.prototype.setVp9Disabled = function (value) {
                    return this.setCodecDisabled(fm.icelink.VideoFormat.getVp9Name(), value);
                };
                WebRtcVideoStream.prototype.setH264Disabled = function (value) {
                    return this.setCodecDisabled(fm.icelink.VideoFormat.getH264Name(), value);
                };
                WebRtcVideoStream.prototype.setH265Disabled = function (value) {
                    return this.setCodecDisabled(fm.icelink.VideoFormat.getH265Name(), value);
                };
                WebRtcVideoStream.prototype.addOnDiscardKeyFrameRequest = function (value) { };
                WebRtcVideoStream.prototype.removeOnDiscardKeyFrameRequest = function (value) { };
                WebRtcVideoStream.prototype.raiseKeyFrameRequest = function (synchronizationSources) { };
                return WebRtcVideoStream;
            }(fm.icelink.WebRtcMediaStream));
            icelink.WebRtcVideoStream = WebRtcVideoStream;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            var WebRtcVideoTrack =  (function (_super) {
                __extends(WebRtcVideoTrack, _super);
                function WebRtcVideoTrack(external, media) {
                    var _this = _super.call(this, external, media) || this;
                    _this._external = external;
                    return _this;
                }
                WebRtcVideoTrack.prototype.getTypeString = function () {
                    return '[fm.icelink.WebRtcVideoTrack]' + ',' + _super.prototype.getTypeString.call(this);
                };
                WebRtcVideoTrack.prototype._getExternal = function () {
                    return this._external;
                };
                WebRtcVideoTrack.prototype.setConfig = function (config) {
                    var nativeMediaStreamTrack = this._getMediaStreamTrack();
                    if (nativeMediaStreamTrack.applyConstraints) {
                        var constraints = {};
                        if (config.getWidth() > 0) {
                            constraints.width = config.getWidth();
                        }
                        if (config.getHeight() > 0) {
                            constraints.height = config.getHeight();
                        }
                        if (config.getFrameRate() > 0) {
                            constraints.frameRate = config.getFrameRate();
                        }
                        nativeMediaStreamTrack.applyConstraints(constraints);
                    }
                };
                WebRtcVideoTrack.prototype.isLocal = function () {
                    return (fm.icelink.Util.isObjectType(this.getMedia(), '[fm.icelink.WebRtcLocalMedia]'));
                };
                WebRtcVideoTrack.prototype.changeSinkOutput = function (sinkOutput) {
                    if (this.isLocal()) {
                        var promise = new fm.icelink.Promise();
                        promise.reject(new fm.icelink.Exception('Cannot call VideoTrack.changeSinkOutput on a local track.'));
                        return promise;
                    }
                    return this.getMedia().changeVideoSinkOutput(sinkOutput);
                };
                WebRtcVideoTrack.prototype.getSinkOutput = function () {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.getSinkOutput on a local track.');
                    }
                    return this.getMedia().getVideoSinkOutput();
                };
                WebRtcVideoTrack.prototype.getSinkOutputs = function () {
                    if (this.isLocal()) {
                        var promise = new fm.icelink.Promise();
                        promise.reject(new fm.icelink.Exception('Cannot call VideoTrack.getSinkOutputs on a local track.'));
                        return promise;
                    }
                    return this.getMedia().getVideoSinkOutputs();
                };
                WebRtcVideoTrack.prototype.setSinkOutput = function (value) {
                    if (this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.setSinkOutput on a local track.');
                    }
                    this.getMedia().setVideoSinkOutput(value);
                };
                WebRtcVideoTrack.prototype.changeSourceInput = function (sourceInput) {
                    if (!this.isLocal()) {
                        var promise = new fm.icelink.Promise();
                        promise.reject(new fm.icelink.Exception('Cannot call VideoTrack.changeSourceInput on a remote track.'));
                        return promise;
                    }
                    return this.getMedia().changeVideoSourceInput(sourceInput);
                };
                WebRtcVideoTrack.prototype.getSourceInput = function () {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.getSourceInput on a remote track.');
                    }
                    return this.getMedia().getVideoSourceInput();
                };
                WebRtcVideoTrack.prototype.getSourceInputs = function () {
                    if (!this.isLocal()) {
                        var promise = new fm.icelink.Promise();
                        promise.reject(new fm.icelink.Exception('Cannot call VideoTrack.getSourceInputs on a remote track.'));
                        return promise;
                    }
                    return this.getMedia().getVideoSourceInputs();
                };
                WebRtcVideoTrack.prototype.setSourceInput = function (value) {
                    if (!this.isLocal()) {
                        throw new fm.icelink.Exception('Cannot call VideoTrack.setSourceInput on a remote track.');
                    }
                    this.getMedia().setVideoSourceInput(value);
                };
                WebRtcVideoTrack.prototype.addOnSize = function (value) {
                    this.getMedia().addOnVideoSize(value);
                };
                WebRtcVideoTrack.prototype.getSize = function () {
                    return this.getMedia().getVideoSize();
                };
                WebRtcVideoTrack.prototype.grabFrame = function () {
                    return this.getMedia().grabVideoFrame();
                };
                WebRtcVideoTrack.prototype.removeOnSize = function (value) {
                    this.getMedia().removeOnVideoSize(value);
                };
                return WebRtcVideoTrack;
            }(fm.icelink.WebRtcMediaTrack));
            icelink.WebRtcVideoTrack = WebRtcVideoTrack;
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.Binary.fmicelinkBinaryInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.Constants.fmicelinkConstantsInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.DataBuffer.fmicelinkDataBufferInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.UnixTimestamp.fmicelinkUnixTimestampInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.HttpTransfer.fmicelinkHttpTransferInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.JsonChecker.fmicelinkJsonCheckerInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.LockedRandomizer.fmicelinkLockedRandomizerInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.Log.fmicelinkLogInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.LogConfiguration.fmicelinkLogConfigurationInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.DataBufferPool.fmicelinkDataBufferPoolInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.WebSocketBase.fmicelinkWebSocketBaseInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.VideoFormat.fmicelinkVideoFormatInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.DataMessage.fmicelinkDataMessageInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (datamessageheader) {
                fm.icelink.datamessageheader.DeliveryAttemptsElement.fmicelinkdatamessageheaderDeliveryAttemptsElementInitialize();
            })(icelink.datamessageheader || (icelink.datamessageheader = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (datamessageheader) {
                fm.icelink.datamessageheader.ConnectionIdElement.fmicelinkdatamessageheaderConnectionIdElementInitialize();
            })(icelink.datamessageheader || (icelink.datamessageheader = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (datamessageheader) {
                fm.icelink.datamessageheader.TimeToLiveElement.fmicelinkdatamessageheaderTimeToLiveElementInitialize();
            })(icelink.datamessageheader || (icelink.datamessageheader = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (datamessageheader) {
                fm.icelink.datamessageheader.UnknownElement.fmicelinkdatamessageheaderUnknownElementInitialize();
            })(icelink.datamessageheader || (icelink.datamessageheader = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.WebRtcLocalMediaBase.fmicelinkWebRtcLocalMediaBaseInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.VideoBuffer.fmicelinkVideoBufferInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                fm.icelink.sdp.Attribute.fmicelinksdpAttributeInitialize();
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            fm.icelink.EncodingInfo.fmicelinkEncodingInfoInitialize();
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                fm.icelink.sdp.Media.fmicelinksdpMediaInitialize();
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    (function (fm) {
        (function (icelink) {
            (function (sdp) {
                (function (rtp) {
                    fm.icelink.sdp.rtp.MapAttribute.fmicelinksdprtpMapAttributeInitialize();
                })(sdp.rtp || (sdp.rtp = {}));
            })(icelink.sdp || (icelink.sdp = {}));
        })(fm.icelink || (fm.icelink = {}));
    })(fm || (fm = {}));
    return fm.icelink;
    }));
    });
    var icelink = fm_icelink;

    var __awaiter$5 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var icelinkUtils;
    (function (icelinkUtils) {
        function futureToPromise(future) {
            return new Promise((resolve, reject) => future.then(resolve, reject));
        }
        icelinkUtils.futureToPromise = futureToPromise;
        function tryInternal(input, ...properties) {
            let result = input;
            for (let index = 0; index < properties.length; index++) {
                result = _tryInternal(result, properties[index].m, properties[index].p || []);
            }
            return result;
        }
        icelinkUtils.tryInternal = tryInternal;
        function _tryInternal(input, property, ...params) {
            if (input) {
                if (property in input) {
                    if (typeof input[property] === "function") {
                        return input[property](input, params);
                    }
                    else {
                        return input[property];
                    }
                }
                else {
                    throw new Error(`${property} not exist on ${"getTypeString" in input ? input["getTypeString"]() : "object"}`);
                }
            }
            else {
                return input;
            }
        }
        function audioTrackLevelToObservable(media, updateIntervalInMS) {
            const mediaStream = tryInternal(tryInternal(media, { m: "_getInternal" }), { m: "_getAudioMediaStream" });
            const audioTracks = mediaStream === null || mediaStream === void 0 ? void 0 : mediaStream.getAudioTracks();
            if ((audioTracks === null || audioTracks === void 0 ? void 0 : audioTracks.length) > 0) {
                return new Observable((observer) => {
                    const vuMeterNode = vuMeter
                        .ofMediaStream(mediaStream, (volume) => observer.next(volume), updateIntervalInMS)
                        .then((vuMeter) => {
                        vuMeter.onprocessorerror = (err) => console.error("vuMeterNode - Error on process", err);
                        vuMeter.start();
                        return vuMeter;
                    });
                    audioTracks.forEach((audioTrack) => {
                        audioTrack.onended = () => {
                            vuMeterNode.then((node) => node.stop()).catch((e) => console.error("vuMeterNode - Error on stop from onended", e));
                        };
                    });
                    return () => {
                        vuMeterNode.then((node) => node.stop()).catch((e) => console.error("vuMeterNode - Error on stop", e));
                    };
                });
            }
            else {
                return EMPTY;
            }
        }
        icelinkUtils.audioTrackLevelToObservable = audioTrackLevelToObservable;
        function videoBufferToCanvas(VideoBuffer) {
            let canvas = document.createElement("canvas");
            canvas.height = VideoBuffer.getHeight();
            canvas.width = VideoBuffer.getWidth();
            canvas.getContext("2d").putImageData(new ImageData(Uint8ClampedArray.from(VideoBuffer.getDataBuffer().getData()), canvas.width, canvas.height), 0, 0);
            return canvas;
        }
        icelinkUtils.videoBufferToCanvas = videoBufferToCanvas;
    })(icelinkUtils || (icelinkUtils = {}));
    var vuMeter;
    (function (vuMeter) {
        var audioContext;
        const vumeterProcessor = `registerProcessor("vumeter",class extends AudioWorkletProcessor{constructor(t){super(),this._updateIntervalInMS=t.processorOptions.updateIntervalInMS,this._nextUpdateFrame=this.intervalInFrames,this.port.onmessage=(t=>{t.data.updateIntervalInMS&&(this._updateIntervalInMS=t.data.updateIntervalInMS)})}get intervalInFrames(){return this._updateIntervalInMS/1e3*sampleRate}process(t,e,r){const s=t[0];if(s.length>0){const t=s[0];if(this._nextUpdateFrame-=t.length,this._nextUpdateFrame<0){var a=0;for(let e=0;e<t.length;++e)a+=t[e]*t[e];this.port.postMessage({volume:Math.sqrt(a/t.length)}),this._nextUpdateFrame+=this.intervalInFrames}}return!0}});`;
        function getAudioContext() {
            return __awaiter$5(this, void 0, void 0, function* () {
                if (audioContext == null) {
                    audioContext = new AudioContext();
                    yield audioContext.resume();
                    yield audioContext.audioWorklet.addModule(URL.createObjectURL(new Blob([vumeterProcessor], { type: "text/javascript" })));
                }
                return audioContext;
            });
        }
        vuMeter.getAudioContext = getAudioContext;
        function ofMediaStream(mediaStream, onLevel, updateIntervalInMS) {
            return __awaiter$5(this, void 0, void 0, function* () {
                audioContext = yield getAudioContext();
                const interval = updateIntervalInMS !== null && updateIntervalInMS !== void 0 ? updateIntervalInMS : 25;
                return new VUMeterNode(audioContext, mediaStream, onLevel, interval < 0 ? 25 : interval);
            });
        }
        vuMeter.ofMediaStream = ofMediaStream;
        class VUMeterNode extends AudioWorkletNode {
            constructor(audioContext, mediaStream, onLevel, updateIntervalInMS) {
                super(audioContext, "vumeter", {
                    numberOfInputs: 1,
                    numberOfOutputs: 0,
                    channelCount: 1,
                    processorOptions: { updateIntervalInMS: updateIntervalInMS },
                });
                this.onLevel = onLevel;
                this.started = false;
                this._mediaStream = audioContext.createMediaStreamSource(mediaStream);
                this._updateIntervalInMS = updateIntervalInMS;
                this.port.onmessage = (event) => {
                    var _a;
                    if (event.data.volume)
                        (_a = this.onLevel) === null || _a === void 0 ? void 0 : _a.call(this, event.data.volume);
                };
            }
            get updateInterval() {
                return this._updateIntervalInMS;
            }
            set updateInterval(updateIntervalInMS) {
                this._updateIntervalInMS = updateIntervalInMS;
                this.port.postMessage({ updateIntervalInMS });
            }
            start() {
                if (!this.started) {
                    this._mediaStream.connect(this);
                    this.started = true;
                }
            }
            stop() {
                if (this.started) {
                    this._mediaStream.disconnect(this);
                    this.started = false;
                }
            }
        }
        vuMeter.VUMeterNode = VUMeterNode;
    })(vuMeter || (vuMeter = {}));

    var LocalMediaConfigurationConstraints =  (function () {
        function LocalMediaConfigurationConstraints(config, prefix) {
            this.bandwidth = null;
            this.constraints = null;
            if (!config)
                return;
            loadConfig(prefix, LocalMediaConfigurationConstraints.CHECK_OPTIONS, this, config);
        }
        LocalMediaConfigurationConstraints.CHECK_OPTIONS = {
            mandatory: {},
            optional: {
                bandwidth: numberCheck,
                constraints: objectCheck,
            },
        };
        return LocalMediaConfigurationConstraints;
    }());

    var LocalMediaConfiguration =  (function () {
        function LocalMediaConfiguration(config, prefix) {
            this.audio = new LocalMediaConfigurationConstraints();
            this.video = new LocalMediaConfigurationConstraints();
            this.audio.bandwidth = 32;
            this.audio.constraints = {};
            this.video.bandwidth = 256;
            this.video.constraints = {
                width: 640,
                height: 480,
                frameRate: 30,
            };
            if (!config)
                return;
            loadConfig(prefix, LocalMediaConfiguration.CHECK_OPTIONS, this, config);
        }
        LocalMediaConfiguration.CHECK_OPTIONS = {
            mandatory: {},
            optional: {
                audio: function (config, destination, prefix) { return new LocalMediaConfigurationConstraints(objectCheck(config), arrayConcat(prefix, ["audio"])); },
                video: function (config, destination, prefix) { return new LocalMediaConfigurationConstraints(objectCheck(config), arrayConcat(prefix, ["video"])); },
            },
        };
        return LocalMediaConfiguration;
    }());

    var RemoteMediaConfiguration =  (function () {
        function RemoteMediaConfiguration(config, prefix) {
            var local = new LocalMediaConfiguration();
            this.audio = { bandwidth: local.audio.bandwidth };
            this.video = { bandwidth: local.video.bandwidth };
            if (!config)
                return;
            loadConfig(prefix, RemoteMediaConfiguration.CHECK_OPTIONS, this, config);
        }
        RemoteMediaConfiguration.CHECK_OPTIONS = {
            mandatory: {},
            optional: {
                audio: function (options, destination, prefix) {
                    for (var opt in options) {
                        if (opt != "bandwidth") {
                            throw ConfigurationError.newInstance(arrayConcat(prefix, ["audio"]).join("."), options[opt], new Error(opt + " is not valid remote media audio options"));
                        }
                    }
                    var value = options.bandwidth ? numberCheck(options.bandwidth) : null;
                    return value ? options : value;
                },
                video: function (options, destination, prefix) {
                    for (var opt in options) {
                        if (opt != "bandwidth") {
                            throw ConfigurationError.newInstance(arrayConcat(prefix, ["video"]).join("."), options[opt], new Error(opt + " is not valid remote media video options"));
                        }
                    }
                    var value = options.bandwidth ? numberCheck(options.bandwidth) : null;
                    return value ? options : value;
                },
            },
        };
        return RemoteMediaConfiguration;
    }());

    var MediaConfiguration =  (function () {
        function MediaConfiguration(config, prefix) {
            this.local = new LocalMediaConfiguration();
            this.remote = new RemoteMediaConfiguration();
            this.audioLevelUpdateIntervalInMS = 50;
            delete this.remote.audio.constraints;
            delete this.remote.video.constraints;
            if (!config)
                return;
            loadConfig(prefix, MediaConfiguration.CHECK_OPTIONS, this, config);
        }
        MediaConfiguration.CHECK_OPTIONS = {
            mandatory: {},
            optional: {
                local: function (config, destination, prefix) { return new LocalMediaConfiguration(objectCheck(config), arrayConcat(prefix, ["local"])); },
                remote: function (config, destination, prefix) { return new RemoteMediaConfiguration(objectCheck(config), arrayConcat(prefix, ["remote"])); },
                audioLevelUpdateIntervalInMS: numberCheck,
            },
        };
        return MediaConfiguration;
    }());

    var WebRTCFieldSession =  (function () {
        function WebRTCFieldSession(answer, session) {
            this.answer = answer;
            this.session = session;
        }
        WebRTCFieldSession.fromObject = function (data) {
            if (data) {
                var sessionDescription = null, answer = false;
                if (data.session) {
                    try {
                        sessionDescription = icelink.SessionDescription.fromJson(data.session);
                        answer = !sessionDescription.getIsOffer();
                    }
                    catch (e) { }
                }
                return new WebRTCFieldSession(answer, sessionDescription);
            }
            else {
                return null;
            }
        };
        WebRTCFieldSession.prototype.toObject = function () {
            return this.session ? { session: this.session.toJson() } : null;
        };
        WebRTCFieldSession.prototype.isAnswer = function () {
            return this.answer;
        };
        return WebRTCFieldSession;
    }());
    var WebRTCFieldCandidate =  (function () {
        function WebRTCFieldCandidate(candidate, last) {
            this.candidate = candidate;
            this.last = last;
        }
        WebRTCFieldCandidate.fromObject = function (data) {
            if (data) {
                var candidate = null;
                if (data.candidate && data.candidate.length > 0) {
                    candidate = [];
                    for (var i = 0; i < data.candidate.length; i++) {
                        if (data.candidate[i]) {
                            try {
                                candidate.push(icelink.Candidate.fromJson(data.candidate[i]));
                            }
                            catch (e) { }
                        }
                    }
                }
                return new WebRTCFieldCandidate(candidate, data.last);
            }
            else {
                return null;
            }
        };
        WebRTCFieldCandidate.prototype.toObject = function () {
            var result = { last: this.last || false };
            if (this.candidate && this.candidate.length) {
                result.candidate = this.candidate.map(function (candidate) { return candidate.toJson(); });
            }
            return result;
        };
        return WebRTCFieldCandidate;
    }());
    var WebRTCFieldAutoanswer =  (function () {
        function WebRTCFieldAutoanswer(after, media) {
            this.after = after;
            this.media = media;
            if (isNaN(after)) {
                this.after = null;
            }
            if (!media || Object.keys(media).length == 0) {
                this.media = null;
            }
        }
        WebRTCFieldAutoanswer.fromObject = function (data) {
            if (data) {
                var media_1 = null;
                if (data.media && data.media.length) {
                    media_1 = {};
                    data.media.forEach(function (e) { return (media_1[e] = true); });
                }
                var result = new WebRTCFieldAutoanswer(data.after, media_1);
                if (result.after == null && result.media == null) {
                    return null;
                }
                else {
                    return result;
                }
            }
            else {
                return null;
            }
        };
        WebRTCFieldAutoanswer.prototype.toObject = function () {
            if (this.after == null && this.media == null) {
                return null;
            }
            else {
                var result = {};
                if (this.after !== null) {
                    result.after = this.after;
                }
                if (this.media) {
                    result.media = Array.from(buildCallMedia(this.media));
                }
                return result;
            }
        };
        return WebRTCFieldAutoanswer;
    }());
    var WebRTCField =  (function () {
        function WebRTCField(clientid, sessionDescription, candidate, autoanswer, ring) {
            this.clientid = clientid;
            this.sessionDescription = sessionDescription;
            this.candidate = candidate;
            this.autoanswer = autoanswer;
            this.ring = ring;
        }
        WebRTCField.fromObject = function (data) {
            if (data) {
                var result = new WebRTCField(data.clientId ? data.clientId : null, data.sessionDescription ? WebRTCFieldSession.fromObject(data.sessionDescription) : null, data.candidate ? WebRTCFieldCandidate.fromObject(data.candidate) : null, data.autoanswer ? WebRTCFieldAutoanswer.fromObject(data.autoanswer) : null, data.ring === true || data.ring === false ? data.ring : null);
                return result;
            }
            else {
                return null;
            }
        };
        WebRTCField.prototype.toObject = function () {
            var webrtcFields = {};
            if (this.clientid) {
                webrtcFields.clientId = this.clientid;
            }
            if (this.sessionDescription) {
                webrtcFields.sessionDescription = this.sessionDescription.toObject();
            }
            if (this.candidate) {
                webrtcFields.candidate = this.candidate.toObject();
            }
            if (this.autoanswer) {
                webrtcFields.autoanswer = this.autoanswer.toObject();
            }
            if (this.ring !== null) {
                webrtcFields.ring = this.ring;
            }
            return webrtcFields;
        };
        return WebRTCField;
    }());

    var ConnectionStateValue;
    (function (ConnectionStateValue) {
        ConnectionStateValue["new"] = "new";
        ConnectionStateValue["initializing"] = "initializing";
        ConnectionStateValue["connecting"] = "connecting";
        ConnectionStateValue["connected"] = "connected";
        ConnectionStateValue["failing"] = "failing";
        ConnectionStateValue["failed"] = "failed";
        ConnectionStateValue["closing"] = "closing";
        ConnectionStateValue["closed"] = "closed";
    })(ConnectionStateValue || (ConnectionStateValue = {}));
    var DeviceStatusValue;
    (function (DeviceStatusValue) {
        DeviceStatusValue["add"] = "add";
        DeviceStatusValue["del"] = "del";
        DeviceStatusValue["none"] = "none";
    })(DeviceStatusValue || (DeviceStatusValue = {}));

    var __extends$2 = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var __assign = (undefined && undefined.__assign) || function () {
        __assign = Object.assign || function(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                    t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };
    var __awaiter$4 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$4 = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    var Call$1 =  (function () {
        function Call(_manager, _controlMessageNotifier, _connectionState, _callId, _channelType, _isOffer, state, realState) {
            var _this = this;
            this._manager = _manager;
            this._controlMessageNotifier = _controlMessageNotifier;
            this._connectionState = _connectionState;
            this._callId = _callId;
            this._channelType = _channelType;
            this._isOffer = _isOffer;
            this._callIsOnServer = new BehaviorSubject(false);
            this._log = Log$1.of("webrtc:call", _manager.client);
            this._deviceIsApp = false;
            this._toneSignalEnabled = true;
            this._connection = null;
            this._connectionStates = [];
            this._connectionStateConnected = null;
            this._localCandidateToSend = [];
            this._localDescriptionToSend = null;
            this._localMedia = null;
            this._remoteMedia = new icelink.RemoteMedia();
            this._localCallMedia = {};
            this._remoteCallMedia = {};
            this._waitForAnswer = true;
            this._waitIceCandidateBeforeUpdate = false;
            this._remoteWebrtcfield = null;
            this._updateFields = new Subject();
            this._localAudioLevel = new MonitorAudioLevel("local", this);
            this._remoteAudioLevel = new MonitorAudioLevel("remote", this);
            this._mediaStreamStats = new MonitorMediaStreamStats(this);
            this.setState(state, realState, false);
            this._controlMessageSubscription = _controlMessageNotifier.pipe(filter(function (message) { return message && message.callId === _this.callId; })).subscribe(function (controlMessage) {
                _this._lastControlMessage = controlMessage;
                if (!_this._device && controlMessage.device && controlMessage.deviceType === ExtenType.WEBRTC) {
                    _this._device = controlMessage.device;
                }
            });
            this._updateFields
                .pipe(debounceTime(10), throttle(function (action) { return _this.updateWebRTCFields(action.sendUpdate).toPromise(); }, { leading: false, trailing: true }), catchError(function (err) {
                _this._log.error("Error on updateWebRTCFields", err);
                return of(false);
            }))
                .subscribe();
            this._mediaEnabled = false;
        }
        Object.defineProperty(Call.prototype, "manager", {
            get: function () {
                return this._manager;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "remoteMedia", {
            get: function () {
                return this._remoteCallMedia;
            },
            set: function (media) {
                this._remoteCallMedia = media ? media : {};
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "remoteDescription", {
            get: function () {
                return this._remoteDescription;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "localDescription", {
            get: function () {
                return this._localDescription;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "channelType", {
            get: function () {
                return this._channelType;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "dialParams", {
            get: function () {
                return this._dialParams;
            },
            set: function (params) {
                this._dialParams = params;
                if (params && params.params.fromDevice) {
                    this._deviceIsApp = params.isForApp();
                    if (this.callIsForApp) {
                        this._toneSignalEnabled = false;
                    }
                }
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "mediaEnabled", {
            set: function (mediaEnabled) {
                this._mediaEnabled = mediaEnabled;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "remoteWebrtcfield", {
            set: function (webrtcfield) {
                this._remoteWebrtcfield = webrtcfield;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "callId", {
            get: function () {
                return this._callId;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "deviceIsApp", {
            get: function () {
                return this._deviceIsApp;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "remoteCallMedia", {
            get: function () {
                return this._remoteCallMedia;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "localCallMedia", {
            get: function () {
                return this._localCallMedia;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "localMedia", {
            get: function () {
                return this._localMedia;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "connection", {
            get: function () {
                return this._connection;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "waitForAnswer", {
            get: function () {
                return this._waitForAnswer;
            },
            set: function (waitForAnswer) {
                this._waitForAnswer = waitForAnswer;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "state", {
            get: function () {
                return this._state;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "realState", {
            get: function () {
                return this._isRealState;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "autoanswer", {
            get: function () {
                return this._autoanswer;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "isOffer", {
            get: function () {
                return this._isOffer;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "videoContainer", {
            get: function () {
                var layoutManager = this._layoutManager || this._manager.layoutManager;
                return layoutManager ? layoutManager.getContainer().parentElement : null;
            },
            set: function (videoContainer) {
                if (videoContainer && (!this._layoutManager || videoContainer !== this._layoutManager.getContainer().parentElement)) {
                    this.unsetVideoContainer();
                    this._layoutManager = new icelink.DomLayoutManager(videoContainer, this._manager.options.layoutPreset);
                    this.setLocalView();
                    this.setRemoteView();
                }
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "toneSignalEnabled", {
            get: function () {
                return this._toneSignalEnabled;
            },
            set: function (toneSignalEnabled) {
                this._toneSignalEnabled = toneSignalEnabled;
            },
            enumerable: false,
            configurable: true
        });
        Call.prototype.setState = function (state, realState, notifyState) {
            this._state = state;
            if (realState === true || realState === false) {
                this._isRealState = realState;
                if (realState) {
                    this._callIsOnServer.next(true);
                }
            }
            if (!this.callIsForApp && notifyState) {
                this.notifyConnectionState();
            }
        };
        Call.prototype.markAsClosedLocal = function () {
            this._closedLocal = true;
        };
        Call.prototype.isClosedLocal = function () {
            return this._closedLocal;
        };
        Call.prototype.getLocalAudioLevel = function () {
            return this.callIsForApp ? null : this._localAudioLevel.start();
        };
        Call.prototype.getRemoteAudioLevel = function () {
            return this.callIsForApp ? null : this._remoteAudioLevel.start();
        };
        Call.prototype.getLocalVideoFrame = function () {
            if (this.callIsForApp) {
                return Promise.reject("Device is App");
            }
            else {
                try {
                    return this._localMedia && this._localMedia.getVideoTrack() ? icelinkUtils.futureToPromise(this._localMedia.grabVideoFrame()) : Promise.reject("Local media is not available");
                }
                catch (e) {
                    return Promise.reject("Local media has not video");
                }
            }
        };
        Call.prototype.getRemoteVideoFrame = function () {
            if (this.callIsForApp) {
                return Promise.reject("Device is App");
            }
            else {
                try {
                    return this._remoteMedia && this._remoteMedia.getVideoTrack() ? icelinkUtils.futureToPromise(this._remoteMedia.grabVideoFrame()) : Promise.reject("Remote media is not available");
                }
                catch (e) {
                    return Promise.reject("Remote media has not video");
                }
            }
        };
        Call.prototype.generateLocalWebRTCField = function () {
            var localSessionDescription = null;
            var localCandidate = null;
            if (!this.callIsForApp) {
                var lastCandidate = this._connection && (this._connection.getTrickleIcePolicy() === icelink.TrickleIcePolicy.NotSupported || this._connection.getGatheringState() === icelink.IceGatheringState.Complete);
                if (this._localDescriptionToSend) {
                    localSessionDescription = new WebRTCFieldSession(this._isOffer, this._localDescriptionToSend);
                }
                if (this._localCandidateToSend.length > 0 || lastCandidate) {
                    localCandidate = new WebRTCFieldCandidate(this._localCandidateToSend, lastCandidate);
                }
            }
            return new WebRTCField(null, localSessionDescription, localCandidate, null, null);
        };
        Call.prototype.localDescriptionIsNotified = function () {
            this._localDescriptionToSend = null;
        };
        Call.prototype.initIcelinkConnection = function () {
            var _a;
            return __awaiter$4(this, void 0, void 0, function () {
                return __generator$4(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , this];
                        case 1:
                            if (!this._mediaEnabled) {
                                return [2 , this];
                            }
                            if (!(this._connection === null || this._connection.getState() === icelink.ConnectionState.Closed)) return [3 , 3];
                            return [4 , this.createIcelinkConnection()];
                        case 2:
                            _b.sent();
                            _b.label = 3;
                        case 3: return [4 , this.updateRemoteWebrtcFields()];
                        case 4:
                            _b.sent();
                            if (!this.sessionDescriptionChange(this._remoteDescription, this._connection.getRemoteDescription())) return [3 , 6];
                            return [4 , icelinkUtils.futureToPromise(this._connection.setRemoteDescription(this._remoteDescription))];
                        case 5:
                            _b.sent();
                            _b.label = 6;
                        case 6: return [4 , this.createAndSetLocalDescription(false)];
                        case 7:
                            _b.sent();
                            return [4 , this.notifyConnectionState()];
                        case 8:
                            _b.sent();
                            if (this._state === CallState.CONNECTED && this._connectionStateConnected) {
                                (_a = this._connectionState) === null || _a === void 0 ? void 0 : _a.next(this._connectionStateConnected);
                                this._connectionStateConnected = null;
                            }
                            return [2 , this];
                    }
                });
            });
        };
        Call.prototype.tryAutoanswer = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                var answerAfter, mediaOfAnswer_1, video_1, devices, e_1;
                var _this = this;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!(!this.callIsForApp && this._remoteWebrtcfield && this._remoteWebrtcfield.autoanswer && !this._autoanswer)) return [3 , 7];
                            answerAfter = this._remoteWebrtcfield.autoanswer.after;
                            mediaOfAnswer_1 = this._remoteWebrtcfield.autoanswer.media;
                            if (!(answerAfter != null && mediaOfAnswer_1 && Object.keys(mediaOfAnswer_1).length)) return [3 , 5];
                            video_1 = mediaOfAnswer_1.video;
                            this._autoanswer = true;
                            this._log.info("Call " + this._callId + " is in autoanswer, answer after " + answerAfter + " with media " + Array.from(buildCallMedia(mediaOfAnswer_1)).join("-"));
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 3, , 4]);
                            return [4 , this._manager.device.status.pipe(timeout(100), first()).toPromise()];
                        case 2:
                            devices = _a.sent();
                            video_1 = video_1 && !!devices.video_input && !!devices.video_input.length;
                            return [3 , 4];
                        case 3:
                            e_1 = _a.sent();
                            this._log.error("error on getMediaDeviceStatus for autoanswer", e_1);
                            return [3 , 4];
                        case 4:
                            setTimeout(function () { return __awaiter$4(_this, void 0, void 0, function () {
                                var answerResult, err_1;
                                return __generator$4(this, function (_a) {
                                    switch (_a.label) {
                                        case 0:
                                            if (!(this._state === CallState.NEW_INBOUND)) return [3 , 6];
                                            this._log.info("Call " + this._callId + " autoanswer start");
                                            _a.label = 1;
                                        case 1:
                                            _a.trys.push([1, 4, , 5]);
                                            answerResult = this._manager.methods.answer(this._channelType, this._callId, __assign(__assign({}, mediaOfAnswer_1), { video: video_1 }));
                                            if (!answerResult) return [3 , 3];
                                            return [4 , answerResult.toPromise()];
                                        case 2:
                                            _a.sent();
                                            _a.label = 3;
                                        case 3:
                                            this._log.info("Call " + this._callId + " - autoanswer end");
                                            return [3 , 5];
                                        case 4:
                                            err_1 = _a.sent();
                                            this._log.info("Call " + this._callId + " - autoanswer failed", err_1);
                                            return [3 , 5];
                                        case 5: return [3 , 7];
                                        case 6:
                                            this._log.info("Call " + this._callId + " - cannot start autoanswer, call state is " + this._state + ", expected NEW_INBOUND");
                                            _a.label = 7;
                                        case 7: return [2 ];
                                    }
                                });
                            }); }, 200 + (answerAfter < 0 ? 0 : answerAfter) * 1000);
                            return [3 , 6];
                        case 5:
                            this._log.info("Call " + this._callId + " is in autoanswer but 'after' and 'media' is not set");
                            _a.label = 6;
                        case 6:
                            delete this._remoteWebrtcfield.autoanswer;
                            _a.label = 7;
                        case 7: return [2 ];
                    }
                });
            });
        };
        Call.prototype.sendDTMF = function (dtmf, playTone, dtmfDuration, dtmfInterToneGap) {
            if (dtmfDuration === void 0) { dtmfDuration = this._manager.options.mediaSignal.dtmfDuration; }
            if (dtmfInterToneGap === void 0) { dtmfInterToneGap = this._manager.options.mediaSignal.dtmfInterToneGap; }
            return __awaiter$4(this, void 0, void 0, function () {
                return __generator$4(this, function (_a) {
                    if (playTone) {
                        this._manager.phoneSignal.playDTMF(this.callId, dtmf, dtmfDuration, dtmfInterToneGap);
                    }
                    try {
                        this.connection.getAudioStream().insertDtmfTones(icelink.dtmf.Tone.fromToneString(dtmf, dtmfDuration, dtmfInterToneGap));
                        return [2 , true];
                    }
                    catch (err) {
                        this._log.debug("Call non support dtmf mode rfc2833, notify with action");
                        return [2 , false];
                    }
                    return [2 ];
                });
            });
        };
        Object.defineProperty(Call.prototype, "callIsForApp", {
            get: function () {
                return this.channelType === ChannelType.PhoneCall && this._deviceIsApp;
            },
            enumerable: false,
            configurable: true
        });
        Call.prototype.restartIcelinkConnection = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!(!this.callIsForApp && this._mediaEnabled && this._connection && this._connection.getState() !== icelink.ConnectionState.Closed)) return [3 , 3];
                            this._connection.close();
                            this._isOffer = true;
                            this._remoteDescription = null;
                            return [4 , this.createIcelinkConnection()];
                        case 1:
                            _a.sent();
                            return [4 , this.createAndSetLocalDescription(true)];
                        case 2:
                            _a.sent();
                            _a.label = 3;
                        case 3: return [2 , this];
                    }
                });
            });
        };
        Call.prototype.unifiedPlanToPlanB = function (sessionDescription) {
            var _this = this;
            var isUnifiedPlan = false;
            [CallMedia.audio, CallMedia.video].forEach(function (mediaType) {
                var media = _this.extractMediaFromSessionDescription(sessionDescription, mediaType);
                if (media && media.length > 1) {
                    isUnifiedPlan = true;
                    media.splice(0, 1);
                    media.forEach(function (m) {
                        sessionDescription.getSdpMessage().removeMediaDescription(m);
                    });
                }
            });
            if (isUnifiedPlan) {
                var bundleAttribute_1 = new icelink.sdp.GroupAttribute(icelink.sdp.GroupSemanticsType.Bundling, []);
                sessionDescription
                    .getSdpMessage()
                    .getSessionAttributes()
                    .forEach(function (a) {
                    if (a.getTypeString() === bundleAttribute_1.getTypeString()) {
                        var bundleIds = a.getIds();
                        var audio = bundleIds.indexOf("audio");
                        var video = bundleIds.indexOf("video");
                        bundleIds.length = 0;
                        if (audio > -1) {
                            bundleIds.push("audio");
                        }
                        if (video > -1) {
                            bundleIds.push("video");
                        }
                    }
                });
            }
        };
        Call.prototype.isTrickleIcePolicyOneOf = function () {
            var policyToCheck = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                policyToCheck[_i] = arguments[_i];
            }
            if (policyToCheck) {
                while (policyToCheck.length) {
                    if (this._manager.trickleIcePolicy === policyToCheck.pop()) {
                        return true;
                    }
                }
            }
            return false;
        };
        Call.prototype.retriveCallMediaFromSessionDescription = function (sessionDescription) {
            var mediaParam = {};
            if (sessionDescription) {
                if (sessionDescription.getHasAudio()) {
                    mediaParam.audio = true;
                }
                if (sessionDescription.getHasVideo()) {
                    mediaParam.video = true;
                }
                if (sessionDescription.getHasData()) {
                    mediaParam.data = true;
                }
            }
            return mediaParam;
        };
        Call.prototype.updateWebRTCFields = function (sendUpdate) {
            var _this = this;
            if (this.callIsForApp) {
                return of(false);
            }
            else {
                if ((sendUpdate || !this._waitIceCandidateBeforeUpdate) && !this._waitForAnswer && (this._manager.trickleIcePolicy == icelink.TrickleIcePolicy.FullTrickle || this._state === CallState.CONNECTED)) {
                    return this._callIsOnServer.asObservable().pipe(filter(function (onServer) { return onServer; }), take(1), timeout(5000), map(function () { return _this.generateLocalWebRTCField(); }), switchMap(function (webrtcField) {
                        if (webrtcField.candidate || webrtcField.sessionDescription) {
                            var request = _this._manager.methods.updateWebRTCFields(_this._callId, _this._localCallMedia, webrtcField);
                            _this._localDescriptionToSend = null;
                            _this._localCandidateToSend.length = 0;
                            return request;
                        }
                        else {
                            return of(false);
                        }
                    }));
                }
                else {
                    return of(false);
                }
            }
        };
        Call.prototype.sessionDescriptionChange = function (from, to) {
            return from && to && from.getSessionId() === to.getSessionId() && from.getSessionVersion() !== to.getSessionVersion();
        };
        Call.prototype.createOfferOptions = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                return __generator$4(this, function (_a) {
                    return [2 , this._offerOptions];
                });
            });
        };
        Call.prototype.createAnswerOption = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                return __generator$4(this, function (_a) {
                    return [2 , this._answerOptions];
                });
            });
        };
        Call.prototype.createAndSetLocalDescription = function (force) {
            return __awaiter$4(this, void 0, void 0, function () {
                var createOffer, createAnswer, sessionDescription, e_2, e_3;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!(this._mediaEnabled && this._connection && (force || !this._localDescription))) return [3 , 11];
                            createOffer = false;
                            createAnswer = false;
                            if (this._isOffer && this._remoteDescription && this._remoteDescription.getType() === icelink.SessionDescriptionType.Offer) {
                                this._isOffer = false;
                            }
                            if (this._isOffer) {
                                createOffer = true;
                            }
                            else if (this._remoteDescription) {
                                createAnswer = true;
                            }
                            if (!(createOffer || createAnswer)) return [3 , 9];
                            return [4 , (createOffer ? this.createOfferOptions() : this.createAnswerOption())];
                        case 1:
                            _a.sent();
                            sessionDescription = null;
                            _a.label = 2;
                        case 2:
                            _a.trys.push([2, 4, , 5]);
                            return [4 , icelinkUtils.futureToPromise(createOffer ? this._connection.createOffer( ) : this._connection.createAnswer( ))];
                        case 3:
                            sessionDescription = _a.sent();
                            return [3 , 5];
                        case 4:
                            e_2 = _a.sent();
                            icelink.Log.warn("error on " + (createOffer ? "createOffer" : "createAnswer"), e_2);
                            throw e_2;
                        case 5:
                            _a.trys.push([5, 7, , 8]);
                            return [4 , icelinkUtils.futureToPromise(this._connection.setLocalDescription(sessionDescription))];
                        case 6: return [2 , _a.sent()];
                        case 7:
                            e_3 = _a.sent();
                            icelink.Log.warn("error on setLocalDescription", e_3);
                            throw e_3;
                        case 8: return [3 , 10];
                        case 9: return [2 , this._localDescription];
                        case 10: return [3 , 12];
                        case 11: return [2 , this._localDescription];
                        case 12: return [2 ];
                    }
                });
            });
        };
        Call.prototype.setAudioOutputDevice = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                var audioOutputDevice, err_2;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            audioOutputDevice = this._manager.device.audioOutput;
                            if (!(audioOutputDevice && this._remoteMedia && (this._remoteMedia.getAudioTrack() || this._remoteMedia.getVideoTrack()))) return [3 , 4];
                            if (!(audioOutputDevice != this._remoteMedia.getAudioSinkOutput())) return [3 , 4];
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 3, , 4]);
                            return [4 , icelinkUtils.futureToPromise(this._remoteMedia.changeAudioSinkOutput(audioOutputDevice))];
                        case 2:
                            _a.sent();
                            this._log.debug("Audio Output Device set to " + audioOutputDevice.toJson());
                            return [3 , 4];
                        case 3:
                            err_2 = _a.sent();
                            this._log.error("Error on changeAudioSinkOutput", err_2);
                            return [3 , 4];
                        case 4: return [2 ];
                    }
                });
            });
        };
        Call.prototype.createIcelinkConnection = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                var iceServers, streams, audioStream, videoStream, remoteCallMedia, defaultTimeout_1, defaultDeadStreamTimeout_1, trickeIceDisabled;
                var _this = this;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , Promise.resolve(this)];
                        case 1: return [4 , this._manager.getIceServers()];
                        case 2:
                            iceServers = _a.sent();
                            streams = [];
                            audioStream = new icelink.AudioStream(this._localMedia, this._remoteMedia);
                            videoStream = new icelink.VideoStream(this._localMedia, this._remoteMedia);
                            if (!this._localCallMedia.audio) {
                                audioStream.setLocalSend(false);
                            }
                            if (!this._localCallMedia.video || this._localCallMedia.desktop) {
                                videoStream.setLocalSend(false);
                            }
                            remoteCallMedia = null;
                            if (this._remoteWebrtcfield && this._remoteWebrtcfield.sessionDescription && this._remoteWebrtcfield.sessionDescription.session) {
                                remoteCallMedia = this.retriveCallMediaFromSessionDescription(this._remoteWebrtcfield.sessionDescription.session);
                            }
                            if (remoteCallMedia && Object.keys(remoteCallMedia).length) {
                                if (remoteCallMedia.audio)
                                    streams.push(audioStream);
                                if (remoteCallMedia.video || remoteCallMedia.desktop)
                                    streams.push(videoStream);
                                if (remoteCallMedia.data && this._dataChannel)
                                    streams.push(new icelink.DataStream(this._dataChannel));
                            }
                            else {
                                if (this._localCallMedia.audio) {
                                    streams.push(audioStream);
                                }
                                if (this._manager.options.videoStreamInOffer || this._localCallMedia.video || this._localCallMedia.desktop) {
                                    streams.push(videoStream);
                                }
                                if (this._localCallMedia.data) {
                                    streams.push(new icelink.DataStream(this._dataChannel));
                                }
                            }
                            if (this._manager.layoutManager) {
                                this.setRemoteView();
                            }
                            this._connection = new icelink.Connection(streams);
                            defaultTimeout_1 = this._manager.options.connectionTimeout ? this._manager.options.connectionTimeout : this._connection.getTimeout();
                            defaultDeadStreamTimeout_1 = this._manager.options.deadStreamTimeout ? this._manager.options.deadStreamTimeout : this._connection.getDeadStreamTimeout();
                            trickeIceDisabled = this.isTrickleIcePolicyOneOf(icelink.TrickleIcePolicy.NotSupported, icelink.TrickleIcePolicy.HalfTrickle);
                            this._connection.setTimeout(trickeIceDisabled ? 7200000 : defaultTimeout_1);
                            this._connection.setDeadStreamTimeout(trickeIceDisabled ? 7200000 : defaultDeadStreamTimeout_1);
                            this._connection.setTrickleIcePolicy(this._manager.trickleIcePolicy);
                            this._connection.setIceGatherPolicy(icelink.IceGatherPolicy[this._manager.options.iceGatherPolicy] || icelink.IceGatherPolicy.All);
                            this._connection.setIceServers(iceServers);
                            this._connection.addOnLocalCandidate(function (connection, candidate) {
                                _this._localCandidateToSend.push(candidate);
                                _this._updateFields.next({ sendUpdate: false });
                            });
                            this._connection.addOnLocalDescription(function (connection, sessionDescription) {
                                sessionDescription.getSdpMessage().getOrigin().setUsername("WebAPIclient-" + pkg.version);
                                _this.unifiedPlanToPlanB(sessionDescription);
                                _this.manageBandwidth(false, sessionDescription);
                                _this._localDescriptionToSend = sessionDescription;
                                _this._localDescription = sessionDescription;
                                _this._updateFields.next({ sendUpdate: false });
                            });
                            this._connection.addOnRemoteDescription(function (connection, sessionDescription) {
                                _this.unifiedPlanToPlanB(sessionDescription);
                                _this.manageBandwidth(true, sessionDescription);
                                _this._remoteDescription = sessionDescription;
                            });
                            if (this.isTrickleIcePolicyOneOf(icelink.TrickleIcePolicy.FullTrickle, icelink.TrickleIcePolicy.HalfTrickle)) {
                                this._connection.addOnGatheringStateChange(function (connection) {
                                    if (icelink.IceGatheringState.Complete === connection.getGatheringState()) {
                                        _this._updateFields.next({ sendUpdate: true });
                                    }
                                });
                            }
                            if (this.connection.getAudioStream()) {
                                this._connection.getAudioStream().addOnSendDtmfToneChange(function (tone) {
                                    icelink.Log.info(_this._callId + " - Sender's DTMF tone is changing: " + tone.toString());
                                });
                            }
                            this._connection.addOnStateChange(function (connection) {
                                var _a;
                                var connectionStateVal = ConnectionStateValue[new icelink.ConnectionStateWrapper(connection.getState()).toString().toLowerCase()];
                                var connectionError = !!connection.getError();
                                if (connectionError) {
                                    icelink.Log.info(_this._callId + " - Connection state is " + connectionStateVal + ".", connection.getError().getException());
                                }
                                else {
                                    icelink.Log.info(_this._callId + " - Connection state is " + connectionStateVal + ".");
                                }
                                var connectionState = {
                                    callId: _this._callId,
                                    state: connectionStateVal,
                                    error: connectionError ? connection.getError().getException() : null,
                                };
                                switch (connection.getState()) {
                                    case icelink.ConnectionState.Connecting:
                                        setTimeout(function () { return _this.setAudioOutputDevice(); });
                                        break;
                                    case icelink.ConnectionState.Connected:
                                        _this._remoteAudioLevel.media = _this._remoteMedia;
                                        _this.startConnectionStats();
                                        connection.setTimeout(defaultTimeout_1);
                                        connection.setDeadStreamTimeout(defaultDeadStreamTimeout_1);
                                        _this.setAudioOutputDevice();
                                        break;
                                    case icelink.ConnectionState.Closing:
                                    case icelink.ConnectionState.Failing:
                                        var remoteMedia = _this._remoteMedia;
                                        if (_this._manager.layoutManager != null) {
                                            if (_this._manager.layoutManager.getRemoteView(remoteMedia.getId())) {
                                                _this._manager.layoutManager.removeRemoteView(remoteMedia.getId());
                                                remoteMedia.destroy();
                                            }
                                        }
                                        break;
                                    case icelink.ConnectionState.Failed:
                                        _this._manager.methods.cancel(_this._callId, true, !(_this instanceof CallChecker));
                                        break;
                                    case icelink.ConnectionState.Closed:
                                        _this.stopConnectionStats();
                                        break;
                                }
                                if (_this._isRealState) {
                                    if (connectionState.state === ConnectionStateValue.connected && _this._state !== CallState.CONNECTED) {
                                        _this._connectionStateConnected = connectionState;
                                    }
                                    else {
                                        (_a = _this._connectionState) === null || _a === void 0 ? void 0 : _a.next(connectionState);
                                        _this._connectionStateConnected = null;
                                    }
                                }
                                else {
                                    _this._connectionStates.push(connectionState);
                                }
                            });
                            return [2 , this];
                    }
                });
            });
        };
        Call.prototype.manageBandwidth = function (local, sessionDescription) {
            var _this = this;
            var audioData = { callMedia: CallMedia.audio, maxBandwidth: 0 };
            var videoData = { callMedia: CallMedia.video, maxBandwidth: 0 };
            var type = local ? "local" : "remote";
            try {
                audioData.maxBandwidth = this._manager.options.mediaConfiguration[type].audio.bandwidth;
            }
            catch (e) { }
            try {
                audioData.maxBandwidth = this._mediaConstraints[type].audio.bandwidth;
            }
            catch (e) { }
            try {
                videoData.maxBandwidth = this._manager.options.mediaConfiguration[type].video.bandwidth;
            }
            catch (e) { }
            try {
                videoData.maxBandwidth = this._mediaConstraints[type].video.bandwidth;
            }
            catch (e) { }
            [audioData, videoData].forEach(function (data) {
                try {
                    var media = _this.extractMediaFromSessionDescription(sessionDescription, data.callMedia);
                    if (media && media.length && data.maxBandwidth) {
                        media.forEach(function (m) {
                            var addAttribute = data.callMedia === CallMedia.video;
                            if (data.callMedia === CallMedia.audio) {
                                var rtpMap = m.getRtpMapAttributes();
                                if (rtpMap && rtpMap.length) {
                                    rtpMap.forEach(function (rtpMapAttribute) {
                                        if (rtpMapAttribute.getFormatName() && "OPUS" === rtpMapAttribute.getFormatName().toUpperCase()) {
                                            addAttribute = true;
                                        }
                                    });
                                }
                            }
                            if (addAttribute) {
                                m.addBandwidth(new icelink.sdp.Bandwidth(icelink.sdp.BandwidthType.getApplicationSpecific(), data.maxBandwidth));
                                m.addBandwidth(new icelink.sdp.Bandwidth(icelink.sdp.BandwidthType.getTransportIndependentApplicationSpecificMaximum(), data.maxBandwidth * 1024));
                            }
                        });
                    }
                }
                catch (e) {
                    _this._log.error("Could not add bandwidth constraints to SDP message", e);
                }
            });
        };
        Call.prototype.extractMediaFromSessionDescription = function (sessionDescription, mediaType) {
            var result = [];
            if (sessionDescription) {
                var media = sessionDescription.getSdpMessage().getMediaDescriptions();
                if (media && media.length) {
                    for (var index = 0; index < media.length; index++) {
                        var m = media[index];
                        try {
                            if (mediaType.toString() === m.getMedia().getMediaType().toLowerCase()) {
                                result.push(m);
                            }
                        }
                        catch (e) { }
                    }
                }
            }
            return result;
        };
        Call.prototype.notifyConnectionState = function () {
            var _this = this;
            if (!this.callIsForApp && this._isRealState) {
                if (this._connectionStates.length) {
                    this._connectionStates.forEach(function (state) { var _a; return (_a = _this._connectionState) === null || _a === void 0 ? void 0 : _a.next(state); });
                    this._connectionStates.length = 0;
                }
                if (this._localDescriptionToSend || this._localCandidateToSend.length) {
                    this._updateFields.next({ sendUpdate: true });
                }
            }
        };
        Call.prototype.unsetVideoContainer = function () {
            if (!this.callIsForApp && this._layoutManager) {
                this.unsetLocalView();
                this.unsetRemoteView();
                try {
                    var container = this._layoutManager.getContainer();
                    if (container) {
                        container.remove();
                    }
                }
                catch (e) { }
            }
        };
        Call.prototype.updateRemoteWebrtcFields = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                var webrtcfields, webrtcFieldsWithSdp, remoteDescriptionHasChanged, receivedValidSdp, e_4;
                var _this = this;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!(!this.callIsForApp && this._mediaEnabled && this._connection && this._remoteWebrtcfield && ((this._remoteWebrtcfield.sessionDescription && this._remoteWebrtcfield.sessionDescription.session) || (this._remoteWebrtcfield.candidate && this._remoteWebrtcfield.candidate.candidate && this._remoteWebrtcfield.candidate.candidate.length)))) return [3 , 8];
                            webrtcfields = __assign({}, this._remoteWebrtcfield);
                            webrtcFieldsWithSdp = !!(webrtcfields.sessionDescription && webrtcfields.sessionDescription.session);
                            remoteDescriptionHasChanged = webrtcFieldsWithSdp && (!this._remoteDescription || this.sessionDescriptionChange(this._remoteDescription, webrtcfields.sessionDescription.session));
                            this._remoteWebrtcfield = null;
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 7, , 8]);
                            receivedValidSdp = webrtcFieldsWithSdp && remoteDescriptionHasChanged;
                            if (!(this._connection.getState() !== icelink.ConnectionState.Connected && receivedValidSdp)) return [3 , 3];
                            return [4 , icelinkUtils.futureToPromise(this._connection.setRemoteDescription(webrtcfields.sessionDescription.session))];
                        case 2:
                            _a.sent();
                            _a.label = 3;
                        case 3: return [4 , this.createAndSetLocalDescription(false)];
                        case 4:
                            _a.sent();
                            if (!(webrtcfields.candidate && webrtcfields.candidate.candidate && webrtcfields.candidate.candidate.length)) return [3 , 6];
                            return [4 , Promise.all(webrtcfields.candidate.candidate.map(function (candidate) { return icelinkUtils.futureToPromise(_this._connection.addRemoteCandidate(candidate)); }))];
                        case 5:
                            _a.sent();
                            _a.label = 6;
                        case 6: return [3 , 8];
                        case 7:
                            e_4 = _a.sent();
                            icelink.Log.error("error on updateWebrtcFields", e_4);
                            return [3 , 8];
                        case 8: return [2 ];
                    }
                });
            });
        };
        Call.prototype.close = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!!this.callIsForApp) return [3 , 2];
                            return [4 , this._manager.phoneSignal.stop(this._callId, false)];
                        case 1:
                            _a.sent();
                            _a.label = 2;
                        case 2:
                            this.unsetVideoContainer();
                            this.closeConnection();
                            this.stopLocalMedia();
                            this._controlMessageSubscription.unsubscribe();
                            this._mediaStreamStats.end();
                            this._localAudioLevel.end();
                            this._remoteAudioLevel.end();
                            this._updateFields.complete();
                            return [2 ];
                    }
                });
            });
        };
        Call.prototype.closeConnection = function () {
            if (this._connection) {
                this._connection.close();
                this._connection = null;
                this._connectionStates.length = 0;
            }
        };
        Call.prototype.toggleAudioMute = function (mute, notifyMediaFeature) {
            if (notifyMediaFeature === void 0) { notifyMediaFeature = true; }
            return __awaiter$4(this, void 0, void 0, function () {
                var result, err_3;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1: return [4 , this.toggleMediaTrackMuted(this._localMedia ? this._localMedia.getAudioTrack() : null, mute)];
                        case 2:
                            result = _a.sent();
                            if (!(this._localMedia && this._localMedia.getAudioTrack())) return [3 , 9];
                            if (!notifyMediaFeature) return [3 , 9];
                            _a.label = 3;
                        case 3:
                            _a.trys.push([3, 7, , 9]);
                            return [4 , this.notifyCallMediaState({ audio: true })];
                        case 4:
                            result = _a.sent();
                            if (!!result) return [3 , 6];
                            return [4 , this.toggleAudioMute(!mute, false)];
                        case 5:
                            _a.sent();
                            _a.label = 6;
                        case 6: return [3 , 9];
                        case 7:
                            err_3 = _a.sent();
                            return [4 , this.toggleAudioMute(!mute, false)];
                        case 8:
                            _a.sent();
                            throw err_3;
                        case 9: return [2 , result];
                    }
                });
            });
        };
        Call.prototype.toggleVideoMute = function (mute, notifyMediaFeature) {
            if (notifyMediaFeature === void 0) { notifyMediaFeature = true; }
            return __awaiter$4(this, void 0, void 0, function () {
                var result, err_4;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1: return [4 , this.toggleMediaTrackMuted(this._localMedia ? this._localMedia.getVideoTrack() : null, mute)];
                        case 2:
                            result = _a.sent();
                            if (!(this._localMedia && this._localMedia.getVideoTrack())) return [3 , 9];
                            if (!notifyMediaFeature) return [3 , 9];
                            _a.label = 3;
                        case 3:
                            _a.trys.push([3, 7, , 9]);
                            return [4 , this.notifyCallMediaState({ video: true })];
                        case 4:
                            result = _a.sent();
                            if (!!result) return [3 , 6];
                            return [4 , this.toggleVideoMute(!mute, false)];
                        case 5:
                            _a.sent();
                            _a.label = 6;
                        case 6: return [3 , 9];
                        case 7:
                            err_4 = _a.sent();
                            return [4 , this.toggleVideoMute(!mute, false)];
                        case 8:
                            _a.sent();
                            throw err_4;
                        case 9: return [2 , result];
                    }
                });
            });
        };
        Call.prototype.toggleRemoteAudioMute = function (mute) {
            return __awaiter$4(this, void 0, void 0, function () {
                var result;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1: return [4 , this.toggleMediaTrackMuted(this._remoteMedia ? this._remoteMedia.getAudioTrack() : null, mute)];
                        case 2:
                            result = _a.sent();
                            if (this._remoteMedia && this._remoteMedia.getAudioTrack()) {
                                this.publishLastCallInfo();
                            }
                            return [2 , result];
                    }
                });
            });
        };
        Call.prototype.toggleRemoteVideoMute = function (mute) {
            return __awaiter$4(this, void 0, void 0, function () {
                var result;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1: return [4 , this.toggleMediaTrackMuted(this._remoteMedia ? this._remoteMedia.getVideoTrack() : null, mute)];
                        case 2:
                            result = _a.sent();
                            if (this._remoteMedia && this._remoteMedia.getVideoTrack()) {
                                this.publishLastCallInfo();
                            }
                            return [2 , result];
                    }
                });
            });
        };
        Call.prototype.isAudioEnabled = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                return __generator$4(this, function (_a) {
                    if (this.callIsForApp) {
                        return [2 , false];
                    }
                    else {
                        return [2 , this._remoteDescription ? !!this.retriveCallMediaFromSessionDescription(this._remoteDescription).audio : true];
                    }
                });
            });
        };
        Call.prototype.isVideoEnabled = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                return __generator$4(this, function (_a) {
                    if (this.callIsForApp) {
                        return [2 , false];
                    }
                    else {
                        return [2 , this._remoteDescription ? !!this.retriveCallMediaFromSessionDescription(this._remoteDescription).video : true];
                    }
                });
            });
        };
        Call.prototype.startAudio = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                var newMedia;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1: return [4 , this.isAudioEnabled()];
                        case 2:
                            if (!_a.sent()) return [3 , 7];
                            if (!this._localMedia) return [3 , 6];
                            if (!!this._localCallMedia.audio) return [3 , 5];
                            newMedia = __assign({}, this._localCallMedia);
                            newMedia.audio = true;
                            return [4 , this.setLocalMedia(newMedia, this._mediaConstraints)];
                        case 3:
                            _a.sent();
                            return [4 , this.toggleAudioMute(false, false)];
                        case 4:
                            _a.sent();
                            _a.label = 5;
                        case 5: return [2 , true];
                        case 6: return [2 , false];
                        case 7: throw new Error("Unable to start audio, remote peer is not supporting");
                    }
                });
            });
        };
        Call.prototype.stopAudio = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                var newMedia;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1: return [4 , this.toggleAudioMute(true, false)];
                        case 2:
                            _a.sent();
                            if (!this._localMedia) return [3 , 5];
                            if (!this._localCallMedia.audio) return [3 , 4];
                            newMedia = __assign({}, this._localCallMedia);
                            delete newMedia.audio;
                            return [4 , this.setLocalMedia(newMedia, this._mediaConstraints)];
                        case 3:
                            _a.sent();
                            _a.label = 4;
                        case 4: return [2 , true];
                        case 5: return [2 , false];
                    }
                });
            });
        };
        Object.defineProperty(Call.prototype, "audioLinkStatus", {
            get: function () {
                if (this.callIsForApp) {
                    return null;
                }
                else {
                    return this._localMedia ? (this._localMedia.getAudioTrack() ? (this._localMedia.getAudioTrack().getMuted() ? CallMediaLinkStatus.MUTE : CallMediaLinkStatus.UNMUTE) : null) : null;
                }
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "audioRemoteLinkStatus", {
            get: function () {
                if (this.callIsForApp) {
                    return null;
                }
                else {
                    return this._remoteMedia ? (this._remoteMedia.getAudioTrack() ? (this._remoteMedia.getAudioTrack().getMuted() ? CallMediaLinkStatus.MUTE : CallMediaLinkStatus.UNMUTE) : null) : null;
                }
            },
            enumerable: false,
            configurable: true
        });
        Call.prototype.startVideo = function (mediaConstraints, videoContainer) {
            return __awaiter$4(this, void 0, void 0, function () {
                var newMedia;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1: return [4 , this.isVideoEnabled()];
                        case 2:
                            if (!_a.sent()) return [3 , 7];
                            if (!(this._localMedia && !this._localCallMedia.video)) return [3 , 5];
                            this.videoContainer = videoContainer;
                            if (mediaConstraints && this._mediaConstraints) {
                                this._mediaConstraints.local.video = new LocalMediaConfigurationConstraints(mediaConstraints);
                            }
                            newMedia = __assign({}, this._localCallMedia);
                            newMedia.video = true;
                            return [4 , this.setLocalMedia(newMedia, this._mediaConstraints)];
                        case 3:
                            _a.sent();
                            return [4 , this.toggleVideoMute(false, false)];
                        case 4:
                            _a.sent();
                            return [2 , this.notifyVideoStartOrStop()];
                        case 5: return [2 , false];
                        case 6: return [3 , 8];
                        case 7: throw new Error("Unable to start video, remote peer is not supporting");
                        case 8: return [2 ];
                    }
                });
            });
        };
        Call.prototype.stopVideo = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                var newMedia;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1: return [4 , this.toggleVideoMute(true, false)];
                        case 2:
                            _a.sent();
                            if (!(this._localMedia && this._localCallMedia.video)) return [3 , 4];
                            newMedia = __assign({}, this._localCallMedia);
                            delete newMedia.video;
                            return [4 , this.setLocalMedia(newMedia, this._mediaConstraints)];
                        case 3:
                            _a.sent();
                            return [2 , this.notifyVideoStartOrStop()];
                        case 4: return [2 , false];
                    }
                });
            });
        };
        Object.defineProperty(Call.prototype, "videoLinkStatus", {
            get: function () {
                if (this.callIsForApp) {
                    return null;
                }
                else {
                    return this._localMedia ? (this._localMedia.getVideoTrack() ? (this._localMedia.getVideoTrack().getMuted() ? CallMediaLinkStatus.MUTE : CallMediaLinkStatus.UNMUTE) : null) : null;
                }
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(Call.prototype, "videoRemoteLinkStatus", {
            get: function () {
                if (this.callIsForApp) {
                    return null;
                }
                else {
                    return this._remoteMedia ? (this._remoteMedia.getVideoTrack() ? (this._remoteMedia.getVideoTrack().getMuted() ? CallMediaLinkStatus.MUTE : CallMediaLinkStatus.UNMUTE) : null) : null;
                }
            },
            enumerable: false,
            configurable: true
        });
        Call.prototype.toggleMediaTrackMuted = function (mediaTrack, mute) {
            if (mediaTrack) {
                if (typeof mute === "boolean") {
                    if (mute !== mediaTrack.getMuted()) {
                        mediaTrack.setMuted(mute);
                    }
                }
                else {
                    mediaTrack.setMuted(!mediaTrack.getMuted());
                }
                return mediaTrack.getMuted();
            }
            else {
                return false;
            }
        };
        Call.prototype.unsetLocalView = function () {
            if (!this.callIsForApp && this._mediaEnabled && this._localMedia && this._localMediaStarted && (this._layoutManager || this._manager.layoutManager)) {
                (this._layoutManager || this._manager.layoutManager).unsetLocalView();
            }
        };
        Call.prototype.setLocalView = function () {
            if (!this.callIsForApp && this._mediaEnabled && this._localMedia && this._localMediaStarted && (this._layoutManager || this._manager.layoutManager)) {
                var localView = this._localMedia.getView();
                if (localView) {
                    (this._layoutManager || this._manager.layoutManager).setLocalView(localView);
                }
            }
        };
        Call.prototype.unsetRemoteView = function () {
            if (!this.callIsForApp && (this._layoutManager || this._manager.layoutManager)) {
                (this._layoutManager || this._manager.layoutManager).removeRemoteViews();
            }
        };
        Call.prototype.setRemoteView = function () {
            if (!this.callIsForApp && (this._layoutManager || this._manager.layoutManager)) {
                var remoteView = this._remoteMedia.getView();
                if (remoteView) {
                    this._remoteMedia.getViewSink().setViewScale(icelink.LayoutScale.Contain);
                    (this._layoutManager || this._manager.layoutManager).addRemoteView(this._remoteMedia.getId(), remoteView);
                }
            }
        };
        Call.prototype.stopConnectionStats = function () {
            this._mediaStreamStats.stop();
            this._localAudioLevel.stop();
            this._remoteAudioLevel.stop();
        };
        Call.prototype.startConnectionStats = function () {
            if (!this.callIsForApp) {
                this._mediaStreamStats.active = true;
            }
        };
        Call.prototype.getMediaStreamStats = function () {
            return this._mediaStreamStats.start();
        };
        Call.prototype.startLocalMedia = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                var localMedia, error_1;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , this._localMedia];
                        case 1:
                            if (!(!this._mediaEnabled || this._localMediaStarted)) return [3 , 2];
                            return [2 , this._localMedia];
                        case 2:
                            _a.trys.push([2, 4, , 5]);
                            return [4 , icelinkUtils.futureToPromise(this._localMedia.start())];
                        case 3:
                            localMedia = _a.sent();
                            this._localMediaStarted = true;
                            this.setLocalView();
                            this._localAudioLevel.media = localMedia;
                            return [2 , localMedia];
                        case 4:
                            error_1 = _a.sent();
                            if (this._localCallMedia.desktop && icelink.Plugin.getChromeExtensionRequired() && !icelink.Plugin.getChromeExtensionInstalled()) {
                                throw new icelink.Exception(error_1.message + "\n\nClick \"Install Screen-Sharing Extension\" to install screen-sharing extension.");
                            }
                            else {
                                throw error_1;
                            }
                        case 5: return [2 ];
                    }
                });
            });
        };
        Call.prototype.stopLocalMedia = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                var localMedia;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , this._localMedia];
                        case 1:
                            if (!(this._mediaEnabled && this._localMediaStarted)) return [3 , 3];
                            return [4 , icelinkUtils.futureToPromise(this._localMedia.stop())];
                        case 2:
                            localMedia = _a.sent();
                            this._localMediaStarted = false;
                            return [2 , localMedia];
                        case 3: return [2 , this._localMedia];
                    }
                });
            });
        };
        Call.prototype.changeVideoConstraints = function (constraints) {
            return __awaiter$4(this, void 0, void 0, function () {
                var webRtcLocalMedia, err_5;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1:
                            this._log.debug(this._callId + " - changeVideoConstraints", constraints);
                            if (!(this._localMedia && this._localMediaStarted)) return [3 , 10];
                            if (!this._localCallMedia.video) return [3 , 8];
                            webRtcLocalMedia = icelinkUtils.tryInternal(this._localMedia, { m: "_getInternal" });
                            if (!webRtcLocalMedia) return [3 , 6];
                            _a.label = 2;
                        case 2:
                            _a.trys.push([2, 4, , 5]);
                            return [4 , icelinkUtils.futureToPromise(webRtcLocalMedia.changeVideoConstraints(constraints))];
                        case 3:
                            _a.sent();
                            this._log.debug(this._callId + " - changeVideoConstraints OK");
                            return [2 , true];
                        case 4:
                            err_5 = _a.sent();
                            this._log.error(this._callId + " - changeVideoConstraints error", err_5);
                            throw err_5;
                        case 5: return [3 , 7];
                        case 6:
                            this._log.error(this._callId + " - LocalMedia is not native webrtc");
                            throw new Error("LocalMedia is not native webrtc");
                        case 7: return [3 , 9];
                        case 8:
                            this._log.error(this._callId + " - LocalMedia has not video enabled");
                            throw new Error("LocalMedia has not video enabled");
                        case 9: return [3 , 11];
                        case 10:
                            this._log.error(this._callId + " - LocalMedia is not started");
                            throw new Error("LocalMedia is not started");
                        case 11: return [2 ];
                    }
                });
            });
        };
        Call.prototype.changeAudioConstraints = function (constraints) {
            return __awaiter$4(this, void 0, void 0, function () {
                var webRtcLocalMedia, err_6;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1:
                            this._log.debug(this._callId + " - changeAudioConstraints", constraints);
                            if (!(this._localMedia && this._localMediaStarted)) return [3 , 10];
                            if (!this._localCallMedia.audio) return [3 , 8];
                            webRtcLocalMedia = icelinkUtils.tryInternal(this._localMedia, { m: "_getInternal" });
                            if (!webRtcLocalMedia) return [3 , 6];
                            _a.label = 2;
                        case 2:
                            _a.trys.push([2, 4, , 5]);
                            return [4 , icelinkUtils.futureToPromise(webRtcLocalMedia.changeAudioConstraints(constraints))];
                        case 3:
                            _a.sent();
                            this._log.debug(this._callId + " - changeAudioConstraints OK");
                            return [2 , true];
                        case 4:
                            err_6 = _a.sent();
                            this._log.error(this._callId + " - changeAudioConstraints error", err_6);
                            throw err_6;
                        case 5: return [3 , 7];
                        case 6:
                            this._log.error(this._callId + " - LocalMedia is not native webrtc");
                            throw new Error("LocalMedia is not native webrtc");
                        case 7: return [3 , 9];
                        case 8:
                            this._log.error(this._callId + " - LocalMedia has not audio enabled");
                            throw new Error("LocalMedia has not audio enabled");
                        case 9: return [3 , 11];
                        case 10:
                            this._log.error(this._callId + " - LocalMedia is not started");
                            throw new Error("LocalMedia is not started");
                        case 11: return [2 ];
                    }
                });
            });
        };
        Call.prototype.changeLocalMedia = function (media, mediaConstraints) {
            return __awaiter$4(this, void 0, void 0, function () {
                var previousLocalMedia, nativePeerConnection_1, newMediaTrack, err_7, prevCallIsOffer, prevRemoteDescription;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , false];
                        case 1:
                            previousLocalMedia = this._localMedia;
                            this._localMediaStarted = false;
                            return [4 , this.setLocalMedia(media, mediaConstraints)];
                        case 2: return [4 , (_a.sent()).startLocalMedia()];
                        case 3:
                            _a.sent();
                            nativePeerConnection_1 = icelinkUtils.tryInternal(this._connection, { m: "_getInternal" }, { m: "getNativePeerConnection" });
                            nativePeerConnection_1.getSenders().forEach(function (t) {
                                nativePeerConnection_1.removeTrack(t);
                            });
                            newMediaTrack = [];
                            try {
                                newMediaTrack.push(icelinkUtils.tryInternal(this._localMedia.getAudioTrack(), { m: "_getInternal" }));
                            }
                            catch (e) { }
                            try {
                                newMediaTrack.push(icelinkUtils.tryInternal(this._localMedia.getVideoTrack(), { m: "_getInternal" }));
                            }
                            catch (e) { }
                            newMediaTrack.forEach(function (localMediaTrack) {
                                if (!localMediaTrack) {
                                    return;
                                }
                                var nativeMediaStreamTrack = icelinkUtils.tryInternal(localMediaTrack, { m: "_getMediaStreamTrack" });
                                if (nativeMediaStreamTrack) {
                                    var nativeMediaStream = icelinkUtils.tryInternal(localMediaTrack.getMedia(), {
                                        m: nativeMediaStreamTrack.kind == "audio" ? "_getAudioMediaStream" : "_getVideoMediaStream",
                                    });
                                    if (nativeMediaStream) {
                                        nativePeerConnection_1.addTrack(nativeMediaStreamTrack, nativeMediaStream);
                                    }
                                }
                            });
                            _a.label = 4;
                        case 4:
                            _a.trys.push([4, 6, , 7]);
                            return [4 , icelinkUtils.futureToPromise(previousLocalMedia.stop())];
                        case 5:
                            _a.sent();
                            return [3 , 7];
                        case 6:
                            err_7 = _a.sent();
                            this._log.error("Error on stop previousLocalMedia", err_7);
                            return [3 , 7];
                        case 7:
                            try {
                                this._connection.getAudioStream().changeDirection(icelink.StreamDirection.SendReceive);
                                this._connection.getAudioStream().setLocalSend(media.audio);
                            }
                            catch (e) { }
                            try {
                                this._connection.getVideoStream().changeDirection(icelink.StreamDirection.SendReceive);
                                this._connection.getVideoStream().setLocalSend(media.video);
                            }
                            catch (e) { }
                            prevCallIsOffer = this._isOffer;
                            prevRemoteDescription = this._remoteDescription;
                            this._isOffer = true;
                            this._remoteDescription = null;
                            return [4 , this.createAndSetLocalDescription(true)];
                        case 8:
                            _a.sent();
                            this._isOffer = prevCallIsOffer;
                            this._remoteDescription = prevRemoteDescription;
                            return [2 , true];
                    }
                });
            });
        };
        Call.prototype.setLocalMedia = function (media, mediaConfiguration) {
            return __awaiter$4(this, void 0, void 0, function () {
                var mdiff, m, m, audioEnable, videoEnable, desktopEnable, datachannelEnable, audioConfig, videoConfig, constraints, _a;
                return __generator$4(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            if (!this.callIsForApp) return [3 , 1];
                            return [2 , this];
                        case 1:
                            if (!this._mediaEnabled) {
                                return [2 , this];
                            }
                            if (!this._localMediaStarted) return [3 , 4];
                            mdiff = 0;
                            for (m in this.localCallMedia) {
                                if (!media[m]) {
                                    mdiff++;
                                }
                            }
                            if (mdiff === 0) {
                                for (m in media) {
                                    if (!this._localCallMedia[m]) {
                                        mdiff++;
                                    }
                                }
                            }
                            if (!(mdiff > 0)) return [3 , 3];
                            return [4 , this.changeLocalMedia(media, mediaConfiguration)];
                        case 2:
                            _b.sent();
                            _b.label = 3;
                        case 3: return [2 , this];
                        case 4:
                            this._localCallMedia = media ? media : {};
                            if (Object.keys(this._localCallMedia).length === 0) {
                                throw new Error("Parameter error, audio or video or desktop must be set");
                            }
                            this._mediaConstraints = new MediaConfiguration(mediaConfiguration);
                            audioEnable = !!this._localCallMedia.audio;
                            videoEnable = !!this._localCallMedia.video;
                            desktopEnable = !!this._localCallMedia.desktop;
                            datachannelEnable = !!this._localCallMedia.data;
                            audioConfig = audioEnable;
                            videoConfig = videoEnable || desktopEnable ? {} : false;
                            if (!!(this._mediaConstraints || null) && this._mediaConstraints.local) {
                                constraints = this._mediaConstraints.local;
                                if (audioConfig && constraints.audio && constraints.audio.constraints) {
                                    audioConfig = __assign({}, constraints.audio.constraints);
                                }
                                if (videoConfig && constraints.video && constraints.video.constraints) {
                                    videoConfig = __assign({}, constraints.video.constraints);
                                }
                            }
                            if (videoConfig) {
                                videoConfig.width = desktopEnable ? window.screen.width : videoConfig.width;
                                videoConfig.height = desktopEnable ? window.screen.height : videoConfig.height;
                                videoConfig.frameRate = desktopEnable ? 3 : videoConfig.frameRate;
                            }
                            if (audioConfig) {
                                this._log.info("local audio is enabled - constraints " + JSON.stringify(audioConfig, MapOrSet_toJSON));
                            }
                            if (!!videoConfig && !desktopEnable) {
                                this._log.info("local video is enabled - constraints " + JSON.stringify(videoConfig, MapOrSet_toJSON));
                            }
                            _a = videoConfig;
                            if (!_a) return [3 , 6];
                            return [4 , this._manager.device.getMediaDeviceAvailable()];
                        case 5:
                            _a = !(_b.sent()).video_input;
                            _b.label = 6;
                        case 6:
                            if (_a) {
                                videoConfig = false;
                            }
                            this._localMedia = new icelink.LocalMedia(audioConfig, videoConfig, desktopEnable);
                            if (datachannelEnable) {
                                this._dataChannel = new icelink.DataChannel(icelink.Guid.newGuid().toString());
                            }
                            if (audioEnable && this._manager.device.audioInput) {
                                this._localMedia.changeAudioSourceInput(this._manager.device.audioInput);
                            }
                            if (videoConfig && !desktopEnable && typeof this._manager.device.videoInput !== "boolean" && this._manager.device.videoInput) {
                                this._localMedia.changeVideoSourceInput(this._manager.device.videoInput);
                            }
                            return [2 , this];
                    }
                });
            });
        };
        Call.prototype.notifyLastControlMessage = function (cleanMedia) {
            var _this = this;
            var controlMessage = Object.assign({}, this._lastControlMessage);
            controlMessage.device = this._device;
            controlMessage._isFromServer = false;
            if (cleanMedia) {
                if (controlMessage.local_media_feature) {
                    controlMessage.local_media_feature = null;
                }
                if (controlMessage.media) {
                    controlMessage.media = null;
                }
                controlMessage.media_feature = null;
                controlMessage.remote_media_status = null;
            }
            setTimeout(function () { return _this._controlMessageNotifier.next(controlMessage); });
        };
        Call.prototype.notifyVideoStartOrStop = function () {
            return __awaiter$4(this, void 0, void 0, function () {
                return __generator$4(this, function (_a) {
                    if (this.callIsForApp) {
                        return [2 , false];
                    }
                    else {
                        if (this.channelType === ChannelType.Video) {
                            this.notifyLastControlMessage(true);
                            return [2 , true];
                        }
                        else {
                            if (this._localCallMedia.video) {
                                return [2 , this._manager.methods.startVideoOnCall(this._callId).toPromise()];
                            }
                            else {
                                return [2 , this._manager.methods.stopVideoOnCall(this._callId).toPromise()];
                            }
                        }
                    }
                });
            });
        };
        Call.prototype.notifyCallMediaState = function (media) {
            return __awaiter$4(this, void 0, void 0, function () {
                var mediaMapMuted_1, m, mediaTrack, mediaParam, response;
                var _this = this;
                return __generator$4(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!(!this.callIsForApp && media && Object.keys(media).length)) return [3 , 5];
                            if (!this._manager.options.notifyMediaFeature) return [3 , 4];
                            if (!(this.channelType === ChannelType.Video)) return [3 , 1];
                            this.notifyLastControlMessage(true);
                            return [2 , true];
                        case 1:
                            mediaMapMuted_1 = new Map();
                            for (m in media) {
                                if (m && this._localCallMedia[m]) {
                                    mediaTrack = null;
                                    switch (m) {
                                        case CallMedia.audio:
                                            mediaTrack = this._localMedia.getAudioTrack();
                                            break;
                                        case CallMedia.video:
                                            mediaTrack = this._localMedia.getVideoTrack();
                                            break;
                                    }
                                    if (mediaTrack) {
                                        mediaParam = mediaMapMuted_1.get(mediaTrack.getMuted());
                                        if (!mediaParam) {
                                            mediaParam = {};
                                            mediaMapMuted_1.set(mediaTrack.getMuted(), mediaParam);
                                        }
                                        mediaParam[m] = true;
                                    }
                                }
                            }
                            return [4 , Promise.all([
                                    (function () { return __awaiter$4(_this, void 0, void 0, function () {
                                        var media;
                                        return __generator$4(this, function (_a) {
                                            media = mediaMapMuted_1.get(true);
                                            return [2 , media ? this._manager.methods.notifyMute(this._callId, media).toPromise() : true];
                                        });
                                    }); })(),
                                    (function () { return __awaiter$4(_this, void 0, void 0, function () {
                                        var media;
                                        return __generator$4(this, function (_a) {
                                            media = mediaMapMuted_1.get(false);
                                            return [2 , media ? this._manager.methods.notifyUnmute(this._callId, media).toPromise() : true];
                                        });
                                    }); })(),
                                ])];
                        case 2:
                            response = _a.sent();
                            return [2 , response[0] && response[1]];
                        case 3: return [3 , 5];
                        case 4: return [2 , true];
                        case 5: return [2 , false];
                    }
                });
            });
        };
        Call.prototype.publishLastCallInfo = function () {
            var callInfo = Object.assign({}, this._lastControlMessage);
            callInfo._isFromServer = false;
            this._controlMessageNotifier.next(callInfo);
        };
        return Call;
    }());
    var MonitorMediaStreamStats =  (function () {
        function MonitorMediaStreamStats(call) {
            this.call = call;
            this._mediaStreamStats = null;
            this._mediaStreamStatsPublisher = null;
            this._mediaStreamStatsSubscription = Subscription.EMPTY;
            this._active = false;
            this._log = Log$1.of("webrtc:call:stats", call.manager.client);
        }
        Object.defineProperty(MonitorMediaStreamStats.prototype, "active", {
            set: function (active) {
                this._active = active;
                this.activate();
            },
            enumerable: false,
            configurable: true
        });
        MonitorMediaStreamStats.prototype.start = function () {
            var _this = this;
            if (!this._mediaStreamStats) {
                this._log.info("start");
                this._mediaStreamStats = new Observable(function (publisher) {
                    if (_this._mediaStreamStats) {
                        _this._mediaStreamStatsPublisher = publisher;
                        _this.activate();
                    }
                    else {
                        publisher.error(new Error("monitorMediaStreamStats is ended"));
                    }
                    return function () { return _this.stop(); };
                }).pipe(share());
            }
            return this._mediaStreamStats;
        };
        MonitorMediaStreamStats.prototype.stop = function () {
            if (this._mediaStreamStatsSubscription !== Subscription.EMPTY)
                this._log.info("stop");
            this._mediaStreamStatsSubscription.unsubscribe();
            this._mediaStreamStatsSubscription = Subscription.EMPTY;
        };
        MonitorMediaStreamStats.prototype.end = function () {
            if (this._mediaStreamStats)
                this._log.info("end");
            this.stop();
            if (this._mediaStreamStatsPublisher) {
                this._mediaStreamStatsPublisher.complete();
                this._mediaStreamStatsPublisher = null;
            }
            this._mediaStreamStats = null;
        };
        MonitorMediaStreamStats.prototype.activate = function () {
            var _this = this;
            this.stop();
            if (this._active && this._mediaStreamStatsPublisher && this._mediaStreamStatsSubscription === Subscription.EMPTY) {
                this._log.info("activate");
                this._mediaStreamStatsSubscription = interval(1000).subscribe(function () { return __awaiter$4(_this, void 0, void 0, function () {
                    var connectionStats, err_8, mediaStreamsStats;
                    var _this = this;
                    return __generator$4(this, function (_a) {
                        switch (_a.label) {
                            case 0:
                                _a.trys.push([0, 2, , 3]);
                                return [4 , icelinkUtils.futureToPromise(this.call.connection.getStats())];
                            case 1:
                                connectionStats = _a.sent();
                                return [3 , 3];
                            case 2:
                                err_8 = _a.sent();
                                this._log.error("Error on retrive connection stats", err_8);
                                return [3 , 3];
                            case 3:
                                if (connectionStats) {
                                    mediaStreamsStats = connectionStats.getMediaStreams();
                                    if (mediaStreamsStats && mediaStreamsStats.length) {
                                        mediaStreamsStats.forEach(function (ms) {
                                            if (icelink.StreamType.Audio === ms.getType() || icelink.StreamType.Video === ms.getType()) {
                                                _this._mediaStreamStatsPublisher.next(ms);
                                            }
                                        });
                                    }
                                }
                                return [2 ];
                        }
                    });
                }); });
            }
        };
        return MonitorMediaStreamStats;
    }());
    var MonitorAudioLevel =  (function () {
        function MonitorAudioLevel(id, call) {
            this.id = id;
            this.call = call;
            this._audioLevelPublisher = null;
            this._audioLevelSubscription = Subscription.EMPTY;
            this._audioLevelObservable = null;
            this._log = Log$1.of("webrtc:call:audioLevel", call.manager.client);
        }
        Object.defineProperty(MonitorAudioLevel.prototype, "media", {
            set: function (media) {
                this._media = media;
                this.activate();
            },
            enumerable: false,
            configurable: true
        });
        MonitorAudioLevel.prototype.start = function () {
            var _this = this;
            if (!this._audioLevelObservable) {
                this._log.info("start " + this.id);
                this._audioLevelObservable = new Observable(function (publisher) {
                    if (_this._audioLevelObservable) {
                        _this._audioLevelPublisher = publisher;
                        _this.activate();
                    }
                    else {
                        publisher.error(new Error(_this.id + " monitorAudioLevel is ended"));
                    }
                    return function () { return _this.stop(); };
                }).pipe(share());
            }
            return this._audioLevelObservable;
        };
        MonitorAudioLevel.prototype.stop = function () {
            if (this._audioLevelSubscription !== Subscription.EMPTY)
                this._log.info("stop " + this.id);
            this._audioLevelSubscription.unsubscribe();
            this._audioLevelSubscription = Subscription.EMPTY;
        };
        MonitorAudioLevel.prototype.end = function () {
            if (this._audioLevelObservable)
                this._log.info("end " + this.id);
            this.stop();
            if (this._audioLevelPublisher) {
                this._audioLevelPublisher.complete();
                this._audioLevelPublisher = null;
            }
            this._audioLevelObservable = null;
        };
        MonitorAudioLevel.prototype.activate = function () {
            var _this = this;
            this.stop();
            if (this._media && this._audioLevelPublisher) {
                this._log.info("activate " + this.id);
                this._audioLevelSubscription = icelinkUtils.audioTrackLevelToObservable(this._media, this.call.manager.options.mediaConfiguration.audioLevelUpdateIntervalInMS).subscribe(function (value) { return _this._audioLevelPublisher.next(value); }, function (err) { return _this._audioLevelPublisher.error(err); });
            }
        };
        return MonitorAudioLevel;
    }());
    var CallChecker =  (function (_super) {
        __extends$2(CallChecker, _super);
        function CallChecker(manager, webrtcControlMessageNotifier, connectionState, callId, channelType, isOffer, state, realState) {
            var _this = _super.call(this, manager, webrtcControlMessageNotifier, connectionState, callId, channelType, isOffer, state, realState) || this;
            _this._toneSignalEnabled = false;
            return _this;
        }
        return CallChecker;
    }(Call$1));
    var CallOmnidesk =  (function (_super) {
        __extends$2(CallOmnidesk, _super);
        function CallOmnidesk(manager, webrtcControlMessageNotifier, callId, state) {
            return _super.call(this, manager, webrtcControlMessageNotifier, null, callId, ChannelType.Omnidesk, false, state, true) || this;
        }
        return CallOmnidesk;
    }(Call$1));

    var WebRTCMediaField =  (function () {
        function WebRTCMediaField(config, prefix) {
            this.loop = false;
            this.volume = 100;
            this.maxlength = null;
            this.interval = null;
            if (!config)
                return;
            loadConfig(prefix, WebRTCMediaField.CHECK_OPTIONS, this, config);
        }
        WebRTCMediaField.CHECK_OPTIONS = {
            mandatory: {
                src: stringCheck,
            },
            optional: {
                loop: booleanCheck,
                volume: function (volume) {
                    var value = numberCheck(volume);
                    if (value == undefined)
                        return value;
                    if (value < 0 || value > 100) {
                        throw new Error("Value is outside range 0÷100");
                    }
                    else {
                        return value;
                    }
                },
                maxlength: numberCheck,
                interval: numberCheck,
            },
        };
        return WebRTCMediaField;
    }());

    var ring = "data:audio/webm; codecs=opus;base64, ";
    var ringback = "data:audio/webm; codecs=opus;base64, ";
    var ringAdvertising = "data:audio/webm; codecs=opus;base64, ";
    var busy = "data:audio/webm; codecs=opus;base64, ";
    var congestion = "data:audio/webm; codecs=opus;base64, ";
    var defaultPhoneSignal = {
        ring: {},
        ringback: {},
        ringAdvertising: {},
        busy: {},
        congestion: {},
        dialtone: {},
        hold: {},
        dtmf: {},
    };
    defaultPhoneSignal.ring = {
        src: ring,
        loop: true,
        interval: 500,
    };
    defaultPhoneSignal.ringback = {
        src: ringback,
        loop: true,
        interval: 3700,
    };
    defaultPhoneSignal.ringAdvertising = {
        src: ringAdvertising,
        volume: 15,
        loop: true,
        interval: 3000,
    };
    defaultPhoneSignal.busy = {
        src: busy,
        loop: true,
        maxlength: 3000,
    };
    defaultPhoneSignal.congestion = {
        src: congestion,
        loop: true,
        maxlength: 3000,
    };
    defaultPhoneSignal.dialtone = null;
    defaultPhoneSignal.hold = null;
    defaultPhoneSignal.dtmf = null;

    var WebRTCMediaAudioSignal =  (function () {
        function WebRTCMediaAudioSignal(config, prefix) {
            this.ring = defaultPhoneSignal.ring;
            this.ringback = defaultPhoneSignal.ringback;
            this.ringAdvertising = defaultPhoneSignal.ringAdvertising;
            this.dialtone = defaultPhoneSignal.dialtone;
            this.busy = defaultPhoneSignal.busy;
            this.congestion = defaultPhoneSignal.congestion;
            this.hold = defaultPhoneSignal.hold;
            this.dtmf = defaultPhoneSignal.dtmf;
            if (!config)
                return;
            for (var tone in config) {
                if (!this.hasOwnProperty(tone)) {
                    throw ConfigurationError.newInstance(arrayConcat(prefix).join("."), config[tone], new Error(tone + " is not valid media audio signal"));
                }
            }
            loadConfig(prefix, WebRTCMediaAudioSignal.CHECK_OPTIONS, this, config);
        }
        WebRTCMediaAudioSignal.CHECK_OPTIONS = {
            mandatory: {},
            optional: {
                ring: function (source, destination, prefix) { return loadConfig(arrayConcat(prefix, ["ring"]), WebRTCMediaField.CHECK_OPTIONS, destination, source); },
                ringback: function (source, destination, prefix) { return loadConfig(arrayConcat(prefix, ["ringback"]), WebRTCMediaField.CHECK_OPTIONS, destination, source); },
                ringAdvertising: function (source, destination, prefix) { return loadConfig(arrayConcat(prefix, ["ringAdvertising"]), WebRTCMediaField.CHECK_OPTIONS, destination, source); },
                dialtone: function (source, destination, prefix) { return loadConfig(arrayConcat(prefix, ["dialtone"]), WebRTCMediaField.CHECK_OPTIONS, destination, source); },
                busy: function (source, destination, prefix) { return loadConfig(arrayConcat(prefix, ["busy"]), WebRTCMediaField.CHECK_OPTIONS, destination, source); },
                congestion: function (source, destination, prefix) { return loadConfig(arrayConcat(prefix, ["congestion"]), WebRTCMediaField.CHECK_OPTIONS, destination, source); },
                hold: function (source, destination, prefix) { return loadConfig(arrayConcat(prefix, ["hold"]), WebRTCMediaField.CHECK_OPTIONS, destination, source); },
                dtmf: function (source, destination, prefix) {
                    for (var dtmf in source) {
                        if (destination.hasOwnProperty(dtmf)) {
                            if (source[dtmf]) {
                                loadConfig(arrayConcat(prefix, ["dtmf", dtmf]), WebRTCMediaField.CHECK_OPTIONS, destination[dtmf], source[dtmf]);
                            }
                            else {
                                destination[dtmf] = null;
                            }
                        }
                        else {
                            throw ConfigurationError.newInstance(arrayConcat(prefix, ["dtmf"]).join("."), source[dtmf], new Error(dtmf + " is not valid dtmf"));
                        }
                    }
                },
            },
        };
        return WebRTCMediaAudioSignal;
    }());
    var MediaSignal;
    (function (MediaSignal) {
        MediaSignal["ring"] = "ring";
        MediaSignal["ringback"] = "ringback";
        MediaSignal["ringAdvertising"] = "ringAdvertising";
        MediaSignal["dialtone"] = "dialtone";
        MediaSignal["busy"] = "busy";
        MediaSignal["congestion"] = "congestion";
        MediaSignal["hold"] = "hold";
    })(MediaSignal || (MediaSignal = {}));

    var WebRTCMediaSignal =  (function () {
        function WebRTCMediaSignal(options, prefix) {
            this.audioenabled = true;
            this.volume = 100;
            this.audio = new WebRTCMediaAudioSignal();
            this.dtmfDuration = 120;
            this.dtmfInterToneGap = 120;
            if (!options)
                return;
            loadConfig(prefix, WebRTCMediaSignal.CHECK_OPTIONS, this, options);
        }
        WebRTCMediaSignal.CHECK_OPTIONS = {
            mandatory: {
                audioenabled: booleanCheck,
            },
            optional: {
                volume: function (volume) {
                    var value = numberCheck(volume);
                    if (value == undefined)
                        return value;
                    if (value < 0 || value > 100) {
                        throw new Error("Value is outside range 0÷100");
                    }
                    else {
                        return value;
                    }
                },
                dtmfDuration: function (volume) {
                    var value = numberCheck(volume);
                    if (value == undefined)
                        return value;
                    if (value < 40 || value > 2000) {
                        throw new Error("Value is outside range 0÷2000");
                    }
                    else {
                        return value;
                    }
                },
                dtmfInterToneGap: function (volume) {
                    var value = numberCheck(volume);
                    if (value == undefined)
                        return value;
                    if (value < 40 || value > 2000) {
                        throw new Error("Value is outside range 0÷2000");
                    }
                    else {
                        return value;
                    }
                },
                audio: function (audio, destination, prefix) {
                    var value = objectCheck(audio);
                    return value ? new WebRTCMediaAudioSignal(value, arrayConcat(prefix, ["audio"])) : value;
                },
            },
        };
        return WebRTCMediaSignal;
    }());

    var WebrtcConfig =  (function () {
        function WebrtcConfig(options, prefix) {
            this.enabled = false;
            this.enabledOnChannel = [ChannelType.PhoneCall, ChannelType.Video];
            this.trickleIcePolicy = TrickleIcePolicy.FullTrickle;
            this.iceGatherPolicy = IceGatherPolicy.All;
            this.audioDeviceInput = null;
            this.videoDeviceInput = null;
            this.audioDeviceOutput = null;
            this.audioDeviceSignalOutput = null;
            this.videoStreamInOffer = true;
            this.immediateRingback = false;
            this.connectionTimeout = 7200000;
            this.deadStreamTimeout = 7200000;
            this.videoContainer = null;
            this.mediaConfiguration = new MediaConfiguration();
            this.notifyAvailableMedia = false;
            this.notifyMediaFeature = true;
            this.mediaSignal = new WebRTCMediaSignal();
            if (!options)
                return;
            loadConfig(prefix, WebrtcConfig.CHECK_OPTIONS, this, options);
        }
        WebrtcConfig.CHECK_OPTIONS = {
            mandatory: {},
            optional: {
                enabled: booleanCheck,
                enabledOnChannel: function (channels) {
                    if (channels) {
                        if (Array.isArray(channels)) {
                            for (var i = 0; i < channels.length; i++) {
                                if (channelTypeToId(channels[i]) === null) {
                                    return undefined;
                                }
                            }
                        }
                        else {
                            return undefined;
                        }
                    }
                    return channels;
                },
                iceServers: function (iceServers) {
                    if (!Array.isArray(iceServers)) {
                        return undefined;
                    }
                    iceServers.forEach(function (server) {
                        if (server.hasOwnProperty("username")) {
                            new icelink.IceServer(server.url, server.username, server.password);
                        }
                        else {
                            new icelink.IceServer(server.url);
                        }
                    });
                    return iceServers;
                },
                trickleIcePolicy: function (trickleIcePolicy) {
                    var value = stringCheck(trickleIcePolicy);
                    switch (value.trim().toLowerCase()) {
                        case TrickleIcePolicy.FullTrickle.toLowerCase():
                            return TrickleIcePolicy.FullTrickle;
                        case TrickleIcePolicy.HalfTrickle.toLowerCase():
                            return TrickleIcePolicy.HalfTrickle;
                        case TrickleIcePolicy.NotSupported.toLowerCase():
                            return TrickleIcePolicy.NotSupported;
                        default:
                            return undefined;
                    }
                },
                iceGatherPolicy: function (iceGatherPolicy) {
                    var value = stringCheck(iceGatherPolicy);
                    switch (value.trim().toLowerCase()) {
                        case IceGatherPolicy.All.toLowerCase():
                            return IceGatherPolicy.All;
                        case IceGatherPolicy.NoHost.toLowerCase():
                            return IceGatherPolicy.NoHost;
                        case IceGatherPolicy.Relay.toLowerCase():
                            return IceGatherPolicy.Relay;
                        default:
                            return undefined;
                    }
                },
                audioDeviceInput: function (device) {
                    if (device && device.hasOwnProperty("getTypeString") && device.getTypeString() === "[fm.icelink.SourceInput]") {
                        return device;
                    }
                    else {
                        return undefined;
                    }
                },
                videoDeviceInput: function (device) {
                    if (device && device.hasOwnProperty("getTypeString") && device.getTypeString() === "[fm.icelink.SourceInput]") {
                        return device;
                    }
                    else {
                        return undefined;
                    }
                },
                audioDeviceOutput: function (device) {
                    if (device && device.hasOwnProperty("getTypeString") && device.getTypeString() === "[fm.icelink.SinkOutput]") {
                        return device;
                    }
                    else {
                        return undefined;
                    }
                },
                audioDeviceSignalOutput: function (device) {
                    if (device && device.hasOwnProperty("getTypeString") && device.getTypeString() === "[fm.icelink.SinkOutput]") {
                        return device;
                    }
                    else {
                        return undefined;
                    }
                },
                videoStreamInOffer: booleanCheck,
                immediateRingback: booleanCheck,
                connectionTimeout: numberCheck,
                deadStreamTimeout: numberCheck,
                videoContainer: objectCheck,
                mediaConfiguration: function (mediaConfiguration, destination, prefix) {
                    var value = objectCheck(mediaConfiguration);
                    return value ? new MediaConfiguration(value, arrayConcat(prefix, ["mediaConfiguration"])) : value;
                },
                notifyAvailableMedia: booleanCheck,
                notifyMediaFeature: booleanCheck,
                mediaSignal: function (mediaSignal, destination, prefix) {
                    var value = objectCheck(mediaSignal);
                    return value ? new WebRTCMediaSignal(value, arrayConcat(prefix, ["mediaSignal"])) : value;
                },
                layoutPreset: function (layoutPreset) {
                    var value = objectCheck(layoutPreset);
                    if (value && value.hasOwnProperty("getTypeString") && value.getTypeString() === "[fm.icelink.LayoutPreset]") {
                        return value;
                    }
                    else {
                        return undefined;
                    }
                },
                ieactivex: function (ieactivex) {
                    var ieactivex = stringCheck(ieactivex);
                    if (isEmpty(ieactivex)) {
                        return undefined;
                    }
                    return ieactivex;
                },
            },
        };
        return WebrtcConfig;
    }());
    var TrickleIcePolicy;
    (function (TrickleIcePolicy) {
        TrickleIcePolicy["NotSupported"] = "NotSupported";
        TrickleIcePolicy["FullTrickle"] = "FullTrickle";
        TrickleIcePolicy["HalfTrickle"] = "HalfTrickle";
    })(TrickleIcePolicy || (TrickleIcePolicy = {}));
    var IceGatherPolicy;
    (function (IceGatherPolicy) {
        IceGatherPolicy["All"] = "All";
        IceGatherPolicy["NoHost"] = "NoHost";
        IceGatherPolicy["Relay"] = "Relay";
    })(IceGatherPolicy || (IceGatherPolicy = {}));

    var __extends$1 = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var __awaiter$3 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$3 = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    var WebrtcDialParams =  (function (_super) {
        __extends$1(WebrtcDialParams, _super);
        function WebrtcDialParams(params) {
            return _super.call(this, params) || this;
        }
        WebrtcDialParams.prototype.toRequest = function () {
            var result = _super.prototype.toRequest.call(this);
            result[8] = this.webrtcFields ? this.webrtcFields.toObject() : null;
            return result;
        };
        return WebrtcDialParams;
    }(DialParams));
    var WebRTCMethods =  (function (_super) {
        __extends$1(WebRTCMethods, _super);
        function WebRTCMethods(
        client) {
            var _this = _super.call(this, client) || this;
            _this.client = client;
            return _this;
        }
        WebRTCMethods.prototype.isWebRTCCall = function (callId) {
            var _a;
            var call = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.retriveCall(callId);
            if (call) {
                return !call.deviceIsApp;
            }
            else {
                return false;
            }
        };
        WebRTCMethods.prototype.setWebRTCAvailableMedia = function (media) {
            return this.requestPromise("setWebRTCAvailableMedia", [buildCallMedia(media)]);
        };
        WebRTCMethods.prototype.startVideoEchoTest = function (audio, video, videoContainer, mediaConfiguration) {
            var _this = this;
            var _a;
            if ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.enable) {
                var webrtcDialParams_1 = new WebrtcDialParams({
                    fromDeviceType: ExtenType.WEBRTC,
                    media: { audio: audio, video: video },
                    privateCall: false,
                    channelId: ChannelType.Video,
                    serviceCode: "dummy",
                });
                return from(this.client.webrtc.generateWebrtcFieldsForDial(webrtcDialParams_1, mediaConfiguration, videoContainer)).pipe(switchMap(function (webrtcFields) {
                    webrtcDialParams_1.webrtcFields = webrtcFields;
                    return _this.requestPromise("startVideoEchoTest", [webrtcDialParams_1.webrtcFields.clientid, buildCallMedia(webrtcDialParams_1.params.media), webrtcDialParams_1.webrtcFields.toObject()]).pipe(catchError(function (err) { return __awaiter$3(_this, void 0, void 0, function () {
                        var webrtcFields;
                        return __generator$3(this, function (_a) {
                            switch (_a.label) {
                                case 0:
                                    webrtcFields = webrtcDialParams_1.webrtcFields;
                                    if (!(webrtcFields && webrtcFields.clientid)) return [3 , 2];
                                    return [4 , this.client.webrtc.destroyCall(webrtcFields.clientid)];
                                case 1:
                                    _a.sent();
                                    _a.label = 2;
                                case 2: throw err;
                            }
                        });
                    }); }));
                }));
            }
            else {
                return throwError(new Error("Webrtc is not enable, call webrtc.start() before startVideoEchoTest"));
            }
        };
        WebRTCMethods.prototype.echoTestConnectivityCheck = function (media, mediaConfiguration, videoContainer) {
            var _a;
            if ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.enable) {
                return this.client.webrtc.generateWebrtcFieldsForConnectivityCheck(ChannelType.PhoneCall, media, mediaConfiguration, videoContainer);
            }
            else {
                return Promise.reject(new Error("Webrtc is not enable, call webrtc.start() before echoTestConnectivityCheck"));
            }
        };
        WebRTCMethods.prototype.stopEchoTestConnectivityCheck = function (id) {
            return this.cancel(id, true, false);
        };
        WebRTCMethods.prototype.dial = function (dialParams, videoContainer, mediaConstraints, userInteractionAction) {
            var _this = this;
            var _a;
            if (ExtenType.WEBRTC === dialParams.params.fromDeviceType && ChannelType.PhoneCall === dialParams.params.channelId ) {
                var callMedia = dialParams.params.media;
                this.log.debug("Webrtc dial is requested - contact: " + dialParams.params.contact.value + " - audio: " + !!callMedia.audio + " - video: " + !!callMedia.video + " - desktop: " + !!callMedia.desktop + " - data: " + !!callMedia.data);
                var webrtcDialParams_2 = new WebrtcDialParams(dialParams.params);
                if ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.enable) {
                    return from(this.client.webrtc.generateWebrtcFieldsForDial(webrtcDialParams_2, mediaConstraints, videoContainer, userInteractionAction)).pipe(switchMap(function (webrtcFields) {
                        webrtcDialParams_2.webrtcFields = webrtcFields;
                        return _this.requestPromise("dial", webrtcDialParams_2.toRequest()).pipe(map(function (result) {
                            return result ? webrtcDialParams_2.webrtcFields.clientid : null;
                        }));
                    }), catchError(function (err) { return __awaiter$3(_this, void 0, void 0, function () {
                        return __generator$3(this, function (_a) {
                            switch (_a.label) {
                                case 0:
                                    if (!(webrtcDialParams_2.webrtcFields && webrtcDialParams_2.webrtcFields.clientid)) return [3 , 2];
                                    return [4 , this.client.webrtc.destroyCall(webrtcDialParams_2.webrtcFields.clientid, dialParams, err)];
                                case 1:
                                    _a.sent();
                                    _a.label = 2;
                                case 2: throw err;
                            }
                        });
                    }); }));
                }
                else {
                    return throwError(new Error("Webrtc is not enable, call webrtc.start() before dial"));
                }
            }
            else {
                return null;
            }
        };
        WebRTCMethods.prototype.answer = function (channelId, callId, media, videoContainer, mediaConfiguration) {
            var _this = this;
            var _a;
            if (channelId === void 0) { channelId = ChannelType.PhoneCall; }
            if (this.isWebRTCCall(callId)) {
                this.log.debug("Webrtc answer is requested - callId: " + callId + " - audio: " + !!media.audio + " - video: " + !!media.video + " - desktop: " + !!media.desktop + " - data: " + !!media.data);
                if ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.enable) {
                    var execAnswer = true;
                    var call = this.client.webrtc.retriveCall(callId);
                    if (call) {
                        execAnswer = call.state === CallState.NEW_INBOUND && call.waitForAnswer;
                    }
                    if (execAnswer) {
                        return from(this.client.webrtc.generateWebrtcFieldsForAnswer(channelId, callId, media, mediaConfiguration, videoContainer)).pipe(switchMap(function (webrtcFields) { return _this.requestPromise("answer", [callId, buildCallMedia(media), webrtcFields.toObject()]); }), catchError(function (err) { return __awaiter$3(_this, void 0, void 0, function () {
                            return __generator$3(this, function (_a) {
                                switch (_a.label) {
                                    case 0: return [4 , this.client.webrtc.destroyCall(callId)];
                                    case 1:
                                        _a.sent();
                                        throw err;
                                }
                            });
                        }); }));
                    }
                    else {
                        var msg = "Answer was previous requested, wait or cancel call";
                        this.log.error(msg);
                        return throwError(new Error(msg));
                    }
                }
                else {
                    return throwError(new Error("Webrtc is not enable, call webrtc.start() before answer"));
                }
            }
            else {
                return null;
            }
        };
        WebRTCMethods.prototype.hold = function (callId) {
            var _a;
            if (this.isWebRTCCall(callId)) {
                if ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.enable) {
                    return from(this.client.webrtc.toggleHold(callId));
                }
                else {
                    return throwError(new Error("Webrtc is not enable, call webrtc.start() before toggleHold"));
                }
            }
            return of(true);
        };
        WebRTCMethods.prototype.unhold = function (callId) {
            return this.hold(callId);
        };
        WebRTCMethods.prototype.attendedTransfer = function (callId, heldCallId, media, fields) {
            var _this = this;
            var _a;
            if (this.isWebRTCCall(callId)) {
                if ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.enable) {
                    var call_1 = this.client.webrtc.retriveCall(callId);
                    if (call_1 && (!media || Object.keys(media).length === 0)) {
                        media = call_1.localCallMedia;
                    }
                    if (call_1 && !fields && call_1.localMedia) {
                        fields = new WebRTCField(null, new WebRTCFieldSession(call_1.isOffer, call_1.localDescription), null, null, null).toObject();
                    }
                    return this.requestPromise("attendedTransfer", [callId, heldCallId, buildCallMedia(media), fields]).pipe(tap(function (response) {
                        if (response && call_1.state === CallState.NEW_OUTBOUND) {
                            _this.log.debug("stopping tone signals for attendedTransfer in ring state");
                            call_1.toneSignalEnabled = false;
                        }
                    }));
                }
                else {
                    return throwError(new Error("Webrtc is not enable, call webrtc.start() before attendedTransfer"));
                }
            }
            else {
                return null;
            }
        };
        WebRTCMethods.prototype.blindTransfer = function (callId, accessCode, number, data) {
            return this.requestPromise("blindTransfer", [callId, accessCode, number, data]);
        };
        WebRTCMethods.prototype.sendDTMF = function (callId, dtmf, playTone, dtmfDuration, dtmfInterToneGap) {
            var _this = this;
            var _a;
            if (playTone === void 0) { playTone = true; }
            if (this.isWebRTCCall(callId)) {
                dtmf = (dtmf || "").split("").reduce(function (d1, d2) { return (dtmfValidator.test(d2) ? d1 + d2 : d1); }, "");
                if (dtmf) {
                    var call = (_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.retriveCall(callId);
                    if (call) {
                        return from(call.sendDTMF(dtmf, playTone, dtmfDuration, dtmfInterToneGap)).pipe(switchMap(function (isSentInband) {
                            if (isSentInband) {
                                return of(true);
                            }
                            else {
                                return _this.requestPromise("sendDTMF", [callId, dtmf]);
                            }
                        }));
                    }
                    else {
                        return throwError(new Error("no call to sendDTMF"));
                    }
                }
                else {
                    return throwError(new Error("Invalid DTMF"));
                }
            }
            else {
                return null;
            }
        };
        WebRTCMethods.prototype.forceCancel = function (callId) {
            return this.requestPromise("cancel", [callId]);
        };
        WebRTCMethods.prototype.cancel = function (callId, storeAction, execWebapiRequest) {
            var _a;
            if (this.isWebRTCCall(callId)) {
                this.log.debug("Webrtc cancel is requested - callId: " + callId);
                if ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.enable) {
                    if (storeAction) {
                        this.client.webrtc.cancelCallRequest(callId);
                    }
                    if (execWebapiRequest) {
                        return this.forceCancel(callId);
                    }
                    else {
                        return of(true);
                    }
                }
                else {
                    return throwError(new Error("Webrtc is not enable, call webrtc.start() before cancel"));
                }
            }
            else {
                return null;
            }
        };
        WebRTCMethods.prototype.createUserInteraction = function (createUserInteraction) {
            return this.requestPromise("createUserInteraction", [createUserInteraction]);
        };
        WebRTCMethods.prototype.removeCallFromUserInteraction = function (callId) {
            return this.requestPromise("removeCallFromUserInteraction", [callId]);
        };
        WebRTCMethods.prototype.updateWebRTCFields = function (callId, media, fields) {
            return this.requestPromise("updateWebRTCFields", [callId, buildCallMedia(media), fields ? fields.toObject() : null]);
        };
        WebRTCMethods.prototype.getWebrtcConfiguration = function () {
            return this.requestPromise("getWebrtcConfiguration", []);
        };
        WebRTCMethods.prototype.mute = function (callId, media) {
            var _a;
            if (this.isWebRTCCall(callId)) {
                this.log.debug("Webrtc MUTE is requested - callId: " + callId + " - " + ("audio: " + !!(media && media.audio) + " - ") + ("video: " + !!(media && media.video) + " - ") + ("desktop: " + !!(media && media.desktop) + " - ") + ("data: " + (!!media && media.data)));
                if ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.enable) {
                    if (media && Object.keys(media).length) {
                        var call_2 = this.client.webrtc.retriveCall(callId);
                        if (call_2) {
                            var result = of(false);
                            if (media.audio) {
                                result = result.pipe(switchMap(function () { return call_2.toggleAudioMute(true, false); }));
                            }
                            if (media.video) {
                                result = result.pipe(switchMap(function () { return call_2.toggleVideoMute(true, false); }));
                            }
                            return result.pipe(switchMap(function () { return call_2.notifyCallMediaState(media); }));
                        }
                        else {
                            var msg = "Webrtc MUTE - call is unavailable";
                            this.log.error(msg);
                            return throwError(new Error(msg));
                        }
                    }
                    else {
                        return throwError(new Error("Webrtc MUTE is called with any media to mute"));
                    }
                }
                else {
                    return throwError(new Error("Webrtc is not enable, call webrtc.start() before mute"));
                }
            }
            else {
                return null;
            }
        };
        WebRTCMethods.prototype.unmute = function (callId, media) {
            var _a;
            if (this.isWebRTCCall(callId)) {
                this.log.debug("Webrtc UNMUTE is requested - callId: " + callId + " - " + ("audio: " + !!(media && media.audio) + " - ") + ("video: " + !!(media && media.video) + " - ") + ("desktop: " + !!(media && media.desktop) + " - ") + ("data: " + (!!media && media.data)));
                if ((_a = this.client.webrtc) === null || _a === void 0 ? void 0 : _a.enable) {
                    if (media && Object.keys(media).length) {
                        var call_3 = this.client.webrtc.retriveCall(callId);
                        if (call_3) {
                            var result = of(false);
                            if (media.audio) {
                                result = result.pipe(switchMap(function () { return call_3.toggleAudioMute(false, false); }));
                            }
                            if (media.video) {
                                result = result.pipe(switchMap(function () { return call_3.toggleVideoMute(false, false); }));
                            }
                            return result.pipe(switchMap(function () { return call_3.notifyCallMediaState(media); }));
                        }
                        else {
                            var msg = "Webrtc UNMUTE - call is unavailable";
                            this.log.error(msg);
                            return throwError(new Error(msg));
                        }
                    }
                    else {
                        return throwError(new Error("Webrtc UNMUTE is called with any media to unmute"));
                    }
                }
                else {
                    return throwError(new Error("Webrtc is not enable, call webrtc.start() before unmute"));
                }
            }
            else {
                return null;
            }
        };
        WebRTCMethods.prototype.notifyMute = function (callId, media, fields) {
            return this.requestPromise("mute", [callId, buildCallMedia(media), fields ? fields.toObject() : null]);
        };
        WebRTCMethods.prototype.notifyUnmute = function (callId, media, fields) {
            return this.requestPromise("unmute", [callId, buildCallMedia(media), fields ? fields.toObject() : null]);
        };
        WebRTCMethods.prototype.startVideoOnCall = function (callId, fields) {
            return this.requestPromise("startVideoOnCall", [callId, fields ? fields.toObject() : null]);
        };
        WebRTCMethods.prototype.stopVideoOnCall = function (callId, fields) {
            return this.requestPromise("stopVideoOnCall", [callId, fields ? fields.toObject() : null]);
        };
        return WebRTCMethods;
    }(Methods));

    var __awaiter$2 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$2 = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    var featurelog = Log$1.of("webrtc:phonesignal:feature");
    var AudioContextClass = window.AudioContext || window.webkitAudioContext || window.mozAudioContext || window.oAudioContext || window.msAudioContext;
    var audioContextInstance = null;
    var supportedFeature = {
        setSinkId: null,
        createMediaStreamDestination: null,
    };
    var dtmfFrequency = new Map([
        ["1", [697, 1209]],
        ["2", [697, 1336]],
        ["3", [697, 1477]],
        ["A", [697, 1633]],
        ["4", [770, 1209]],
        ["5", [770, 1336]],
        ["6", [770, 1477]],
        ["B", [770, 1633]],
        ["7", [852, 1209]],
        ["8", [852, 1336]],
        ["9", [852, 1477]],
        ["C", [852, 1633]],
        ["*", [941, 1209]],
        ["0", [941, 1336]],
        ["#", [941, 1477]],
        ["D", [941, 1633]],
    ]);
    var audioSilence = "data:audio/wav;base64,UklGRpwAAABXQVZFZm10IBAAAAABAAIARKwAABCxAgAEABAAZGF0YXgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
    function retriveAudioContextState() {
        return __awaiter$2(this, void 0, void 0, function () {
            var _audioContext, closeAudioContext, audioContextState;
            return __generator$2(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        _audioContext = null;
                        closeAudioContext = false;
                        audioContextState = null;
                        if (AudioContextClass) {
                            try {
                                _audioContext = new AudioContextClass();
                                closeAudioContext = true;
                            }
                            catch (e) {
                                _audioContext = audioContextInstance;
                            }
                            audioContextState = _audioContext ? _audioContext.state : null;
                        }
                        if (!closeAudioContext) return [3 , 4];
                        _a.label = 1;
                    case 1:
                        _a.trys.push([1, 3, , 4]);
                        return [4 , _audioContext.close()];
                    case 2:
                        _a.sent();
                        _audioContext = null;
                        return [3 , 4];
                    case 3:
                        _a.sent();
                        return [3 , 4];
                    case 4: return [2 , audioContextState];
                }
            });
        });
    }
    function userGestureIsRequiredForMediaElement() {
        return __awaiter$2(this, void 0, void 0, function () {
            var autoPlayAllowed, mediaElement, error_1;
            return __generator$2(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        autoPlayAllowed = true;
                        _a.label = 1;
                    case 1:
                        _a.trys.push([1, 6, , 7]);
                        mediaElement = new Audio();
                        mediaElement.src = audioSilence;
                        _a.label = 2;
                    case 2:
                        _a.trys.push([2, 4, , 5]);
                        return [4 , mediaElement.play()];
                    case 3:
                        _a.sent();
                        return [3 , 5];
                    case 4:
                        error_1 = _a.sent();
                        if (error_1.name == "NotAllowedError") {
                            autoPlayAllowed = false;
                        }
                        return [3 , 5];
                    case 5:
                        if (autoPlayAllowed) {
                            mediaElement.pause();
                            mediaElement = null;
                        }
                        return [2 , autoPlayAllowed];
                    case 6:
                        _a.sent();
                        return [2 , false];
                    case 7: return [2 ];
                }
            });
        });
    }
    var DefaultOptions = new WebRTCMediaSignal();
    function setSinkOutput(element, deviceId) {
        return __awaiter$2(this, void 0, void 0, function () {
            var e_3;
            return __generator$2(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!(supportedFeature.setSinkId !== false)) return [3 , 5];
                        _a.label = 1;
                    case 1:
                        _a.trys.push([1, 4, , 5]);
                        if (!(deviceId != null)) return [3 , 3];
                        return [4 , element.setSinkId(deviceId)];
                    case 2:
                        _a.sent();
                        supportedFeature.setSinkId = true;
                        _a.label = 3;
                    case 3: return [2 , true];
                    case 4:
                        e_3 = _a.sent();
                        if (e_3 instanceof DOMException) {
                            featurelog.error("setSinkOutput - no permission to use output device " + deviceId, e_3);
                        }
                        else {
                            supportedFeature.setSinkId = false;
                            featurelog.debug("setSinkId is not supported, play to default output device");
                        }
                        return [3 , 5];
                    case 5: return [2 , !!supportedFeature.setSinkId];
                }
            });
        });
    }
    var PhoneSignalManager =  (function () {
        function PhoneSignalManager(
        webrtcManager) {
            var _this = this;
            this.webrtcManager = webrtcManager;
            this.gestureRequired = new BehaviorSubject(null);
            this.log = Log$1.of("webrtc:phonesignal", webrtcManager.client);
            this.callMediaSignal = new CallMediaSignalPlayerStore(this);
            this.setConfig(webrtcManager.options.mediaSignal, true);
            var checkUserGestureRequired = function () { return __awaiter$2(_this, void 0, void 0, function () {
                var result, response;
                return __generator$2(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            this.log.debug("CheckUserGesture START");
                            return [4 , Promise.all([retriveAudioContextState(), userGestureIsRequiredForMediaElement()])];
                        case 1:
                            result = _a.sent();
                            this.log.debug("CheckUserGesture END: AudioContext state '" + result[0] + "' - AudioElement autoPlay allowed '" + result[1] + "'");
                            response = result[0] === "suspended" || !result[1];
                            if (response) {
                                this.log.debug("User gesture is required for play phone signal");
                            }
                            else {
                                this.log.debug("User gesture is not required for play phone signal");
                            }
                            return [2 , response];
                    }
                });
            }); };
            var documentClickHandler = debounce(function () { return __awaiter$2(_this, void 0, void 0, function () {
                return __generator$2(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            this.log.debug("User click on document, check can play phone signal");
                            return [4 , checkUserGestureRequired()];
                        case 1:
                            if (_a.sent()) {
                                this.gestureRequired.next(true);
                            }
                            else {
                                document.removeEventListener("click", documentClickHandler);
                                this.gestureRequired.next(false);
                                if (audioContextInstance) {
                                    audioContextInstance.resume();
                                }
                            }
                            return [2 ];
                    }
                });
            }); }, 5000, { leading: true });
            (function () { return __awaiter$2(_this, void 0, void 0, function () {
                return __generator$2(this, function (_a) {
                    switch (_a.label) {
                        case 0: return [4 , checkUserGestureRequired()];
                        case 1:
                            if (_a.sent()) {
                                document.addEventListener("click", documentClickHandler);
                                this.gestureRequired.next(true);
                            }
                            else {
                                this.gestureRequired.next(false);
                            }
                            return [2 ];
                    }
                });
            }); })();
        }
        Object.defineProperty(PhoneSignalManager.prototype, "webrtc", {
            get: function () {
                return this.webrtcManager;
            },
            enumerable: false,
            configurable: true
        });
        PhoneSignalManager.prototype.getGestureRequired = function () {
            return this.gestureRequired;
        };
        PhoneSignalManager.prototype.getAudioContext = function () {
            if (audioContextInstance == null && AudioContextClass) {
                audioContextInstance = new AudioContextClass();
            }
            return audioContextInstance;
        };
        PhoneSignalManager.prototype.setConfig = function (options, resetDefault) {
            var mediaSignal = Object.assign({}, options);
            if (!mediaSignal.hasOwnProperty("audioenabled")) {
                mediaSignal.audioenabled = resetDefault ? DefaultOptions.audioenabled : this.signalOptions.audioenabled;
            }
            if (!mediaSignal.hasOwnProperty("volume")) {
                mediaSignal.volume = resetDefault ? DefaultOptions.volume : this.signalOptions.volume;
            }
            this.signalOptions = mediaSignal;
            if (!mediaSignal.hasOwnProperty("audio")) {
                mediaSignal.audio = resetDefault ? Object.assign({}, DefaultOptions.audio) : this.signalOptions.audio;
                this.callMediaSignal.reloadConfig();
            }
            else {
                this.setAudioSignalConfig(options.audio, resetDefault);
            }
        };
        PhoneSignalManager.prototype.setAudioSignalConfig = function (options, resetDefault) {
            if (options) {
                for (var key in DefaultOptions.audio) {
                    if (options.hasOwnProperty(key)) {
                        this.signalOptions.audio[key] = Object.assign({}, resetDefault ? DefaultOptions.audio[key] : options[key] ? options[key] : DefaultOptions.audio[key]);
                        if (options[key] && options[key].hasOwnProperty("volume")) {
                            this.changeVolume(options[key].volume, key);
                        }
                    }
                }
            }
            this.callMediaSignal.reloadConfig();
            if (this.testerMediaSignal) {
                this.testerMediaSignal.stop(true);
                this.testerMediaSignal = null;
            }
        };
        PhoneSignalManager.prototype.getConfig = function () {
            return this.signalOptions;
        };
        PhoneSignalManager.prototype.getAudioSignalConfig = function () {
            return this.signalOptions.audio;
        };
        PhoneSignalManager.prototype.getCurrentPlay = function (callId) {
            return this.callMediaSignal.getCurrentPlay(callId);
        };
        PhoneSignalManager.prototype.playDTMF = function (callId, dtmf, duration, interToneGap) {
            var call = this.webrtcManager.retriveCall(callId);
            if (call && call.toneSignalEnabled) {
                this.callMediaSignal.playDTMF(callId, dtmf, duration || this.signalOptions.dtmfDuration, interToneGap || this.signalOptions.dtmfInterToneGap);
            }
        };
        PhoneSignalManager.prototype.play = function (callId, mediaSignal) {
            return __awaiter$2(this, void 0, void 0, function () {
                var call;
                return __generator$2(this, function (_a) {
                    if (this.callMediaSignal.getCurrentPlay(callId) != mediaSignal) {
                        call = this.webrtcManager.retriveCall(callId);
                        if (call && call.toneSignalEnabled) {
                            return [2 , this.callMediaSignal.play(callId, mediaSignal)];
                        }
                        else {
                            return [2 ];
                        }
                    }
                    else {
                        return [2 ];
                    }
                });
            });
        };
        PhoneSignalManager.prototype.stop = function (callId, force) {
            return __awaiter$2(this, void 0, void 0, function () {
                var call, ex_1;
                return __generator$2(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.callMediaSignal.getCurrentPlay(callId)) return [3 , 4];
                            this.callMediaSignal.stop(callId, force);
                            this.callMediaSignal.delete(callId);
                            call = this.webrtcManager.retriveCall(callId);
                            if (!(call && call.toneSignalEnabled)) return [3 , 4];
                            if (call.state == CallState.NEW_INBOUND || call.state == CallState.CONNECTED) {
                                this.log.debug("stopSingleInstancePlayerIfNeedle - " + MediaSignal.ring + " - " + callId);
                                this.callMediaSignal.stopSingleInstancePlayerIfNeedle(MediaSignal.ring);
                                this.log.debug("stopSingleInstancePlayerIfNeedle - " + MediaSignal.ringAdvertising + " - " + callId);
                                this.callMediaSignal.stopSingleInstancePlayerIfNeedle(MediaSignal.ringAdvertising);
                            }
                            if (!(this.callMediaSignal.size() === 0)) return [3 , 4];
                            this.callMediaSignal.stopSingleInstancePlayerIfNeedle();
                            if (!audioContextInstance) return [3 , 4];
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 3, , 4]);
                            return [4 , audioContextInstance.close()];
                        case 2:
                            _a.sent();
                            audioContextInstance = null;
                            return [3 , 4];
                        case 3:
                            ex_1 = _a.sent();
                            this.log.error("Could not destroy AudioContext.", ex_1);
                            return [3 , 4];
                        case 4: return [2 ];
                    }
                });
            });
        };
        PhoneSignalManager.prototype.changeVolume = function (volume, mediaSignal, callId) {
            var conf = this.getConfig();
            var newVolume = volume >= 0 && volume <= 100 ? volume : 100;
            if (!mediaSignal) {
                conf.volume = newVolume;
                if (conf.audio) {
                    for (var signal in conf.audio) {
                        conf.audio[signal].volume = newVolume;
                    }
                }
            }
            else {
                if (conf && conf.audio && conf.audio[mediaSignal]) {
                    conf.audio[mediaSignal].volume = newVolume;
                }
            }
            this.callMediaSignal.changeVolume(newVolume, mediaSignal, callId);
            if (this.testerMediaSignal) {
                this.testerMediaSignal.changeVolume(newVolume, mediaSignal);
            }
        };
        PhoneSignalManager.prototype.getVolume = function (mediaSignal, configuration) {
            var volume = 100;
            var conf = this.getConfig();
            if (configuration && configuration.volume >= 0 && configuration.volume <= 100) {
                volume = configuration.volume;
            }
            else if (conf && conf.audio && conf.audio[mediaSignal] && conf.audio[mediaSignal].volume >= 0 && conf.audio[mediaSignal].volume <= 100) {
                volume = conf.audio[mediaSignal].volume;
            }
            else if (conf && conf.volume >= 0 && conf.volume <= 100) {
                volume = conf.volume;
            }
            return volume;
        };
        PhoneSignalManager.prototype.playSignalTest = function (mediaSignal, conf, ignoreLoop, device) {
            if (this.testerMediaSignal == null) {
                this.testerMediaSignal = new CallMediaSignalPlayer(this.log, "", this, new Map());
            }
            return this.testerMediaSignal.play(mediaSignal, conf, ignoreLoop, device, true);
        };
        PhoneSignalManager.prototype.stopSignalTest = function (mediaSignal) {
            if (this.testerMediaSignal) {
                if (mediaSignal) {
                    var player = this.testerMediaSignal.getMediaSignalPlayerTest(mediaSignal);
                    if (player) {
                        player.stop(true);
                    }
                }
                else {
                    this.testerMediaSignal.stop(true);
                }
            }
        };
        PhoneSignalManager.prototype.convertRingAdvertisingToRingIfNeedle = function () {
            this.callMediaSignal.convertRingAdvertisingToRingIfNeedle();
        };
        return PhoneSignalManager;
    }());
    var DtmfPlayer =  (function () {
        function DtmfPlayer(
        instance,
        duration,
        interToneGap) {
            this.instance = instance;
            this.duration = duration;
            this.interToneGap = interToneGap;
            this.dtmfPlayerElement = null;
            this.audioElement = new Audio();
            this.audioElementPlay = null;
            this.mediaStreamDestination = null;
            this.playerNotifier = new Subject();
            this.log = Log$1.of("webrtc:phonesignal:dtmf", instance.webrtc.client);
        }
        DtmfPlayer.prototype.initDestination = function () {
            return __awaiter$2(this, void 0, void 0, function () {
                var outputDevice, result, audioContext;
                return __generator$2(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            result = Promise.resolve(true);
                            try {
                                outputDevice = this.instance.webrtc.device.audioOutput;
                            }
                            catch (e) { }
                            if (!(outputDevice && outputDevice.getId())) return [3 , 3];
                            if (!(supportedFeature.createMediaStreamDestination !== false && supportedFeature.setSinkId !== false && !this.mediaStreamDestination && !this.audioElement.srcObject)) return [3 , 2];
                            audioContext = this.instance.getAudioContext();
                            try {
                                this.mediaStreamDestination = audioContext.createMediaStreamDestination();
                                this.audioElement.srcObject = this.mediaStreamDestination.stream;
                                supportedFeature.createMediaStreamDestination = true;
                            }
                            catch (e) {
                                supportedFeature.createMediaStreamDestination = false;
                                featurelog.debug("createMediaStreamDestination is not supported, play to default output device");
                                this.mediaStreamDestination = null;
                                this.audioElement.srcObject = null;
                            }
                            if (!this.mediaStreamDestination) return [3 , 2];
                            return [4 , setSinkOutput(this.audioElement, outputDevice.getId())];
                        case 1:
                            if (_a.sent()) {
                                return [2 , true];
                            }
                            else {
                                this.mediaStreamDestination = null;
                                this.audioElement.srcObject = null;
                                return [2 , false];
                            }
                        case 2: return [3 , 4];
                        case 3:
                            this.mediaStreamDestination = null;
                            this.audioElement.srcObject = null;
                            _a.label = 4;
                        case 4: return [2 , result];
                    }
                });
            });
        };
        DtmfPlayer.prototype._createOscillator = function () {
            var audioContext = this.instance.getAudioContext();
            if (audioContext) {
                var gainNode = audioContext.createGain();
                var oscillator = audioContext.createOscillator();
                oscillator.type = "sine";
                oscillator.connect(gainNode, 0, 0);
                if (this.mediaStreamDestination && this.mediaStreamDestination) {
                    gainNode.connect(this.mediaStreamDestination);
                }
                else {
                    gainNode.connect(audioContext.destination);
                }
                try {
                    gainNode.gain.setValueAtTime(0.1, 0);
                }
                catch (e) {
                    console.error(e);
                }
                return oscillator;
            }
            else {
                return null;
            }
        };
        DtmfPlayer.prototype.spoolDTMF = function () {
            return __awaiter$2(this, void 0, void 0, function () {
                var dtmfElement, dtmfTone, signalOptions;
                var _this = this;
                return __generator$2(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.dtmfPlayerElement) return [3 , 6];
                            dtmfElement = this.dtmfPlayerElement;
                            dtmfTone = dtmfElement.dtmf.charAt(0).toUpperCase();
                            dtmfElement.stats = true;
                            dtmfElement.dtmf = dtmfElement.dtmf.substring(1);
                            if (!dtmfValidator.test(dtmfTone)) return [3 , 5];
                            signalOptions = this.instance.getConfig().audio.dtmf;
                            if (dtmfElement && signalOptions && signalOptions[dtmfTone] && signalOptions[dtmfTone].src && !dtmfElement.audioElement) {
                                dtmfElement.audioElement = new Audio();
                            }
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 3, , 4]);
                            return [4 , this.playDtmfTone(dtmfElement, dtmfTone)];
                        case 2:
                            _a.sent();
                            return [3 , 4];
                        case 3:
                            _a.sent();
                            return [3 , 4];
                        case 4:
                            setTimeout(function () { return __awaiter$2(_this, void 0, void 0, function () {
                                return __generator$2(this, function (_a) {
                                    this.spoolDTMF();
                                    return [2 ];
                                });
                            }); }, this.interToneGap);
                            return [3 , 6];
                        case 5:
                            if (dtmfElement.dtmf.length) {
                                this.spoolDTMF();
                            }
                            else {
                                this.dtmfPlayerElement = null;
                                this.playerNotifier.complete();
                            }
                            _a.label = 6;
                        case 6: return [2 ];
                    }
                });
            });
        };
        DtmfPlayer.prototype.playDtmfTone = function (dtmfElement, dtmfTone) {
            var _this = this;
            return new Promise(function (resolve, reject) {
                try {
                    _this.playerNotifier.next(dtmfTone);
                    var signalOptions = _this.instance.getConfig().audio.dtmf;
                    if (dtmfElement.audioElement && signalOptions && signalOptions[dtmfTone] && signalOptions[dtmfTone].src) {
                        fromEvent(dtmfElement.audioElement, "ended")
                            .pipe(timeout(_this.duration), take(1), catchError(function (err) { return of(true); }),
                        switchMap(function () { return dtmfElement.audioElementPlay; }), catchError(function (e) {
                            _this.log.error("Error on play dtmf from src", e);
                            return of(false);
                        }))
                            .subscribe(function () {
                            dtmfElement.audioElement.pause();
                            dtmfElement.audioElement.currentTime = 0;
                        });
                        dtmfElement.audioElement.src = signalOptions[dtmfTone].src;
                        dtmfElement.audioElement.loop = true;
                        dtmfElement.audioElementPlay = dtmfElement.audioElement.play();
                    }
                    else {
                        var frequency = dtmfFrequency.get(dtmfTone);
                        if (frequency && frequency.length === 2) {
                            if (!dtmfElement.oscillator1 && !dtmfElement.oscillator2) {
                                dtmfElement.oscillator1 = _this._createOscillator();
                                dtmfElement.oscillator2 = _this._createOscillator();
                                if (dtmfElement.oscillator1) {
                                    dtmfElement.oscillator1.start(0);
                                }
                                if (dtmfElement.oscillator2) {
                                    dtmfElement.oscillator2.start(0);
                                }
                                if (_this.audioElement.srcObject) {
                                    _this.audioElementPlay = _this.audioElement.play();
                                }
                            }
                            try {
                                if (dtmfElement.oscillator1) {
                                    dtmfElement.oscillator1.frequency.setValueAtTime(frequency[0], 0);
                                }
                                if (dtmfElement.oscillator2) {
                                    dtmfElement.oscillator2.frequency.setValueAtTime(frequency[1], 0);
                                }
                            }
                            catch (e) {
                                console.error(e);
                            }
                            setTimeout(function () { return __awaiter$2(_this, void 0, void 0, function () {
                                var e_4;
                                return __generator$2(this, function (_a) {
                                    switch (_a.label) {
                                        case 0:
                                            _a.trys.push([0, 2, , 3]);
                                            return [4 , this.audioElementPlay];
                                        case 1:
                                            _a.sent();
                                            if (dtmfElement.oscillator1) {
                                                dtmfElement.oscillator1.stop();
                                                dtmfElement.oscillator1.disconnect();
                                            }
                                            if (dtmfElement.oscillator2) {
                                                dtmfElement.oscillator2.stop();
                                                dtmfElement.oscillator2.disconnect();
                                            }
                                            dtmfElement.oscillator1 = null;
                                            dtmfElement.oscillator2 = null;
                                            this.audioElement.pause();
                                            this.audioElement.currentTime = 0;
                                            resolve(true);
                                            return [3 , 3];
                                        case 2:
                                            e_4 = _a.sent();
                                            this.log.error("Error on play dtmf", e_4);
                                            return [3 , 3];
                                        case 3: return [2 ];
                                    }
                                });
                            }); }, _this.duration);
                        }
                        else {
                            reject("Invalid DTMF \"" + dtmfTone + "\"");
                        }
                    }
                }
                catch (e) {
                    reject(e);
                }
            });
        };
        DtmfPlayer.prototype.destroy = function () {
            this.mediaStreamDestination = null;
            this.audioElement.srcObject = null;
        };
        DtmfPlayer.prototype.playDTMF = function (dtmf) {
            if (typeof dtmf === "string" && this.instance.getConfig().audioenabled && dtmf) {
                var dtmfElement = this.dtmfPlayerElement;
                if (dtmfElement) {
                    dtmfElement.dtmf += dtmf;
                }
                else {
                    dtmfElement = {
                        audioElement: null,
                        audioElementPlay: null,
                        oscillator1: null,
                        oscillator2: null,
                        stats: false,
                        dtmf: dtmf,
                    };
                    this.dtmfPlayerElement = dtmfElement;
                }
                if (!dtmfElement.stats) {
                    this.spoolDTMF();
                }
            }
            else {
                this.playerNotifier.complete();
            }
            return this.playerNotifier.asObservable();
        };
        return DtmfPlayer;
    }());
    var MediaSignalPlayer =  (function () {
        function MediaSignalPlayer(signal,
        phoneSignalManager) {
            var _this = this;
            this.phoneSignalManager = phoneSignalManager;
            this.playInProgress = false;
            this.phoneSignalAudioElementPlay = Promise.resolve();
            this.phoneSignalAudioElement = new Audio();
            this.phoneSignalEndedSubscription = new Subscription();
            this.phoneSignalEndedObservable = fromEvent(this.phoneSignalAudioElement, "ended").pipe(tap(function () { return _this.stopAudioElement(); }));
            this.log = Log$1.of("webrtc:phonesignal", phoneSignalManager.webrtc.client);
            var signalOptions = phoneSignalManager.getConfig();
            this.signal = signal;
            this.conf = signalOptions.audio && signalOptions.audio[signal] ? signalOptions.audio[signal] : null;
            this.phoneSignalAudioElement.autoplay = true;
            this.phoneSignalAudioElement.loop = true;
            this.changeVolume(phoneSignalManager.getVolume(signal, this.conf));
        }
        MediaSignalPlayer.prototype.stopAudioElement = function () {
            return __awaiter$2(this, void 0, void 0, function () {
                var e_5;
                return __generator$2(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this.phoneSignalAudioElementPlay) return [3 , 5];
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 3, , 4]);
                            return [4 , this.phoneSignalAudioElementPlay];
                        case 2:
                            _a.sent();
                            return [3 , 4];
                        case 3:
                            e_5 = _a.sent();
                            this.log.error("Error on play", e_5);
                            return [3 , 4];
                        case 4:
                            this.phoneSignalAudioElement.pause();
                            this.phoneSignalAudioElement.currentTime = 0;
                            _a.label = 5;
                        case 5: return [2 ];
                    }
                });
            });
        };
        MediaSignalPlayer.prototype.setOutputDevice = function (outputDevice) {
            return setSinkOutput(this.phoneSignalAudioElement, outputDevice && outputDevice.getId() ? outputDevice.getId() : null);
        };
        MediaSignalPlayer.prototype.setConfiguration = function (conf) {
            this.conf = conf;
        };
        MediaSignalPlayer.prototype.getSignal = function () {
            return this.signal;
        };
        MediaSignalPlayer.prototype.changeVolume = function (volume) {
            this.phoneSignalAudioElement.volume = volume >= 0 && volume <= 100 ? volume / 100 : 1;
        };
        MediaSignalPlayer.prototype.getVolume = function () {
            return this.phoneSignalAudioElement.volume * 100;
        };
        MediaSignalPlayer.prototype.stop = function (immediate) {
            if (this.playInProgress) {
                this.log.debug("MediaSignalPlayer - stop - " + this.signal);
                this.playInProgress = false;
                if (immediate) {
                    this.stopAudioElement();
                }
            }
            this.phoneSignalEndedSubscription.unsubscribe();
        };
        MediaSignalPlayer.prototype.playInternal = function () {
            try {
                if (this.phoneSignalManager.getGestureRequired().value) {
                    this.phoneSignalAudioElementPlay = Promise.reject("Unable to play, user gesture on page is required");
                    this.log.error("Unable to play, user gesture on page is required");
                }
                else {
                    this.phoneSignalAudioElementPlay = Promise.resolve(this.phoneSignalAudioElement.play());
                }
            }
            catch (e) {
                this.log.error("Error on playInternal", e);
            }
        };
        MediaSignalPlayer.prototype.play = function (ignoreLoop, resolveOnSignalEnd) {
            var _this = this;
            this.log.debug("MediaSignalPlayer - play - " + this.signal);
            if (!this.playInProgress) {
                var audio = this.conf;
                if (audio && audio.src) {
                    var loop_1 = !!audio.loop;
                    this.phoneSignalAudioElement.src = audio.src;
                    this.phoneSignalAudioElement.loop = loop_1;
                    if (loop_1 && audio.interval) {
                        this.phoneSignalAudioElement.loop = false;
                        this.phoneSignalEndedSubscription = this.phoneSignalEndedObservable
                            .pipe(delay(audio.interval), filter(function () { return _this.playInProgress; }))
                            .subscribe(function () {
                            _this.playInternal();
                        });
                    }
                    else {
                        this.phoneSignalEndedSubscription = new Subscription(function () {
                            if (loop_1) {
                                _this.phoneSignalAudioElement.loop = false;
                                switch (_this.signal) {
                                    case MediaSignal.ringback:
                                    case MediaSignal.ring:
                                        _this.stopAudioElement();
                                        break;
                                    default:
                                        _this.phoneSignalEndedObservable.pipe(first()).subscribe(function () { return _this.stopAudioElement(); });
                                        break;
                                }
                            }
                            else {
                                _this.stopAudioElement();
                            }
                        });
                    }
                    if (audio.maxlength) {
                        var phoneSignalTimer_1 = setTimeout(function () {
                            phoneSignalTimer_1 = null;
                            _this.stop(true);
                        }, audio.maxlength);
                        this.phoneSignalEndedSubscription.add(function () {
                            if (phoneSignalTimer_1) {
                                clearTimeout(phoneSignalTimer_1);
                                phoneSignalTimer_1 = null;
                            }
                        });
                    }
                    if (ignoreLoop) {
                        this.phoneSignalEndedObservable.pipe(first()).subscribe(function () { return _this.stop(true); });
                    }
                    this.playInternal();
                }
                this.playInProgress = true;
            }
            return resolveOnSignalEnd
                ? new Promise(function (resolve) {
                    _this.phoneSignalEndedSubscription.add(resolve);
                })
                : Promise.resolve();
        };
        return MediaSignalPlayer;
    }());
    var CallMediaSignalPlayer =  (function () {
        function CallMediaSignalPlayer(
        log,
        callId,
        phoneSignal,
        singleInstancePlayer) {
            this.log = log;
            this.callId = callId;
            this.phoneSignal = phoneSignal;
            this.singleInstancePlayer = singleInstancePlayer;
            this.dtmfPlayer = [];
            this.signalPlayed = new Map();
            this.currentPlay = null;
        }
        CallMediaSignalPlayer.prototype.getOutputDeviceBySignal = function (signal) {
            return signal === MediaSignal.ring ? this.phoneSignal.webrtc.device.audioSignalOutput : this.phoneSignal.webrtc.device.audioOutput;
        };
        CallMediaSignalPlayer.prototype.buildPhoneSignal = function (signal, conf, device) {
            return __awaiter$2(this, void 0, void 0, function () {
                var signalPlayer;
                return __generator$2(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            signalPlayer = this.singleInstancePlayer.get(signal);
                            if (!signalPlayer) {
                                signalPlayer = this.signalPlayed.get(signal);
                                if (!signalPlayer) {
                                    signalPlayer = new MediaSignalPlayer(signal, this.phoneSignal);
                                    this.signalPlayed.set(signal, signalPlayer);
                                }
                            }
                            if (conf && signalPlayer) {
                                signalPlayer.setConfiguration(conf);
                                signalPlayer.changeVolume(this.phoneSignal.getVolume(signal, conf));
                            }
                            return [4 , signalPlayer.setOutputDevice(device ? device : this.getOutputDeviceBySignal(signal))];
                        case 1:
                            _a.sent();
                            return [2 , signalPlayer];
                    }
                });
            });
        };
        CallMediaSignalPlayer.prototype.changeVolume = function (volume, mediaSignal) {
            this.signalPlayed.forEach(function (signalPlayer) {
                if (!mediaSignal || signalPlayer.getSignal() == mediaSignal) {
                    signalPlayer.changeVolume(volume);
                }
            });
        };
        CallMediaSignalPlayer.prototype.getCurrentPlay = function () {
            return this.currentPlay;
        };
        CallMediaSignalPlayer.prototype.getMediaSignalPlayer = function (type) {
            var player = this.singleInstancePlayer.get(type);
            return player ? player : this.signalPlayed.get(type);
        };
        CallMediaSignalPlayer.prototype.getMediaSignalPlayerTest = function (type) {
            return this.signalPlayed.get(type);
        };
        CallMediaSignalPlayer.prototype.stop = function (immediate) {
            this.log.debug("CallMediaSignalPlayer - request stop - immediate: " + immediate);
            this.currentPlay = null;
            if (this.signalPlayed.size) {
                this.signalPlayed.forEach(function (signalPlayer) {
                    signalPlayer.stop(immediate);
                });
                this.signalPlayed.clear();
            }
            if (this.dtmfPlayer && this.dtmfPlayer.length) {
                this.dtmfPlayer.forEach(function (dtmfPlayer) {
                    dtmfPlayer.destroy();
                });
                this.dtmfPlayer = [];
            }
        };
        CallMediaSignalPlayer.prototype.playDTMF = function (dtmf, duration, interToneGap) {
            return __awaiter$2(this, void 0, void 0, function () {
                var dtmfPlayer;
                var _this = this;
                return __generator$2(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            dtmfPlayer = new DtmfPlayer(this.phoneSignal, duration, interToneGap);
                            this.dtmfPlayer.push(dtmfPlayer);
                            return [4 , dtmfPlayer.initDestination()];
                        case 1:
                            _a.sent();
                            dtmfPlayer
                                .playDTMF(dtmf)
                                .pipe(finalize(function () {
                                dtmfPlayer.destroy();
                                var indexOfPlayer = _this.dtmfPlayer.indexOf(dtmfPlayer);
                                if (indexOfPlayer > -1) {
                                    _this.dtmfPlayer.splice(indexOfPlayer, 1);
                                }
                            }))
                                .subscribe();
                            return [2 , true];
                    }
                });
            });
        };
        CallMediaSignalPlayer.prototype.play = function (type, conf, ignoreLoop, device, resolveOnSignalEnd) {
            return __awaiter$2(this, void 0, void 0, function () {
                var phoneSignalPlayer;
                return __generator$2(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            this.log.debug("CallMediaSignalPlayer - request play - " + type);
                            this.currentPlay = type;
                            return [4 , this.buildPhoneSignal(type, conf, device)];
                        case 1:
                            phoneSignalPlayer = _a.sent();
                            if (this.currentPlay === type) {
                                return [2 , phoneSignalPlayer.play(ignoreLoop, !!resolveOnSignalEnd)];
                            }
                            else {
                                this.log.debug("CallMediaSignalPlayer - block play " + type + " - current play '" + this.currentPlay + "' is different from '" + type + "'");
                            }
                            return [2 ];
                    }
                });
            });
        };
        return CallMediaSignalPlayer;
    }());
    var CallMediaSignalPlayerStore =  (function () {
        function CallMediaSignalPlayerStore(
        instance) {
            this.instance = instance;
            this.log = Log$1.of("webrtc:phonesignal", instance.webrtc.client);
            this.currentPhoneSignal = new Map();
            this.singleInstancePlayer = new Map();
        }
        CallMediaSignalPlayerStore.prototype.reloadConfig = function () {
            var signalOptions = this.instance.getConfig();
            if (signalOptions) {
                this.stopSingleInstancePlayerIfNeedle();
                this.singleInstancePlayer.set(MediaSignal.ring, new MediaSignalPlayer(MediaSignal.ring, this.instance));
                this.singleInstancePlayer.set(MediaSignal.ringAdvertising, new MediaSignalPlayer(MediaSignal.ringAdvertising, this.instance));
            }
        };
        CallMediaSignalPlayerStore.prototype.createNewIfNotSet = function (callId) {
            var phoneSignalPlayer = this.currentPhoneSignal.get(callId);
            if (!phoneSignalPlayer) {
                phoneSignalPlayer = new CallMediaSignalPlayer(this.log, callId, this.instance, this.singleInstancePlayer);
                this.currentPhoneSignal.set(callId, phoneSignalPlayer);
            }
            return phoneSignalPlayer;
        };
        CallMediaSignalPlayerStore.prototype.get = function (callId) {
            return this.createNewIfNotSet(callId);
        };
        CallMediaSignalPlayerStore.prototype.getCurrentPlay = function (callId) {
            var phoneSignalPlayer = this.currentPhoneSignal.get(callId);
            return phoneSignalPlayer ? phoneSignalPlayer.getCurrentPlay() : null;
        };
        CallMediaSignalPlayerStore.prototype.playDTMF = function (callId, dtmf, duration, interToneGap) {
            this.log.info("callid: " + callId + " - playDTMF: " + dtmf);
            this.get(callId).playDTMF(dtmf, duration, interToneGap);
        };
        CallMediaSignalPlayerStore.prototype.play = function (callId, type) {
            this.log.info("callid: " + callId + " - play: " + type);
            return this.get(callId).play(type, null, false, null, false);
        };
        CallMediaSignalPlayerStore.prototype.stop = function (callId, immediate) {
            this.log.info("callid: " + callId + " - stop all");
            this.get(callId).stop(immediate);
        };
        CallMediaSignalPlayerStore.prototype.delete = function (callId) {
            this.get(callId).stop(true);
            this.currentPhoneSignal.delete(callId);
        };
        CallMediaSignalPlayerStore.prototype.keys = function () {
            return this.currentPhoneSignal.keys();
        };
        CallMediaSignalPlayerStore.prototype.size = function () {
            return this.currentPhoneSignal.size;
        };
        CallMediaSignalPlayerStore.prototype.changeVolume = function (volume, mediaSignal, callId) {
            this.currentPhoneSignal.forEach(function (signalPlayed, idcall) {
                if (!callId || idcall === callId) {
                    signalPlayed.changeVolume(volume, mediaSignal);
                }
            });
            this.singleInstancePlayer.forEach(function (signalPlayer) {
                if (!mediaSignal || signalPlayer.getSignal() == mediaSignal) {
                    signalPlayer.changeVolume(volume);
                }
            });
        };
        CallMediaSignalPlayerStore.prototype.stopSingleInstancePlayerIfNeedle = function (signal) {
            if (signal) {
                if (this.singleInstancePlayer.has(signal)) {
                    var otherCallSameSignal_1 = 0;
                    this.currentPhoneSignal.forEach(function (callPhoneSignalPlayer) {
                        var currentPlay = callPhoneSignalPlayer.getCurrentPlay();
                        if (currentPlay && currentPlay == signal) {
                            otherCallSameSignal_1++;
                        }
                    });
                    if (otherCallSameSignal_1 === 0) {
                        this.log.debug("stopSingleInstancePlayerIfNeedle - no other call is play " + signal + ", stop now");
                        this.singleInstancePlayer.get(signal).stop(false);
                    }
                    else {
                        this.log.debug("stopSingleInstancePlayerIfNeedle - other call is play " + signal + ", so can't stop now");
                    }
                }
            }
            else {
                this.singleInstancePlayer.forEach(function (signalPlayer) {
                    signalPlayer.stop(false);
                });
            }
        };
        CallMediaSignalPlayerStore.prototype.convertRingAdvertisingToRingIfNeedle = function () {
            if (this.currentPhoneSignal.size) {
                var ringadv_1 = [];
                this.currentPhoneSignal.forEach(function (phoneSignal, callId) {
                    if (phoneSignal.getCurrentPlay() === "ringAdvertising") {
                        ringadv_1.push(callId);
                    }
                });
                var doConvert = ringadv_1.length === this.currentPhoneSignal.size;
                this.log.debug("convertRingAdvertisingToRingIfNeedle - " + (doConvert ? ringadv_1[0] + " convert to ring" : "No need to convert") + " - PhoneSignal: " + this.currentPhoneSignal.size + ", ringAdvertising: " + ringadv_1.length);
                if (doConvert) {
                    this.stop(ringadv_1[0], true);
                    this.play(ringadv_1[0], MediaSignal.ring);
                }
            }
            else {
                this.log.debug("convertRingAdvertisingToRingIfNeedle - PhoneSignal: 0");
            }
        };
        return CallMediaSignalPlayerStore;
    }());

    var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator$1 = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    var WebrtDeviceManager =  (function () {
        function WebrtDeviceManager(
        manager) {
            var _this = this;
            this.manager = manager;
            this._execNotifyAvailableMedia = new Subject();
            this._mediaNotified = {};
            this._localMediaTestStarted = false;
            this._log = Log$1.of("webrtc:device", manager.client);
            this._deviceSubject = new BehaviorSubject(null);
            this._localMediaTestAudioLevelSubscription = Subscription.EMPTY;
            this._localMediaTestAudioLevel = new Subject();
            this._deviceSelected = {};
            if (navigator && navigator.mediaDevices) {
                var onDeviceChangeHandler_1 = function () {
                    return from(_this.checkMediaDevice(false, true, true)).subscribe(function (mediaDevice) { return _this.updateMediaDeviceSubject(mediaDevice); }, function (err) { return _this._log.error(err); });
                };
                var prevOndevicechange_1 = navigator.mediaDevices.ondevicechange;
                navigator.mediaDevices.ondevicechange = function () {
                    if (prevOndevicechange_1)
                        prevOndevicechange_1.apply(this, arguments);
                    onDeviceChangeHandler_1.apply(this, arguments);
                };
            }
            combineLatest([
                this.manager.client.loginProfileLoggedOnNewSession,
                this._deviceSubject.pipe(filter(function (deviceStatus) { return !!deviceStatus; }), map(function (deviceStatus) {
                    var availableMedia = {};
                    var _loop_1 = function (type) {
                        var availableDeviceCounter = 0;
                        if (deviceStatus[type] && deviceStatus[type].length) {
                            deviceStatus[type].forEach(function (d) {
                                if (d.status && d.status !== DeviceStatusValue.del) {
                                    availableDeviceCounter++;
                                }
                            });
                        }
                        availableMedia[type] = availableDeviceCounter > 0;
                    };
                    for (var type in deviceStatus) {
                        _loop_1(type);
                    }
                    return availableMedia;
                }), distinctUntilChanged(function (prev, curr) {
                    if (Object.keys(prev).length === Object.keys(curr).length) {
                        for (var type in curr) {
                            if (prev.hasOwnProperty(type)) {
                                if (curr[type] !== prev[type]) {
                                    return false;
                                }
                            }
                            else {
                                return false;
                            }
                        }
                        return true;
                    }
                    else {
                        return false;
                    }
                })),
                this._execNotifyAvailableMedia.pipe(throttleTime(200, asyncScheduler, { leading: false, trailing: true })),
            ])
                .pipe(filter(function (_a) {
                var loginProfile = _a[0], mediaInputAvailable = _a[1];
                return _this.manager.enable && loginProfile && !!mediaInputAvailable;
            }), map(function (_a) {
                _a[0]; var mediaInputAvailable = _a[1];
                return { audio: mediaInputAvailable.audio_input, video: mediaInputAvailable.video_input && (typeof _this.videoInput === "boolean" ? _this.videoInput : true), desktop: mediaInputAvailable.desktop, data: false };
            }),
            concatMap(function (mediaNotified) {
                _this._mediaNotified = mediaNotified;
                if (_this.manager.options.notifyAvailableMedia) {
                    _this._log.debug("Notify available media");
                    return _this.manager.methods.setWebRTCAvailableMedia(_this._mediaNotified).pipe(tap(function (response) {
                        if (response) {
                            _this._log.debug("Available media notified");
                        }
                        else {
                            _this._log.error("Available media notified but have unexpected response");
                        }
                    }), catchError(function (err) {
                        _this._log.error("Error on notify available media", err);
                        return of(false);
                    }));
                }
                else {
                    _this._log.info("options.notifyAvailableMedia is not enable, no call to setWebRTCAvailableMedia");
                    return of(true);
                }
            }))
                .subscribe();
        }
        Object.defineProperty(WebrtDeviceManager.prototype, "audioInput", {
            get: function () {
                return this._deviceSelected.audioInput;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebrtDeviceManager.prototype, "videoInput", {
            get: function () {
                return this._deviceSelected.videoInput;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebrtDeviceManager.prototype, "audioOutput", {
            get: function () {
                return this._deviceSelected.audioOutput;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebrtDeviceManager.prototype, "audioSignalOutput", {
            get: function () {
                return this._deviceSelected.audioSignalOutput;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebrtDeviceManager.prototype, "status", {
            get: function () {
                return this._deviceSubject.asObservable();
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebrtDeviceManager.prototype, "callMediaNotified", {
            get: function () {
                return this._mediaNotified;
            },
            enumerable: false,
            configurable: true
        });
        WebrtDeviceManager.prototype.init = function () {
            return __awaiter$1(this, void 0, void 0, function () {
                var _this = this;
                return __generator$1(this, function (_a) {
                    if (!this._loaded && this.manager.enable) {
                        this._loaded = true;
                        return [2 , combineLatest([this.setMediaDevice(this.manager.options.audioDeviceInput, this.manager.options.videoDeviceInput, this.manager.options.audioDeviceOutput, this.manager.options.audioDeviceSignalOutput), checkActiveX(this.manager)])
                                .pipe(switchMap(function () { return getMediaDevice(false, true, true); }), map(function (mediaDevice) { return _this.updateMediaDeviceSubject(mediaDevice); }), catchError(function (e) {
                                _this._log.error("Error on retrive media devices", e);
                                return empty();
                            }), switchMap(function () {
                                if (!Object.keys(_this._mediaNotified).length) {
                                    _this.notifyAvailableMedia();
                                }
                                return empty();
                            }))
                                .toPromise()];
                    }
                    return [2 ];
                });
            });
        };
        WebrtDeviceManager.prototype.notifyAvailableMedia = function () {
            this._execNotifyAvailableMedia.next();
            return true;
        };
        WebrtDeviceManager.prototype.setMediaDevice = function (audio_input, video_input, audio_output, audio_signal_output) {
            return __awaiter$1(this, void 0, void 0, function () {
                var err_1;
                return __generator$1(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            this._deviceSelected.audioInput = audio_input ? audio_input : null;
                            this._deviceSelected.videoInput = typeof video_input === "boolean" ? video_input : video_input === null || !!video_input ? video_input : false;
                            this._deviceSelected.audioOutput = audio_output ? audio_output : null;
                            this._deviceSelected.audioSignalOutput = audio_signal_output ? audio_signal_output : null;
                            if (!(this._deviceSelected.audioInput || this._deviceSelected.videoInput || this._deviceSelected.audioOutput || this._deviceSelected.audioSignalOutput)) return [3 , 4];
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 3, , 4]);
                            return [4 , this.checkMediaDevice(false, true, true)];
                        case 2:
                            _a.sent();
                            return [3 , 4];
                        case 3:
                            err_1 = _a.sent();
                            this._log.error(err_1);
                            return [3 , 4];
                        case 4:
                            this.notifyAvailableMedia();
                            return [2 ];
                    }
                });
            });
        };
        WebrtDeviceManager.prototype.getMediaDeviceAvailable = function () {
            return __awaiter$1(this, void 0, void 0, function () {
                return __generator$1(this, function (_a) {
                    return [2 , getMediaDeviceAvailable()];
                });
            });
        };
        WebrtDeviceManager.prototype.getMediaDevice = function (startMedia, acquireAudio, acquireVideo) {
            if (acquireAudio === void 0) { acquireAudio = true; }
            if (acquireVideo === void 0) { acquireVideo = true; }
            return getMediaDevice(startMedia, acquireAudio, acquireVideo);
        };
        WebrtDeviceManager.prototype.checkAudioDevicePermission = function () {
            return __awaiter$1(this, void 0, void 0, function () {
                var localMedia;
                return __generator$1(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            localMedia = new icelink.LocalMedia(true, false, false);
                            return [4 , icelinkUtils.futureToPromise(localMedia.start())];
                        case 1:
                            _a.sent();
                            return [4 , icelinkUtils.futureToPromise(localMedia.stop())];
                        case 2:
                            _a.sent();
                            return [2 , true];
                    }
                });
            });
        };
        WebrtDeviceManager.prototype.checkVideoDevicePermission = function () {
            return __awaiter$1(this, void 0, void 0, function () {
                var localMedia;
                return __generator$1(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            localMedia = new icelink.LocalMedia(false, true, false);
                            return [4 , icelinkUtils.futureToPromise(localMedia.start())];
                        case 1:
                            _a.sent();
                            return [4 , icelinkUtils.futureToPromise(localMedia.stop())];
                        case 2:
                            _a.sent();
                            return [2 , true];
                    }
                });
            });
        };
        WebrtDeviceManager.prototype.testMediaDevice = function (audio_input, video_input, audio_output, videoContainer) {
            return __awaiter$1(this, void 0, void 0, function () {
                var htmlMediaElement, audioSink, e_1;
                var _this = this;
                return __generator$1(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!(audio_input || video_input) ) return [3 , 13];
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 10, , 12]);
                            return [4 , this.stopTestMediaDevice()];
                        case 2:
                            _a.sent();
                            this._localMediaTest = new icelink.LocalMedia(!!audio_input, !!video_input, false);
                            if (!audio_input) return [3 , 4];
                            return [4 , icelinkUtils.futureToPromise(this._localMediaTest.changeAudioSourceInput(audio_input))];
                        case 3:
                            _a.sent();
                            _a.label = 4;
                        case 4:
                            if (!video_input) return [3 , 6];
                            return [4 , icelinkUtils.futureToPromise(this._localMediaTest.changeVideoSourceInput(video_input))];
                        case 5:
                            _a.sent();
                            _a.label = 6;
                        case 6: return [4 , icelinkUtils.futureToPromise(this._localMediaTest.start())];
                        case 7:
                            _a.sent();
                            this._localMediaTestStarted = true;
                            this._localMediaTestAudioLevelSubscription.unsubscribe();
                            this._localMediaTestAudioLevelSubscription = icelinkUtils.audioTrackLevelToObservable(this._localMediaTest).subscribe(function (value) { return _this._localMediaTestAudioLevel.next(value); });
                            new icelink.DomLayoutManager(videoContainer).setLocalMedia(this._localMediaTest);
                            htmlMediaElement = null;
                            try {
                                audioSink = icelinkUtils.tryInternal(this._localMediaTest.getAudioTrack(), { m: "_getInternal" }, { m: "getMedia" }, { m: "_audioSink" });
                                htmlMediaElement = audioSink.getAudio();
                                htmlMediaElement.srcObject = icelinkUtils.tryInternal(audioSink.getTrack().getMedia(), { m: "_getAudioMediaStream" });
                            }
                            catch (e) {
                                htmlMediaElement = this._localMediaTest.getViewSink().getView().childNodes[0];
                            }
                            if (!htmlMediaElement) return [3 , 9];
                            return [4 , setSinkOutput(htmlMediaElement, audio_output ? audio_output.getId() : null)];
                        case 8:
                            _a.sent();
                            htmlMediaElement.muted = false;
                            _a.label = 9;
                        case 9: return [2 , this._localMediaTestStarted];
                        case 10:
                            e_1 = _a.sent();
                            return [4 , this.stopTestMediaDevice()];
                        case 11:
                            _a.sent();
                            throw e_1;
                        case 12: return [3 , 14];
                        case 13: throw new Error("No media device to test");
                        case 14: return [2 ];
                    }
                });
            });
        };
        WebrtDeviceManager.prototype.stopTestMediaDevice = function () {
            return __awaiter$1(this, void 0, void 0, function () {
                return __generator$1(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!this._localMediaTestStarted) return [3 , 2];
                            this._localMediaTestStarted = false;
                            this._localMediaTestAudioLevelSubscription.unsubscribe();
                            return [4 , icelinkUtils.futureToPromise(this._localMediaTest.stop())];
                        case 1:
                            _a.sent();
                            _a.label = 2;
                        case 2: return [2 , true];
                    }
                });
            });
        };
        WebrtDeviceManager.prototype.getLocalMediaTestAudioLevel = function () {
            return this._localMediaTestAudioLevel.asObservable();
        };
        WebrtDeviceManager.prototype.checkMediaDevice = function (startMedia, acquireAudio, acquireVideo) {
            return __awaiter$1(this, void 0, void 0, function () {
                var mediaDevice;
                return __generator$1(this, function (_a) {
                    switch (_a.label) {
                        case 0: return [4 , getMediaDevice(startMedia, acquireAudio, acquireVideo)];
                        case 1:
                            mediaDevice = _a.sent();
                            if (this._deviceSelected.audioInput && !devicesHasDevice(this._deviceSelected.audioInput, mediaDevice.audio_input)) {
                                this._deviceSelected.audioInput = null;
                            }
                            if (typeof this._deviceSelected.videoInput === "boolean") {
                                this._deviceSelected.videoInput = false === this._deviceSelected.videoInput ? false : null;
                            }
                            else if (this._deviceSelected.videoInput && !devicesHasDevice(this._deviceSelected.videoInput, mediaDevice.video_input)) {
                                this._deviceSelected.videoInput = null;
                            }
                            if (this._deviceSelected.audioOutput && !devicesHasDevice(this._deviceSelected.audioOutput, mediaDevice.audio_output)) {
                                this._deviceSelected.audioOutput = null;
                            }
                            if (this._deviceSelected.audioSignalOutput && !devicesHasDevice(this._deviceSelected.audioSignalOutput, mediaDevice.audio_output)) {
                                this._deviceSelected.audioSignalOutput = null;
                            }
                            return [2 , mediaDevice];
                    }
                });
            });
        };
        WebrtDeviceManager.prototype.updateMediaDeviceSubject = function (mediaDevice) {
            var lastDevice = this._deviceSubject.value;
            var newDevice = {
                audio_input: this.elaborateDeviceStatus(lastDevice ? lastDevice.audio_input : null, mediaDevice ? mediaDevice.audio_input : null),
                video_input: this.elaborateDeviceStatus(lastDevice ? lastDevice.video_input : null, mediaDevice ? mediaDevice.video_input : null),
                audio_output: this.elaborateDeviceStatus(lastDevice ? lastDevice.audio_output : null, mediaDevice ? mediaDevice.audio_output : null),
            };
            this._log.info("Media device change", lastDevice, newDevice);
            this._deviceSubject.next(newDevice);
        };
        WebrtDeviceManager.prototype.elaborateDeviceStatus = function (current, devices) {
            var result = [];
            var status = DeviceStatusValue.none;
            if (current && current.length) {
                status = DeviceStatusValue.add;
                for (var index = 0; index < current.length; index++) {
                    if (current[index].status === DeviceStatusValue.del) {
                        current.splice(index, 1);
                        continue;
                    }
                    var prevDevice = Object.assign({}, current[index]);
                    var newDevice = devicesHasDevice(prevDevice.device, devices);
                    if (newDevice) {
                        prevDevice.status = DeviceStatusValue.none;
                        devices.splice(newDevice.index, 1);
                    }
                    else {
                        prevDevice.status = DeviceStatusValue.del;
                    }
                    result.push(prevDevice);
                }
            }
            if (devices && devices.length) {
                result.push.apply(result, devices.map(function (device) {
                    return { device: device, status: status };
                }));
            }
            return result;
        };
        return WebrtDeviceManager;
    }());
    function devicesHasDevice(device, sources) {
        if (sources && sources.length) {
            for (var index = 0; index < sources.length; index++) {
                if (sources[index].getId() === device.getId()) {
                    return {
                        device: sources[index],
                        index: index,
                    };
                }
            }
        }
        return null;
    }
    function checkActiveX(manager) {
        return __awaiter$1(this, void 0, void 0, function () {
            var pluginConfig, res;
            return __generator$1(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!manager.options.ieactivex) return [3 , 2];
                        pluginConfig = new icelink.PluginConfig();
                        pluginConfig.setActiveXPath(manager.options.ieactivex);
                        return [4 , icelinkUtils.futureToPromise(icelink.Plugin.install(pluginConfig))];
                    case 1:
                        res = _a.sent();
                        if (!icelink.Plugin.isReady(true)) {
                            if (icelink.Plugin.isReady()) {
                                throw new Error("This browser supports WebRTC, but does not support media capture.");
                            }
                            else {
                                throw new Error("This browser does not support WebRTC, and no plugin could be found.");
                            }
                        }
                        return [2 , res];
                    case 2: return [2 , null];
                }
            });
        });
    }
    function getMediaDeviceAvailable() {
        var localMedia = new icelink.LocalMedia(false, false, false);
        var remoteMedia = new icelink.RemoteMedia();
        return combineLatest([icelinkUtils.futureToPromise(localMedia.getAudioSourceInputs()), icelinkUtils.futureToPromise(localMedia.getVideoSourceInputs()), icelinkUtils.futureToPromise(remoteMedia.getAudioSinkOutputs())])
            .pipe(map(function (sourcesInputOutput) {
            return {
                audio_input: sourcesInputOutput[0] && sourcesInputOutput[0].length > 0,
                video_input: sourcesInputOutput[1] && sourcesInputOutput[1].length > 0,
                audio_output: sourcesInputOutput[2] && sourcesInputOutput[2].length > 0,
                desktop: !(icelink.Plugin.getChromeExtensionRequired() && !icelink.LocalMedia.getChromeExtensionInstalled()),
            };
        }))
            .toPromise();
    }
    function getMediaDevice(startMedia, acquireAudio, acquireVideo) {
        return __awaiter$1(this, void 0, void 0, function () {
            var mediaEnabled, remoteMedia, localMedia;
            var _this = this;
            return __generator$1(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 , getMediaDeviceAvailable()];
                    case 1:
                        mediaEnabled = _a.sent();
                        remoteMedia = new icelink.RemoteMedia();
                        localMedia = new icelink.LocalMedia(mediaEnabled && mediaEnabled.audio_input && acquireAudio, mediaEnabled && mediaEnabled.video_input && acquireVideo, false);
                        if (!startMedia) return [3 , 3];
                        return [4 , icelinkUtils.futureToPromise(localMedia.start())];
                    case 2:
                        _a.sent();
                        _a.label = 3;
                    case 3: return [2 , combineLatest([icelinkUtils.futureToPromise(localMedia.getAudioSourceInputs()), icelinkUtils.futureToPromise(localMedia.getVideoSourceInputs()), icelinkUtils.futureToPromise(remoteMedia.getAudioSinkOutputs())])
                            .pipe(switchMap(function (sources) {
                            return defer(function () { return __awaiter$1(_this, void 0, void 0, function () {
                                return __generator$1(this, function (_a) {
                                    switch (_a.label) {
                                        case 0:
                                            if (!startMedia) return [3 , 2];
                                            return [4 , icelinkUtils.futureToPromise(localMedia.stop())];
                                        case 1:
                                            _a.sent();
                                            _a.label = 2;
                                        case 2: return [2 , sources];
                                    }
                                });
                            }); });
                        }), map(function (sources) {
                            return {
                                audio_input: sources[0],
                                video_input: sources[1],
                                audio_output: sources[2],
                            };
                        }), catchError(function (err) {
                            return defer(function () { return __awaiter$1(_this, void 0, void 0, function () {
                                var e_2;
                                return __generator$1(this, function (_a) {
                                    switch (_a.label) {
                                        case 0:
                                            if (!startMedia) return [3 , 4];
                                            _a.label = 1;
                                        case 1:
                                            _a.trys.push([1, 3, , 4]);
                                            return [4 , icelinkUtils.futureToPromise(localMedia.stop())];
                                        case 2:
                                            _a.sent();
                                            return [3 , 4];
                                        case 3:
                                            e_2 = _a.sent();
                                            return [3 , 4];
                                        case 4: throw err;
                                    }
                                });
                            }); });
                        }))
                            .toPromise()];
                }
            });
        });
    }

    var __extends = (undefined && undefined.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    };
    var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    };
    icelink.Log.removeProviders();
    var WebRTCManager =  (function () {
        function WebRTCManager(options) {
            if (options === void 0) { options = new WebrtcConfig(); }
            this._callIdToRemove = new Set();
            this._controlMessageNotifierSubscription = Subscription.EMPTY;
            this._connectionStateSubscription = Subscription.EMPTY;
            this._loadedOptions = new WebrtcConfig(options);
            this.applyOptions();
        }
        Object.defineProperty(WebRTCManager.prototype, "client", {
            get: function () {
                return this._client;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebRTCManager.prototype, "enable", {
            get: function () {
                return !!this._enabled;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebRTCManager.prototype, "options", {
            get: function () {
                return this._loadedOptions;
            },
            set: function (options) {
                this._loadedOptions = new WebrtcConfig(options);
                this.applyOptions();
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebRTCManager.prototype, "methods", {
            get: function () {
                return this._apiMethods;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebRTCManager.prototype, "connectionState", {
            get: function () {
                return this._connectionStateSubject.asObservable();
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebRTCManager.prototype, "trickleIcePolicy", {
            get: function () {
                return icelink.TrickleIcePolicy[this.options.trickleIcePolicy] || icelink.TrickleIcePolicy.NotSupported;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebRTCManager.prototype, "layoutManager", {
            get: function () {
                return this._layoutManagerByOption;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebRTCManager.prototype, "phoneSignal", {
            get: function () {
                return this._phoneSignalManager;
            },
            enumerable: false,
            configurable: true
        });
        Object.defineProperty(WebRTCManager.prototype, "device", {
            get: function () {
                return this._deviceManager;
            },
            enumerable: false,
            configurable: true
        });
        WebRTCManager.prototype.attachToClient = function (client) {
            var prevClient = this._client;
            this._client = client;
            if (!prevClient || prevClient.instanceId !== client.instanceId) {
                this._log = Log$1.of("webrtc", client);
                this._log.info("WebRTCManager attached to client, configuration used:", this._loadedOptions);
                this._enabled = false;
                this._callIdToRemove.clear();
                this._icelinkLogger = new IcelinkLogger(this);
                this._apiMethods = new WebRTCMethods(client);
                if (!client.webrtc || (prevClient && prevClient.instanceId != client.instanceId)) {
                    client.webrtc = this;
                }
            }
        };
        WebRTCManager.prototype.initFromClient = function (controlMessageNotifier) {
            if (controlMessageNotifier) {
                this._controlMessageNotifier = controlMessageNotifier;
                this.init();
            }
        };
        WebRTCManager.prototype.init = function () {
            this._log.info("WebRTCManager init");
            this._connections = new Map();
            this._connectionStateSubject = new Subject();
            this._deviceManager = new WebrtDeviceManager(this);
            this._phoneSignalManager = new PhoneSignalManager(this);
            if (this._loadedOptions.enabled) {
                return this.start();
            }
            else {
                return Promise.resolve();
            }
        };
        WebRTCManager.prototype.applyOptions = function () {
            var options = this._loadedOptions;
            if (options.iceServers) {
                this._iceServers = options.iceServers.map(function (iceServer) { return (iceServer.username ? new icelink.IceServer(iceServer.url, iceServer.username, iceServer.password) : new icelink.IceServer(iceServer.url)); });
            }
            else {
                this._iceServers = null;
            }
            if (options.videoContainer) {
                this._layoutManagerByOption = new icelink.DomLayoutManager(options.videoContainer, options.layoutPreset);
            }
        };
        WebRTCManager.prototype.phoneSignalPlayEnabled = function () {
            return this.phoneSignal
                .getGestureRequired()
                .asObservable()
                .pipe(map(function (res) { return (res === null ? res : !res); }));
        };
        WebRTCManager.prototype.getIceServers = function () {
            return __awaiter(this, void 0, void 0, function () {
                var response, e_1;
                var _this = this;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            if (!(!this._iceServers || this._iceServers.length === 0)) return [3 , 4];
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 3, , 4]);
                            return [4 , this._apiMethods.getWebrtcConfiguration().toPromise()];
                        case 2:
                            response = _a.sent();
                            this._iceServers = [];
                            if (response) {
                                if (response.iceServers && response.iceServers.length) {
                                    response.iceServers.forEach(function (s) {
                                        if (s && s.url) {
                                            try {
                                                _this._iceServers.push(s.hasOwnProperty("username") ? new icelink.IceServer(s.url, s.username, s.password || "") : new icelink.IceServer(s.url));
                                            }
                                            catch (e) {
                                                _this._log.error("Error on create IceServer", e);
                                            }
                                        }
                                    });
                                }
                            }
                            return [3 , 4];
                        case 3:
                            e_1 = _a.sent();
                            this._log.error("Error on getWebrtcConfiguration", e_1);
                            return [3 , 4];
                        case 4: return [2 , this._iceServers];
                    }
                });
            });
        };
        WebRTCManager.prototype.setEnabledOnChannel = function (channels) {
            if (channels) {
                this._loadedOptions.enabledOnChannel.length = 0;
                this._loadedOptions.enabledOnChannel.push.apply(this._loadedOptions.enabledOnChannel, channels);
                this._log.debug("Enabled on channels " + this._loadedOptions.enabledOnChannel.join(","));
            }
        };
        WebRTCManager.prototype.start = function () {
            return __awaiter(this, void 0, void 0, function () {
                var uniqueId;
                var _this = this;
                return __generator(this, function (_a) {
                    if (!this._enabled && this._client) {
                        icelink.Log.registerProvider(this._icelinkLogger);
                        this._enabled = true;
                        uniqueId = 0;
                        this._log.debug("Enabled on channels " + this._loadedOptions.enabledOnChannel.join(","));
                        this._controlMessageNotifierSubscription.unsubscribe();
                        this._controlMessageNotifierSubscription = this._controlMessageNotifier
                            .pipe(tap(function (data) {
                            data.internalId = ++uniqueId;
                            _this._log.debug("ControlMessageManager - Receiving message " + data.internalId, data);
                        }), concatMap(function (data) {
                            _this._log.debug("ControlMessageManager - Start manage message " + data.internalId + " - " + data.state + " - " + data.callId);
                            return _this.controlMessageHandler(data).catch(function (err) {
                                _this._log.error("ControlMessageManager - Error on manage message " + err.controlMessage.internalId, err);
                                return err.controlMessage;
                            });
                        }))
                            .subscribe(function (data) {
                            _this._log.debug("ControlMessageManager - End manage message " + data.internalId + " - " + data.state + " - " + data.callId);
                        });
                        this._client.loginProfileLoggedOnNewSession.subscribe(function () { return __awaiter(_this, void 0, void 0, function () {
                            return __generator(this, function (_a) {
                                try {
                                    this.getIceServers();
                                }
                                catch (e) { }
                                return [2 ];
                            });
                        }); });
                        this._connectionStateSubscription.unsubscribe();
                        this._connectionStateSubscription = this._client.connectionEvent.subscribe(function (event) {
                            if (event.connected) {
                                _this.cleanPendingCall();
                            }
                        });
                        return [2 , this.device.init()];
                    }
                    return [2 ];
                });
            });
        };
        WebRTCManager.prototype.stop = function () {
            return __awaiter(this, void 0, void 0, function () {
                var _this = this;
                return __generator(this, function (_a) {
                    if (this._enabled) {
                        icelink.Log.removeProvider(this._icelinkLogger);
                        this._controlMessageNotifierSubscription.unsubscribe();
                        this._connectionStateSubscription.unsubscribe();
                        this._enabled = false;
                        this._connections.forEach(function (call) {
                            _this.methods.cancel(call.callId, true, true);
                        });
                    }
                    return [2 ];
                });
            });
        };
        WebRTCManager.prototype.checkUniqueCallBeforeDial = function (dialParam) {
            this._connections.forEach(function (call) {
                if (call.isOffer) {
                    var callDialParams = call.dialParams;
                    if (callDialParams && callDialParams.equals(dialParam)) {
                        throw CallInProgress.newInstance(call.callId);
                    }
                }
            });
        };
        WebRTCManager.prototype.generateWebrtcFieldsForDial = function (dialParam, mediaConfiguration, videoContainer, userInteractionAction) {
            return __awaiter(this, void 0, void 0, function () {
                var callId, call, fromDevice, contact, media, createUserInteraction, e_2;
                var _this = this;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            this.checkUniqueCallBeforeDial(dialParam);
                            callId = icelink.Guid.newGuid().toString();
                            call = this.createCall(callId, ChannelType.PhoneCall, true, CallState.NEW_OUTBOUND, false, dialParam);
                            fromDevice = dialParam.params.fromDevice;
                            contact = dialParam.params.contact;
                            media = dialParam.params.media;
                            createUserInteraction = !(dialParam.params.serviceCode || dialParam.params.abandonedCallId || dialParam.params.callbackRequestId);
                            if (createUserInteraction) {
                                this._apiMethods
                                    .createUserInteraction({
                                    action: userInteractionAction || null,
                                    contact: contact,
                                    callId: callId,
                                    type: UserInteractionType.call,
                                })
                                    .subscribe(function (userInteractionId) {
                                    if (!call || (call.isOffer && !call.state)) {
                                        _this._log.debug("createUserInteraction response before dial for call " + callId + ", emit dummy NEW_OUTBOUND event");
                                        _this._controlMessageNotifier.next({
                                            callId: callId,
                                            device: fromDevice,
                                            direction: CallDirection.outbound,
                                            state: CallState.NEW_OUTBOUND,
                                            features: [CallFeature.CANCEL],
                                            _isFromServer: false,
                                            _channelType: dialParam.params.channelId,
                                            _realChannelType: dialParam.params.channelId,
                                        });
                                    }
                                }, function (error) {
                                    _this._log.error("createUserInteraction error", error);
                                });
                            }
                            _a.label = 1;
                        case 1:
                            _a.trys.push([1, 5, , 6]);
                            if (!call.deviceIsApp) return [3 , 2];
                            return [2 , this.generateWebrtcFieldsForApp(callId, false, media, mediaConfiguration, videoContainer)];
                        case 2: return [4 , this.generateWebrtcFields(call, false, media, mediaConfiguration, videoContainer)];
                        case 3: return [2 , _a.sent()];
                        case 4: return [3 , 6];
                        case 5:
                            e_2 = _a.sent();
                            if (createUserInteraction && call && call.state && call.state === CallState.NEW_OUTBOUND && !call.realState) {
                                this._controlMessageNotifier.next({
                                    callId: callId,
                                    device: fromDevice,
                                    direction: CallDirection.outbound,
                                    state: CallState.IDLE,
                                    _isFromServer: false,
                                    _channelType: dialParam.params.channelId,
                                    _realChannelType: dialParam.params.channelId,
                                });
                            }
                            throw e_2;
                        case 6: return [2 ];
                    }
                });
            });
        };
        WebRTCManager.prototype.generateWebrtcFieldsForCallChannel = function (call, answer, media, mediaConfiguration) {
            return __awaiter(this, void 0, void 0, function () {
                return __generator(this, function (_a) {
                    return [2 , this.generateWebrtcFields(call, answer, media, mediaConfiguration, null)];
                });
            });
        };
        WebRTCManager.prototype.generateWebrtcFieldsForAnswer = function (channelId, callId, media, mediaConfiguration, videoContainer) {
            return __awaiter(this, void 0, void 0, function () {
                var answer, offer, call;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            answer = true;
                            offer = false;
                            if (channelId && channelId === ChannelType.Video) {
                                answer = false;
                                offer = true;
                            }
                            call = this.createCall(callId, channelId, offer, CallState.NEW_INBOUND, false);
                            return [4 , this.phoneSignal.stop(call.callId, false)];
                        case 1:
                            _a.sent();
                            return [2 , this.generateWebrtcFields(call, answer, media, mediaConfiguration, videoContainer).then(function (result) {
                                    call.waitForAnswer = false;
                                    return result;
                                })];
                    }
                });
            });
        };
        WebRTCManager.prototype.generateWebrtcFieldsForConnectivityCheck = function (channelType, media, mediaConfiguration, videoContainer) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.createCall(icelink.Guid.newGuid().toString(), channelType, true, null, true);
                    return [2 , this.generateWebrtcFields(call, false, media, mediaConfiguration, videoContainer)];
                });
            });
        };
        WebRTCManager.prototype.generateWebrtcFieldsForApp = function (callId, answer, media, mediaConfiguration, videoContainer) {
            return new WebRTCField(answer ? null : callId, new WebRTCFieldSession(answer, null), null, null, null);
        };
        WebRTCManager.prototype.generateWebrtcFields = function (call, answer, media, mediaConfiguration, videoContainer) {
            return __awaiter(this, void 0, void 0, function () {
                var err_1, err_2, webrtcField;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            call.mediaEnabled = true;
                            call.videoContainer = videoContainer;
                            if (!(media && (media.audio || media.audio || media.desktop || media.data))) return [3 , 10];
                            if (!!answer) return [3 , 2];
                            return [4 , this.phoneSignal.play(call.callId, MediaSignal.dialtone)];
                        case 1:
                            _a.sent();
                            _a.label = 2;
                        case 2:
                            _a.trys.push([2, 4, , 5]);
                            return [4 , call.setLocalMedia(media, mediaConfiguration)];
                        case 3:
                            _a.sent();
                            return [3 , 5];
                        case 4:
                            err_1 = _a.sent();
                            this._log.error("error on generateWebrtcFields.setLocalMedia", err_1);
                            throw err_1;
                        case 5:
                            _a.trys.push([5, 7, , 8]);
                            return [4 , call.startLocalMedia()];
                        case 6:
                            _a.sent();
                            return [3 , 8];
                        case 7:
                            err_2 = _a.sent();
                            this._log.error("error on generateWebrtcFields.startLocalMedia", err_2);
                            throw err_2;
                        case 8: return [4 , call.initIcelinkConnection()];
                        case 9:
                            _a.sent();
                            webrtcField = call.generateLocalWebRTCField();
                            if (webrtcField.sessionDescription) {
                                webrtcField.sessionDescription.answer = !call.isOffer;
                            }
                            else {
                                webrtcField.sessionDescription = new WebRTCFieldSession(answer, null);
                            }
                            webrtcField.clientid = answer ? null : call.callId;
                            call.localDescriptionIsNotified();
                            return [2 , webrtcField];
                        case 10: return [2 , new WebRTCField(answer ? null : call.callId, new WebRTCFieldSession(answer, null), null, null, null)];
                    }
                });
            });
        };
        WebRTCManager.prototype.toggleHold = function (callId) {
            return __awaiter(this, void 0, void 0, function () {
                var call, callIsHold;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    if (call) {
                        callIsHold = call.state == CallState.HOLD;
                        call.setState(callIsHold ? CallState.CONNECTED : CallState.HOLD, null);
                        return [2 , call.toggleRemoteAudioMute(!callIsHold)];
                    }
                    else {
                        return [2 , false];
                    }
                });
            });
        };
        WebRTCManager.prototype.setLocalMedia = function (callId, media, mediaConfiguration) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            call = this.retriveCall(callId);
                            if (!call) return [3 , 2];
                            return [4 , call.setLocalMedia(media, mediaConfiguration)];
                        case 1:
                            _a.sent();
                            return [2 , this];
                        case 2: throw new Error("idCall is invalid");
                    }
                });
            });
        };
        WebRTCManager.prototype.toggleAudioMute = function (callId, mute) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.toggleAudioMute(mute, true) : false];
                });
            });
        };
        WebRTCManager.prototype.toggleVideoMute = function (callId, mute) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.toggleVideoMute(mute, true) : false];
                });
            });
        };
        WebRTCManager.prototype.toggleRemoteAudioMute = function (callId, mute) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.toggleRemoteAudioMute(mute) : false];
                });
            });
        };
        WebRTCManager.prototype.toggleRemoteVideoMute = function (callId, mute) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.toggleRemoteVideoMute(mute) : false];
                });
            });
        };
        WebRTCManager.prototype.isVideoEnabled = function (callId) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.isVideoEnabled() : false];
                });
            });
        };
        WebRTCManager.prototype.startAudio = function (callId) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.startAudio() : false];
                });
            });
        };
        WebRTCManager.prototype.stopAudio = function (callId) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.stopAudio() : false];
                });
            });
        };
        WebRTCManager.prototype.startVideo = function (callId, constraints, videoContainer) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.startVideo(constraints, videoContainer) : false];
                });
            });
        };
        WebRTCManager.prototype.stopVideo = function (callId) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.stopVideo() : false];
                });
            });
        };
        WebRTCManager.prototype.getLocalVideoFrame = function (callId) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    if (call) {
                        return [2 , call.getLocalVideoFrame()];
                    }
                    else {
                        throw new Error("Call " + callId + " is not defined");
                    }
                });
            });
        };
        WebRTCManager.prototype.getRemoteVideoFrame = function (callId) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    if (call) {
                        return [2 , call.getRemoteVideoFrame()];
                    }
                    else {
                        throw new Error("Call " + callId + " is not defined");
                    }
                });
            });
        };
        WebRTCManager.prototype.setGlobalVideoContainer = function (videoContainer, layoutPreset) {
            this.unsetGlobalVideoContainer();
            this.options.videoContainer = videoContainer;
            if (layoutPreset) {
                this.options.layoutPreset = layoutPreset;
            }
            if (this.options.videoContainer) {
                this._layoutManagerByOption = new icelink.DomLayoutManager(this.options.videoContainer, this.options.layoutPreset);
            }
        };
        WebRTCManager.prototype.unsetGlobalVideoContainer = function () {
            this.options.videoContainer = null;
            if (this._layoutManagerByOption) {
                this._layoutManagerByOption.unsetLocalView();
                this._layoutManagerByOption.removeRemoteViews();
                try {
                    var container = this._layoutManagerByOption.getContainer();
                    if (container) {
                        container.remove();
                    }
                }
                catch (e) { }
                this._layoutManagerByOption = null;
            }
        };
        WebRTCManager.prototype.setVideoContainer = function (callId, videoContainer) {
            var call = this.retriveCall(callId);
            if (call) {
                call.videoContainer = videoContainer;
            }
        };
        WebRTCManager.prototype.unsetVideoContainer = function (callId) {
            var call = this.retriveCall(callId);
            if (call) {
                call.unsetVideoContainer();
            }
        };
        WebRTCManager.prototype.getRemoteAudioLevel = function (callId) {
            var call = this.retriveCall(callId);
            return call ? call.getRemoteAudioLevel() : empty();
        };
        WebRTCManager.prototype.getLocalAudioLevel = function (callId) {
            var call = this.retriveCall(callId);
            return call ? call.getLocalAudioLevel() : empty();
        };
        WebRTCManager.prototype.getMediaStreamStats = function (callId) {
            var call = this.retriveCall(callId);
            return call ? call.getMediaStreamStats() : empty();
        };
        WebRTCManager.prototype.omnideskControlMessageHandler = function (_webrtcControlMessage) {
            return __awaiter(this, void 0, void 0, function () {
                var callInfo, call, deviceIsApp, realEvent, _a, currentPlay;
                return __generator(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            callInfo = _webrtcControlMessage;
                            call = this.retriveCall(callInfo.callId);
                            deviceIsApp = (call && call.deviceIsApp) || (callInfo.device && callInfo.device.startsWith("_app_"));
                            realEvent = callInfo._isFromServer;
                            _a = callInfo.state;
                            switch (_a) {
                                case CallState.NEW_INBOUND: return [3 , 1];
                                case CallState.IDLE: return [3 , 4];
                                case CallState.CONNECTED: return [3 , 13];
                            }
                            return [3 , 14];
                        case 1:
                            if (!call && !deviceIsApp) {
                                call = this.createCall(callInfo.callId, callInfo._channelType, false, callInfo.state, realEvent);
                            }
                            if (!call) return [3 , 3];
                            return [4 , this.phoneSignal.play(call.callId, this._connections.size > 1 ? MediaSignal.ringAdvertising : MediaSignal.ring)];
                        case 2:
                            _b.sent();
                            _b.label = 3;
                        case 3: return [3 , 14];
                        case 4:
                            if (!call) return [3 , 11];
                            if (realEvent) {
                                this._callIdToRemove.delete(call.callId);
                            }
                            else {
                                call.markAsClosedLocal();
                            }
                            currentPlay = this.phoneSignal.getCurrentPlay(call.callId);
                            if (!(call.state === CallState.NEW_INBOUND)) return [3 , 5];
                            this.phoneSignal.stop(call.callId, true);
                            return [3 , 10];
                        case 5:
                            if (!currentPlay) return [3 , 8];
                            if (!(currentPlay !== MediaSignal.hold)) return [3 , 7];
                            if (!!call.isClosedLocal()) return [3 , 7];
                            this.phoneSignal.stop(call.callId, true);
                            return [4 , this.phoneSignal.play(call.callId, currentPlay === MediaSignal.ringback ? MediaSignal.congestion : MediaSignal.busy)];
                        case 6:
                            _b.sent();
                            _b.label = 7;
                        case 7: return [3 , 10];
                        case 8:
                            if (!(!call.isClosedLocal() && callInfo.idleReason && callInfo.idleReason !== IdleReason.HANGUP)) return [3 , 10];
                            return [4 , this.phoneSignal.play(call.callId, callInfo.idleReason === IdleReason.CONGESTION ? MediaSignal.congestion : MediaSignal.busy)];
                        case 9:
                            _b.sent();
                            _b.label = 10;
                        case 10: return [3 , 12];
                        case 11:
                            if (realEvent) {
                                this._callIdToRemove.delete(callInfo.callId);
                            }
                            _b.label = 12;
                        case 12:
                            if (this.destroyCall(callInfo.callId)) {
                                call = null;
                            }
                            return [3 , 14];
                        case 13:
                            if (call) {
                                call.waitForAnswer = false;
                                this.phoneSignal.stop(call.callId, true);
                            }
                            return [3 , 14];
                        case 14:
                            if (call) {
                                call.setState(callInfo.state, realEvent, true);
                            }
                            else {
                                if (callInfo.state !== CallState.IDLE) {
                                    throw new Error("No call");
                                }
                            }
                            return [2 , _webrtcControlMessage];
                    }
                });
            });
        };
        WebRTCManager.prototype.controlMessageHandler = function (_webrtcControlMessage) {
            return __awaiter(this, void 0, void 0, function () {
                var callInfo, call, deviceIsApp, webrtcfields, localMediaFeature, realEvent, media, _a, offer, playringback, currentPlay, err_3;
                return __generator(this, function (_b) {
                    switch (_b.label) {
                        case 0:
                            _b.trys.push([0, 54, , 55]);
                            if (!_webrtcControlMessage) {
                                throw new Error("controlMessageHandler - message is invalid");
                            }
                            if (_webrtcControlMessage._channelType === ChannelType.Omnidesk) {
                                return [2 , this.omnideskControlMessageHandler(_webrtcControlMessage)];
                            }
                            callInfo = _webrtcControlMessage;
                            if (this._loadedOptions.enabledOnChannel.indexOf(callInfo._channelType) < 0) {
                                throw new Error("controlMessageHandler - Channel " + callInfo._channelType + " not enabled for webrtc");
                            }
                            call = this.retriveCall(callInfo.callId);
                            deviceIsApp = (call && call.deviceIsApp) || (callInfo.device && callInfo.device.startsWith("_app_"));
                            webrtcfields = callInfo.fields ? WebRTCField.fromObject(callInfo.fields) : null;
                            localMediaFeature = {};
                            realEvent = callInfo._isFromServer;
                            if (callInfo.media_feature && callInfo.media_feature.local) {
                                for (media in callInfo.media_feature.local) {
                                    localMediaFeature[media] = new Set(callInfo.media_feature.local[media] ? callInfo.media_feature.local[media] : []);
                                }
                            }
                            _a = callInfo.state;
                            switch (_a) {
                                case CallState.NEW_INBOUND: return [3 , 1];
                                case CallState.NEW_OUTBOUND: return [3 , 10];
                                case CallState.IDLE: return [3 , 19];
                                case CallState.CONNECTED: return [3 , 31];
                                case CallState.HOLD: return [3 , 43];
                            }
                            return [3 , 50];
                        case 1:
                            offer = callInfo._channelType === ChannelType.Video;
                            if (!call && !deviceIsApp) {
                                call = this.createCall(callInfo.callId, callInfo._channelType, offer, callInfo.state, realEvent);
                            }
                            if (!call) return [3 , 9];
                            if (!webrtcfields) return [3 , 3];
                            call.remoteWebrtcfield = webrtcfields;
                            return [4 , call.tryAutoanswer()];
                        case 2:
                            _b.sent();
                            _b.label = 3;
                        case 3:
                            if (callInfo.remote_media_status) {
                                call.remoteMedia = { audio: !!callInfo.remote_media_status.audio, video: !!callInfo.remote_media_status.video, desktop: !!callInfo.remote_media_status.desktop, data: !!callInfo.remote_media_status.data };
                            }
                            if (!(!localMediaFeature.audio || !localMediaFeature.audio.has(CallMediaFeature.START))) return [3 , 5];
                            return [4 , call.toggleAudioMute(true, false)];
                        case 4:
                            _b.sent();
                            _b.label = 5;
                        case 5:
                            if (!(!localMediaFeature.video || !localMediaFeature.video.has(CallMediaFeature.START))) return [3 , 7];
                            return [4 , call.toggleVideoMute(true, false)];
                        case 6:
                            _b.sent();
                            _b.label = 7;
                        case 7:
                            if (!(!call.autoanswer && call.waitForAnswer)) return [3 , 9];
                            return [4 , this.phoneSignal.play(call.callId, this._connections.size > 1 ? MediaSignal.ringAdvertising : MediaSignal.ring)];
                        case 8:
                            _b.sent();
                            _b.label = 9;
                        case 9: return [3 , 50];
                        case 10:
                            if (!call && !deviceIsApp && callInfo._channelType === ChannelType.PhoneCall) {
                                call = this.createCall(callInfo.callId, callInfo._channelType, true, callInfo.state, realEvent);
                            }
                            if (!call) return [3 , 18];
                            call.waitForAnswer = false;
                            playringback = call.realState && call.state != CallState.NEW_INBOUND && call.state != CallState.CONNECTED;
                            if (!playringback) return [3 , 13];
                            return [4 , call.toggleAudioMute(true, false)];
                        case 11:
                            _b.sent();
                            return [4 , call.toggleVideoMute(true, false)];
                        case 12:
                            _b.sent();
                            _b.label = 13;
                        case 13:
                            if (!webrtcfields) return [3 , 16];
                            call.remoteWebrtcfield = webrtcfields;
                            if (!(webrtcfields.sessionDescription && webrtcfields.sessionDescription.session)) return [3 , 15];
                            return [4 , this.phoneSignal.stop(call.callId, true)];
                        case 14:
                            _b.sent();
                            playringback = false;
                            _b.label = 15;
                        case 15:
                            if (!this.options.immediateRingback && playringback && !webrtcfields.ring) {
                                playringback = false;
                            }
                            _b.label = 16;
                        case 16:
                            if (!playringback) return [3 , 18];
                            return [4 , this.phoneSignal.play(call.callId, MediaSignal.ringback)];
                        case 17:
                            _b.sent();
                            _b.label = 18;
                        case 18: return [3 , 50];
                        case 19:
                            if (!call) return [3 , 28];
                            if (realEvent) {
                                this._callIdToRemove.delete(call.callId);
                            }
                            else {
                                call.markAsClosedLocal();
                            }
                            currentPlay = this.phoneSignal.getCurrentPlay(call.callId);
                            if (!(call.state === CallState.NEW_INBOUND)) return [3 , 21];
                            return [4 , this.phoneSignal.stop(call.callId, true)];
                        case 20:
                            _b.sent();
                            return [3 , 27];
                        case 21:
                            if (!currentPlay) return [3 , 25];
                            if (!(currentPlay !== MediaSignal.hold)) return [3 , 24];
                            if (!!call.isClosedLocal()) return [3 , 24];
                            return [4 , this.phoneSignal.stop(call.callId, true)];
                        case 22:
                            _b.sent();
                            return [4 , this.phoneSignal.play(call.callId, currentPlay === MediaSignal.ringback ? MediaSignal.congestion : MediaSignal.busy)];
                        case 23:
                            _b.sent();
                            _b.label = 24;
                        case 24: return [3 , 27];
                        case 25:
                            if (!(!call.isClosedLocal() && callInfo.idleReason && callInfo.idleReason !== IdleReason.HANGUP)) return [3 , 27];
                            return [4 , this.phoneSignal.play(call.callId, callInfo.idleReason === IdleReason.CONGESTION ? MediaSignal.congestion : MediaSignal.busy)];
                        case 26:
                            _b.sent();
                            _b.label = 27;
                        case 27:
                            call.closeConnection();
                            webrtcfields = null;
                            call.remoteWebrtcfield = webrtcfields;
                            return [3 , 29];
                        case 28:
                            if (realEvent) {
                                this._callIdToRemove.delete(callInfo.callId);
                            }
                            _b.label = 29;
                        case 29: return [4 , this.destroyCall(callInfo.callId)];
                        case 30:
                            if (_b.sent()) {
                                call = null;
                            }
                            return [3 , 50];
                        case 31:
                            if (!call) return [3 , 42];
                            call.waitForAnswer = false;
                            call.remoteWebrtcfield = webrtcfields;
                            call.setState(callInfo.state, realEvent);
                            return [4 , this.phoneSignal.stop(call.callId, true)];
                        case 32:
                            _b.sent();
                            if (!call.localMedia) return [3 , 33];
                            return [3 , 36];
                        case 33:
                            if (!localMediaFeature) return [3 , 35];
                            return [4 , call.setLocalMedia({
                                    audio: localMediaFeature.audio && (localMediaFeature.audio.has(CallMediaFeature.UNMUTE) || localMediaFeature.audio.has(CallMediaFeature.START)),
                                    video: localMediaFeature.video && (localMediaFeature.video.has(CallMediaFeature.UNMUTE) || localMediaFeature.video.has(CallMediaFeature.START)),
                                    desktop: localMediaFeature.desktop && (localMediaFeature.desktop.has(CallMediaFeature.UNMUTE) || localMediaFeature.desktop.has(CallMediaFeature.START)),
                                    data: localMediaFeature.data && (localMediaFeature.data.has(CallMediaFeature.UNMUTE) || localMediaFeature.data.has(CallMediaFeature.START)),
                                }, this._loadedOptions.mediaConfiguration)];
                        case 34:
                            _b.sent();
                            return [3 , 36];
                        case 35: throw new Error("No media defined");
                        case 36: return [4 , call.startLocalMedia()];
                        case 37:
                            _b.sent();
                            return [4 , call.initIcelinkConnection()];
                        case 38:
                            _b.sent();
                            if (!(call.audioLinkStatus === CallMediaLinkStatus.MUTE && localMediaFeature.audio && localMediaFeature.audio.has(CallMediaFeature.MUTE))) return [3 , 40];
                            return [4 , call.toggleAudioMute(false, false)];
                        case 39:
                            _b.sent();
                            _b.label = 40;
                        case 40:
                            if (!(call.videoLinkStatus === CallMediaLinkStatus.MUTE && localMediaFeature.video && localMediaFeature.video.has(CallMediaFeature.MUTE))) return [3 , 42];
                            return [4 , call.toggleVideoMute(false, false)];
                        case 41:
                            _b.sent();
                            _b.label = 42;
                        case 42: return [3 , 50];
                        case 43:
                            if (!call) return [3 , 49];
                            call.remoteWebrtcfield = webrtcfields;
                            if (!(call.audioLinkStatus === CallMediaLinkStatus.UNMUTE)) return [3 , 45];
                            return [4 , call.toggleAudioMute(true, false)];
                        case 44:
                            _b.sent();
                            _b.label = 45;
                        case 45:
                            if (!(call.videoLinkStatus === CallMediaLinkStatus.UNMUTE)) return [3 , 47];
                            return [4 , call.toggleVideoMute(true, false)];
                        case 46:
                            _b.sent();
                            _b.label = 47;
                        case 47:
                            if (!(CallState.HOLD !== call.state)) return [3 , 49];
                            return [4 , this.phoneSignal.play(call.callId, MediaSignal.hold)];
                        case 48:
                            _b.sent();
                            _b.label = 49;
                        case 49: return [3 , 50];
                        case 50:
                            localMediaFeature = null;
                            if (!call) return [3 , 52];
                            call.setState(callInfo.state, realEvent, true);
                            return [4 , call.updateRemoteWebrtcFields()];
                        case 51:
                            _b.sent();
                            return [3 , 53];
                        case 52:
                            if (callInfo.state !== CallState.IDLE) {
                                throw new Error("No call");
                            }
                            _b.label = 53;
                        case 53: return [2 , _webrtcControlMessage];
                        case 54:
                            err_3 = _b.sent();
                            err_3.controlMessage = _webrtcControlMessage;
                            throw err_3;
                        case 55: return [2 ];
                    }
                });
            });
        };
        WebRTCManager.prototype.createCall = function (callId, channelType, offer, state, realState, dialParam, callChecker) {
            var call = this.retriveCall(callId);
            if (call) {
                return call;
            }
            else {
                if (callId) {
                    if (channelType === ChannelType.Omnidesk) {
                        call = new CallOmnidesk(this, this._controlMessageNotifier, callId, state);
                    }
                    else {
                        call = callChecker ? new CallChecker(this, this._controlMessageNotifier, this._connectionStateSubject, callId, channelType, offer, state, realState) : new Call$1(this, this._controlMessageNotifier, this._connectionStateSubject, callId, channelType, offer, state, realState);
                        call.dialParams = dialParam ? dialParam : null;
                    }
                    this._connections.set(callId, call);
                    return call;
                }
                else {
                    return null;
                }
            }
        };
        WebRTCManager.prototype.retriveCall = function (callId) {
            return callId ? this._connections.get(callId) : null;
        };
        WebRTCManager.prototype.cleanPendingCall = function () {
            var _this = this;
            if (this._callIdToRemove.size > 0) {
                var toRemove = new Set(this._callIdToRemove);
                toRemove.forEach(function (callId) {
                    _this._log.info("Cancel pending call " + callId);
                    _this._apiMethods.forceCancel(callId).subscribe(function () {
                        _this._callIdToRemove.delete(callId);
                    }, function (err) {
                        _this._log.error("Error on cancel pending call " + callId, err);
                    });
                    _this._apiMethods.removeCallFromUserInteraction(callId).subscribe(null, function (err) {
                        _this._log.error("Error on removeCallFromUserInteraction of pending call " + callId, err);
                    });
                });
            }
        };
        WebRTCManager.prototype.cancelCallRequest = function (callId) {
            var _this = this;
            if (this._connections.has(callId)) {
                this._callIdToRemove.add(callId);
                setTimeout(function (channelType) {
                    _this._controlMessageNotifier.next({
                        callId: callId,
                        device: ExtenType.WEBRTC,
                        direction: CallDirection.outbound,
                        state: CallState.IDLE,
                        _isFromServer: false,
                        _channelType: channelType,
                        _realChannelType: channelType,
                    });
                }, 0, this._connections.get(callId).channelType || ChannelType.PhoneCall);
                return true;
            }
            else {
                return false;
            }
        };
        WebRTCManager.prototype.destroyCall = function (callId, dialParam, error) {
            return __awaiter(this, void 0, void 0, function () {
                var call, deviceIsApp;
                var _this = this;
                return __generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            call = callId ? this.retriveCall(callId) : null;
                            deviceIsApp = (call && call.deviceIsApp) || (dialParam && dialParam.isForApp());
                            if (!(call || deviceIsApp)) return [3 , 3];
                            if (dialParam && error && error instanceof WebAPI) {
                                setTimeout(function () {
                                    if (deviceIsApp || (call && call.state && call.state === CallState.NEW_OUTBOUND && !call.realState)) {
                                        _this._controlMessageNotifier.next({
                                            callId: callId,
                                            device: dialParam.params.fromDevice,
                                            direction: CallDirection.outbound,
                                            state: CallState.IDLE,
                                            _isFromServer: false,
                                            _channelType: dialParam.params.channelId,
                                            _realChannelType: dialParam.params.channelId,
                                        });
                                    }
                                });
                            }
                            if (!call) return [3 , 2];
                            return [4 , call.close()];
                        case 1:
                            _a.sent();
                            this._connections.delete(callId);
                            _a.label = 2;
                        case 2:
                            if (deviceIsApp || (call && call.channelType === ChannelType.PhoneCall && !(call instanceof CallChecker))) {
                                this._apiMethods.removeCallFromUserInteraction(callId).subscribe(null, function (err) {
                                    _this._log.error("Error on removeCallFromUserInteraction", err);
                                });
                            }
                            if (this._connections.size === 1) {
                                this.phoneSignal.convertRingAdvertisingToRingIfNeedle();
                            }
                            return [2 , true];
                        case 3: return [2 , false];
                    }
                });
            });
        };
        WebRTCManager.prototype.changeAudioConstraints = function (callId, constraints) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.changeAudioConstraints(constraints) : false];
                });
            });
        };
        WebRTCManager.prototype.changeVideoConstraints = function (callId, constraints) {
            return __awaiter(this, void 0, void 0, function () {
                var call;
                return __generator(this, function (_a) {
                    call = this.retriveCall(callId);
                    return [2 , call ? call.changeVideoConstraints(constraints) : false];
                });
            });
        };
        WebRTCManager.prototype.generateNewCallId = function () {
            return icelink.Guid.newGuid().toString();
        };
        return WebRTCManager;
    }());
    var IcelinkLogger =  (function (_super) {
        __extends(IcelinkLogger, _super);
        function IcelinkLogger(manager) {
            var _this = _super.call(this) || this;
            _this._logger = Log$1.of("webrtc:icelink", manager.client);
            _this.setLevel(icelink.LogLevel.Verbose);
            return _this;
        }
        IcelinkLogger.prototype.getTypeString = function () {
            return "[WebRTCmanagerLogProvider]";
        };
        IcelinkLogger.prototype.doLog = function (logItem) {
            var logLine = this.generateLogLine(logItem);
            logLine ? this._logger.logWithTimestamp(this.icelinkLogLevelToLogLevel(logItem.getLogLevel() || logItem.getLevel()) || LogLevel.Debug, logItem.getTimestamp().getDate(), logItem.getMessage(), logLine) : this._logger.logWithTimestamp(this.icelinkLogLevelToLogLevel(logItem.getLogLevel() || logItem.getLevel()) || LogLevel.Debug, logItem.getTimestamp().getDate(), logItem.getMessage());
        };
        IcelinkLogger.prototype.generateLogLine = function (logEvent) {
            if (arguments.length == 1) {
                var str = "";
                if (icelink.Global.equals(logEvent.getException(), null)) {
                    return str;
                }
                return icelink.StringExtensions.concat(str, icelink.StringExtensions.format("\n{0}", logEvent.getException().message || logEvent.getException().toString()));
            }
            else {
                return _super.prototype.generateLogLine.call(this, arguments);
            }
        };
        IcelinkLogger.prototype.icelinkLogLevelToLogLevel = function (level) {
            return level;
        };
        return IcelinkLogger;
    }(icelink.LogProvider));

    const logPrefix = "TVoxClientSdk:";
    const DEFAULT_LOG_CONFIGURATOR = new DefaultLogConfigurator(new LogConfig({ prefix: logPrefix }));
    class Log {
        constructor(
        _pkg,
        _instanceId,
        _config) {
            this._pkg = _pkg;
            this._instanceId = _instanceId;
            this._config = _config;
            this.verbose = (...args) => this.log(Log.LogLevel.Verbose, args);
            this.debug = (...args) => this.log(Log.LogLevel.Debug, null, args);
            this.info = (...args) => this.log(Log.LogLevel.Info, null, args);
            this.warn = (...args) => this.log(Log.LogLevel.Warn, null, args);
            this.error = (...args) => this.log(Log.LogLevel.Error, null, args);
            this.fatal = (...args) => this.log(Log.LogLevel.Fatal, null, args);
            this._apiLog = Log$1.create(_pkg, _instanceId, _config !== null && _config !== void 0 ? _config : DEFAULT_LOG_CONFIGURATOR);
        }
        static of(pkg, client) {
            return new Log(pkg, client === null || client === void 0 ? void 0 : client.api.instanceId, client === null || client === void 0 ? void 0 : client.api.logConfigurator);
        }
        get config() {
            var _a;
            return (_a = this._config) !== null && _a !== void 0 ? _a : DEFAULT_LOG_CONFIGURATOR;
        }
        log(level, ...args) {
            this.logWithTimestamp(level, null, args);
        }
        logWithTimestamp(level, timestamp, ...args) {
            this._apiLog.logWithTimestamp(level, timestamp, args);
        }
    }
    Log.verbose = (...args) => DEFAULT_LOGGER.verbose(args);
    Log.debug = (...args) => DEFAULT_LOGGER.debug(args);
    Log.info = (...args) => DEFAULT_LOGGER.info(args);
    Log.warn = (...args) => DEFAULT_LOGGER.warn(args);
    Log.error = (...args) => DEFAULT_LOGGER.error(args);
    Log.fatal = (...args) => DEFAULT_LOGGER.fatal(args);
    const DEFAULT_LOGGER = Log.of("");
    (function (Log) {
        (function (LogLevel) {
            LogLevel[LogLevel["Verbose"] = 1] = "Verbose";
            LogLevel[LogLevel["Debug"] = 2] = "Debug";
            LogLevel[LogLevel["Info"] = 3] = "Info";
            LogLevel[LogLevel["Warn"] = 4] = "Warn";
            LogLevel[LogLevel["Error"] = 5] = "Error";
            LogLevel[LogLevel["Fatal"] = 6] = "Fatal";
            LogLevel[LogLevel["None"] = 7] = "None";
        })(Log.LogLevel || (Log.LogLevel = {}));
        function toWebapiConfig(configuration) {
            return configuration
                ? new LogConfig({
                    enabled: configuration.enabled,
                    prefix: logPrefix,
                    timestamp: configuration.timestamp,
                    objectToJson: configuration.objectToJson,
                    logLevel: configuration.logLevel,
                })
                : new LogConfig({ prefix: logPrefix });
        }
        Log.toWebapiConfig = toWebapiConfig;
        class LogConfigurator {
            constructor() { }
        }
        Log.LogConfigurator = LogConfigurator;
    })(Log || (Log = {}));

    var eventemitter3 = createCommonjsModule(function (module) {
    var has = Object.prototype.hasOwnProperty
      , prefix = '~';
    function Events() {}
    if (Object.create) {
      Events.prototype = Object.create(null);
      if (!new Events().__proto__) prefix = false;
    }
    function EE(fn, context, once) {
      this.fn = fn;
      this.context = context;
      this.once = once || false;
    }
    function addListener(emitter, event, fn, context, once) {
      if (typeof fn !== 'function') {
        throw new TypeError('The listener must be a function');
      }
      var listener = new EE(fn, context || emitter, once)
        , evt = prefix ? prefix + event : event;
      if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
      else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
      else emitter._events[evt] = [emitter._events[evt], listener];
      return emitter;
    }
    function clearEvent(emitter, evt) {
      if (--emitter._eventsCount === 0) emitter._events = new Events();
      else delete emitter._events[evt];
    }
    function EventEmitter() {
      this._events = new Events();
      this._eventsCount = 0;
    }
    EventEmitter.prototype.eventNames = function eventNames() {
      var names = []
        , events
        , name;
      if (this._eventsCount === 0) return names;
      for (name in (events = this._events)) {
        if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
      }
      if (Object.getOwnPropertySymbols) {
        return names.concat(Object.getOwnPropertySymbols(events));
      }
      return names;
    };
    EventEmitter.prototype.listeners = function listeners(event) {
      var evt = prefix ? prefix + event : event
        , handlers = this._events[evt];
      if (!handlers) return [];
      if (handlers.fn) return [handlers.fn];
      for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
        ee[i] = handlers[i].fn;
      }
      return ee;
    };
    EventEmitter.prototype.listenerCount = function listenerCount(event) {
      var evt = prefix ? prefix + event : event
        , listeners = this._events[evt];
      if (!listeners) return 0;
      if (listeners.fn) return 1;
      return listeners.length;
    };
    EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
      var evt = prefix ? prefix + event : event;
      if (!this._events[evt]) return false;
      var listeners = this._events[evt]
        , len = arguments.length
        , args
        , i;
      if (listeners.fn) {
        if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
        switch (len) {
          case 1: return listeners.fn.call(listeners.context), true;
          case 2: return listeners.fn.call(listeners.context, a1), true;
          case 3: return listeners.fn.call(listeners.context, a1, a2), true;
          case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
          case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
          case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
        }
        for (i = 1, args = new Array(len -1); i < len; i++) {
          args[i - 1] = arguments[i];
        }
        listeners.fn.apply(listeners.context, args);
      } else {
        var length = listeners.length
          , j;
        for (i = 0; i < length; i++) {
          if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
          switch (len) {
            case 1: listeners[i].fn.call(listeners[i].context); break;
            case 2: listeners[i].fn.call(listeners[i].context, a1); break;
            case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
            case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
            default:
              if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
                args[j - 1] = arguments[j];
              }
              listeners[i].fn.apply(listeners[i].context, args);
          }
        }
      }
      return true;
    };
    EventEmitter.prototype.on = function on(event, fn, context) {
      return addListener(this, event, fn, context, false);
    };
    EventEmitter.prototype.once = function once(event, fn, context) {
      return addListener(this, event, fn, context, true);
    };
    EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
      var evt = prefix ? prefix + event : event;
      if (!this._events[evt]) return this;
      if (!fn) {
        clearEvent(this, evt);
        return this;
      }
      var listeners = this._events[evt];
      if (listeners.fn) {
        if (
          listeners.fn === fn &&
          (!once || listeners.once) &&
          (!context || listeners.context === context)
        ) {
          clearEvent(this, evt);
        }
      } else {
        for (var i = 0, events = [], length = listeners.length; i < length; i++) {
          if (
            listeners[i].fn !== fn ||
            (once && !listeners[i].once) ||
            (context && listeners[i].context !== context)
          ) {
            events.push(listeners[i]);
          }
        }
        if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
        else clearEvent(this, evt);
      }
      return this;
    };
    EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
      var evt;
      if (event) {
        evt = prefix ? prefix + event : event;
        if (this._events[evt]) clearEvent(this, evt);
      } else {
        this._events = new Events();
        this._eventsCount = 0;
      }
      return this;
    };
    EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
    EventEmitter.prototype.addListener = EventEmitter.prototype.on;
    EventEmitter.prefixed = prefix;
    EventEmitter.EventEmitter = EventEmitter;
    {
      module.exports = EventEmitter;
    }
    });

    var C;
    (function (C) {
        (function (LineType) {
            LineType["SIP"] = "SIP";
            LineType["WEBRTC"] = "WEBRTC";
        })(C.LineType || (C.LineType = {}));
    })(C || (C = {}));

    function isString(value) {
        return typeof value === "string" || value instanceof String;
    }
    class SearchResult extends eventemitter3.EventEmitter {
        constructor() {
            super();
        }
    }
    SearchResult.data = "data";
    SearchResult.error = "error";
    SearchResult.complete = "complete";

    class Contact$1 {
        constructor(data, type, subtype = null) {
            this.data = data;
            this.type = type;
            this.subtype = subtype;
            this.id = data.id;
        }
        static from(data) {
            if (isUserContact(data)) {
                return new InternalUserContact$1(data);
            }
            else if (isServiceContact(data)) {
                return new InternalServiceContact$1(data);
            }
            else if (isShortNumberContact(data)) {
                return new InternalShortNumberContact$1(data);
            }
            else if (isExternalContact(data)) {
                return new ExternalItemContact$1(data);
            }
            else if (isExternalOrganizationContact(data)) {
                return new ExternalOrganizationContact$1(data);
            }
            else if (isPersonalContact(data)) {
                return new PersonalContact$1(data);
            }
            else {
                return null;
            }
        }
        get addressBookContactType() {
            return this.data.type;
        }
    }
    class InternalUserContact$1 extends Contact$1 {
        constructor(data) {
            super(data, Contact$1.Type.INTERNAL, Contact$1.InternalSubType.USER);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact$1.Type.INTERNAL && contact.subtype === Contact$1.InternalSubType.USER;
        }
    }
    class InternalServiceContact$1 extends Contact$1 {
        constructor(data) {
            super(data, Contact$1.Type.INTERNAL, Contact$1.InternalSubType.SERVICE);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact$1.Type.INTERNAL && contact.subtype === Contact$1.InternalSubType.SERVICE;
        }
    }
    class InternalShortNumberContact$1 extends Contact$1 {
        constructor(data) {
            super(data, Contact$1.Type.INTERNAL, Contact$1.InternalSubType.SHORT_NUMBER);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact$1.Type.INTERNAL && contact.subtype === Contact$1.InternalSubType.SHORT_NUMBER;
        }
    }
    class ExternalItemContact$1 extends Contact$1 {
        constructor(data) {
            super(data, Contact$1.Type.EXTERNAL);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact$1.Type.EXTERNAL && contact.subtype === null;
        }
    }
    class ExternalOrganizationContact$1 extends Contact$1 {
        constructor(data) {
            super(data, Contact$1.Type.EXTERNAL, Contact$1.ExternalSubType.ORGANIZATION);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact$1.Type.EXTERNAL && contact.subtype === Contact$1.ExternalSubType.ORGANIZATION;
        }
    }
    class PersonalContact$1 extends Contact$1 {
        constructor(data) {
            super(data, Contact$1.Type.PERSONAL);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact$1.Type.PERSONAL;
        }
    }
    (function (Contact) {
        class SearchContactResult extends SearchResult {
            constructor(requestOptions) {
                super();
                this.requestOptions = requestOptions;
            }
        }
        Contact.SearchContactResult = SearchContactResult;
        (function (Type) {
            Type["INTERNAL"] = "INTERNAL";
            Type["EXTERNAL"] = "EXTERNAL";
            Type["PERSONAL"] = "PERSONAL";
        })(Contact.Type || (Contact.Type = {}));
        (function (InternalSubType) {
            InternalSubType["SERVICE"] = "SERVICE";
            InternalSubType["USER"] = "USER";
            InternalSubType["SHORT_NUMBER"] = "SHORT_NUMBER";
        })(Contact.InternalSubType || (Contact.InternalSubType = {}));
        (function (ExternalSubType) {
            ExternalSubType["ORGANIZATION"] = "ORGANIZATION";
        })(Contact.ExternalSubType || (Contact.ExternalSubType = {}));
        (function (AddressBookContactAddressType) {
            AddressBookContactAddressType["MAIN"] = "MAIN";
            AddressBookContactAddressType["OTHER"] = "OTHER";
        })(Contact.AddressBookContactAddressType || (Contact.AddressBookContactAddressType = {}));
        (function (AddressBookContactMailType) {
            AddressBookContactMailType["INTERNET_WORK"] = "INTERNET_WORK";
            AddressBookContactMailType["INTERNET_HOME"] = "INTERNET_HOME";
        })(Contact.AddressBookContactMailType || (Contact.AddressBookContactMailType = {}));
        (function (AddressBookContactNumberType) {
            AddressBookContactNumberType["FAX"] = "FAX";
            AddressBookContactNumberType["HOME"] = "HOME";
            AddressBookContactNumberType["CELL"] = "CELL";
            AddressBookContactNumberType["WORK"] = "WORK";
            AddressBookContactNumberType["CELL_WORK"] = "CELL_WORK";
            AddressBookContactNumberType["FAX_WORK"] = "FAX_WORK";
            AddressBookContactNumberType["FAX_HOME"] = "FAX_HOME";
            AddressBookContactNumberType["CELL_HOME"] = "CELL_HOME";
            AddressBookContactNumberType["MAIN"] = "MAIN";
            AddressBookContactNumberType["OTHER"] = "OTHER";
        })(Contact.AddressBookContactNumberType || (Contact.AddressBookContactNumberType = {}));
        (function (AddressBookContactWebType) {
            AddressBookContactWebType["WORK"] = "WORK";
            AddressBookContactWebType["HOME"] = "HOME";
        })(Contact.AddressBookContactWebType || (Contact.AddressBookContactWebType = {}));
    })(Contact$1 || (Contact$1 = {}));

    class Call extends eventemitter3.EventEmitter {
        constructor(device, id, direction) {
            super();
            this.device = device;
            this.id = id;
            this.direction = direction;
            this._lastApiMessage = null;
            this.lookup = new Call.Lookup();
            this._startTime = new Date();
        }
        get startTime() {
            return this._startTime;
        }
        get endTime() {
            return this._endTime;
        }
        get features() {
            return this._lastApiMessage ? (this._lastApiMessage.features ? this._lastApiMessage.features : []) : [];
        }
        get lastUpdateMessageDate() {
            var _a, _b;
            if ((_a = this._lastApiMessage) === null || _a === void 0 ? void 0 : _a.time) {
                return new Date((_b = this._lastApiMessage) === null || _b === void 0 ? void 0 : _b.time);
            }
            else {
                return null;
            }
        }
        updateFromApi(data, emitEvent = true) {
            return __awaiter$d(this, void 0, void 0, function* () {
                const previouseFeatures = this.features;
                this._lastApiMessage = data;
                const newFeatures = this.features;
                if (previouseFeatures.length !== newFeatures.length || previouseFeatures.find((f) => newFeatures.indexOf(f) < 0) || newFeatures.find((f) => previouseFeatures.indexOf(f) < 0)) {
                    this.featureChange(newFeatures, previouseFeatures);
                }
                if (data.start) {
                    try {
                        const startDate = new Date(data.start);
                        this._startTime = startDate;
                    }
                    catch (e) { }
                }
                this.lookup.updateFromApi(data, emitEvent);
            });
        }
    }
    (function (Call) {
        (function (Direction) {
            Direction["INBOUND"] = "inbound";
            Direction["OUTBOUND"] = "outbound";
        })(Call.Direction || (Call.Direction = {}));
        (function (CallFeature) {
            CallFeature["ANSWER"] = "ANSWER";
            CallFeature["CANCEL"] = "CANCEL";
            CallFeature["CONFERENCE"] = "CONFERENCE";
            CallFeature["DIAL"] = "DIAL";
            CallFeature["HOLD"] = "HOLD";
            CallFeature["GENERATE_DTMF"] = "GENERATE_DTMF";
            CallFeature["MONITOR_START"] = "MONITOR_START";
            CallFeature["SETCALLDATA"] = "SETCALLDATA";
            CallFeature["TRANSFER_BLIND"] = "TRANSFER_BLIND";
            CallFeature["TRANSFER_ATTENDED"] = "TRANSFER_ATTENDED";
            CallFeature["UNHOLD"] = "UNHOLD";
            CallFeature["MONITOR_STOP"] = "MONITOR_STOP";
            CallFeature["MUTE"] = "MUTE";
            CallFeature["REJECT"] = "REJECT";
            CallFeature["ACCEPT"] = "ACCEPT";
            CallFeature["UNMUTE"] = "UNMUTE";
            CallFeature["UPDATE"] = "UPDATE";
            CallFeature["VIDEO_START"] = "VIDEO_START";
            CallFeature["VIDEO_STOP"] = "VIDEO_STOP";
        })(Call.CallFeature || (Call.CallFeature = {}));
        class Lookup extends eventemitter3.EventEmitter {
            constructor() {
                super();
                this._status = "progress";
                this.display = {};
            }
            get contact() {
                return this._contact;
            }
            get status() {
                return this._status;
            }
            get result() {
                return this._result;
            }
            updateFromApi(data, emitEvent = true) {
                return __awaiter$d(this, void 0, void 0, function* () {
                    if (this.display.company != data.lookup_display_company) {
                        this.display.company = data.lookup_display_company;
                    }
                    if (this.display.name != data.lookup_display_name) {
                        this.display.name = data.lookup_display_name;
                    }
                    if (this.display.number != data.lookup_display_number) {
                        this.display.number = data.lookup_display_number;
                    }
                    this.emit("update_display", this.display, this);
                    if (data.lookup_addressbook_type) {
                        const contact = Contact$1.from({ type: data.lookup_addressbook_type, id: data.lookup_addressbook_uid, username: data.lookup_addressbook_username, photo: data.lookup_addressbook_photo });
                        if (contact) {
                            this._contact = contact;
                            this.emit("update_contact", this.contact, this);
                        }
                    }
                    if (data.lookup_finished) {
                        this._status = "end";
                        this._result = data.lookup_display_result;
                        this.emit("end");
                    }
                });
            }
        }
        Lookup.update_contact = "update_contact";
        Lookup.update_display = "update_display";
        Lookup.end = "end";
        Call.Lookup = Lookup;
        (function (LookupResult) {
            LookupResult["SUCCESS"] = "SUCCESS";
            LookupResult["MULTIPLE"] = "MULTIPLE";
            LookupResult["ERROR"] = "ERROR";
            LookupResult["NONE"] = "NONE";
        })(Call.LookupResult || (Call.LookupResult = {}));
    })(Call || (Call = {}));

    class CallSip extends Call {
        constructor(device, id, direction) {
            super(device, id, direction);
            this.type = C.LineType.SIP;
            this._hold = false;
        }
        updateFromApi(data, emitEvent = true) {
            const _super = Object.create(null, {
                updateFromApi: { get: () => super.updateFromApi }
            });
            var _a;
            return __awaiter$d(this, void 0, void 0, function* () {
                if (!this._lastApiMessage) {
                    yield _super.updateFromApi.call(this, data);
                    if (emitEvent) {
                        this.emit("connecting");
                    }
                }
                else if (((_a = this._lastApiMessage) === null || _a === void 0 ? void 0 : _a.state) === data.state) {
                    if (emitEvent) {
                        this.emit("progress");
                    }
                }
                else {
                    switch (data.state) {
                        case CallState.CONNECTED:
                            if (emitEvent) {
                                this.emit("accepted");
                            }
                            break;
                        case CallState.IDLE:
                            if (emitEvent) {
                                this.emit("ended");
                            }
                            break;
                    }
                }
                if (this._lastApiMessage !== data) {
                    _super.updateFromApi.call(this, data);
                }
            });
        }
        featureChange(features, previousFeatures) {
            this.emit("change_features", features, previousFeatures);
        }
        isInProgress() {
            var _a, _b;
            return ((_a = this._lastApiMessage) === null || _a === void 0 ? void 0 : _a.state) === CallState.NEW_INBOUND || ((_b = this._lastApiMessage) === null || _b === void 0 ? void 0 : _b.state) === CallState.NEW_OUTBOUND;
        }
        isEstablished() {
            var _a;
            return !this.isInProgress() && ((_a = this._lastApiMessage) === null || _a === void 0 ? void 0 : _a.state) !== CallState.IDLE;
        }
        isEnded() {
            var _a;
            return ((_a = this._lastApiMessage) === null || _a === void 0 ? void 0 : _a.state) === CallState.IDLE;
        }
        isOnHold() {
            return this._hold;
        }
        answer() {
            return __awaiter$d(this, void 0, void 0, function* () {
                return this.device.client.api.methods.answerOnChannel(ChannelType.PhoneCall, this.id, null);
            });
        }
        terminate() {
            return __awaiter$d(this, void 0, void 0, function* () {
                return this.device.client.api.methods.cancel(this.id);
            });
        }
        sendDTMF(tone) {
            return __awaiter$d(this, void 0, void 0, function* () {
                const response = yield this.device.client.api.methods.sendDTMF(this.id, `${tone}`, true);
                this.emit("newDTMF", tone);
                return response;
            });
        }
        hold() {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (!this._hold) {
                    this._hold = true;
                    const response = yield this.device.client.api.methods.hold(this.id);
                    if (response) {
                        this.emit("hold");
                    }
                    else {
                        this._hold = false;
                    }
                    return response;
                }
                return false;
            });
        }
        unhold() {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (this._hold) {
                    this._hold = false;
                    const response = yield this.device.client.api.methods.unhold(this.id);
                    if (response) {
                        this.emit("unhold");
                    }
                    else {
                        this._hold = true;
                    }
                    return response;
                }
                else {
                    return false;
                }
            });
        }
        transferToNumber(number) {
            return __awaiter$d(this, void 0, void 0, function* () {
                return this.transfer(number);
            });
        }
        transferToCall(call) {
            return __awaiter$d(this, void 0, void 0, function* () {
                return this.transfer(call);
            });
        }
        transfer(target) {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (isString(target)) {
                    return this.device.client.api.methods.blindTransfer(this.id, null, target, null);
                }
                else if (target instanceof CallSip) {
                    return this.device.client.api.methods.attendedTransfer(this.id, target.id, null);
                }
                else {
                    throw "invalid target for transfer";
                }
            });
        }
    }
    CallSip.connecting = "connecting";
    CallSip.progress = "progress";
    CallSip.accepted = "accepted";
    CallSip.ended = "ended";
    CallSip.newDTMF = "newDTMF";
    CallSip.hold = "hold";
    CallSip.unhold = "unhold";
    CallSip.change_features = "change_features";

    class DeviceSip {
        constructor(phone,
        label,
        exten) {
            this.phone = phone;
            this.label = label;
            this.exten = exten;
            this.type = C.LineType.SIP;
        }
        get client() {
            return this.phone.client;
        }
        dial(phoneNumber, param) {
            var _a, _b, _c;
            return __awaiter$d(this, void 0, void 0, function* () {
                const contactIdentifier = {
                    type: AddressBookContactType.UNKNOWN,
                    value: phoneNumber,
                };
                const dialParam = {
                    fromDeviceType: ExtenType.SIP,
                    fromDevice: this.exten,
                    media: { audio: true },
                    accessCode: param === null || param === void 0 ? void 0 : param.accessCode,
                    privateCall: param === null || param === void 0 ? void 0 : param.privateCall,
                    serviceCode: param === null || param === void 0 ? void 0 : param.serviceCode,
                    note1: param === null || param === void 0 ? void 0 : param.note1,
                    note2: param === null || param === void 0 ? void 0 : param.note2,
                    channelId: ChannelType.PhoneCall,
                    contact: contactIdentifier,
                };
                if (param === null || param === void 0 ? void 0 : param.contact) {
                    contactIdentifier.uid = param.contact.id;
                    contactIdentifier.type = (_a = param.contact.addressBookContactType) !== null && _a !== void 0 ? _a : contactIdentifier.type;
                    if (InternalUserContact$1.check(param.contact)) {
                        const contactIdentifierWithUser = contactIdentifier;
                        contactIdentifierWithUser.username = param.contact.data.username;
                        contactIdentifierWithUser.surname = param.contact.data.surname;
                        contactIdentifierWithUser.name = param.contact.data.name;
                    }
                }
                if ((_c = (_b = dialParam.contact) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : null) {
                    const response = yield this.client.api.methods.dial(dialParam);
                    if (!response) {
                        throw "Unable to dial, server response is empty";
                    }
                }
                else {
                    throw "Unable to dial, phoneNumber is empty";
                }
            });
        }
    }

    class Phone extends eventemitter3.EventEmitter {
        constructor(_client) {
            super();
            this._client = _client;
            this._state = Phone.Status.ERROR_NO_DEVICE_AVAILABLE;
            this.availableDevice = [];
            this._device = null;
            this._calls = new Map();
            this._client.api.callNotification.subscribe((() => {
                let callNotificationHandlerChain = Promise.resolve();
                return (callInfo) => __awaiter$d(this, void 0, void 0, function* () {
                    try {
                        yield callNotificationHandlerChain;
                    }
                    finally {
                        callNotificationHandlerChain = this.handleChannelNotification(callInfo);
                    }
                });
            })());
        }
        get state() {
            return this._state;
        }
        set state(state) {
            this._state = state;
        }
        get device() {
            return this._device;
        }
        set device(device) {
            this._device = device;
        }
        get client() {
            return this._client;
        }
        initFromApiData(userDetail) {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (userDetail.devices) {
                    const availableDevice = userDetail.devices
                        .filter((d) =>  { var _a;  return d.type === ExtenType.SIP  && !((_a = d.extension) === null || _a === void 0 ? void 0 : _a.startsWith("_app_")); })
                        .map((d) => {
                        return d.type === ExtenType.SIP ? new DeviceSip(this, d.label, d.extension) : null ;
                    })
                        .filter((d) => d != null);
                    this.availableDevice.forEach((d, index, data) => {
                        if (!availableDevice.find((ds) => ds.type === d.type && ds.exten === d.exten)) {
                            data.splice(index, 1);
                        }
                    });
                    availableDevice
                        .filter((d) => !this.availableDevice.find((ds) => ds.type === d.type && ds.exten === d.exten))
                        .forEach((d) => {
                        this.availableDevice.push(d);
                    });
                    yield this.checkDeviceAfterApiData();
                }
            });
        }
        initFromApiDataUpdate(userDetail) {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (userDetail.devices && userDetail.devices.length) {
                    userDetail.devices.forEach((device) => {
                        var _a;
                        if (device.type === ExtenType.SIP  && !((_a = device.extension) === null || _a === void 0 ? void 0 : _a.startsWith("_app_"))) {
                            const type = device.type === ExtenType.SIP ? C.LineType.SIP : C.LineType.WEBRTC;
                            const fromAvailableDevice = this.availableDevice.find((d) => d.type === type && d.exten === device.extension);
                            if (fromAvailableDevice) {
                                if (device.deleted) {
                                    this.availableDevice.splice(this.availableDevice.indexOf(fromAvailableDevice), 1);
                                }
                            }
                            else {
                                this.availableDevice.push(new DeviceSip(this, device.label, device.extension));
                            }
                        }
                    });
                }
                yield this.checkDeviceAfterApiData();
            });
        }
        checkDeviceAfterApiData() {
            var _a, _b;
            return __awaiter$d(this, void 0, void 0, function* () {
                if (this.availableDevice.length) {
                    let doUseDevice = false;
                    if (this.device) {
                        if (!this.availableDevice.find((d) => { var _a; return d.type === ((_a = this.device) === null || _a === void 0 ? void 0 : _a.type) && d.exten === this.device.exten; })) {
                            doUseDevice = true;
                        }
                    }
                    else {
                        doUseDevice = true;
                    }
                    if (doUseDevice) {
                        yield this.useDevice((_b = (_a = (this.device ? (this.availableDevice.indexOf(this.device) >= 0 ? this.device : undefined) : undefined)) !== null && _a !== void 0 ? _a : this.availableDevice.find((d) => d.type === C.LineType.SIP)) !== null && _b !== void 0 ? _b : this.availableDevice[0]);
                    }
                }
                else {
                    this.device = null;
                    this.state = Phone.Status.ERROR_NO_DEVICE_AVAILABLE;
                }
            });
        }
        handleChannelNotification(data) {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (ChannelType.PhoneCall !== channelIdToChannelType(data.channelid)) {
                    return;
                }
                let call = this.getCall(data.callId);
                if (call) {
                    yield call.updateFromApi(data);
                }
                else if (data.state === CallState.NEW_INBOUND || data.state === CallState.NEW_OUTBOUND) {
                    const direction = data.state === CallState.NEW_INBOUND ? Call.Direction.INBOUND : Call.Direction.OUTBOUND;
                    const deviceOfCall = this.availableDevice.find((d) => d.type === C.LineType.SIP && d.exten === data.device);
                    switch (data.deviceType) {
                        case ExtenType.SIP:
                            call = new CallSip(deviceOfCall, data.callId, direction);
                            this._calls.set(call.id, call);
                            break;
                    }
                    if (call) {
                        call.updateFromApi(data, false);
                        this.emit("newcall", call);
                    }
                }
            });
        }
        useDevice(device ) {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (device) {
                    if (this._client.api.webrtc && this._client.api.webrtc.enable) {
                        this._client.api.webrtc.stop();
                    }
                    this.device = device;
                    this.state = Phone.Status.READY;
                    return true;
                }
                this.state = Phone.Status.ERROR_NO_DEVICE;
                return false;
            });
        }
        getCall(id) {
            var _a;
            return (_a = this._calls.get(id)) !== null && _a !== void 0 ? _a : null;
        }
    }
    Phone.newcall = "newcall";
    (function (Phone) {
        (function (Status) {
            Status["READY"] = "READY";
            Status["ERROR_NO_DEVICE_AVAILABLE"] = "ERROR_NO_DEVICE_AVAILABLE";
            Status["ERROR_NO_DEVICE"] = "ERROR_NO_DEVICE";
        })(Phone.Status || (Phone.Status = {}));
    })(Phone || (Phone = {}));

    class Transport extends eventemitter3.EventEmitter {
        constructor(client) {
            super();
            this.client = client;
            this._state = Transport.Status.DISCONNECTED;
            this.client.api.connectionEvent.subscribe((event) => {
                if (event.connected) {
                    this._state = Transport.Status.CONNECTED;
                    this.emit("connect");
                }
                else {
                    this._state = Transport.Status.DISCONNECTED;
                    this.emit("disconnect");
                }
            });
        }
        get state() {
            return this._state;
        }
        connect() {
            this.client.api.transport.connect();
        }
        disconnect() {
            this.client.api.disconnect();
        }
        isConnected() {
            return this.state === Transport.Status.CONNECTED;
        }
    }
    Transport.connect = "connect";
    Transport.disconnect = "disconnect";
    (function (Transport) {
        (function (Status) {
            Status["CONNECTED"] = "CONNECTED";
            Status["DISCONNECTED"] = "DISCONNECTED";
        })(Transport.Status || (Transport.Status = {}));
    })(Transport || (Transport = {}));

    class Contact {
        constructor(data, type, subtype = null) {
            this.data = data;
            this.type = type;
            this.subtype = subtype;
            this.id = data.id;
        }
        static from(data) {
            if (isUserContact(data)) {
                return new InternalUserContact(data);
            }
            else if (isServiceContact(data)) {
                return new InternalServiceContact(data);
            }
            else if (isShortNumberContact(data)) {
                return new InternalShortNumberContact(data);
            }
            else if (isExternalContact(data)) {
                return new ExternalItemContact(data);
            }
            else if (isExternalOrganizationContact(data)) {
                return new ExternalOrganizationContact(data);
            }
            else if (isPersonalContact(data)) {
                return new PersonalContact(data);
            }
            else {
                return null;
            }
        }
        get addressBookContactType() {
            return this.data.type;
        }
    }
    function isContact(contact) {
        return contact instanceof Contact;
    }
    class InternalUserContact extends Contact {
        constructor(data) {
            super(data, Contact.Type.INTERNAL, Contact.InternalSubType.USER);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact.Type.INTERNAL && contact.subtype === Contact.InternalSubType.USER;
        }
    }
    class InternalServiceContact extends Contact {
        constructor(data) {
            super(data, Contact.Type.INTERNAL, Contact.InternalSubType.SERVICE);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact.Type.INTERNAL && contact.subtype === Contact.InternalSubType.SERVICE;
        }
    }
    class InternalShortNumberContact extends Contact {
        constructor(data) {
            super(data, Contact.Type.INTERNAL, Contact.InternalSubType.SHORT_NUMBER);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact.Type.INTERNAL && contact.subtype === Contact.InternalSubType.SHORT_NUMBER;
        }
    }
    class ExternalItemContact extends Contact {
        constructor(data) {
            super(data, Contact.Type.EXTERNAL);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact.Type.EXTERNAL && contact.subtype === null;
        }
    }
    class ExternalOrganizationContact extends Contact {
        constructor(data) {
            super(data, Contact.Type.EXTERNAL, Contact.ExternalSubType.ORGANIZATION);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact.Type.EXTERNAL && contact.subtype === Contact.ExternalSubType.ORGANIZATION;
        }
    }
    class PersonalContact extends Contact {
        constructor(data) {
            super(data, Contact.Type.PERSONAL);
            this.data = data;
        }
        static check(contact) {
            return contact && contact.type === Contact.Type.PERSONAL;
        }
    }
    (function (Contact) {
        class SearchContactResult extends SearchResult {
            constructor(requestOptions) {
                super();
                this.requestOptions = requestOptions;
            }
        }
        Contact.SearchContactResult = SearchContactResult;
        (function (Type) {
            Type["INTERNAL"] = "INTERNAL";
            Type["EXTERNAL"] = "EXTERNAL";
            Type["PERSONAL"] = "PERSONAL";
        })(Contact.Type || (Contact.Type = {}));
        (function (InternalSubType) {
            InternalSubType["SERVICE"] = "SERVICE";
            InternalSubType["USER"] = "USER";
            InternalSubType["SHORT_NUMBER"] = "SHORT_NUMBER";
        })(Contact.InternalSubType || (Contact.InternalSubType = {}));
        (function (ExternalSubType) {
            ExternalSubType["ORGANIZATION"] = "ORGANIZATION";
        })(Contact.ExternalSubType || (Contact.ExternalSubType = {}));
        (function (AddressBookContactAddressType) {
            AddressBookContactAddressType["MAIN"] = "MAIN";
            AddressBookContactAddressType["OTHER"] = "OTHER";
        })(Contact.AddressBookContactAddressType || (Contact.AddressBookContactAddressType = {}));
        (function (AddressBookContactMailType) {
            AddressBookContactMailType["INTERNET_WORK"] = "INTERNET_WORK";
            AddressBookContactMailType["INTERNET_HOME"] = "INTERNET_HOME";
        })(Contact.AddressBookContactMailType || (Contact.AddressBookContactMailType = {}));
        (function (AddressBookContactNumberType) {
            AddressBookContactNumberType["FAX"] = "FAX";
            AddressBookContactNumberType["HOME"] = "HOME";
            AddressBookContactNumberType["CELL"] = "CELL";
            AddressBookContactNumberType["WORK"] = "WORK";
            AddressBookContactNumberType["CELL_WORK"] = "CELL_WORK";
            AddressBookContactNumberType["FAX_WORK"] = "FAX_WORK";
            AddressBookContactNumberType["FAX_HOME"] = "FAX_HOME";
            AddressBookContactNumberType["CELL_HOME"] = "CELL_HOME";
            AddressBookContactNumberType["MAIN"] = "MAIN";
            AddressBookContactNumberType["OTHER"] = "OTHER";
        })(Contact.AddressBookContactNumberType || (Contact.AddressBookContactNumberType = {}));
        (function (AddressBookContactWebType) {
            AddressBookContactWebType["WORK"] = "WORK";
            AddressBookContactWebType["HOME"] = "HOME";
        })(Contact.AddressBookContactWebType || (Contact.AddressBookContactWebType = {}));
    })(Contact || (Contact = {}));

    exports.CallHistory = void 0;
    (function (CallHistory) {
        class CallHistoryResult extends SearchResult {
            constructor(options) {
                super();
                this.options = options;
            }
        }
        CallHistory.CallHistoryResult = CallHistoryResult;
        (function (CallHistoryDevStatus) {
            CallHistoryDevStatus["TRASF"] = "TRASF";
            CallHistoryDevStatus["TRASF_CANCEL"] = "TRASF_CANCEL";
            CallHistoryDevStatus["TRASF_ANSWER"] = "TRASF_ANSWER";
            CallHistoryDevStatus["TRASF_VM"] = "TRASF_VM";
            CallHistoryDevStatus["TRASF_VM_NO"] = "TRASF_VM_NO";
            CallHistoryDevStatus["RETURN"] = "RETURN";
        })(CallHistory.CallHistoryDevStatus || (CallHistory.CallHistoryDevStatus = {}));
        (function (CallHistoryDialStatus) {
            CallHistoryDialStatus["CHANUNAVAIL"] = "CHANUNAVAIL";
            CallHistoryDialStatus["CONGESTION"] = "CONGESTION";
            CallHistoryDialStatus["NOANSWER"] = "NOANSWER";
            CallHistoryDialStatus["BUSY"] = "BUSY";
            CallHistoryDialStatus["ANSWER"] = "ANSWER";
            CallHistoryDialStatus["CANCEL"] = "CANCEL";
            CallHistoryDialStatus["ERROR"] = "ERROR";
            CallHistoryDialStatus["NON_PRESENTE"] = "NON_PRESENTE";
            CallHistoryDialStatus["ALWAYS"] = "ALWAYS";
            CallHistoryDialStatus["ENABLE_FROM_PHONE"] = "ENABLE_FROM_PHONE";
            CallHistoryDialStatus["PICKUPED"] = "PICKUPED";
            CallHistoryDialStatus["PICKUPER"] = "PICKUPER";
            CallHistoryDialStatus["TVOX_NO_PERMISSION"] = "TVOX_NO_PERMISSION";
            CallHistoryDialStatus["DONTCALL"] = "DONTCALL";
            CallHistoryDialStatus["REJECTED"] = "REJECTED";
        })(CallHistory.CallHistoryDialStatus || (CallHistory.CallHistoryDialStatus = {}));
        (function (TransportType) {
            TransportType["PHONE"] = "PHONE";
            TransportType["VOICEMAIL"] = "VOICEMAIL";
            TransportType["FAX"] = "FAX";
            TransportType["SMS"] = "SMS";
        })(CallHistory.TransportType || (CallHistory.TransportType = {}));
        (function (CallHistoryType) {
            CallHistoryType["INBOUND"] = "INBOUND";
            CallHistoryType["OUTBOUND"] = "OUTBOUND";
        })(CallHistory.CallHistoryType || (CallHistory.CallHistoryType = {}));
    })(exports.CallHistory || (exports.CallHistory = {}));

    class User extends eventemitter3.EventEmitter {
        constructor(client) {
            super();
            this.client = client;
            this._state = User.State.NOTLOGGED;
            this.info = {};
            this._loadUserProfileInProgress = false;
            this.getUserDetailSubscription = Subscription.EMPTY;
            this.availableProfile = [];
            this.useProfileChain = Promise.resolve();
            this.handleEvents();
        }
        get state() {
            return this._state;
        }
        set state(status) {
            this._state = status;
        }
        handleEvents() {
            this.client.on("ready", () => (this._loadUserProfileInProgress = false));
            this.client.api.loginProfile.subscribe((data) => __awaiter$d(this, void 0, void 0, function* () {
                const prevstate = this.state;
                this.state = data.logged ? User.State.LOGGED : User.State.NOTLOGGED;
                this.info.username = data.username;
                this.info.name = data.name;
                this.info.surname = data.surname;
                switch (data.status) {
                    case LoginProfileStatus.SOCKET_CLOSED_BY_USER:
                    case LoginProfileStatus.SOCKET_CLOSED_USER_NOT_ENABLED:
                    case LoginProfileStatus.SOCKET_CLOSED_USER_NOT_ENABLED_MCS:
                        if (prevstate === User.State.LOGGED) {
                            this.client.emit("logged_out", this);
                        }
                        break;
                    default:
                        switch (this.client.state) {
                            case Client.ClientState.LOGIN_REQUIRED:
                                if (data.logged && prevstate !== this.state) {
                                    this.client.emit("logged_in", this);
                                    this.initializeApiAfterLogin();
                                }
                                break;
                            case Client.ClientState.LOGIN_IN_PROGRESS:
                                if (data.logged) {
                                    if (prevstate !== this.state) {
                                        this.client.emit("logged_in", this);
                                        this.initializeApiAfterLogin();
                                    }
                                }
                                else if (data.status === LoginProfileStatus.SOCKET_CLOSED_REQUEST_FORCE) {
                                    setTimeout(() => {
                                        this.client.api.methods.loginForce();
                                    });
                                }
                                break;
                            case Client.ClientState.READY:
                                if (this.state === User.State.NOTLOGGED) {
                                    this.client.emit("logged_out", this);
                                }
                                break;
                        }
                        break;
                }
            }));
        }
        initializeApiAfterLogin() {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (!this._loadUserProfileInProgress) {
                    this._loadUserProfileInProgress = true;
                    this.getUserDetailSubscription.unsubscribe();
                    const request = this.client.api.methods.getUserDetail();
                    this.getUserDetailSubscription = request.resultSync.subscribe((result) => __awaiter$d(this, void 0, void 0, function* () {
                        try {
                            yield this.loadUserDetail(yield result.toPromise());
                            yield this.client.api.methods.startCallNotify();
                            this.client.state = Client.ClientState.READY;
                            this.client.emit("ready");
                        }
                        catch (e) { }
                    }));
                    request.notification.subscribe((userDetail) => __awaiter$d(this, void 0, void 0, function* () {
                        this.client.phone.initFromApiDataUpdate(userDetail);
                        yield this.loadUserDetailUpdate(userDetail);
                    }));
                }
            });
        }
        loadDefaultConfiguration(loggedProfileId) {
            var _a, _b, _c;
            if (!loggedProfileId && this.info.profile) {
                loggedProfileId = this.info.profile.id;
            }
            if (loggedProfileId) {
                this.defaultProfile = this.availableProfile.find((p) => p.id === loggedProfileId);
            }
            if (!this.defaultProfile) {
                this.defaultProfile = ((_a = this.availableProfile) === null || _a === void 0 ? void 0 : _a.length) === 1 ? this.availableProfile[0] : (_c = (_b = this.availableProfile.find((p) => p.type === User.ProfileType.UC)) !== null && _b !== void 0 ? _b : this.availableProfile.find((p) => p.type === User.ProfileType.AG)) !== null && _c !== void 0 ? _c : this.availableProfile[0];
            }
        }
        loadUserDetail(userDetail) {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (userDetail.profiles) {
                    const availableProfile = userDetail.profiles
                        .filter((p) => p.clientLoginEnable)
                        .map((p) => new User.Profile(p.id, p.label, p.type))
                        .filter((p) => p != null);
                    this.availableProfile.forEach((p, index, data) => {
                        if (!availableProfile.find((ps) => ps.id === p.id)) {
                            data.splice(index, 1);
                            this.emit("profile_removed", p);
                        }
                    });
                    availableProfile
                        .filter((p) => !this.availableProfile.find((ps) => ps.id === p.id))
                        .forEach((p) => {
                        this.availableProfile.push(p);
                        this.emit("profile_added", p);
                    });
                }
                else {
                    this.availableProfile.length = 0;
                }
                this.loadDefaultConfiguration(userDetail.loggedProfileId);
                yield this.client.phone.initFromApiData(userDetail);
                yield this.useProfile();
                return userDetail;
            });
        }
        loadUserDetailUpdate(userDetail) {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (userDetail.profiles && userDetail.profiles.length) {
                    userDetail.profiles.forEach((profile) => {
                        const fromAvailableDevice = this.availableProfile.find((p) => p.id === profile.id);
                        if (fromAvailableDevice) {
                            if (profile.deleted) {
                                this.availableProfile.splice(this.availableProfile.indexOf(fromAvailableDevice), 1);
                                this.emit("profile_removed", fromAvailableDevice);
                            }
                        }
                        else {
                            const profileAdded = new User.Profile(profile.id, profile.label, profile.type);
                            this.availableProfile.push(profileAdded);
                            this.emit("profile_added", profileAdded);
                        }
                    });
                }
                this.loadDefaultConfiguration(userDetail.loggedProfileId);
                this.useProfile();
            });
        }
        useProfile(profile) {
            return __awaiter$d(this, void 0, void 0, function* () {
                try {
                    yield this.useProfileChain;
                }
                catch (e) {
                }
                finally {
                    this.useProfileChain = Promise.resolve().then(() => __awaiter$d(this, void 0, void 0, function* () {
                        if (profile && this.info.profile && this.info.profile.id !== profile.id) {
                            yield this.useProfileInternal(profile);
                        }
                        else {
                            if (!this.info.profile || (this.info.profile && !this.availableProfile.find((p) => { var _a; return p.id === ((_a = this.info.profile) === null || _a === void 0 ? void 0 : _a.id); }))) {
                                yield this.useProfileInternal(profile);
                            }
                        }
                    }));
                }
            });
        }
        useProfileInternal(profile) {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (this.availableProfile.length) {
                    if (profile) {
                        profile = this.availableProfile.find((p) => p.id === (profile === null || profile === void 0 ? void 0 : profile.id));
                    }
                    if (!profile) {
                        profile = this.defaultProfile;
                    }
                    if (profile) {
                        if (this.client.phone.device) {
                            const device = this.client.phone.device;
                            try {
                                yield this.client.api.methods.useProfile(profile.id, this.client.phone.device.type === C.LineType.SIP ? ExtenType.SIP : ExtenType.WEBRTC, device.exten, false).result.toPromise();
                            }
                            catch (e) {
                                this.info.profile = undefined;
                                this._state = User.State.ERROR_NO_PROFILE;
                                throw e;
                            }
                        }
                        else {
                            try {
                                yield this.client.api.methods.useProfile(profile.id, null, null, false).result.toPromise();
                            }
                            catch (e) {
                                this.info.profile = undefined;
                                this._state = User.State.ERROR_NO_PROFILE;
                                throw e;
                            }
                        }
                        this.emit("profile_selected", profile);
                        this._state = User.State.LOGGED;
                    }
                    else {
                        this._state = User.State.ERROR_NO_PROFILE;
                        this.emit("error_no_profile");
                    }
                    this.info.profile = profile;
                }
                else {
                    this._state = User.State.ERROR_NO_PROFILE_AVAILABLE;
                    this.info.profile = undefined;
                    this.emit("error_no_profile_available");
                }
            });
        }
        canDoRequest() {
            return __awaiter$d(this, void 0, void 0, function* () {
                if (Client.ClientState.READY === this.client.state) {
                    return;
                }
                else {
                    throw "Client is not ready to request data";
                }
            });
        }
        searchContact(options) {
            var _a, _b;
            return __awaiter$d(this, void 0, void 0, function* () {
                yield this.canDoRequest();
                const addressbooktype = options.type ? (options.type === Contact.Type.INTERNAL ? AddressBookType.INTERNAL : options.type === Contact.Type.EXTERNAL ? AddressBookType.EXTERNAL : options.type === Contact.Type.PERSONAL ? AddressBookType.PERSONAL : null) : null;
                const mode = options.searchMethods === "contains" ? AddressBookSearchMode.LIKE : AddressBookSearchMode.START_WITH;
                const type = AddressBookFieldType.NONE;
                const response = new Contact.SearchContactResult(options);
                const request = this.client.api.methods.searchUsersExtended(addressbooktype, [
                    { exclusive: true, key: AddressBookFieldKey.N, mode, type, value: [options.toSearch] },
                    { exclusive: true, key: AddressBookFieldKey.TEL, mode, type, value: [options.toSearch] },
                    { exclusive: true, key: AddressBookFieldKey.ORG, mode, type, value: [options.toSearch] },
                ], false, (_a = options.pageNumber) !== null && _a !== void 0 ? _a : 1, (_b = options.pageSize) !== null && _b !== void 0 ? _b : 20);
                request.result.subscribe((data) => {
                    response.emit("data", Contact.from(data.data), data.i, data.tot);
                }, (err) => {
                    response.emit("error", err);
                }, () => {
                    response.emit("complete");
                    request.stopNotification();
                });
                return response;
            });
        }
        getContact(id) {
            return __awaiter$d(this, void 0, void 0, function* () {
                yield this.canDoRequest();
                return Contact.from(yield this.client.api.methods.getAddressBookContactByUuid(id));
            });
        }
        getCallHistory(options) {
            var _a, _b;
            return __awaiter$d(this, void 0, void 0, function* () {
                yield this.canDoRequest();
                const response = new exports.CallHistory.CallHistoryResult(options);
                this.client.api.methods
                    .searchUserCallHistoryItems(null, [
                    { transportType: TransportType.SMS },
                    { transportType: TransportType.FAX },
                    { transportType: TransportType.VOICEMAIL },
                ], null, null, null, null, null, null, null, (_a = options.pageNumber) !== null && _a !== void 0 ? _a : 1, (_b = options.pageSize) !== null && _b !== void 0 ? _b : 100)
                    .subscribe((element) => {
                    response.emit("data", element.data, element.i, element.tot);
                }, (err) => {
                    response.emit("error", err);
                }, () => {
                    response.emit("complete");
                });
                return response;
            });
        }
    }
    User.error_no_profile = "error_no_profile";
    User.error_no_profile_available = "error_no_profile_available";
    User.profile_selected = "profile_selected";
    User.profile_removed = "profile_removed";
    User.profile_added = "profile_added";
    (function (User) {
        (function (State) {
            State["LOGGED"] = "LOGGED";
            State["NOTLOGGED"] = "NOTLOGGED";
            State["ERROR_NO_PROFILE_AVAILABLE"] = "ERROR_NO_PROFILE_AVAILABLE";
            State["ERROR_NO_PROFILE"] = "ERROR_NO_PROFILE";
        })(User.State || (User.State = {}));
        (function (ProfileType) {
            ProfileType["UC"] = "UC";
            ProfileType["AG"] = "AG";
            ProfileType["AG_EXTERNAL"] = "AG_EXTERNAL";
            ProfileType["AG_REMOTE"] = "AG_REMOTE";
            ProfileType["TQM"] = "TQM";
        })(User.ProfileType || (User.ProfileType = {}));
        class Profile {
            constructor(id, label, type) {
                this.id = id;
                this.label = label;
                this.type = type;
            }
        }
        User.Profile = Profile;
    })(User || (User = {}));

    class Client extends eventemitter3.EventEmitter {
        constructor(configuration) {
            super();
            this._state = Client.ClientState.LOGIN_REQUIRED;
            this.configuration = configuration;
            this.api = new WebapiClient(this.mapConfigurationToWebapiConfig());
            this._logConfigImpl = new Client.ClientLogConfigurator(this);
            this.api.webrtc = new WebRTCManager({ enabled: false, enabledOnChannel: [ChannelType.PhoneCall] });
            this.transport = new Transport(this);
            this.user = new User(this);
            this.phone = new Phone(this);
            this.on("login_in_progress", () => {
                this._state = Client.ClientState.LOGIN_IN_PROGRESS;
            });
            this.on("login_failed", () => {
                this._state = Client.ClientState.LOGIN_FAILED;
            });
            this.on("logged_out", () => {
                this._state = Client.ClientState.LOGIN_REQUIRED;
            });
        }
        get state() {
            return this._state;
        }
        set state(status) {
            this._state = status;
        }
        get logConfigurator() {
            return this._logConfigImpl;
        }
        get instanceId() {
            return this.api.instanceId;
        }
        mapConfigurationToWebapiConfig() {
            const configuration = this.configuration;
            return {
                url: configuration.url.endsWith("/clientproxy") ? configuration.url : `${configuration.url}/clientproxy`,
                selfManagedLogin: false,
                multisession: true,
                logConfig: Log.toWebapiConfig(configuration.log),
            };
        }
        login(credential) {
            var _a;
            return __awaiter$d(this, void 0, void 0, function* () {
                const rememberMe = (_a = this.api.options.rememberMe) !== null && _a !== void 0 ? _a : false;
                let validCredential = true;
                let loginProfile = null;
                try {
                    if (isBasicCredential(credential)) {
                        this.emit("login_in_progress", this.user, credential);
                        loginProfile = yield this.api.methods.login(credential.username, credential.password, rememberMe);
                    }
                    else if (isBerearCredential(credential)) {
                        this.emit("login_in_progress", this.user, credential);
                        loginProfile = yield this.api.methods.loginByAccessToken(credential.token, rememberMe);
                    }
                    else if (isExternalSessionIdCredential(credential)) {
                        this.emit("login_in_progress", this.user, credential);
                        loginProfile = yield this.api.methods.loginCustom(credential.externalSessionId, rememberMe);
                    }
                    else {
                        validCredential = false;
                    }
                }
                catch (error) {
                    this.emit("login_failed", error, this.user);
                    throw error;
                }
                if (!validCredential) {
                    throw "invalid credential, only Basic or Bearer or ExternalSessionId is allowed";
                }
                if (!loginProfile) {
                    throw "invalid response from login";
                }
            });
        }
        logout(reason, note) {
            return __awaiter$d(this, void 0, void 0, function* () {
                return this.api.methods.logoutAndExit(reason, note);
            });
        }
        isLogged() {
            var _a;
            if (isApiLoginProfileBehaviourSubject(this.api.loginProfile)) {
                return (_a = this.api.loginProfile.value.logged) !== null && _a !== void 0 ? _a : false;
            }
            else {
                return this.user.state === User.State.LOGGED;
            }
        }
    }
    Client.ready = "ready";
    Client.logged_in = "logged_in";
    Client.logged_out = "logged_out";
    Client.login_in_progress = "login_in_progress";
    Client.login_failed = "login_failed";
    function isApiLoginProfileBehaviourSubject(observable) {
        return !!observable.value;
    }
    function isBasicCredential(credential) {
        return credential.username !== undefined;
    }
    function isBerearCredential(credential) {
        return credential.token !== undefined;
    }
    function isExternalSessionIdCredential(credential) {
        return credential.externalSessionId !== undefined;
    }
    (function (Client) {
        (function (ClientState) {
            ClientState["READY"] = "READY";
            ClientState["LOGIN_REQUIRED"] = "LOGIN_REQUIRED";
            ClientState["LOGIN_IN_PROGRESS"] = "LOGIN_IN_PROGRESS";
            ClientState["LOGIN_FAILED"] = "LOGIN_FAILED";
        })(Client.ClientState || (Client.ClientState = {}));
        class ClientLogConfigurator extends Log.LogConfigurator {
            constructor(
            client) {
                super();
                this.client = client;
                const enableValue = this.client.api.logConfigurator.prefix ? this.client.api.logConfigurator.prefix + "*" : "*";
                let enabled = ClientLogConfigurator.disableNamespace();
                if (enabled) {
                    if (enabled !== "*" && this.client.api.logConfigurator.prefix && enabled.indexOf(this.client.api.logConfigurator.prefix) < 0) {
                        enabled += "," + enableValue;
                    }
                }
                else {
                    enabled = enableValue;
                }
                ClientLogConfigurator.enableNamespace(enabled);
            }
            get enabled() {
                return this.client.api.logConfigurator.enabled;
            }
            set enabled(enabled) {
                this.client.api.logConfigurator.enabled = enabled;
            }
            get objectToJson() {
                return this.client.api.logConfigurator.objectToJson;
            }
            set objectToJson(objectToJson) {
                this.client.api.logConfigurator.objectToJson = !!objectToJson;
            }
            set instanceIdLogged(instanceIdLogged) {
                this.client.api.logConfigurator.instanceIdLogged = !!instanceIdLogged;
            }
            get instanceIdLogged() {
                return this.client.api.logConfigurator.instanceIdLogged;
            }
            set logLevel(logLevel) {
                if (logLevel && logLevel >= Log.LogLevel.Verbose && logLevel <= Log.LogLevel.None) {
                    this.client.api.logConfigurator.logLevel = logLevel;
                }
            }
            get logLevel() {
                return this.enabled ? this.client.api.logConfigurator.logLevel : Log.LogLevel.None;
            }
            get prefix() {
                return this.client.api.logConfigurator.prefix;
            }
            set prefix(prefix) {
                this.client.api.logConfigurator.prefix = prefix;
            }
            get timestamp() {
                return this.client.api.logConfigurator.timestamp;
            }
            set timestamp(timestamp) {
                this.client.api.logConfigurator.timestamp = !!timestamp;
            }
            static enableNamespace(namespace) {
                debug.enable(namespace);
            }
            static disableNamespace() {
                return debug.disable();
            }
        }
        Client.ClientLogConfigurator = ClientLogConfigurator;
    })(Client || (Client = {}));

    exports.Call = Call;
    exports.CallSip = CallSip;
    exports.Client = Client;
    exports.Contact = Contact;
    exports.DeviceSip = DeviceSip;
    exports.ExternalItemContact = ExternalItemContact;
    exports.ExternalOrganizationContact = ExternalOrganizationContact;
    exports.InternalServiceContact = InternalServiceContact;
    exports.InternalShortNumberContact = InternalShortNumberContact;
    exports.InternalUserContact = InternalUserContact;
    exports.Log = Log;
    exports.PersonalContact = PersonalContact;
    exports.Phone = Phone;
    exports.SearchResult = SearchResult;
    exports.Transport = Transport;
    exports.User = User;
    exports.isContact = isContact;
    exports.isString = isString;

    Object.defineProperty(exports, '__esModule', { value: true });

}));
