{"version":3,"sources":["jsdelivr-header.js","/npm/src/useAfterFirstTruthy.ts","/npm/src/LazyMount.tsx"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,kOCJwB,oBAAoB,G,IACpC,EAAe,e,OAEjB,IAAQ,EAAQ,UAClB,EAAQ,SAAU,KAGhB,EAAQ,O,CCCd,IAAM,UAAY,SAAC,G,IAAE,aAAU,YAAA,gBAAiB,a,OAC5B,oBAAoB,GAMlC,EAEA,6BAAC,eAAD,CAAU,SAAU,GACjB,GAKA,0DAAG,GAXD,I","file":"/npm/react-lazy-mount@1.3.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/react-lazy-mount@1.3.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { useRef } from 'react';\n\nexport default function useAfterFirstTruthy(val: boolean) {\n  const mounted: any = useRef();\n\n  if (val && !mounted.current) {\n    mounted.current = true;\n  }\n\n  if (mounted.current) return true;\n\n  return false;\n}\n","import React, { Suspense, SuspenseProps } from 'react';\nimport useAfterFirstTruthy from './useAfterFirstTruthy';\n\nexport type LazyMountProps = {\n  trigger?: boolean;\n  children?: SuspenseProps['children'];\n  /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */\n  fallback?: SuspenseProps['fallback'];\n}\n\nconst LazyMount = ({ children, trigger = false, fallback }: LazyMountProps) => {\n  const isMounted = useAfterFirstTruthy(trigger);\n\n  if (!isMounted) {\n    return null;\n  }\n\n  if (fallback) {\n    return (\n      <Suspense fallback={fallback} >\n        {children}\n      </Suspense>\n    )\n  }\n\n  return <>{children}</>;\n};\n\nexport default LazyMount;\n"]}