import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useEffect,useRef,useState}from"react";import{useComponentSize}from"../../hooks/useComponentSize";import{useRefs}from"../../hooks/useRefs";import{useResizeObserved}from"../../hooks/useResizeObserved";import{getPagesArray}from"./helpers";import{usePaginationKeys}from"./usePaginationKeys";export var itemSizeMap={l:48,m:40,s:32,xs:24};var getElementSize=function(a){var b;return null!==(b=null===a||void 0===a?void 0:a.offsetWidth)&&void 0!==b?b:0};export var usePaginationItems=function(a){var b=a.visibleCount,c=a.value,d=a.items,e=a.showFirstPage,f=a.showLastPage,g=a.containerEventListener,h=a.size,i=a.hotKeys,j=useState([]),k=_slicedToArray(j,2),l=k[0],m=k[1],n=useState(7),o=_slicedToArray(n,2),p=o[0],q=o[1],r=useRef(null),s=useRefs(4),t=useResizeObserved(s,getElementSize),u=_slicedToArray(t,4),v=u[0],w=u[1],x=u[2],y=u[3];usePaginationKeys({containerEventListener:g,hotKeys:i,prevButtonRef:s[1],nextButtonRef:s[2]});var z=useComponentSize(r),A=z.width;return useEffect(function(){q(Math.max(Math.floor((A-v-w-x-y)/(itemSizeMap[h]+2)),3+(e?2:0)+(f?2:0)))},[l,v,w,x,y,A,h]),useEffect(function(){m(getPagesArray({currentPage:c,totalPages:d,visibleCount:null!==b&&void 0!==b?b:p,showFirstPage:e,showLastPage:f}))},[b,e,f,c,d,p]),{buttonRefs:s,wrapperRef:r,pages:l}};
//# sourceMappingURL=usePaginationItems.js.map