import e from"@babel/runtime/helpers/defineProperty";import{jsx as r,jsxs as t}from"react/jsx-runtime";import o from"classnames";import{Dialog as i,Typography as n,IconButton as l}from"@material-ui/core";import a from"@material-ui/icons/Close";import s from"@material-ui/icons/GetApp";import c from"../GoogleDocsViewer/index.js";import{isGoogleDocsPreviewEnabled as p}from"../../utils/env.js";import m from"../LoadingIndicator/LoadingIndicator.js";import{useFileContent as f}from"./effects/useFileContent.js";import{useStyles as d}from"./styles.js";function u(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function h(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?u(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):u(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}var b=function(e){var u=e.classes,b=e.open,v=e.fileUrl,j=e.fileName,O=void 0===j?"DocumentViewer":j,w=e.onClose,y=e.fileSize,g=e.webviewType,N=e["data-testid"],P=void 0===N?"DocumentViewer":N,C=d(),D=f({fileUrl:v,fileName:O}),z=D.isLoading,S=D.fileContent;return r(i,p?{open:b,onClose:w,classes:h(h({},u),{},{paper:o(C.paper,null==u?void 0:u.paper)}),children:r(c,{webviewType:g,fileUrl:v,fileName:O,fileSize:y,onClose:w,width:"100%",height:"100%"})}:{classes:h(h({},u),{},{paper:o(C.paper,null==u?void 0:u.paper)}),open:b,onClose:w,onContextMenu:function(e){return e.stopPropagation()},children:t("div",{"data-testid":"".concat(P,"_file_").concat(O),className:C.root,children:[t("div",{className:C.toolbar,children:[r(n,{"data-testid":"".concat(P,"_fileName"),children:O}),t("div",{children:[r(l,{size:"small",className:C.iconButton,children:r("a",{download:!0,href:v,target:"_blank",rel:"noopener noreferrer",children:r(s,{fontSize:"small"})})}),r(l,{size:"small",onClick:w,className:C.iconButton,children:r(a,{fontSize:"small"})})]})]}),z&&r("div",{className:C.frame,children:r(m,{white:!1})}),!z&&r("div",{className:C.frame,children:r("div",{className:C.sheet,children:S})})]})})};export{b as default};
//# sourceMappingURL=NewDocumentViewer.js.map
