{
  "version": 3,
  "sources": ["../../src/notice/index.tsx"],
  "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { RawHTML, useEffect, renderToString } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { VisuallyHidden } from '../visually-hidden';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n */\nfunction useSpokenMessage(message, politeness) {\n  const spokenMessage = typeof message === 'string' ? message : renderToString(message);\n  useEffect(() => {\n    if (spokenMessage) {\n      speak(spokenMessage, politeness);\n    }\n  }, [spokenMessage, politeness]);\n}\nfunction getDefaultPoliteness(status) {\n  switch (status) {\n    case 'success':\n    case 'warning':\n    case 'info':\n      return 'polite';\n    // The default will also catch the 'error' status.\n    default:\n      return 'assertive';\n  }\n}\nfunction getStatusLabel(status) {\n  switch (status) {\n    case 'warning':\n      return __('Warning notice');\n    case 'info':\n      return __('Information notice');\n    case 'error':\n      return __('Error notice');\n    // The default will also catch the 'success' status.\n    default:\n      return __('Notice');\n  }\n}\n\n/**\n * `Notice` is a component used to communicate feedback to the user.\n *\n *```jsx\n * import { Notice } from `@wordpress/components`;\n *\n * const MyNotice = () => (\n *   <Notice status=\"error\">An unknown error occurred.</Notice>\n * );\n * ```\n */\nfunction Notice({\n  className,\n  status = 'info',\n  children,\n  spokenMessage = children,\n  onRemove = noop,\n  isDismissible = true,\n  actions = [],\n  politeness = getDefaultPoliteness(status),\n  __unstableHTML,\n  // onDismiss is a callback executed when the notice is dismissed.\n  // It is distinct from onRemove, which _looks_ like a callback but is\n  // actually the function to call to remove the notice from the UI.\n  onDismiss = noop\n}) {\n  useSpokenMessage(spokenMessage, politeness);\n\n  // Dismissibility is not a wrapper modifier; target `.components-notice__dismiss`\n  // or `.components-notice:has(.components-notice__dismiss)` from outside CSS.\n  const classes = clsx(className, 'components-notice', 'is-' + status);\n  if (__unstableHTML && typeof children === 'string') {\n    children = /*#__PURE__*/_jsx(RawHTML, {\n      children: children\n    });\n  }\n  const onDismissNotice = () => {\n    onDismiss();\n    onRemove();\n  };\n  return /*#__PURE__*/_jsxs(\"div\", {\n    className: classes,\n    children: [/*#__PURE__*/_jsx(VisuallyHidden, {\n      children: getStatusLabel(status)\n    }), /*#__PURE__*/_jsx(\"div\", {\n      className: \"components-notice__content\",\n      children: children\n    }), actions.length > 0 && /*#__PURE__*/_jsx(\"div\", {\n      className: \"components-notice__actions\",\n      children: actions.map(({\n        className: buttonCustomClasses,\n        label,\n        isPrimary,\n        variant,\n        noDefaultClasses = false,\n        onClick,\n        url,\n        disabled\n      }, index) => {\n        let computedVariant = variant;\n        if (variant !== 'primary' && !noDefaultClasses) {\n          computedVariant = !url ? 'secondary' : 'link';\n        }\n        if (typeof computedVariant === 'undefined' && isPrimary) {\n          computedVariant = 'primary';\n        }\n        return /*#__PURE__*/_jsx(Button, {\n          size: \"compact\",\n          href: url,\n          variant: computedVariant,\n          onClick: onClick,\n          disabled: disabled,\n          accessibleWhenDisabled: true,\n          className: clsx('components-notice__action', buttonCustomClasses),\n          children: label\n        }, index);\n      })\n    }), isDismissible && /*#__PURE__*/_jsx(Button, {\n      size: \"small\",\n      className: \"components-notice__dismiss\",\n      icon: closeSmall,\n      label: __('Close'),\n      onClick: onDismissNotice\n    })]\n  });\n}\nexport default Notice;"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAmB;AACnB,qBAAmD;AACnD,kBAAsB;AACtB,mBAA2B;AAK3B,oBAAmB;AACnB,6BAA+B;AAC/B,yBAA2C;AAC3C,IAAM,OAAO,MAAM;AAAC;AAMpB,SAAS,iBAAiB,SAAS,YAAY;AAC7C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