import { __assign, __extends } from "tslib";
import { Config, Logger, FetchTransport, LogLevel } from '@amplitude/analytics-core';
import { DEFAULT_PERFORMANCE_CONFIG, DEFAULT_SAMPLE_RATE, DEFAULT_SERVER_ZONE } from '../constants';
import { SafeLoggerProvider } from '../logger';
import { validateUGCFilterRules } from '../helpers';
export var getDefaultConfig = function () { return ({
    flushMaxRetries: 2,
    logLevel: LogLevel.Warn,
    loggerProvider: new Logger(),
    transportProvider: new FetchTransport(),
}); };
var SessionReplayLocalConfig = /** @class */ (function (_super) {
    __extends(SessionReplayLocalConfig, _super);
    function SessionReplayLocalConfig(apiKey, options) {
        var _this = this;
        var _a, _b;
        var defaultConfig = getDefaultConfig();
        _this = _super.call(this, __assign(__assign({ transportProvider: defaultConfig.transportProvider, loggerProvider: new SafeLoggerProvider(options.loggerProvider || defaultConfig.loggerProvider) }, options), { apiKey: apiKey })) || this;
        _this.flushMaxRetries =
            options.flushMaxRetries !== undefined && options.flushMaxRetries <= defaultConfig.flushMaxRetries
                ? options.flushMaxRetries
                : defaultConfig.flushMaxRetries;
        _this.apiKey = apiKey;
        _this.sampleRate = options.sampleRate || DEFAULT_SAMPLE_RATE;
        _this.serverZone = options.serverZone || DEFAULT_SERVER_ZONE;
        _this.configServerUrl = options.configServerUrl;
        _this.trackServerUrl = options.trackServerUrl;
        _this.shouldInlineStylesheet = options.shouldInlineStylesheet;
        _this.version = options.version;
        _this.performanceConfig = options.performanceConfig || DEFAULT_PERFORMANCE_CONFIG;
        _this.storeType = (_a = options.storeType) !== null && _a !== void 0 ? _a : 'idb';
        _this.applyBackgroundColorToBlockedElements = (_b = options.applyBackgroundColorToBlockedElements) !== null && _b !== void 0 ? _b : false;
        if (options.privacyConfig) {
            _this.privacyConfig = options.privacyConfig;
        }
        if (options.interactionConfig) {
            _this.interactionConfig = options.interactionConfig;
            // validate ugcFilterRules, throw error if invalid - throw error at the beginning of the config
            if (_this.interactionConfig.ugcFilterRules) {
                validateUGCFilterRules(_this.interactionConfig.ugcFilterRules);
            }
        }
        if (options.debugMode) {
            _this.debugMode = options.debugMode;
        }
        if (options.experimental) {
            _this.experimental = options.experimental;
        }
        if (options.omitElementTags) {
            _this.omitElementTags = options.omitElementTags;
        }
        return _this;
    }
    return SessionReplayLocalConfig;
}(Config));
export { SessionReplayLocalConfig };
//# sourceMappingURL=local-config.js.map