();\n\nexport function useMaxAllowedInstancesGuard(name: string, error: string, maxCount = 1): void {\n React.useEffect(() => {\n const count = counts.get(name) || 0;\n if (count == maxCount) {\n return errorThrower.throw(error);\n }\n counts.set(name, count + 1);\n\n return () => {\n counts.set(name, (counts.get(name) || 1) - 1);\n };\n }, []);\n}\n\nexport function withMaxAllowedInstancesGuard(\n WrappedComponent: P,\n name: string,\n error: string,\n): P & { displayName: string } {\n // @ts-expect-error - simplified types to preserve generics in P\n const displayName = WrappedComponent.displayName || WrappedComponent.name || name || 'Component';\n const Hoc = (props: P) => {\n useMaxAllowedInstancesGuard(name, error);\n // @ts-expect-error - simplified types to preserve generics in P\n return ;\n };\n Hoc.displayName = `withMaxAllowedInstancesGuard(${displayName})`;\n // @ts-expect-error - simplified types to preserve generics in P\n return Hoc;\n}\n","import type React from 'react';\nimport { useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nexport type UseCustomElementPortalParams = {\n component: React.ReactNode;\n id: number;\n};\n\nexport type UseCustomElementPortalReturn = {\n portal: () => React.JSX.Element;\n mount: (node: Element) => void;\n unmount: () => void;\n id: number;\n};\n\n// This function takes a component as prop, and returns functions that mount and unmount\n// the given component into a given node\nexport const useCustomElementPortal = (elements: UseCustomElementPortalParams[]) => {\n const [nodeMap, setNodeMap] = useState