{"version":3,"file":"toastService.mjs","names":[],"sources":["../../../../package/common/toast/toastService.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ToastOptions } from './toast.types';\n\ntype ShowToastFn = (content: ReactNode, options?: ToastOptions) => void;\n\n// A list, so that when the host registered last unmounts, the one before it takes over again.\nconst handlers: ShowToastFn[] = [];\n\nexport function _registerToastHandler(fn: ShowToastFn): void {\n  if (handlers.length > 0) {\n    console.warn(\n      '[Toast] More than one outermost AhroweProvider is mounted, and toasts show in only one of them. Keep one at the root and nest any other inside it.',\n    );\n  }\n  handlers.push(fn);\n}\n\nexport function _unregisterToastHandler(fn: ShowToastFn): void {\n  const index = handlers.indexOf(fn);\n  if (index !== -1) handlers.splice(index, 1);\n}\n\nexport function showToast(content: ReactNode, options?: ToastOptions): void {\n  const handler = handlers[handlers.length - 1];\n  if (!handler) {\n    console.error('[Toast] No AhroweProvider found. Wrap your app in <AhroweProvider>.');\n    return;\n  }\n  handler(content, options);\n}\n"],"mappings":"aAMA,IAAM,EAA0B,CAAC,EAEjC,SAAgB,EAAsB,EAAuB,CACvD,EAAS,OAAS,GACpB,QAAQ,KACN,oJACF,EAEF,EAAS,KAAK,CAAE,CAClB,CAEA,SAAgB,EAAwB,EAAuB,CAC7D,IAAM,EAAQ,EAAS,QAAQ,CAAE,EAC7B,IAAU,IAAI,EAAS,OAAO,EAAO,CAAC,CAC5C,CAEA,SAAgB,EAAU,EAAoB,EAA8B,CAC1E,IAAM,EAAU,EAAS,EAAS,OAAS,GAC3C,GAAI,CAAC,EAAS,CACZ,QAAQ,MAAM,qEAAqE,EACnF,MACF,CACA,EAAQ,EAAS,CAAO,CAC1B"}