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bvB,EAAiB,OAAOI,EAAU,4BAEtCI,GAAW,GACX,IACE,MAAMgB,QAAYC,MAAM,OAAQ,CAC9BC,OAAQ,OACRC,QAAS,CACP,eAAgB,oBAElBC,KAAMC,KAAKC,UAAU,CACnB9B,eAIE+B,QAAiCP,EAAIQ,OACvCD,EAAK5B,OAAQC,EAAU2B,EAAK5B,QAC3BC,EAAU,mCACjB,CAAE,MAAO6B,GACP7B,EAAU,mCACZ,CAAC,QACCI,GAAW,EACb,IAmCMQ,EAAAA,cAAA,YACEkB,MAAOlC,EACPmC,SAAW5C,GAAMU,EAAYV,EAAE4B,OAAOe,OACtCE,YAAY,yBACZnB,UAAU,+GACVoB,KAAM,IAERrB,EAAAA,cAAA,OAAKC,UAAW,qCACdD,EAAAA,cAAA,UACEsB,KAAK,SACLrB,UAAU,qEACX,eACc,IACZV,GACCS,EAAAA,cAAA,OACEC,UAAU,6CACVsB,MAAM,6BACNC,KAAK,OACLC,QAAQ,aAERzB,EAAAA,cAAA,UACEC,UAAU,aACVyB,GAAG,KACHC,GAAG,KACHC,EAAE,KACFC,OAAO,eACPC,YAAY,MAEd9B,EAAAA,cAAA,QACEC,UAAU,aACVuB,KAAK,eACLO,EAAE,wHAOb1C,GACCW,EAAAA,cAAA,OAAKC,UAAU,+BAA+BZ,IAGlDW,EAAAA,cAAA,KAAGC,UAAW,sDACZD,EAAAA,cAAA,KAAGE,KAAK,qBAAqBC,OAAO,SAASF,UAAU,eAAc,cAGrED,EAAAA,cAAA,KAAGE,KAAK,4DAA4DC,OAAO,SAASF,UAAU,eAAc,WAI1G,C,gECzGV,UAVa+B,IAEThC,EAAAA,cAAA,OAAKC,UAAW,gBACdD,EAAAA,cAAA,OAAKC,UAAW,qBACdD,EAAAA,cAACjB,EAAAA,QAAQ,O,sBCSjB,IAAIkD,EAA0BC,EAAAA,KACVA,EAAQ,KACdC,WAAWF,E","sources":["webpack://app/./app/javascript/components/ sync ^\\.\\/.*$","webpack://app/./app/javascript/components/AskMyPdf.tsx","webpack://app/./app/javascript/components/Home.tsx","webpack://app/./app/javascript/packs/application.js"],"sourcesContent":["var map = {\n\t\"./AskMyPdf\": 780,\n\t\"./AskMyPdf.tsx\": 780,\n\t\"./Home\": 599,\n\t\"./Home.tsx\": 599\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = 982;","import React, { useState, useEffect } from \"react\";\nimport { updateSourceFile } from \"typescript\";\n\nconst AskMyPdf: React.FC = () => {\n const [question, setQuestion] = useState(\"\");\n const [answer, setAnswer] = useState(\"\");\n const [displayedAnswer, setDisplayedAnswer] = useState(\"\");\n const [loading, setLoading] = useState(false);\n\n const handleFormSubmit = async (event: React.FormEvent) => {\n event.preventDefault();\n\n if (question === \"\") return setAnswer(\"Please enter a question.\")\n\n setLoading(true);\n try {\n const res = await fetch(\"/ask\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n question,\n }),\n });\n\n const data: { answer: string } = await res.json();\n if (data.answer) setAnswer(data.answer);\n else setAnswer(\"An unexpected error has occured.\");\n } catch (err) {\n setAnswer(\"An unexpected error has occured.\");\n } finally {\n setLoading(false);\n }\n };\n\n useEffect(() => {\n let index = 0;\n setDisplayedAnswer(answer[index]);\n\n const typeEffect = setInterval(() => {\n if (index < answer.length - 1) {\n setDisplayedAnswer((prev) => prev + answer[index]);\n index++;\n } else {\n clearInterval(typeEffect);\n }\n }, 20);\n\n return () => clearInterval(typeEffect);\n }, [answer]);\n\n return (\n
\n
\n

Ask My PDF

{\" \"}\n

\n This is an experiment using AI to make a PDF's content more\n accessible. Current PDF:{\" \"}\n \n Trapping Furbearers: An Introduction to Responsible Trapping\n \n

\n
\n setQuestion(e.target.value)}\n placeholder=\"What is your question?\"\n className=\"p-2 rounded w-full mb-4 border focus:outline-none focus:ring-2 focus:ring-gray-600 focus:border-transparent\"\n rows={4}\n />\n
\n \n Ask question{\" \"}\n {loading && (\n \n \n \n \n )}\n \n
\n \n {displayedAnswer && (\n
{displayedAnswer}
\n )}\n
\n

\n \n lebich.dev\n \n \n github\n \n

\n
\n );\n};\n\nexport default AskMyPdf;\n","import React from \"react\";\nimport AskMyPdf from \"./AskMyPdf\";\n\nconst Home = () => {\n return (\n
\n
\n \n
\n
\n );\n};\n\nexport default Home;\n","/* eslint no-console:0 */\n// This file is automatically compiled by Webpack, along with any other files\n// present in this directory. You're encouraged to place your actual application logic in\n// a relevant structure within app/javascript and only use these pack files to reference\n// that code so it'll be compiled.\n//\n// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate\n// layout file, like app/views/layouts/application.html.erb\n\n// Uncomment to copy all static images under ./images to the output folder and reference\n// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)\n// or the `imagePath` JavaScript helper below.\n//\n// const images = require.context('./images', true)\n// const imagePath = (name) => images(name, true)\n// Support component names relative to this directory:\nvar componentRequireContext = require.context(\"../components\", true);\nvar ReactRailsUJS = require(\"react_ujs\");\nReactRailsUJS.useContext(componentRequireContext);\n"],"names":["map","webpackContext","req","id","webpackContextResolve","__webpack_require__","o","e","Error","code","keys","Object","resolve","module","exports","AskMyPdf","question","setQuestion","useState","answer","setAnswer","displayedAnswer","setDisplayedAnswer","loading","setLoading","useEffect","index","typeEffect","setInterval","length","prev","clearInterval","React","className","href","target","onSubmit","async","event","preventDefault","res","fetch","method","headers","body","JSON","stringify","data","json","err","value","onChange","placeholder","rows","type","xmlns","fill","viewBox","cx","cy","r","stroke","strokeWidth","d","Home","componentRequireContext","require","useContext"],"sourceRoot":""}