//
// Copyright 2024 DXOS.org
//
import React from 'react';
import { Panel } from '../../Panel';
import { Table, Unit } from '../Table';
export const DatabasePanel = ({ database, ...props }) => {
    const interval = database?.dataStats?.meta?.rateAverageOverSeconds
        ? ` (${database?.dataStats?.meta?.rateAverageOverSeconds}s)`
        : '';
    const storageStats = database?.dataStats?.storage;
    const rows = [
        ['#', 'objects', database?.objects ?? 0],
        ['#', 'documents', database?.documents ?? 0],
        ['#', 'documents (syncing)', database?.documentsToReconcile ?? 0],
        ['μ', `read rate ${interval}`, storageStats?.reads?.countPerSecond ?? 0, 'op/s'],
        ['μ', 'read duration', storageStats?.reads?.opDuration ?? 0, 'ms'],
        ['μ', 'read chunk size', Unit.KB(storageStats?.reads?.payloadSize), 'KB'],
        ['μ', `write rate ${interval}`, storageStats?.writes?.countPerSecond ?? 0, 'op/s'],
        ['μ', 'write duration', storageStats?.writes?.opDuration ?? 0, 'ms'],
        ['μ', 'write chunk size', Unit.KB(storageStats?.writes?.payloadSize), 'KB'],
    ];
    return (React.createElement(Panel, { ...props, icon: 'ph--database--regular', title: 'Database', info: React.createElement("div", { className: 'flex items-center gap-2' },
            database?.spaces ?? 0,
            " Space(s)"), maxHeight: 0 },
        React.createElement(Table, { rows: rows })));
};
//# sourceMappingURL=DatabasePanel.js.map