import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { createElement as _createElement } from "react";
import { pdfjs } from 'react-pdf';
import { ContentState } from '../ContentState';
import { LoadingPlaceholder } from '../placeholders/LoadingPlaceholder';
import { defineWithResolversPolyfill } from '../polyfills';
import { ControlBar } from './ControlBar';
import { PDFJS_WORKER_URL } from './constants';
import { List } from './List';
import { PDFDocument } from './PdfDocument';
import { PDFPage } from './PdfPage';
import { PDFViewerContainer, ScrollContainer, Wrapper } from './styles';
import { useLogic } from './useLogic';
defineWithResolversPolyfill();
pdfjs.GlobalWorkerOptions.workerSrc = PDFJS_WORKER_URL;
/**
 * Компонент для просмотра PDF файлов
 */
export const PdfViewer = (props) => {
    const { documentProps, pageProps, pageCount, pageHeightList, isError, errorState, paginationRef, isLoading, initialIndex, isRenderList, isViewerLite, scale, zoomOut, zoomIn, isDisabledZoomOutButton, isDisabledZoomInButton, scrollContainerRef, loadingPlaceholderTitle, enabledZoom, isCentered, } = useLogic(props);
    return (_jsx(ContentState, { isError: isError, errorState: errorState, children: _jsxs(Wrapper, { "$isViewerLite": isViewerLite, "$enabledZoom": enabledZoom, children: [_jsx(PDFViewerContainer, { "$isViewerLite": isViewerLite, "$enabledZoom": enabledZoom, children: _jsx(ScrollContainer, { ref: scrollContainerRef, "$isViewerLite": isViewerLite, "$enabledZoom": enabledZoom, children: _jsx(PDFDocument, { ...documentProps, isLoading: isLoading, isCentered: isCentered, loading: _jsx(LoadingPlaceholder, { title: loadingPlaceholderTitle }), isViewerLite: isViewerLite, enabledZoom: enabledZoom, children: isRenderList && (_jsx(List, { paginationRef: paginationRef, initialIndex: initialIndex, children: pageHeightList?.map((height, index) => (_createElement(PDFPage, { ...pageProps, 
                                    // biome-ignore lint/suspicious/noArrayIndexKey: Страницы статичны
                                    key: index, height: height * scale, pageNumber: index + 1, pageCount: pageCount, isViewerLite: isViewerLite, scale: scale, enabledZoom: enabledZoom }))) }, pageHeightList?.[0])) }) }) }), _jsx(ControlBar, { zoomOut: zoomOut, zoomIn: zoomIn, pageNumber: Number(initialIndex) + 1, buttonProps: {
                        isDisabledZoomIn: isDisabledZoomInButton,
                        isDisabledZoomOut: isDisabledZoomOutButton,
                    }, isViewerLite: isViewerLite, isLoading: isLoading, pageCount: pageCount, enabledZoom: enabledZoom })] }) }));
};
