import { Flex, Heading, Pagination, Space, SpaceVertical, Text } from '@looker/components';
import React, { useState } from 'react';
import { DiffItem } from './DiffItem';
export var DocDiff = _ref => {
  var {
    delta,
    leftKey,
    leftSpec,
    rightKey,
    rightSpec,
    pageSize = 15
  } = _ref;
  var [page, setPage] = useState(1);
  if (delta.length === 0) return React.createElement(Text, null, 'No differences found');
  var pageCount = Math.round((delta.length - 1) / pageSize);
  var pageItemData = delta.slice((page - 1) * pageSize + 1, page * pageSize + 1);
  return React.createElement(React.Fragment, null, delta.length === 0 ? React.createElement(Text, null, 'No differences found') : React.createElement(Flex, {
    flexDirection: "column",
    alignItems: "center"
  }, React.createElement(Space, null, React.createElement(Heading, {
    as: "h2"
  }, "".concat(delta.length, " differences between ").concat(leftKey, " and ").concat(rightKey))), React.createElement(SpaceVertical, {
    mt: "large",
    gap: "xxsmall"
  }, pageItemData.map((item, index) => React.createElement(DiffItem, {
    key: index,
    item: item,
    leftKey: leftKey,
    leftSpec: leftSpec,
    rightKey: rightKey,
    rightSpec: rightSpec
  }))), React.createElement(Pagination, {
    current: page,
    pages: pageCount,
    onChange: nextPage => {
      setPage(nextPage);
    }
  })));
};
//# sourceMappingURL=DocDiff.js.map