{"version":3,"file":"Alert-Nx-j4xh1.cjs","sources":["../src/components/Alert/Alert.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useEffect, useRef, useState } from 'react';\nimport { AlertCircle, AlertTriangle, CheckCircle2, Info, X } from 'lucide-react';\nimport type { LucideIcon } from 'lucide-react';\nimport { withSx } from '../../utils/withSx';\nimport type { AlertColor, AlertProps } from './Alert.types';\n\nconst ICONS: Record<AlertColor, LucideIcon> = {\n  info: Info,\n  success: CheckCircle2,\n  warning: AlertTriangle,\n  danger: AlertCircle,\n};\n\nfunction DefaultIcon({ color }: { color: AlertColor }) {\n  const Icon = ICONS[color];\n  return <Icon size={16} className=\"alert-icon-glyph\" aria-hidden=\"true\" />;\n}\n\n/** Keep in sync with `alert-exit` in _alerts.scss. */\nconst EXIT_MS = 160;\n\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(\n  {\n    color = 'info',\n    solid = false,\n    title,\n    className,\n    style,\n    sx,\n    children,\n    icon,\n    action,\n    onDismiss,\n    dismissLabel = 'Dismiss',\n    exitAnimation = true,\n    ...rest\n  },\n  ref,\n) {\n  const [leaving, setLeaving] = useState(false);\n  const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n  useEffect(() => () => clearTimeout(timer.current), []);\n  const dismiss = () => {\n    let reduce = false;\n    try {\n      reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n    } catch {\n      /* no matchMedia — animate */\n    }\n    if (!exitAnimation || reduce || leaving) return onDismiss?.();\n    setLeaving(true);\n    timer.current = setTimeout(() => onDismiss?.(), EXIT_MS);\n  };\n\n  const showIcon = icon !== false;\n  const iconNode = icon && icon !== true ? icon : <DefaultIcon color={color} />;\n  const { className: classes, style: mergedStyle, styleTag } = withSx(\n    sx, style, 'alert', color, solid && 'solid', leaving && 'is-leaving', className,\n  );\n  const role = color === 'danger' ? 'alert' : 'status';\n\n  return (\n    <div ref={ref} role={role} className={classes} style={mergedStyle} {...rest}>\n      {styleTag}\n      {showIcon && <span className=\"alert-icon\" aria-hidden=\"true\">{iconNode}</span>}\n      <div className=\"alert-content\">\n        {title && <p className=\"alert-title\">{title}</p>}\n        {children && <p className=\"alert-body\">{children}</p>}\n      </div>\n      {action && <div className=\"alert-action\">{action}</div>}\n      {onDismiss && (\n        <button\n          type=\"button\"\n          className=\"alert-close\"\n          onClick={dismiss}\n          aria-label={dismissLabel}\n        >\n          <X size={14} aria-hidden=\"true\" />\n        </button>\n      )}\n    </div>\n  );\n});\n"],"names":["ICONS","Info","CheckCircle2","AlertTriangle","AlertCircle","DefaultIcon","color","Icon","EXIT_MS","Alert","forwardRef","solid","title","className","style","sx","children","icon","action","onDismiss","dismissLabel","exitAnimation","rest","ref","leaving","setLeaving","useState","timer","useRef","useEffect","dismiss","reduce","showIcon","iconNode","jsx","classes","mergedStyle","styleTag","withSx","role","jsxs","X"],"mappings":"uOAQMA,EAAwC,CAC5C,KAAMC,EAAAA,KACN,QAASC,EAAAA,YACT,QAASC,EAAAA,cACT,OAAQC,EAAAA,WACV,EAEA,SAASC,EAAY,CAAE,MAAAC,GAAgC,CACrD,MAAMC,EAAOP,EAAMM,CAAK,EACxB,aAAQC,EAAA,CAAK,KAAM,GAAI,UAAU,mBAAmB,cAAY,OAAO,CACzE,CAGA,MAAMC,EAAU,IAEHC,EAAQC,EAAAA,WAAuC,SAC1D,CACE,MAAAJ,EAAQ,OACR,MAAAK,EAAQ,GACR,MAAAC,EACA,UAAAC,EACA,MAAAC,EACA,GAAAC,EACA,SAAAC,EACA,KAAAC,EACA,OAAAC,EACA,UAAAC,EACA,aAAAC,EAAe,UACf,cAAAC,EAAgB,GAChB,GAAGC,CACL,EACAC,EACA,CACA,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAAA,SAAS,EAAK,EACtCC,EAAQC,EAAAA,OAAkD,MAAS,EACzEC,EAAAA,UAAU,IAAM,IAAM,aAAaF,EAAM,OAAO,EAAG,CAAA,CAAE,EACrD,MAAMG,EAAU,IAAM,CACpB,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