"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/objectWithoutProperties"),n=require("react"),o=require("clsx"),l=require("@prom-ui/core/useForwardRef"),i=require("@babel/runtime/helpers/taggedTemplateLiteral"),u=require("@babel/runtime/helpers/slicedToArray"),c=require("@prom-ui/core/Button"),a=require("@prom-ui/core/Icon"),s=require("@prom-ui/core/BodyProvider"),d=require("@prom-ui/icons/Left"),f=require("@prom-ui/icons/Right");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 v,p,h=b(e),x=b(t),y=b(r),q=m(n),N=b(o),g=b(i),O=b(u),C="mOlOq",E="_3uXYG _8-zJW",k="L0VTc _8-zJW",w="_8BNAe",z="_1GCww",I="lzBzL",P="StbVV",j=function(e){var t=e.scrollRef,r=e.hideOnDisabled,o=void 0!==r&&r,l=e.isActive,i=void 0===l||l,u=e.onClickNext,b=e.onClickPrev,m=e.zIndex,h=e.children,y=s.useBodyStoreTTag().t,C=n.useRef(null),P=n.useState({prev:!1,next:!1}),j=O.default(P,2),L=j[0],A=j[1],B=function(e){if(t.current){var r=t.current,n=r.scrollLeft,o=r.scrollWidth,l=r.clientWidth,i=(Number.isInteger(e)?e:n)||0;A({prev:i>1,next:i<o-l-1})}},R=function(e){if(t.current){var r=t.current,n=r.scrollLeft,o=r.clientWidth*e;requestAnimationFrame((function(){var e=n+o;B(e),t.current&&t.current.scrollTo({left:e,behavior:"smooth"})}))}},S=function(){clearTimeout(C.current||0),C.current=setTimeout(B,100)};return n.useEffect((function(){return t.current&&i&&(requestAnimationFrame((function(){B()})),t.current.addEventListener("scroll",S)),function(){t.current&&i&&t.current.removeEventListener("scroll",S)}}),[i,h]),i&&(L.prev||L.next)?q.default.createElement(q.default.Fragment,null,q.default.createElement("div",{className:N.default(E,x.default({},w,!L.prev)),style:{zIndex:m}},q.default.createElement(c.Button,{"button-theme":"white","button-padding":"none","button-round":"full","button-width":"1-1","button-height":"1-1","button-blackhole":"scroll-button",type:"button",className:o?z:void 0,onClick:function(e){"function"==typeof b&&b(e),R(-1)},disabled:!L.prev,title:y(v||(v=g.default(["Назад"])))},q.default.createElement(a.Icon,{className:I,"icon-events":"none","icon-as":d.SvgLeft}))),q.default.createElement("div",{className:N.default(k,x.default({},w,!L.next)),style:{zIndex:m}},q.default.createElement(c.Button,{"button-theme":"white","button-padding":"none","button-round":"full","button-width":"1-1","button-height":"1-1","button-blackhole":"scroll-button",type:"button",className:o?z:void 0,onClick:function(e){"function"==typeof u&&u(e),R(1)},disabled:!L.next,title:y(p||(p=g.default(["Далее"])))},q.default.createElement(a.Icon,{className:I,"icon-events":"none","icon-as":f.SvgRight})))):null};j.displayName="ScrollControlsButton";var L=["children","className","hideOnDisabled","isActive","onClickNext","onClickPrev","showOnHover","zIndex"],A=q.forwardRef((function(e,t){var r=e.children,n=e.className,o=e.hideOnDisabled,i=void 0===o||o,u=e.isActive,c=void 0===u||u,a=e.onClickNext,s=e.onClickPrev,d=e.showOnHover,f=void 0!==d&&d,b=e.zIndex,m=y.default(e,L),v=l.useForwardRef(t,null);return q.createElement("div",h.default({className:N.default(C,n,x.default({},P,f))},m),q.cloneElement(r,{ref:v}),q.createElement(j,{scrollRef:v,hideOnDisabled:i,isActive:c,onClickNext:a,onClickPrev:s,zIndex:b},r))}));A.displayName="ScrollControls",exports.ScrollControls=A,require("./style.production.css");
