"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("@babel/runtime/helpers/taggedTemplateLiteral"),r=require("@babel/runtime/helpers/defineProperty"),n=require("@babel/runtime/helpers/slicedToArray"),o=require("@babel/runtime/helpers/objectWithoutProperties"),i=require("react"),u=require("ts-debounce"),l=require("clsx"),c=require("@prom-ui/core/Button"),a=require("@prom-ui/core/Icon"),s=require("@prom-ui/core/Portal"),f=require("@prom-ui/core/BodyProvider"),d=require("@prom-ui/core/useIsMounted"),p=require("@prom-ui/icons/ArrowUp");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function m(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var y,v=b(e),g=b(t),h=b(r),O=b(n),P=b(o),j=m(i),q=b(l),E="_5lPav",w=["children","scrollRef","onClick","scrollDelay","scrollOffset","margin","zIndex","style","className","onVisibleChange"];function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?x(Object(r),!0).forEach((function(t){h.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var k={position:"fixed",right:0,bottom:0,width:"100%"},D={position:"sticky",bottom:0,height:0,width:"100%"},I=function(e){var t=e.children,r=e.scrollRef,n=e.onClick,o=e.scrollDelay,i=void 0===o?100:o,l=e.scrollOffset,b=void 0===l?100:l,m=e.margin,h=void 0===m?"0 18px 18px 0":m,x=e.zIndex,I=void 0===x?10:x,z=e.style,U=e.className,C=e.onVisibleChange,L=P.default(e,w),S=f.useBodyStoreTTag().t,T=j.useState(!1),N=O.default(T,2),A=N[0],M=N[1],_=d.useIsMounted(),H=function(){return(null==r?void 0:r.current)||document.documentElement},R=u.debounce((function(){var e=H(),t=e.scrollHeight-e.clientHeight>0,r=e.scrollTop>=b;M(t&&r)}),i);if(j.useEffect((function(){_&&"function"==typeof C&&C(A)}),[A]),j.useEffect((function(){var e=(null==r?void 0:r.current)||document;return e.addEventListener("resize",R),e.addEventListener("scroll",R),R(),function(){e.removeEventListener("resize",R),e.removeEventListener("scroll",R)}}),[]),!A)return null;var V=null!=r&&r.current?j.Fragment:s.Portal,F=null!=r&&r.current?D:k;return j.createElement(V,null,j.createElement("div",{style:B(B({},F),{},{zIndex:I})},j.createElement(c.Button,v.default({"button-padding":"xs","button-theme":"white","button-round":"full","button-blackhole":"scroll-button",type:"button","aria-label":S(y||(y=g.default(["Наверх"]))),"data-qaid":"ButtonPageUp","data-testid":"ButtonPageUp"},L,{className:q.default(E,U),style:B(B({},z),{},{margin:h}),onClick:function(e){"function"==typeof n&&n(e),H().scroll({top:0,behavior:"smooth"})}}),t||j.createElement(a.Icon,{"icon-as":p.SvgArrowUp,style:{width:24,height:24}}))))};I.displayName="ButtonPageUp",exports.ButtonPageUp=I,require("./style.production.css");
