{"version":3,"file":"Badge-3E3sq8P8.cjs","sources":["../src/components/Badge/Badge.tsx"],"sourcesContent":["'use client';\nimport { forwardRef } from 'react';\nimport type { HTMLAttributes, ReactNode } from 'react';\nimport { cx } from '../../utils/cx';\nimport { withSx } from '../../utils/withSx';\nimport type { SxProp } from '../Layout/sx';\n\nexport type BadgeColor = 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'neutral';\nexport type BadgePlacement = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';\n\nexport interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {\n  /** Numeric count shown in the indicator. */\n  count?: number;\n  /** Render a small dot instead of a number. */\n  dot?: boolean;\n  /** Cap displayed count; values above show `{max}+`. Default 99. */\n  max?: number;\n  /** Show the indicator even when count is 0. Default false. */\n  showZero?: boolean;\n  /** Semantic color. Default `'danger'`. */\n  color?: BadgeColor;\n  /** Corner the indicator anchors to (ignored when standalone). Default `'top-right'`. */\n  placement?: BadgePlacement;\n  /** Render the indicator inline with no anchored child. */\n  standalone?: boolean;\n  /**\n   * One-off CSS, same as `Box`'s `sx`: each value may be a scalar or a\n   * responsive breakpoint map (`{ base, sm, md, lg, xl }`). Scalar-only sx\n   * merges into inline style; responsive sx injects a scoped class.\n   */\n  sx?: SxProp;\n  children?: ReactNode;\n}\n\nexport const Badge = forwardRef<HTMLSpanElement, BadgeProps>(function Badge(\n  {\n    count,\n    dot = false,\n    max = 99,\n    showZero = false,\n    color = 'danger',\n    placement = 'top-right',\n    standalone = false,\n    children,\n    className,\n    style,\n    sx,\n    ...rest\n  },\n  ref,\n) {\n  const hasCount = typeof count === 'number';\n  const display = hasCount && (count as number) > max ? `${max}+` : count;\n  // Nothing to show (no dot, no count, or a zero count without showZero) draws no indicator\n  const hidden = !dot && (!hasCount || (count === 0 && !showZero));\n\n  const indicator = hidden ? null : (\n    <span\n      className={cx(\n        'cny-badge-indicator',\n        `cny-badge-${color}`,\n        dot && 'cny-badge-dot',\n        !standalone && `cny-badge-${placement}`,\n      )}\n    >\n      {dot ? null : display}\n    </span>\n  );\n\n  if (standalone) {\n    const { className: classes, style: mergedStyle, styleTag } = withSx(\n      sx, style, 'cny-badge-standalone', className,\n    );\n    return (\n      <span ref={ref} className={classes} style={mergedStyle} {...rest}>\n        {styleTag}\n        {indicator}\n      </span>\n    );\n  }\n\n  const { className: classes, style: mergedStyle, styleTag } = withSx(\n    sx, style, 'cny-badge-anchor', className,\n  );\n  return (\n    <span ref={ref} className={classes} style={mergedStyle} {...rest}>\n      {styleTag}\n      {children}\n      {indicator}\n    </span>\n  );\n});\n"],"names":["Badge","forwardRef","count","dot","max","showZero","color","placement","standalone","children","className","style","sx","rest","ref","hasCount","display","indicator","jsx","cx","classes","mergedStyle","styleTag","withSx","jsxs"],"mappings":"qHAkCaA,EAAQC,EAAAA,WAAwC,SAC3D,CACE,MAAAC,EACA,IAAAC,EAAM,GACN,IAAAC,EAAM,GACN,SAAAC,EAAW,GACX,MAAAC,EAAQ,SACR,UAAAC,EAAY,YACZ,WAAAC,EAAa,GACb,SAAAC,EACA,UAAAC,EACA,MAAAC,EACA,GAAAC,EACA,GAAGC,CACL,EACAC,EACA,CACA,MAAMC,EAAW,OAAOb,GAAU,SAC5Bc,EAAUD,GAAab,EAAmBE,EAAM,GAAGA,CAAG,IAAMF,EAI5De,EAFS,CAACd,IAAQ,CAACY,GAAab,IAAU,GAAK,CAACG,GAE3B,KACzBa,EAAAA,IAAC,OAAA,CACC,UAAWC,EAAAA,GACT,sBACA,aAAab,CAAK,GAClBH,GAAO,gBACP,CAACK,GAAc,aAAaD,CAAS,EAAA,EAGtC,WAAM,KAAOS,CAAA,CAAA,EAIlB,GAAIR,EAAY,CACd,KAAM,CAAE,UAAWY,EAAS,MAAOC,EAAa,SAAAC,GAAaC,EAAAA,OAC3DX,EAAID,EAAO,uBAAwBD,CAAA,EAErC,OACEc,OAAC,QAAK,IAAAV,EAAU,UAAWM,EAAS,MAAOC,EAAc,GAAGR,EACzD,SAAA,CAAAS,EACAL,CAAA,EACH,CAEJ,CAEA,KAAM,CAAE,UAAWG,EAAS,MAAOC,EAAa,SAAAC,GAAaC,EAAAA,OAC3DX,EAAID,EAAO,mBAAoBD,CAAA,EAEjC,OACEc,OAAC,QAAK,IAAAV,EAAU,UAAWM,EAAS,MAAOC,EAAc,GAAGR,EACzD,SAAA,CAAAS,EACAb,EACAQ,CAAA,EACH,CAEJ,CAAC"}