import{__rest as o,__assign as t}from'./../../../ext-esm/tslib/tslib.es6.js';import{jsx as i,jsxs as n,Fragment as e}from"react/jsx-runtime";import{useState as s}from"react";import c from"classnames";import{makeStyles as r,Popover as l}from"@material-ui/core";import{SettingTwoIcon as a,CloseSmallIcon as m}from"../../../icons/iconParkIcons.js";import"../../../icons/customIcons/icons/AddMessage.js";import"../../../icons/customIcons/icons/Attention.js";import"../../../icons/customIcons/icons/Collapse.js";import"../../../icons/customIcons/icons/Dashboard.js";import"../../../icons/customIcons/icons/Expand.js";import"../../../icons/customIcons/icons/FolderClosed.js";import"../../../icons/customIcons/icons/FolderClosedFilled.js";import"../../../icons/customIcons/icons/FolderOpened.js";import"../../../icons/customIcons/icons/GreaterOrEqual.js";import"../../../icons/customIcons/icons/LessOrEqual.js";import"../../../icons/customIcons/icons/Search.js";import"../../../icons/customIcons/icons/Wellhub.js";import"../../../icons/customIcons/icons/MultiRuler.js";import"../../../icons/customIcons/icons/Checkbox.js";import"../../../icons/customIcons/icons/CheckboxChecked.js";import"../../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../../icons/customIcons/icons/Radio.js";import"../../../icons/customIcons/icons/RadioChecked.js";import"../../../icons/customIcons/icons/SimulFrac.js";import"../../../icons/customIcons/icons/ZipperFrac.js";import"../../../icons/customIcons/icons/CautionFilled.js";import"../../../icons/customIcons/icons/MoreApp.js";import{isNativeDetected as p,isMobileDetected as d}from"../../../utils/mobileDetect.js";import u from"../../IconButton/index.js";import h from"../../Modal/Modal.js";import g from"../../Button/components/Button/index.js";import"moment-timezone";import"../../Button/components/LiveButton/components/LiveButtonStateIndicator/index.js";import"../../Button/components/LiveButton/styles.js";var v=p||d,b=r((function(o){return{popoverPaper:{position:"relative",marginTop:function(o){return o.isScrollable?0:8},minWidth:286,width:286,overflowY:"hidden",backgroundColor:o.palette.background.b9,maxHeight:function(o){var t=o.maxHeight;return t?t-24:"calc(100% - 24px)"},"&.scrollable":{height:function(o){return o.maxHeight||"100%"},"&::after":{content:'""',position:"absolute",left:0,bottom:0,height:16,width:"calc(100% - 16px)",zIndex:1,background:"linear-gradient(180deg, rgba(65, 65, 65, 0.00) 0%, ".concat(o.palette.background.b9," 100%);")}}},popoverHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",height:76,padding:"24px 16px 16px 16px",position:"absolute",left:0,right:0,zIndex:1,"&.scrollable":{background:"linear-gradient(to bottom, ".concat(o.palette.background.b9,", ").concat(o.palette.background.b9," 89%, rgba(65, 65, 65, 0) 100%)")}},headerTitle:{fontSize:20},popoverContentContainer:{marginTop:60,paddingTop:16,overflowX:"hidden",overflowY:"auto","&.scrollable":{height:"calc(100% - 60px)"}},popoverContent:{width:"100%"},modalActions:{display:"flex",justifyContent:"flex-end"}}}));function f(r){var d=r.Trigger,f=void 0===d?null:d,j=r.children,C=r.classes,I=r.defaultScrollable,x=void 0!==I&&I,k=r.header,S=void 0===k?"Settings":k,B=r.iconSettingsProps,H=void 0===B?{}:B,z=r.maxHeight,A=void 0===z?null:z,P=r.modalActions,T=void 0===P?null:P,w=r.modalProps,F=void 0===w?{}:w,y=r.onClose,N=void 0===y?function(){}:y,O=o(r,["Trigger","children","classes","defaultScrollable","header","iconSettingsProps","maxHeight","modalActions","modalProps","onClose"]),E=s(null),L=E[0],M=E[1],D=s(!0),R=D[0],q=D[1],W=b({maxHeight:A,isScrollable:R,isNativeDetected:p}),Y=C||{},G=Y.popoverContent,X=o(Y,["popoverContent"]),Z=function(){M(null),N()},_=Boolean(L),J=function(o){return M(o.currentTarget)},K=T||i(g,{variation:"secondary",onClick:Z,children:"CLOSE"});return n(e,{children:[f?i(f,{onClick:J,isActive:_}):i(u,t({"data-testid":"chartSettingsButton",isActive:_,onClick:J,size:"small",tooltipProps:{title:"Settings"},variant:"contained"},H,{children:i(a,{size:(null==H?void 0:H.size)||16})})),!v&&n(l,t({open:_,anchorEl:L,onClose:Z,anchorOrigin:{vertical:R?"top":"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},marginThreshold:12},O,{classes:t(t({},X),{paper:c(W.popoverPaper,R&&"scrollable",null==X?void 0:X.paper)}),children:[n("div",{className:c(W.popoverHeader,R&&"scrollable"),children:[i("div",{className:W.headerTitle,children:S}),i(u,{tooltipProps:{title:"Close"},onClick:Z,children:i(m,{})})]}),i("div",{className:c(W.popoverContentContainer,R&&"scrollable"),ref:function(o){o&&o.scrollHeight<=o.clientHeight&&!x&&q(!1)},children:i("div",{className:c(W.popoverContent,G),children:j})})]})),v&&i(h,t({actions:K,onClose:Z,open:_,actionsClassName:W.modalActions,title:S},F,{children:j}))]})}export{f as AppSettingsPopover};
