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5B,QAAQ,EAAE,CAAC;IACf,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACH,8BAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE;YAC5B,UAAU;YACV,QAAQ;SACX,IACI,QAAQ,CACa,CAC7B,CAAA;AACL,CAAC;AAMQ,0CAAe;AAJxB,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAC9B,OAAO,IAAA,kBAAU,EAAC,cAAc,CAAC,CAAC;AACtC,CAAC,CAAA;AAEyB,oDAAoB","sourcesContent":["import React, { useState, createContext, useEffect, useRef, useContext } from \"react\";\nimport init from \"radiantkit\";\nimport { RadiantController } from \"controller\";\n\nexport interface RadiantState {\n controller: RadiantController | null;\n response: any;\n}\n\nconst RadiantContext = createContext({\n controller: null,\n response: {},\n});\n\nfunction RadiantProvider({ children }: any) {\n const [controller, setController] = useState(null);\n const [response, setResponse] = useState({});\n\n const initWasm = async () => {\n try {\n await init();\n let controller = await RadiantController.createController((message: any) => {\n setResponse(message);\n });\n setController(controller);\n } catch (error) {\n console.log(error);\n }\n };\n\n const [, setTimesRun] = useState(0);\n const counter = useRef(0);\n const effectCalled = useRef(false);\n\n useEffect(() => {\n if (effectCalled.current) return;\n counter.current += 1;\n setTimesRun(counter.current);\n effectCalled.current = true;\n initWasm();\n }, []);\n\n return (\n \n {children}\n \n )\n}\n\nconst useCurrentController = () => {\n return useContext(RadiantContext);\n}\n\nexport { RadiantProvider, useCurrentController };\n"]}