"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLogic = void 0;
const react_1 = require("react");
const personalDataSecurity_1 = require("../../../../../personalDataSecurity");
const useGenerateLocalFileURL_1 = require("../../../../hooks/useGenerateLocalFileURL");
const useLogic = ({ file, fileUrl, isHidePersonalData, }) => {
    const { generateUrl } = (0, useGenerateLocalFileURL_1.useGenerateLocalFileURL)();
    const generateSrc = () => {
        if (fileUrl) {
            return fileUrl;
        }
        if (file) {
            return generateUrl(file);
        }
        return '';
    };
    const hidePersonalDataClassName = (0, personalDataSecurity_1.useHidePersonalData)({
        isEnabled: isHidePersonalData,
    });
    const scrollRef = (0, react_1.useRef)(null);
    return {
        mediaObjectProps: {
            data: `${generateSrc()}#toolbar=0&scrollbar=0`,
            className: hidePersonalDataClassName,
        },
        imageProps: {
            src: generateSrc(),
            className: hidePersonalDataClassName,
        },
        pdfViewerProps: {
            isViewerLite: true,
            isFullHeight: true,
            isCentered: true,
            file: file || fileUrl,
            scrollRef,
            renderPageRange: { end: 0 },
        },
        scrollRef,
    };
};
exports.useLogic = useLogic;
