import i from"@babel/runtime/helpers/slicedToArray";import{useState as e,useEffect as r}from"react";import n from"prop-types";import o from"classnames";import{withStyles as a,Button as t,TextField as s}from"@material-ui/core";import l from"./icons/LeftArrow.js";import c from"./icons/GoLive.js";import m from"./icons/RightArrow.js";import d from"./icons/ZoomIn.js";import f from"./icons/TimeRange.js";import p from"./icons/ZoomOut.js";import u from"./ChartActionsList.css.js";import h from"../Modal/Modal.js";import{jsxs as v,jsx as g}from"react/jsx-runtime";var b=function(n){var a=n.onChange,b=n.min,C=n.max,k=n.left,A=n.right,N=n.classes,R=e(!1),j=i(R,2),y=j[0],q=j[1],x=e(k),L=i(x,2),F=L[0],T=L[1],I=e(A),P=i(I,2),V=P[0],w=P[1];r((function(){w(A),T(k)}),[k,A]);var M=A-k>=1,W=b<k||C>A,Z=k>b,G=A<C,J=A!==C,O=F<b||V>C||F+1>V,S=function(){q(!1)};return v("div",{className:u.container,children:[g("span",{className:o(u.action,!M&&u.disabled),onClick:function(){var i=A-k,e=k+i/4,r=A-i/4,n=r-e;if(n<1){var o=(1-n)/2;e+=o,r-=o}a({left:e,right:r})},children:g(d,{isActive:M})}),g("span",{className:o(u.action,!W&&u.disabled),onClick:function(){var i=A-k,e=k-i/2,r=A+i/2,n=r-e;e<b&&r>C?(e=b,r=C):e<b?(e=b,r=b+n):r>C&&(r=C,e=C-n),a({left:e,right:r})},children:g(p,{isActive:W})}),g("span",{className:o(u.action,!Z&&u.disabled),onClick:function(){var i=.75*(A-k),e=k-i,r=A-i;e<b&&(e=b,r=b+i),a({left:e,right:r})},children:g(l,{isActive:Z})}),g("span",{className:o(u.action,!G&&u.disabled),onClick:function(){var i=.75*(A-k),e=k+i,r=A+i;r>C&&(r=C,e=C-i),a({left:e,right:r})},children:g(m,{isActive:G})}),g("span",{className:o(u.action,!J&&u.disabled),onClick:function(){a({left:k,right:C})},children:g(c,{isActive:J})}),g("span",{className:u.action,onClick:function(){q(!0)},children:g(f,{})}),g(h,{open:y,onClose:S,title:"Jump to Selected Range",actions:v("div",{className:u.actions,children:[g(t,{variant:"textPrimary",onClick:S,children:"Cancel"}),g(t,{variant:"contained",color:"primary",onClick:function(){a({left:F,right:V}),q(!1)},disabled:O,children:"Apply"})]}),children:v("form",{noValidate:!0,className:u.form,children:[g(s,{id:"depth-from",label:"From",type:"number",defaultValue:F,onChange:function(i){T(parseFloat(i.target.value))},InputLabelProps:{shrink:!0},error:F<b,autoFocus:!0,className:N.input,fullWidth:!0}),g(s,{id:"depth-from",label:"To",type:"number",defaultValue:V,onChange:function(i){w(parseFloat(i.target.value))},InputLabelProps:{shrink:!0},error:V>C,fullWidth:!0})]})})]})};b.propTypes={onChange:n.func.isRequired,min:n.number.isRequired,max:n.number.isRequired,left:n.number.isRequired,right:n.number.isRequired,classes:n.shape({}).isRequired};var C=a({input:{marginRight:20}})(b);export{C as default};
