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