"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactPdf = require("react-pdf");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
// CustomPDFViewer.js

// Importing the PDF.js worker.
_reactPdf.pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.js', import.meta.url).toString();
const CustomPDFViewer = _ref => {
  let {
    pdfFile
  } = _ref;
  const [numPages, setNumPages] = (0, _react.useState)(null);
  const [pageNumber, setPageNumber] = (0, _react.useState)(1);
  const onDocumentLoadSuccess = _ref2 => {
    let {
      numPages
    } = _ref2;
    setNumPages(numPages);
  };
  const goToPrevPage = () => setPageNumber(pageNumber - 1 <= 1 ? 1 : pageNumber - 1);
  const goToNextPage = () => setPageNumber(pageNumber + 1 >= numPages ? numPages : pageNumber + 1);
  return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("nav", null, /*#__PURE__*/_react.default.createElement("button", {
    onClick: goToPrevPage
  }, "Prev"), /*#__PURE__*/_react.default.createElement("button", {
    onClick: goToNextPage
  }, "Next"), /*#__PURE__*/_react.default.createElement("p", null, "Page ", pageNumber, " of ", numPages)), /*#__PURE__*/_react.default.createElement(_reactPdf.Document, {
    file: pdfFile,
    onLoadSuccess: onDocumentLoadSuccess
  }, /*#__PURE__*/_react.default.createElement(_reactPdf.Page, {
    pageNumber: pageNumber
  })));
};
var _default = exports.default = CustomPDFViewer;