"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"),d=require("@prom-ui/core/BodyProvider"),s=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),g=m(n),q=b(o),N=b(i),C=b(u),E="_5xFyd",k="PY-Co _1fL6b",O="u2XoF _1fL6b",P="AZbdb",w="zw-fa",I="z7X7-",j="PVtmJ",z=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=d.useBodyStoreTTag().t,E=n.useRef(null),j=n.useState({prev:!1,next:!1}),z=C.default(j,2),L=z[0],A=z[1],R=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})}},F=function(e){if(t.current){var r=t.current,n=r.scrollLeft,o=r.clientWidth*e;requestAnimationFrame((function(){var e=n+o;R(e),t.current&&t.current.scrollTo({left:e,behavior:"smooth"})}))}},S=function(){clearTimeout(E.current||0),E.current=setTimeout(R,100)};return n.useEffect((function(){return t.current&&i&&(requestAnimationFrame((function(){R()})),t.current.addEventListener("scroll",S)),function(){t.current&&i&&t.current.removeEventListener("scroll",S)}}),[i,h]),i&&(L.prev||L.next)?g.default.createElement(g.default.Fragment,null,g.default.createElement("div",{className:q.default(k,x.default({},P,!L.prev)),style:{zIndex:m}},g.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?w:void 0,onClick:function(e){"function"==typeof b&&b(e),F(-1)},disabled:!L.prev,title:y(v||(v=N.default(["Назад"])))},g.default.createElement(a.Icon,{className:I,"icon-events":"none","icon-as":s.SvgLeft}))),g.default.createElement("div",{className:q.default(O,x.default({},P,!L.next)),style:{zIndex:m}},g.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?w:void 0,onClick:function(e){"function"==typeof u&&u(e),F(1)},disabled:!L.next,title:y(p||(p=N.default(["Далее"])))},g.default.createElement(a.Icon,{className:I,"icon-events":"none","icon-as":f.SvgRight})))):null};z.displayName="ScrollControlsButton";var L=["children","className","hideOnDisabled","isActive","onClickNext","onClickPrev","showOnHover","zIndex"],A=g.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,d=e.onClickPrev,s=e.showOnHover,f=void 0!==s&&s,b=e.zIndex,m=y.default(e,L),v=l.useForwardRef(t,null);return g.createElement("div",h.default({className:q.default(E,n,x.default({},j,f))},m),g.cloneElement(r,{ref:v}),g.createElement(z,{scrollRef:v,hideOnDisabled:i,isActive:c,onClickNext:a,onClickPrev:d,zIndex:b},r))}));A.displayName="ScrollControls",exports.ScrollControls=A,require("./style.production.v2.css");
