"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GenericLayerSetOL = exports.DEFAULT_METERS_PER_UNIT = void 0;
var tslib_1 = require("tslib");
var base_layer_set_1 = require("./base-layer-set");
var Tile_1 = tslib_1.__importDefault(require("ol/layer/Tile"));
var Image_1 = tslib_1.__importDefault(require("ol/layer/Image"));
var constants_1 = require("../constants");
var number_1 = require("../utils/number");
exports.DEFAULT_METERS_PER_UNIT = 1.0;
var M_TO_IN = 39.37;
var DEFAULT_DPI = 96;
/**
 * @hidden
 */
var GenericLayerSetOL = /** @class */ (function (_super) {
    tslib_1.__extends(GenericLayerSetOL, _super);
    function GenericLayerSetOL(view, subjectLayer, extent, externalBaseLayersGroup, projection, metersPerUnit, dpi) {
        if (metersPerUnit === void 0) { metersPerUnit = exports.DEFAULT_METERS_PER_UNIT; }
        if (dpi === void 0) { dpi = DEFAULT_DPI; }
        var _this = _super.call(this, externalBaseLayersGroup, projection, dpi, extent, M_TO_IN * metersPerUnit, view) || this;
        _this.subjectLayer = subjectLayer;
        return _this;
    }
    GenericLayerSetOL.prototype.getLayers = function () {
        var layers = [];
        if (this.externalBaseLayersGroup) {
            layers.push(this.externalBaseLayersGroup);
        }
        if (this.subjectLayer) {
            layers.push(this.subjectLayer);
        }
        return layers;
    };
    GenericLayerSetOL.prototype.getSourcesForProgressTracking = function () {
        var sources = [];
        if (this.externalBaseLayersGroup) {
            var bls = this.externalBaseLayersGroup.getLayersArray();
            for (var _i = 0, bls_1 = bls; _i < bls_1.length; _i++) {
                var bl = bls_1[_i];
                if (bl instanceof Image_1.default || bl instanceof Tile_1.default) {
                    sources.push(bl.getSource());
                }
            }
        }
        if (this.subjectLayer instanceof Image_1.default) {
            sources.push(this.subjectLayer.getSource());
        }
        else if (this.subjectLayer instanceof Tile_1.default) {
            sources.push(this.subjectLayer.getSource());
        }
        return sources;
    };
    GenericLayerSetOL.prototype.updateTransparency = function (trans) {
        //If no external layers defined, this won't be set
        if (this.externalBaseLayersGroup) {
            if (constants_1.LAYER_ID_BASE in trans) {
                this.externalBaseLayersGroup.setOpacity((0, number_1.restrictToRange)(trans[constants_1.LAYER_ID_BASE], 0, 1.0));
            }
            else {
                this.externalBaseLayersGroup.setOpacity(1.0);
            }
        }
        if (this.subjectLayer) {
            if (constants_1.LAYER_ID_MG_BASE in trans) {
                var opacity = (0, number_1.restrictToRange)(trans[constants_1.LAYER_ID_MG_BASE], 0, 1.0);
                this.subjectLayer.setOpacity(opacity);
            }
            else {
                this.subjectLayer.setOpacity(1.0);
            }
        }
    };
    GenericLayerSetOL.prototype.showActiveSelectedFeature = function (mapExtent, size, uri) {
        //throw new Error("Method not implemented.");
    };
    GenericLayerSetOL.prototype.update = function (showGroups, showLayers, hideGroups, hideLayers) {
        //throw new Error("Method not implemented.");
    };
    GenericLayerSetOL.prototype.updateSelectionColor = function (color) {
        //throw new Error("Method not implemented.");
    };
    return GenericLayerSetOL;
}(base_layer_set_1.BaseLayerSetOL));
exports.GenericLayerSetOL = GenericLayerSetOL;
//# sourceMappingURL=generic-layer-set.js.map