import t from"@babel/runtime/helpers/slicedToArray";import e from"@babel/runtime/helpers/objectWithoutProperties";import{useContext as o,useState as i,useRef as r,useEffect as l}from"react";import{makeStyles as n,Tooltip as a}from"@material-ui/core";import u from"@material-ui/icons/Straighten";import s from"../ChartWrapperContext.js";import{jsxs as p,jsx as c}from"react/jsx-runtime";var f=["left","width","top","bottom","right","labelOffset","offset","height","coll","opposite","visible","onCustomizeScaleClick"],h=n((function(t){return{axis:function(t){var e=t.width,o=t.height;return{position:"absolute",cursor:"pointer",width:e,left:t.left,bottom:t.bottom,height:o,right:t.right,top:t.top}},tooltip:{display:"flex",alignItems:"center",justifyContent:"space-between",minWidth:125,backgroundColor:t.palette.background.b9,color:t.palette.text.primary,fontSize:"12px",lineHeight:"16px",letterSpacing:"0.4px",borderRadius:"4px",padding:"4px",zIndex:1e4},tooltipIcon:{fontSize:16,color:t.palette.primary.text6}}})),m=function(n){var m,d,g=n.left,b=n.width,x=n.top,v=n.bottom,y=n.right,C=n.labelOffset,w=n.offset,B=n.height,E=n.coll,S=n.opposite,z=n.visible,M=n.onCustomizeScaleClick,O=e(n,f),W=o(s).chart,k=i({}),j=t(k,2),I=j[0],A=j[1],N=r(),P=(null==W?void 0:W.inverted)?"yAxis"===E:"xAxis"===E,R=14+Math.abs(C),H=14+Math.abs(C),D=((null==O||null===(m=O.userOptions)||void 0===m?void 0:m.title)||{}).text,F=h({width:P?b:H,height:P?H:B,top:P?S?x-H+w:"auto":x,right:P?y:S?y-H-w:"auto",left:P?g:S?"auto":g-H+w,bottom:P?S?"auto":v-H-w:v}),G=null===(d=N.current)||void 0===d?void 0:d.getBoundingClientRect(),L=p("div",{className:F.tooltip,children:[c(u,{className:F.tooltipIcon})," Customize Scale"]}),T=function(){var t=W[E].find((function(t){return t.userOptions.title.text===D}));null==t||t.update({lineColor:"#03BCD4",lineWidth:2,labels:{style:{color:"#ffffff"}},title:{style:{color:"#ffffff"}}})},X=function(){var t=W[E].find((function(t){return t.userOptions.title.text===D}));null==t||t.update({lineColor:"#3B3B3B",lineWidth:1,labels:{style:{color:"#9E9E9E"}},title:{style:{color:"#9E9E9E"}}})};return l((function(){var t=W.axisGroup;t&&(t.element.style.cursor="pointer")}),[W]),z?c(a,{title:L,placement:P?S?"bottom":"top":S?"left":"right",onMouseMove:function(t){var e=t.pageX,o=t.pageY;A({x:e,y:o})},PopperProps:{anchorEl:{clientHeight:0,clientWidth:0,getBoundingClientRect:function(){var t=S?R:0,e=S?0:R;return{top:P?G.y-t:I.y,left:P?I.x:G.x-e,right:P?I.x:G.x+e,bottom:P?G.y+t:I.y,width:0,height:0}}}},children:c("div",{className:F.axis,ref:N,onClick:function(){return M(O)},onMouseOver:T,onMouseLeave:X,onFocus:T,onBlur:X})}):null};export{m as default};
//# sourceMappingURL=AxisOverlay.js.map
