"use strict";var stringUtil=require("./stringUtil-dea69be9.js"),React=require("react"),useAutoScroll=function(i,u,o,l,s){void 0===s&&(s=!0);var a=stringUtil.__read(React.useState([]),2)[1],f=React.useRef(0),g=React.useRef([]);React.useEffect(function(){var r,t,e;i.show&&(r=u(),e=o(),r&&e&&(t=r.clientHeight,e=e.scrollHeight-(s?t:0),i.direction===stringUtil.ScrollDirection.up&&(f.current=e),r.scrollTop=f.current))},[u,o,s,i.direction,i.show]),React.useEffect(function(){if(i.show){var r,t,e=l(),c=u(),n=o();if(e&&c&&n)return e=e.clientHeight,r=c.clientHeight,n=n.scrollHeight-(s?r:0),r=i.step===stringUtil.ScrollType.byPage?r:e,e=1e3*(i.duration||1),i.direction===stringUtil.ScrollDirection.down?(i.loop?f.current>=n&&(f.current=0):f.current>n&&(f.current=n),f.current+=r):(i.loop?f.current<=0&&(f.current=n):f.current<0&&(f.current=0),f.current-=r),f.current>-r&&f.current<n+r&&(n=setTimeout(function(){c.scrollTop=f.current,a([])},e),g.current.push(n)),t=g.current,function(){for(;t.length;){var r=t.pop();clearTimeout(r)}}}})};exports.useAutoScroll=useAutoScroll;
