import _objectWithoutProperties from"@babel/runtime/helpers/esm/objectWithoutProperties";import _defineProperty from"@babel/runtime/helpers/esm/defineProperty";import _extends from"@babel/runtime/helpers/esm/extends";import*as React from"react";import PropTypes from"prop-types";import clsx from"clsx";import{unstable_composeClasses as composeClasses}from"@material-ui/unstyled";import useThemeProps from"../styles/useThemeProps";import paginationItemClasses,{getPaginationItemUtilityClass}from"./paginationItemClasses";import{useTheme}from"../styles";import{alpha}from"../styles/colorManipulator";import ButtonBase from"../ButtonBase";import capitalize from"../utils/capitalize";import FirstPageIcon from"../internal/svg-icons/FirstPage";import LastPageIcon from"../internal/svg-icons/LastPage";import NavigateBeforeIcon from"../internal/svg-icons/NavigateBefore";import NavigateNextIcon from"../internal/svg-icons/NavigateNext";import experimentalStyled from"../styles/experimentalStyled";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var rootOverridesResolver=function(e,t){e=e.styleProps;return _extends({},t.root,t[e.variant],t["size".concat(capitalize(e.size))],"text"===e.variant&&t["text".concat(capitalize(e.color))],"outlined"===e.variant&&t["outlined".concat(capitalize(e.color))],"rounded"===e.shape&&t.rounded,"page"===e.type&&t.page,("start-ellipsis"===e.type||"end-ellipsis"===e.type)&&t.ellipsis,("previous"===e.type||"next"===e.type)&&t.previousNext,("first"===e.type||"last"===e.type)&&t.firstLast)},useUtilityClasses=function(e){var t=e.classes,o=e.color,a=e.disabled,i=e.selected,r=e.size,s=e.shape,n=e.type,e=e.variant,n={root:["root","size".concat(capitalize(r)),e,s,"standard"!==o&&"".concat(e).concat(capitalize(o)),a&&"disabled",i&&"selected",{page:"page",first:"firstLast",last:"firstLast","start-ellipsis":"ellipsis","end-ellipsis":"ellipsis",previous:"previousNext",next:"previousNext"}[n]],icon:["icon"]};return composeClasses(n,getPaginationItemUtilityClass,t)},PaginationItemEllipsis=experimentalStyled("div",{},{name:"MuiPaginationItem",slot:"Root",overridesResolver:rootOverridesResolver})(function(e){var t=e.theme,e=e.styleProps;return _extends({},t.typography.body2,_defineProperty({borderRadius:16,textAlign:"center",boxSizing:"border-box",minWidth:32,padding:"0 6px",margin:"0 3px",color:t.palette.text.primary,height:"auto"},"&.".concat(paginationItemClasses.disabled),{opacity:t.palette.action.disabledOpacity}),"small"===e.size&&{minWidth:26,borderRadius:13,margin:"0 1px",padding:"0 4px"},"large"===e.size&&{minWidth:40,borderRadius:20,padding:"0 10px",fontSize:t.typography.pxToRem(15)})}),PaginationItemPage=experimentalStyled(ButtonBase,{},{name:"MuiPaginationItem",slot:"Root",overridesResolver:rootOverridesResolver})(function(e){var t=e.theme,o=e.styleProps;return _extends({},t.typography.body2,(e={borderRadius:16,textAlign:"center",boxSizing:"border-box",minWidth:32,height:32,padding:"0 6px",margin:"0 3px",color:t.palette.text.primary},_defineProperty(e,"&.".concat(paginationItemClasses.focusVisible),{backgroundColor:t.palette.action.focus}),_defineProperty(e,"&.".concat(paginationItemClasses.disabled),{opacity:t.palette.action.disabledOpacity}),e),"page"===o.type&&_defineProperty({transition:t.transitions.create(["color","background-color"],{duration:t.transitions.duration.short}),"&:hover":{backgroundColor:t.palette.action.hover,"@media (hover: none)":{backgroundColor:"transparent"}}},"&.".concat(paginationItemClasses.selected),(e={backgroundColor:t.palette.action.selected,"&:hover":{backgroundColor:alpha(t.palette.action.selected,t.palette.action.selectedOpacity+t.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:t.palette.action.selected}}},_defineProperty(e,"&.".concat(paginationItemClasses.focusVisible),{backgroundColor:alpha(t.palette.action.selected,t.palette.action.selectedOpacity+t.palette.action.focusOpacity)}),_defineProperty(e,"&.".concat(paginationItemClasses.disabled),{opacity:1,color:t.palette.action.disabled,backgroundColor:t.palette.action.selected}),e)),"small"===o.size&&{minWidth:26,height:26,borderRadius:13,margin:"0 1px",padding:"0 4px"},"large"===o.size&&{minWidth:40,height:40,borderRadius:20,padding:"0 10px",fontSize:t.typography.pxToRem(15)},"rounded"===o.shape&&{borderRadius:t.shape.borderRadius})},function(e){var t=e.theme,e=e.styleProps;return _extends({},"text"===e.variant&&_defineProperty({},"&.".concat(paginationItemClasses.selected),_extends({},"standard"!==e.color&&_defineProperty({color:t.palette[e.color].contrastText,backgroundColor:t.palette[e.color].main,"&:hover":{backgroundColor:t.palette[e.color].dark,"@media (hover: none)":{backgroundColor:t.palette[e.color].main}}},"&.".concat(paginationItemClasses.focusVisible),{backgroundColor:t.palette[e.color].dark}),_defineProperty({},"&.".concat(paginationItemClasses.disabled),{color:t.palette.action.disabled}))),"outlined"===e.variant&&_defineProperty({border:"1px solid ".concat("light"===t.palette.mode?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)")},"&.".concat(paginationItemClasses.selected),_extends({},"standard"!==e.color&&_defineProperty({color:t.palette[e.color].main,border:"1px solid ".concat(alpha(t.palette[e.color].main,.5)),backgroundColor:alpha(t.palette[e.color].main,t.palette.action.activatedOpacity),"&:hover":{backgroundColor:alpha(t.palette[e.color].main,t.palette.action.activatedOpacity+t.palette.action.focusOpacity),"@media (hover: none)":{backgroundColor:"transparent"}}},"&.".concat(paginationItemClasses.focusVisible),{backgroundColor:alpha(t.palette[e.color].main,t.palette.action.activatedOpacity+t.palette.action.focusOpacity)}),_defineProperty({},"&.".concat(paginationItemClasses.disabled),{borderColor:t.palette.action.disabledBackground,color:t.palette.action.disabled}))))}),PaginationItemPageIcon=experimentalStyled("div",{},{name:"MuiPaginationItem",slot:"Icon",overridesResolver:function(e,t){return t.icon}})(function(e){var t=e.theme,e=e.styleProps;return _extends({fontSize:t.typography.pxToRem(20),margin:"0 -8px"},"small"===e.size&&{fontSize:t.typography.pxToRem(18)},"large"===e.size&&{fontSize:t.typography.pxToRem(22)})}),PaginationItem=React.forwardRef(function(e,t){var o=useThemeProps({props:e,name:"MuiPaginationItem"}),a=o.className,i=o.color,r=void 0===i?"standard":i,s=o.component,n=o.disabled,p=void 0!==n&&n,l=o.page,c=o.selected,d=void 0!==c&&c,m=o.shape,e=void 0===m?"circular":m,i=o.size,n=void 0===i?"medium":i,c=o.type,m=void 0===c?"page":c,i=o.variant,c=void 0===i?"text":i,i=_objectWithoutProperties(o,["className","color","component","disabled","page","selected","shape","size","type","variant"]),e=_extends({},o,{color:r,disabled:p,selected:d,shape:e,size:n,type:m,variant:c}),n=useTheme(),c=useUtilityClasses(e),n=("rtl"===n.direction?{previous:NavigateNextIcon,next:NavigateBeforeIcon,last:FirstPageIcon,first:LastPageIcon}:{previous:NavigateBeforeIcon,next:NavigateNextIcon,first:FirstPageIcon,last:LastPageIcon})[m];return"start-ellipsis"===m||"end-ellipsis"===m?_jsx(PaginationItemEllipsis,_extends({ref:t,styleProps:e,className:clsx(c.root,a)},i,{children:"…"})):_jsxs(PaginationItemPage,_extends({ref:t,styleProps:e,component:s,disabled:p,className:clsx(c.root,a)},i,{children:["page"===m&&l,n?_jsx(PaginationItemPageIcon,{as:n,styleProps:e,className:c.icon}):null]}))});"production"!==process.env.NODE_ENV&&(PaginationItem.propTypes={children:PropTypes.node,classes:PropTypes.object,className:PropTypes.string,color:PropTypes.oneOfType([PropTypes.oneOf(["primary","secondary","standard"]),PropTypes.string]),component:PropTypes.elementType,disabled:PropTypes.bool,page:PropTypes.node,selected:PropTypes.bool,shape:PropTypes.oneOf(["circular","rounded"]),size:PropTypes.oneOfType([PropTypes.oneOf(["large","medium","small"]),PropTypes.string]),sx:PropTypes.object,type:PropTypes.oneOf(["end-ellipsis","first","last","next","page","previous","start-ellipsis"]),variant:PropTypes.oneOfType([PropTypes.oneOf(["outlined","text"]),PropTypes.string])});export default PaginationItem;