/**
 * DevExtreme (renovation/ui/grids/data_grid_next/plugins.js)
 * Version: 22.1.3 (build 22180-0310)
 * Build date: Wed Jun 29 2022
 *
 * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
exports.VisibleRows = exports.VisibleDataRows = exports.VisibleColumns = exports.TotalCount = exports.RemoteOperations = exports.LocalVisibleItems = exports.LocalDataState = exports.LocalData = exports.LoadOptionsValue = exports.KeyExprPlugin = exports.DataStateValue = exports.Columns = exports.CalculateLocalDataState = void 0;
var _context = require("../../../utils/plugin/context");
var LocalData = (0, _context.createValue)();
exports.LocalData = LocalData;
var LocalVisibleItems = (0, _context.createGetter)([]);
exports.LocalVisibleItems = LocalVisibleItems;
var VisibleRows = (0, _context.createGetter)([]);
exports.VisibleRows = VisibleRows;
var RemoteOperations = (0, _context.createValue)();
exports.RemoteOperations = RemoteOperations;
var LoadOptionsValue = (0, _context.createGetter)({});
exports.LoadOptionsValue = LoadOptionsValue;
var DataStateValue = (0, _context.createValue)();
exports.DataStateValue = DataStateValue;
var Columns = (0, _context.createValue)();
exports.Columns = Columns;
var VisibleColumns = (0, _context.createGetter)([]);
exports.VisibleColumns = VisibleColumns;
var LocalDataState = (0, _context.createGetter)(void 0);
exports.LocalDataState = LocalDataState;
var KeyExprPlugin = (0, _context.createValue)();
exports.KeyExprPlugin = KeyExprPlugin;
var TotalCount = (0, _context.createSelector)([DataStateValue], (function(dataState) {
    var _dataState$totalCount;
    return null !== (_dataState$totalCount = dataState.totalCount) && void 0 !== _dataState$totalCount ? _dataState$totalCount : dataState.data.length
}));
exports.TotalCount = TotalCount;
var VisibleDataRows = (0, _context.createSelector)([DataStateValue, KeyExprPlugin], (function(dataStateValue, keyExpr) {
    var rows = dataStateValue.data.map((function(data) {
        return {
            key: keyExpr ? data[keyExpr] : data,
            data: data,
            rowType: "data"
        }
    }));
    return rows
}));
exports.VisibleDataRows = VisibleDataRows;
var CalculateLocalDataState = (0, _context.createSelector)([LocalVisibleItems, LocalData], (function(visibleItems, localData) {
    return Array.isArray(localData) ? {
        data: null !== visibleItems && void 0 !== visibleItems ? visibleItems : [],
        totalCount: localData.length
    } : void 0
}));
exports.CalculateLocalDataState = CalculateLocalDataState;
