"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.countSelection = void 0;
function isSelectedFeatureSet(ss) {
    return ss.SelectedLayer;
}
function countSelection(mgSelection, clientSelection) {
    var _a, _b, _c, _d, _e, _f, _g;
    var summary = { total: 0, layerCount: 0 };
    if (mgSelection) {
        if (isSelectedFeatureSet(mgSelection)) {
            summary.layerCount = mgSelection.SelectedLayer.length;
            for (var _i = 0, _h = mgSelection.SelectedLayer; _i < _h.length; _i++) {
                var lyr = _h[_i];
                summary.total += (_b = (_a = lyr.Feature) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
            }
        }
        else {
            summary.layerCount = mgSelection.Layer.length;
            for (var _j = 0, _k = mgSelection.Layer; _j < _k.length; _j++) {
                var lyr = _k[_j];
                summary.total += (_e = (_d = (_c = lyr.Class) === null || _c === void 0 ? void 0 : _c.ID) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0;
            }
        }
    }
    if (clientSelection) {
        summary.layerCount = clientSelection.layers.length;
        for (var _l = 0, _m = clientSelection.layers; _l < _m.length; _l++) {
            var lyr = _m[_l];
            summary.total += (_g = (_f = lyr.features) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0;
        }
    }
    if (summary.total == 0 && summary.layerCount == 0) {
        return undefined;
    }
    return summary;
}
exports.countSelection = countSelection;
//# sourceMappingURL=selection-count.js.map