{"version":3,"file":"use-object-url.cjs","names":[],"sources":["../../src/hooks/use-object-url.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\n/**\n * Create an object URL for a `Blob` (or `File`) and revoke it automatically on\n * unmount or whenever the blob changes. Returns `null` for nullish input.\n *\n * @param blob - the blob to expose as an object URL, or `null`/`undefined`.\n * @returns The object URL string, or `null` when there is no blob.\n */\nexport function useObjectUrl(blob: Blob | null | undefined): string | null {\n    const [url, setUrl] = useState<string | null>(null);\n\n    useEffect(() => {\n        if (!blob) {\n            setUrl(null);\n            return;\n        }\n        const next = URL.createObjectURL(blob);\n        setUrl(next);\n        return () => URL.revokeObjectURL(next);\n    }, [blob]);\n\n    return url;\n}\n"],"mappings":"uBASA,SAAgB,EAAa,EAA8C,CACvE,GAAM,CAAC,EAAK,IAAA,EAAU,EAAA,SAAA,CAAwB,IAAI,EAYlD,OAVA,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,CAAC,EAAM,CACP,EAAO,IAAI,EACX,MACJ,CACA,IAAM,EAAO,IAAI,gBAAgB,CAAI,EAErC,OADA,EAAO,CAAI,MACE,IAAI,gBAAgB,CAAI,CACzC,EAAG,CAAC,CAAI,CAAC,EAEF,CACX"}