Spaces:
Running
Running
| import{r as t,j as e}from"./react-D_B_5QVd.js";import{v as h,B as g,L as m}from"./index-QBya0NjG.js";import{m as u}from"./marked-CesSW9Du.js";import"./jszip-C9ownNzX.js";import"./react-dom-EAO2-NBm.js";import"./scheduler-DYLXRpC5.js";import"./@google-4tyssLU_.js";import"./idb-Dob3nYDb.js";const S=()=>{const[r,o]=t.useState(""),[a,c]=t.useState(!1),[n,i]=t.useState(""),[p,d]=t.useState("");t.useEffect(()=>{(async()=>{if(r){const s=await u.parse(r);d(s)}else d("")})()},[r]);const x=t.useCallback(async()=>{c(!0),i(""),o("");try{const l=h(null);let s="";for await(const f of l)s+=f,o(s)}catch(l){const s=l instanceof Error?l.message:"An unknown error occurred.";i(`Failed to generate challenge: ${s}`)}finally{c(!1)}},[]);return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8",children:[e.jsxs("header",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold text-slate-100 flex items-center",children:[e.jsx(g,{}),e.jsx("span",{className:"ml-3",children:"AI Coding Challenge Generator"})]}),e.jsx("p",{className:"text-slate-400 mt-1",children:"Generate a unique coding problem to test your skills."})]}),e.jsx("button",{onClick:x,disabled:a,className:"flex items-center justify-center px-6 py-3 bg-cyan-500 text-slate-900 font-bold rounded-md hover:bg-cyan-400 transition-colors disabled:bg-slate-600 disabled:cursor-not-allowed",children:a?e.jsx(m,{}):"Generate New Challenge"})]}),e.jsxs("div",{className:"flex-grow p-4 bg-slate-800/50 border border-slate-700/50 rounded-md overflow-y-auto",children:[a&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(m,{})}),n&&e.jsx("p",{className:"text-red-400",children:n}),r&&!a&&e.jsx("div",{className:"prose prose-sm prose-invert max-w-none prose-headings:text-slate-200 prose-p:text-slate-300 prose-strong:text-slate-100 prose-code:text-cyan-300 prose-code:before:content-none prose-code:after:content-none prose-pre:bg-slate-900/50 prose-pre:border prose-pre:border-slate-700",dangerouslySetInnerHTML:{__html:p}}),!a&&!r&&!n&&e.jsx("div",{className:"text-slate-500 h-full flex items-center justify-center",children:'Click "Generate New Challenge" to start.'})]})]})};export{S as AiCodingChallenge}; | |
| //# sourceMappingURL=AiCodingChallenge-BQSkuis0.js.map | |