"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    fileXLSX: ()=>fileXLSX,
    fileCSV: ()=>fileCSV,
    fileXLS: ()=>fileXLS
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const excel_namespaceObject = require("@js-preview/excel");
var excel_default = /*#__PURE__*/ __webpack_require__.n(excel_namespaceObject);
const external_antd_namespaceObject = require("antd");
const external_file_sheet_style_js_namespaceObject = require("./file-sheet.style.js");
require("@js-preview/excel/lib/index.css");
const ExcelView = (props)=>{
    const { file } = props;
    const fileUrl = file.url;
    const { styles } = (0, external_file_sheet_style_js_namespaceObject.useStyles)();
    const excelContainerRef = (0, external_react_namespaceObject.useRef)(null);
    const excelPreviewerRef = (0, external_react_namespaceObject.useRef)(null);
    const [isLoading, setIsLoading] = (0, external_react_namespaceObject.useState)(true);
    (0, external_react_namespaceObject.useEffect)(()=>{
        const containerElement = excelContainerRef.current;
        if (containerElement && !excelPreviewerRef.current) {
            const myExcelPreviewer = excel_default().init(containerElement);
            excelPreviewerRef.current = myExcelPreviewer;
            setIsLoading(true);
            const handleShowPreviewer = async ()=>{
                await myExcelPreviewer.preview(fileUrl);
                setIsLoading(false);
            };
            try {
                handleShowPreviewer();
            } catch (e) {
                console.log('%c Line:36 🥟 e', e);
            }
        }
    }, [
        fileUrl
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
        className: styles.excelPreview,
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
                ref: excelContainerRef,
                className: styles.container
            }),
            isLoading && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
                className: styles.loading,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
                    size: "large"
                })
            })
        ]
    });
};
const OnlineView = (props)=>{
    const { file } = props;
    var _file_url;
    let fileUrl = null !== (_file_url = file.url) && void 0 !== _file_url ? _file_url : '';
    if (fileUrl.startsWith('/storage') && window.location.origin) fileUrl = window.location.origin + fileUrl;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("iframe", {
        src: "https://view.officeapps.live.com/op/embed.aspx?src=".concat(fileUrl),
        width: "100%",
        height: "600px",
        frameBorder: "0"
    });
};
const ViewComponent = (props)=>{
    const { file, prefixCls } = props;
    return file.imageUrl && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("img", {
        src: "".concat(file.imageUrl).concat(file.thumbnailRule || ''),
        style: {
            width: '100%',
            height: '100%'
        },
        alt: file.title,
        className: "".concat(prefixCls, "-list-item-image")
    });
};
const fileXLS = {
    key: 'application/vnd.ms-excel',
    type: 'application/vnd.ms-excel',
    viewComponet: (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ViewComponent, {
            ...props
        }),
    checkedComponent: (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(OnlineView, {
            ...props
        })
};
const fileXLSX = {
    key: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    viewComponet: (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ViewComponent, {
            ...props
        }),
    checkedComponent: (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(OnlineView, {
            ...props
        })
};
const fileCSV = {
    key: 'text/csv',
    type: 'text/csv',
    viewComponet: (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ViewComponent, {
            ...props
        }),
    checkedComponent: (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ExcelView, {
            ...props
        })
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
