import _objectWithoutPropertiesLoose from"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";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 experimentalStyled from"../styles/experimentalStyled";import useThemeProps from"../styles/useThemeProps";import{darken,lighten}from"../styles/colorManipulator";import capitalize from"../utils/capitalize";import Paper from"../Paper";import alertClasses,{getAlertUtilityClass}from"./alertClasses";import IconButton from"../IconButton";import SuccessOutlinedIcon from"../internal/svg-icons/SuccessOutlined";import ReportProblemOutlinedIcon from"../internal/svg-icons/ReportProblemOutlined";import ErrorOutlineIcon from"../internal/svg-icons/ErrorOutline";import InfoOutlinedIcon from"../internal/svg-icons/InfoOutlined";import CloseIcon from"../internal/svg-icons/Close";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";const useUtilityClasses=e=>{var{variant:o,color:r,severity:t,classes:e}=e,o={root:["root",`${o}${capitalize(r||t)}`,`${o}`],icon:["icon"],message:["message"],action:["action"]};return composeClasses(o,getAlertUtilityClass,e)},AlertRoot=experimentalStyled(Paper,{},{name:"MuiAlert",slot:"Root",overridesResolver:(e,o)=>{var{styleProps:e}=e;return _extends({},o.root,o[e.variant],o[`${e.variant}${capitalize(e.color||e.severity)}`])}})(({theme:e,styleProps:o})=>{const r="light"===e.palette.mode?darken:lighten,t="light"===e.palette.mode?lighten:darken;var s=o.color||o.severity;return _extends({},e.typography.body2,{borderRadius:e.shape.borderRadius,backgroundColor:"transparent",display:"flex",padding:"6px 16px"},s&&"standard"===o.variant&&{color:r(e.palette[s].main,.6),backgroundColor:t(e.palette[s].main,.9),[`& .${alertClasses.icon}`]:{color:e.palette[s].main}},s&&"outlined"===o.variant&&{color:r(e.palette[s].main,.6),border:`1px solid ${e.palette[s].main}`,[`& .${alertClasses.icon}`]:{color:e.palette[s].main}},s&&"filled"===o.variant&&{color:"#fff",fontWeight:e.typography.fontWeightMedium,backgroundColor:e.palette[s].main})}),AlertIcon=experimentalStyled("div",{},{name:"MuiAlert",slot:"Icon",overridesResolver:(e,o)=>o.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),AlertMessage=experimentalStyled("div",{},{name:"MuiAlert",slot:"Message",overridesResolver:(e,o)=>o.message})({padding:"8px 0"}),AlertAction=experimentalStyled("div",{},{name:"MuiAlert",slot:"Action",overridesResolver:(e,o)=>o.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),defaultIconMapping={success:_jsx(SuccessOutlinedIcon,{fontSize:"inherit"}),warning:_jsx(ReportProblemOutlinedIcon,{fontSize:"inherit"}),error:_jsx(ErrorOutlineIcon,{fontSize:"inherit"}),info:_jsx(InfoOutlinedIcon,{fontSize:"inherit"})};var _ref=_jsx(CloseIcon,{fontSize:"small"});const Alert=React.forwardRef(function(e,o){var r=useThemeProps({props:e,name:"MuiAlert"}),{action:t,children:s,className:n,closeText:i="Close",color:l,icon:a,iconMapping:p=defaultIconMapping,onClose:c,role:m="alert",severity:d="success",variant:u="standard"}=r,e=_objectWithoutPropertiesLoose(r,["action","children","className","closeText","color","icon","iconMapping","onClose","role","severity","variant"]),u=_extends({},r,{variant:u,color:l,severity:d}),l=useUtilityClasses(u);return _jsxs(AlertRoot,_extends({role:m,square:!0,elevation:0,styleProps:u,className:clsx(l.root,n),ref:o},e,{children:[!1!==a?_jsx(AlertIcon,{styleProps:u,className:l.icon,children:a||p[d]||defaultIconMapping[d]}):null,_jsx(AlertMessage,{styleProps:u,className:l.message,children:s}),null!=t?_jsx(AlertAction,{className:l.action,children:t}):null,null==t&&c?_jsx(AlertAction,{styleProps:u,className:l.action,children:_jsx(IconButton,{size:"small","aria-label":i,title:i,color:"inherit",onClick:c,children:_ref})}):null]}))});"production"!==process.env.NODE_ENV&&(Alert.propTypes={action:PropTypes.node,children:PropTypes.node,classes:PropTypes.object,className:PropTypes.string,closeText:PropTypes.string,color:PropTypes.oneOf(["error","info","success","warning"]),icon:PropTypes.node,iconMapping:PropTypes.shape({error:PropTypes.node,info:PropTypes.node,success:PropTypes.node,warning:PropTypes.node}),onClose:PropTypes.func,role:PropTypes.string,severity:PropTypes.oneOf(["error","info","success","warning"]),sx:PropTypes.object,variant:PropTypes.oneOfType([PropTypes.oneOf(["filled","outlined","standard"]),PropTypes.string])});export default Alert;