"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),s=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/objectWithoutProperties"),o=require("react"),i=require("@material-ui/core"),t=require("classnames"),c=require("../../IconButton/index.js"),n=require("../../Tooltip/Tooltip.js");require("../../Tooltip/ScrollableTooltip.js");var l=require("../../../icons/iconParkIcons.js");require("../../../icons/customIcons/icons/AddMessage.js"),require("../../../icons/customIcons/icons/Attention.js"),require("../../../icons/customIcons/icons/Collapse.js"),require("../../../icons/customIcons/icons/Dashboard.js"),require("../../../icons/customIcons/icons/Expand.js"),require("../../../icons/customIcons/icons/FolderClosed.js"),require("../../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../../icons/customIcons/icons/FolderOpened.js"),require("../../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../../icons/customIcons/icons/LessOrEqual.js"),require("../../../icons/customIcons/icons/Search.js"),require("../../../icons/customIcons/icons/Wellhub.js"),require("../../../icons/customIcons/icons/MultiRuler.js"),require("../../../icons/customIcons/icons/Checkbox.js"),require("../../../icons/customIcons/icons/CheckboxChecked.js"),require("../../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../../icons/customIcons/icons/Radio.js"),require("../../../icons/customIcons/icons/RadioChecked.js"),require("../../../icons/customIcons/icons/SimulFrac.js"),require("../../../icons/customIcons/icons/ZipperFrac.js"),require("../../../icons/customIcons/icons/CautionFilled.js"),require("../../../icons/customIcons/icons/MoreApp.js");var u=require("react/jsx-runtime");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=a(e),p=a(s),m=a(r),b=a(t),j=["isExpanded","setIsExpanded","tooltipTitle","collapsibleHeader","collapsibleBody","maxCellWidth","maxCharsNumberFromStart","maxCharsNumberFromEnd","cellWidth","children"];function h(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter((function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable}))),r.push.apply(r,o)}return r}function C(e){for(var s=1;s<arguments.length;s++){var r=null!=arguments[s]?arguments[s]:{};s%2?h(Object(r),!0).forEach((function(s){d.default(e,s,r[s])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))}))}return e}var q=i.makeStyles((function(e){return{stickyCell:{position:"sticky",left:0,zIndex:2,background:e.palette.background.b4},stickyEmptyCell:{position:"sticky",right:0,zIndex:2},collapseHeader:{width:function(e){var s=e.isExpanded,r=e.maxCellWidth,o=e.cellWidth;return s?r:o}},tableCellWrapper:{display:"flex",alignItems:"center",justifyContent:"space-between",width:function(e){var s=e.isExpanded,r=e.maxCellWidth,o=e.cellWidth;return s?r:o}},iconButton:{padding:0,fontSize:16,"&:hover":{backgroundColor:"transparent"}}}}));exports.TableCell=function(e){var s,r=e.isExpanded,t=e.setIsExpanded,a=e.tooltipTitle,d=e.collapsibleHeader,h=e.collapsibleBody,x=e.maxCellWidth,y=e.maxCharsNumberFromStart,f=e.maxCharsNumberFromEnd,I=e.cellWidth,k=e.children,O=m.default(e,j),g=O.stickyCell&&!O.emptyCell,E=q({isExpanded:r,cellWidth:I,maxCellWidth:x}),v=o.useState(!1),W=p.default(v,2),P=W[0],F=W[1];return u.jsxs(i.TableCell,C(C({},O),{},{className:b.default(d&&E.collapseHeader,g&&E.stickyCell,O.emptyCell&&E.stickyEmptyCell,g&&"stickyCell",O.emptyCell&&"stickyEmptyCell",O.className),children:[d&&u.jsxs("div",{className:E.tableCellWrapper,children:[k,u.jsx(c,{className:E.iconButton,size:"small",onClick:function(){F(!1),t(!r)},tooltipProps:{title:r?"Collapse":"Expand",open:P,disableHoverListener:!0,onMouseEnter:function(){return F(!0)},onMouseLeave:function(){return F(!1)}},children:r?u.jsx(l.LeftIcon,{size:16}):u.jsx(l.RightIcon,{size:16})})]}),h&&u.jsx(n.Tooltip,{title:r?"":a,children:u.jsx("div",{children:r?k:(s=a,s.length>y+f?"".concat(s.substring(0,y)," ... ").concat(s.substring(s.length-f)):s)})}),!d&&!h&&k]}))};
