"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/toConsumableArray"),t=require("@babel/runtime/helpers/defineProperty"),r=require("react/jsx-runtime"),n=require("react"),o=require("classnames"),i=require("react-virtualized"),a=require("@material-ui/core"),l=require("@material-ui/icons"),u=require("../../utils/convert.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=s(e),d=s(t),f=s(o);function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){d.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var p=a.makeStyles((function(e){return{table:{"& .ReactVirtualized__Table__headerRow":{textTransform:"none",borderBottom:e.isLightTheme?"1px solid rgba(224, 224, 224, 1)":"1px solid rgba(81, 81, 81, 1)"},"& .ReactVirtualized__Table__row":{borderBottom:e.isLightTheme?"1px solid rgba(224, 224, 224, 1)":"1px solid rgba(81, 81, 81, 1)"},"& .ReactVirtualized__Table__Grid":{outline:"none"},"& .ReactVirtualized__Table__headerColumn":{outline:"none"}},oddRow:{backgroundColor:e.isLightTheme?"rgba(189, 189, 189, 0.1)":"#303030"},headerLabel:{lineHeight:"14px",fontSize:"12px",fontStyle:"normal",letterSpacing:"-0.25px",display:"flex",alignItems:"center",flexWrap:"wrap"},cellData:{lineHeight:"14px",fontSize:"12px",fontWeight:"normal",fontStyle:"normal",letterSpacing:"0.15px"},unitLabel:{fontSize:"10px",opacity:.5},settingIcon:{padding:"3px",fontSize:"20px"},sortIcon:{fontSize:"16px"}}}));function b(e,t){var r=e.find((function(e){return e.key===t}))||{},n=r.unitType,o=r.customUnit;return o?"(".concat(o,")"):n?"(".concat(u.getUnitDisplay(n),")"):""}function y(e,t){return(e.find((function(e){return e.key===t}))||{}).headerLabelClassName||""}function g(e,t){return(e.find((function(e){return e.key===t}))||{}).headerLabelUnitClassName||""}var w=function(e){var t=e.columns,o=e.data,u=e.useColumnSetting,s=e.useFixedColumnWidth,h=e.onOpenSettingDlg,w=e.width,x=e.height,S=e.headerHeight,j=e.rowHeight,v=e.showTopSettingIcon,O=e.customMuiStyles,_=e.isTopSettingIconShownAlways,z=e.CustomCellRenderer,C=e.CustomHeaderCellRenderer,T=e.customRowStyle,k=e.sort,D=e.sortBy,N=e.sortDirection,R=e.onScroll,I=void 0===R?function(){}:R,P=p(),q=m(m({},P),O),L=n.useMemo((function(){return{label:"",key:"setting",width:u?25:0}}),[u]),M=n.useMemo((function(){return t.filter((function(e){return e.show}))}),[t]),H=n.useMemo((function(){return u?[].concat(c.default(M),[L]):M}),[M,u,L]),A=n.useMemo((function(){if(w<=0)return{};var e=d.default({},L.key,L.width),t=[];return M.filter((function(e){return Number.isFinite(e.width)})).forEach((function(r){e[r.key]=r.width-1,t.push(r.width-1)})),M.filter((function(e){return!Number.isFinite(e.width)})).forEach((function(r){var n=t.reduce((function(e,t){return e+t}),0),o=Math.floor((w-n-L.width)/(M.length-t.length)),i=r.minWidth||65,a=o<i?i:o;e[r.key]=a-1,t.push(a-1)})),e}),[w,M,L]),B=n.useMemo((function(){return Object.values(A).reduce((function(e,t){return e+t}),0)}),[A]),E=_||B-12.5>=w;n.useEffect((function(){v(E)}),[E]);var K=function(e){var n=e.label,o=e.dataKey,u=D||N||k;return C?r.jsx(C,{columnKey:o,columns:t,sortBy:D,sortDirection:N}):o===L.key?E?null:r.jsx(a.IconButton,{size:"small","aria-label":"customize columns",className:q.settingIcon,onClick:h,children:r.jsx(l.Settings,{fontSize:"inherit"})}):r.jsxs(a.Typography,{variant:"body2",className:f.default(q.headerLabel,y(t,o)),children:[n," ",r.jsx("span",{className:f.default(q.unitLabel,g(t,o)),children:b(t,o)}),u&&o!==D&&r.jsx(a.Tooltip,{title:"Sort A-Z",children:r.jsx(l.Sort,{fontSize:"small",className:P.sortIcon})}),u&&o===D&&(N===i.SortDirection.ASC?r.jsx(l.ArrowUpward,{fontSize:"small",className:P.sortIcon}):r.jsx(l.ArrowDownward,{fontSize:"small",className:P.sortIcon}))]})},V=function(e){var n=e.dataKey,o=e.rowData;return z?r.jsx(z,{columnKey:n,value:o[n],rowData:o,columns:t}):r.jsx(a.Typography,{variant:"body2",className:q.cellData,children:o[n]})};return r.jsx(r.Fragment,{children:r.jsx(i.Table,{width:s?B:w,height:x,headerHeight:S,rowClassName:function(e){var t=e.index;return f.default(d.default({},q.oddRow,t%2==1))},rowHeight:j,rowCount:o.length,rowGetter:function(e){var t=e.index;return o[t]},rowStyle:T||{},className:q.table,sort:k,sortBy:D,sortDirection:N,onScroll:I,children:H.map((function(e){return r.jsx(i.Column,{width:A[e.key]||0,dataKey:e.key,label:e.label,headerRenderer:K,cellRenderer:V},e.key)}))})})};exports.VirtualizedTableComponent=w,exports.default=w;
//# sourceMappingURL=VirtualizedTable.js.map
