"use strict";var e=require('./../../ext-esm/tslib/tslib.es6.js'),i=require("react/jsx-runtime"),s=require("classnames"),l=require("@material-ui/core"),a=require("@material-ui/icons/Close"),r=require("@material-ui/icons/GetApp"),n=require("../GoogleDocsViewer/index.js"),o=require("../../utils/env.js"),t=require("../LoadingIndicator/LoadingIndicator.js"),c=require("./effects/useFileContent.js"),d=require("./styles.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=u(s),m=u(a),p=u(r);module.exports=function(s){var a=s.classes,r=s.open,u=s.fileUrl,j=s.fileName,x=void 0===j?"DocumentViewer":j,h=s.onClose,v=s.fileSize,g=s.webviewType,_=s["data-testid"],q=void 0===_?"DocumentViewer":_,w=d.useStyles(),N=c.useFileContent({fileUrl:u,fileName:x}),C=N.isLoading,b=N.fileContent;return o.isGoogleDocsPreviewEnabled?i.jsx(l.Dialog,{open:r,onClose:h,classes:e.__assign(e.__assign({},a),{paper:f.default(w.paper,null==a?void 0:a.paper)}),children:i.jsx(n,{webviewType:g,fileUrl:u,fileName:x,fileSize:v,onClose:h,width:"100%",height:"100%"})}):i.jsx(l.Dialog,{classes:e.__assign(e.__assign({},a),{paper:f.default(w.paper,null==a?void 0:a.paper)}),open:r,onClose:h,onContextMenu:function(e){return e.stopPropagation()},children:i.jsxs("div",{"data-testid":"".concat(q,"_file_").concat(x),className:w.root,children:[i.jsxs("div",{className:w.toolbar,children:[i.jsx(l.Typography,{"data-testid":"".concat(q,"_fileName"),children:x}),i.jsxs("div",{children:[i.jsx(l.IconButton,{size:"small",className:w.iconButton,children:i.jsx("a",{download:!0,href:u,target:"_blank",rel:"noopener noreferrer",children:i.jsx(p.default,{fontSize:"small"})})}),i.jsx(l.IconButton,{size:"small",onClick:h,className:w.iconButton,children:i.jsx(m.default,{fontSize:"small"})})]})]}),C&&i.jsx("div",{className:w.frame,children:i.jsx(t,{white:!1})}),!C&&i.jsx("div",{className:w.frame,children:i.jsx("div",{className:w.sheet,children:b})})]})})};
