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ACrB,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7B,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,QAAQ,EAAE,CAAC;IACf,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACH,oBAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE;YAC5B,UAAU;YACV,QAAQ;SACX,IACI,QAAQ,CACa,CAC7B,CAAA;AACL,CAAC;AAED,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAC9B,OAAO,UAAU,CAAC,cAAc,CAAC,CAAC;AACtC,CAAC,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,CAAC","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"]}