iamfebin commited on
Commit
f0175ec
·
1 Parent(s): 4f6bb9e

feat: FSRS card manager, fantasy cartography art polish, and map progression effects

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. README.md +1 -1
  2. algospaced-ui/dist/assets/{Auth-DHdm5r3r.js → Auth-CphacI2S.js} +1 -1
  3. algospaced-ui/dist/assets/CardManager-BEhyd34f.js +1 -0
  4. algospaced-ui/dist/assets/{CreateProblemForm-Cej3QR08.js → CreateProblemForm-Ccz3TNzp.js} +1 -1
  5. algospaced-ui/dist/assets/FileExplorer-CJE9LlAj.js +0 -3
  6. algospaced-ui/dist/assets/FileExplorer-D3FrJW-x.js +3 -0
  7. algospaced-ui/dist/assets/GitHubSyncWindow-CrRFKIeu.js +1 -0
  8. algospaced-ui/dist/assets/GitHubSyncWindow-DHS56rys.js +0 -1
  9. algospaced-ui/dist/assets/JourneyPath-BhAvKOiu.js +0 -0
  10. algospaced-ui/dist/assets/JourneyPath-Dpd3IPxF.js +0 -0
  11. algospaced-ui/dist/assets/{KatexRenderer-HIhDCm0G.js → KatexRenderer-DVt2cqHc.js} +1 -1
  12. algospaced-ui/dist/assets/{MarkdownRenderer-BMZIn30p.js → MarkdownRenderer-D8UdFpnD.js} +2 -2
  13. algospaced-ui/dist/assets/{MySQLPlayground-CDRacqFf.js → MySQLPlayground-iGzsbjAa.js} +1 -1
  14. algospaced-ui/dist/assets/OnboardingModal-DmgTXeeL.js +0 -1
  15. algospaced-ui/dist/assets/PrincessChamber-5t89aBn-.js +0 -1
  16. algospaced-ui/dist/assets/PrincessChamber-abJShfI5.js +1 -0
  17. algospaced-ui/dist/assets/{ProblemSpecPanel-CLbwqTwe.js → ProblemSpecPanel-BRW8UyO6.js} +3 -3
  18. algospaced-ui/dist/assets/{PythonChallenge-BOgiGe52.js → PythonChallenge-CQdOe4Q2.js} +1 -1
  19. algospaced-ui/dist/assets/ReviewQueue-CltGWQpb.js +5 -0
  20. algospaced-ui/dist/assets/ReviewQueue-DmsrlLxn.js +0 -5
  21. algospaced-ui/dist/assets/Settings-ACJ113RL.js +0 -1
  22. algospaced-ui/dist/assets/Settings-BVuXk3LW.js +1 -0
  23. algospaced-ui/dist/assets/TerminalEmulator-C2zR6yON.js +0 -1
  24. algospaced-ui/dist/assets/TerminalEmulator-CZed0tiA.js +1 -0
  25. algospaced-ui/dist/assets/index-BsU9BpJx.css +0 -0
  26. algospaced-ui/dist/assets/{index-DnK6BACV.js → index-DVWZ15xt.js} +0 -0
  27. algospaced-ui/dist/assets/index-tlaKBeUb.css +0 -0
  28. algospaced-ui/dist/assets/vendor-react-CIO8MTK1.js +0 -0
  29. algospaced-ui/dist/assets/vendor-react-hnaVBnLv.js +0 -0
  30. algospaced-ui/dist/index.html +3 -3
  31. algospaced-ui/dist/llms.txt +1 -1
  32. algospaced-ui/dist/sw.js +1 -1
  33. algospaced-ui/package.json +1 -1
  34. algospaced-ui/public/llms.txt +1 -1
  35. algospaced-ui/src/App.tsx +11 -35
  36. algospaced-ui/src/components/DesktopContextMenu.tsx +11 -0
  37. algospaced-ui/src/components/FileExplorer.tsx +36 -17
  38. algospaced-ui/src/components/OnboardingModal.tsx +0 -600
  39. algospaced-ui/src/components/ReviewQueue.tsx +5 -32
  40. algospaced-ui/src/components/TerminalEmulator.tsx +10 -4
  41. algospaced-ui/src/components/card-manager/CardManager.tsx +1344 -0
  42. algospaced-ui/src/components/desktop/DesktopStartMenu.tsx +9 -11
  43. algospaced-ui/src/components/desktop/DesktopTaskbar.tsx +1 -6
  44. algospaced-ui/src/components/desktop/DesktopWindowContainer.tsx +42 -5
  45. algospaced-ui/src/components/desktop/MobileMetroScreen.tsx +13 -0
  46. algospaced-ui/src/components/map/CurvyPathAndNodes.tsx +257 -94
  47. algospaced-ui/src/components/map/MapBorderAndFilters.tsx +239 -84
  48. algospaced-ui/src/components/map/MapControls.tsx +44 -39
  49. algospaced-ui/src/components/map/NodeDetailCard.tsx +1 -1
  50. algospaced-ui/src/components/map/PencilMapCanvas.tsx +16 -13
README.md CHANGED
@@ -16,7 +16,7 @@ A retro-styled Spaced Repetition System (SRS) for mastering Data Structures & Al
16
 
17
  ## 🌟 Features
18
 
19
- - **SRS Review Queue**: Leitner 5-box spaced repetition algorithm with AI critique and hints.
20
  - **Expedition Trail Map**: Hand-drawn vintage cartography map visualizing progress along the LeetCode 150 path.
21
  - **Interactive Sandboxes**: Python algorithm practice and SQLite sandbox with real-time validation.
22
  - **File Explorer & Exporter**: Tag, manage, and export DSA solutions as `.py` archives.
 
16
 
17
  ## 🌟 Features
18
 
19
+ - **SRS Review Queue**: Free Spaced Repetition Scheduler (FSRS) algorithm with AI critique and hints.
20
  - **Expedition Trail Map**: Hand-drawn vintage cartography map visualizing progress along the LeetCode 150 path.
21
  - **Interactive Sandboxes**: Python algorithm practice and SQLite sandbox with real-time validation.
22
  - **File Explorer & Exporter**: Tag, manage, and export DSA solutions as `.py` archives.
algospaced-ui/dist/assets/{Auth-DHdm5r3r.js → Auth-CphacI2S.js} RENAMED
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,Bt as n,Rt as r,Tt as i,U as a,V as o,o as s,q as c,x as l,yt as u}from"./vendor-react-CIO8MTK1.js";import{t as d}from"./firebaseClient-DZobvwSx.js";var f=e(n(),1),p=r();function m(){let[e,n]=(0,f.useState)(!1),[r,m]=(0,f.useState)(``),[h,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(null),T=h.length>=8,E=/[A-Z]/.test(h),D=/[a-z]/.test(h),O=/[0-9]/.test(h),k=/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?~`]/.test(h),A=h.length>0&&h===_,j=T&&E&&D&&O&&k;return(0,p.jsxs)(`div`,{className:`fixed inset-0 w-full h-full max-h-[100dvh] overflow-y-auto overscroll-contain custom-scrollbar flex flex-col items-center px-3 pt-3 pb-8 sm:px-4 sm:py-6 md:p-8 relative isolate selection:bg-highlight-pink selection:text-white`,children:[(0,p.jsx)(`div`,{className:`fixed inset-0 w-full h-full bg-cover bg-center z-0 saturate-150 contrast-125 pointer-events-none`,style:{backgroundImage:`url('/wallpapers/default.webp')`}}),(0,p.jsxs)(`div`,{className:`w-full max-w-md bg-paper-white border-[4px] border-ink-black window-shadow z-10 flex flex-col overflow-hidden shadow-[inset_2px_2px_0px_rgba(255,255,255,0.8)] relative my-auto shrink-0`,children:[(0,p.jsx)(`div`,{className:`bg-[#0ea5e9] border-b-[4px] border-ink-black px-3 sm:px-4 py-2 sm:py-2.5 flex justify-between items-center text-ink-black select-none`,children:(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`material-symbols-outlined select-none text-base sm:text-xl`,style:{fontVariationSettings:`'FILL' 1`},children:`sports_esports`}),(0,p.jsx)(`span`,{className:`font-window-title text-xs sm:text-base font-bold tracking-wide`,children:`System_Setup.exe`})]})}),(0,p.jsxs)(`div`,{className:`p-4 sm:p-6 bg-[#fdf8e1] flex-1 flex flex-col`,children:[typeof window<`u`&&window.self!==window.top&&(0,p.jsxs)(`div`,{className:`mb-4 sm:mb-5 p-3 sm:p-3.5 border-[3px] border-[#ea580c] bg-[#ffedd5] text-[#9a3412] text-xs font-bold font-arcade leading-relaxed shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[`⚠️ RUNNING INSIDE IFRAME`,(0,p.jsx)(`p`,{className:`mt-1 font-sans text-[11px] font-normal text-ink-black normal-case leading-normal`,children:`If Google Sign-In popup is restricted inside Hugging Face wrapper, open the standalone link below:`}),(0,p.jsx)(`a`,{href:`https://iamfebin-algospaced-dsa.hf.space/`,target:`_top`,className:`mt-2.5 inline-block w-full text-center bg-[#ea580c] hover:bg-[#c2410c] text-white border-[2.5px] border-ink-black py-1.5 px-3 rounded-lg font-window-title text-xs font-bold transition-all shadow-[1.5px_1.5px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:`OPEN FULLSCREEN / DIRECT SITE`})]}),(0,p.jsxs)(`div`,{className:`flex flex-col items-center mb-4 sm:mb-6`,children:[(0,p.jsx)(`div`,{className:`w-12 h-12 sm:w-16 sm:h-16 bg-paper-white border-[3px] border-ink-black flex items-center justify-center gadget-shadow shadow-[inset_2px_2px_0px_rgba(255,255,255,0.8)] mb-2.5 sm:mb-4`,children:(0,p.jsx)(l,{className:`w-7 h-7 sm:w-9 sm:h-9 text-primary`})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold tracking-tight text-ink-black font-headline-md leading-none m-0`,children:`AlgoSpaced`}),(0,p.jsx)(`span`,{className:`text-[9px] sm:text-[10px] font-arcade bg-[#facc15] text-ink-black font-extrabold px-1.5 sm:px-2 py-0.5 border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] uppercase rotate-[-3deg]`,children:`BETA`})]}),(0,p.jsx)(`p`,{className:`text-[10px] sm:text-xs font-arcade text-trash-gray mt-1.5 sm:mt-2 tracking-wide uppercase text-center`,children:`Spaced Repetition for DSA`})]}),(0,p.jsxs)(`div`,{className:`flex gap-2 mb-4 sm:mb-6 font-arcade text-[9px] sm:text-[10px]`,children:[(0,p.jsx)(`button`,{onClick:()=>{n(!1),w(null)},className:`flex-1 py-2 sm:py-2.5 border-[3px] border-ink-black cursor-pointer font-bold tracking-wider outline-none transition-all shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none active:translate-y-0.5 ${e?`bg-white text-slate-700 hover:bg-surface-container`:`bg-secondary-container text-ink-black translate-y-0.5 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]`}`,children:`SIGN IN`}),(0,p.jsx)(`button`,{onClick:()=>{n(!0),w(null)},className:`flex-1 py-2 sm:py-2.5 border-[3px] border-ink-black cursor-pointer font-bold tracking-wider outline-none transition-all shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none active:translate-y-0.5 ${e?`bg-secondary-container text-ink-black translate-y-0.5 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]`:`bg-white text-slate-700 hover:bg-surface-container`}`,children:`CREATE ACCOUNT`})]}),C&&(0,p.jsxs)(`div`,{className:`mb-4 sm:mb-6 p-3 sm:p-4 border-[3px] border-ink-black text-xs font-arcade leading-relaxed ${C.type===`error`?`bg-red-100 border-red-500 text-error shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:C.type===`unverified`?`bg-amber-100 border-amber-500 text-amber-900 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:`bg-emerald-100 border-emerald-500 text-emerald-700 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`}`,children:[(0,p.jsx)(`p`,{children:C.text}),C.type===`unverified`&&(0,p.jsxs)(`button`,{type:`button`,onClick:async()=>{if(!r.trim()||!h){w({type:`error`,text:`Please enter your email and password above to resend the verification link.`});return}try{S(!0),await d.resendVerificationEmail(r.trim(),h),w({type:`success`,text:`Verification email resent to ${r.trim()}! Please check your inbox and spam folder.`})}catch(e){w({type:`error`,text:e.message||`Failed to resend verification email. Check your credentials.`})}finally{S(!1)}},disabled:x,className:`mt-3 w-full bg-amber-500 hover:bg-amber-600 text-white font-window-title text-xs font-bold py-2 px-3 border-[2px] border-ink-black rounded flex items-center justify-center gap-2 cursor-pointer shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none uppercase disabled:opacity-50`,children:[(0,p.jsx)(t,{className:`w-3.5 h-3.5 ${x?`animate-spin`:``}`}),x?`SENDING LINK...`:`RESEND VERIFICATION EMAIL`]})]}),(0,p.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),b(!0),w(null);let i=r.trim();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i)){w({type:`error`,text:`Please enter a valid email address.`}),b(!1);return}if(e){if(!j){w({type:`error`,text:`Password does not meet the security criteria. Please check the requirements below.`}),b(!1);return}if(h!==_){w({type:`error`,text:`Passwords do not match. Please re-enter.`}),b(!1);return}try{await d.signUpWithEmail(i,h),w({type:`success`,text:`Registration successful! A verification link has been sent to your email. Please verify your email before logging in.`}),n(!1),g(``),v(``)}catch(e){let t=e,n=t.message||`An error occurred during registration.`;t.code===`auth/email-already-in-use`?n=`This email address is already registered. Please sign in instead.`:t.code===`auth/invalid-email`?n=`The email address format is invalid.`:t.code===`auth/weak-password`&&(n=`Firebase requires a stronger password.`),w({type:`error`,text:n})}finally{b(!1)}}else try{await d.signInWithEmail(i,h)}catch(e){let t=e;if(t.code===`auth/email-not-verified`)w({type:`unverified`,text:`Your email address is not verified yet. Please check your inbox for the activation link.`});else{let e=t.message||`An error occurred during sign in.`;t.code===`auth/invalid-credential`||t.code===`auth/user-not-found`||t.code===`auth/wrong-password`?e=`Invalid email or password. Please check your credentials.`:t.code===`auth/too-many-requests`&&(e=`Access temporarily locked due to many failed attempts. Try again later or reset password.`),w({type:`error`,text:e})}}finally{b(!1)}},className:`space-y-3 sm:space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-email`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Email Address`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(o,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-email`,type:`email`,required:!0,value:r,onChange:e=>m(e.target.value),placeholder:`name@arcade.com`,"aria-label":`Email Address`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-password`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Password`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(a,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-password`,type:`password`,required:!0,value:h,onChange:e=>g(e.target.value),placeholder:`••••••••`,"aria-label":`Password`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),e&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-confirm-password`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Confirm Password`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(c,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-confirm-password`,type:`password`,required:!0,value:_,onChange:e=>v(e.target.value),placeholder:`••••••••`,"aria-label":`Confirm Password`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),(0,p.jsxs)(`div`,{className:`p-2.5 sm:p-3 bg-white border-[2px] border-ink-black rounded-lg text-[9px] sm:text-[10px] font-code-mono space-y-1 shadow-[inset_1px_1px_0px_rgba(0,0,0,0.05)]`,children:[(0,p.jsx)(`div`,{className:`font-bold font-arcade uppercase text-[8px] sm:text-[9px] text-trash-gray mb-1 sm:mb-1.5`,children:`Password Security Requirements:`}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${T?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[T?(0,p.jsx)(u,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(s,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`Minimum 8 characters`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${E&&D?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[E&&D?(0,p.jsx)(u,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(s,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`Uppercase & lowercase letters (A-Z, a-z)`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${O?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[O?(0,p.jsx)(u,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(s,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`At least 1 number (0-9)`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${k?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[k?(0,p.jsx)(u,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(s,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`At least 1 special character (!@#$%^&*...)`})]}),_.length>0&&(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${A?`text-emerald-700 font-bold`:`text-red-600 font-bold`}`,children:[A?(0,p.jsx)(u,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(s,{className:`w-3 h-3 text-red-500 shrink-0 stroke-[3]`}),(0,p.jsx)(`span`,{children:A?`Passwords match`:`Passwords do not match`})]})]})]}),(0,p.jsxs)(`button`,{type:`submit`,disabled:y||e&&(!j||!A),className:`w-full bg-[#ffcc00] hover:bg-yellow-400 border-[3px] sm:border-[4px] border-ink-black rounded-xl py-2.5 sm:py-3.5 font-window-title text-sm sm:text-base text-ink-black arcade-btn cursor-pointer disabled:opacity-50 flex items-center justify-center gap-2 uppercase font-bold tracking-wide transition-all shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none`,children:[y?`PROCESSING...`:e?`CREATE ACCOUNT`:`SIGN IN`,!y&&(0,p.jsx)(i,{className:`w-4 h-4 stroke-[3px]`})]})]}),(0,p.jsxs)(`div`,{className:`relative my-3.5 sm:my-5 select-none`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,p.jsx)(`div`,{className:`w-full border-t-[3px] border-ink-black border-dashed`})}),(0,p.jsx)(`div`,{className:`relative flex justify-center text-[9px] sm:text-[10px] uppercase font-arcade`,children:(0,p.jsx)(`span`,{className:`bg-[#fdf8e1] px-2 sm:px-3 text-trash-gray font-bold`,children:`OR CONTINUE WITH`})})]}),(0,p.jsxs)(`button`,{onClick:async()=>{try{b(!0),w(null),await d.signInWithGoogle()}catch(e){w({type:`error`,text:e.message||`Google Sign-In failed to initialize`}),b(!1)}},disabled:y,className:`w-full bg-white hover:bg-slate-100 border-[3px] border-ink-black text-ink-black font-bold py-2.5 sm:py-3 px-3 sm:px-4 rounded-xl flex items-center justify-center gap-2.5 sm:gap-3 transition-all text-[11px] sm:text-xs cursor-pointer shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none`,children:[(0,p.jsxs)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,p.jsx)(`path`,{d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`,fill:`#4285F4`}),(0,p.jsx)(`path`,{d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`,fill:`#34A853`}),(0,p.jsx)(`path`,{d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.06H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.94l2.85-2.22.81-.63z`,fill:`#FBBC05`}),(0,p.jsx)(`path`,{d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.06l3.66 2.84c.87-2.6 3.3-4.52 6.16-4.52z`,fill:`#EA4335`})]}),`SIGN IN WITH GOOGLE`]}),(0,p.jsxs)(`button`,{onClick:()=>{d.enterSandbox()},disabled:y,className:`mt-2.5 sm:mt-3 w-full bg-[#10b981] hover:bg-emerald-600 text-white font-window-title py-2.5 sm:py-3 px-3 sm:px-4 border-[3px] border-ink-black rounded-xl flex items-center justify-center gap-2 cursor-pointer shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none uppercase font-bold text-[11px] sm:text-xs`,children:[(0,p.jsx)(`span`,{className:`material-symbols-outlined text-sm font-bold`,children:`sports_esports`}),`Enter Sandbox Mode (No Login)`]})]})]})]})}export{m as default};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,C as n,G as r,Ht as i,M as a,Ot as o,St as s,U as c,Y as l,o as u}from"./vendor-react-hnaVBnLv.js";import{t as d}from"./firebaseClient-DZobvwSx.js";var f=e(i(),1),p=t();function m(){let[e,t]=(0,f.useState)(!1),[i,m]=(0,f.useState)(``),[h,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(null),T=h.length>=8,E=/[A-Z]/.test(h),D=/[a-z]/.test(h),O=/[0-9]/.test(h),k=/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?~`]/.test(h),A=h.length>0&&h===_,j=T&&E&&D&&O&&k;return(0,p.jsxs)(`div`,{className:`fixed inset-0 w-full h-full max-h-[100dvh] overflow-y-auto overscroll-contain custom-scrollbar flex flex-col items-center px-3 pt-3 pb-8 sm:px-4 sm:py-6 md:p-8 relative isolate selection:bg-highlight-pink selection:text-white`,children:[(0,p.jsx)(`div`,{className:`fixed inset-0 w-full h-full bg-cover bg-center z-0 saturate-150 contrast-125 pointer-events-none`,style:{backgroundImage:`url('/wallpapers/default.webp')`}}),(0,p.jsxs)(`div`,{className:`w-full max-w-md bg-paper-white border-[4px] border-ink-black window-shadow z-10 flex flex-col overflow-hidden shadow-[inset_2px_2px_0px_rgba(255,255,255,0.8)] relative my-auto shrink-0`,children:[(0,p.jsx)(`div`,{className:`bg-[#0ea5e9] border-b-[4px] border-ink-black px-3 sm:px-4 py-2 sm:py-2.5 flex justify-between items-center text-ink-black select-none`,children:(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`material-symbols-outlined select-none text-base sm:text-xl`,style:{fontVariationSettings:`'FILL' 1`},children:`sports_esports`}),(0,p.jsx)(`span`,{className:`font-window-title text-xs sm:text-base font-bold tracking-wide`,children:`System_Setup.exe`})]})}),(0,p.jsxs)(`div`,{className:`p-4 sm:p-6 bg-[#fdf8e1] flex-1 flex flex-col`,children:[typeof window<`u`&&window.self!==window.top&&(0,p.jsxs)(`div`,{className:`mb-4 sm:mb-5 p-3 sm:p-3.5 border-[3px] border-[#ea580c] bg-[#ffedd5] text-[#9a3412] text-xs font-bold font-arcade leading-relaxed shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[`⚠️ RUNNING INSIDE IFRAME`,(0,p.jsx)(`p`,{className:`mt-1 font-sans text-[11px] font-normal text-ink-black normal-case leading-normal`,children:`If Google Sign-In popup is restricted inside Hugging Face wrapper, open the standalone link below:`}),(0,p.jsx)(`a`,{href:`https://iamfebin-algospaced-dsa.hf.space/`,target:`_top`,className:`mt-2.5 inline-block w-full text-center bg-[#ea580c] hover:bg-[#c2410c] text-white border-[2.5px] border-ink-black py-1.5 px-3 rounded-lg font-window-title text-xs font-bold transition-all shadow-[1.5px_1.5px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:`OPEN FULLSCREEN / DIRECT SITE`})]}),(0,p.jsxs)(`div`,{className:`flex flex-col items-center mb-4 sm:mb-6`,children:[(0,p.jsx)(`div`,{className:`w-12 h-12 sm:w-16 sm:h-16 bg-paper-white border-[3px] border-ink-black flex items-center justify-center gadget-shadow shadow-[inset_2px_2px_0px_rgba(255,255,255,0.8)] mb-2.5 sm:mb-4`,children:(0,p.jsx)(n,{className:`w-7 h-7 sm:w-9 sm:h-9 text-primary`})}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold tracking-tight text-ink-black font-headline-md leading-none m-0`,children:`AlgoSpaced`}),(0,p.jsx)(`span`,{className:`text-[9px] sm:text-[10px] font-arcade bg-[#facc15] text-ink-black font-extrabold px-1.5 sm:px-2 py-0.5 border-[2px] border-ink-black shadow-[2px_2px_0px_0px_#1E293B] uppercase rotate-[-3deg]`,children:`BETA`})]}),(0,p.jsx)(`p`,{className:`text-[10px] sm:text-xs font-arcade text-trash-gray mt-1.5 sm:mt-2 tracking-wide uppercase text-center`,children:`Spaced Repetition for DSA`})]}),(0,p.jsxs)(`div`,{className:`flex gap-2 mb-4 sm:mb-6 font-arcade text-[9px] sm:text-[10px]`,children:[(0,p.jsx)(`button`,{onClick:()=>{t(!1),w(null)},className:`flex-1 py-2 sm:py-2.5 border-[3px] border-ink-black cursor-pointer font-bold tracking-wider outline-none transition-all shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none active:translate-y-0.5 ${e?`bg-white text-slate-700 hover:bg-surface-container`:`bg-secondary-container text-ink-black translate-y-0.5 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]`}`,children:`SIGN IN`}),(0,p.jsx)(`button`,{onClick:()=>{t(!0),w(null)},className:`flex-1 py-2 sm:py-2.5 border-[3px] border-ink-black cursor-pointer font-bold tracking-wider outline-none transition-all shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:shadow-none active:translate-y-0.5 ${e?`bg-secondary-container text-ink-black translate-y-0.5 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]`:`bg-white text-slate-700 hover:bg-surface-container`}`,children:`CREATE ACCOUNT`})]}),C&&(0,p.jsxs)(`div`,{className:`mb-4 sm:mb-6 p-3 sm:p-4 border-[3px] border-ink-black text-xs font-arcade leading-relaxed ${C.type===`error`?`bg-red-100 border-red-500 text-error shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:C.type===`unverified`?`bg-amber-100 border-amber-500 text-amber-900 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:`bg-emerald-100 border-emerald-500 text-emerald-700 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`}`,children:[(0,p.jsx)(`p`,{children:C.text}),C.type===`unverified`&&(0,p.jsxs)(`button`,{type:`button`,onClick:async()=>{if(!i.trim()||!h){w({type:`error`,text:`Please enter your email and password above to resend the verification link.`});return}try{S(!0),await d.resendVerificationEmail(i.trim(),h),w({type:`success`,text:`Verification email resent to ${i.trim()}! Please check your inbox and spam folder.`})}catch(e){w({type:`error`,text:e.message||`Failed to resend verification email. Check your credentials.`})}finally{S(!1)}},disabled:x,className:`mt-3 w-full bg-amber-500 hover:bg-amber-600 text-white font-window-title text-xs font-bold py-2 px-3 border-[2px] border-ink-black rounded flex items-center justify-center gap-2 cursor-pointer shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none uppercase disabled:opacity-50`,children:[(0,p.jsx)(a,{className:`w-3.5 h-3.5 ${x?`animate-spin`:``}`}),x?`SENDING LINK...`:`RESEND VERIFICATION EMAIL`]})]}),(0,p.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),b(!0),w(null);let r=i.trim();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)){w({type:`error`,text:`Please enter a valid email address.`}),b(!1);return}if(e){if(!j){w({type:`error`,text:`Password does not meet the security criteria. Please check the requirements below.`}),b(!1);return}if(h!==_){w({type:`error`,text:`Passwords do not match. Please re-enter.`}),b(!1);return}try{await d.signUpWithEmail(r,h),w({type:`success`,text:`Registration successful! A verification link has been sent to your email. Please verify your email before logging in.`}),t(!1),g(``),v(``)}catch(e){let t=e,n=t.message||`An error occurred during registration.`;t.code===`auth/email-already-in-use`?n=`This email address is already registered. Please sign in instead.`:t.code===`auth/invalid-email`?n=`The email address format is invalid.`:t.code===`auth/weak-password`&&(n=`Firebase requires a stronger password.`),w({type:`error`,text:n})}finally{b(!1)}}else try{await d.signInWithEmail(r,h)}catch(e){let t=e;if(t.code===`auth/email-not-verified`)w({type:`unverified`,text:`Your email address is not verified yet. Please check your inbox for the activation link.`});else{let e=t.message||`An error occurred during sign in.`;t.code===`auth/invalid-credential`||t.code===`auth/user-not-found`||t.code===`auth/wrong-password`?e=`Invalid email or password. Please check your credentials.`:t.code===`auth/too-many-requests`&&(e=`Access temporarily locked due to many failed attempts. Try again later or reset password.`),w({type:`error`,text:e})}}finally{b(!1)}},className:`space-y-3 sm:space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-email`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Email Address`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(c,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-email`,type:`email`,required:!0,value:i,onChange:e=>m(e.target.value),placeholder:`name@arcade.com`,"aria-label":`Email Address`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-password`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Password`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(r,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-password`,type:`password`,required:!0,value:h,onChange:e=>g(e.target.value),placeholder:`••••••••`,"aria-label":`Password`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),e&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{htmlFor:`auth-confirm-password`,className:`block text-[11px] sm:text-xs font-bold text-ink-black uppercase tracking-wider mb-1.5 sm:mb-2 font-headline-md`,children:`Confirm Password`}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(l,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 sm:w-4 sm:h-4 text-ink-black`}),(0,p.jsx)(`input`,{id:`auth-confirm-password`,type:`password`,required:!0,value:_,onChange:e=>v(e.target.value),placeholder:`••••••••`,"aria-label":`Confirm Password`,className:`w-full bg-white border-[3px] border-ink-black rounded-lg py-2 sm:py-2.5 pl-9 sm:pl-10 pr-3 sm:pr-4 text-ink-black placeholder-trash-gray focus:outline-none focus:bg-white text-xs sm:text-sm font-code-mono shadow-[inset_2px_2px_0px_rgba(0,0,0,0.1)]`})]})]}),(0,p.jsxs)(`div`,{className:`p-2.5 sm:p-3 bg-white border-[2px] border-ink-black rounded-lg text-[9px] sm:text-[10px] font-code-mono space-y-1 shadow-[inset_1px_1px_0px_rgba(0,0,0,0.05)]`,children:[(0,p.jsx)(`div`,{className:`font-bold font-arcade uppercase text-[8px] sm:text-[9px] text-trash-gray mb-1 sm:mb-1.5`,children:`Password Security Requirements:`}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${T?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[T?(0,p.jsx)(s,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(u,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`Minimum 8 characters`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${E&&D?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[E&&D?(0,p.jsx)(s,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(u,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`Uppercase & lowercase letters (A-Z, a-z)`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${O?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[O?(0,p.jsx)(s,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(u,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`At least 1 number (0-9)`})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${k?`text-emerald-700 font-bold`:`text-slate-500`}`,children:[k?(0,p.jsx)(s,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(u,{className:`w-3 h-3 text-slate-400 shrink-0`}),(0,p.jsx)(`span`,{children:`At least 1 special character (!@#$%^&*...)`})]}),_.length>0&&(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 ${A?`text-emerald-700 font-bold`:`text-red-600 font-bold`}`,children:[A?(0,p.jsx)(s,{className:`w-3 h-3 text-emerald-600 shrink-0 stroke-[3]`}):(0,p.jsx)(u,{className:`w-3 h-3 text-red-500 shrink-0 stroke-[3]`}),(0,p.jsx)(`span`,{children:A?`Passwords match`:`Passwords do not match`})]})]})]}),(0,p.jsxs)(`button`,{type:`submit`,disabled:y||e&&(!j||!A),className:`w-full bg-[#ffcc00] hover:bg-yellow-400 border-[3px] sm:border-[4px] border-ink-black rounded-xl py-2.5 sm:py-3.5 font-window-title text-sm sm:text-base text-ink-black arcade-btn cursor-pointer disabled:opacity-50 flex items-center justify-center gap-2 uppercase font-bold tracking-wide transition-all shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none`,children:[y?`PROCESSING...`:e?`CREATE ACCOUNT`:`SIGN IN`,!y&&(0,p.jsx)(o,{className:`w-4 h-4 stroke-[3px]`})]})]}),(0,p.jsxs)(`div`,{className:`relative my-3.5 sm:my-5 select-none`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,p.jsx)(`div`,{className:`w-full border-t-[3px] border-ink-black border-dashed`})}),(0,p.jsx)(`div`,{className:`relative flex justify-center text-[9px] sm:text-[10px] uppercase font-arcade`,children:(0,p.jsx)(`span`,{className:`bg-[#fdf8e1] px-2 sm:px-3 text-trash-gray font-bold`,children:`OR CONTINUE WITH`})})]}),(0,p.jsxs)(`button`,{onClick:async()=>{try{b(!0),w(null),await d.signInWithGoogle()}catch(e){w({type:`error`,text:e.message||`Google Sign-In failed to initialize`}),b(!1)}},disabled:y,className:`w-full bg-white hover:bg-slate-100 border-[3px] border-ink-black text-ink-black font-bold py-2.5 sm:py-3 px-3 sm:px-4 rounded-xl flex items-center justify-center gap-2.5 sm:gap-3 transition-all text-[11px] sm:text-xs cursor-pointer shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none`,children:[(0,p.jsxs)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 24 24`,fill:`currentColor`,children:[(0,p.jsx)(`path`,{d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`,fill:`#4285F4`}),(0,p.jsx)(`path`,{d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`,fill:`#34A853`}),(0,p.jsx)(`path`,{d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.06H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.94l2.85-2.22.81-.63z`,fill:`#FBBC05`}),(0,p.jsx)(`path`,{d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.06l3.66 2.84c.87-2.6 3.3-4.52 6.16-4.52z`,fill:`#EA4335`})]}),`SIGN IN WITH GOOGLE`]}),(0,p.jsxs)(`button`,{onClick:()=>{d.enterSandbox()},disabled:y,className:`mt-2.5 sm:mt-3 w-full bg-[#10b981] hover:bg-emerald-600 text-white font-window-title py-2.5 sm:py-3 px-3 sm:px-4 border-[3px] border-ink-black rounded-xl flex items-center justify-center gap-2 cursor-pointer shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none uppercase font-bold text-[11px] sm:text-xs`,children:[(0,p.jsx)(`span`,{className:`material-symbols-outlined text-sm font-bold`,children:`sports_esports`}),`Enter Sandbox Mode (No Login)`]})]})]})]})}export{m as default};
algospaced-ui/dist/assets/CardManager-BEhyd34f.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,Bt as r,Dt as i,Ht as a,M as o,P as s,St as c,T as l,X as u,a as ee,b as te,h as ne,mt as re,ot as ie,p as d,q as ae,v as f,x as oe,y as se}from"./vendor-react-hnaVBnLv.js";import{s as p}from"./firebaseClient-DZobvwSx.js";import{i as ce,l as m}from"./index-DVWZ15xt.js";var h=e(a(),1);async function g(){try{let{data:{session:e}}=await p.auth.getSession();return e?e.access_token:`sandbox`}catch{return`sandbox`}}function _(e){return e.toLowerCase().replace(/\s*-\s*method.*$/i,``).replace(/[^a-z0-9]+/g,``)}function v(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return}return e??void 0}async function le(){let e=await g(),t=ce(),n=[];try{let t=await fetch(`/api/explorer/problems`,{headers:{Authorization:`Bearer ${e}`}});t.ok&&(n=await t.json())}catch{n=[]}let r=new Map,i=new Map,a=new Set;for(let e of n)e.problem_number!==void 0&&e.problem_number!==null&&r.set(e.problem_number,e),i.set(_(e.name),e);let o=new Date,s=[];for(let e of t){let t=r.get(e.problem_number)||i.get(_(e.name));if(t){a.add(t.id);let n=t.next_review!==null&&t.next_review!==void 0||t.fsrs_state!==null&&t.fsrs_state!==void 0,r=t.next_review?new Date(t.next_review):null,i=n&&r!==null?r<=o:!1,c=v(t.solutions),l=v(t.examples),u=v(t.constraints);s.push({id:t.id,problem_number:e.problem_number,name:e.name,pattern:e.pattern,difficulty:e.difficulty,description:t.description||e.description,reference_code:t.reference_code||e.reference_solution,starter_code:t.starter_code||e.starter_code,optimal_time:t.optimal_time||e.time_complexity,optimal_space:t.optimal_space||e.space_complexity,how_to_solve:t.how_to_solve||``,examples:l&&(!Array.isArray(l)||l.length>0)?l:e.examples,constraints:u&&(!Array.isArray(u)||u.length>0)?u:e.constraints,solutions:c,leetcode_url:e.leetcode_url,is_enrolled:n,is_custom:!1,fsrs_state:t.fsrs_state??(n?0:null),fsrs_step:t.fsrs_step??0,fsrs_stability:t.fsrs_stability??0,fsrs_difficulty:t.fsrs_difficulty??0,fsrs_elapsed_days:t.fsrs_elapsed_days??0,fsrs_scheduled_days:t.fsrs_scheduled_days??0,fsrs_reps:t.fsrs_reps??0,fsrs_lapses:t.fsrs_lapses??0,next_review:t.next_review??null,last_reviewed:t.last_reviewed??null,times_correct:t.times_correct??0,total_attempts:t.total_attempts??0,is_due:i,catalogProblem:e})}else s.push({id:e.id,problem_number:e.problem_number,name:e.name,pattern:e.pattern,difficulty:e.difficulty,description:e.description,reference_code:e.reference_solution,starter_code:e.starter_code,optimal_time:e.time_complexity,optimal_space:e.space_complexity,how_to_solve:``,examples:e.examples,constraints:e.constraints,leetcode_url:e.leetcode_url,is_enrolled:!1,is_custom:!1,fsrs_state:null,fsrs_step:0,fsrs_stability:0,fsrs_difficulty:0,fsrs_elapsed_days:0,fsrs_scheduled_days:0,fsrs_reps:0,fsrs_lapses:0,next_review:null,last_reviewed:null,times_correct:0,total_attempts:0,is_due:!1,catalogProblem:e})}for(let e of n)if(!a.has(e.id)){let t=e.next_review!==null&&e.next_review!==void 0||e.fsrs_state!==null&&e.fsrs_state!==void 0,n=e.next_review?new Date(e.next_review):null,r=t&&n!==null?n<=o:!1,i=v(e.solutions),a=v(e.examples)||[],c=v(e.constraints)||[];s.push({id:e.id,problem_number:e.problem_number,name:e.name,pattern:e.pattern||`General`,difficulty:e.difficulty||`Medium`,description:e.description||``,reference_code:e.reference_code||``,starter_code:e.starter_code||``,optimal_time:e.optimal_time||`O(N)`,optimal_space:e.optimal_space||`O(1)`,how_to_solve:e.how_to_solve||``,examples:a,constraints:c,solutions:i,is_enrolled:t,is_custom:!0,fsrs_state:e.fsrs_state??(t?0:null),fsrs_step:e.fsrs_step??0,fsrs_stability:e.fsrs_stability??0,fsrs_difficulty:e.fsrs_difficulty??0,fsrs_elapsed_days:e.fsrs_elapsed_days??0,fsrs_scheduled_days:e.fsrs_scheduled_days??0,fsrs_reps:e.fsrs_reps??0,fsrs_lapses:e.fsrs_lapses??0,next_review:e.next_review??null,last_reviewed:e.last_reviewed??null,times_correct:e.times_correct??0,total_attempts:e.total_attempts??0,is_due:r})}return s}async function y(e){if(e.length===0)return!0;let t=await g(),n=await fetch(`/api/reviews/reset`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${t}`},body:JSON.stringify({problem_ids:e})});if(!n.ok){let e=await n.json().catch(()=>({detail:`Failed to reset reviews`}));throw Error(e.detail||`Failed to reset reviews`)}return!0}async function b(e){let t=await g(),n=await fetch(`/api/explorer/problems/${e}`,{method:`DELETE`,headers:{Authorization:`Bearer ${t}`}});if(!n.ok){let e=await n.json().catch(()=>({detail:`Failed to delete problem`}));throw Error(e.detail||`Failed to delete problem`)}return!0}async function ue(e){let t=0;for(let n of e)try{await b(n),t++}catch{}return t}async function x(e){return e.length===0?0:(await m(e)).enrolled_count}var S=r();function C({onOpenQueue:e,onOpenCreateProblem:r,onOpenEditProblem:a,onSelectProblemForReview:p,refreshTrigger:ce,onRefreshExplorer:m}){let[g,_]=(0,h.useState)([]),[v,C]=(0,h.useState)(!0),[de,w]=(0,h.useState)(null),[T,fe]=(0,h.useState)(``),[E,D]=(0,h.useState)(`all`),[O,pe]=(0,h.useState)(`ALL`),[k,me]=(0,h.useState)(`ALL`),[A,he]=(0,h.useState)(`number`),[j,M]=(0,h.useState)(`asc`),[N,P]=(0,h.useState)(new Set),[F,I]=(0,h.useState)(null),[L,R]=(0,h.useState)(`front`),[z,B]=(0,h.useState)(!1),[V,H]=(0,h.useState)(!1),[ge,U]=(0,h.useState)(null),[W,G]=(0,h.useState)(`table`),K=(0,h.useCallback)(async()=>{C(!0),w(null);try{let e=await le();_(e),e.length>0&&!F&&I(e[0].id)}catch(e){let t=e instanceof Error?e.message:`Failed to load card database`;w(t)}finally{C(!1)}},[F]);(0,h.useEffect)(()=>{K()},[K,ce]);let q=(0,h.useMemo)(()=>{let e=0,t=0,n=0,r=0,i=0,a=0;for(let o of g)if(o.is_enrolled){t++,o.is_due&&e++;let n=o.fsrs_state??0;n===1?r++:n===2?i++:n===3&&a++}else n++;return{total:g.length,due:e,enrolled:t,newCards:n,learning:r,reviewing:i,relearning:a}},[g]),_e=(0,h.useMemo)(()=>{let e=new Map;for(let t of g)e.set(t.pattern,(e.get(t.pattern)||0)+1);let t=Array.from(e.entries()).map(([e,t])=>({pattern:e,count:t}));return t.sort((e,t)=>e.pattern.localeCompare(t.pattern)),t},[g]),ve=(0,h.useMemo)(()=>{let e=T.trim().toLowerCase();return g.filter(t=>{if(E===`due`&&!t.is_due||E===`enrolled`&&!t.is_enrolled||E===`new`&&t.is_enrolled||E===`learning`&&(!t.is_enrolled||t.fsrs_state!==1)||E===`reviewing`&&(!t.is_enrolled||t.fsrs_state!==2)||E===`relearning`&&(!t.is_enrolled||t.fsrs_state!==3)||O!==`ALL`&&t.pattern!==O||k!==`ALL`&&t.difficulty!==k)return!1;if(e){let n=t.problem_number?String(t.problem_number).includes(e):!1,r=t.name.toLowerCase().includes(e),i=t.pattern.toLowerCase().includes(e),a=t.difficulty.toLowerCase().includes(e);if(!n&&!r&&!i&&!a)return!1}return!0})},[g,E,O,k,T]),J=(0,h.useMemo)(()=>{let e=[...ve];return e.sort((e,t)=>{let n=0;switch(A){case`number`:n=(e.problem_number??999999)-(t.problem_number??999999);break;case`name`:n=e.name.localeCompare(t.name);break;case`pattern`:n=e.pattern.localeCompare(t.pattern);break;case`difficulty`:{let r={Easy:1,Medium:2,Hard:3};n=(r[e.difficulty]||2)-(r[t.difficulty]||2);break}case`state`:n=(e.fsrs_state??-1)-(t.fsrs_state??-1);break;case`due`:n=(e.next_review?new Date(e.next_review).getTime():9999999999999)-(t.next_review?new Date(t.next_review).getTime():9999999999999);break;case`retention`:n=(e.total_attempts>0?e.times_correct/e.total_attempts:0)-(t.total_attempts>0?t.times_correct/t.total_attempts:0)}return j===`asc`?n:-n}),e},[ve,A,j]),Y=(0,h.useMemo)(()=>!F&&J.length>0?J[0]:g.find(e=>e.id===F)||J[0]||null,[g,F,J]),X=e=>{A===e?M(e=>e===`asc`?`desc`:`asc`):(he(e),M(`asc`))},ye=(e,t)=>{t.stopPropagation(),P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},be=(0,h.useMemo)(()=>J.length>0&&J.every(e=>N.has(e.id)),[J,N]),xe=()=>{P(e=>{let t=new Set(e);if(be)for(let e of J)t.delete(e.id);else for(let e of J)t.add(e.id);return t})},Z=(0,h.useMemo)(()=>g.filter(e=>N.has(e.id)&&e.is_custom),[g,N]),Se=async()=>{if(Z.length!==0&&confirm(`Are you sure you want to delete ${Z.length} custom cards?`)){H(!0);try{let e=await ue(Z.map(e=>e.id));U(`Deleted ${e} custom cards.`),P(e=>{let t=new Set(e);for(let e of Z)t.delete(e.id);return t}),await K(),m?.()}catch(e){let t=e instanceof Error?e.message:`Batch delete failed`;w(t)}finally{H(!1),setTimeout(()=>U(null),3500)}}},Ce=async()=>{let e=g.filter(e=>N.has(e.id)&&!e.is_enrolled&&e.catalogProblem);if(e.length===0){U(`No unenrolled catalog cards in current selection.`),setTimeout(()=>U(null),3e3);return}H(!0);try{let t=await x(e.map(e=>e.catalogProblem));U(`Enrolled ${t} cards into Daily Queue!`),P(new Set),await K(),m?.()}catch(e){let t=e instanceof Error?e.message:`Enrollment failed`;w(t)}finally{H(!1),setTimeout(()=>U(null),3500)}},we=async()=>{let e=g.filter(e=>N.has(e.id)&&e.is_enrolled);if(e.length===0){U(`No active cards in selection to reset.`),setTimeout(()=>U(null),3e3);return}H(!0);try{await y(e.map(e=>e.id)),U(`Reset ${e.length} cards to initial FSRS state due today!`),P(new Set),await K(),m?.()}catch(e){let t=e instanceof Error?e.message:`Reset failed`;w(t)}finally{H(!1),setTimeout(()=>U(null),3500)}},Te=async e=>{H(!0);try{await y([e.id]),U(`Reset #${e.problem_number??`—`} ${e.name} for FSRS!`),await K(),m?.()}catch(e){let t=e instanceof Error?e.message:`Reset failed`;w(t)}finally{H(!1),setTimeout(()=>U(null),3500)}},Ee=async e=>{if(e.catalogProblem){H(!0);try{await x([e.catalogProblem]),U(`Enrolled #${e.problem_number??`—`} ${e.name} into review queue!`),await K(),m?.()}catch(e){let t=e instanceof Error?e.message:`Enrollment failed`;w(t)}finally{H(!1),setTimeout(()=>U(null),3500)}}},De=async e=>{if(confirm(`Are you sure you want to delete custom card "${e.name}"?`)){H(!0);try{await b(e.id),U(`Deleted custom card "${e.name}"`),await K(),m?.()}catch(e){let t=e instanceof Error?e.message:`Delete failed`;w(t)}finally{H(!1),setTimeout(()=>U(null),3500)}}},Q=(0,h.useCallback)(t=>{p(t.id),e()},[p,e]),$=e=>{a({id:e.id,name:e.name,problem_number:e.problem_number,pattern:e.pattern,difficulty:e.difficulty,description:e.description,examples:e.examples,constraints:e.constraints,optimal_time:e.optimal_time,optimal_space:e.optimal_space,starter_code:e.starter_code,reference_code:e.reference_code,how_to_solve:e.how_to_solve,solutions:e.solutions})},Oe=()=>{Y?.reference_code&&(navigator.clipboard.writeText(Y.reference_code),B(!0),setTimeout(()=>B(!1),2e3))},ke=(e,t,n)=>{if(!n)return`Not enrolled`;if(!e)return`Due now`;if(t)return`Due today`;let r=new Date(e),i=new Date,a=Math.ceil((r.getTime()-i.getTime())/864e5);return a<=1?`Tomorrow`:`In ${a}d`};return(0,h.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable||J.length===0)return;let n=J.findIndex(e=>e.id===Y?.id);if(e.key===`ArrowDown`){e.preventDefault();let t=n<J.length-1?n+1:0;I(J[t].id)}else if(e.key===`ArrowUp`){e.preventDefault();let t=n>0?n-1:J.length-1;I(J[t].id)}else e.key===` `||e.code===`Space`?(e.preventDefault(),R(e=>e===`front`?`back`:`front`)):e.key===`Enter`&&Y?.is_enrolled&&(e.preventDefault(),Q(Y))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[J,Y,Q]),(0,S.jsxs)(`div`,{className:`w-full h-full flex flex-col bg-[#fdf8e1] font-sans text-ink-black select-none overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`bg-slate-900 text-white border-b-[3px] border-ink-black px-4 py-2.5 flex flex-wrap items-center justify-between gap-3 shrink-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,S.jsx)(`div`,{className:`w-8 h-8 rounded bg-sky-500 border-2 border-white flex items-center justify-center shadow-[2px_2px_0px_0px_rgba(0,0,0,0.5)]`,children:(0,S.jsx)(ae,{className:`w-5 h-5 text-white stroke-[2.5]`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`font-arcade text-xs sm:text-sm font-bold tracking-wider text-amber-300 uppercase flex items-center gap-1.5`,children:`MANAGE FSRS`}),(0,S.jsx)(`p`,{className:`text-[10px] text-slate-300 font-mono`,children:`Browse, filter, and reschedule spaced-repetition cards`})]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap text-[10px] font-mono`,children:[(0,S.jsxs)(`button`,{onClick:()=>D(`all`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${E===`all`?`bg-sky-500 text-white font-bold`:`bg-slate-800 text-slate-300 hover:bg-slate-700`}`,children:[`Total: `,(0,S.jsx)(`span`,{className:`font-bold`,children:q.total})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`due`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${E===`due`?`bg-rose-500 text-white font-bold`:`bg-slate-800 text-rose-300 hover:bg-slate-700`}`,children:[`Due Today: `,(0,S.jsx)(`span`,{className:`font-bold`,children:q.due})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`enrolled`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${E===`enrolled`?`bg-emerald-600 text-white font-bold`:`bg-slate-800 text-emerald-300 hover:bg-slate-700`}`,children:[`In Review: `,(0,S.jsx)(`span`,{className:`font-bold`,children:q.enrolled})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`learning`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${E===`learning`?`bg-amber-500 text-slate-900 font-bold`:`bg-slate-800 text-amber-300 hover:bg-slate-700`}`,children:[`Learning: `,(0,S.jsx)(`span`,{className:`font-bold`,children:q.learning})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`reviewing`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${E===`reviewing`?`bg-emerald-600 text-white font-bold`:`bg-slate-800 text-emerald-300 hover:bg-slate-700`}`,children:[`Review: `,(0,S.jsx)(`span`,{className:`font-bold`,children:q.reviewing})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`relearning`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${E===`relearning`?`bg-rose-600 text-white font-bold`:`bg-slate-800 text-rose-300 hover:bg-slate-700`}`,children:[`Relearning: `,(0,S.jsx)(`span`,{className:`font-bold`,children:q.relearning})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`new`),className:`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${E===`new`?`bg-indigo-600 text-white font-bold`:`bg-slate-800 text-indigo-300 hover:bg-slate-700`}`,children:[`Unenrolled: `,(0,S.jsx)(`span`,{className:`font-bold`,children:q.newCards})]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsxs)(`button`,{onClick:r,className:`px-2.5 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black border-2 border-white rounded font-arcade text-[9px] font-bold shadow-[2px_2px_0px_0px_rgba(0,0,0,0.5)] active:translate-y-0.5 cursor-pointer flex items-center gap-1`,children:[(0,S.jsx)(re,{className:`w-3.5 h-3.5`}),(0,S.jsx)(`span`,{children:`ADD CARD`})]}),(0,S.jsx)(`button`,{onClick:K,disabled:v,className:`p-1 bg-slate-800 hover:bg-slate-700 text-slate-200 border border-slate-600 rounded cursor-pointer disabled:opacity-50`,title:`Refresh Deck`,children:(0,S.jsx)(o,{className:`w-3.5 h-3.5 ${v?`animate-spin`:``}`})})]})]}),ge&&(0,S.jsxs)(`div`,{className:`bg-amber-300 border-b-2 border-ink-black px-4 py-1.5 text-xs font-bold text-ink-black flex items-center justify-between shrink-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(oe,{className:`w-4 h-4 text-amber-800`}),(0,S.jsx)(`span`,{children:ge})]}),(0,S.jsx)(`button`,{onClick:()=>U(null),className:`text-xs hover:opacity-75 cursor-pointer`,children:`✕`})]}),de&&(0,S.jsxs)(`div`,{className:`bg-rose-100 border-b-2 border-rose-400 px-4 py-1.5 text-xs font-semibold text-rose-800 flex items-center justify-between shrink-0`,children:[(0,S.jsx)(`span`,{children:de}),(0,S.jsx)(`button`,{onClick:()=>w(null),className:`text-xs hover:opacity-75 cursor-pointer`,children:`✕`})]}),(0,S.jsxs)(`div`,{className:`sm:hidden flex border-b-2 border-ink-black bg-white shrink-0`,children:[(0,S.jsxs)(`button`,{onClick:()=>G(`table`),className:`flex-1 py-2 font-arcade text-[10px] font-bold text-center border-r border-ink-black ${W===`table`?`bg-amber-300 text-ink-black`:`text-slate-600`}`,children:[`CARDS LIST (`,J.length,`)`]}),(0,S.jsxs)(`button`,{onClick:()=>G(`inspector`),className:`flex-1 py-2 font-arcade text-[10px] font-bold text-center ${W===`inspector`?`bg-amber-300 text-ink-black`:`text-slate-600`}`,children:[`INSPECTOR `,Y?`#${Y.problem_number??``}`:``]})]}),(0,S.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[(0,S.jsxs)(`aside`,{className:`w-56 bg-[#f7f0cf] border-r-[3px] border-ink-black flex flex-col shrink-0 overflow-y-auto custom-scrollbar hidden md:flex`,children:[(0,S.jsx)(`div`,{className:`p-3 border-b-2 border-ink-black/20`,children:(0,S.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase tracking-wider flex items-center gap-1.5`,children:[(0,S.jsx)(t,{className:`w-3.5 h-3.5 text-amber-700`}),` DECKS & STATES`]})}),(0,S.jsxs)(`div`,{className:`p-2 space-y-1 text-xs`,children:[(0,S.jsxs)(`button`,{onClick:()=>D(`all`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${E===`all`?`bg-ink-black text-amber-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,S.jsx)(`span`,{children:`📁 All Cards`}),(0,S.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.total})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`due`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${E===`due`?`bg-ink-black text-rose-300 font-bold`:`hover:bg-amber-200/60 text-rose-900 font-semibold`}`,children:[(0,S.jsx)(`span`,{className:`flex items-center gap-1`,children:`⏰ Due Today`}),(0,S.jsx)(`span`,{className:`font-mono text-[10px] font-bold text-rose-600`,children:q.due})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`enrolled`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${E===`enrolled`?`bg-ink-black text-emerald-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,S.jsx)(`span`,{children:`📥 In Review`}),(0,S.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.enrolled})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`new`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${E===`new`?`bg-ink-black text-sky-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,S.jsx)(`span`,{children:`🆕 Unenrolled (Catalog)`}),(0,S.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.newCards})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`learning`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${E===`learning`?`bg-ink-black text-amber-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,S.jsx)(`span`,{children:`🔄 Learning (State 1)`}),(0,S.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.learning})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`reviewing`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${E===`reviewing`?`bg-ink-black text-emerald-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,S.jsx)(`span`,{children:`📈 Review (State 2)`}),(0,S.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.reviewing})]}),(0,S.jsxs)(`button`,{onClick:()=>D(`relearning`),className:`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${E===`relearning`?`bg-ink-black text-rose-300 font-bold`:`hover:bg-amber-200/60 text-ink-black font-semibold`}`,children:[(0,S.jsx)(`span`,{children:`🔁 Relearning (State 3)`}),(0,S.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:q.relearning})]})]}),(0,S.jsx)(`div`,{className:`p-3 border-t-2 border-ink-black/20`,children:(0,S.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase tracking-wider flex items-center gap-1.5`,children:[(0,S.jsx)(ne,{className:`w-3.5 h-3.5 text-purple-700`}),` PATTERNS (TAGS)`]})}),(0,S.jsxs)(`div`,{className:`p-2 space-y-0.5 text-xs flex-1`,children:[(0,S.jsxs)(`button`,{onClick:()=>pe(`ALL`),className:`w-full text-left px-2.5 py-1 rounded flex items-center justify-between cursor-pointer transition-colors ${O===`ALL`?`bg-purple-900 text-white font-bold`:`hover:bg-purple-100 text-ink-black font-semibold`}`,children:[(0,S.jsx)(`span`,{children:`All Patterns`}),(0,S.jsx)(`span`,{className:`font-mono text-[10px] opacity-80`,children:g.length})]}),_e.map(({pattern:e,count:t})=>(0,S.jsxs)(`button`,{onClick:()=>pe(e),className:`w-full text-left px-2.5 py-1 rounded flex items-center justify-between cursor-pointer transition-colors text-[11px] ${O===e?`bg-purple-900 text-white font-bold`:`hover:bg-purple-100 text-ink-black`}`,children:[(0,S.jsx)(`span`,{className:`truncate`,children:e}),(0,S.jsx)(`span`,{className:`font-mono text-[10px] opacity-80 shrink-0 ml-1`,children:t})]},e))]})]}),(0,S.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 bg-white border-r-[3px] border-ink-black ${W===`inspector`?`hidden sm:flex`:`flex`}`,children:[(0,S.jsxs)(`div`,{className:`p-3 bg-[#fdf8e1] border-b-2 border-ink-black flex flex-wrap items-center justify-between gap-2 shrink-0`,children:[(0,S.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,S.jsx)(l,{className:`w-4 h-4 absolute left-2.5 top-2.5 text-slate-500`}),(0,S.jsx)(`input`,{type:`text`,value:T,onChange:e=>fe(e.target.value),placeholder:`Search by card #, title, pattern, or keyword...`,className:`w-full pl-8 pr-3 py-1.5 bg-white border-2 border-ink-black text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-sky-500 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`}),T&&(0,S.jsx)(`button`,{onClick:()=>fe(``),className:`absolute right-2.5 top-2 text-slate-400 hover:text-ink-black text-xs cursor-pointer`,children:`✕`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsxs)(`select`,{"aria-label":`Filter cards by difficulty`,value:k,onChange:e=>me(e.target.value),className:`px-2.5 py-1.5 bg-white border-2 border-ink-black text-xs font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] cursor-pointer`,children:[(0,S.jsx)(`option`,{value:`ALL`,children:`All Difficulties`}),(0,S.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,S.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,S.jsx)(`option`,{value:`Hard`,children:`Hard`})]}),(0,S.jsxs)(`span`,{className:`text-[11px] font-mono text-slate-600 font-semibold hidden lg:inline`,children:[J.length,` matching cards`]})]})]}),N.size>0&&(0,S.jsxs)(`div`,{className:`bg-sky-100 border-b-2 border-ink-black px-3 py-2 flex items-center justify-between gap-2 shrink-0 animate-in fade-in flex-wrap`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsxs)(`span`,{className:`font-arcade text-[10px] font-bold text-sky-900 uppercase`,children:[N.size,` SELECTED`,Z.length>0&&` (${Z.length} custom)`]}),(0,S.jsx)(`button`,{onClick:()=>P(new Set),className:`text-xs text-sky-800 underline hover:text-sky-950 cursor-pointer`,children:`Clear`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,S.jsxs)(`button`,{onClick:Ce,disabled:V,className:`px-3 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,S.jsx)(ee,{className:`w-3.5 h-3.5 text-amber-900`}),(0,S.jsx)(`span`,{children:`ADD TO QUEUE`})]}),(0,S.jsxs)(`button`,{onClick:we,disabled:V,className:`px-3 py-1 bg-amber-300 hover:bg-amber-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,S.jsx)(n,{className:`w-3.5 h-3.5`}),(0,S.jsx)(`span`,{children:`RESET PROGRESS`})]}),Z.length>0&&(0,S.jsxs)(`button`,{onClick:Se,disabled:V,className:`px-3 py-1 bg-rose-200 hover:bg-rose-300 text-rose-950 font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,S.jsx)(d,{className:`w-3.5 h-3.5 text-rose-700`}),(0,S.jsxs)(`span`,{children:[`DELETE CUSTOM (`,Z.length,`)`]})]})]})]}),(0,S.jsx)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar`,children:(0,S.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,S.jsx)(`thead`,{className:`sticky top-0 bg-[#f4ebd0] border-b-2 border-ink-black font-arcade text-[9px] font-bold text-ink-black z-10 select-none`,children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{className:`p-2 w-8 text-center border-r border-ink-black/20`,children:(0,S.jsx)(`button`,{onClick:xe,className:`cursor-pointer flex items-center justify-center mx-auto text-ink-black`,title:`Select all matching cards`,children:be?(0,S.jsx)(te,{className:`w-4 h-4 text-sky-700`}):(0,S.jsx)(f,{className:`w-4 h-4`})})}),(0,S.jsx)(`th`,{onClick:()=>X(`number`),className:`p-2 w-16 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{children:`#`}),(0,S.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,S.jsx)(`th`,{onClick:()=>X(`name`),className:`p-2 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{children:`CARD TITLE`}),(0,S.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,S.jsx)(`th`,{onClick:()=>X(`pattern`),className:`p-2 hidden md:table-cell cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{children:`DECK / PATTERN`}),(0,S.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,S.jsx)(`th`,{onClick:()=>X(`difficulty`),className:`p-2 w-20 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{children:`DIFF`}),(0,S.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,S.jsx)(`th`,{onClick:()=>X(`state`),className:`p-2 w-24 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{children:`FSRS STATE`}),(0,S.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,S.jsx)(`th`,{onClick:()=>X(`due`),className:`p-2 w-24 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{children:`DUE`}),(0,S.jsx)(i,{className:`w-3 h-3 opacity-60`})]})}),(0,S.jsx)(`th`,{onClick:()=>X(`retention`),className:`p-2 w-20 hidden lg:table-cell cursor-pointer hover:bg-amber-200/50`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{children:`RETENTION`}),(0,S.jsx)(i,{className:`w-3 h-3 opacity-60`})]})})]})}),(0,S.jsx)(`tbody`,{className:`divide-y divide-slate-200`,children:J.length===0?(0,S.jsx)(`tr`,{children:(0,S.jsx)(`td`,{colSpan:8,className:`p-8 text-center text-trash-gray font-mono`,children:`No cards match current filter criteria.`})}):J.map(e=>{let t=N.has(e.id),n=Y?.id===e.id;return(0,S.jsxs)(`tr`,{onClick:()=>{I(e.id),G(`inspector`)},onDoubleClick:()=>{e.is_enrolled?Q(e):$(e)},className:`cursor-pointer transition-colors ${n?`bg-sky-100 font-semibold`:t?`bg-amber-50`:`hover:bg-slate-50`}`,children:[(0,S.jsx)(`td`,{className:`p-2 text-center`,onClick:t=>ye(e.id,t),children:t?(0,S.jsx)(te,{className:`w-4 h-4 text-sky-600 mx-auto`}):(0,S.jsx)(f,{className:`w-4 h-4 text-slate-400 mx-auto`})}),(0,S.jsx)(`td`,{className:`p-2 font-mono text-[11px] font-bold text-slate-700`,children:e.problem_number?`#${e.problem_number}`:`—`}),(0,S.jsx)(`td`,{className:`p-2`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`font-semibold text-ink-black truncate`,children:e.name}),e.is_custom&&(0,S.jsx)(`span`,{className:`px-1.5 py-0.2 rounded bg-purple-100 text-purple-800 border border-purple-300 text-[8px] font-bold uppercase shrink-0`,children:`CUSTOM`})]})}),(0,S.jsx)(`td`,{className:`p-2 hidden md:table-cell text-slate-600 text-[11px] truncate`,children:e.pattern}),(0,S.jsx)(`td`,{className:`p-2`,children:(0,S.jsx)(`span`,{className:`px-1.5 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${e.difficulty===`Easy`?`bg-emerald-600`:e.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:e.difficulty})}),(0,S.jsx)(`td`,{className:`p-2`,children:e.is_enrolled?(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[10px] font-bold text-slate-800`,children:[(0,S.jsx)(`span`,{className:`w-2 h-2 rounded-full ${(e.fsrs_state??0)===2?`bg-emerald-500`:(e.fsrs_state??0)===1?`bg-amber-500`:(e.fsrs_state??0)===3?`bg-rose-500`:`bg-blue-500`}`}),(e.fsrs_state??0)===0?`New`:(e.fsrs_state??0)===1?`Learning`:(e.fsrs_state??0)===2?`Review`:`Relearning`]}):(0,S.jsx)(`span`,{className:`text-[10px] font-mono text-slate-400 uppercase font-semibold`,children:`Unenrolled`})}),(0,S.jsx)(`td`,{className:`p-2 font-mono text-[10px]`,children:(0,S.jsx)(`span`,{className:e.is_due?`text-rose-600 font-bold bg-rose-50 px-1 py-0.5 rounded border border-rose-200`:`text-slate-600`,children:ke(e.next_review,e.is_due,e.is_enrolled)})}),(0,S.jsx)(`td`,{className:`p-2 hidden lg:table-cell font-mono text-[10px] text-slate-600`,children:e.total_attempts>0?(0,S.jsxs)(`span`,{children:[e.times_correct,`/`,e.total_attempts,` `,(0,S.jsxs)(`span`,{className:`text-[9px] text-slate-400`,children:[`(`,Math.round(e.times_correct/e.total_attempts*100),`%)`]})]}):(0,S.jsx)(`span`,{className:`text-slate-400`,children:`—`})})]},e.id)})})]})})]}),(0,S.jsx)(`aside`,{className:`w-full sm:w-80 lg:w-96 bg-[#fdf8e1] flex flex-col shrink-0 overflow-hidden ${W===`table`?`hidden sm:flex`:`flex`}`,children:Y?(0,S.jsxs)(`div`,{className:`flex-1 flex flex-col h-full overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`p-4 bg-[#f8efcd] border-b-2 border-ink-black space-y-2 shrink-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-amber-900 uppercase flex items-center gap-1`,children:[(0,S.jsx)(u,{className:`w-3.5 h-3.5 text-amber-700`}),` CARD INSPECTOR`]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{className:`px-1.5 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${Y.difficulty===`Easy`?`bg-emerald-600`:Y.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:Y.difficulty}),(0,S.jsx)(`span`,{className:`font-mono text-[10px] font-bold px-1.5 py-0.5 bg-white border border-ink-black rounded`,children:Y.problem_number?`#${Y.problem_number}`:`Custom`})]})]}),(0,S.jsx)(`h3`,{className:`font-headline-md text-base font-extrabold text-ink-black leading-tight`,children:Y.name}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap text-[10px] font-mono text-slate-700`,children:[(0,S.jsx)(`span`,{className:`bg-purple-100 text-purple-900 px-2 py-0.5 rounded border border-purple-200 font-semibold`,children:Y.pattern}),Y.optimal_time&&(0,S.jsxs)(`span`,{className:`bg-slate-100 px-1.5 py-0.5 rounded border border-slate-300`,children:[`T: `,Y.optimal_time]}),Y.optimal_space&&(0,S.jsxs)(`span`,{className:`bg-slate-100 px-1.5 py-0.5 rounded border border-slate-300`,children:[`S: `,Y.optimal_space]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 pt-2 flex-wrap`,children:[Y.is_enrolled?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{onClick:()=>Q(Y),className:`px-2.5 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1`,children:[(0,S.jsx)(s,{className:`w-3 h-3 fill-ink-black`}),(0,S.jsx)(`span`,{children:`REVIEW NOW`})]}),(0,S.jsxs)(`button`,{onClick:()=>Te(Y),disabled:V,className:`px-2 py-1 bg-amber-200 hover:bg-amber-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,title:`Reset interval to initial FSRS state due today`,children:[(0,S.jsx)(n,{className:`w-3 h-3`}),(0,S.jsx)(`span`,{children:`RESET`})]})]}):(0,S.jsxs)(`button`,{onClick:()=>Ee(Y),disabled:V||!Y.catalogProblem,className:`px-2.5 py-1 bg-sky-400 hover:bg-sky-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,S.jsx)(re,{className:`w-3 h-3`}),(0,S.jsx)(`span`,{children:`ENROLL CARD`})]}),(0,S.jsxs)(`button`,{onClick:()=>$(Y),className:`px-2 py-1 bg-white hover:bg-slate-100 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1`,children:[(0,S.jsx)(se,{className:`w-3 h-3`}),(0,S.jsx)(`span`,{children:`EDIT`})]}),Y.is_custom&&(0,S.jsxs)(`button`,{onClick:()=>De(Y),disabled:V,className:`px-2 py-1 bg-rose-200 hover:bg-rose-300 text-rose-950 font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50`,children:[(0,S.jsx)(d,{className:`w-3 h-3 text-rose-700`}),(0,S.jsx)(`span`,{children:`DELETE`})]})]})]}),(0,S.jsxs)(`div`,{className:`flex border-b-2 border-ink-black bg-white shrink-0`,children:[(0,S.jsx)(`button`,{onClick:()=>R(`front`),className:`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center border-r border-ink-black/20 cursor-pointer ${L===`front`?`bg-amber-300 text-ink-black`:`text-slate-600 hover:bg-slate-50`}`,children:`QUESTION`}),(0,S.jsx)(`button`,{onClick:()=>R(`back`),className:`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center border-r border-ink-black/20 cursor-pointer ${L===`back`?`bg-amber-300 text-ink-black`:`text-slate-600 hover:bg-slate-50`}`,children:`SHOW ANSWER`}),(0,S.jsx)(`button`,{onClick:()=>R(`stats`),className:`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center cursor-pointer ${L===`stats`?`bg-amber-300 text-ink-black`:`text-slate-600 hover:bg-slate-50`}`,children:`SRS INFO`})]}),(0,S.jsxs)(`div`,{className:`flex-1 p-4 overflow-y-auto custom-scrollbar space-y-4`,children:[L===`front`&&(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`PROBLEM DESCRIPTION`}),(0,S.jsx)(`div`,{className:`p-3 bg-white border-2 border-ink-black text-xs font-semibold leading-relaxed shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] whitespace-pre-wrap`,children:Y.description||`No description provided.`})]}),Y.examples&&(!Array.isArray(Y.examples)||Y.examples.length>0)&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`EXAMPLES`}),(0,S.jsx)(`div`,{className:`space-y-1.5`,children:Array.isArray(Y.examples)?Y.examples.map((e,t)=>typeof e==`string`?(0,S.jsx)(`div`,{className:`p-2 bg-white border border-slate-300 text-[11px] font-mono`,children:e},t):(0,S.jsxs)(`div`,{className:`p-2 bg-white border border-slate-300 text-[11px] font-mono space-y-0.5`,children:[e.input&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-bold text-slate-700`,children:`Input:`}),` `,e.input]}),e.output&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-bold text-slate-700`,children:`Output:`}),` `,e.output]}),e.explanation&&(0,S.jsx)(`div`,{className:`text-slate-500 italic text-[10px]`,children:e.explanation})]},t)):(0,S.jsx)(`div`,{className:`p-2 bg-white border border-slate-300 text-[11px] font-mono`,children:String(Y.examples)})})]}),Y.constraints&&(!Array.isArray(Y.constraints)||Y.constraints.length>0)&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`CONSTRAINTS`}),(0,S.jsx)(`div`,{className:`p-2.5 bg-slate-50 border border-slate-300 text-[11px] font-mono space-y-1 text-slate-700`,children:Array.isArray(Y.constraints)?Y.constraints.map((e,t)=>(0,S.jsxs)(`div`,{children:[`• `,e]},t)):(0,S.jsxs)(`div`,{children:[`• `,String(Y.constraints)]})})]})]}),L===`back`&&(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase`,children:`REFERENCE SOLUTION (PYTHON)`}),Y.reference_code&&(0,S.jsxs)(`button`,{onClick:Oe,className:`px-2 py-0.5 bg-white hover:bg-slate-100 text-ink-black border border-ink-black text-[9px] font-bold rounded flex items-center gap-1 cursor-pointer`,children:[z?(0,S.jsx)(c,{className:`w-3 h-3 text-emerald-600`}):(0,S.jsx)(ie,{className:`w-3 h-3`}),(0,S.jsx)(`span`,{children:z?`COPIED!`:`COPY`})]})]}),(0,S.jsx)(`div`,{className:`relative`,children:(0,S.jsx)(`pre`,{className:`p-3 bg-slate-900 text-emerald-400 font-mono text-[11px] rounded border-2 border-ink-black overflow-x-auto shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:(0,S.jsx)(`code`,{children:Y.reference_code||`# No reference code available.`})})}),Y.how_to_solve&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1`,children:`HOW TO SOLVE & STRATEGY`}),(0,S.jsx)(`div`,{className:`p-2.5 bg-white border border-slate-300 text-xs font-semibold leading-relaxed`,children:Y.how_to_solve})]})]}),L===`stats`&&(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`p-3 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-2`,children:[(0,S.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase block border-b pb-1`,children:`FSRS REVIEW STATE`}),(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Current State`}),(0,S.jsx)(`div`,{className:`font-arcade text-base font-bold text-sky-700`,children:Y.is_enrolled?(Y.fsrs_state??0)===0?`New (0)`:(Y.fsrs_state??0)===1?`Learning (1)`:(Y.fsrs_state??0)===2?`Review (2)`:`Relearning (3)`:`Unenrolled`})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Status`}),(0,S.jsx)(`div`,{className:`font-arcade text-xs font-bold text-emerald-700`,children:Y.is_due?`Due Today`:Y.is_enrolled?`Scheduled`:`Catalog New`})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Stability`}),(0,S.jsx)(`div`,{className:`font-mono text-sm font-bold text-slate-800`,children:Y.fsrs_stability===void 0?`0.0d`:`${Y.fsrs_stability.toFixed(1)}d`})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Difficulty`}),(0,S.jsx)(`div`,{className:`font-mono text-sm font-bold text-amber-700`,children:Y.fsrs_difficulty===void 0?`0.0/10`:`${Y.fsrs_difficulty.toFixed(1)}/10`})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Total Attempts`}),(0,S.jsx)(`div`,{className:`font-mono text-sm font-bold text-slate-800`,children:Y.total_attempts})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Times Correct`}),(0,S.jsx)(`div`,{className:`font-mono text-sm font-bold text-emerald-600`,children:Y.times_correct})]}),(0,S.jsxs)(`div`,{className:`col-span-2 pt-1 border-t border-slate-200`,children:[(0,S.jsx)(`div`,{className:`text-[10px] text-trash-gray font-semibold`,children:`Retention Success Rate`}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,S.jsx)(`div`,{className:`flex-1 h-3 bg-slate-200 rounded-full overflow-hidden border border-slate-300`,children:(0,S.jsx)(`div`,{className:`h-full bg-emerald-500 rounded-full`,style:{width:`${Y.total_attempts>0?Math.round(Y.times_correct/Y.total_attempts*100):0}%`}})}),(0,S.jsx)(`span`,{className:`font-mono text-xs font-bold text-slate-800`,children:Y.total_attempts>0?`${Math.round(Y.times_correct/Y.total_attempts*100)}%`:`0%`})]})]})]})]}),(0,S.jsxs)(`div`,{className:`p-3 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-1.5 text-xs`,children:[(0,S.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase block border-b pb-1`,children:`TIMESTAMPS`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between text-slate-700`,children:[(0,S.jsx)(`span`,{className:`text-[11px] font-semibold`,children:`Next Review:`}),(0,S.jsx)(`span`,{className:`font-mono text-[10px]`,children:Y.next_review?new Date(Y.next_review).toLocaleString():`Not scheduled`})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between text-slate-700`,children:[(0,S.jsx)(`span`,{className:`text-[11px] font-semibold`,children:`Last Reviewed:`}),(0,S.jsx)(`span`,{className:`font-mono text-[10px]`,children:Y.last_reviewed?new Date(Y.last_reviewed).toLocaleString():`Never`})]})]})]})]})]}):(0,S.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-6 text-center text-trash-gray font-mono text-xs`,children:`Select a card to view its Front, Back, and SRS details.`})})]})]})}export{C as default};
algospaced-ui/dist/assets/{CreateProblemForm-Cej3QR08.js → CreateProblemForm-Ccz3TNzp.js} RENAMED
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Rt as n}from"./vendor-react-CIO8MTK1.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(t(),1),a=n(),o=[`Arrays & Hashing`,`Two Pointers`,`Sliding Window`,`Stack`,`Binary Search`,`Linked List`,`Trees`,`Tries`,`Heap / Priority Queue`,`Backtracking`,`Graphs`,`Advanced Graphs`,`1-D Dynamic Programming`,`2-D Dynamic Programming`,`Greedy`,`Intervals`,`Math & Geometry`,`Bit Manipulation`];function s(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`sol-${crypto.randomUUID()}`:`sol-${Date.now()}`}function c({onClose:e,onSuccess:t,initialProblem:n,mode:c=n?`edit`:`create`}){let l=c===`edit`||!!n,[u,d]=(0,i.useState)(`form`),[f,p]=(0,i.useState)(``),[ee,m]=(0,i.useState)(!1),[h,g]=(0,i.useState)(()=>{if(n?.name)return n.name;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).name||``}catch{}return``}),[_,v]=(0,i.useState)(()=>n?.problem_number!==void 0&&n?.problem_number!==null?n.problem_number:``),[y,b]=(0,i.useState)(()=>{if(n?.pattern)return n.pattern;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).pattern||``}catch{}return`Arrays & Hashing`}),[x,S]=(0,i.useState)(()=>n?.difficulty===`Easy`||n?.difficulty===`Medium`||n?.difficulty===`Hard`?n.difficulty:`Medium`),[C,w]=(0,i.useState)(()=>n?.optimal_time||`O(N)`),[T,E]=(0,i.useState)(()=>n?.optimal_space||`O(1)`),[D,O]=(0,i.useState)(()=>n?.description||``),[k,A]=(0,i.useState)(()=>n?.examples&&Array.isArray(n.examples)&&n.examples.length>0?n.examples.map(e=>typeof e==`string`?{input:e,output:``,explanation:``}:{input:String(e?.input??``),output:String(e?.output??``),explanation:e?.explanation||``}):[{input:``,output:``,explanation:``}]),[j,M]=(0,i.useState)(()=>n?.constraints?Array.isArray(n.constraints)?n.constraints.join(`
2
  `):String(n.constraints):``),[te,ne]=(0,i.useState)(()=>n?.how_to_solve||``),[N,P]=(0,i.useState)(()=>{if(n?.reference_code)return n.reference_code;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).code||``}catch{}return``}),[F,I]=(0,i.useState)(()=>{if(n?.solutions&&Array.isArray(n.solutions)&&n.solutions.length>0)return n.solutions.map((e,t)=>({id:e.id||`sol-${t+1}`,name:e.name||`Method ${t+1}`,pattern:e.pattern||n.pattern||`Arrays & Hashing`,time_complexity:e.time_complexity||n.optimal_time||`O(N)`,space_complexity:e.space_complexity||n.optimal_space||`O(1)`,code:e.code||``,explanation:e.explanation||``,is_optimal:e.is_optimal??t===0}));let e=n?.reference_code||``,t=n?.pattern||`Arrays & Hashing`;try{let n=localStorage.getItem(`algospaced_prefill_draft`);if(n){let r=JSON.parse(n);r.code&&!e&&(e=r.code),r.pattern&&!t&&(t=r.pattern)}}catch{}return[{id:`sol-1`,name:`Optimal Method`,pattern:t,time_complexity:n?.optimal_time||`O(N)`,space_complexity:n?.optimal_space||`O(1)`,code:e,explanation:n?.how_to_solve||``,is_optimal:!0}]}),[L,R]=(0,i.useState)(0),z=F[L]||F[0]||{id:`sol-1`,name:`Method 1`,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!0},B=e=>{I(t=>{let n=[...t],r=L<n.length?L:0;return n[r]={...n[r],...e},e.is_optimal&&(n.forEach((e,t)=>{t!==r&&(e.is_optimal=!1)}),n[r].time_complexity&&w(n[r].time_complexity),n[r].space_complexity&&E(n[r].space_complexity),n[r].pattern&&b(n[r].pattern)),n})},re=()=>{let e=F.length+1,t={id:s(),name:`Method ${e}`,pattern:y||`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:F.length===0};I(e=>[...e,t]),R(F.length)},ie=e=>{F.length<=1||(I(t=>{let n=t.filter((t,n)=>n!==e);return n.some(e=>e.is_optimal)||(n[0].is_optimal=!0),n}),L>=F.length-1&&R(Math.max(0,F.length-2)))},[V,ae]=(0,i.useState)(!0),[H,U]=(0,i.useState)(``),[W,G]=(0,i.useState)(``),[K,q]=(0,i.useState)(!1),[J,Y]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[oe,se]=(0,i.useState)(!1);i.useEffect(()=>{l||localStorage.removeItem(`algospaced_prefill_draft`)},[l]);let Q=async()=>{let{data:{session:e}}=await r.auth.getSession(),t=e?e.access_token:`sandbox`,n=localStorage.getItem(`algospaced_custom_api_key`)||localStorage.getItem(`sandbox_gemini_api_key`)||``,i=localStorage.getItem(`algospaced_custom_ai_provider`)||`default`,a={"Content-Type":`application/json`,Authorization:`Bearer ${t}`};return i&&i!=="default"&&n&&n.trim()&&(a[`x-custom-api-key`]=n.trim(),a[`x-gemini-api-key`]=n.trim(),a[`x-ai-provider`]=i),a},ce=async()=>{if(f.trim()){m(!0),U(``);try{let e=await Q(),t=await fetch(`/api/explorer/problems/fetch-leetcode`,{method:`POST`,headers:e,body:JSON.stringify({query:f.trim()})});if(t.ok){let e=await t.json();e.problem_number!==void 0&&e.problem_number!==null&&v(e.problem_number),e.title&&g(e.title),e.difficulty&&S(e.difficulty),e.pattern&&b(e.pattern),e.optimal_time&&w(e.optimal_time),e.optimal_space&&E(e.optimal_space),e.description&&O(e.description),e.how_to_solve&&ne(e.how_to_solve),e.starter_code&&!N.trim()&&P(e.starter_code),I(t=>{let n=[...t],r={...n[L]};return e.pattern&&(r.pattern=e.pattern),e.optimal_time&&(r.time_complexity=e.optimal_time),e.optimal_space&&(r.space_complexity=e.optimal_space),e.how_to_solve&&(r.explanation=e.how_to_solve),e.starter_code&&!r.code?.trim()&&(r.code=e.starter_code),n[L]=r,n}),Array.isArray(e.examples)&&e.examples.length>0&&A(e.examples),Array.isArray(e.constraints)?M(e.constraints.join(`
3
  `)):typeof e.constraints==`string`&&M(e.constraints)}else{let e=await t.json();U(e.detail||`Failed to fetch LeetCode problem data.`)}}catch{U(`Fetch request failed due to connection error.`)}finally{m(!1)}}},le=async()=>{let e=z.code||N;if(h.trim()||e.trim()){se(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/prefill`,{method:`POST`,headers:t,body:JSON.stringify({name:h,code:e})});if(n.ok){let t=await n.json();t.problem_number!==void 0&&t.problem_number!==null&&v(t.problem_number),t.title&&!h&&g(t.title),t.pattern&&b(t.pattern),t.difficulty&&S(t.difficulty),t.optimal_time&&w(t.optimal_time),t.optimal_space&&E(t.optimal_space),t.description&&O(t.description),t.reference_code&&!e.trim()&&P(t.reference_code),I(e=>{let n=[...e],r={...n[L]};return t.pattern&&(r.pattern=t.pattern),t.optimal_time&&(r.time_complexity=t.optimal_time),t.optimal_space&&(r.space_complexity=t.optimal_space),t.reference_code&&!r.code?.trim()&&(r.code=t.reference_code),n[L]=r,n})}else{let e=await n.json();U(e.detail||`Prefill failed.`)}}catch{U(`Prefill request failed due to connection error.`)}finally{se(!1)}}},ue=async()=>{let e=z.code||N;if(!h.trim()&&!e.trim()){U(`Please enter a problem name or code first.`);return}Y(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/assist-field`,{method:`POST`,headers:t,body:JSON.stringify({field:`intuition`,title:h,code:e,description:D})});if(n.ok){let e=await n.json();e.how_to_solve&&(ne(e.how_to_solve),B({explanation:e.how_to_solve}))}else{let e=await n.json();U(e.detail||`Failed to generate intuition.`)}}catch{U(`Intuition generator failed due to connection error.`)}finally{Y(!1)}},de=async()=>{let e=z.code||N;if(!e.trim()){U(`Please enter some Python code to format.`);return}Z(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/assist-field`,{method:`POST`,headers:t,body:JSON.stringify({field:`comments`,title:h,code:e})});if(n.ok){let e=await n.json();e.formatted_code&&(P(e.formatted_code),B({code:e.formatted_code}))}else{let e=await n.json();U(e.detail||`Failed to format code.`)}}catch{U(`Code formatter failed due to connection error.`)}finally{Z(!1)}},fe=async r=>{if(r.preventDefault(),!h.trim()){U(`Problem name cannot be empty`);return}q(!0),U(``),G(``);try{let r=await Q(),i=j.split(`
4
  `).map(e=>e.trim()).filter(Boolean),a=F.find(e=>e.is_optimal)||F[0],o=a?.pattern||y.trim()||`General`,s=a?.code||N,c=a?.explanation||te,u=C||a?.time_complexity||`O(N)`,d=T||a?.space_complexity||`O(1)`,f;if(l&&n){let e=n.id||(n.problem_number?String(n.problem_number):``)||h.trim();f=await fetch(`/api/explorer/problems/${encodeURIComponent(e)}`,{method:`PUT`,headers:r,body:JSON.stringify({name:h.trim(),pattern:o,difficulty:x,reference_code:s,description:D,problem_number:_===``?null:Number(_),optimal_time:u,optimal_space:d,examples:k.filter(e=>e.input.trim()||e.output.trim()),constraints:i,how_to_solve:c,solutions:F})})}else f=await fetch(`/api/explorer/problems/create`,{method:`POST`,headers:r,body:JSON.stringify({name:h.trim(),pattern:o,difficulty:x,reference_code:s,description:D,problem_number:_===``?null:Number(_),optimal_time:u,optimal_space:d,examples:k.filter(e=>e.input.trim()||e.output.trim()),constraints:i,how_to_solve:c,sync_to_gdoc:V,solutions:F})});let p=await f.json();f.ok&&(p.success||p.problem_id)?(G(l?`Problem updated successfully!`:`Problem saved and synced successfully!`),setTimeout(()=>{t(),e()},1e3)):U(p.detail||(l?`Failed to update problem.`:`Failed to create problem.`))}catch{U(`Connection timed out.`)}finally{q(!1)}},pe=()=>{A([...k,{input:``,output:``,explanation:``}])},me=e=>{k.length<=1||A(k.filter((t,n)=>n!==e))},$=(e,t,n)=>{let r=[...k];r[e]={...r[e],[t]:n},A(r)};return(0,a.jsxs)(`form`,{onSubmit:fe,className:`flex flex-col h-full bg-[#fdf8e1] text-ink-black font-sans overflow-hidden`,children:[(0,a.jsxs)(`div`,{className:`bg-[#f0e6c8] p-2.5 border-b-2 border-ink-black flex flex-col gap-2 shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`font-arcade text-xs text-primary-purple`,children:`✦`}),(0,a.jsx)(`h2`,{className:`text-xs font-bold font-arcade tracking-tight uppercase`,children:l?`Edit Problem Specification`:`Problem & Note Studio`}),l&&(0,a.jsx)(`span`,{className:`text-[9px] bg-primary-purple/10 text-primary-purple font-mono px-1.5 py-0.5 rounded border border-primary-purple/30 font-bold`,children:`EDIT MODE`})]}),(0,a.jsxs)(`div`,{className:`flex border-2 border-ink-black bg-white rounded overflow-hidden shadow-[1px_1px_0px_#1E293B]`,children:[(0,a.jsx)(`button`,{type:`button`,onClick:()=>d(`form`),className:`px-3 py-1 text-[10px] font-bold uppercase transition-colors ${u===`form`?`bg-primary-purple text-white`:`hover:bg-slate-100`}`,children:`✏️ Editor`}),(0,a.jsx)(`button`,{type:`button`,onClick:()=>d(`preview`),className:`px-3 py-1 text-[10px] font-bold uppercase transition-colors ${u===`preview`?`bg-primary-purple text-white`:`hover:bg-slate-100`}`,children:`📄 Doc Preview`})]})]}),(0,a.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,a.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ce())},placeholder:`Paste LeetCode URL (e.g. https://leetcode.com/problems/two-sum/) or Title...`,className:`flex-1 bg-white border-2 border-ink-black px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-medium`}),(0,a.jsxs)(`button`,{type:`button`,onClick:ce,disabled:ee||!f.trim(),className:`bg-[#ffe24c] hover:bg-yellow-300 disabled:opacity-50 text-ink-black font-arcade text-[9px] font-bold px-2.5 py-1.5 border-2 border-ink-black shadow-[1px_1px_0px_#1E293B] active:translate-y-0.5 cursor-pointer flex items-center gap-1 shrink-0`,children:[(0,a.jsx)(`span`,{children:`⚡`}),` `,ee?`FETCHING...`:`FETCH LEETCODE`]})]})]}),H&&(0,a.jsxs)(`div`,{className:`mx-3 mt-2 p-2 border-2 border-red-500 bg-red-50 text-red-800 text-[11px] font-mono leading-relaxed shrink-0`,children:[`⚠️ `,H]}),W&&(0,a.jsxs)(`div`,{className:`mx-3 mt-2 p-2 border-2 border-green-500 bg-green-50 text-green-800 text-[11px] font-mono leading-relaxed shrink-0`,children:[`✅ `,W]}),(0,a.jsx)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar p-3 space-y-3`,children:u===`form`?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`div`,{className:`grid grid-cols-12 gap-2`,children:[(0,a.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Problem #:`}),(0,a.jsx)(`input`,{type:`number`,value:_,onChange:e=>v(e.target.value===``?``:Number(e.target.value)),placeholder:`e.g. 1`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-bold`})]}),(0,a.jsxs)(`div`,{className:`col-span-6 flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Title:`}),(0,a.jsxs)(`button`,{type:`button`,onClick:le,disabled:oe||!h.trim()&&!z.code?.trim(),className:`text-[8px] font-arcade font-bold px-1.5 py-0.5 border border-ink-black bg-[#ffe24c] hover:bg-yellow-300 disabled:opacity-50 flex items-center gap-1 cursor-pointer`,children:[(0,a.jsx)(`span`,{children:`✦`}),` `,oe?`...`:`AUTO-FILL`]})]}),(0,a.jsx)(`input`,{type:`text`,required:!0,value:h,onChange:e=>g(e.target.value),placeholder:`e.g. Two Sum`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-bold`})]}),(0,a.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Difficulty:`}),(0,a.jsxs)(`select`,{value:x,onChange:e=>S(e.target.value),className:`border-2 border-ink-black p-1.5 text-xs font-bold outline-none cursor-pointer ${x===`Easy`?`bg-emerald-100 text-emerald-900`:x===`Medium`?`bg-amber-100 text-amber-900`:`bg-rose-100 text-rose-900`}`,children:[(0,a.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,a.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,a.jsx)(`option`,{value:`Hard`,children:`Hard`})]})]})]}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 bg-[#f6edd2] p-2 border-2 border-ink-black rounded`,children:[(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`⏱️`}),` Target Optimal Time:`]}),(0,a.jsx)(`span`,{className:`text-[8px] font-mono text-slate-500`,children:`(hidden behind spoiler on review)`})]}),(0,a.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:`e.g. O(N)`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-mono font-bold`})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`📦`}),` Target Optimal Space:`]}),(0,a.jsx)(`span`,{className:`text-[8px] font-mono text-slate-500`,children:`(hidden behind spoiler on review)`})]}),(0,a.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`e.g. O(1)`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-mono font-bold`})]})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Problem Description:`}),(0,a.jsx)(`textarea`,{value:D,onChange:e=>O(e.target.value),placeholder:`Given an array of integers nums and an integer target...`,className:`bg-white border-2 border-ink-black p-2 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-sans h-20 resize-y leading-relaxed`})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1.5 bg-[#f6edd2] p-2.5 border-2 border-ink-black rounded`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`🧪`}),` Examples (`,k.length,`)`]}),(0,a.jsx)(`button`,{type:`button`,onClick:pe,className:`text-[9px] font-bold px-2 py-0.5 border border-ink-black bg-white hover:bg-slate-100 cursor-pointer shadow-[1px_1px_0px_#1E293B]`,children:`+ Add Example`})]}),k.map((e,t)=>(0,a.jsxs)(`div`,{className:`bg-white border border-ink-black p-2 space-y-1.5 rounded relative text-xs`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsxs)(`span`,{className:`font-bold text-[10px] text-slate-500`,children:[`Example `,t+1,`:`]}),k.length>1&&(0,a.jsx)(`button`,{type:`button`,onClick:()=>me(t),className:`text-[10px] text-red-600 hover:text-red-800 font-bold cursor-pointer`,children:`✕`})]}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,a.jsx)(`input`,{type:`text`,value:e.input,onChange:e=>$(t,`input`,e.target.value),placeholder:`Input: nums = [2,7,11,15], target = 9`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] font-mono outline-none`}),(0,a.jsx)(`input`,{type:`text`,value:e.output,onChange:e=>$(t,`output`,e.target.value),placeholder:`Output: [0,1]`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] font-mono outline-none`})]}),(0,a.jsx)(`input`,{type:`text`,value:e.explanation||``,onChange:e=>$(t,`explanation`,e.target.value),placeholder:`Explanation (Optional): Because nums[0] + nums[1] == 9, we return [0, 1].`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] outline-none w-full`})]},t))]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Constraints (1 per line):`}),(0,a.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),placeholder:`2 <= nums.length <= 10^4
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n}from"./vendor-react-hnaVBnLv.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(n(),1),a=t(),o=[`Arrays & Hashing`,`Two Pointers`,`Sliding Window`,`Stack`,`Binary Search`,`Linked List`,`Trees`,`Tries`,`Heap / Priority Queue`,`Backtracking`,`Graphs`,`Advanced Graphs`,`1-D Dynamic Programming`,`2-D Dynamic Programming`,`Greedy`,`Intervals`,`Math & Geometry`,`Bit Manipulation`];function s(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`sol-${crypto.randomUUID()}`:`sol-${Date.now()}`}function c({onClose:e,onSuccess:t,initialProblem:n,mode:c=n?`edit`:`create`}){let l=c===`edit`||!!n,[u,d]=(0,i.useState)(`form`),[f,p]=(0,i.useState)(``),[ee,m]=(0,i.useState)(!1),[h,g]=(0,i.useState)(()=>{if(n?.name)return n.name;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).name||``}catch{}return``}),[_,v]=(0,i.useState)(()=>n?.problem_number!==void 0&&n?.problem_number!==null?n.problem_number:``),[y,b]=(0,i.useState)(()=>{if(n?.pattern)return n.pattern;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).pattern||``}catch{}return`Arrays & Hashing`}),[x,S]=(0,i.useState)(()=>n?.difficulty===`Easy`||n?.difficulty===`Medium`||n?.difficulty===`Hard`?n.difficulty:`Medium`),[C,w]=(0,i.useState)(()=>n?.optimal_time||`O(N)`),[T,E]=(0,i.useState)(()=>n?.optimal_space||`O(1)`),[D,O]=(0,i.useState)(()=>n?.description||``),[k,A]=(0,i.useState)(()=>n?.examples&&Array.isArray(n.examples)&&n.examples.length>0?n.examples.map(e=>typeof e==`string`?{input:e,output:``,explanation:``}:{input:String(e?.input??``),output:String(e?.output??``),explanation:e?.explanation||``}):[{input:``,output:``,explanation:``}]),[j,M]=(0,i.useState)(()=>n?.constraints?Array.isArray(n.constraints)?n.constraints.join(`
2
  `):String(n.constraints):``),[te,ne]=(0,i.useState)(()=>n?.how_to_solve||``),[N,P]=(0,i.useState)(()=>{if(n?.reference_code)return n.reference_code;try{let e=localStorage.getItem(`algospaced_prefill_draft`);if(e)return JSON.parse(e).code||``}catch{}return``}),[F,I]=(0,i.useState)(()=>{if(n?.solutions&&Array.isArray(n.solutions)&&n.solutions.length>0)return n.solutions.map((e,t)=>({id:e.id||`sol-${t+1}`,name:e.name||`Method ${t+1}`,pattern:e.pattern||n.pattern||`Arrays & Hashing`,time_complexity:e.time_complexity||n.optimal_time||`O(N)`,space_complexity:e.space_complexity||n.optimal_space||`O(1)`,code:e.code||``,explanation:e.explanation||``,is_optimal:e.is_optimal??t===0}));let e=n?.reference_code||``,t=n?.pattern||`Arrays & Hashing`;try{let n=localStorage.getItem(`algospaced_prefill_draft`);if(n){let r=JSON.parse(n);r.code&&!e&&(e=r.code),r.pattern&&!t&&(t=r.pattern)}}catch{}return[{id:`sol-1`,name:`Optimal Method`,pattern:t,time_complexity:n?.optimal_time||`O(N)`,space_complexity:n?.optimal_space||`O(1)`,code:e,explanation:n?.how_to_solve||``,is_optimal:!0}]}),[L,R]=(0,i.useState)(0),z=F[L]||F[0]||{id:`sol-1`,name:`Method 1`,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!0},B=e=>{I(t=>{let n=[...t],r=L<n.length?L:0;return n[r]={...n[r],...e},e.is_optimal&&(n.forEach((e,t)=>{t!==r&&(e.is_optimal=!1)}),n[r].time_complexity&&w(n[r].time_complexity),n[r].space_complexity&&E(n[r].space_complexity),n[r].pattern&&b(n[r].pattern)),n})},re=()=>{let e=F.length+1,t={id:s(),name:`Method ${e}`,pattern:y||`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:F.length===0};I(e=>[...e,t]),R(F.length)},ie=e=>{F.length<=1||(I(t=>{let n=t.filter((t,n)=>n!==e);return n.some(e=>e.is_optimal)||(n[0].is_optimal=!0),n}),L>=F.length-1&&R(Math.max(0,F.length-2)))},[V,ae]=(0,i.useState)(!0),[H,U]=(0,i.useState)(``),[W,G]=(0,i.useState)(``),[K,q]=(0,i.useState)(!1),[J,Y]=(0,i.useState)(!1),[X,Z]=(0,i.useState)(!1),[oe,se]=(0,i.useState)(!1);i.useEffect(()=>{l||localStorage.removeItem(`algospaced_prefill_draft`)},[l]);let Q=async()=>{let{data:{session:e}}=await r.auth.getSession(),t=e?e.access_token:`sandbox`,n=localStorage.getItem(`algospaced_custom_api_key`)||localStorage.getItem(`sandbox_gemini_api_key`)||``,i=localStorage.getItem(`algospaced_custom_ai_provider`)||`default`,a={"Content-Type":`application/json`,Authorization:`Bearer ${t}`};return i&&i!=="default"&&n&&n.trim()&&(a[`x-custom-api-key`]=n.trim(),a[`x-gemini-api-key`]=n.trim(),a[`x-ai-provider`]=i),a},ce=async()=>{if(f.trim()){m(!0),U(``);try{let e=await Q(),t=await fetch(`/api/explorer/problems/fetch-leetcode`,{method:`POST`,headers:e,body:JSON.stringify({query:f.trim()})});if(t.ok){let e=await t.json();e.problem_number!==void 0&&e.problem_number!==null&&v(e.problem_number),e.title&&g(e.title),e.difficulty&&S(e.difficulty),e.pattern&&b(e.pattern),e.optimal_time&&w(e.optimal_time),e.optimal_space&&E(e.optimal_space),e.description&&O(e.description),e.how_to_solve&&ne(e.how_to_solve),e.starter_code&&!N.trim()&&P(e.starter_code),I(t=>{let n=[...t],r={...n[L]};return e.pattern&&(r.pattern=e.pattern),e.optimal_time&&(r.time_complexity=e.optimal_time),e.optimal_space&&(r.space_complexity=e.optimal_space),e.how_to_solve&&(r.explanation=e.how_to_solve),e.starter_code&&!r.code?.trim()&&(r.code=e.starter_code),n[L]=r,n}),Array.isArray(e.examples)&&e.examples.length>0&&A(e.examples),Array.isArray(e.constraints)?M(e.constraints.join(`
3
  `)):typeof e.constraints==`string`&&M(e.constraints)}else{let e=await t.json();U(e.detail||`Failed to fetch LeetCode problem data.`)}}catch{U(`Fetch request failed due to connection error.`)}finally{m(!1)}}},le=async()=>{let e=z.code||N;if(h.trim()||e.trim()){se(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/prefill`,{method:`POST`,headers:t,body:JSON.stringify({name:h,code:e})});if(n.ok){let t=await n.json();t.problem_number!==void 0&&t.problem_number!==null&&v(t.problem_number),t.title&&!h&&g(t.title),t.pattern&&b(t.pattern),t.difficulty&&S(t.difficulty),t.optimal_time&&w(t.optimal_time),t.optimal_space&&E(t.optimal_space),t.description&&O(t.description),t.reference_code&&!e.trim()&&P(t.reference_code),I(e=>{let n=[...e],r={...n[L]};return t.pattern&&(r.pattern=t.pattern),t.optimal_time&&(r.time_complexity=t.optimal_time),t.optimal_space&&(r.space_complexity=t.optimal_space),t.reference_code&&!r.code?.trim()&&(r.code=t.reference_code),n[L]=r,n})}else{let e=await n.json();U(e.detail||`Prefill failed.`)}}catch{U(`Prefill request failed due to connection error.`)}finally{se(!1)}}},ue=async()=>{let e=z.code||N;if(!h.trim()&&!e.trim()){U(`Please enter a problem name or code first.`);return}Y(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/assist-field`,{method:`POST`,headers:t,body:JSON.stringify({field:`intuition`,title:h,code:e,description:D})});if(n.ok){let e=await n.json();e.how_to_solve&&(ne(e.how_to_solve),B({explanation:e.how_to_solve}))}else{let e=await n.json();U(e.detail||`Failed to generate intuition.`)}}catch{U(`Intuition generator failed due to connection error.`)}finally{Y(!1)}},de=async()=>{let e=z.code||N;if(!e.trim()){U(`Please enter some Python code to format.`);return}Z(!0),U(``);try{let t=await Q(),n=await fetch(`/api/explorer/problems/assist-field`,{method:`POST`,headers:t,body:JSON.stringify({field:`comments`,title:h,code:e})});if(n.ok){let e=await n.json();e.formatted_code&&(P(e.formatted_code),B({code:e.formatted_code}))}else{let e=await n.json();U(e.detail||`Failed to format code.`)}}catch{U(`Code formatter failed due to connection error.`)}finally{Z(!1)}},fe=async r=>{if(r.preventDefault(),!h.trim()){U(`Problem name cannot be empty`);return}q(!0),U(``),G(``);try{let r=await Q(),i=j.split(`
4
  `).map(e=>e.trim()).filter(Boolean),a=F.find(e=>e.is_optimal)||F[0],o=a?.pattern||y.trim()||`General`,s=a?.code||N,c=a?.explanation||te,u=C||a?.time_complexity||`O(N)`,d=T||a?.space_complexity||`O(1)`,f;if(l&&n){let e=n.id||(n.problem_number?String(n.problem_number):``)||h.trim();f=await fetch(`/api/explorer/problems/${encodeURIComponent(e)}`,{method:`PUT`,headers:r,body:JSON.stringify({name:h.trim(),pattern:o,difficulty:x,reference_code:s,description:D,problem_number:_===``?null:Number(_),optimal_time:u,optimal_space:d,examples:k.filter(e=>e.input.trim()||e.output.trim()),constraints:i,how_to_solve:c,solutions:F})})}else f=await fetch(`/api/explorer/problems/create`,{method:`POST`,headers:r,body:JSON.stringify({name:h.trim(),pattern:o,difficulty:x,reference_code:s,description:D,problem_number:_===``?null:Number(_),optimal_time:u,optimal_space:d,examples:k.filter(e=>e.input.trim()||e.output.trim()),constraints:i,how_to_solve:c,sync_to_gdoc:V,solutions:F})});let p=await f.json();f.ok&&(p.success||p.problem_id)?(G(l?`Problem updated successfully!`:`Problem saved and synced successfully!`),setTimeout(()=>{t(),e()},1e3)):U(p.detail||(l?`Failed to update problem.`:`Failed to create problem.`))}catch{U(`Connection timed out.`)}finally{q(!1)}},pe=()=>{A([...k,{input:``,output:``,explanation:``}])},me=e=>{k.length<=1||A(k.filter((t,n)=>n!==e))},$=(e,t,n)=>{let r=[...k];r[e]={...r[e],[t]:n},A(r)};return(0,a.jsxs)(`form`,{onSubmit:fe,className:`flex flex-col h-full bg-[#fdf8e1] text-ink-black font-sans overflow-hidden`,children:[(0,a.jsxs)(`div`,{className:`bg-[#f0e6c8] p-2.5 border-b-2 border-ink-black flex flex-col gap-2 shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`font-arcade text-xs text-primary-purple`,children:`✦`}),(0,a.jsx)(`h2`,{className:`text-xs font-bold font-arcade tracking-tight uppercase`,children:l?`Edit Problem Specification`:`Problem & Note Studio`}),l&&(0,a.jsx)(`span`,{className:`text-[9px] bg-primary-purple/10 text-primary-purple font-mono px-1.5 py-0.5 rounded border border-primary-purple/30 font-bold`,children:`EDIT MODE`})]}),(0,a.jsxs)(`div`,{className:`flex border-2 border-ink-black bg-white rounded overflow-hidden shadow-[1px_1px_0px_#1E293B]`,children:[(0,a.jsx)(`button`,{type:`button`,onClick:()=>d(`form`),className:`px-3 py-1 text-[10px] font-bold uppercase transition-colors ${u===`form`?`bg-primary-purple text-white`:`hover:bg-slate-100`}`,children:`✏️ Editor`}),(0,a.jsx)(`button`,{type:`button`,onClick:()=>d(`preview`),className:`px-3 py-1 text-[10px] font-bold uppercase transition-colors ${u===`preview`?`bg-primary-purple text-white`:`hover:bg-slate-100`}`,children:`📄 Doc Preview`})]})]}),(0,a.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,a.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ce())},placeholder:`Paste LeetCode URL (e.g. https://leetcode.com/problems/two-sum/) or Title...`,className:`flex-1 bg-white border-2 border-ink-black px-2 py-1 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-medium`}),(0,a.jsxs)(`button`,{type:`button`,onClick:ce,disabled:ee||!f.trim(),className:`bg-[#ffe24c] hover:bg-yellow-300 disabled:opacity-50 text-ink-black font-arcade text-[9px] font-bold px-2.5 py-1.5 border-2 border-ink-black shadow-[1px_1px_0px_#1E293B] active:translate-y-0.5 cursor-pointer flex items-center gap-1 shrink-0`,children:[(0,a.jsx)(`span`,{children:`⚡`}),` `,ee?`FETCHING...`:`FETCH LEETCODE`]})]})]}),H&&(0,a.jsxs)(`div`,{className:`mx-3 mt-2 p-2 border-2 border-red-500 bg-red-50 text-red-800 text-[11px] font-mono leading-relaxed shrink-0`,children:[`⚠️ `,H]}),W&&(0,a.jsxs)(`div`,{className:`mx-3 mt-2 p-2 border-2 border-green-500 bg-green-50 text-green-800 text-[11px] font-mono leading-relaxed shrink-0`,children:[`✅ `,W]}),(0,a.jsx)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar p-3 space-y-3`,children:u===`form`?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`div`,{className:`grid grid-cols-12 gap-2`,children:[(0,a.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Problem #:`}),(0,a.jsx)(`input`,{type:`number`,value:_,onChange:e=>v(e.target.value===``?``:Number(e.target.value)),placeholder:`e.g. 1`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-bold`})]}),(0,a.jsxs)(`div`,{className:`col-span-6 flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Title:`}),(0,a.jsxs)(`button`,{type:`button`,onClick:le,disabled:oe||!h.trim()&&!z.code?.trim(),className:`text-[8px] font-arcade font-bold px-1.5 py-0.5 border border-ink-black bg-[#ffe24c] hover:bg-yellow-300 disabled:opacity-50 flex items-center gap-1 cursor-pointer`,children:[(0,a.jsx)(`span`,{children:`✦`}),` `,oe?`...`:`AUTO-FILL`]})]}),(0,a.jsx)(`input`,{type:`text`,required:!0,value:h,onChange:e=>g(e.target.value),placeholder:`e.g. Two Sum`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-bold`})]}),(0,a.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Difficulty:`}),(0,a.jsxs)(`select`,{value:x,onChange:e=>S(e.target.value),className:`border-2 border-ink-black p-1.5 text-xs font-bold outline-none cursor-pointer ${x===`Easy`?`bg-emerald-100 text-emerald-900`:x===`Medium`?`bg-amber-100 text-amber-900`:`bg-rose-100 text-rose-900`}`,children:[(0,a.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,a.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,a.jsx)(`option`,{value:`Hard`,children:`Hard`})]})]})]}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 bg-[#f6edd2] p-2 border-2 border-ink-black rounded`,children:[(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`⏱️`}),` Target Optimal Time:`]}),(0,a.jsx)(`span`,{className:`text-[8px] font-mono text-slate-500`,children:`(hidden behind spoiler on review)`})]}),(0,a.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:`e.g. O(N)`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-mono font-bold`})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`📦`}),` Target Optimal Space:`]}),(0,a.jsx)(`span`,{className:`text-[8px] font-mono text-slate-500`,children:`(hidden behind spoiler on review)`})]}),(0,a.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`e.g. O(1)`,className:`bg-white border-2 border-ink-black p-1.5 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-mono font-bold`})]})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Problem Description:`}),(0,a.jsx)(`textarea`,{value:D,onChange:e=>O(e.target.value),placeholder:`Given an array of integers nums and an integer target...`,className:`bg-white border-2 border-ink-black p-2 text-xs outline-none focus:ring-1 focus:ring-primary-purple font-sans h-20 resize-y leading-relaxed`})]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1.5 bg-[#f6edd2] p-2.5 border-2 border-ink-black rounded`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsxs)(`label`,{className:`text-[10px] font-bold text-slate-700 uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`🧪`}),` Examples (`,k.length,`)`]}),(0,a.jsx)(`button`,{type:`button`,onClick:pe,className:`text-[9px] font-bold px-2 py-0.5 border border-ink-black bg-white hover:bg-slate-100 cursor-pointer shadow-[1px_1px_0px_#1E293B]`,children:`+ Add Example`})]}),k.map((e,t)=>(0,a.jsxs)(`div`,{className:`bg-white border border-ink-black p-2 space-y-1.5 rounded relative text-xs`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,a.jsxs)(`span`,{className:`font-bold text-[10px] text-slate-500`,children:[`Example `,t+1,`:`]}),k.length>1&&(0,a.jsx)(`button`,{type:`button`,onClick:()=>me(t),className:`text-[10px] text-red-600 hover:text-red-800 font-bold cursor-pointer`,children:`✕`})]}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,a.jsx)(`input`,{type:`text`,value:e.input,onChange:e=>$(t,`input`,e.target.value),placeholder:`Input: nums = [2,7,11,15], target = 9`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] font-mono outline-none`}),(0,a.jsx)(`input`,{type:`text`,value:e.output,onChange:e=>$(t,`output`,e.target.value),placeholder:`Output: [0,1]`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] font-mono outline-none`})]}),(0,a.jsx)(`input`,{type:`text`,value:e.explanation||``,onChange:e=>$(t,`explanation`,e.target.value),placeholder:`Explanation (Optional): Because nums[0] + nums[1] == 9, we return [0, 1].`,className:`bg-slate-50 border border-slate-300 p-1 text-[11px] outline-none w-full`})]},t))]}),(0,a.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,a.jsx)(`label`,{className:`text-[10px] font-bold text-slate-600 uppercase`,children:`Constraints (1 per line):`}),(0,a.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),placeholder:`2 <= nums.length <= 10^4
algospaced-ui/dist/assets/FileExplorer-CJE9LlAj.js DELETED
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Rt as n}from"./vendor-react-CIO8MTK1.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(t(),1),a=n(),o=[{name:`Retro Arcade Grid.img`,url:`/wallpapers/default.webp`,desc:`Default AlgoSpaced purple grid and pixel theme background.`},{name:`Classic Board Logo.img`,url:`/icons/computer.webp`,desc:`System info and arcade machine diagram wallpaper.`},{name:`Terminal Console Icon.img`,url:`/icons/terminal.webp`,desc:`Dark retro CRT terminal screen layout.`},{name:`Synthwave Sunset Grid.img`,url:`https://images.unsplash.com/photo-1550745165-9bc0b252726f?q=80&w=1000&auto=format&fit=crop`,desc:`Glowing neon grids and vector mountains styling.`},{name:`Matrix Code Rain.img`,url:`https://images.unsplash.com/photo-1526374965328-7f61d4dc18c5?q=80&w=1000&auto=format&fit=crop`,desc:`Falling green digital characters rain.`}];function s({onSetWallpaper:e,activeWallpaperUrl:t,onOpenCreateProblem:n,onOpenQueue:s,onOpenJourney:c,refreshTrigger:l}){let[u,d]=(0,i.useState)([`C:`]),[f,p]=(0,i.useState)([]),[m,h]=(0,i.useState)(!0),[g,_]=(0,i.useState)(null),v=i.useMemo(()=>{let e=[...o],t=localStorage.getItem(`customWallpaperUrl`),n=localStorage.getItem(`customWallpaperName`)||`Custom Wallpaper.img`;return t&&(e.some(e=>e.url===t)||e.push({name:n,url:t,desc:`User uploaded custom background wallpaper.`})),e},[t]),[y,ee]=(0,i.useState)(``),[b,te]=(0,i.useState)(`All`),[x,S]=(0,i.useState)(`All`),[C,w]=(0,i.useState)(!1),[ne,T]=(0,i.useState)(!1),[E,D]=(0,i.useState)(!1),[O,k]=(0,i.useState)(``),[A,j]=(0,i.useState)(``),re=async e=>{let t=e.target.files;if(!t||t.length===0)return;let n=t[0];e.target.value=``,D(!0),k(``),j(``);try{let{data:{session:e}}=await r.auth.getSession(),t=e?e.access_token:`sandbox`,i=new FormData;i.append(`file`,n);let a=await fetch(`/api/explorer/import`,{method:`POST`,headers:{Authorization:`Bearer ${t}`},body:i}),o=await a.json();a.ok?(j(o.message||`Problems imported successfully!`),setTimeout(()=>{q()},500),setTimeout(()=>{T(!1),j(``)},2e3)):k(o.detail||`Import failed. Verify the file format.`)}catch{k(`Import failed due to a network error.`)}finally{D(!1)}},[M,N]=(0,i.useState)(null),[P,F]=(0,i.useState)(`description`),[I,L]=(0,i.useState)(!1),[R,z]=(0,i.useState)(``),[B,V]=(0,i.useState)(``),[H,U]=(0,i.useState)(!1),[W,G]=(0,i.useState)(!1),[ie,K]=(0,i.useState)(!1),q=async()=>{h(!0);try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;let t=await fetch(`/api/explorer/problems`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();p(e)}}catch(e){console.error(`Failed to fetch explorer files:`,e)}finally{h(!1)}};(0,i.useEffect)(()=>{q()},[l]);let J=e=>{d([`C:`,e]),_(null)},ae=()=>{u.length>1&&(d([`C:`]),_(null))},oe=async()=>{try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;let t=await fetch(`/api/explorer/export`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.blob(),n=window.URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`algospaced_solutions.zip`,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n)}}catch(e){console.error(`Failed to download solutions ZIP:`,e)}},se=async()=>{if(M){U(!0),G(!1);try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;if((await fetch(`/api/explorer/problems/${M.id}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({name:M.name,pattern:M.pattern,difficulty:M.difficulty,reference_code:R,description:B})})).ok){G(!0),L(!1);let e=f.map(e=>e.id===M.id?{...e,reference_code:R,description:B}:e);p(e),N({...M,reference_code:R,description:B}),setTimeout(()=>G(!1),2e3)}}catch(e){console.error(`Failed to update solution code:`,e)}finally{U(!1)}}},ce=e=>{e.preventDefault(),w(!0)},le=()=>{w(!1)},ue=async e=>{e.preventDefault(),w(!1);let t=e.dataTransfer.files;if(t.length>0){let e=t[0];if(e.name.endsWith(`.py`))try{let t=await e.text(),r=e.name.replace(`.py`,``).replace(/_/g,` `).replace(/-/g,` `),i=`General`,a=`Medium`,o=t.match(/#\s*Pattern:\s*(.+)/i);o&&(i=o[1].trim());let s=t.match(/#\s*Difficulty:\s*(.+)/i);if(s){let e=s[1].trim();[`Easy`,`Medium`,`Hard`].includes(e)&&(a=e)}let c=t.split(`
2
- `),l=[];for(let e of c){let t=e.trim();if(t.startsWith(`#`)){if(t.match(/#\s*(Pattern|Difficulty|Problem|Description):/i))continue;l.push(t.replace(/^#\s*/,``))}else if(t!==``)break}let u=l.join(`
3
- `).trim();localStorage.setItem(`algospaced_prefill_draft`,JSON.stringify({name:r,pattern:i,difficulty:a,code:t,description:u})),n&&n()}catch(e){console.error(`Failed to parse uploaded script:`,e)}}},de=e=>{navigator.clipboard.writeText(e),K(!0),setTimeout(()=>K(!1),2e3)},Y=u.length>1?u[1]:`root`,X=f.length,fe=f.filter(e=>e.reference_code&&e.reference_code.trim()).length,Z=X>0?Math.round(fe/X*100):0,Q={1:0,2:0,3:0,4:0,5:0};f.forEach(e=>{if(e.box_level!==null&&e.box_level!==void 0){let t=e.box_level;t>=1&&t<=5&&Q[t]++}});let pe=Array.from(new Set(f.map(e=>e.pattern).filter(Boolean))),$=f.filter(e=>{let t=e.name.toLowerCase().includes(y.toLowerCase()),n=b===`All`||e.difficulty===b,r=x===`All`||e.pattern===x;return t&&n&&r});return(0,a.jsxs)(`div`,{className:`w-full h-full bg-paper-white text-ink-black flex flex-col overflow-hidden text-xs md:text-sm font-sans select-none`,children:[(0,a.jsxs)(`div`,{className:`bg-slate-200 border-b-[3px] border-ink-black p-2 flex items-center justify-between shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,a.jsx)(`button`,{onClick:ae,disabled:u.length===1,className:`w-7 h-7 bg-white border-2 border-ink-black flex items-center justify-center hover:bg-slate-100 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer active:translate-y-0.5`,title:`Up One Folder`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[16px] font-bold`,children:`arrow_upward`})}),(0,a.jsx)(`div`,{className:`bg-white border-2 border-ink-black px-3 py-1 font-mono text-[10px] flex-1 max-w-[280px] truncate`,children:u.join(`\\`)})]}),(0,a.jsxs)(`div`,{className:`flex gap-3 text-[10px] font-bold pr-2 font-mono items-center`,children:[Y===`Database_Codes`&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`button`,{onClick:()=>n&&n(),className:`text-blue-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`add_box`}),`NEW FILE`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`}),(0,a.jsxs)(`button`,{onClick:()=>T(!0),className:`text-indigo-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`upload`}),`IMPORT (.CSV / .DB)`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`}),(0,a.jsxs)(`button`,{onClick:oe,className:`text-purple-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`downloadzip`}),`BACKUP (.ZIP)`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`})]}),(0,a.jsx)(`span`,{className:`text-slate-500`,children:Y===`root`?`2 Folder(s)`:Y===`Database_Codes`?`${$.length} of ${f.length} item(s)`:`${v.length} image(s)`})]})]}),(0,a.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[(0,a.jsxs)(`aside`,{className:`w-1/3 border-r-[3px] border-ink-black bg-[#fdf8e1] p-3 overflow-y-auto custom-scrollbar flex flex-col gap-4 shrink-0`,children:[(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-500 block uppercase mb-1.5`,children:`Folders`}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsxs)(`button`,{onClick:()=>d([`C:`]),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${u.length===1?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[#855400] text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`desktop_windows`}),(0,a.jsx)(`span`,{children:`C: (Root)`})]}),(0,a.jsxs)(`div`,{className:`pl-4 space-y-1`,children:[(0,a.jsxs)(`button`,{onClick:()=>J(`Database_Codes`),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${Y===`Database_Codes`?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-yellow-600 text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`truncate`,children:`Database_Codes`})]}),(0,a.jsxs)(`button`,{onClick:()=>J(`Wallpapers`),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${Y===`Wallpapers`?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-yellow-600 text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`truncate`,children:`Wallpapers`})]})]})]})]}),(0,a.jsxs)(`div`,{className:`border-t-2 border-dashed border-slate-300 pt-3`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-500 block uppercase mb-2`,children:`System Statistics`}),(0,a.jsxs)(`div`,{className:`space-y-3 font-sans text-[11px] font-bold text-slate-700`,children:[(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between text-[10px]`,children:[(0,a.jsx)(`span`,{children:`CODE COMPLETION:`}),(0,a.jsxs)(`span`,{className:`font-mono text-emerald-600`,children:[Z,`%`]})]}),(0,a.jsx)(`div`,{className:`w-full h-4 bg-white border-2 border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{style:{width:`${Z}%`},className:`h-full bg-emerald-500 border-r-2 border-ink-black transition-all duration-500`})})]}),(0,a.jsxs)(`div`,{className:`space-y-1.5 mt-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] uppercase text-slate-500 block`,children:`Leitner Distribution:`}),[1,2,3,4,5].map(e=>{let t=Q[e],n=Math.max(...Object.values(Q),1),r=Math.max(8,Math.round(t/n*100));return(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsxs)(`span`,{className:`w-9 font-mono text-[10px] text-slate-400`,children:[`Box `,e,`:`]}),(0,a.jsx)(`div`,{className:`flex-1 h-3 bg-white border border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{style:{width:`${r}%`},className:`h-full bg-[#0ea5e9] border-r border-ink-black transition-all`})}),(0,a.jsx)(`span`,{className:`w-4 text-right font-mono text-[10px] text-slate-600`,children:t})]},e)})]})]})]})]}),(0,a.jsxs)(`main`,{onDragOver:ce,onDragLeave:le,onDrop:ue,className:`flex-1 bg-white p-4 overflow-y-auto custom-scrollbar flex flex-col relative transition-all ${C?`bg-blue-50 border-4 border-dashed border-blue-500 m-2`:``}`,children:[C&&(0,a.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center text-blue-800 bg-white/80 pointer-events-none select-none z-[10] gap-2 font-sans font-bold`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl animate-bounce`,children:`upload_file`}),(0,a.jsx)(`div`,{className:`text-sm`,children:`DROP SOLUTIONS PYTHON SCRIPT (.PY) HERE`}),(0,a.jsx)(`p`,{className:`text-[10px] text-slate-400`,children:`Will load and parse file metadata for import`})]}),m?(0,a.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center font-arcade text-[8px] animate-pulse`,children:`READING SYSTEM DISK...`}):(0,a.jsxs)(a.Fragment,{children:[Y===`Database_Codes`&&(0,a.jsxs)(`div`,{className:`mb-4 bg-slate-50 border-[2px] border-ink-black p-2 flex flex-col gap-2 shrink-0 select-none`,children:[(0,a.jsx)(`div`,{className:`flex gap-2`,children:(0,a.jsxs)(`div`,{className:`flex-1 bg-white border border-slate-300 rounded px-2 py-1 flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-slate-400 text-sm`,children:`search`}),(0,a.jsx)(`input`,{type:`text`,value:y,onChange:e=>ee(e.target.value),className:`w-full bg-transparent outline-none border-none p-0 text-[11px] focus:ring-0 font-sans`,placeholder:`Search codes by name...`})]})}),(0,a.jsxs)(`div`,{className:`flex gap-3 text-[10px] font-bold text-slate-600`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`Diff:`}),(0,a.jsxs)(`select`,{value:b,onChange:e=>te(e.target.value),className:`bg-white border border-slate-300 p-0.5 text-[9px] rounded font-sans cursor-pointer focus:ring-1 outline-none`,children:[(0,a.jsx)(`option`,{value:`All`,children:`All`}),(0,a.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,a.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,a.jsx)(`option`,{value:`Hard`,children:`Hard`})]})]}),(0,a.jsxs)(`div`,{className:`flex items-center gap-1 flex-1`,children:[(0,a.jsx)(`span`,{children:`Pattern:`}),(0,a.jsxs)(`select`,{value:x,onChange:e=>S(e.target.value),className:`bg-white border border-slate-300 p-0.5 text-[9px] rounded font-sans cursor-pointer max-w-[120px] focus:ring-1 outline-none truncate`,children:[(0,a.jsx)(`option`,{value:`All`,children:`All`}),pe.map(e=>(0,a.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),Y===`root`&&(0,a.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,a.jsxs)(`div`,{onDoubleClick:()=>s&&s(),onClick:()=>_(`queue_app`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`queue_app`?`bg-green-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`div`,{className:`w-12 h-12 bg-grass-green border-2 border-ink-black flex items-center justify-center shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-ink-black`,style:{fontVariationSettings:`'FILL' 1`},children:`view_list`})}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Daily_Queue.exe`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Spaced Repetition Review`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>c&&c(),onClick:()=>_(`journey_app`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`journey_app`?`bg-blue-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`div`,{className:`w-12 h-12 bg-[#0ea5e9] border-2 border-ink-black flex items-center justify-center shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-white`,style:{fontVariationSettings:`'FILL' 1`},children:`route`})}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Journey_Path.exe`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`NeetCode 150 Road`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>J(`Database_Codes`),onClick:()=>_(`codes`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`codes`?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl text-yellow-500`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Database_Codes`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Synced solution files`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>J(`Wallpapers`),onClick:()=>_(`wallpapers`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`wallpapers`?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl text-yellow-500`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Wallpapers`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Desktop wallpaper images`})]})]}),Y===`Database_Codes`&&($.length===0?(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center text-slate-400 p-6 italic select-none`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl mb-1`,children:`drafts`}),`No matching files found. Drag and drop a .py script to upload/create!`]}):(0,a.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:$.map(e=>{let t=`${e.name.replace(/\s+/g,`_`)}.py`,n=g===e.id;return(0,a.jsxs)(`div`,{onClick:()=>_(e.id),onDoubleClick:()=>{N(e),z(e.reference_code||``),V(e.description||``),F(`description`),L(!1)},className:`flex flex-col items-center p-2 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none text-center ${n?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-emerald-600`,children:`article`}),(0,a.jsx)(`span`,{className:`font-bold text-[10px] truncate w-full mt-1.5 leading-tight`,children:t}),(0,a.jsx)(`span`,{className:`text-[8px] text-slate-400 font-bold uppercase mt-0.5`,children:e.difficulty})]},e.id)})})),Y===`Wallpapers`&&(0,a.jsx)(`div`,{className:`grid grid-cols-2 gap-3 select-none`,children:v.map(n=>{let r=g===n.name,i=t===n.url;return(0,a.jsxs)(`div`,{onClick:()=>_(n.name),className:`border-[3px] p-2 flex flex-col cursor-pointer bg-slate-50 relative hover:bg-slate-100 ${r?`border-ink-black bg-yellow-50 shadow-[2px_2px_0_0_#1E293B]`:`border-slate-300`}`,children:[(0,a.jsxs)(`div`,{className:`aspect-video w-full border border-slate-300 overflow-hidden bg-black shrink-0 relative`,children:[(0,a.jsx)(`img`,{src:n.url,alt:n.name,className:`w-full h-full object-cover select-none`}),i&&(0,a.jsx)(`div`,{className:`absolute top-1 right-1 bg-green-500 text-white rounded-full w-5 h-5 flex items-center justify-center border border-white`,title:`Active Wallpaper`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-extrabold`,children:`check`})})]}),(0,a.jsx)(`span`,{className:`font-bold text-[10px] mt-1.5 truncate`,children:n.name}),(0,a.jsx)(`p`,{className:`text-[8px] text-slate-400 font-sans leading-tight mt-0.5 line-clamp-2`,children:n.desc}),r&&(0,a.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e(n.url),localStorage.setItem(`desktopWallpaperUrl`,n.url)},className:`mt-2 w-full py-1 bg-highlight-pink text-white border-2 border-ink-black font-window-title font-bold text-[9px] hover:bg-pink-400 shadow-[1px_1px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none transition-all text-center cursor-pointer`,children:`APPLY BACKGROUND`})]},n.name)})})]})]})]}),M&&(0,a.jsx)(`div`,{className:`absolute inset-0 bg-black/60 z-[999] flex items-center justify-center p-4`,children:(0,a.jsxs)(`div`,{className:`w-[90%] h-[90%] bg-paper-white border-[4px] border-ink-black shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden animate-scale-up text-ink-black`,children:[(0,a.jsxs)(`div`,{className:`bg-emerald-600 text-white p-2 border-b-[3px] border-ink-black flex justify-between items-center shrink-0 select-none`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`article`}),(0,a.jsxs)(`span`,{className:`font-window-title font-bold text-xs`,children:[M.name.replace(/\s+/g,`_`),`.py`]})]}),(0,a.jsx)(`button`,{onClick:()=>N(null),className:`bg-white text-ink-black border-[2px] border-ink-black w-5 h-5 flex items-center justify-center font-bold hover:bg-red-500 hover:text-white cursor-pointer`,children:`X`})]}),(0,a.jsxs)(`div`,{className:`bg-slate-200 border-b-2 border-ink-black flex shrink-0 select-none`,children:[(0,a.jsx)(`button`,{onClick:()=>F(`description`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`description`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`PROBLEM DESCRIPTION`}),(0,a.jsx)(`button`,{onClick:()=>F(`code`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`code`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`CODE VIEW & EDIT`}),(0,a.jsx)(`button`,{onClick:()=>F(`properties`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`properties`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`LEITNER PROPERTIES`})]}),P===`description`&&(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden bg-slate-900 relative`,children:[I?(0,a.jsx)(`textarea`,{value:B,onChange:e=>V(e.target.value),className:`flex-1 w-full bg-slate-950 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,placeholder:`Enter problem description / question body here...`,spellCheck:`false`}):(0,a.jsx)(`div`,{className:`flex-1 p-4 bg-slate-900 text-[#4ADE80] font-sans text-xs leading-relaxed overflow-y-auto custom-scrollbar select-text`,children:(0,a.jsx)(`div`,{className:`whitespace-pre-wrap font-semibold`,children:M.description||`No description provided for this problem.`})}),I&&(0,a.jsx)(`div`,{className:`absolute top-2 right-2 bg-yellow-400 text-ink-black border border-ink-black px-2 py-0.5 text-[9px] font-bold select-none animate-pulse`,children:`EDIT MODE ACTIVE`})]}),P===`code`&&(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden bg-slate-900 relative`,children:[I?(0,a.jsx)(`textarea`,{value:R,onChange:e=>z(e.target.value),className:`flex-1 w-full bg-slate-950 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,spellCheck:`false`}):(0,a.jsx)(`textarea`,{readOnly:!0,value:M.reference_code||`# Write your solution here.`,className:`flex-1 w-full bg-slate-900 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,spellCheck:`false`}),I&&(0,a.jsx)(`div`,{className:`absolute top-2 right-2 bg-yellow-400 text-ink-black border border-ink-black px-2 py-0.5 text-[9px] font-bold select-none animate-pulse`,children:`EDIT MODE ACTIVE`})]}),P===`properties`&&(0,a.jsxs)(`div`,{className:`flex-1 p-6 overflow-y-auto custom-scrollbar bg-slate-50 font-sans leading-relaxed select-text flex flex-col gap-4`,children:[(0,a.jsx)(`h3`,{className:`font-arcade text-[10px] border-b border-slate-300 pb-1 text-slate-500`,children:`Card Diagnostics`}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-[#0ea5e9] block`,children:`Scheduling Status`}),(0,a.jsxs)(`div`,{children:[`Leitner Combo Box: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-lg text-sky-600`,children:M.box_level||`N/A (Box 1)`})]}),(0,a.jsxs)(`div`,{children:[`Next Review Date: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.next_review?new Date(M.next_review).toLocaleString():`N/A (Due)`})]}),(0,a.jsxs)(`div`,{children:[`Last Reviewed: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.last_reviewed?new Date(M.last_reviewed).toLocaleDateString():`Never`})]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-emerald-600 block`,children:`Performance History`}),(0,a.jsxs)(`div`,{children:[`Total Attempts: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm`,children:M.total_attempts})]}),(0,a.jsxs)(`div`,{children:[`Times Correct: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-green-600`,children:M.times_correct})]}),(0,a.jsxs)(`div`,{children:[`Success Ratio: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-purple-700`,children:M.total_attempts>0?`${Math.round(M.times_correct/M.total_attempts*100)}%`:`0%`})]})]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-1.5 text-xs font-semibold`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-400 block`,children:`Properties`}),(0,a.jsxs)(`div`,{children:[`File ID: `,(0,a.jsx)(`span`,{className:`font-mono text-[10px] text-slate-500`,children:M.id})]}),(0,a.jsxs)(`div`,{children:[`Logical Pattern: `,(0,a.jsx)(`span`,{className:`text-blue-600`,children:M.pattern})]}),(0,a.jsxs)(`div`,{children:[`Difficulty Tag: `,(0,a.jsx)(`span`,{className:`uppercase`,children:M.difficulty})]})]})]}),(0,a.jsxs)(`div`,{className:`p-3 bg-slate-100 border-t-[3px] border-ink-black flex justify-between items-center shrink-0 select-none`,children:[(0,a.jsx)(`div`,{children:W&&(0,a.jsx)(`span`,{className:`text-green-600 font-bold text-xs animate-pulse`,children:`✓ Solution saved!`})}),(0,a.jsxs)(`div`,{className:`flex gap-2`,children:[(P===`code`||P===`description`)&&(I?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`button`,{onClick:()=>{z(M.reference_code||``),V(M.description||``),L(!1)},className:`px-3 py-1.5 bg-white hover:bg-slate-50 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer`,children:`CANCEL`}),(0,a.jsx)(`button`,{disabled:H,onClick:se,className:`px-3 py-1.5 bg-[#4ADE80] hover:bg-emerald-400 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:H?`SAVING...`:`SAVE CHANGES`})]}):(0,a.jsxs)(`button`,{onClick:()=>L(!0),className:`px-3 py-1.5 bg-yellow-400 hover:bg-yellow-300 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`edit`}),`EDIT FILE`]})),(0,a.jsxs)(`button`,{onClick:()=>de(I?R:M.reference_code),className:`px-3 py-1.5 bg-[#ffcc00] hover:bg-yellow-300 text-ink-black border-2 border-ink-black font-bold text-xs shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none cursor-pointer flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`content_copy`}),ie?`COPIED!`:`COPY CODE`]}),(0,a.jsx)(`button`,{onClick:()=>N(null),className:`px-3 py-1.5 bg-white hover:bg-slate-50 text-ink-black border-2 border-ink-black font-bold text-xs shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none cursor-pointer`,children:`CLOSE`})]})]})]})}),ne&&(0,a.jsx)(`div`,{className:`absolute inset-0 bg-black/60 z-[999] flex items-center justify-center p-4 select-none`,children:(0,a.jsxs)(`div`,{className:`w-[80%] max-w-[400px] bg-paper-white border-[4px] border-ink-black shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden animate-scale-up text-ink-black font-sans`,children:[(0,a.jsxs)(`div`,{className:`bg-indigo-700 text-white p-2.5 border-b-[3px] border-ink-black flex justify-between items-center font-bold`,children:[(0,a.jsx)(`span`,{className:`font-window-title text-xs`,children:`IMPORT PROBLEMS`}),(0,a.jsx)(`button`,{onClick:()=>{T(!1),k(``),j(``)},className:`bg-white text-ink-black border-[2px] border-ink-black w-5 h-5 flex items-center justify-center font-bold hover:bg-red-500 hover:text-white cursor-pointer`,children:`X`})]}),(0,a.jsxs)(`div`,{className:`p-6 space-y-4`,children:[O&&(0,a.jsx)(`div`,{className:`p-2 border-2 border-red-500 bg-red-50 text-red-800 text-[10px] font-mono leading-relaxed`,children:O}),A&&(0,a.jsx)(`div`,{className:`p-2 border-2 border-green-500 bg-green-50 text-green-800 text-[10px] font-mono leading-relaxed`,children:A}),(0,a.jsxs)(`div`,{className:`flex flex-col items-center justify-center border-4 border-dashed border-ink-black p-6 relative ${E?`bg-indigo-50 cursor-wait`:`bg-slate-50 hover:bg-slate-100 cursor-pointer`}`,children:[E?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-indigo-700 mb-2 animate-bounce`,children:`cloud_upload`}),(0,a.jsx)(`span`,{className:`text-xs font-bold text-indigo-800 text-center`,children:`UPLOADING & PROCESSING...`}),(0,a.jsx)(`span`,{className:`text-[9px] text-indigo-600 mt-1 uppercase font-semibold text-center`,children:`Please wait, this might take a moment`})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-indigo-700 mb-2`,children:`upload_file`}),(0,a.jsx)(`span`,{className:`text-xs font-bold text-ink-black text-center`,children:`SELECT A CSV OR SQLite (.DB) FILE`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-1 uppercase font-semibold text-center`,children:`Imports problems & solution notes`})]}),(0,a.jsx)(`input`,{type:`file`,accept:`.csv,.db`,disabled:E,onChange:re,className:`absolute inset-0 opacity-0 cursor-pointer w-full h-full disabled:cursor-wait`})]}),(0,a.jsxs)(`div`,{className:`text-[9px] text-slate-400 font-medium leading-normal space-y-1 font-sans`,children:[(0,a.jsxs)(`p`,{children:[`• `,(0,a.jsx)(`b`,{children:`CSV File:`}),` Must have a `,(0,a.jsx)(`code`,{children:`name`}),` column. Optional: `,(0,a.jsx)(`code`,{children:`problem_number`}),`, `,(0,a.jsx)(`code`,{children:`pattern`}),`, `,(0,a.jsx)(`code`,{children:`difficulty`}),`, `,(0,a.jsx)(`code`,{children:`optimal_time`}),`, `,(0,a.jsx)(`code`,{children:`optimal_space`}),`, `,(0,a.jsx)(`code`,{children:`reference_code`}),`, `,(0,a.jsx)(`code`,{children:`description`}),`.`]}),(0,a.jsxs)(`p`,{children:[`• `,(0,a.jsx)(`b`,{children:`SQLite DB File:`}),` Must be a standard database backup containing a `,(0,a.jsx)(`code`,{children:`problems`}),` table matching AlgoSpaced design.`]})]})]})]})})]})}export{s as default};
 
 
 
 
algospaced-ui/dist/assets/FileExplorer-D3FrJW-x.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n}from"./vendor-react-hnaVBnLv.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(n(),1),a=t(),o=[{name:`Retro Arcade Grid.img`,url:`/wallpapers/default.webp`,desc:`Default AlgoSpaced purple grid and pixel theme background.`},{name:`Classic Board Logo.img`,url:`/icons/computer.webp`,desc:`System info and arcade machine diagram wallpaper.`},{name:`Terminal Console Icon.img`,url:`/icons/terminal.webp`,desc:`Dark retro CRT terminal screen layout.`},{name:`Synthwave Sunset Grid.img`,url:`https://images.unsplash.com/photo-1550745165-9bc0b252726f?q=80&w=1000&auto=format&fit=crop`,desc:`Glowing neon grids and vector mountains styling.`},{name:`Matrix Code Rain.img`,url:`https://images.unsplash.com/photo-1526374965328-7f61d4dc18c5?q=80&w=1000&auto=format&fit=crop`,desc:`Falling green digital characters rain.`}];function s({onSetWallpaper:e,activeWallpaperUrl:t,onOpenCreateProblem:n,onOpenQueue:s,onOpenJourney:c,refreshTrigger:l}){let[u,d]=(0,i.useState)([`C:`]),[f,p]=(0,i.useState)([]),[m,h]=(0,i.useState)(!0),[g,_]=(0,i.useState)(null),v=i.useMemo(()=>{let e=[...o],t=localStorage.getItem(`customWallpaperUrl`),n=localStorage.getItem(`customWallpaperName`)||`Custom Wallpaper.img`;return t&&(e.some(e=>e.url===t)||e.push({name:n,url:t,desc:`User uploaded custom background wallpaper.`})),e},[t]),[y,ee]=(0,i.useState)(``),[b,te]=(0,i.useState)(`All`),[x,S]=(0,i.useState)(`All`),[C,w]=(0,i.useState)(!1),[ne,T]=(0,i.useState)(!1),[E,D]=(0,i.useState)(!1),[O,k]=(0,i.useState)(``),[A,j]=(0,i.useState)(``),re=async e=>{let t=e.target.files;if(!t||t.length===0)return;let n=t[0];e.target.value=``,D(!0),k(``),j(``);try{let{data:{session:e}}=await r.auth.getSession(),t=e?e.access_token:`sandbox`,i=new FormData;i.append(`file`,n);let a=await fetch(`/api/explorer/import`,{method:`POST`,headers:{Authorization:`Bearer ${t}`},body:i}),o=await a.json();a.ok?(j(o.message||`Problems imported successfully!`),setTimeout(()=>{q()},500),setTimeout(()=>{T(!1),j(``)},2e3)):k(o.detail||`Import failed. Verify the file format.`)}catch{k(`Import failed due to a network error.`)}finally{D(!1)}},[M,N]=(0,i.useState)(null),[P,F]=(0,i.useState)(`description`),[I,L]=(0,i.useState)(!1),[R,z]=(0,i.useState)(``),[B,V]=(0,i.useState)(``),[H,U]=(0,i.useState)(!1),[W,G]=(0,i.useState)(!1),[ie,K]=(0,i.useState)(!1),q=async()=>{h(!0);try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;let t=await fetch(`/api/explorer/problems`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();p(e)}}catch(e){console.error(`Failed to fetch explorer files:`,e)}finally{h(!1)}};(0,i.useEffect)(()=>{q()},[l]);let J=e=>{d([`C:`,e]),_(null)},ae=()=>{u.length>1&&(d([`C:`]),_(null))},oe=async()=>{try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;let t=await fetch(`/api/explorer/export`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.blob(),n=window.URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`algospaced_solutions.zip`,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n)}}catch(e){console.error(`Failed to download solutions ZIP:`,e)}},se=async()=>{if(M){U(!0),G(!1);try{let{data:{session:e}}=await r.auth.getSession();if(!e)return;if((await fetch(`/api/explorer/problems/${M.id}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({name:M.name,pattern:M.pattern,difficulty:M.difficulty,reference_code:R,description:B})})).ok){G(!0),L(!1);let e=f.map(e=>e.id===M.id?{...e,reference_code:R,description:B}:e);p(e),N({...M,reference_code:R,description:B}),setTimeout(()=>G(!1),2e3)}}catch(e){console.error(`Failed to update solution code:`,e)}finally{U(!1)}}},ce=e=>{e.preventDefault(),w(!0)},le=()=>{w(!1)},ue=async e=>{e.preventDefault(),w(!1);let t=e.dataTransfer.files;if(t.length>0){let e=t[0];if(e.name.endsWith(`.py`))try{let t=await e.text(),r=e.name.replace(`.py`,``).replace(/_/g,` `).replace(/-/g,` `),i=`General`,a=`Medium`,o=t.match(/#\s*Pattern:\s*(.+)/i);o&&(i=o[1].trim());let s=t.match(/#\s*Difficulty:\s*(.+)/i);if(s){let e=s[1].trim();[`Easy`,`Medium`,`Hard`].includes(e)&&(a=e)}let c=t.split(`
2
+ `),l=[];for(let e of c){let t=e.trim();if(t.startsWith(`#`)){if(t.match(/#\s*(Pattern|Difficulty|Problem|Description):/i))continue;l.push(t.replace(/^#\s*/,``))}else if(t!==``)break}let u=l.join(`
3
+ `).trim();localStorage.setItem(`algospaced_prefill_draft`,JSON.stringify({name:r,pattern:i,difficulty:a,code:t,description:u})),n&&n()}catch(e){console.error(`Failed to parse uploaded script:`,e)}}},de=e=>{navigator.clipboard.writeText(e),K(!0),setTimeout(()=>K(!1),2e3)},Y=u.length>1?u[1]:`root`,X=f.length,fe=f.filter(e=>e.reference_code&&e.reference_code.trim()).length,Z=X>0?Math.round(fe/X*100):0,Q={0:0,1:0,2:0,3:0};f.forEach(e=>{if(e.fsrs_state!==null&&e.fsrs_state!==void 0){let t=e.fsrs_state;t>=0&&t<=3&&Q[t]++}});let pe=Array.from(new Set(f.map(e=>e.pattern).filter(Boolean))),$=f.filter(e=>{let t=e.name.toLowerCase().includes(y.toLowerCase()),n=b===`All`||e.difficulty===b,r=x===`All`||e.pattern===x;return t&&n&&r});return(0,a.jsxs)(`div`,{className:`w-full h-full bg-paper-white text-ink-black flex flex-col overflow-hidden text-xs md:text-sm font-sans select-none`,children:[(0,a.jsxs)(`div`,{className:`bg-slate-200 border-b-[3px] border-ink-black p-2 flex items-center justify-between shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,a.jsx)(`button`,{onClick:ae,disabled:u.length===1,className:`w-7 h-7 bg-white border-2 border-ink-black flex items-center justify-center hover:bg-slate-100 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer active:translate-y-0.5`,title:`Up One Folder`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[16px] font-bold`,children:`arrow_upward`})}),(0,a.jsx)(`div`,{className:`bg-white border-2 border-ink-black px-3 py-1 font-mono text-[10px] flex-1 max-w-[280px] truncate`,children:u.join(`\\`)})]}),(0,a.jsxs)(`div`,{className:`flex gap-3 text-[10px] font-bold pr-2 font-mono items-center`,children:[Y===`Database_Codes`&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`button`,{onClick:()=>n&&n(),className:`text-blue-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`add_box`}),`NEW FILE`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`}),(0,a.jsxs)(`button`,{onClick:()=>T(!0),className:`text-indigo-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`upload`}),`IMPORT (.CSV / .DB)`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`}),(0,a.jsxs)(`button`,{onClick:oe,className:`text-purple-700 hover:underline cursor-pointer flex items-center gap-0.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-bold`,children:`downloadzip`}),`BACKUP (.ZIP)`]}),(0,a.jsx)(`span`,{className:`text-slate-400`,children:`|`})]}),(0,a.jsx)(`span`,{className:`text-slate-500`,children:Y===`root`?`2 Folder(s)`:Y===`Database_Codes`?`${$.length} of ${f.length} item(s)`:`${v.length} image(s)`})]})]}),(0,a.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[(0,a.jsxs)(`aside`,{className:`w-1/3 border-r-[3px] border-ink-black bg-[#fdf8e1] p-3 overflow-y-auto custom-scrollbar flex flex-col gap-4 shrink-0`,children:[(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-500 block uppercase mb-1.5`,children:`Folders`}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsxs)(`button`,{onClick:()=>d([`C:`]),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${u.length===1?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[#855400] text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`desktop_windows`}),(0,a.jsx)(`span`,{children:`C: (Root)`})]}),(0,a.jsxs)(`div`,{className:`pl-4 space-y-1`,children:[(0,a.jsxs)(`button`,{onClick:()=>J(`Database_Codes`),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${Y===`Database_Codes`?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-yellow-600 text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`truncate`,children:`Database_Codes`})]}),(0,a.jsxs)(`button`,{onClick:()=>J(`Wallpapers`),className:`w-full text-left p-1.5 flex items-center gap-1.5 font-semibold border-2 border-transparent hover:bg-slate-100 rounded ${Y===`Wallpapers`?`bg-white border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-yellow-600 text-sm`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`truncate`,children:`Wallpapers`})]})]})]})]}),(0,a.jsxs)(`div`,{className:`border-t-2 border-dashed border-slate-300 pt-3`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-500 block uppercase mb-2`,children:`System Statistics`}),(0,a.jsxs)(`div`,{className:`space-y-3 font-sans text-[11px] font-bold text-slate-700`,children:[(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between text-[10px]`,children:[(0,a.jsx)(`span`,{children:`CODE COMPLETION:`}),(0,a.jsxs)(`span`,{className:`font-mono text-emerald-600`,children:[Z,`%`]})]}),(0,a.jsx)(`div`,{className:`w-full h-4 bg-white border-2 border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{style:{width:`${Z}%`},className:`h-full bg-emerald-500 border-r-2 border-ink-black transition-all duration-500`})})]}),(0,a.jsxs)(`div`,{className:`space-y-1.5 mt-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] uppercase text-slate-500 block`,children:`FSRS Distribution:`}),[{state:0,label:`New`,color:`#3b82f6`},{state:1,label:`Learn`,color:`#f59e0b`},{state:2,label:`Review`,color:`#10b981`},{state:3,label:`Relearn`,color:`#ef4444`}].map(e=>{let t=Q[e.state],n=Math.max(...Object.values(Q),1),r=Math.max(8,Math.round(t/n*100));return(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsxs)(`span`,{className:`w-12 font-mono text-[10px] text-slate-400`,children:[e.label,`:`]}),(0,a.jsx)(`div`,{className:`flex-1 h-3 bg-white border border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{style:{width:`${r}%`,backgroundColor:e.color},className:`h-full border-r border-ink-black transition-all`})}),(0,a.jsx)(`span`,{className:`w-4 text-right font-mono text-[10px] text-slate-600`,children:t})]},e.state)})]})]})]})]}),(0,a.jsxs)(`main`,{onDragOver:ce,onDragLeave:le,onDrop:ue,className:`flex-1 bg-white p-4 overflow-y-auto custom-scrollbar flex flex-col relative transition-all ${C?`bg-blue-50 border-4 border-dashed border-blue-500 m-2`:``}`,children:[C&&(0,a.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center text-blue-800 bg-white/80 pointer-events-none select-none z-[10] gap-2 font-sans font-bold`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl animate-bounce`,children:`upload_file`}),(0,a.jsx)(`div`,{className:`text-sm`,children:`DROP SOLUTIONS PYTHON SCRIPT (.PY) HERE`}),(0,a.jsx)(`p`,{className:`text-[10px] text-slate-400`,children:`Will load and parse file metadata for import`})]}),m?(0,a.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center font-arcade text-[8px] animate-pulse`,children:`READING SYSTEM DISK...`}):(0,a.jsxs)(a.Fragment,{children:[Y===`Database_Codes`&&(0,a.jsxs)(`div`,{className:`mb-4 bg-slate-50 border-[2px] border-ink-black p-2 flex flex-col gap-2 shrink-0 select-none`,children:[(0,a.jsx)(`div`,{className:`flex gap-2`,children:(0,a.jsxs)(`div`,{className:`flex-1 bg-white border border-slate-300 rounded px-2 py-1 flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-slate-400 text-sm`,children:`search`}),(0,a.jsx)(`input`,{type:`text`,value:y,onChange:e=>ee(e.target.value),className:`w-full bg-transparent outline-none border-none p-0 text-[11px] focus:ring-0 font-sans`,placeholder:`Search codes by name...`})]})}),(0,a.jsxs)(`div`,{className:`flex gap-3 text-[10px] font-bold text-slate-600`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,a.jsx)(`span`,{children:`Diff:`}),(0,a.jsxs)(`select`,{value:b,onChange:e=>te(e.target.value),className:`bg-white border border-slate-300 p-0.5 text-[9px] rounded font-sans cursor-pointer focus:ring-1 outline-none`,children:[(0,a.jsx)(`option`,{value:`All`,children:`All`}),(0,a.jsx)(`option`,{value:`Easy`,children:`Easy`}),(0,a.jsx)(`option`,{value:`Medium`,children:`Medium`}),(0,a.jsx)(`option`,{value:`Hard`,children:`Hard`})]})]}),(0,a.jsxs)(`div`,{className:`flex items-center gap-1 flex-1`,children:[(0,a.jsx)(`span`,{children:`Pattern:`}),(0,a.jsxs)(`select`,{value:x,onChange:e=>S(e.target.value),className:`bg-white border border-slate-300 p-0.5 text-[9px] rounded font-sans cursor-pointer max-w-[120px] focus:ring-1 outline-none truncate`,children:[(0,a.jsx)(`option`,{value:`All`,children:`All`}),pe.map(e=>(0,a.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),Y===`root`&&(0,a.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,a.jsxs)(`div`,{onDoubleClick:()=>s&&s(),onClick:()=>_(`queue_app`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`queue_app`?`bg-green-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`div`,{className:`w-12 h-12 bg-grass-green border-2 border-ink-black flex items-center justify-center shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-ink-black`,style:{fontVariationSettings:`'FILL' 1`},children:`view_list`})}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Daily_Queue.exe`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Spaced Repetition Review`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>c&&c(),onClick:()=>_(`journey_app`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`journey_app`?`bg-blue-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`div`,{className:`w-12 h-12 bg-[#0ea5e9] border-2 border-ink-black flex items-center justify-center shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-white`,style:{fontVariationSettings:`'FILL' 1`},children:`route`})}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Journey_Path.exe`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`NeetCode 150 Road`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>J(`Database_Codes`),onClick:()=>_(`codes`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`codes`?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl text-yellow-500`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Database_Codes`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Synced solution files`})]}),(0,a.jsxs)(`div`,{onDoubleClick:()=>J(`Wallpapers`),onClick:()=>_(`wallpapers`),className:`flex flex-col items-center justify-center p-3 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none ${g===`wallpapers`?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-5xl text-yellow-500`,style:{fontVariationSettings:`'FILL' 1`},children:`folder`}),(0,a.jsx)(`span`,{className:`font-bold text-center mt-2 text-xs`,children:`Wallpapers`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-0.5`,children:`Desktop wallpaper images`})]})]}),Y===`Database_Codes`&&($.length===0?(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center text-slate-400 p-6 italic select-none`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl mb-1`,children:`drafts`}),`No matching files found. Drag and drop a .py script to upload/create!`]}):(0,a.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:$.map(e=>{let t=`${e.name.replace(/\s+/g,`_`)}.py`,n=g===e.id;return(0,a.jsxs)(`div`,{onClick:()=>_(e.id),onDoubleClick:()=>{N(e),z(e.reference_code||``),V(e.description||``),F(`description`),L(!1)},className:`flex flex-col items-center p-2 border-[3px] border-transparent hover:bg-slate-50 cursor-pointer rounded select-none text-center ${n?`bg-yellow-50 border-dashed border-ink-black`:``}`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-3xl text-emerald-600`,children:`article`}),(0,a.jsx)(`span`,{className:`font-bold text-[10px] truncate w-full mt-1.5 leading-tight`,children:t}),(0,a.jsx)(`span`,{className:`text-[8px] text-slate-400 font-bold uppercase mt-0.5`,children:e.difficulty})]},e.id)})})),Y===`Wallpapers`&&(0,a.jsx)(`div`,{className:`grid grid-cols-2 gap-3 select-none`,children:v.map(n=>{let r=g===n.name,i=t===n.url;return(0,a.jsxs)(`div`,{onClick:()=>_(n.name),className:`border-[3px] p-2 flex flex-col cursor-pointer bg-slate-50 relative hover:bg-slate-100 ${r?`border-ink-black bg-yellow-50 shadow-[2px_2px_0_0_#1E293B]`:`border-slate-300`}`,children:[(0,a.jsxs)(`div`,{className:`aspect-video w-full border border-slate-300 overflow-hidden bg-black shrink-0 relative`,children:[(0,a.jsx)(`img`,{src:n.url,alt:n.name,className:`w-full h-full object-cover select-none`}),i&&(0,a.jsx)(`div`,{className:`absolute top-1 right-1 bg-green-500 text-white rounded-full w-5 h-5 flex items-center justify-center border border-white`,title:`Active Wallpaper`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px] font-extrabold`,children:`check`})})]}),(0,a.jsx)(`span`,{className:`font-bold text-[10px] mt-1.5 truncate`,children:n.name}),(0,a.jsx)(`p`,{className:`text-[8px] text-slate-400 font-sans leading-tight mt-0.5 line-clamp-2`,children:n.desc}),r&&(0,a.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e(n.url),localStorage.setItem(`desktopWallpaperUrl`,n.url)},className:`mt-2 w-full py-1 bg-highlight-pink text-white border-2 border-ink-black font-window-title font-bold text-[9px] hover:bg-pink-400 shadow-[1px_1px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none transition-all text-center cursor-pointer`,children:`APPLY BACKGROUND`})]},n.name)})})]})]})]}),M&&(0,a.jsx)(`div`,{className:`absolute inset-0 bg-black/60 z-[999] flex items-center justify-center p-4`,children:(0,a.jsxs)(`div`,{className:`w-[90%] h-[90%] bg-paper-white border-[4px] border-ink-black shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden animate-scale-up text-ink-black`,children:[(0,a.jsxs)(`div`,{className:`bg-emerald-600 text-white p-2 border-b-[3px] border-ink-black flex justify-between items-center shrink-0 select-none`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`article`}),(0,a.jsxs)(`span`,{className:`font-window-title font-bold text-xs`,children:[M.name.replace(/\s+/g,`_`),`.py`]})]}),(0,a.jsx)(`button`,{onClick:()=>N(null),className:`bg-white text-ink-black border-[2px] border-ink-black w-5 h-5 flex items-center justify-center font-bold hover:bg-red-500 hover:text-white cursor-pointer`,children:`X`})]}),(0,a.jsxs)(`div`,{className:`bg-slate-200 border-b-2 border-ink-black flex shrink-0 select-none`,children:[(0,a.jsx)(`button`,{onClick:()=>F(`description`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`description`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`PROBLEM DESCRIPTION`}),(0,a.jsx)(`button`,{onClick:()=>F(`code`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`code`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`CODE VIEW & EDIT`}),(0,a.jsx)(`button`,{onClick:()=>F(`properties`),className:`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${P===`properties`?`bg-white translate-y-[2px]`:`bg-slate-300 hover:bg-slate-100`}`,children:`FSRS PROPERTIES`})]}),P===`description`&&(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden bg-slate-900 relative`,children:[I?(0,a.jsx)(`textarea`,{value:B,onChange:e=>V(e.target.value),className:`flex-1 w-full bg-slate-950 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,placeholder:`Enter problem description / question body here...`,spellCheck:`false`}):(0,a.jsx)(`div`,{className:`flex-1 p-4 bg-slate-900 text-[#4ADE80] font-sans text-xs leading-relaxed overflow-y-auto custom-scrollbar select-text`,children:(0,a.jsx)(`div`,{className:`whitespace-pre-wrap font-semibold`,children:M.description||`No description provided for this problem.`})}),I&&(0,a.jsx)(`div`,{className:`absolute top-2 right-2 bg-yellow-400 text-ink-black border border-ink-black px-2 py-0.5 text-[9px] font-bold select-none animate-pulse`,children:`EDIT MODE ACTIVE`})]}),P===`code`&&(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden bg-slate-900 relative`,children:[I?(0,a.jsx)(`textarea`,{value:R,onChange:e=>z(e.target.value),className:`flex-1 w-full bg-slate-950 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,spellCheck:`false`}):(0,a.jsx)(`textarea`,{readOnly:!0,value:M.reference_code||`# Write your solution here.`,className:`flex-1 w-full bg-slate-900 text-[#4ADE80] font-mono p-4 outline-none border-none text-xs leading-relaxed resize-none custom-scrollbar`,spellCheck:`false`}),I&&(0,a.jsx)(`div`,{className:`absolute top-2 right-2 bg-yellow-400 text-ink-black border border-ink-black px-2 py-0.5 text-[9px] font-bold select-none animate-pulse`,children:`EDIT MODE ACTIVE`})]}),P===`properties`&&(0,a.jsxs)(`div`,{className:`flex-1 p-6 overflow-y-auto custom-scrollbar bg-slate-50 font-sans leading-relaxed select-text flex flex-col gap-4`,children:[(0,a.jsx)(`h3`,{className:`font-arcade text-[10px] border-b border-slate-300 pb-1 text-slate-500`,children:`Card Diagnostics`}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-[#0ea5e9] block`,children:`Scheduling Status`}),(0,a.jsxs)(`div`,{children:[`FSRS State: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-sky-600`,children:M.fsrs_state!==null&&M.fsrs_state!==void 0?M.fsrs_state===0?`New (0)`:M.fsrs_state===1?`Learning (1)`:M.fsrs_state===2?`Review (2)`:`Relearning (3)`:`Unenrolled`})]}),(0,a.jsxs)(`div`,{children:[`Stability: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.fsrs_stability===void 0?`0.0 days`:`${M.fsrs_stability.toFixed(1)} days`})]}),(0,a.jsxs)(`div`,{children:[`Difficulty: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.fsrs_difficulty===void 0?`0.0/10`:`${M.fsrs_difficulty.toFixed(1)}/10`})]}),(0,a.jsxs)(`div`,{children:[`Next Review Date: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.next_review?new Date(M.next_review).toLocaleString():`N/A (Due)`})]}),(0,a.jsxs)(`div`,{children:[`Last Reviewed: `,(0,a.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:M.last_reviewed?new Date(M.last_reviewed).toLocaleDateString():`Never`})]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-2`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-emerald-600 block`,children:`Performance History`}),(0,a.jsxs)(`div`,{children:[`Total Attempts: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm`,children:M.total_attempts})]}),(0,a.jsxs)(`div`,{children:[`Times Correct: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-green-600`,children:M.times_correct})]}),(0,a.jsxs)(`div`,{children:[`Success Ratio: `,(0,a.jsx)(`span`,{className:`font-mono font-bold text-sm text-purple-700`,children:M.total_attempts>0?`${Math.round(M.times_correct/M.total_attempts*100)}%`:`0%`})]})]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 space-y-1.5 text-xs font-semibold`,children:[(0,a.jsx)(`span`,{className:`text-[9px] font-arcade text-slate-400 block`,children:`Properties`}),(0,a.jsxs)(`div`,{children:[`File ID: `,(0,a.jsx)(`span`,{className:`font-mono text-[10px] text-slate-500`,children:M.id})]}),(0,a.jsxs)(`div`,{children:[`Logical Pattern: `,(0,a.jsx)(`span`,{className:`text-blue-600`,children:M.pattern})]}),(0,a.jsxs)(`div`,{children:[`Difficulty Tag: `,(0,a.jsx)(`span`,{className:`uppercase`,children:M.difficulty})]})]})]}),(0,a.jsxs)(`div`,{className:`p-3 bg-slate-100 border-t-[3px] border-ink-black flex justify-between items-center shrink-0 select-none`,children:[(0,a.jsx)(`div`,{children:W&&(0,a.jsx)(`span`,{className:`text-green-600 font-bold text-xs animate-pulse`,children:`✓ Solution saved!`})}),(0,a.jsxs)(`div`,{className:`flex gap-2`,children:[(P===`code`||P===`description`)&&(I?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`button`,{onClick:()=>{z(M.reference_code||``),V(M.description||``),L(!1)},className:`px-3 py-1.5 bg-white hover:bg-slate-50 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer`,children:`CANCEL`}),(0,a.jsx)(`button`,{disabled:H,onClick:se,className:`px-3 py-1.5 bg-[#4ADE80] hover:bg-emerald-400 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:H?`SAVING...`:`SAVE CHANGES`})]}):(0,a.jsxs)(`button`,{onClick:()=>L(!0),className:`px-3 py-1.5 bg-yellow-400 hover:bg-yellow-300 text-ink-black border-2 border-ink-black font-bold text-xs cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`edit`}),`EDIT FILE`]})),(0,a.jsxs)(`button`,{onClick:()=>de(I?R:M.reference_code),className:`px-3 py-1.5 bg-[#ffcc00] hover:bg-yellow-300 text-ink-black border-2 border-ink-black font-bold text-xs shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none cursor-pointer flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`content_copy`}),ie?`COPIED!`:`COPY CODE`]}),(0,a.jsx)(`button`,{onClick:()=>N(null),className:`px-3 py-1.5 bg-white hover:bg-slate-50 text-ink-black border-2 border-ink-black font-bold text-xs shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none cursor-pointer`,children:`CLOSE`})]})]})]})}),ne&&(0,a.jsx)(`div`,{className:`absolute inset-0 bg-black/60 z-[999] flex items-center justify-center p-4 select-none`,children:(0,a.jsxs)(`div`,{className:`w-[80%] max-w-[400px] bg-paper-white border-[4px] border-ink-black shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden animate-scale-up text-ink-black font-sans`,children:[(0,a.jsxs)(`div`,{className:`bg-indigo-700 text-white p-2.5 border-b-[3px] border-ink-black flex justify-between items-center font-bold`,children:[(0,a.jsx)(`span`,{className:`font-window-title text-xs`,children:`IMPORT PROBLEMS`}),(0,a.jsx)(`button`,{onClick:()=>{T(!1),k(``),j(``)},className:`bg-white text-ink-black border-[2px] border-ink-black w-5 h-5 flex items-center justify-center font-bold hover:bg-red-500 hover:text-white cursor-pointer`,children:`X`})]}),(0,a.jsxs)(`div`,{className:`p-6 space-y-4`,children:[O&&(0,a.jsx)(`div`,{className:`p-2 border-2 border-red-500 bg-red-50 text-red-800 text-[10px] font-mono leading-relaxed`,children:O}),A&&(0,a.jsx)(`div`,{className:`p-2 border-2 border-green-500 bg-green-50 text-green-800 text-[10px] font-mono leading-relaxed`,children:A}),(0,a.jsxs)(`div`,{className:`flex flex-col items-center justify-center border-4 border-dashed border-ink-black p-6 relative ${E?`bg-indigo-50 cursor-wait`:`bg-slate-50 hover:bg-slate-100 cursor-pointer`}`,children:[E?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-indigo-700 mb-2 animate-bounce`,children:`cloud_upload`}),(0,a.jsx)(`span`,{className:`text-xs font-bold text-indigo-800 text-center`,children:`UPLOADING & PROCESSING...`}),(0,a.jsx)(`span`,{className:`text-[9px] text-indigo-600 mt-1 uppercase font-semibold text-center`,children:`Please wait, this might take a moment`})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-indigo-700 mb-2`,children:`upload_file`}),(0,a.jsx)(`span`,{className:`text-xs font-bold text-ink-black text-center`,children:`SELECT A CSV OR SQLite (.DB) FILE`}),(0,a.jsx)(`span`,{className:`text-[9px] text-slate-400 mt-1 uppercase font-semibold text-center`,children:`Imports problems & solution notes`})]}),(0,a.jsx)(`input`,{type:`file`,accept:`.csv,.db`,disabled:E,onChange:re,className:`absolute inset-0 opacity-0 cursor-pointer w-full h-full disabled:cursor-wait`})]}),(0,a.jsxs)(`div`,{className:`text-[9px] text-slate-400 font-medium leading-normal space-y-1 font-sans`,children:[(0,a.jsxs)(`p`,{children:[`• `,(0,a.jsx)(`b`,{children:`CSV File:`}),` Must have a `,(0,a.jsx)(`code`,{children:`name`}),` column. Optional: `,(0,a.jsx)(`code`,{children:`problem_number`}),`, `,(0,a.jsx)(`code`,{children:`pattern`}),`, `,(0,a.jsx)(`code`,{children:`difficulty`}),`, `,(0,a.jsx)(`code`,{children:`optimal_time`}),`, `,(0,a.jsx)(`code`,{children:`optimal_space`}),`, `,(0,a.jsx)(`code`,{children:`reference_code`}),`, `,(0,a.jsx)(`code`,{children:`description`}),`.`]}),(0,a.jsxs)(`p`,{children:[`• `,(0,a.jsx)(`b`,{children:`SQLite DB File:`}),` Must be a standard database backup containing a `,(0,a.jsx)(`code`,{children:`problems`}),` table matching AlgoSpaced design.`]})]})]})]})})]})}export{s as default};
algospaced-ui/dist/assets/GitHubSyncWindow-CrRFKIeu.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n,M as r,Q as i,St as a,W as o,Z as s,_t as c,a as l,et as u,ht as d,it as f,nt as p,rt as m,ut as h}from"./vendor-react-hnaVBnLv.js";import{a as g,c as _,i as v,l as y,n as b,o as x,r as S,s as C,t as w}from"./githubSyncService-x0Mm_uEl.js";var T=e(n(),1),E=t(),D=({onClose:e,currentProblem:t})=>{let[n,D]=(0,T.useState)(()=>S()),[O,k]=(0,T.useState)(()=>v()),[A,j]=(0,T.useState)(``),[M,N]=(0,T.useState)(!1),[P,F]=(0,T.useState)(!1),[I,L]=(0,T.useState)(!1),[R,z]=(0,T.useState)(!1),[B,V]=(0,T.useState)(!1),[H,U]=(0,T.useState)(!1),[W,G]=(0,T.useState)(!1),[K,q]=(0,T.useState)(null),J=!!(n.token&&(n.username||O?.login));(0,T.useEffect)(()=>{n.token&&!O&&y(n.token).then(e=>{e.valid&&e.user&&(k(e.user),C({username:e.user.login},e.user))})},[n.token,O]);let Y=async()=>{L(!0),q(null);try{let{token:e,user:t}=await b();k(t);let n=S();D(n);try{await g(e,n.repoName,n.isPrivate)}catch{}q({type:`success`,text:`Connected successfully to GitHub as @${t.login}!`,linkUrl:t.html_url})}catch(e){q({type:`error`,text:e.message||`GitHub OAuth authorization failed.`})}finally{L(!1)}},X=async()=>{let e=A.trim();if(!e){q({type:`error`,text:`Please enter a valid GitHub token.`});return}z(!0),q(null);try{let t=await y(e);if(t.valid&&t.user){k(t.user),C({token:e,username:t.user.login},t.user),D(S());try{await g(e,n.repoName,n.isPrivate)}catch{}j(``),N(!1),q({type:`success`,text:`Verified and connected as @${t.user.login}!`,linkUrl:t.user.html_url})}else q({type:`error`,text:t.error||`Token verification failed. Please check permissions.`})}catch(e){q({type:`error`,text:e.message||`Failed to connect with token.`})}finally{z(!1)}},Z=async()=>{if(n.token){V(!0),q(null);try{let e=await g(n.token,n.repoName,n.isPrivate);C({repoName:n.repoName}),q({type:`success`,text:e.created?`Created new repository ${e.full_name} on GitHub!`:`Connected to existing repository ${e.full_name}!`,linkUrl:e.html_url})}catch(e){q({type:`error`,text:e.message||`Failed to initialize repository.`})}finally{V(!1)}}},Q=async()=>{if(n.token&&n.repoName){U(!0),q(null);try{let e=await _(n.token,n.repoName,n.branch);q({type:`success`,text:e.message||`Synced ${e.synced_count} solutions to ${n.repoName}!`,linkUrl:e.repo_url})}catch(e){q({type:`error`,text:e.message||`Batch sync failed.`})}finally{U(!1)}}},$=async()=>{if(!t||!n.token)return;let e=t.code||t.reference_code;if(!e||!e.trim()){q({type:`error`,text:`Current problem has no code to push. Write or save code first!`});return}G(!0),q(null);try{let r={token:n.token,repo:n.repoName,branch:n.branch,problem_number:t.problem_number,problem_name:t.name||`Algorithm Problem`,difficulty:t.difficulty||`Medium`,pattern:t.pattern||`Algorithms`,optimal_time:t.optimal_time||`O(N)`,optimal_space:t.optimal_space||`O(1)`,description:t.description||``,code:e},i=await x(r);q({type:`success`,text:`Committed ${t.name} to GitHub!`,linkUrl:i.html_url})}catch(e){q({type:`error`,text:e.message||`Failed to push current solution.`})}finally{G(!1)}},ee=e=>{C({autoCommit:e}),D(t=>({...t,autoCommit:e})),q({type:`info`,text:e?`Auto-commit ENABLED: Solutions will sync automatically on submission.`:`Auto-commit DISABLED: You can still push manually any time.`})};return(0,E.jsxs)(`div`,{className:`w-full h-full bg-[#fdf8e1] p-4 sm:p-6 flex flex-col justify-between select-none font-sans text-ink-black overflow-y-auto custom-scrollbar`,children:[(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between border-b-[3px] border-ink-black pb-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.jsx)(`div`,{className:`w-9 h-9 bg-ink-black rounded border-2 border-ink-black flex items-center justify-center text-white shadow-[2px_2px_0px_0px_rgba(0,0,0,0.15)]`,children:(0,E.jsx)(`svg`,{className:`w-5 h-5 fill-white`,viewBox:`0 0 19 19`,children:(0,E.jsx)(`path`,{fillRule:`evenodd`,d:`M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844`,clipRule:`evenodd`})})}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{className:`font-headline-md font-bold text-sm uppercase m-0 flex items-center gap-2`,children:`GitHub Solutions Station`}),(0,E.jsx)(`p`,{className:`text-[11px] text-trash-gray font-semibold m-0`,children:`Sync algorithm solutions & auto-commit to your personal portfolio repository`})]})]}),(0,E.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,E.jsx)(`span`,{className:`px-2.5 py-1 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black ${J?`bg-emerald-300 text-emerald-950`:`bg-amber-200 text-amber-950`}`,children:J?`CONNECTED`:`DISCONNECTED`})})]}),J?(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[O?.avatar_url?(0,E.jsx)(`img`,{src:O.avatar_url,alt:O.login,className:`w-10 h-10 rounded-full border-2 border-ink-black shadow-[1px_1px_0px_0px_#1E293B]`}):(0,E.jsx)(`div`,{className:`w-10 h-10 bg-slate-200 rounded-full border-2 border-ink-black flex items-center justify-center font-bold`,children:`GH`}),(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:`font-bold text-xs text-ink-black`,children:O?.name||O?.login||n.username}),(0,E.jsxs)(`span`,{className:`text-[10px] text-trash-gray font-mono`,children:[`(@`,O?.login||n.username,`)`]})]}),(0,E.jsxs)(`div`,{className:`text-[11px] text-slate-600 font-medium flex items-center gap-1 mt-0.5`,children:[(0,E.jsx)(u,{className:`w-3.5 h-3.5 text-blue-600 shrink-0`}),(0,E.jsxs)(`span`,{className:`font-semibold text-ink-black`,children:[n.username||O?.login,`/`,n.repoName]}),(0,E.jsxs)(`span`,{className:`text-slate-400`,children:[`(`,n.branch,`)`]})]})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(`a`,{href:`https://github.com/${n.username||O?.login}/${n.repoName}`,target:`_blank`,rel:`noopener noreferrer`,className:`px-3 py-1.5 bg-slate-50 hover:bg-slate-100 border-2 border-ink-black text-xs font-bold text-ink-black flex items-center gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none no-underline cursor-pointer`,children:[(0,E.jsx)(f,{className:`w-3.5 h-3.5`}),(0,E.jsx)(`span`,{children:`View Repo`})]}),(0,E.jsxs)(`button`,{onClick:()=>{window.confirm(`Disconnect your GitHub account from AlgoSpaced?`)&&(w(),D(S()),k(null),q({type:`info`,text:`Disconnected from GitHub.`}))},className:`px-3 py-1.5 bg-white hover:bg-rose-50 border-2 border-rose-300 text-rose-700 text-xs font-bold flex items-center gap-1 cursor-pointer transition-all`,title:`Disconnect GitHub`,children:[(0,E.jsx)(o,{className:`w-3 h-3`}),(0,E.jsx)(`span`,{children:`Disconnect`})]})]})]}),(0,E.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2 border-slate-200`,children:[(0,E.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,E.jsx)(i,{className:`w-3.5 h-3.5 text-ink-black`}),`Target Repository & Branch`]}),(0,E.jsxs)(`button`,{onClick:Z,disabled:B,className:`px-2.5 py-1 bg-yellow-100 hover:bg-yellow-200 border border-ink-black text-[10px] font-bold text-ink-black flex items-center gap-1 cursor-pointer disabled:opacity-50 shadow-[1px_1px_0px_0px_#1E293B]`,children:[B?(0,E.jsx)(r,{className:`w-3 h-3 animate-spin`}):(0,E.jsx)(a,{className:`w-3 h-3 text-emerald-700`}),(0,E.jsx)(`span`,{children:`Verify / Init Repo`})]})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Repository Name`}),(0,E.jsx)(`input`,{type:`text`,value:n.repoName,onChange:e=>{let t=e.target.value;D(e=>({...e,repoName:t})),C({repoName:t})},placeholder:`algospaced-solutions`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-1.5 px-2.5 text-xs font-mono font-medium focus:outline-none focus:bg-white`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Branch Name`}),(0,E.jsx)(`input`,{type:`text`,value:n.branch,onChange:e=>{let t=e.target.value;D(e=>({...e,branch:t})),C({branch:t})},placeholder:`main`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-1.5 px-2.5 text-xs font-mono font-medium focus:outline-none focus:bg-white`})]})]}),(0,E.jsxs)(`div`,{className:`pt-2 border-t border-slate-100 flex items-center justify-between`,children:[(0,E.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,E.jsx)(l,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,E.jsx)(`span`,{className:`text-[10px] text-trash-gray font-medium`,children:`Automatically push code to your repo when grading a review card or saving a solution.`})]})]}),(0,E.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer select-none`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:n.autoCommit,onChange:e=>ee(e.target.checked),className:`sr-only peer`}),(0,E.jsx)(`div`,{className:`w-9 h-5 bg-slate-300 peer-focus:outline-none border-2 border-ink-black rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-2 after:border-ink-black after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-emerald-500`})]})]})]}),(0,E.jsxs)(`div`,{className:`bg-[#fffdf0] border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,E.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,E.jsx)(h,{className:`w-3.5 h-3.5 text-ink-black`}),`Manual Push & Sync Operations`]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,E.jsxs)(`button`,{onClick:$,disabled:W||!t,className:`p-3 bg-white hover:bg-emerald-50 border-2 border-ink-black text-left flex flex-col justify-between gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer transition-all disabled:opacity-50`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,E.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[W?(0,E.jsx)(r,{className:`w-3.5 h-3.5 animate-spin text-emerald-600`}):(0,E.jsx)(s,{className:`w-3.5 h-3.5 text-emerald-600`}),`Push Active Problem`]}),t?.problem_number&&(0,E.jsxs)(`span`,{className:`text-[9px] font-mono px-1.5 py-0.5 bg-emerald-100 text-emerald-800 rounded font-bold`,children:[`#`,t.problem_number]})]}),(0,E.jsx)(`span`,{className:`text-[10px] text-slate-500 line-clamp-1`,children:t?.name||`No active problem open in review`})]}),(0,E.jsxs)(`button`,{onClick:Q,disabled:H,className:`p-3 bg-[#ffe24c] hover:bg-yellow-300 border-2 border-ink-black text-left flex flex-col justify-between gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer transition-all disabled:opacity-50`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,E.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[H?(0,E.jsx)(r,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):(0,E.jsx)(u,{className:`w-3.5 h-3.5 text-ink-black`}),`Sync Entire Library`]}),(0,E.jsx)(`span`,{className:`text-[8px] font-arcade uppercase font-bold bg-white px-1.5 py-0.5 border border-ink-black`,children:`BATCH`})]}),(0,E.jsx)(`span`,{className:`text-[10px] text-slate-700`,children:`Push all solved problems + generate root README index`})]})]})]})]}):(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-5 sm:p-6 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] text-center space-y-4`,children:[(0,E.jsxs)(`div`,{className:`max-w-md mx-auto space-y-2`,children:[(0,E.jsx)(`h4`,{className:`font-headline-md font-bold text-sm uppercase text-ink-black m-0`,children:`Connect Your GitHub Account`}),(0,E.jsx)(`p`,{className:`text-xs text-trash-gray font-medium leading-relaxed m-0`,children:`Sync all your DSA solutions directly to your GitHub repository. Commit automatically on review completion or push anytime with 1-click.`})]}),(0,E.jsxs)(`div`,{className:`pt-2 flex flex-col items-center`,children:[(0,E.jsx)(`button`,{onClick:Y,disabled:I,className:`w-full sm:w-auto px-6 py-3 bg-[#24292e] hover:bg-black text-white font-bold text-xs uppercase font-headline-md border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center justify-center gap-2.5 transition-all cursor-pointer disabled:opacity-50`,children:I?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(r,{className:`w-4 h-4 animate-spin text-yellow-300`}),(0,E.jsx)(`span`,{children:`AUTHORIZING WITH GITHUB...`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`svg`,{className:`w-4 h-4 fill-white`,viewBox:`0 0 19 19`,children:(0,E.jsx)(`path`,{fillRule:`evenodd`,d:`M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844`,clipRule:`evenodd`})}),(0,E.jsx)(`span`,{children:`CONNECT WITH GITHUB (1-CLICK)`})]})}),(0,E.jsxs)(`span`,{className:`text-[10px] text-trash-gray mt-2`,children:[`Direct 1-click OAuth (works for guest and signed-in users). Requests `,(0,E.jsx)(`code`,{children:`repo`}),` access.`]})]})]}),(0,E.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)]`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>N(!M),className:`w-full flex items-center justify-between text-left text-xs font-bold text-ink-black font-headline-md uppercase cursor-pointer bg-transparent border-0 p-0`,children:[(0,E.jsx)(`span`,{children:`Or connect via Personal Access Token (PAT)`}),(0,E.jsx)(`span`,{className:`text-slate-500`,children:M?`▲ Hide`:`▼ Show`})]}),M&&(0,E.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-slate-200 space-y-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,E.jsx)(`span`,{className:`font-semibold text-slate-700`,children:`Personal Access Token:`}),(0,E.jsxs)(`a`,{href:`https://github.com/settings/tokens/new?scopes=repo&description=AlgoSpaced%20Solutions%20Sync`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 hover:text-blue-800 font-bold flex items-center gap-1 no-underline text-[10px]`,children:[(0,E.jsx)(`span`,{children:`Generate token with repo scope`}),(0,E.jsx)(f,{className:`w-3 h-3`})]})]}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(`input`,{type:P?`text`:`password`,value:A,onChange:e=>j(e.target.value),placeholder:`ghp_... or github_pat_...`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-2 pl-3 pr-9 text-xs font-mono focus:outline-none focus:bg-white`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>F(!P),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-ink-black cursor-pointer bg-transparent border-0 p-1`,children:P?(0,E.jsx)(m,{className:`w-3.5 h-3.5`}):(0,E.jsx)(p,{className:`w-3.5 h-3.5`})})]}),(0,E.jsx)(`button`,{onClick:X,disabled:R||!A.trim(),className:`px-4 py-2 bg-[#ffe24c] hover:bg-yellow-300 text-ink-black font-bold text-xs uppercase border-2 border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer disabled:opacity-50 flex items-center gap-1.5`,children:R?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(r,{className:`w-3.5 h-3.5 animate-spin`}),(0,E.jsx)(`span`,{children:`VERIFYING TOKEN...`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(a,{className:`w-3.5 h-3.5`}),(0,E.jsx)(`span`,{children:`SAVE & CONNECT TOKEN`})]})})]})]})]}),K&&(0,E.jsxs)(`div`,{className:`p-3 border-[2px] border-ink-black text-xs font-semibold rounded flex items-center justify-between gap-2 ${K.type===`success`?`bg-emerald-100 text-emerald-900 border-emerald-600`:K.type===`error`?`bg-rose-100 text-rose-900 border-rose-600`:`bg-sky-100 text-sky-900 border-sky-600`}`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K.type===`success`?(0,E.jsx)(d,{className:`w-4 h-4 shrink-0`}):(0,E.jsx)(c,{className:`w-4 h-4 shrink-0`}),(0,E.jsx)(`span`,{children:K.text})]}),K.linkUrl&&(0,E.jsxs)(`a`,{href:K.linkUrl,target:`_blank`,rel:`noopener noreferrer`,className:`px-2 py-0.5 bg-white border border-ink-black text-[10px] font-bold text-ink-black hover:bg-slate-50 no-underline shrink-0 flex items-center gap-1`,children:[(0,E.jsx)(`span`,{children:`Open`}),(0,E.jsx)(f,{className:`w-3 h-3`})]})]})]}),(0,E.jsx)(`div`,{className:`pt-4 border-t border-slate-300 flex justify-end`,children:(0,E.jsx)(`button`,{onClick:e,className:`px-4 py-2 bg-white hover:bg-slate-100 border-[2px] border-ink-black text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase`,children:`CLOSE`})})]})};export{D as GitHubSyncWindow,D as default};
algospaced-ui/dist/assets/GitHubSyncWindow-DHS56rys.js DELETED
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,Bt as r,H as i,Rt as a,X as o,Y as s,Z as c,a as l,et as u,ft as d,mt as f,st as p,tt as m,yt as h}from"./vendor-react-CIO8MTK1.js";import{a as g,c as _,i as v,l as y,n as b,o as x,r as S,s as C,t as w}from"./githubSyncService-x0Mm_uEl.js";var T=e(r(),1),E=a(),D=({onClose:e,currentProblem:r})=>{let[a,D]=(0,T.useState)(()=>S()),[O,k]=(0,T.useState)(()=>v()),[A,j]=(0,T.useState)(``),[M,N]=(0,T.useState)(!1),[P,F]=(0,T.useState)(!1),[I,L]=(0,T.useState)(!1),[R,z]=(0,T.useState)(!1),[B,V]=(0,T.useState)(!1),[H,U]=(0,T.useState)(!1),[W,G]=(0,T.useState)(!1),[K,q]=(0,T.useState)(null),J=!!(a.token&&(a.username||O?.login));(0,T.useEffect)(()=>{a.token&&!O&&y(a.token).then(e=>{e.valid&&e.user&&(k(e.user),C({username:e.user.login},e.user))})},[a.token,O]);let Y=async()=>{L(!0),q(null);try{let{token:e,user:t}=await b();k(t);let n=S();D(n);try{await g(e,n.repoName,n.isPrivate)}catch{}q({type:`success`,text:`Connected successfully to GitHub as @${t.login}!`,linkUrl:t.html_url})}catch(e){q({type:`error`,text:e.message||`GitHub OAuth authorization failed.`})}finally{L(!1)}},X=async()=>{let e=A.trim();if(!e){q({type:`error`,text:`Please enter a valid GitHub token.`});return}z(!0),q(null);try{let t=await y(e);if(t.valid&&t.user){k(t.user),C({token:e,username:t.user.login},t.user),D(S());try{await g(e,a.repoName,a.isPrivate)}catch{}j(``),N(!1),q({type:`success`,text:`Verified and connected as @${t.user.login}!`,linkUrl:t.user.html_url})}else q({type:`error`,text:t.error||`Token verification failed. Please check permissions.`})}catch(e){q({type:`error`,text:e.message||`Failed to connect with token.`})}finally{z(!1)}},Z=async()=>{if(a.token){V(!0),q(null);try{let e=await g(a.token,a.repoName,a.isPrivate);C({repoName:a.repoName}),q({type:`success`,text:e.created?`Created new repository ${e.full_name} on GitHub!`:`Connected to existing repository ${e.full_name}!`,linkUrl:e.html_url})}catch(e){q({type:`error`,text:e.message||`Failed to initialize repository.`})}finally{V(!1)}}},Q=async()=>{if(a.token&&a.repoName){U(!0),q(null);try{let e=await _(a.token,a.repoName,a.branch);q({type:`success`,text:e.message||`Synced ${e.synced_count} solutions to ${a.repoName}!`,linkUrl:e.repo_url})}catch(e){q({type:`error`,text:e.message||`Batch sync failed.`})}finally{U(!1)}}},$=async()=>{if(!r||!a.token)return;let e=r.code||r.reference_code;if(!e||!e.trim()){q({type:`error`,text:`Current problem has no code to push. Write or save code first!`});return}G(!0),q(null);try{let t={token:a.token,repo:a.repoName,branch:a.branch,problem_number:r.problem_number,problem_name:r.name||`Algorithm Problem`,difficulty:r.difficulty||`Medium`,pattern:r.pattern||`Algorithms`,optimal_time:r.optimal_time||`O(N)`,optimal_space:r.optimal_space||`O(1)`,description:r.description||``,code:e},n=await x(t);q({type:`success`,text:`Committed ${r.name} to GitHub!`,linkUrl:n.html_url})}catch(e){q({type:`error`,text:e.message||`Failed to push current solution.`})}finally{G(!1)}},ee=e=>{C({autoCommit:e}),D(t=>({...t,autoCommit:e})),q({type:`info`,text:e?`Auto-commit ENABLED: Solutions will sync automatically on submission.`:`Auto-commit DISABLED: You can still push manually any time.`})};return(0,E.jsxs)(`div`,{className:`w-full h-full bg-[#fdf8e1] p-4 sm:p-6 flex flex-col justify-between select-none font-sans text-ink-black overflow-y-auto custom-scrollbar`,children:[(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between border-b-[3px] border-ink-black pb-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.jsx)(`div`,{className:`w-9 h-9 bg-ink-black rounded border-2 border-ink-black flex items-center justify-center text-white shadow-[2px_2px_0px_0px_rgba(0,0,0,0.15)]`,children:(0,E.jsx)(`svg`,{className:`w-5 h-5 fill-white`,viewBox:`0 0 19 19`,children:(0,E.jsx)(`path`,{fillRule:`evenodd`,d:`M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844`,clipRule:`evenodd`})})}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{className:`font-headline-md font-bold text-sm uppercase m-0 flex items-center gap-2`,children:`GitHub Solutions Station`}),(0,E.jsx)(`p`,{className:`text-[11px] text-trash-gray font-semibold m-0`,children:`Sync algorithm solutions & auto-commit to your personal portfolio repository`})]})]}),(0,E.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,E.jsx)(`span`,{className:`px-2.5 py-1 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black ${J?`bg-emerald-300 text-emerald-950`:`bg-amber-200 text-amber-950`}`,children:J?`CONNECTED`:`DISCONNECTED`})})]}),J?(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[O?.avatar_url?(0,E.jsx)(`img`,{src:O.avatar_url,alt:O.login,className:`w-10 h-10 rounded-full border-2 border-ink-black shadow-[1px_1px_0px_0px_#1E293B]`}):(0,E.jsx)(`div`,{className:`w-10 h-10 bg-slate-200 rounded-full border-2 border-ink-black flex items-center justify-center font-bold`,children:`GH`}),(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:`font-bold text-xs text-ink-black`,children:O?.name||O?.login||a.username}),(0,E.jsxs)(`span`,{className:`text-[10px] text-trash-gray font-mono`,children:[`(@`,O?.login||a.username,`)`]})]}),(0,E.jsxs)(`div`,{className:`text-[11px] text-slate-600 font-medium flex items-center gap-1 mt-0.5`,children:[(0,E.jsx)(c,{className:`w-3.5 h-3.5 text-blue-600 shrink-0`}),(0,E.jsxs)(`span`,{className:`font-semibold text-ink-black`,children:[a.username||O?.login,`/`,a.repoName]}),(0,E.jsxs)(`span`,{className:`text-slate-400`,children:[`(`,a.branch,`)`]})]})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(`a`,{href:`https://github.com/${a.username||O?.login}/${a.repoName}`,target:`_blank`,rel:`noopener noreferrer`,className:`px-3 py-1.5 bg-slate-50 hover:bg-slate-100 border-2 border-ink-black text-xs font-bold text-ink-black flex items-center gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none no-underline cursor-pointer`,children:[(0,E.jsx)(m,{className:`w-3.5 h-3.5`}),(0,E.jsx)(`span`,{children:`View Repo`})]}),(0,E.jsxs)(`button`,{onClick:()=>{window.confirm(`Disconnect your GitHub account from AlgoSpaced?`)&&(w(),D(S()),k(null),q({type:`info`,text:`Disconnected from GitHub.`}))},className:`px-3 py-1.5 bg-white hover:bg-rose-50 border-2 border-rose-300 text-rose-700 text-xs font-bold flex items-center gap-1 cursor-pointer transition-all`,title:`Disconnect GitHub`,children:[(0,E.jsx)(i,{className:`w-3 h-3`}),(0,E.jsx)(`span`,{children:`Disconnect`})]})]})]}),(0,E.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2 border-slate-200`,children:[(0,E.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,E.jsx)(o,{className:`w-3.5 h-3.5 text-ink-black`}),`Target Repository & Branch`]}),(0,E.jsxs)(`button`,{onClick:Z,disabled:B,className:`px-2.5 py-1 bg-yellow-100 hover:bg-yellow-200 border border-ink-black text-[10px] font-bold text-ink-black flex items-center gap-1 cursor-pointer disabled:opacity-50 shadow-[1px_1px_0px_0px_#1E293B]`,children:[B?(0,E.jsx)(n,{className:`w-3 h-3 animate-spin`}):(0,E.jsx)(h,{className:`w-3 h-3 text-emerald-700`}),(0,E.jsx)(`span`,{children:`Verify / Init Repo`})]})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Repository Name`}),(0,E.jsx)(`input`,{type:`text`,value:a.repoName,onChange:e=>{let t=e.target.value;D(e=>({...e,repoName:t})),C({repoName:t})},placeholder:`algospaced-solutions`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-1.5 px-2.5 text-xs font-mono font-medium focus:outline-none focus:bg-white`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`block text-[10px] font-bold text-trash-gray uppercase mb-1`,children:`Branch Name`}),(0,E.jsx)(`input`,{type:`text`,value:a.branch,onChange:e=>{let t=e.target.value;D(e=>({...e,branch:t})),C({branch:t})},placeholder:`main`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-1.5 px-2.5 text-xs font-mono font-medium focus:outline-none focus:bg-white`})]})]}),(0,E.jsxs)(`div`,{className:`pt-2 border-t border-slate-100 flex items-center justify-between`,children:[(0,E.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,E.jsx)(l,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,E.jsx)(`span`,{className:`text-[10px] text-trash-gray font-medium`,children:`Automatically push code to your repo when grading a review card or saving a solution.`})]})]}),(0,E.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer select-none`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:a.autoCommit,onChange:e=>ee(e.target.checked),className:`sr-only peer`}),(0,E.jsx)(`div`,{className:`w-9 h-5 bg-slate-300 peer-focus:outline-none border-2 border-ink-black rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-2 after:border-ink-black after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-emerald-500`})]})]})]}),(0,E.jsxs)(`div`,{className:`bg-[#fffdf0] border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,E.jsxs)(`span`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black flex items-center gap-1.5`,children:[(0,E.jsx)(p,{className:`w-3.5 h-3.5 text-ink-black`}),`Manual Push & Sync Operations`]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,E.jsxs)(`button`,{onClick:$,disabled:W||!r,className:`p-3 bg-white hover:bg-emerald-50 border-2 border-ink-black text-left flex flex-col justify-between gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer transition-all disabled:opacity-50`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,E.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[W?(0,E.jsx)(n,{className:`w-3.5 h-3.5 animate-spin text-emerald-600`}):(0,E.jsx)(s,{className:`w-3.5 h-3.5 text-emerald-600`}),`Push Active Problem`]}),r?.problem_number&&(0,E.jsxs)(`span`,{className:`text-[9px] font-mono px-1.5 py-0.5 bg-emerald-100 text-emerald-800 rounded font-bold`,children:[`#`,r.problem_number]})]}),(0,E.jsx)(`span`,{className:`text-[10px] text-slate-500 line-clamp-1`,children:r?.name||`No active problem open in review`})]}),(0,E.jsxs)(`button`,{onClick:Q,disabled:H,className:`p-3 bg-[#ffe24c] hover:bg-yellow-300 border-2 border-ink-black text-left flex flex-col justify-between gap-1 shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer transition-all disabled:opacity-50`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,E.jsxs)(`span`,{className:`font-bold text-xs text-ink-black font-headline-md flex items-center gap-1.5`,children:[H?(0,E.jsx)(n,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):(0,E.jsx)(c,{className:`w-3.5 h-3.5 text-ink-black`}),`Sync Entire Library`]}),(0,E.jsx)(`span`,{className:`text-[8px] font-arcade uppercase font-bold bg-white px-1.5 py-0.5 border border-ink-black`,children:`BATCH`})]}),(0,E.jsx)(`span`,{className:`text-[10px] text-slate-700`,children:`Push all solved problems + generate root README index`})]})]})]})]}):(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-5 sm:p-6 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] text-center space-y-4`,children:[(0,E.jsxs)(`div`,{className:`max-w-md mx-auto space-y-2`,children:[(0,E.jsx)(`h4`,{className:`font-headline-md font-bold text-sm uppercase text-ink-black m-0`,children:`Connect Your GitHub Account`}),(0,E.jsx)(`p`,{className:`text-xs text-trash-gray font-medium leading-relaxed m-0`,children:`Sync all your DSA solutions directly to your GitHub repository. Commit automatically on review completion or push anytime with 1-click.`})]}),(0,E.jsxs)(`div`,{className:`pt-2 flex flex-col items-center`,children:[(0,E.jsx)(`button`,{onClick:Y,disabled:I,className:`w-full sm:w-auto px-6 py-3 bg-[#24292e] hover:bg-black text-white font-bold text-xs uppercase font-headline-md border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center justify-center gap-2.5 transition-all cursor-pointer disabled:opacity-50`,children:I?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(n,{className:`w-4 h-4 animate-spin text-yellow-300`}),(0,E.jsx)(`span`,{children:`AUTHORIZING WITH GITHUB...`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`svg`,{className:`w-4 h-4 fill-white`,viewBox:`0 0 19 19`,children:(0,E.jsx)(`path`,{fillRule:`evenodd`,d:`M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844`,clipRule:`evenodd`})}),(0,E.jsx)(`span`,{children:`CONNECT WITH GITHUB (1-CLICK)`})]})}),(0,E.jsxs)(`span`,{className:`text-[10px] text-trash-gray mt-2`,children:[`Direct 1-click OAuth (works for guest and signed-in users). Requests `,(0,E.jsx)(`code`,{children:`repo`}),` access.`]})]})]}),(0,E.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)]`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>N(!M),className:`w-full flex items-center justify-between text-left text-xs font-bold text-ink-black font-headline-md uppercase cursor-pointer bg-transparent border-0 p-0`,children:[(0,E.jsx)(`span`,{children:`Or connect via Personal Access Token (PAT)`}),(0,E.jsx)(`span`,{className:`text-slate-500`,children:M?`▲ Hide`:`▼ Show`})]}),M&&(0,E.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-slate-200 space-y-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,E.jsx)(`span`,{className:`font-semibold text-slate-700`,children:`Personal Access Token:`}),(0,E.jsxs)(`a`,{href:`https://github.com/settings/tokens/new?scopes=repo&description=AlgoSpaced%20Solutions%20Sync`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 hover:text-blue-800 font-bold flex items-center gap-1 no-underline text-[10px]`,children:[(0,E.jsx)(`span`,{children:`Generate token with repo scope`}),(0,E.jsx)(m,{className:`w-3 h-3`})]})]}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(`input`,{type:P?`text`:`password`,value:A,onChange:e=>j(e.target.value),placeholder:`ghp_... or github_pat_...`,className:`w-full bg-slate-50 border-2 border-ink-black rounded py-2 pl-3 pr-9 text-xs font-mono focus:outline-none focus:bg-white`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>F(!P),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-ink-black cursor-pointer bg-transparent border-0 p-1`,children:P?(0,E.jsx)(u,{className:`w-3.5 h-3.5`}):(0,E.jsx)(t,{className:`w-3.5 h-3.5`})})]}),(0,E.jsx)(`button`,{onClick:X,disabled:R||!A.trim(),className:`px-4 py-2 bg-[#ffe24c] hover:bg-yellow-300 text-ink-black font-bold text-xs uppercase border-2 border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer disabled:opacity-50 flex items-center gap-1.5`,children:R?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(n,{className:`w-3.5 h-3.5 animate-spin`}),(0,E.jsx)(`span`,{children:`VERIFYING TOKEN...`})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(h,{className:`w-3.5 h-3.5`}),(0,E.jsx)(`span`,{children:`SAVE & CONNECT TOKEN`})]})})]})]})]}),K&&(0,E.jsxs)(`div`,{className:`p-3 border-[2px] border-ink-black text-xs font-semibold rounded flex items-center justify-between gap-2 ${K.type===`success`?`bg-emerald-100 text-emerald-900 border-emerald-600`:K.type===`error`?`bg-rose-100 text-rose-900 border-rose-600`:`bg-sky-100 text-sky-900 border-sky-600`}`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[K.type===`success`?(0,E.jsx)(d,{className:`w-4 h-4 shrink-0`}):(0,E.jsx)(f,{className:`w-4 h-4 shrink-0`}),(0,E.jsx)(`span`,{children:K.text})]}),K.linkUrl&&(0,E.jsxs)(`a`,{href:K.linkUrl,target:`_blank`,rel:`noopener noreferrer`,className:`px-2 py-0.5 bg-white border border-ink-black text-[10px] font-bold text-ink-black hover:bg-slate-50 no-underline shrink-0 flex items-center gap-1`,children:[(0,E.jsx)(`span`,{children:`Open`}),(0,E.jsx)(m,{className:`w-3 h-3`})]})]})]}),(0,E.jsx)(`div`,{className:`pt-4 border-t border-slate-300 flex justify-end`,children:(0,E.jsx)(`button`,{onClick:e,className:`px-4 py-2 bg-white hover:bg-slate-100 border-[2px] border-ink-black text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none cursor-pointer uppercase`,children:`CLOSE`})})]})};export{D as GitHubSyncWindow,D as default};
 
 
algospaced-ui/dist/assets/JourneyPath-BhAvKOiu.js ADDED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/assets/JourneyPath-Dpd3IPxF.js DELETED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/assets/{KatexRenderer-HIhDCm0G.js → KatexRenderer-DVt2cqHc.js} RENAMED
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{Bt as e,Rt as t}from"./vendor-react-CIO8MTK1.js";import{t as n}from"./vendor-katex-Balf574a.js";e();var r=t(),i=({math:e,displayMode:t=!1,className:i=``})=>{let a=``;try{a=n.renderToString(e.trim(),{displayMode:t,throwOnError:!1,output:`html`})}catch{a=`<span class="katex-error text-rose-600 font-mono text-[11px]">${e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}</span>`}return(0,r.jsx)(`span`,{className:i,dangerouslySetInnerHTML:{__html:a}})};export{i as KatexRenderer,i as default};
 
1
+ import"./rolldown-runtime-hePW80VL.js";import{Bt as e,Ht as t}from"./vendor-react-hnaVBnLv.js";import{t as n}from"./vendor-katex-Balf574a.js";t();var r=e(),i=({math:e,displayMode:t=!1,className:i=``})=>{let a=``;try{a=n.renderToString(e.trim(),{displayMode:t,throwOnError:!1,output:`html`})}catch{a=`<span class="katex-error text-rose-600 font-mono text-[11px]">${e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}</span>`}return(0,r.jsx)(`span`,{className:i,dangerouslySetInnerHTML:{__html:a}})};export{i as KatexRenderer,i as default};
algospaced-ui/dist/assets/{MarkdownRenderer-BMZIn30p.js → MarkdownRenderer-D8UdFpnD.js} RENAMED
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KatexRenderer-HIhDCm0G.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-react-CIO8MTK1.js","assets/vendor-codemirror-By0wlJeM.js","assets/vendor-katex-Balf574a.js","assets/vendor-katex-DtkCqjBQ.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Rt as n}from"./vendor-react-CIO8MTK1.js";import{t as r}from"./index-DnK6BACV.js";var i=e(t(),1),a=n(),o=(0,i.lazy)(()=>r(()=>import(`./KatexRenderer-HIhDCm0G.js`),__vite__mapDeps([0,1,2,3,4,5])));function s(e){return e?e.split(/(\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\]|\\\([\s\S]*?\\\)|\$(?:\\\$|[^$\n])+?\$|`[^`\n]+`|\*\*[^*\n]+\*\*|__[^_\n]+__|(?<!\*)\*[^*\n]+(?<!\*)\*|(?<!_)_[^_\n]+(?<!_)_|\[[^\]\n]+\]\([^)\n]+\))/g).map((e,t)=>{if(!e)return null;if(e.startsWith(`$$`)&&e.endsWith(`$$`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!0,className:`inline-block my-1 px-1 overflow-x-auto align-middle`})},t):e}if(e.startsWith(`\\[`)&&e.endsWith(`\\]`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!0,className:`inline-block my-1 px-1 overflow-x-auto align-middle`})},t):e}if(e.startsWith(`\\(`)&&e.endsWith(`\\)`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!1,className:`inline-katex px-0.5 align-baseline`})},t):e}if(e.startsWith(`$`)&&e.endsWith(`$`)&&e.length>=2){let n=e.slice(1,-1);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!1,className:`inline-katex px-0.5 align-baseline`})},t):e}if(e.startsWith("`")&&e.endsWith("`")&&e.length>=2)return(0,a.jsx)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] px-1.5 py-0.5 rounded text-[11px] font-mono border border-ink-black shadow-[1px_1px_0px_0px_#000]`,children:e.slice(1,-1)},t);if(e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>=4||e.startsWith(`__`)&&e.endsWith(`__`)&&e.length>=4)return(0,a.jsx)(`strong`,{className:`text-ink-black font-extrabold`,children:s(e.slice(2,-2))},t);if(e.startsWith(`*`)&&e.endsWith(`*`)&&e.length>=2||e.startsWith(`_`)&&e.endsWith(`_`)&&e.length>=2)return(0,a.jsx)(`em`,{className:`italic text-slate-800`,children:s(e.slice(1,-1))},t);let n=e.match(/^\[([^\]]+)\]\(([^)]+)\)$/);return n?(0,a.jsx)(`a`,{href:n[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline hover:text-primary/80 font-bold`,children:n[1]},t):e}):[]}var c=(0,i.lazy)(()=>r(()=>import(`./KatexRenderer-HIhDCm0G.js`),__vite__mapDeps([0,1,2,3,4,5]))),l=({content:e,className:t=``})=>{if(!e)return null;let n=e.split(/(```[\s\S]*?```|\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\])/g);return(0,a.jsx)(`div`,{className:`markdown-content space-y-2.5 text-ink-black text-xs leading-relaxed font-sans ${t}`,children:n.map((e,t)=>{if(!e)return null;let n=e.trim();if(n.startsWith("```")&&n.endsWith("```")&&n.length>=6){let e=n.indexOf(`
3
  `),r=e===-1?``:n.slice(3,e).trim(),i=e===-1?n.slice(3,-3).trim():n.slice(e+1,-3).trimEnd();return(0,a.jsxs)(`div`,{className:`my-3 rounded-md overflow-hidden border-[2px] border-ink-black shadow-[3px_3px_0px_0px_#1E293B] bg-[#1E293B]`,children:[r&&(0,a.jsxs)(`div`,{className:`bg-slate-800 text-slate-400 px-3 py-1 text-[9px] font-arcade uppercase tracking-wider border-b border-slate-700 flex justify-between items-center`,children:[(0,a.jsx)(`span`,{children:r}),(0,a.jsx)(`span`,{className:`text-[8px] opacity-70`,children:`SNIPPET`})]}),(0,a.jsx)(`pre`,{className:`p-3 overflow-x-auto font-mono text-[11px] text-[#4ADE80] leading-relaxed custom-scrollbar selection:bg-[#4ADE80] selection:text-[#1E293B]`,children:(0,a.jsx)(`code`,{children:i})})]},`code-${t}`)}if(n.startsWith(`$$`)&&n.endsWith(`$$`)&&n.length>=4||n.startsWith(`\\[`)&&n.endsWith(`\\]`)&&n.length>=4){let e=n.slice(2,-2);return(0,a.jsx)(`div`,{className:`my-3 p-3 bg-slate-50 border-2 border-ink-black rounded overflow-x-auto text-center shadow-[2px_2px_0px_0px_rgba(30,41,59,0.3)] custom-scrollbar`,children:(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:e}),children:(0,a.jsx)(c,{math:e,displayMode:!0})})},`math-${t}`)}let r=e.split(`
4
  `),o=[],l=0;for(;l<r.length;){let e=r[l],n=e.trim(),i=`${t}-${l}`;if(n===``){o.push((0,a.jsx)(`div`,{className:`h-1`},i)),l++;continue}if(n.startsWith(`|`)&&n.endsWith(`|`)&&l+1<r.length&&r[l+1].trim().startsWith(`|`)){let e=[];for(;l<r.length&&r[l].trim().startsWith(`|`)&&r[l].trim().endsWith(`|`);)e.push(r[l].trim()),l++;if(e.length>=2){let t=e[0].slice(1,-1).split(`|`).map(e=>e.trim()),n=e.slice(2).map(e=>e.slice(1,-1).split(`|`).map(e=>e.trim()));o.push((0,a.jsx)(`div`,{className:`my-3 overflow-x-auto border-2 border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,a.jsx)(`thead`,{children:(0,a.jsx)(`tr`,{className:`bg-slate-200 border-b-2 border-ink-black`,children:t.map((e,t)=>(0,a.jsx)(`th`,{className:`p-2 font-bold font-headline-md border-r last:border-r-0 border-ink-black`,children:s(e)},t))})}),(0,a.jsx)(`tbody`,{children:n.map((e,t)=>(0,a.jsx)(`tr`,{className:`border-b border-slate-300 last:border-b-0 ${t%2==1?`bg-slate-50`:`bg-white`}`,children:e.map((e,t)=>(0,a.jsx)(`td`,{className:`p-2 border-r last:border-r-0 border-slate-200 font-medium`,children:s(e)},t))},t))})]})},`table-${i}`));continue}}if(n.startsWith(`#### `)){o.push((0,a.jsx)(`h4`,{className:`text-xs font-bold text-ink-black mt-3 mb-1 font-headline-md`,children:s(n.substring(5))},i)),l++;continue}if(n.startsWith(`### `)){o.push((0,a.jsxs)(`h3`,{className:`text-xs font-bold text-primary mt-4 mb-1.5 uppercase font-arcade tracking-wide flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`w-2 h-2 bg-primary inline-block rounded-xs`}),s(n.substring(4))]},i)),l++;continue}if(n.startsWith(`## `)){o.push((0,a.jsx)(`h2`,{className:`text-sm font-extrabold text-ink-black mt-4 mb-2 font-headline-md border-b-2 border-ink-black pb-1`,children:s(n.substring(3))},i)),l++;continue}if(n.startsWith(`# `)){o.push((0,a.jsx)(`h1`,{className:`text-base font-black text-ink-black mt-5 mb-2 font-headline-md`,children:s(n.substring(2))},i)),l++;continue}if(n===`---`||n===`***`||n===`___`){o.push((0,a.jsx)(`hr`,{className:`my-3 border-t-2 border-dashed border-slate-300`},i)),l++;continue}if(e.trim().startsWith(`>`)){o.push((0,a.jsx)(`blockquote`,{className:`border-l-4 border-primary pl-3 py-1 my-2 bg-slate-50 italic text-slate-700`,children:s(e.trim().substring(1).trim())},i)),l++;continue}if(n.startsWith(`- `)||n.startsWith(`* `)||n.startsWith(`+ `)){let t=e.search(/\S/)>=2?`pl-6`:`pl-2`;o.push((0,a.jsxs)(`div`,{className:`flex items-start gap-2 my-1 ${t}`,children:[(0,a.jsx)(`span`,{className:`text-primary font-bold mt-0.5 shrink-0`,children:`•`}),(0,a.jsx)(`div`,{className:`text-ink-black leading-relaxed flex-1 font-medium`,children:s(n.substring(2))})]},i)),l++;continue}let c=n.match(/^(\d+)\.\s+(.*)$/);if(c){let t=e.search(/\S/)>=2?`pl-6`:`pl-2`;o.push((0,a.jsxs)(`div`,{className:`flex items-start gap-2 my-1 ${t}`,children:[(0,a.jsx)(`span`,{className:`text-primary font-arcade text-[9px] font-bold mt-1 shrink-0 px-1 py-0.2 bg-slate-100 border border-ink-black rounded-xs`,children:c[1]}),(0,a.jsx)(`div`,{className:`text-ink-black leading-relaxed flex-1 font-medium`,children:s(c[2])})]},i)),l++;continue}o.push((0,a.jsx)(`p`,{className:`text-ink-black my-1 font-medium leading-relaxed`,children:s(e)},i)),l++}return(0,a.jsx)(i.Fragment,{children:o},`block-${t}`)})})};export{s as n,l as t};
 
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KatexRenderer-DVt2cqHc.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-react-hnaVBnLv.js","assets/vendor-codemirror-By0wlJeM.js","assets/vendor-katex-Balf574a.js","assets/vendor-katex-DtkCqjBQ.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n}from"./vendor-react-hnaVBnLv.js";import{t as r}from"./index-DVWZ15xt.js";var i=e(n(),1),a=t(),o=(0,i.lazy)(()=>r(()=>import(`./KatexRenderer-DVt2cqHc.js`),__vite__mapDeps([0,1,2,3,4,5])));function s(e){return e?e.split(/(\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\]|\\\([\s\S]*?\\\)|\$(?:\\\$|[^$\n])+?\$|`[^`\n]+`|\*\*[^*\n]+\*\*|__[^_\n]+__|(?<!\*)\*[^*\n]+(?<!\*)\*|(?<!_)_[^_\n]+(?<!_)_|\[[^\]\n]+\]\([^)\n]+\))/g).map((e,t)=>{if(!e)return null;if(e.startsWith(`$$`)&&e.endsWith(`$$`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!0,className:`inline-block my-1 px-1 overflow-x-auto align-middle`})},t):e}if(e.startsWith(`\\[`)&&e.endsWith(`\\]`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!0,className:`inline-block my-1 px-1 overflow-x-auto align-middle`})},t):e}if(e.startsWith(`\\(`)&&e.endsWith(`\\)`)&&e.length>=4){let n=e.slice(2,-2);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!1,className:`inline-katex px-0.5 align-baseline`})},t):e}if(e.startsWith(`$`)&&e.endsWith(`$`)&&e.length>=2){let n=e.slice(1,-1);return n.trim()?(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:n}),children:(0,a.jsx)(o,{math:n,displayMode:!1,className:`inline-katex px-0.5 align-baseline`})},t):e}if(e.startsWith("`")&&e.endsWith("`")&&e.length>=2)return(0,a.jsx)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] px-1.5 py-0.5 rounded text-[11px] font-mono border border-ink-black shadow-[1px_1px_0px_0px_#000]`,children:e.slice(1,-1)},t);if(e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>=4||e.startsWith(`__`)&&e.endsWith(`__`)&&e.length>=4)return(0,a.jsx)(`strong`,{className:`text-ink-black font-extrabold`,children:s(e.slice(2,-2))},t);if(e.startsWith(`*`)&&e.endsWith(`*`)&&e.length>=2||e.startsWith(`_`)&&e.endsWith(`_`)&&e.length>=2)return(0,a.jsx)(`em`,{className:`italic text-slate-800`,children:s(e.slice(1,-1))},t);let n=e.match(/^\[([^\]]+)\]\(([^)]+)\)$/);return n?(0,a.jsx)(`a`,{href:n[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline hover:text-primary/80 font-bold`,children:n[1]},t):e}):[]}var c=(0,i.lazy)(()=>r(()=>import(`./KatexRenderer-DVt2cqHc.js`),__vite__mapDeps([0,1,2,3,4,5]))),l=({content:e,className:t=``})=>{if(!e)return null;let n=e.split(/(```[\s\S]*?```|\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\])/g);return(0,a.jsx)(`div`,{className:`markdown-content space-y-2.5 text-ink-black text-xs leading-relaxed font-sans ${t}`,children:n.map((e,t)=>{if(!e)return null;let n=e.trim();if(n.startsWith("```")&&n.endsWith("```")&&n.length>=6){let e=n.indexOf(`
3
  `),r=e===-1?``:n.slice(3,e).trim(),i=e===-1?n.slice(3,-3).trim():n.slice(e+1,-3).trimEnd();return(0,a.jsxs)(`div`,{className:`my-3 rounded-md overflow-hidden border-[2px] border-ink-black shadow-[3px_3px_0px_0px_#1E293B] bg-[#1E293B]`,children:[r&&(0,a.jsxs)(`div`,{className:`bg-slate-800 text-slate-400 px-3 py-1 text-[9px] font-arcade uppercase tracking-wider border-b border-slate-700 flex justify-between items-center`,children:[(0,a.jsx)(`span`,{children:r}),(0,a.jsx)(`span`,{className:`text-[8px] opacity-70`,children:`SNIPPET`})]}),(0,a.jsx)(`pre`,{className:`p-3 overflow-x-auto font-mono text-[11px] text-[#4ADE80] leading-relaxed custom-scrollbar selection:bg-[#4ADE80] selection:text-[#1E293B]`,children:(0,a.jsx)(`code`,{children:i})})]},`code-${t}`)}if(n.startsWith(`$$`)&&n.endsWith(`$$`)&&n.length>=4||n.startsWith(`\\[`)&&n.endsWith(`\\]`)&&n.length>=4){let e=n.slice(2,-2);return(0,a.jsx)(`div`,{className:`my-3 p-3 bg-slate-50 border-2 border-ink-black rounded overflow-x-auto text-center shadow-[2px_2px_0px_0px_rgba(30,41,59,0.3)] custom-scrollbar`,children:(0,a.jsx)(i.Suspense,{fallback:(0,a.jsx)(`span`,{className:`font-mono text-xs opacity-75`,children:e}),children:(0,a.jsx)(c,{math:e,displayMode:!0})})},`math-${t}`)}let r=e.split(`
4
  `),o=[],l=0;for(;l<r.length;){let e=r[l],n=e.trim(),i=`${t}-${l}`;if(n===``){o.push((0,a.jsx)(`div`,{className:`h-1`},i)),l++;continue}if(n.startsWith(`|`)&&n.endsWith(`|`)&&l+1<r.length&&r[l+1].trim().startsWith(`|`)){let e=[];for(;l<r.length&&r[l].trim().startsWith(`|`)&&r[l].trim().endsWith(`|`);)e.push(r[l].trim()),l++;if(e.length>=2){let t=e[0].slice(1,-1).split(`|`).map(e=>e.trim()),n=e.slice(2).map(e=>e.slice(1,-1).split(`|`).map(e=>e.trim()));o.push((0,a.jsx)(`div`,{className:`my-3 overflow-x-auto border-2 border-ink-black rounded shadow-[2px_2px_0px_0px_#1E293B]`,children:(0,a.jsxs)(`table`,{className:`w-full text-left border-collapse text-xs`,children:[(0,a.jsx)(`thead`,{children:(0,a.jsx)(`tr`,{className:`bg-slate-200 border-b-2 border-ink-black`,children:t.map((e,t)=>(0,a.jsx)(`th`,{className:`p-2 font-bold font-headline-md border-r last:border-r-0 border-ink-black`,children:s(e)},t))})}),(0,a.jsx)(`tbody`,{children:n.map((e,t)=>(0,a.jsx)(`tr`,{className:`border-b border-slate-300 last:border-b-0 ${t%2==1?`bg-slate-50`:`bg-white`}`,children:e.map((e,t)=>(0,a.jsx)(`td`,{className:`p-2 border-r last:border-r-0 border-slate-200 font-medium`,children:s(e)},t))},t))})]})},`table-${i}`));continue}}if(n.startsWith(`#### `)){o.push((0,a.jsx)(`h4`,{className:`text-xs font-bold text-ink-black mt-3 mb-1 font-headline-md`,children:s(n.substring(5))},i)),l++;continue}if(n.startsWith(`### `)){o.push((0,a.jsxs)(`h3`,{className:`text-xs font-bold text-primary mt-4 mb-1.5 uppercase font-arcade tracking-wide flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`w-2 h-2 bg-primary inline-block rounded-xs`}),s(n.substring(4))]},i)),l++;continue}if(n.startsWith(`## `)){o.push((0,a.jsx)(`h2`,{className:`text-sm font-extrabold text-ink-black mt-4 mb-2 font-headline-md border-b-2 border-ink-black pb-1`,children:s(n.substring(3))},i)),l++;continue}if(n.startsWith(`# `)){o.push((0,a.jsx)(`h1`,{className:`text-base font-black text-ink-black mt-5 mb-2 font-headline-md`,children:s(n.substring(2))},i)),l++;continue}if(n===`---`||n===`***`||n===`___`){o.push((0,a.jsx)(`hr`,{className:`my-3 border-t-2 border-dashed border-slate-300`},i)),l++;continue}if(e.trim().startsWith(`>`)){o.push((0,a.jsx)(`blockquote`,{className:`border-l-4 border-primary pl-3 py-1 my-2 bg-slate-50 italic text-slate-700`,children:s(e.trim().substring(1).trim())},i)),l++;continue}if(n.startsWith(`- `)||n.startsWith(`* `)||n.startsWith(`+ `)){let t=e.search(/\S/)>=2?`pl-6`:`pl-2`;o.push((0,a.jsxs)(`div`,{className:`flex items-start gap-2 my-1 ${t}`,children:[(0,a.jsx)(`span`,{className:`text-primary font-bold mt-0.5 shrink-0`,children:`•`}),(0,a.jsx)(`div`,{className:`text-ink-black leading-relaxed flex-1 font-medium`,children:s(n.substring(2))})]},i)),l++;continue}let c=n.match(/^(\d+)\.\s+(.*)$/);if(c){let t=e.search(/\S/)>=2?`pl-6`:`pl-2`;o.push((0,a.jsxs)(`div`,{className:`flex items-start gap-2 my-1 ${t}`,children:[(0,a.jsx)(`span`,{className:`text-primary font-arcade text-[9px] font-bold mt-1 shrink-0 px-1 py-0.2 bg-slate-100 border border-ink-black rounded-xs`,children:c[1]}),(0,a.jsx)(`div`,{className:`text-ink-black leading-relaxed flex-1 font-medium`,children:s(c[2])})]},i)),l++;continue}o.push((0,a.jsx)(`p`,{className:`text-ink-black my-1 font-medium leading-relaxed`,children:s(e)},i)),l++}return(0,a.jsx)(i.Fragment,{children:o},`block-${t}`)})})};export{s as n,l as t};
algospaced-ui/dist/assets/{MySQLPlayground-CDRacqFf.js → MySQLPlayground-iGzsbjAa.js} RENAMED
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Rt as n}from"./vendor-react-CIO8MTK1.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(t(),1),a=n();function o(){let[e,t]=(0,i.useState)(null),[n,o]=(0,i.useState)(``),[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(!0),[d,f]=(0,i.useState)(``),[p,m]=(0,i.useState)(null),h=async()=>{u(!0),f(``);try{let{data:{session:e}}=await r.auth.getSession();if(!e){f(`Unauthenticated session`);return}let n=await fetch(`/api/challenges/mysql/status`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(n.ok){let e=await n.json();e.active?t(e):t(null)}else f(`Failed to fetch playground status.`)}catch{f(`Connection timed out.`)}finally{u(!1)}},g=async(e=!1)=>{u(!0),f(``),m(null);try{let{data:{session:n}}=await r.auth.getSession();if(!n){f(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/mysql/init${e?`?refresh=true`:``}`,{method:`POST`,headers:{Authorization:`Bearer ${n.access_token}`}});if(i.ok){let e=await i.json();t({active:!0,title:e.title,objective:e.objective,points:e.points,schema:e.schema,challenge_type:e.challenge_type,completed:!1,total_score:e.total_score})}else f(`Failed to initialize mock database playground.`)}catch{f(`Server connection error.`)}finally{u(!1)}};return(0,i.useEffect)(()=>{h()},[]),l?(0,a.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col items-center justify-center font-arcade text-[10px]`,children:[(0,a.jsx)(`div`,{className:`animate-bounce mb-2`,children:`INITIALIZING SQL PLAYGROUND...`}),(0,a.jsx)(`div`,{className:`w-48 h-4 bg-white border-[3px] border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-[#0ea5e9] w-1/2 animate-pulse border-r-2 border-ink-black`})})]}):e?(0,a.jsx)(`div`,{className:`w-full h-full bg-paper-white text-ink-black flex flex-col overflow-hidden text-xs md:text-sm`,children:(0,a.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 custom-scrollbar flex flex-col gap-4`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center bg-slate-100 border-[3px] border-ink-black p-3 shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex gap-2`,children:[(0,a.jsx)(`span`,{className:`bg-blue-100 text-blue-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px] uppercase`,children:e.challenge_type}),(0,a.jsxs)(`span`,{className:`bg-yellow-100 text-yellow-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:[`+`,e.points,` PTS`]}),e.completed?(0,a.jsx)(`span`,{className:`bg-emerald-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`SOLVED`}):(0,a.jsx)(`span`,{className:`bg-rose-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`UNSOLVED`})]}),(0,a.jsxs)(`div`,{className:`font-arcade text-[8px] text-sky-700 font-bold bg-white border-2 border-ink-black px-2 py-0.5 shadow-[1px_1px_0_0_#1E293B]`,children:[`SCORE: `,e.total_score]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-yellow-400 bg-yellow-50 p-3 rounded font-sans leading-relaxed text-xs`,children:[(0,a.jsx)(`h4`,{className:`font-arcade text-[9px] text-yellow-800 mb-1`,children:`PROBLEM`}),(0,a.jsx)(`p`,{className:`font-bold text-slate-800`,children:e.objective})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`schema`}),(0,a.jsx)(`span`,{children:`SCHEMA EXPLORER (MOCK INSTANCE)`})]}),(0,a.jsx)(`div`,{className:`grid grid-cols-2 gap-3 max-h-[140px] overflow-y-auto custom-scrollbar font-mono text-[10px]`,children:Object.entries(e.schema).map(([e,t])=>(0,a.jsxs)(`div`,{className:`border border-slate-300 p-2 bg-slate-50`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-blue-700 border-b border-slate-200 pb-0.5 mb-1 flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px]`,children:`table_chart`}),e]}),(0,a.jsx)(`ul`,{className:`space-y-0.5 text-slate-600 text-[9px]`,children:t.map((e,t)=>(0,a.jsxs)(`li`,{className:`flex justify-between`,children:[(0,a.jsx)(`span`,{children:e.name}),(0,a.jsx)(`span`,{className:`text-slate-400 italic text-[8px]`,children:e.type})]},t))})]},e))})]}),(0,a.jsxs)(`div`,{className:`flex flex-col min-h-[120px]`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] mb-1 tracking-wide uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm text-sky-600`,children:`terminal`}),(0,a.jsx)(`span`,{children:`Enter SQL Query:`})]}),(0,a.jsx)(`textarea`,{value:n,onChange:e=>o(e.target.value),className:`flex-1 w-full bg-slate-900 text-[#4ADE80] font-mono p-3 border-[3px] border-ink-black rounded outline-none focus:ring-2 focus:ring-sky-500 text-xs leading-relaxed resize-none`,placeholder:`SELECT * FROM customers WHERE score > 100;`,spellCheck:`false`})]}),(0,a.jsxs)(`div`,{className:`flex gap-3`,children:[(0,a.jsx)(`button`,{onClick:()=>g(!0),className:`flex-1 bg-white hover:bg-slate-100 text-ink-black border-[3px] border-ink-black font-bold font-window-title text-xs py-2 shadow-[3px_3px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none cursor-pointer`,children:`NEW PROBLEM`}),(0,a.jsx)(`button`,{disabled:s,onClick:async()=>{if(n.trim()){c(!0),f(``),m(null);try{let{data:{session:e}}=await r.auth.getSession();if(!e){f(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/mysql/query`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({query:n})});if(i.ok){let e=await i.json();e.success?(m({columns:e.columns,rows:e.rows,rowsAffected:e.rows_affected,isCorrect:e.is_correct}),e.is_correct&&t(t=>t?{...t,completed:!0,total_score:e.total_score}:null),e.schema&&t(t=>t?{...t,schema:e.schema}:null)):f(e.error)}else f(`Database server query failure.`)}catch{f(`Query connection lost.`)}finally{c(!1)}}},className:`flex-[2] bg-highlight-pink text-white font-window-title font-bold py-2 border-[3px] border-ink-black shadow-[3px_3px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none hover:bg-pink-400 transition-all disabled:opacity-50 cursor-pointer text-center text-xs`,children:s?`EXECUTING SQL...`:`EXECUTE SQL QUERY`})]}),d&&(0,a.jsxs)(`div`,{className:`border-[3px] border-red-500 bg-red-50 text-red-800 p-3 font-mono text-xs whitespace-pre-wrap`,children:[(0,a.jsx)(`div`,{className:`font-bold mb-1`,children:`SQL RUNTIME / SYNTAX ERROR:`}),d]}),p&&(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 flex flex-col`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 flex justify-between items-center`,children:[(0,a.jsx)(`span`,{children:`QUERY OUTPUT BUFFER`}),p.isCorrect&&(0,a.jsx)(`span`,{className:`text-green-600 font-bold animate-bounce text-[9px]`,children:`✓ ACCEPTED!`})]}),(0,a.jsxs)(`div`,{className:`text-[9px] text-slate-500 mb-2 font-mono`,children:[`Rows Affected: `,p.rowsAffected,` | Total Returned: `,p.rows.length]}),p.rows.length>0?(0,a.jsx)(`div`,{className:`overflow-x-auto border border-slate-300 max-h-[180px] custom-scrollbar`,children:(0,a.jsxs)(`table`,{className:`border-collapse w-full font-mono text-[9px] min-w-full`,children:[(0,a.jsx)(`thead`,{children:(0,a.jsx)(`tr`,{className:`bg-slate-100 border-b border-slate-300`,children:p.columns.map((e,t)=>(0,a.jsx)(`th`,{className:`border-r border-slate-300 p-1.5 text-left font-bold text-slate-700`,children:e},t))})}),(0,a.jsx)(`tbody`,{className:`divide-y divide-slate-200`,children:p.rows.map((e,t)=>(0,a.jsx)(`tr`,{className:`hover:bg-slate-50`,children:p.columns.map((t,n)=>(0,a.jsx)(`td`,{className:`border-r border-slate-200 p-1.5 text-slate-800 whitespace-nowrap`,children:e[t]===null?(0,a.jsx)(`span`,{className:`text-slate-300 italic`,children:`NULL`}):String(e[t])},n))},t))})]})}):(0,a.jsx)(`div`,{className:`p-3 border border-dashed border-slate-300 text-center text-slate-400 italic font-sans text-xs`,children:`Query executed successfully. Result set is empty (or modification completed).`})]})]})}):(0,a.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col justify-between items-center text-center text-ink-black text-xs md:text-sm font-sans select-none`,children:[(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col justify-center items-center gap-4`,children:[(0,a.jsx)(`div`,{className:`w-16 h-16 bg-white border-[3px] border-ink-black flex items-center justify-center shadow-[4px_4px_0_0_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-[#0ea5e9]`,style:{fontVariationSettings:`'FILL' 1`},children:`database`})}),(0,a.jsx)(`h3`,{className:`font-headline-md font-bold text-lg`,children:`Interactive MySQL Playground`}),(0,a.jsx)(`p`,{className:`max-w-md text-slate-600 leading-relaxed font-semibold`,children:`Practice SQL queries against realistic schema tables. Includes full support for:`}),(0,a.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2 font-mono text-[10px] text-slate-700 font-bold uppercase mt-1`,children:[(0,a.jsx)(`span`,{className:`bg-blue-100 border border-blue-400 px-2 py-0.5`,children:`SELECT / JOIN`}),(0,a.jsx)(`span`,{className:`bg-emerald-100 border border-emerald-400 px-2 py-0.5`,children:`UPDATE / DELETE`}),(0,a.jsx)(`span`,{className:`bg-purple-100 border border-purple-400 px-2 py-0.5`,children:`WINDOW FUNCTIONS`})]})]}),(0,a.jsx)(`div`,{className:`w-full border-t border-slate-200 pt-4 flex flex-col gap-2 shrink-0`,children:(0,a.jsx)(`button`,{onClick:()=>g(!1),className:`w-full py-2.5 bg-[#0ea5e9] hover:bg-sky-400 text-white font-window-title font-bold text-xs uppercase border-[3px] border-ink-black shadow-[4px_4px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer text-center`,children:`CREATE NEW DATABASE`})})]})}export{o as default};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n}from"./vendor-react-hnaVBnLv.js";import{s as r}from"./firebaseClient-DZobvwSx.js";var i=e(n(),1),a=t();function o(){let[e,t]=(0,i.useState)(null),[n,o]=(0,i.useState)(``),[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(!0),[d,f]=(0,i.useState)(``),[p,m]=(0,i.useState)(null),h=async()=>{u(!0),f(``);try{let{data:{session:e}}=await r.auth.getSession();if(!e){f(`Unauthenticated session`);return}let n=await fetch(`/api/challenges/mysql/status`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(n.ok){let e=await n.json();e.active?t(e):t(null)}else f(`Failed to fetch playground status.`)}catch{f(`Connection timed out.`)}finally{u(!1)}},g=async(e=!1)=>{u(!0),f(``),m(null);try{let{data:{session:n}}=await r.auth.getSession();if(!n){f(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/mysql/init${e?`?refresh=true`:``}`,{method:`POST`,headers:{Authorization:`Bearer ${n.access_token}`}});if(i.ok){let e=await i.json();t({active:!0,title:e.title,objective:e.objective,points:e.points,schema:e.schema,challenge_type:e.challenge_type,completed:!1,total_score:e.total_score})}else f(`Failed to initialize mock database playground.`)}catch{f(`Server connection error.`)}finally{u(!1)}};return(0,i.useEffect)(()=>{h()},[]),l?(0,a.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col items-center justify-center font-arcade text-[10px]`,children:[(0,a.jsx)(`div`,{className:`animate-bounce mb-2`,children:`INITIALIZING SQL PLAYGROUND...`}),(0,a.jsx)(`div`,{className:`w-48 h-4 bg-white border-[3px] border-ink-black overflow-hidden relative`,children:(0,a.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-[#0ea5e9] w-1/2 animate-pulse border-r-2 border-ink-black`})})]}):e?(0,a.jsx)(`div`,{className:`w-full h-full bg-paper-white text-ink-black flex flex-col overflow-hidden text-xs md:text-sm`,children:(0,a.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 custom-scrollbar flex flex-col gap-4`,children:[(0,a.jsxs)(`div`,{className:`flex justify-between items-center bg-slate-100 border-[3px] border-ink-black p-3 shrink-0`,children:[(0,a.jsxs)(`div`,{className:`flex gap-2`,children:[(0,a.jsx)(`span`,{className:`bg-blue-100 text-blue-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px] uppercase`,children:e.challenge_type}),(0,a.jsxs)(`span`,{className:`bg-yellow-100 text-yellow-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:[`+`,e.points,` PTS`]}),e.completed?(0,a.jsx)(`span`,{className:`bg-emerald-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`SOLVED`}):(0,a.jsx)(`span`,{className:`bg-rose-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`UNSOLVED`})]}),(0,a.jsxs)(`div`,{className:`font-arcade text-[8px] text-sky-700 font-bold bg-white border-2 border-ink-black px-2 py-0.5 shadow-[1px_1px_0_0_#1E293B]`,children:[`SCORE: `,e.total_score]})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-yellow-400 bg-yellow-50 p-3 rounded font-sans leading-relaxed text-xs`,children:[(0,a.jsx)(`h4`,{className:`font-arcade text-[9px] text-yellow-800 mb-1`,children:`PROBLEM`}),(0,a.jsx)(`p`,{className:`font-bold text-slate-800`,children:e.objective})]}),(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 flex items-center gap-1.5`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`schema`}),(0,a.jsx)(`span`,{children:`SCHEMA EXPLORER (MOCK INSTANCE)`})]}),(0,a.jsx)(`div`,{className:`grid grid-cols-2 gap-3 max-h-[140px] overflow-y-auto custom-scrollbar font-mono text-[10px]`,children:Object.entries(e.schema).map(([e,t])=>(0,a.jsxs)(`div`,{className:`border border-slate-300 p-2 bg-slate-50`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-blue-700 border-b border-slate-200 pb-0.5 mb-1 flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-[12px]`,children:`table_chart`}),e]}),(0,a.jsx)(`ul`,{className:`space-y-0.5 text-slate-600 text-[9px]`,children:t.map((e,t)=>(0,a.jsxs)(`li`,{className:`flex justify-between`,children:[(0,a.jsx)(`span`,{children:e.name}),(0,a.jsx)(`span`,{className:`text-slate-400 italic text-[8px]`,children:e.type})]},t))})]},e))})]}),(0,a.jsxs)(`div`,{className:`flex flex-col min-h-[120px]`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] mb-1 tracking-wide uppercase flex items-center gap-1`,children:[(0,a.jsx)(`span`,{className:`material-symbols-outlined text-sm text-sky-600`,children:`terminal`}),(0,a.jsx)(`span`,{children:`Enter SQL Query:`})]}),(0,a.jsx)(`textarea`,{value:n,onChange:e=>o(e.target.value),className:`flex-1 w-full bg-slate-900 text-[#4ADE80] font-mono p-3 border-[3px] border-ink-black rounded outline-none focus:ring-2 focus:ring-sky-500 text-xs leading-relaxed resize-none`,placeholder:`SELECT * FROM customers WHERE score > 100;`,spellCheck:`false`})]}),(0,a.jsxs)(`div`,{className:`flex gap-3`,children:[(0,a.jsx)(`button`,{onClick:()=>g(!0),className:`flex-1 bg-white hover:bg-slate-100 text-ink-black border-[3px] border-ink-black font-bold font-window-title text-xs py-2 shadow-[3px_3px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none cursor-pointer`,children:`NEW PROBLEM`}),(0,a.jsx)(`button`,{disabled:s,onClick:async()=>{if(n.trim()){c(!0),f(``),m(null);try{let{data:{session:e}}=await r.auth.getSession();if(!e){f(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/mysql/query`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({query:n})});if(i.ok){let e=await i.json();e.success?(m({columns:e.columns,rows:e.rows,rowsAffected:e.rows_affected,isCorrect:e.is_correct}),e.is_correct&&t(t=>t?{...t,completed:!0,total_score:e.total_score}:null),e.schema&&t(t=>t?{...t,schema:e.schema}:null)):f(e.error)}else f(`Database server query failure.`)}catch{f(`Query connection lost.`)}finally{c(!1)}}},className:`flex-[2] bg-highlight-pink text-white font-window-title font-bold py-2 border-[3px] border-ink-black shadow-[3px_3px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none hover:bg-pink-400 transition-all disabled:opacity-50 cursor-pointer text-center text-xs`,children:s?`EXECUTING SQL...`:`EXECUTE SQL QUERY`})]}),d&&(0,a.jsxs)(`div`,{className:`border-[3px] border-red-500 bg-red-50 text-red-800 p-3 font-mono text-xs whitespace-pre-wrap`,children:[(0,a.jsx)(`div`,{className:`font-bold mb-1`,children:`SQL RUNTIME / SYNTAX ERROR:`}),d]}),p&&(0,a.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-white p-3 flex flex-col`,children:[(0,a.jsxs)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 flex justify-between items-center`,children:[(0,a.jsx)(`span`,{children:`QUERY OUTPUT BUFFER`}),p.isCorrect&&(0,a.jsx)(`span`,{className:`text-green-600 font-bold animate-bounce text-[9px]`,children:`✓ ACCEPTED!`})]}),(0,a.jsxs)(`div`,{className:`text-[9px] text-slate-500 mb-2 font-mono`,children:[`Rows Affected: `,p.rowsAffected,` | Total Returned: `,p.rows.length]}),p.rows.length>0?(0,a.jsx)(`div`,{className:`overflow-x-auto border border-slate-300 max-h-[180px] custom-scrollbar`,children:(0,a.jsxs)(`table`,{className:`border-collapse w-full font-mono text-[9px] min-w-full`,children:[(0,a.jsx)(`thead`,{children:(0,a.jsx)(`tr`,{className:`bg-slate-100 border-b border-slate-300`,children:p.columns.map((e,t)=>(0,a.jsx)(`th`,{className:`border-r border-slate-300 p-1.5 text-left font-bold text-slate-700`,children:e},t))})}),(0,a.jsx)(`tbody`,{className:`divide-y divide-slate-200`,children:p.rows.map((e,t)=>(0,a.jsx)(`tr`,{className:`hover:bg-slate-50`,children:p.columns.map((t,n)=>(0,a.jsx)(`td`,{className:`border-r border-slate-200 p-1.5 text-slate-800 whitespace-nowrap`,children:e[t]===null?(0,a.jsx)(`span`,{className:`text-slate-300 italic`,children:`NULL`}):String(e[t])},n))},t))})]})}):(0,a.jsx)(`div`,{className:`p-3 border border-dashed border-slate-300 text-center text-slate-400 italic font-sans text-xs`,children:`Query executed successfully. Result set is empty (or modification completed).`})]})]})}):(0,a.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col justify-between items-center text-center text-ink-black text-xs md:text-sm font-sans select-none`,children:[(0,a.jsxs)(`div`,{className:`flex-1 flex flex-col justify-center items-center gap-4`,children:[(0,a.jsx)(`div`,{className:`w-16 h-16 bg-white border-[3px] border-ink-black flex items-center justify-center shadow-[4px_4px_0_0_#1E293B]`,children:(0,a.jsx)(`span`,{className:`material-symbols-outlined text-4xl text-[#0ea5e9]`,style:{fontVariationSettings:`'FILL' 1`},children:`database`})}),(0,a.jsx)(`h3`,{className:`font-headline-md font-bold text-lg`,children:`Interactive MySQL Playground`}),(0,a.jsx)(`p`,{className:`max-w-md text-slate-600 leading-relaxed font-semibold`,children:`Practice SQL queries against realistic schema tables. Includes full support for:`}),(0,a.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2 font-mono text-[10px] text-slate-700 font-bold uppercase mt-1`,children:[(0,a.jsx)(`span`,{className:`bg-blue-100 border border-blue-400 px-2 py-0.5`,children:`SELECT / JOIN`}),(0,a.jsx)(`span`,{className:`bg-emerald-100 border border-emerald-400 px-2 py-0.5`,children:`UPDATE / DELETE`}),(0,a.jsx)(`span`,{className:`bg-purple-100 border border-purple-400 px-2 py-0.5`,children:`WINDOW FUNCTIONS`})]})]}),(0,a.jsx)(`div`,{className:`w-full border-t border-slate-200 pt-4 flex flex-col gap-2 shrink-0`,children:(0,a.jsx)(`button`,{onClick:()=>g(!1),className:`w-full py-2.5 bg-[#0ea5e9] hover:bg-sky-400 text-white font-window-title font-bold text-xs uppercase border-[3px] border-ink-black shadow-[4px_4px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer text-center`,children:`CREATE NEW DATABASE`})})]})}export{o as default};
algospaced-ui/dist/assets/OnboardingModal-DmgTXeeL.js DELETED
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,Bt as n,C as r,Et as i,Rt as a,St as o,_ as s,a as c,ft as l,ht as u,it as d,o as f,v as p,vt as m,y as h,yt as g}from"./vendor-react-CIO8MTK1.js";import{a as _,i as v,l as y,o as b}from"./index-DnK6BACV.js";var x=e(n(),1),S=a(),C=[217,242,1,49,20];function w({isOpen:e,onClose:n,onCompleted:a,userId:w}){let[T,E]=(0,x.useState)(`welcome`),[D,O]=(0,x.useState)(new Set),[k,A]=(0,x.useState)(``),[j,M]=(0,x.useState)(`ALL`),[N,P]=(0,x.useState)({}),[F,I]=(0,x.useState)(!1),[L,R]=(0,x.useState)(null),[z,B]=(0,x.useState)(null),V=()=>`algospaced_onboarding_done_${w===`sandbox-user-id`?`sandbox`:w||`sandbox`}`;(0,x.useEffect)(()=>{if(e){let e=localStorage.getItem(V());E(e?`checklist`:`welcome`),B(null),R(null)}},[e,w]);let H=(0,x.useMemo)(()=>v(),[]),U=(0,x.useMemo)(()=>_(),[]),W=(0,x.useMemo)(()=>{let e=k.trim().toLowerCase();return H.filter(t=>j!==`ALL`&&t.pattern!==j?!1:!e||t.name.toLowerCase().includes(e)||t.problem_number.toString().includes(e)||t.pattern.toLowerCase().includes(e)||t.difficulty.toLowerCase().includes(e))},[H,k,j]),G=(0,x.useMemo)(()=>{let e=new Map;for(let t of W){let n=e.get(t.pattern)||[];n.push(t),e.set(t.pattern,n)}return e},[W]);if(!e)return null;let K=()=>{localStorage.setItem(V(),`true`)},q=async()=>{I(!0),B(null),R(`Enrolling 5 foundational starter problems...`);try{let e=C.map(e=>b(e)).filter(e=>e!==void 0);await y(e),K(),R(`All 5 starter problems enrolled into Box 1!`),setTimeout(()=>{a(),n()},700)}catch(e){console.error(`Failed to start from scratch:`,e),B(e instanceof Error?e.message:`Failed to enroll starter problems`),I(!1)}},J=e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Y=e=>{let t=H.filter(t=>t.pattern===e),n=t.every(e=>D.has(e.problem_number));O(e=>{let r=new Set(e);for(let e of t)n?r.delete(e.problem_number):r.add(e.problem_number);return r})},X=e=>{O(t=>{let n=new Set(t);for(let t of H)t.difficulty===e&&n.add(t.problem_number);return n})},Z=()=>{O(new Set(H.map(e=>e.problem_number)))},Q=()=>{O(new Set)},$=e=>{P(t=>({...t,[e]:!t[e]}))};return(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/75 backdrop-blur-sm p-3 sm:p-6 overflow-y-auto`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-4xl max-h-[92vh] bg-paper-white border-[4px] border-ink-black gadget-shadow flex flex-col relative overflow-hidden text-ink-black`,children:[(0,S.jsxs)(`div`,{className:`h-10 bg-gradient-to-r from-amber-400 via-amber-300 to-grass-green border-b-[3px] border-ink-black px-4 flex items-center justify-between shrink-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`w-3 h-3 rounded-full bg-rose-500 border border-ink-black`}),(0,S.jsx)(`span`,{className:`w-3 h-3 rounded-full bg-amber-500 border border-ink-black`}),(0,S.jsx)(`span`,{className:`w-3 h-3 rounded-full bg-emerald-500 border border-ink-black`}),(0,S.jsxs)(`span`,{className:`font-arcade text-[11px] font-bold tracking-wider text-ink-black uppercase ml-2 flex items-center gap-1.5`,children:[(0,S.jsx)(d,{className:`w-4 h-4 text-amber-900`}),`GET STARTED`]})]}),(0,S.jsx)(`button`,{onClick:()=>{K(),n()},disabled:F,className:`p-1 hover:bg-black/10 rounded transition-colors text-ink-black cursor-pointer border-0`,title:`Dismiss for now`,children:(0,S.jsx)(f,{className:`w-4 h-4`})})]}),T===`welcome`&&(0,S.jsxs)(`div`,{className:`p-6 sm:p-10 space-y-8 overflow-y-auto custom-scrollbar text-center`,children:[(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`inline-flex items-center gap-2 px-3 py-1 bg-amber-100 border-2 border-ink-black font-arcade text-[10px] font-bold text-amber-900 uppercase`,children:[(0,S.jsx)(h,{className:`w-3.5 h-3.5 text-amber-700`}),`WELCOME TO ALGOSPACED`]}),(0,S.jsx)(`h1`,{className:`font-headline-md text-2xl sm:text-4xl font-extrabold text-ink-black tracking-tight`,children:`How would you like to begin your journey?`}),(0,S.jsx)(`p`,{className:`font-sans text-xs sm:text-sm text-trash-gray max-w-xl mx-auto leading-relaxed font-semibold`,children:`AlgoSpaced uses a 5-box Leitner spaced repetition engine. Choose how to seed your active practice cards.`})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6 max-w-2xl mx-auto text-left`,children:[(0,S.jsxs)(`div`,{className:`p-5 sm:p-6 bg-gradient-to-br from-emerald-50 to-emerald-100/60 border-[3px] border-ink-black gadget-shadow hover:translate-y-[-2px] transition-all flex flex-col justify-between space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsx)(`div`,{className:`w-12 h-12 bg-grass-green border-2 border-ink-black rounded-xl flex items-center justify-center shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:(0,S.jsx)(o,{className:`w-6 h-6 text-ink-black stroke-[2.5]`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-emerald-800 uppercase tracking-wide`,children:`RECOMMENDED FOR BEGINNERS`}),(0,S.jsx)(`h2`,{className:`font-headline-md text-lg sm:text-xl font-bold text-ink-black mt-0.5`,children:`🌱 Start From Scratch`})]}),(0,S.jsx)(`p`,{className:`font-sans text-xs text-trash-gray leading-relaxed font-semibold`,children:`Begin with the 5 foundational starter problems: Contains Duplicate, Valid Anagram, Two Sum, Group Anagrams, and Valid Parentheses.`})]}),(0,S.jsx)(`button`,{onClick:q,disabled:F,className:`w-full py-3 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[10px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center justify-center gap-2 disabled:opacity-50`,children:F?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(t,{className:`w-4 h-4 animate-spin`}),(0,S.jsx)(`span`,{children:`INITIALIZING...`})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(g,{className:`w-4 h-4 stroke-[3]`}),(0,S.jsx)(`span`,{children:`START FRESH (5 PROBLEMS)`})]})})]}),(0,S.jsxs)(`div`,{className:`p-5 sm:p-6 bg-gradient-to-br from-amber-50 to-orange-100/60 border-[3px] border-ink-black gadget-shadow hover:translate-y-[-2px] transition-all flex flex-col justify-between space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsx)(`div`,{className:`w-12 h-12 bg-amber-400 border-2 border-ink-black rounded-xl flex items-center justify-center shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:(0,S.jsx)(c,{className:`w-6 h-6 text-ink-black stroke-[2.5]`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-amber-800 uppercase tracking-wide`,children:`IF YOU'VE ALREADY SOLVED SOME PROBLEMS ELSEWHERE`}),(0,S.jsx)(`h2`,{className:`font-headline-md text-lg sm:text-xl font-bold text-ink-black mt-0.5`,children:`⚡ Fast-Track Checklist`})]}),(0,S.jsx)(`p`,{className:`font-sans text-xs text-trash-gray leading-relaxed font-semibold`,children:`Already solved some problems? Check off problems you've already solved elsewhere to seed your review queue and update your progress.`})]}),(0,S.jsxs)(`button`,{onClick:()=>E(`checklist`),disabled:F,className:`w-full py-3 bg-amber-400 hover:bg-amber-300 text-ink-black font-arcade text-[10px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center justify-center gap-2`,children:[(0,S.jsx)(`span`,{children:`SELECT WHAT I KNOW (150 POOL)`}),(0,S.jsx)(i,{className:`w-4 h-4 rotate-180`})]})]})]}),L&&(0,S.jsx)(`p`,{className:`font-arcade text-[10px] text-emerald-700 font-bold animate-pulse`,children:L}),z&&(0,S.jsx)(`p`,{className:`font-arcade text-[10px] text-rose-600 font-bold`,children:z})]}),T===`checklist`&&(0,S.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`p-3 sm:p-4 bg-amber-50/60 border-b-[2px] border-ink-black shrink-0 space-y-3`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsxs)(`button`,{onClick:()=>E(`welcome`),className:`px-2.5 py-1.5 bg-paper-white hover:bg-slate-100 border-2 border-ink-black font-arcade text-[9px] font-bold text-ink-black flex items-center gap-1 cursor-pointer transition-colors shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]`,children:[(0,S.jsx)(i,{className:`w-3.5 h-3.5`}),`BACK`]}),(0,S.jsx)(`h2`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black`,children:`Fast-Track Catalog Checklist`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 bg-paper-white border-2 border-ink-black p-1.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,S.jsx)(`span`,{className:`font-arcade text-[8px] font-bold text-trash-gray px-1 uppercase`,children:`FSRS STATE:`}),(0,S.jsx)(`span`,{className:`px-2 py-1 font-arcade text-[9px] font-bold bg-amber-400 text-ink-black border border-ink-black`,children:`ALL START AS 'NEW'`})]})]}),(0,S.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2 items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`relative w-full sm:w-72`,children:[(0,S.jsx)(r,{className:`w-3.5 h-3.5 text-trash-gray absolute left-3 top-1/2 -translate-y-1/2`}),(0,S.jsx)(`input`,{type:`text`,value:k,onChange:e=>A(e.target.value),placeholder:`Search by title, number, or pattern...`,"aria-label":`Search problems by title, number, or pattern`,className:`w-full pl-8 pr-3 py-1.5 bg-paper-white border-2 border-ink-black font-sans text-xs text-ink-black font-medium outline-none focus:bg-amber-50`}),k&&(0,S.jsx)(`button`,{onClick:()=>A(``),"aria-label":`Clear search`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-trash-gray hover:text-ink-black p-0.5 cursor-pointer`,children:(0,S.jsx)(f,{className:`w-3 h-3`})})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap w-full sm:w-auto justify-end`,children:[(0,S.jsx)(`button`,{onClick:()=>X(`Easy`),className:`px-2 py-1 bg-emerald-100 hover:bg-emerald-200 border border-emerald-800 text-emerald-900 font-arcade text-[8px] font-bold cursor-pointer transition-colors`,children:`+ ALL EASY`}),(0,S.jsx)(`button`,{onClick:()=>X(`Medium`),className:`px-2 py-1 bg-amber-100 hover:bg-amber-200 border border-amber-800 text-amber-900 font-arcade text-[8px] font-bold cursor-pointer transition-colors`,children:`+ ALL MEDIUM`}),(0,S.jsx)(`button`,{onClick:Z,className:`px-2 py-1 bg-purple-100 hover:bg-purple-200 border border-purple-800 text-purple-900 font-arcade text-[8px] font-bold cursor-pointer transition-colors`,children:`SELECT ALL (150)`}),(0,S.jsx)(`button`,{onClick:Q,className:`px-2 py-1 bg-slate-100 hover:bg-slate-200 border border-slate-700 text-slate-800 font-arcade text-[8px] font-bold cursor-pointer transition-colors`,children:`CLEAR`})]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 overflow-x-auto custom-scrollbar pb-1 text-[8px] font-arcade font-bold`,children:[(0,S.jsxs)(`button`,{onClick:()=>M(`ALL`),className:`px-2 py-0.5 border cursor-pointer shrink-0 transition-colors ${j===`ALL`?`bg-ink-black text-amber-300 border-ink-black`:`bg-paper-white text-trash-gray border-slate-300 hover:text-ink-black`}`,children:[`ALL PATTERNS (`,H.length,`)`]}),U.map(e=>{let t=H.filter(t=>t.pattern===e).length;return(0,S.jsxs)(`button`,{onClick:()=>M(e),className:`px-2 py-0.5 border cursor-pointer shrink-0 transition-colors ${j===e?`bg-ink-black text-amber-300 border-ink-black`:`bg-paper-white text-trash-gray border-slate-300 hover:text-ink-black`}`,children:[e.toUpperCase(),` (`,t,`)`]},e)})]})]}),(0,S.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 sm:p-6 custom-scrollbar space-y-4 bg-slate-50/50`,children:[Array.from(G.entries()).map(([e,t])=>{let n=t.filter(e=>D.has(e.problem_number)).length,r=n===t.length,i=N[e]!==!1;return(0,S.jsxs)(`div`,{className:`bg-paper-white border-2 border-ink-black gadget-shadow overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`px-3.5 py-2.5 bg-gradient-to-r from-amber-100 to-amber-50 border-b-2 border-ink-black flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{onClick:()=>$(e),className:`p-1 hover:bg-black/10 rounded cursor-pointer transition-colors text-ink-black`,children:i?(0,S.jsx)(u,{className:`w-3.5 h-3.5`}):(0,S.jsx)(m,{className:`w-3.5 h-3.5`})}),(0,S.jsx)(`span`,{className:`font-headline-md text-xs sm:text-sm font-bold text-ink-black`,children:e}),(0,S.jsxs)(`span`,{className:`font-arcade text-[8px] font-bold px-1.5 py-0.5 rounded bg-amber-900/10 text-amber-900 border border-amber-900/20`,children:[n,` / `,t.length,` selected`]})]}),(0,S.jsx)(`button`,{onClick:()=>Y(e),className:`px-2 py-1 font-arcade text-[8px] font-bold border border-ink-black bg-paper-white hover:bg-amber-200 transition-colors cursor-pointer flex items-center gap-1 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]`,children:r?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(p,{className:`w-3 h-3 text-emerald-600`}),(0,S.jsx)(`span`,{children:`DESELECT ALL`})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(s,{className:`w-3 h-3 text-slate-500`}),(0,S.jsx)(`span`,{children:`SELECT ALL`})]})})]}),i&&(0,S.jsx)(`div`,{className:`p-3 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2`,children:t.map(e=>{let t=D.has(e.problem_number);return(0,S.jsxs)(`div`,{onClick:()=>J(e.problem_number),className:`p-2.5 border-2 transition-all cursor-pointer select-none flex items-start gap-2.5 ${t?`bg-amber-50/80 border-amber-600 shadow-[2px_2px_0px_0px_#d97706]`:`bg-paper-white border-slate-300 hover:border-ink-black`}`,children:[(0,S.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:t?(0,S.jsx)(p,{className:`w-4 h-4 text-emerald-600 stroke-[2.5]`}):(0,S.jsx)(s,{className:`w-4 h-4 text-slate-400 stroke-[2]`})}),(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,S.jsxs)(`span`,{className:`font-mono text-[9px] font-bold text-trash-gray`,children:[`#`,e.problem_number]}),(0,S.jsx)(`span`,{className:`px-1.5 py-0.2 rounded font-arcade text-[7px] font-bold uppercase text-white ${e.difficulty===`Easy`?`bg-emerald-600`:e.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:e.difficulty})]}),(0,S.jsx)(`h3`,{className:`font-headline-md text-xs font-bold text-ink-black truncate mt-0.5`,children:e.name}),(0,S.jsxs)(`div`,{className:`text-[10px] font-code-mono text-slate-500 truncate mt-0.5`,children:[`T: `,e.time_complexity,` | S: `,e.space_complexity]})]})]},e.problem_number)})})]},e)}),G.size===0&&(0,S.jsxs)(`div`,{className:`p-8 text-center bg-paper-white border-2 border-dashed border-slate-300 text-trash-gray space-y-2`,children:[(0,S.jsx)(r,{className:`w-8 h-8 mx-auto text-slate-400`}),(0,S.jsx)(`p`,{className:`font-arcade text-xs font-bold`,children:`NO MATCHING PROBLEMS FOUND`}),(0,S.jsx)(`p`,{className:`text-xs font-sans`,children:`Try searching another keyword or clearing filters.`})]})]}),(0,S.jsxs)(`div`,{className:`p-3 sm:p-4 bg-paper-white border-t-[3px] border-ink-black shrink-0 flex flex-col sm:flex-row items-center justify-between gap-3 shadow-[0px_-4px_10px_rgba(0,0,0,0.05)]`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`div`,{className:`w-7 h-7 rounded-lg bg-emerald-100 border border-emerald-800 flex items-center justify-center`,children:(0,S.jsx)(l,{className:`w-4 h-4 text-emerald-700`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`span`,{className:`font-arcade text-[10px] font-bold text-ink-black`,children:[D.size,` of `,H.length,` PROBLEMS SELECTED`]}),(0,S.jsx)(`div`,{className:`font-sans text-[11px] text-trash-gray font-semibold`,children:`Target: FSRS (New)`})]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 w-full sm:w-auto justify-end`,children:[z&&(0,S.jsx)(`span`,{className:`font-arcade text-[9px] text-rose-600 font-bold mr-2 truncate`,children:z}),(0,S.jsx)(`button`,{onClick:async()=>{if(D.size!==0){I(!0),B(null),R(`Enrolling ${D.size} problems into FSRS...`);try{let e=H.filter(e=>D.has(e.problem_number));await y(e),K(),R(`Successfully enrolled ${e.length} problems!`),setTimeout(()=>{a(),n()},700)}catch(e){console.error(`Failed to batch activate:`,e),B(e instanceof Error?e.message:`Failed to enroll problems`),I(!1)}}},disabled:D.size===0||F,className:`w-full sm:w-auto px-6 py-2.5 bg-gradient-to-r from-amber-400 to-grass-green hover:from-amber-300 hover:to-emerald-400 text-ink-black font-arcade text-[10px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center justify-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed`,children:F?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(t,{className:`w-3.5 h-3.5 animate-spin`}),(0,S.jsx)(`span`,{children:`ENROLLING...`})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(c,{className:`w-3.5 h-3.5 text-amber-900`}),(0,S.jsxs)(`span`,{children:[`ENROLL `,D.size,` PROBLEMS (FSRS)`]})]})})]})]})]})]})})}export{w as default};
 
 
algospaced-ui/dist/assets/PrincessChamber-5t89aBn-.js DELETED
@@ -1 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{Bt as n,I as r,O as i,Rt as a,S as o,St as s,T as c,U as l,a as u,bt as d,c as f,ct as p,ft as m,k as h,l as g,o as _,p as v,y}from"./vendor-react-CIO8MTK1.js";import{C as b,S as x,_ as S,b as C,g as w,v as T,x as E,y as D}from"./index-DnK6BACV.js";var O=t(n(),1),k={1:{particleType:`pollen`,particleCount:16,particleColors:[`#FDE047`,`#FEF08A`,`#86EFAC`],gradientBg:`from-[#FFFDF0] via-[#FFF9E6] to-[#FEF3C7]`,glowColor:`rgba(251, 191, 36, 0.3)`,badgeLabel:`🌾 Plains Breeze`},2:{particleType:`leaves`,particleCount:18,particleColors:[`#86EFAC`,`#4ADE80`,`#22C55E`,`#A7F3D0`],gradientBg:`from-[#F0FDF4] via-[#DCFCE7] to-[#FEF9C3]`,glowColor:`rgba(34, 197, 94, 0.3)`,badgeLabel:`🍃 Whispering Leaves`},3:{particleType:`spores`,particleCount:22,particleColors:[`#67E8F9`,`#38BDF8`,`#818CF8`,`#C084FC`],gradientBg:`from-[#F0F9FF] via-[#E0F2FE] to-[#EDE9FE]`,glowColor:`rgba(56, 189, 248, 0.35)`,badgeLabel:`✨ Crystal Spores`},4:{particleType:`snow`,particleCount:28,particleColors:[`#FFFFFF`,`#E0F2FE`,`#BAE6FD`],gradientBg:`from-[#F8FAFC] via-[#F1F5F9] to-[#E2E8F0]`,glowColor:`rgba(186, 230, 253, 0.4)`,badgeLabel:`❄️ Alpine Snowfall`},5:{particleType:`runes`,particleCount:20,particleColors:[`#E879F9`,`#C084FC`,`#A855F7`,`#F472B6`],gradientBg:`from-[#FAF5FF] via-[#F3E8FF] to-[#FCE7F3]`,glowColor:`rgba(192, 132, 252, 0.4)`,badgeLabel:`🔮 Arcane Runes`},6:{particleType:`stardust`,particleCount:35,particleColors:[`#FDE047`,`#F59E0B`,`#E11D48`,`#818CF8`],gradientBg:`from-[#FFFBEB] via-[#FEF3C7] to-[#FFE4E6]`,glowColor:`rgba(245, 158, 11, 0.5)`,badgeLabel:`👑 Spire Gates`}};function A(e){return e<=30?k[1]:e<=60?k[2]:e<=90?k[3]:e<=120?k[4]:e<150?k[5]:k[6]}var j=a();function M({emotion:e,floor:t,rhythm:n,activity:r,isLoading:i=!1,className:a=``,onClick:o}){let s=T[e]||T.smiling_warmly,c=(0,O.useMemo)(()=>A(t),[t]),l=(0,O.useMemo)(()=>{switch(n){case`dawn`:return`from-amber-400/30 via-yellow-300/20 to-transparent`;case`dusk`:return`from-orange-500/30 via-purple-500/20 to-transparent`;case`night`:return`from-indigo-600/30 via-blue-500/20 to-transparent`;default:return`from-amber-300/25 via-sky-300/20 to-transparent`}},[n]);return(0,j.jsxs)(`div`,{onClick:o,className:`relative flex flex-col items-center justify-end select-none pointer-events-auto transition-transform ${a}`,children:[(0,j.jsx)(`div`,{className:`absolute -inset-10 overflow-hidden pointer-events-none z-0`,children:Array.from({length:Math.min(16,c.particleCount)}).map((e,t)=>{let n=c.particleColors[t%c.particleColors.length],r=`${t*17%100}%`,i=`${7+t%5*2}s`,a=`${t*.8%4}s`,o=c.particleType===`leaves`||c.particleType===`runes`?`w-2 h-2`:`w-1.5 h-1.5`;return(0,j.jsx)(`span`,{className:`absolute rounded-full opacity-60 animate-pulse ${o}`,style:{backgroundColor:n,left:r,top:`${t*21%90}%`,boxShadow:`0 0 10px ${n}`,animationDuration:i,animationDelay:a}},t)})}),(0,j.jsx)(`div`,{className:`absolute bottom-4 inset-x-0 h-48 sm:h-72 md:h-96 bg-radial ${l} blur-2xl opacity-70 pointer-events-none z-0`}),(0,j.jsxs)(`div`,{className:`relative z-10 flex flex-col items-start justify-end`,children:[r&&(0,j.jsx)(`div`,{className:`mb-2 max-w-[120px] sm:max-w-xs text-center pointer-events-none animate-in fade-in duration-300`,children:(0,j.jsxs)(`span`,{className:`text-[9px] sm:text-[10px] font-mono font-medium text-[#bfe1ff] bg-[#101e2e]/85 px-2 sm:px-2.5 py-0.5 rounded-full border border-[#3e6080]/70 shadow-md inline-flex items-center gap-1 sm:gap-1.5 backdrop-blur-xs`,children:[(0,j.jsx)(`span`,{className:`text-amber-400`,children:`🏰`}),(0,j.jsx)(`span`,{className:`truncate`,children:r})]})}),(0,j.jsx)(`div`,{className:`relative h-[28vh] sm:h-[40vh] md:h-[46vh] lg:h-[50vh] max-h-[220px] sm:max-h-[380px] md:max-h-[460px] lg:max-h-[500px] min-h-[160px] sm:min-h-[240px] md:min-h-[300px] w-auto max-w-[110px] sm:max-w-[200px] md:max-w-[270px] lg:max-w-[320px] flex items-end justify-end`,children:(0,j.jsx)(`img`,{src:s.imagePath,alt:s.label,loading:`eager`,className:`h-full w-auto max-h-[85vh] object-contain object-bottom-left drop-shadow-[0_16px_32px_rgba(0,0,0,0.55)] transition-all duration-300 ${i?`scale-[1.02] filter brightness-110 saturate-125`:`scale-100`}`,onError:e=>{let t=e.currentTarget;t.src.endsWith(`/sprites/princess/smiling_warmly.webp`)?t.src.endsWith(`/sprites/princess/neutral.webp`)||(t.src=`/sprites/princess/neutral.webp`):t.src=`/sprites/princess/smiling_warmly.webp`}})})]})]})}var N=[`I solved a tough task today!`,`I'm feeling stuck on something.`,`Just need a breather.`],P={backgroundColor:`rgba(20, 36, 54, 0.94)`,boxShadow:`0 0 0 2px #0a1420, inset 0 0 0 3px #4c7396, inset 1px 1px 0 4px #8db7dc, inset -1px -1px 0 4px #1a2c3f, inset 0 0 0 5px #0c1724, 0 10px 28px rgba(0, 0, 0, 0.75)`};function F({characterName:e,text:t,isStreaming:n=!1,isLoading:i=!1,choices:a,toolCalls:o,onSelectChoice:s,onSendMessage:l,onTypingStatusChange:u,currentFloor:p,bondTier:m,satchelCount:v=0,isMuted:b=!1,onToggleMute:x,onOpenProgress:S,onOpenSatchel:C,onOpenHistory:w,onMinimize:T,onClose:E,className:D=``}){let[k,A]=(0,O.useState)(``),[M,F]=(0,O.useState)(!1),[I,L]=(0,O.useState)(0),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(!1),H=(0,O.useRef)(t),U=(0,O.useRef)(!1),W=(0,O.useRef)(null),G=(0,O.useRef)(null),K=n||M;(0,O.useEffect)(()=>{u?.(K)},[K,u]);let q=(0,O.useMemo)(()=>Array.isArray(a)&&a.length>0?a.slice(0,4):N,[a]),J=I<q.length?I:0,Y=!n&&M?k:t;(0,O.useEffect)(()=>{if(n){W.current&&=(clearInterval(W.current),null),U.current=!0,H.current=t;return}if(U.current){U.current=!1,H.current=t,W.current&&=(clearInterval(W.current),null);return}if(t!==H.current&&!i){if(H.current=t,!t){W.current&&=(clearInterval(W.current),null);return}W.current&&clearInterval(W.current);let e=0,n=setInterval(()=>{e++,A(t.slice(0,e)),F(!0),e>=t.length&&(clearInterval(n),W.current=null,F(!1))},20);return W.current=n,()=>{clearInterval(n),W.current=null,F(!1)}}},[t,i,n]);let X=(0,O.useCallback)(()=>{W.current&&=(clearInterval(W.current),null),F(!1)},[]),Z=()=>{let e=R.trim();!e||i||n||(l(e),z(``))};return(0,O.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&E){e.preventDefault(),E();return}if(!B){if(e.key>=`1`&&e.key<=String(q.length)){let t=parseInt(e.key,10)-1;q[t]&&!i&&!n&&(e.preventDefault(),s(q[t]));return}if(e.key===`ArrowUp`){e.preventDefault(),L(e=>(e-1+q.length)%q.length);return}if(e.key===`ArrowDown`){e.preventDefault(),L(e=>(e+1)%q.length);return}if(e.key===`Enter`){!i&&!n&&q[J]&&(e.preventDefault(),s(q[J]));return}e.key===` `&&K&&(e.preventDefault(),X())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[B,q,J,i,n,K,s,X,E]),(0,j.jsxs)(`div`,{className:`relative flex flex-col gap-2 w-full ${D}`,children:[(0,j.jsxs)(`div`,{onClick:X,className:`relative w-full rounded-md sm:rounded-lg text-white pt-3.5 pb-3.5 pr-3.5 pl-8 sm:pt-5 sm:pb-5 sm:pr-5 sm:pl-14 md:pl-16 lg:pl-18 flex flex-col gap-2.5 backdrop-blur-md transition-all select-none cursor-pointer`,style:P,children:[(0,j.jsxs)(`div`,{className:`absolute -top-7 right-1 flex items-center gap-1 sm:gap-1.5 z-30`,onClick:e=>e.stopPropagation(),children:[S&&(0,j.jsxs)(`button`,{type:`button`,onClick:S,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Spire Tower Road (Floor Progress)`,children:[(0,j.jsx)(d,{className:`w-3 h-3 text-amber-400`}),(0,j.jsxs)(`span`,{children:[p,`/150 LC`]})]}),C&&(0,j.jsxs)(`button`,{type:`button`,onClick:C,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Open Royal Satchel`,children:[(0,j.jsx)(c,{className:`w-3 h-3 text-amber-400`}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:`Satchel`}),v>0&&(0,j.jsxs)(`span`,{className:`text-[9px] text-[#f3cb65]`,children:[`(`,v,`)`]})]}),w&&(0,j.jsxs)(`button`,{type:`button`,onClick:w,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Dialogue Transcript`,children:[(0,j.jsx)(h,{className:`w-3 h-3 text-[#8cb4db]`}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:`Log`})]}),x&&(0,j.jsx)(`button`,{type:`button`,onClick:x,className:`p-1 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[#8cb4db] hover:text-white transition-all cursor-pointer shadow-md`,title:b?`Unmute Audio`:`Mute Audio`,children:b?(0,j.jsx)(f,{className:`w-3 h-3`}):(0,j.jsx)(g,{className:`w-3 h-3`})}),T&&(0,j.jsx)(`button`,{type:`button`,onClick:T,className:`p-1 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[#8cb4db] hover:text-white transition-all cursor-pointer shadow-md`,title:`Minimize to Taskbar`,children:(0,j.jsx)(r,{className:`w-3 h-3`})}),E&&(0,j.jsx)(`button`,{type:`button`,onClick:E,className:`p-1 bg-[#101e2e]/90 hover:bg-rose-900/70 border border-[#3e6080]/80 hover:border-rose-400 rounded text-[#8cb4db] hover:text-rose-200 transition-all cursor-pointer shadow-md`,title:`Leave Parlor (Esc)`,children:(0,j.jsx)(_,{className:`w-3 h-3`})})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`span`,{className:`font-mono text-sm sm:text-base font-bold text-[#f3cb65] tracking-wide drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]`,children:[`-`,e||`Princess Aurelia`,`-`]}),m&&(0,j.jsx)(`span`,{className:`hidden md:inline-block text-[9px] font-mono text-[#8cb4db] bg-[#101d2c]/80 border border-[#3e6080]/60 px-1.5 py-0.2 rounded uppercase tracking-wider`,children:m})]}),(0,j.jsxs)(`div`,{className:`min-h-[48px] sm:min-h-[54px] flex flex-col justify-start`,children:[i?(0,j.jsxs)(`div`,{className:`flex items-center gap-2 py-1 text-xs sm:text-sm font-mono text-[#8cb4db]`,children:[(0,j.jsx)(`span`,{className:`inline-block w-2 h-2 bg-[#f3cb65] rounded-full animate-ping`}),(0,j.jsxs)(`span`,{children:[e||`Princess Aurelia`,` is attuning the crystal relay...`]})]}):(0,j.jsxs)(`div`,{className:`font-mono text-xs sm:text-sm md:text-[15px] leading-relaxed text-[#e6edf4] select-text`,children:[(e=>e.split(/(\*[^*]+\*)/g).map((e,t)=>e.startsWith(`*`)&&e.endsWith(`*`)?(0,j.jsx)(`span`,{className:`text-[#f3cb65] italic font-semibold mr-1 inline-block`,children:e},t):(0,j.jsx)(`span`,{children:e},t)))(Y),K&&(0,j.jsx)(`span`,{className:`inline-block w-1.5 h-3.5 bg-[#f3cb65] ml-1 animate-pulse align-middle`})]}),o&&o.length>0&&!i&&(0,j.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 select-none`,children:o.map((e,t)=>(0,j.jsxs)(`span`,{className:`px-2 py-0.5 rounded bg-[#102438] border border-[#44729b] text-[10px] font-mono font-bold text-[#bfe1ff] flex items-center gap-1`,children:[(0,j.jsx)(y,{className:`w-2.5 h-2.5 text-[#f3cb65]`}),(0,j.jsxs)(`span`,{children:[`Enchantment: `,e.name]})]},t))})]}),(0,j.jsx)(`div`,{className:`flex flex-col gap-1 pt-1`,onClick:e=>e.stopPropagation(),children:q.map((e,t)=>{let r=t+1,a=J===t;return(0,j.jsxs)(`button`,{type:`button`,disabled:i||n,onClick:()=>s(e),onMouseEnter:()=>L(t),className:`w-full sm:max-w-[90%] md:max-w-[85%] text-left flex items-center gap-2 px-2.5 py-1 rounded-xs sm:rounded-sm transition-all select-none font-mono text-xs sm:text-sm disabled:opacity-40 disabled:cursor-not-allowed ${a&&!i&&!n?`bg-[#1c3e61]/80 border border-[#4883b6]/80 shadow-[0_0_12px_rgba(72,131,182,0.25)] cursor-pointer`:`border border-transparent hover:bg-[#1c3e61]/35 cursor-pointer`}`,children:[(0,j.jsxs)(`span`,{className:`font-bold shrink-0 ${a?`text-[#e2ecf7]`:`text-[#b4c8dc]`}`,children:[r,`.`]}),(0,j.jsxs)(`span`,{className:`truncate font-medium ${a?`text-[#f3cb65]`:`text-[#dde7f2]`}`,children:[`[`,e,`]`]})]},t)})})]}),(0,j.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),Z()},onClick:e=>e.stopPropagation(),className:`w-full rounded-md sm:rounded-lg text-white py-2 sm:py-2.5 pr-3 sm:pr-4 pl-8 sm:pl-14 md:pl-16 lg:pl-18 flex items-center gap-2 backdrop-blur-md transition-all select-none`,style:P,children:[(0,j.jsx)(`span`,{className:`font-mono text-sm sm:text-base font-bold text-[#e2ecf7] select-none pl-0.5 shrink-0`,children:`>`}),(0,j.jsxs)(`div`,{className:`flex-1 flex items-center bg-[#101e2e]/90 border border-[#3b5d7d] rounded px-2.5 py-1 focus-within:border-[#67b1ec] focus-within:ring-1 focus-within:ring-[#67b1ec]/40 shadow-inner`,children:[(0,j.jsx)(`span`,{className:`text-[#f3cb65] font-mono text-xs sm:text-sm select-none mr-1.5 shrink-0`,children:`[`}),(0,j.jsx)(`input`,{ref:G,type:`text`,value:R,onChange:e=>z(e.target.value),onFocus:()=>V(!0),onBlur:()=>V(!1),disabled:i||n,placeholder:`Speak with ${e||`Princess Aurelia`}...`,className:`flex-1 bg-transparent border-none text-[#e2ecf7] placeholder-[#f3cb65]/70 font-mono text-xs sm:text-sm focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed`}),(0,j.jsx)(`span`,{className:`text-[#f3cb65] font-mono text-xs sm:text-sm select-none ml-1.5 shrink-0`,children:`]`})]}),(0,j.jsxs)(`button`,{type:`submit`,disabled:i||n||!R.trim(),className:`bg-[#34597b] hover:bg-[#3f6990] active:bg-[#2b4c6e] disabled:opacity-40 disabled:cursor-not-allowed border border-[#5c8cb5] hover:border-[#8db7dc] rounded px-3 sm:px-4 py-1 text-xs sm:text-sm font-mono font-bold text-white transition-all cursor-pointer shadow-md select-none shrink-0 flex items-center`,children:[(0,j.jsx)(`span`,{className:`text-[#f3cb65]`,children:`[`}),(0,j.jsx)(`span`,{className:`text-white px-1`,children:`Send`}),(0,j.jsx)(`span`,{className:`text-[#f3cb65]`,children:`]`})]})]})]})}function I({currentFloor:e,onClose:t}){let n=b(e),r=Math.min(100,Math.round(e/150*100));return(0,j.jsx)(`div`,{className:`absolute inset-0 z-50 bg-ink-black/40 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 select-none`,onClick:t,children:(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-xl p-4 sm:p-5 max-w-md w-full shadow-[6px_6px_0px_0px_#1E293B] flex flex-col gap-3.5`,onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(d,{className:`w-5 h-5 text-indigo-600`}),(0,j.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`Journey to the Big-O Spire`})]}),(0,j.jsx)(`button`,{type:`button`,onClick:t,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,j.jsx)(_,{className:`w-4 h-4`})})]}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-xs font-bold font-headline-md`,children:[(0,j.jsx)(`span`,{children:`Path Progress:`}),(0,j.jsxs)(`span`,{className:`font-arcade bg-indigo-100 text-indigo-900 px-2 py-0.5 rounded border border-indigo-300`,children:[e,` / 150 Leagues`]})]}),(0,j.jsx)(`div`,{className:`w-full bg-slate-200 h-4 border-[2px] border-ink-black rounded-full overflow-hidden p-0.5`,children:(0,j.jsx)(`div`,{className:`bg-gradient-to-r from-amber-400 via-yellow-400 to-emerald-400 h-full rounded-full transition-all duration-500`,style:{width:`${r}%`}})}),(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-trash-gray font-medium`,children:[(0,j.jsxs)(`span`,{children:[`Progress: `,(0,j.jsxs)(`strong`,{children:[r,`%`]})]}),(0,j.jsxs)(`span`,{children:[`Distance to Tower: `,(0,j.jsxs)(`strong`,{children:[Math.max(0,150-e),` leagues`]})]})]})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[2px] border-ink-black rounded-lg p-3 shadow-[2px_2px_0px_0px_#1E293B] flex flex-col gap-1`,children:[(0,j.jsx)(`div`,{className:`text-[10px] font-bold uppercase text-amber-700 tracking-wider`,children:`Current Realm:`}),(0,j.jsx)(`div`,{className:`font-bold text-xs text-ink-black`,children:n.title}),(0,j.jsx)(`p`,{className:`text-[11px] text-slate-600 m-0 leading-relaxed font-medium`,children:n.description}),(0,j.jsxs)(`div`,{className:`text-[10px] text-amber-900 bg-amber-50 p-1.5 rounded border border-amber-200 italic mt-1`,children:[`📜 `,n.bgLore]})]}),(0,j.jsx)(`div`,{className:`flex items-center justify-between gap-1 text-center`,children:[{floor:30,label:`Arrays`},{floor:60,label:`Pointers`},{floor:90,label:`Trees`},{floor:120,label:`Heaps`},{floor:150,label:`Spire`}].map(t=>{let n=e>=t.floor;return(0,j.jsxs)(`div`,{className:`flex-1 p-1.5 rounded border text-[10px] flex flex-col items-center ${n?`bg-emerald-100 border-emerald-600 text-emerald-900 font-bold`:`bg-slate-100 border-slate-300 text-slate-500`}`,children:[(0,j.jsx)(`span`,{children:n?`✓`:t.floor}),(0,j.jsx)(`span`,{className:`text-[9px] truncate w-full`,children:t.label})]},t.floor)})}),(0,j.jsx)(`div`,{className:`flex items-center justify-end border-t border-slate-200 pt-2 mt-1`,children:(0,j.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-1.5 bg-white hover:bg-slate-100 border-[1.5px] border-ink-black rounded font-bold text-xs text-ink-black cursor-pointer shadow-xs active:translate-y-0.5`,children:`Done`})})]})})}function L({unlockedLetters:e,spireChronicles:t,currentFloor:n,heroCodex:r,episodicEvents:i,recentToolTelemetry:a,onRemoveCodexItem:d,onClose:f}){let[h,g]=(0,O.useState)(`letters`),[b,S]=(0,O.useState)(e[e.length-1]||null);return(0,j.jsx)(`div`,{className:`absolute inset-0 z-50 bg-ink-black/50 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 select-none`,onClick:f,children:(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-xl max-w-lg w-full h-[85%] max-h-[560px] shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)(`div`,{className:`bg-white border-b-[2px] border-ink-black px-4 py-2.5 flex items-center justify-between shrink-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(c,{className:`w-5 h-5 text-amber-700`}),(0,j.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`The Royal Satchel`})]}),(0,j.jsx)(`button`,{type:`button`,onClick:f,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,j.jsx)(_,{className:`w-4 h-4`})})]}),(0,j.jsxs)(`div`,{className:`flex border-b-2 border-ink-black bg-amber-100/70 shrink-0`,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>g(`letters`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer border-r border-ink-black/20 ${h===`letters`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,j.jsx)(c,{className:`w-3.5 h-3.5`}),(0,j.jsxs)(`span`,{children:[`Missives (`,e.length,`/5)`]})]}),(0,j.jsxs)(`button`,{type:`button`,onClick:()=>g(`diary`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer border-r border-ink-black/20 ${h===`diary`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,j.jsx)(s,{className:`w-3.5 h-3.5`}),(0,j.jsxs)(`span`,{children:[`Chronicles (`,t.length,`)`]})]}),(0,j.jsxs)(`button`,{type:`button`,onClick:()=>g(`codex`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer ${h===`codex`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,j.jsx)(y,{className:`w-3.5 h-3.5 text-amber-700`}),(0,j.jsx)(`span`,{children:`Codex`})]})]}),(0,j.jsxs)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-3 min-h-0`,children:[h===`letters`&&(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1`,children:[(0,j.jsx)(`div`,{className:`flex items-center gap-1.5 overflow-x-auto pb-1`,children:[30,60,90,120,150].map(e=>{let t=x[e],r=n>=e,i=b?.floor===e;return(0,j.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&S(t),className:`px-3 py-1 rounded-full text-[11px] font-bold border-[1.5px] border-ink-black flex items-center gap-1 shrink-0 transition-all cursor-pointer ${r?i?`bg-[#FFE24C] text-ink-black shadow-[1.5px_1.5px_0px_0px_#1E293B]`:`bg-white hover:bg-amber-100 text-slate-800`:`opacity-40 bg-slate-200 text-slate-500 cursor-not-allowed`}`,children:[r?(0,j.jsx)(`span`,{children:`📜`}):(0,j.jsx)(l,{className:`w-3 h-3`}),(0,j.jsxs)(`span`,{children:[`League `,e]})]},e)})}),b?(0,j.jsxs)(`div`,{className:`bg-[#FFF9E6] border-[2px] border-amber-900/40 rounded-lg p-4 shadow-sm flex-1 overflow-y-auto custom-scrollbar flex flex-col select-text`,children:[(0,j.jsxs)(`div`,{className:`border-b border-amber-800/20 pb-2 mb-3 flex items-center justify-between`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`text-[10px] font-bold text-amber-800 uppercase tracking-wider`,children:[b.chapterTitle,` • League `,b.floor]}),(0,j.jsx)(`h5`,{className:`font-headline-md font-bold text-sm text-amber-950 m-0`,children:b.title})]}),(0,j.jsx)(`span`,{className:`text-xl`,children:`🪶`})]}),(0,j.jsx)(`p`,{className:`text-xs sm:text-[13px] text-amber-950 font-serif leading-relaxed whitespace-pre-wrap flex-1 italic`,children:b.letterText})]}):(0,j.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,j.jsx)(l,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:`Conquer 30 LeetCode problems along the path to receive your first Royal Missive from Aurelia.`})]})]}),h===`diary`&&(0,j.jsx)(`div`,{className:`flex flex-col gap-2.5 flex-1`,children:t.length>0?t.map(e=>(0,j.jsxs)(`div`,{className:`p-3 bg-white border-[1.5px] border-ink-black rounded-lg shadow-xs flex flex-col gap-1 select-text`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-amber-800 font-bold border-b border-slate-100 pb-1`,children:[(0,j.jsxs)(`span`,{children:[`League `,e.floor,` along the Path`]}),(0,j.jsx)(`span`,{children:new Date(e.timestamp).toLocaleDateString()})]}),(0,j.jsxs)(`p`,{className:`text-xs text-ink-black font-medium leading-relaxed m-0 italic font-serif`,children:[`“`,e.text,`”`]})]},e.id)):(0,j.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,j.jsx)(s,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:`Aurelia records entries in her Spire Chronicles autonomously as you chat, rest, and cross chapter milestones.`})]})}),h===`codex`&&(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1 select-text`,children:[(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1.5`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,j.jsx)(y,{className:`w-4 h-4 text-amber-600`}),(0,j.jsx)(`h5`,{className:`font-headline-md font-bold text-xs text-ink-black m-0`,children:`Hero Codex (MemGPT & Mem0 Core Memory)`})]}),(0,j.jsx)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:`Cognitive Sync`})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 text-xs`,children:[(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Hero Alias`}),(0,j.jsx)(`span`,{className:`font-bold text-ink-black text-xs`,children:r?.heroName||`Champion`})]}),(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Target Goal`}),(0,j.jsx)(`span`,{className:`font-bold text-amber-900 text-xs`,children:r?.targetGoal||`None shared yet (mention to Aurelia!)`})]})]}),r?.preferredLanguage&&(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2 text-xs`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Weapon of Choice (Language)`}),(0,j.jsx)(`span`,{className:`font-bold text-ink-black`,children:r.preferredLanguage})]})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-emerald-800`,children:[(0,j.jsx)(m,{className:`w-3.5 h-3.5`}),(0,j.jsxs)(`span`,{children:[`Mastered Patterns (`,r?.strengths?.length||0,`)`]})]}),r?.strengths&&r.strengths.length>0?(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.strengths.map(e=>(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-emerald-50 text-emerald-800 border border-emerald-300`,children:[e,d&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>d(`strengths`,e),className:`hover:text-red-600 ml-0.5 cursor-pointer`,title:`Forget strength`,children:(0,j.jsx)(_,{className:`w-3 h-3`})})]},e))}):(0,j.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia will note topics you conquer during your practice.`})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-rose-800`,children:[(0,j.jsx)(o,{className:`w-3.5 h-3.5`}),(0,j.jsxs)(`span`,{children:[`Nemesis Patterns (`,r?.nemesisPatterns?.length||0,`)`]})]}),r?.nemesisPatterns&&r.nemesisPatterns.length>0?(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.nemesisPatterns.map(e=>(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-rose-50 text-rose-800 border border-rose-300`,children:[e,d&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>d(`nemesisPatterns`,e),className:`hover:text-red-700 ml-0.5 cursor-pointer`,title:`Forget nemesis`,children:(0,j.jsx)(_,{className:`w-3 h-3`})})]},e))}):(0,j.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia tracks patterns that give you trouble to help you prepare targeted drills.`})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsx)(`div`,{className:`text-xs font-bold text-slate-800`,children:(0,j.jsxs)(`span`,{children:[`Personal Notes & Shared Lore (`,r?.personalNotes?.length||0,`)`]})}),r?.personalNotes&&r.personalNotes.length>0?(0,j.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.personalNotes.map(e=>(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2 p-2 bg-slate-50 border border-slate-200 rounded text-[11px] text-slate-700`,children:[(0,j.jsxs)(`span`,{children:[`• `,e]}),d&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>d(`personalNotes`,e),className:`text-slate-400 hover:text-red-600 shrink-0 cursor-pointer p-0.5`,title:`Forget note`,children:(0,j.jsx)(v,{className:`w-3 h-3`})})]},e))}):(0,j.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Share your background or routine with Aurelia and she will hold it in her memory.`})]}),i&&i.length>0&&(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,j.jsx)(`span`,{className:`text-xs font-bold text-slate-800`,children:`Episodic Memory Chain (EM-LLM)`}),(0,j.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[i.length,` events`]})]}),(0,j.jsx)(`div`,{className:`flex flex-col gap-2 max-h-40 overflow-y-auto custom-scrollbar`,children:i.slice(0,8).map(e=>(0,j.jsxs)(`div`,{className:`text-[11px] p-2 bg-[#FFFDF0] border border-amber-900/15 rounded flex flex-col gap-0.5`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(`span`,{className:`font-bold text-ink-black uppercase text-[9px] px-1.5 py-0.5 bg-amber-200/60 rounded`,children:e.eventType.replace(`_`,` `)}),(0,j.jsx)(`span`,{className:`text-[10px] text-slate-400`,children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),(0,j.jsx)(`div`,{className:`font-bold text-slate-800 mt-0.5`,children:e.title}),(0,j.jsx)(`div`,{className:`text-slate-600 text-[10px]`,children:e.description})]},e.id))})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-indigo-900`,children:[(0,j.jsx)(u,{className:`w-3.5 h-3.5 text-amber-500`}),(0,j.jsx)(`span`,{children:`Autonomous Enchantment Telemetry`})]}),(0,j.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[a?.length||0,` executed`]})]}),a&&a.length>0?(0,j.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-36 overflow-y-auto custom-scrollbar`,children:a.slice(0,10).map((e,t)=>(0,j.jsxs)(`div`,{className:`text-[11px] p-2 bg-indigo-50/50 border border-indigo-100 rounded flex items-center justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,j.jsxs)(`span`,{className:`font-bold text-indigo-950 font-mono text-[10px] truncate`,children:[e.tool_name,`()`]}),e.args&&Object.keys(e.args).length>0&&(0,j.jsx)(`span`,{className:`text-[9px] text-slate-500 truncate`,children:JSON.stringify(e.args).slice(0,50)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.execution_time_ms!==void 0&&(0,j.jsxs)(`span`,{className:`text-[9px] text-slate-400 flex items-center gap-0.5 font-mono`,children:[(0,j.jsx)(p,{className:`w-2.5 h-2.5`}),e.execution_time_ms,`ms`]}),(0,j.jsx)(`span`,{className:`px-1.5 py-0.2 text-[9px] font-bold rounded ${e.success?`bg-emerald-100 text-emerald-800`:`bg-rose-100 text-rose-800`}`,children:e.success?`SUCCESS`:`ERR`})]})]},t))}):(0,j.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`No autonomous enchantments executed yet in this session.`})]})]})]}),(0,j.jsx)(`div`,{className:`bg-white border-t border-slate-200 px-4 py-2 flex items-center justify-end shrink-0`,children:(0,j.jsx)(`button`,{type:`button`,onClick:f,className:`px-4 py-1.5 bg-white hover:bg-slate-100 border-[1.5px] border-ink-black rounded font-bold text-xs text-ink-black cursor-pointer shadow-xs active:translate-y-0.5`,children:`Close`})})]})})}var R=e({default:()=>z});function z({onClose:e,onMinimize:t,isActive:n=!0,onFocus:r,zIndex:a}){let o=E(),[s,c]=(0,O.useState)(w()),[l,u]=(0,O.useState)(!1),[d,f]=(0,O.useState)(!1),[p,m]=(0,O.useState)(!1);(0,O.useEffect)(()=>{C.syncWithBackend(),C.triggerProactiveGreeting()},[]);let g=(0,O.useCallback)(()=>{e?e():D.getState().closeWindow(`companion`)},[e]),v=(0,O.useCallback)(()=>{t?t():D.getState().minimizeWindow(`companion`)},[t]),y=(0,O.useCallback)(()=>{r?r():D.getState().setActiveWindow(`companion`)},[r]),b=(0,O.useCallback)(()=>{let e=!s;c(e),S(e)},[s]),x=(0,O.useCallback)(()=>{window.confirm(`Clear conversation transcript with Princess Aurelia?`)&&C.clearTranscript()},[]),T=(0,O.useCallback)(e=>{C.setIsTyping(e)},[]),k=(0,O.useMemo)(()=>[...o.transcript].reverse().find(e=>e.sender===`princess`)||o.transcript[0],[o.transcript]),A=`Welcome back to the Spire Tower Parlor. How is your day going today? Are you making progress, or could you use a hand?`,N=k?k.isStreaming?k.text:k.text||(o.isLoading?``:A):A,P=(0,O.useMemo)(()=>k?.choiceSuggestions&&k.choiceSuggestions.length>0?k.choiceSuggestions:[...o.transcript].reverse().find(e=>e.sender===`princess`&&e.choiceSuggestions&&e.choiceSuggestions.length>0)?.choiceSuggestions,[k,o.transcript]);return(0,j.jsxs)(`div`,{onClick:y,className:`fixed inset-x-0 top-0 bottom-[40px] select-none pointer-events-none overflow-hidden font-sans`,style:{zIndex:a??(n?40:30)},children:[(0,j.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-44 bg-gradient-to-t from-slate-950/35 via-slate-900/10 to-transparent pointer-events-none z-0`}),(0,j.jsxs)(`div`,{className:`relative w-full h-full flex flex-col justify-end pointer-events-none pb-2 sm:pb-3 px-2 sm:px-4 md:px-8`,children:[(0,j.jsxs)(`div`,{className:`relative w-full max-w-5xl lg:max-w-6xl mx-auto flex items-end justify-start pointer-events-none`,children:[(0,j.jsx)(`div`,{className:`relative z-30 shrink-0 pointer-events-auto -mr-6 sm:-mr-10 md:-mr-12 lg:-mr-14`,children:(0,j.jsx)(M,{emotion:o.activeEmotion,floor:o.currentFloor,rhythm:o.currentRhythm,activity:o.currentActivity,isLoading:o.isLoading,onClick:y})}),(0,j.jsx)(`div`,{className:`relative z-20 flex-1 min-w-0 pointer-events-auto mb-1`,children:(0,j.jsx)(F,{characterName:o.companionSettings.name||`Princess Aurelia`,emotion:o.activeEmotion,text:N,isStreaming:k?.isStreaming,isLoading:o.isLoading,choices:P,toolCalls:k?.toolCalls,onSelectChoice:e=>C.sendMessage(e),onSendMessage:e=>C.sendMessage(e),onTypingStatusChange:T,currentFloor:o.currentFloor,bondTier:o.bondTier,satchelCount:o.unlockedLetters.length,isMuted:s,onToggleMute:b,onOpenProgress:()=>u(!0),onOpenSatchel:()=>f(!0),onOpenHistory:()=>m(!0),onMinimize:v,onClose:g})})]}),(0,j.jsxs)(`div`,{className:`absolute bottom-1 right-3.5 pointer-events-none z-30 hidden md:flex flex-col items-center gap-0.5 opacity-65 select-none`,children:[(0,j.jsx)(`svg`,{className:`w-8 h-8 text-[#9cbcdb] drop-shadow-[0_0_6px_rgba(156,188,219,0.5)] rotate-6`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,j.jsx)(`path`,{d:`M12 2 C12 7.8 7.8 12 2 12 C7.8 12 12 16.2 12 22 C12 16.2 16.2 12 22 12 C16.2 12 12 7.8 12 2 Z`})}),(0,j.jsxs)(`div`,{className:`font-mono text-[9px] text-[#7ba4c8] tracking-tight leading-tight text-center`,children:[(0,j.jsx)(`div`,{children:`AlgoSpaced (Beta)`}),(0,j.jsx)(`div`,{children:`Build Jun24 preview`})]})]})]}),l&&(0,j.jsx)(`div`,{className:`pointer-events-auto`,children:(0,j.jsx)(I,{currentFloor:o.currentFloor,totalSolved:o.totalSolved,onClose:()=>u(!1)})}),d&&(0,j.jsx)(`div`,{className:`pointer-events-auto`,children:(0,j.jsx)(L,{unlockedLetters:o.unlockedLetters,spireChronicles:o.spireChronicles,currentFloor:o.currentFloor,heroCodex:o.heroCodex,episodicEvents:o.episodicEvents,recentToolTelemetry:o.recentToolTelemetry,onRemoveCodexItem:C.removeCodexItem,onClose:()=>f(!1)})}),p&&(0,j.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 pointer-events-auto`,onClick:()=>m(!1),children:(0,j.jsxs)(`div`,{className:`bg-[#142335] border-[3px] border-[#5a80a2] rounded-xl max-w-lg w-full h-[80%] max-h-[520px] shadow-[0_16px_40px_rgba(0,0,0,0.85)] flex flex-col overflow-hidden text-white`,onClick:e=>e.stopPropagation(),style:{boxShadow:`inset 0 0 0 1px #0a1420, inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 16px 40px rgba(0, 0, 0, 0.85)`},children:[(0,j.jsxs)(`div`,{className:`bg-[#101b2a] border-b border-[#304f6f] px-4 py-2.5 flex items-center justify-between shrink-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(h,{className:`w-4 h-4 text-[#67b1ec]`}),(0,j.jsxs)(`h4`,{className:`font-mono font-bold text-xs sm:text-sm text-[#e6f0fa] m-0`,children:[`Dialogue Transcript (`,o.transcript.length,` turns)`]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:x,className:`px-2 py-0.5 bg-rose-950/60 hover:bg-rose-900 border border-rose-700/60 rounded text-[11px] font-mono font-bold text-rose-300 hover:text-white flex items-center gap-1 cursor-pointer mr-1 transition-colors`,title:`Clear Chat History`,children:[(0,j.jsx)(i,{className:`w-3 h-3`}),(0,j.jsx)(`span`,{children:`Clear`})]}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>m(!1),className:`p-1 hover:bg-[#203a55] rounded text-[#8cb4db] hover:text-white cursor-pointer transition-colors`,title:`Close`,children:(0,j.jsx)(_,{className:`w-4 h-4`})})]})]}),(0,j.jsx)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-2.5 bg-[#0e1824]/90`,children:o.transcript.map((e,t)=>(0,j.jsxs)(`div`,{className:`p-2.5 rounded-lg border font-mono text-xs max-w-[90%] shadow-md ${e.sender===`princess`?`bg-[#182c42] border-[#3e6080] text-[#e6f0fa] self-start`:`bg-[#214365] border-[#5a8bb9] text-white self-end`}`,children:[(0,j.jsx)(`div`,{className:`text-[10px] font-bold mb-1 text-[#f6d267]`,children:e.sender===`princess`?o.companionSettings.name:`Hero`}),(0,j.jsx)(`p`,{className:`font-medium m-0 leading-relaxed whitespace-pre-wrap select-text`,children:e.text})]},e.id||t))})]})})]})}export{R as t};
 
 
algospaced-ui/dist/assets/PrincessChamber-abJShfI5.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{A as n,Bt as r,Ct as i,D as a,G as o,Ht as s,R as c,Tt as l,a as u,c as d,dt as f,ht as p,j as m,l as h,o as g,p as _,w as v,x as y}from"./vendor-react-hnaVBnLv.js";import{C as b,S as x,_ as S,b as C,g as w,v as T,x as E,y as D}from"./index-DVWZ15xt.js";var O=t(s(),1),k={1:{particleType:`pollen`,particleCount:16,particleColors:[`#FDE047`,`#FEF08A`,`#86EFAC`],gradientBg:`from-[#FFFDF0] via-[#FFF9E6] to-[#FEF3C7]`,glowColor:`rgba(251, 191, 36, 0.3)`,badgeLabel:`🌾 Plains Breeze`},2:{particleType:`leaves`,particleCount:18,particleColors:[`#86EFAC`,`#4ADE80`,`#22C55E`,`#A7F3D0`],gradientBg:`from-[#F0FDF4] via-[#DCFCE7] to-[#FEF9C3]`,glowColor:`rgba(34, 197, 94, 0.3)`,badgeLabel:`🍃 Whispering Leaves`},3:{particleType:`spores`,particleCount:22,particleColors:[`#67E8F9`,`#38BDF8`,`#818CF8`,`#C084FC`],gradientBg:`from-[#F0F9FF] via-[#E0F2FE] to-[#EDE9FE]`,glowColor:`rgba(56, 189, 248, 0.35)`,badgeLabel:`✨ Crystal Spores`},4:{particleType:`snow`,particleCount:28,particleColors:[`#FFFFFF`,`#E0F2FE`,`#BAE6FD`],gradientBg:`from-[#F8FAFC] via-[#F1F5F9] to-[#E2E8F0]`,glowColor:`rgba(186, 230, 253, 0.4)`,badgeLabel:`❄️ Alpine Snowfall`},5:{particleType:`runes`,particleCount:20,particleColors:[`#E879F9`,`#C084FC`,`#A855F7`,`#F472B6`],gradientBg:`from-[#FAF5FF] via-[#F3E8FF] to-[#FCE7F3]`,glowColor:`rgba(192, 132, 252, 0.4)`,badgeLabel:`🔮 Arcane Runes`},6:{particleType:`stardust`,particleCount:35,particleColors:[`#FDE047`,`#F59E0B`,`#E11D48`,`#818CF8`],gradientBg:`from-[#FFFBEB] via-[#FEF3C7] to-[#FFE4E6]`,glowColor:`rgba(245, 158, 11, 0.5)`,badgeLabel:`👑 Spire Gates`}};function A(e){return e<=30?k[1]:e<=60?k[2]:e<=90?k[3]:e<=120?k[4]:e<150?k[5]:k[6]}var j=r();function M({emotion:e,floor:t,rhythm:n,activity:r,isLoading:i=!1,className:a=``,onClick:o}){let s=T[e]||T.smiling_warmly,c=(0,O.useMemo)(()=>A(t),[t]),l=(0,O.useMemo)(()=>{switch(n){case`dawn`:return`from-amber-400/30 via-yellow-300/20 to-transparent`;case`dusk`:return`from-orange-500/30 via-purple-500/20 to-transparent`;case`night`:return`from-indigo-600/30 via-blue-500/20 to-transparent`;default:return`from-amber-300/25 via-sky-300/20 to-transparent`}},[n]);return(0,j.jsxs)(`div`,{onClick:o,className:`relative flex flex-col items-center justify-end select-none pointer-events-auto transition-transform ${a}`,children:[(0,j.jsx)(`div`,{className:`absolute -inset-10 overflow-hidden pointer-events-none z-0`,children:Array.from({length:Math.min(16,c.particleCount)}).map((e,t)=>{let n=c.particleColors[t%c.particleColors.length],r=`${t*17%100}%`,i=`${7+t%5*2}s`,a=`${t*.8%4}s`,o=c.particleType===`leaves`||c.particleType===`runes`?`w-2 h-2`:`w-1.5 h-1.5`;return(0,j.jsx)(`span`,{className:`absolute rounded-full opacity-60 animate-pulse ${o}`,style:{backgroundColor:n,left:r,top:`${t*21%90}%`,boxShadow:`0 0 10px ${n}`,animationDuration:i,animationDelay:a}},t)})}),(0,j.jsx)(`div`,{className:`absolute bottom-4 inset-x-0 h-48 sm:h-72 md:h-96 bg-radial ${l} blur-2xl opacity-70 pointer-events-none z-0`}),(0,j.jsxs)(`div`,{className:`relative z-10 flex flex-col items-start justify-end`,children:[r&&(0,j.jsx)(`div`,{className:`mb-2 max-w-[120px] sm:max-w-xs text-center pointer-events-none animate-in fade-in duration-300`,children:(0,j.jsxs)(`span`,{className:`text-[9px] sm:text-[10px] font-mono font-medium text-[#bfe1ff] bg-[#101e2e]/85 px-2 sm:px-2.5 py-0.5 rounded-full border border-[#3e6080]/70 shadow-md inline-flex items-center gap-1 sm:gap-1.5 backdrop-blur-xs`,children:[(0,j.jsx)(`span`,{className:`text-amber-400`,children:`🏰`}),(0,j.jsx)(`span`,{className:`truncate`,children:r})]})}),(0,j.jsx)(`div`,{className:`relative h-[28vh] sm:h-[40vh] md:h-[46vh] lg:h-[50vh] max-h-[220px] sm:max-h-[380px] md:max-h-[460px] lg:max-h-[500px] min-h-[160px] sm:min-h-[240px] md:min-h-[300px] w-auto max-w-[110px] sm:max-w-[200px] md:max-w-[270px] lg:max-w-[320px] flex items-end justify-end`,children:(0,j.jsx)(`img`,{src:s.imagePath,alt:s.label,loading:`eager`,className:`h-full w-auto max-h-[85vh] object-contain object-bottom-left drop-shadow-[0_16px_32px_rgba(0,0,0,0.55)] transition-all duration-300 ${i?`scale-[1.02] filter brightness-110 saturate-125`:`scale-100`}`,onError:e=>{let t=e.currentTarget;t.src.endsWith(`/sprites/princess/smiling_warmly.webp`)?t.src.endsWith(`/sprites/princess/neutral.webp`)||(t.src=`/sprites/princess/neutral.webp`):t.src=`/sprites/princess/smiling_warmly.webp`}})})]})]})}var N=[`I solved a tough task today!`,`I'm feeling stuck on something.`,`Just need a breather.`],P={backgroundColor:`rgba(20, 36, 54, 0.94)`,boxShadow:`0 0 0 2px #0a1420, inset 0 0 0 3px #4c7396, inset 1px 1px 0 4px #8db7dc, inset -1px -1px 0 4px #1a2c3f, inset 0 0 0 5px #0c1724, 0 10px 28px rgba(0, 0, 0, 0.75)`};function F({characterName:e,text:t,isStreaming:n=!1,isLoading:r=!1,choices:o,toolCalls:s,onSelectChoice:l,onSendMessage:u,onTypingStatusChange:f,currentFloor:p,bondTier:_,satchelCount:v=0,isMuted:b=!1,onToggleMute:x,onOpenProgress:S,onOpenSatchel:C,onOpenHistory:w,onMinimize:T,onClose:E,className:D=``}){let[k,A]=(0,O.useState)(``),[M,F]=(0,O.useState)(!1),[I,L]=(0,O.useState)(0),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(!1),H=(0,O.useRef)(t),U=(0,O.useRef)(!1),W=(0,O.useRef)(null),G=(0,O.useRef)(null),K=n||M;(0,O.useEffect)(()=>{f?.(K)},[K,f]);let q=(0,O.useMemo)(()=>Array.isArray(o)&&o.length>0?o.slice(0,4):N,[o]),J=I<q.length?I:0,Y=!n&&M?k:t;(0,O.useEffect)(()=>{if(n){W.current&&=(clearInterval(W.current),null),U.current=!0,H.current=t;return}if(U.current){U.current=!1,H.current=t,W.current&&=(clearInterval(W.current),null);return}if(t!==H.current&&!r){if(H.current=t,!t){W.current&&=(clearInterval(W.current),null);return}W.current&&clearInterval(W.current);let e=0,n=setInterval(()=>{e++,A(t.slice(0,e)),F(!0),e>=t.length&&(clearInterval(n),W.current=null,F(!1))},20);return W.current=n,()=>{clearInterval(n),W.current=null,F(!1)}}},[t,r,n]);let X=(0,O.useCallback)(()=>{W.current&&=(clearInterval(W.current),null),F(!1)},[]),Z=()=>{let e=R.trim();!e||r||n||(u(e),z(``))};return(0,O.useEffect)(()=>{let e=e=>{if(e.key===`Escape`&&E){e.preventDefault(),E();return}if(!B){if(e.key>=`1`&&e.key<=String(q.length)){let t=parseInt(e.key,10)-1;q[t]&&!r&&!n&&(e.preventDefault(),l(q[t]));return}if(e.key===`ArrowUp`){e.preventDefault(),L(e=>(e-1+q.length)%q.length);return}if(e.key===`ArrowDown`){e.preventDefault(),L(e=>(e+1)%q.length);return}if(e.key===`Enter`){!r&&!n&&q[J]&&(e.preventDefault(),l(q[J]));return}e.key===` `&&K&&(e.preventDefault(),X())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[B,q,J,r,n,K,l,X,E]),(0,j.jsxs)(`div`,{className:`relative flex flex-col gap-2 w-full ${D}`,children:[(0,j.jsxs)(`div`,{onClick:X,className:`relative w-full rounded-md sm:rounded-lg text-white pt-3.5 pb-3.5 pr-3.5 pl-8 sm:pt-5 sm:pb-5 sm:pr-5 sm:pl-14 md:pl-16 lg:pl-18 flex flex-col gap-2.5 backdrop-blur-md transition-all select-none cursor-pointer`,style:P,children:[(0,j.jsxs)(`div`,{className:`absolute -top-7 right-1 flex items-center gap-1 sm:gap-1.5 z-30`,onClick:e=>e.stopPropagation(),children:[S&&(0,j.jsxs)(`button`,{type:`button`,onClick:S,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Spire Tower Road (Floor Progress)`,children:[(0,j.jsx)(i,{className:`w-3 h-3 text-amber-400`}),(0,j.jsxs)(`span`,{children:[p,`/150 LC`]})]}),C&&(0,j.jsxs)(`button`,{type:`button`,onClick:C,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Open Royal Satchel`,children:[(0,j.jsx)(a,{className:`w-3 h-3 text-amber-400`}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:`Satchel`}),v>0&&(0,j.jsxs)(`span`,{className:`text-[9px] text-[#f3cb65]`,children:[`(`,v,`)`]})]}),w&&(0,j.jsxs)(`button`,{type:`button`,onClick:w,className:`px-2 py-0.5 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[10px] sm:text-[11px] font-mono font-bold text-[#8cb4db] hover:text-white transition-all cursor-pointer flex items-center gap-1 shadow-md`,title:`Dialogue Transcript`,children:[(0,j.jsx)(m,{className:`w-3 h-3 text-[#8cb4db]`}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:`Log`})]}),x&&(0,j.jsx)(`button`,{type:`button`,onClick:x,className:`p-1 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[#8cb4db] hover:text-white transition-all cursor-pointer shadow-md`,title:b?`Unmute Audio`:`Mute Audio`,children:b?(0,j.jsx)(d,{className:`w-3 h-3`}):(0,j.jsx)(h,{className:`w-3 h-3`})}),T&&(0,j.jsx)(`button`,{type:`button`,onClick:T,className:`p-1 bg-[#101e2e]/90 hover:bg-[#1f3750] border border-[#3e6080]/80 hover:border-[#67b1ec] rounded text-[#8cb4db] hover:text-white transition-all cursor-pointer shadow-md`,title:`Minimize to Taskbar`,children:(0,j.jsx)(c,{className:`w-3 h-3`})}),E&&(0,j.jsx)(`button`,{type:`button`,onClick:E,className:`p-1 bg-[#101e2e]/90 hover:bg-rose-900/70 border border-[#3e6080]/80 hover:border-rose-400 rounded text-[#8cb4db] hover:text-rose-200 transition-all cursor-pointer shadow-md`,title:`Leave Parlor (Esc)`,children:(0,j.jsx)(g,{className:`w-3 h-3`})})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`span`,{className:`font-mono text-sm sm:text-base font-bold text-[#f3cb65] tracking-wide drop-shadow-[0_1px_2px_rgba(0,0,0,0.9)]`,children:[`-`,e||`Princess Aurelia`,`-`]}),_&&(0,j.jsx)(`span`,{className:`hidden md:inline-block text-[9px] font-mono text-[#8cb4db] bg-[#101d2c]/80 border border-[#3e6080]/60 px-1.5 py-0.2 rounded uppercase tracking-wider`,children:_})]}),(0,j.jsxs)(`div`,{className:`min-h-[48px] sm:min-h-[54px] flex flex-col justify-start`,children:[r?(0,j.jsxs)(`div`,{className:`flex items-center gap-2 py-1 text-xs sm:text-sm font-mono text-[#8cb4db]`,children:[(0,j.jsx)(`span`,{className:`inline-block w-2 h-2 bg-[#f3cb65] rounded-full animate-ping`}),(0,j.jsxs)(`span`,{children:[e||`Princess Aurelia`,` is attuning the crystal relay...`]})]}):(0,j.jsxs)(`div`,{className:`font-mono text-xs sm:text-sm md:text-[15px] leading-relaxed text-[#e6edf4] select-text`,children:[(e=>e.split(/(\*[^*]+\*)/g).map((e,t)=>e.startsWith(`*`)&&e.endsWith(`*`)?(0,j.jsx)(`span`,{className:`text-[#f3cb65] italic font-semibold mr-1 inline-block`,children:e},t):(0,j.jsx)(`span`,{children:e},t)))(Y),K&&(0,j.jsx)(`span`,{className:`inline-block w-1.5 h-3.5 bg-[#f3cb65] ml-1 animate-pulse align-middle`})]}),s&&s.length>0&&!r&&(0,j.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 select-none`,children:s.map((e,t)=>(0,j.jsxs)(`span`,{className:`px-2 py-0.5 rounded bg-[#102438] border border-[#44729b] text-[10px] font-mono font-bold text-[#bfe1ff] flex items-center gap-1`,children:[(0,j.jsx)(y,{className:`w-2.5 h-2.5 text-[#f3cb65]`}),(0,j.jsxs)(`span`,{children:[`Enchantment: `,e.name]})]},t))})]}),(0,j.jsx)(`div`,{className:`flex flex-col gap-1 pt-1`,onClick:e=>e.stopPropagation(),children:q.map((e,t)=>{let i=t+1,a=J===t;return(0,j.jsxs)(`button`,{type:`button`,disabled:r||n,onClick:()=>l(e),onMouseEnter:()=>L(t),className:`w-full sm:max-w-[90%] md:max-w-[85%] text-left flex items-center gap-2 px-2.5 py-1 rounded-xs sm:rounded-sm transition-all select-none font-mono text-xs sm:text-sm disabled:opacity-40 disabled:cursor-not-allowed ${a&&!r&&!n?`bg-[#1c3e61]/80 border border-[#4883b6]/80 shadow-[0_0_12px_rgba(72,131,182,0.25)] cursor-pointer`:`border border-transparent hover:bg-[#1c3e61]/35 cursor-pointer`}`,children:[(0,j.jsxs)(`span`,{className:`font-bold shrink-0 ${a?`text-[#e2ecf7]`:`text-[#b4c8dc]`}`,children:[i,`.`]}),(0,j.jsxs)(`span`,{className:`truncate font-medium ${a?`text-[#f3cb65]`:`text-[#dde7f2]`}`,children:[`[`,e,`]`]})]},t)})})]}),(0,j.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),Z()},onClick:e=>e.stopPropagation(),className:`w-full rounded-md sm:rounded-lg text-white py-2 sm:py-2.5 pr-3 sm:pr-4 pl-8 sm:pl-14 md:pl-16 lg:pl-18 flex items-center gap-2 backdrop-blur-md transition-all select-none`,style:P,children:[(0,j.jsx)(`span`,{className:`font-mono text-sm sm:text-base font-bold text-[#e2ecf7] select-none pl-0.5 shrink-0`,children:`>`}),(0,j.jsxs)(`div`,{className:`flex-1 flex items-center bg-[#101e2e]/90 border border-[#3b5d7d] rounded px-2.5 py-1 focus-within:border-[#67b1ec] focus-within:ring-1 focus-within:ring-[#67b1ec]/40 shadow-inner`,children:[(0,j.jsx)(`span`,{className:`text-[#f3cb65] font-mono text-xs sm:text-sm select-none mr-1.5 shrink-0`,children:`[`}),(0,j.jsx)(`input`,{ref:G,type:`text`,value:R,onChange:e=>z(e.target.value),onFocus:()=>V(!0),onBlur:()=>V(!1),disabled:r||n,placeholder:`Speak with ${e||`Princess Aurelia`}...`,className:`flex-1 bg-transparent border-none text-[#e2ecf7] placeholder-[#f3cb65]/70 font-mono text-xs sm:text-sm focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed`}),(0,j.jsx)(`span`,{className:`text-[#f3cb65] font-mono text-xs sm:text-sm select-none ml-1.5 shrink-0`,children:`]`})]}),(0,j.jsxs)(`button`,{type:`submit`,disabled:r||n||!R.trim(),className:`bg-[#34597b] hover:bg-[#3f6990] active:bg-[#2b4c6e] disabled:opacity-40 disabled:cursor-not-allowed border border-[#5c8cb5] hover:border-[#8db7dc] rounded px-3 sm:px-4 py-1 text-xs sm:text-sm font-mono font-bold text-white transition-all cursor-pointer shadow-md select-none shrink-0 flex items-center`,children:[(0,j.jsx)(`span`,{className:`text-[#f3cb65]`,children:`[`}),(0,j.jsx)(`span`,{className:`text-white px-1`,children:`Send`}),(0,j.jsx)(`span`,{className:`text-[#f3cb65]`,children:`]`})]})]})]})}function I({currentFloor:e,onClose:t}){let n=b(e),r=Math.min(100,Math.round(e/150*100));return(0,j.jsx)(`div`,{className:`absolute inset-0 z-50 bg-ink-black/40 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 select-none`,onClick:t,children:(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-xl p-4 sm:p-5 max-w-md w-full shadow-[6px_6px_0px_0px_#1E293B] flex flex-col gap-3.5`,onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(i,{className:`w-5 h-5 text-indigo-600`}),(0,j.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`Journey to the Big-O Spire`})]}),(0,j.jsx)(`button`,{type:`button`,onClick:t,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,j.jsx)(g,{className:`w-4 h-4`})})]}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-xs font-bold font-headline-md`,children:[(0,j.jsx)(`span`,{children:`Path Progress:`}),(0,j.jsxs)(`span`,{className:`font-arcade bg-indigo-100 text-indigo-900 px-2 py-0.5 rounded border border-indigo-300`,children:[e,` / 150 Leagues`]})]}),(0,j.jsx)(`div`,{className:`w-full bg-slate-200 h-4 border-[2px] border-ink-black rounded-full overflow-hidden p-0.5`,children:(0,j.jsx)(`div`,{className:`bg-gradient-to-r from-amber-400 via-yellow-400 to-emerald-400 h-full rounded-full transition-all duration-500`,style:{width:`${r}%`}})}),(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-trash-gray font-medium`,children:[(0,j.jsxs)(`span`,{children:[`Progress: `,(0,j.jsxs)(`strong`,{children:[r,`%`]})]}),(0,j.jsxs)(`span`,{children:[`Distance to Tower: `,(0,j.jsxs)(`strong`,{children:[Math.max(0,150-e),` leagues`]})]})]})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[2px] border-ink-black rounded-lg p-3 shadow-[2px_2px_0px_0px_#1E293B] flex flex-col gap-1`,children:[(0,j.jsx)(`div`,{className:`text-[10px] font-bold uppercase text-amber-700 tracking-wider`,children:`Current Realm:`}),(0,j.jsx)(`div`,{className:`font-bold text-xs text-ink-black`,children:n.title}),(0,j.jsx)(`p`,{className:`text-[11px] text-slate-600 m-0 leading-relaxed font-medium`,children:n.description}),(0,j.jsxs)(`div`,{className:`text-[10px] text-amber-900 bg-amber-50 p-1.5 rounded border border-amber-200 italic mt-1`,children:[`📜 `,n.bgLore]})]}),(0,j.jsx)(`div`,{className:`flex items-center justify-between gap-1 text-center`,children:[{floor:30,label:`Arrays`},{floor:60,label:`Pointers`},{floor:90,label:`Trees`},{floor:120,label:`Heaps`},{floor:150,label:`Spire`}].map(t=>{let n=e>=t.floor;return(0,j.jsxs)(`div`,{className:`flex-1 p-1.5 rounded border text-[10px] flex flex-col items-center ${n?`bg-emerald-100 border-emerald-600 text-emerald-900 font-bold`:`bg-slate-100 border-slate-300 text-slate-500`}`,children:[(0,j.jsx)(`span`,{children:n?`✓`:t.floor}),(0,j.jsx)(`span`,{className:`text-[9px] truncate w-full`,children:t.label})]},t.floor)})}),(0,j.jsx)(`div`,{className:`flex items-center justify-end border-t border-slate-200 pt-2 mt-1`,children:(0,j.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-1.5 bg-white hover:bg-slate-100 border-[1.5px] border-ink-black rounded font-bold text-xs text-ink-black cursor-pointer shadow-xs active:translate-y-0.5`,children:`Done`})})]})})}function L({unlockedLetters:e,spireChronicles:t,currentFloor:n,heroCodex:r,episodicEvents:i,recentToolTelemetry:s,onRemoveCodexItem:c,onClose:d}){let[m,h]=(0,O.useState)(`letters`),[b,S]=(0,O.useState)(e[e.length-1]||null);return(0,j.jsx)(`div`,{className:`absolute inset-0 z-50 bg-ink-black/50 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 select-none`,onClick:d,children:(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black rounded-xl max-w-lg w-full h-[85%] max-h-[560px] shadow-[6px_6px_0px_0px_#1E293B] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)(`div`,{className:`bg-white border-b-[2px] border-ink-black px-4 py-2.5 flex items-center justify-between shrink-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(a,{className:`w-5 h-5 text-amber-700`}),(0,j.jsx)(`h4`,{className:`font-headline-md font-bold text-sm text-ink-black m-0`,children:`The Royal Satchel`})]}),(0,j.jsx)(`button`,{type:`button`,onClick:d,className:`p-1 hover:bg-slate-200 rounded text-slate-700 cursor-pointer`,title:`Close`,children:(0,j.jsx)(g,{className:`w-4 h-4`})})]}),(0,j.jsxs)(`div`,{className:`flex border-b-2 border-ink-black bg-amber-100/70 shrink-0`,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>h(`letters`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer border-r border-ink-black/20 ${m===`letters`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,j.jsx)(a,{className:`w-3.5 h-3.5`}),(0,j.jsxs)(`span`,{children:[`Missives (`,e.length,`/5)`]})]}),(0,j.jsxs)(`button`,{type:`button`,onClick:()=>h(`diary`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer border-r border-ink-black/20 ${m===`diary`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,j.jsx)(l,{className:`w-3.5 h-3.5`}),(0,j.jsxs)(`span`,{children:[`Chronicles (`,t.length,`)`]})]}),(0,j.jsxs)(`button`,{type:`button`,onClick:()=>h(`codex`),className:`flex-1 py-2 text-xs font-bold font-headline-md flex items-center justify-center gap-1.5 transition-colors cursor-pointer ${m===`codex`?`bg-[#FFFDF0] text-amber-950 border-b-2 border-b-[#FFFDF0] -mb-[2px]`:`text-slate-600 hover:bg-amber-200/50`}`,children:[(0,j.jsx)(y,{className:`w-3.5 h-3.5 text-amber-700`}),(0,j.jsx)(`span`,{children:`Codex`})]})]}),(0,j.jsxs)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-3 min-h-0`,children:[m===`letters`&&(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1`,children:[(0,j.jsx)(`div`,{className:`flex items-center gap-1.5 overflow-x-auto pb-1`,children:[30,60,90,120,150].map(e=>{let t=x[e],r=n>=e,i=b?.floor===e;return(0,j.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&S(t),className:`px-3 py-1 rounded-full text-[11px] font-bold border-[1.5px] border-ink-black flex items-center gap-1 shrink-0 transition-all cursor-pointer ${r?i?`bg-[#FFE24C] text-ink-black shadow-[1.5px_1.5px_0px_0px_#1E293B]`:`bg-white hover:bg-amber-100 text-slate-800`:`opacity-40 bg-slate-200 text-slate-500 cursor-not-allowed`}`,children:[r?(0,j.jsx)(`span`,{children:`📜`}):(0,j.jsx)(o,{className:`w-3 h-3`}),(0,j.jsxs)(`span`,{children:[`League `,e]})]},e)})}),b?(0,j.jsxs)(`div`,{className:`bg-[#FFF9E6] border-[2px] border-amber-900/40 rounded-lg p-4 shadow-sm flex-1 overflow-y-auto custom-scrollbar flex flex-col select-text`,children:[(0,j.jsxs)(`div`,{className:`border-b border-amber-800/20 pb-2 mb-3 flex items-center justify-between`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`text-[10px] font-bold text-amber-800 uppercase tracking-wider`,children:[b.chapterTitle,` • League `,b.floor]}),(0,j.jsx)(`h5`,{className:`font-headline-md font-bold text-sm text-amber-950 m-0`,children:b.title})]}),(0,j.jsx)(`span`,{className:`text-xl`,children:`🪶`})]}),(0,j.jsx)(`p`,{className:`text-xs sm:text-[13px] text-amber-950 font-serif leading-relaxed whitespace-pre-wrap flex-1 italic`,children:b.letterText})]}):(0,j.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,j.jsx)(o,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:`Conquer 30 LeetCode problems along the path to receive your first Royal Missive from Aurelia.`})]})]}),m===`diary`&&(0,j.jsx)(`div`,{className:`flex flex-col gap-2.5 flex-1`,children:t.length>0?t.map(e=>(0,j.jsxs)(`div`,{className:`p-3 bg-white border-[1.5px] border-ink-black rounded-lg shadow-xs flex flex-col gap-1 select-text`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-amber-800 font-bold border-b border-slate-100 pb-1`,children:[(0,j.jsxs)(`span`,{children:[`League `,e.floor,` along the Path`]}),(0,j.jsx)(`span`,{children:new Date(e.timestamp).toLocaleDateString()})]}),(0,j.jsxs)(`p`,{className:`text-xs text-ink-black font-medium leading-relaxed m-0 italic font-serif`,children:[`“`,e.text,`”`]})]},e.id)):(0,j.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center p-6 text-slate-500`,children:[(0,j.jsx)(l,{className:`w-8 h-8 mb-2 text-slate-400`}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:`Aurelia records entries in her Spire Chronicles autonomously as you chat, rest, and cross chapter milestones.`})]})}),m===`codex`&&(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 flex-1 select-text`,children:[(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1.5`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,j.jsx)(y,{className:`w-4 h-4 text-amber-600`}),(0,j.jsx)(`h5`,{className:`font-headline-md font-bold text-xs text-ink-black m-0`,children:`Hero Codex (MemGPT & Mem0 Core Memory)`})]}),(0,j.jsx)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:`Cognitive Sync`})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 text-xs`,children:[(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Hero Alias`}),(0,j.jsx)(`span`,{className:`font-bold text-ink-black text-xs`,children:r?.heroName||`Champion`})]}),(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Target Goal`}),(0,j.jsx)(`span`,{className:`font-bold text-amber-900 text-xs`,children:r?.targetGoal||`None shared yet (mention to Aurelia!)`})]})]}),r?.preferredLanguage&&(0,j.jsxs)(`div`,{className:`bg-[#FFFDF0] border border-amber-900/20 rounded p-2 text-xs`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Weapon of Choice (Language)`}),(0,j.jsx)(`span`,{className:`font-bold text-ink-black`,children:r.preferredLanguage})]})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-emerald-800`,children:[(0,j.jsx)(p,{className:`w-3.5 h-3.5`}),(0,j.jsxs)(`span`,{children:[`Mastered Patterns (`,r?.strengths?.length||0,`)`]})]}),r?.strengths&&r.strengths.length>0?(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.strengths.map(e=>(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-emerald-50 text-emerald-800 border border-emerald-300`,children:[e,c&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>c(`strengths`,e),className:`hover:text-red-600 ml-0.5 cursor-pointer`,title:`Forget strength`,children:(0,j.jsx)(g,{className:`w-3 h-3`})})]},e))}):(0,j.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia will note topics you conquer during your practice.`})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-rose-800`,children:[(0,j.jsx)(v,{className:`w-3.5 h-3.5`}),(0,j.jsxs)(`span`,{children:[`Nemesis Patterns (`,r?.nemesisPatterns?.length||0,`)`]})]}),r?.nemesisPatterns&&r.nemesisPatterns.length>0?(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.nemesisPatterns.map(e=>(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-bold bg-rose-50 text-rose-800 border border-rose-300`,children:[e,c&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>c(`nemesisPatterns`,e),className:`hover:text-red-700 ml-0.5 cursor-pointer`,title:`Forget nemesis`,children:(0,j.jsx)(g,{className:`w-3 h-3`})})]},e))}):(0,j.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Aurelia tracks patterns that give you trouble to help you prepare targeted drills.`})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsx)(`div`,{className:`text-xs font-bold text-slate-800`,children:(0,j.jsxs)(`span`,{children:[`Personal Notes & Shared Lore (`,r?.personalNotes?.length||0,`)`]})}),r?.personalNotes&&r.personalNotes.length>0?(0,j.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.personalNotes.map(e=>(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2 p-2 bg-slate-50 border border-slate-200 rounded text-[11px] text-slate-700`,children:[(0,j.jsxs)(`span`,{children:[`• `,e]}),c&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>c(`personalNotes`,e),className:`text-slate-400 hover:text-red-600 shrink-0 cursor-pointer p-0.5`,title:`Forget note`,children:(0,j.jsx)(_,{className:`w-3 h-3`})})]},e))}):(0,j.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`Share your background or routine with Aurelia and she will hold it in her memory.`})]}),i&&i.length>0&&(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,j.jsx)(`span`,{className:`text-xs font-bold text-slate-800`,children:`Episodic Memory Chain (EM-LLM)`}),(0,j.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[i.length,` events`]})]}),(0,j.jsx)(`div`,{className:`flex flex-col gap-2 max-h-40 overflow-y-auto custom-scrollbar`,children:i.slice(0,8).map(e=>(0,j.jsxs)(`div`,{className:`text-[11px] p-2 bg-[#FFFDF0] border border-amber-900/15 rounded flex flex-col gap-0.5`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(`span`,{className:`font-bold text-ink-black uppercase text-[9px] px-1.5 py-0.5 bg-amber-200/60 rounded`,children:e.eventType.replace(`_`,` `)}),(0,j.jsx)(`span`,{className:`text-[10px] text-slate-400`,children:new Date(e.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),(0,j.jsx)(`div`,{className:`font-bold text-slate-800 mt-0.5`,children:e.title}),(0,j.jsx)(`div`,{className:`text-slate-600 text-[10px]`,children:e.description})]},e.id))})]}),(0,j.jsxs)(`div`,{className:`bg-white border-[1.5px] border-ink-black rounded-lg p-3 shadow-xs flex flex-col gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between border-b border-slate-100 pb-1`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-bold text-indigo-900`,children:[(0,j.jsx)(u,{className:`w-3.5 h-3.5 text-amber-500`}),(0,j.jsx)(`span`,{children:`Autonomous Enchantment Telemetry`})]}),(0,j.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-mono`,children:[s?.length||0,` executed`]})]}),s&&s.length>0?(0,j.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-36 overflow-y-auto custom-scrollbar`,children:s.slice(0,10).map((e,t)=>(0,j.jsxs)(`div`,{className:`text-[11px] p-2 bg-indigo-50/50 border border-indigo-100 rounded flex items-center justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,j.jsxs)(`span`,{className:`font-bold text-indigo-950 font-mono text-[10px] truncate`,children:[e.tool_name,`()`]}),e.args&&Object.keys(e.args).length>0&&(0,j.jsx)(`span`,{className:`text-[9px] text-slate-500 truncate`,children:JSON.stringify(e.args).slice(0,50)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.execution_time_ms!==void 0&&(0,j.jsxs)(`span`,{className:`text-[9px] text-slate-400 flex items-center gap-0.5 font-mono`,children:[(0,j.jsx)(f,{className:`w-2.5 h-2.5`}),e.execution_time_ms,`ms`]}),(0,j.jsx)(`span`,{className:`px-1.5 py-0.2 text-[9px] font-bold rounded ${e.success?`bg-emerald-100 text-emerald-800`:`bg-rose-100 text-rose-800`}`,children:e.success?`SUCCESS`:`ERR`})]})]},t))}):(0,j.jsx)(`p`,{className:`text-[11px] text-slate-400 italic m-0`,children:`No autonomous enchantments executed yet in this session.`})]})]})]}),(0,j.jsx)(`div`,{className:`bg-white border-t border-slate-200 px-4 py-2 flex items-center justify-end shrink-0`,children:(0,j.jsx)(`button`,{type:`button`,onClick:d,className:`px-4 py-1.5 bg-white hover:bg-slate-100 border-[1.5px] border-ink-black rounded font-bold text-xs text-ink-black cursor-pointer shadow-xs active:translate-y-0.5`,children:`Close`})})]})})}var R=e({default:()=>z});function z({onClose:e,onMinimize:t,isActive:r=!0,onFocus:i,zIndex:a}){let o=E(),[s,c]=(0,O.useState)(w()),[l,u]=(0,O.useState)(!1),[d,f]=(0,O.useState)(!1),[p,h]=(0,O.useState)(!1);(0,O.useEffect)(()=>{C.syncWithBackend(),C.triggerProactiveGreeting()},[]);let _=(0,O.useCallback)(()=>{e?e():D.getState().closeWindow(`companion`)},[e]),v=(0,O.useCallback)(()=>{t?t():D.getState().minimizeWindow(`companion`)},[t]),y=(0,O.useCallback)(()=>{i?i():D.getState().setActiveWindow(`companion`)},[i]),b=(0,O.useCallback)(()=>{let e=!s;c(e),S(e)},[s]),x=(0,O.useCallback)(()=>{window.confirm(`Clear conversation transcript with Princess Aurelia?`)&&C.clearTranscript()},[]),T=(0,O.useCallback)(e=>{C.setIsTyping(e)},[]),k=(0,O.useMemo)(()=>[...o.transcript].reverse().find(e=>e.sender===`princess`)||o.transcript[0],[o.transcript]),A=`Welcome back to the Spire Tower Parlor. How is your day going today? Are you making progress, or could you use a hand?`,N=k?k.isStreaming?k.text:k.text||(o.isLoading?``:A):A,P=(0,O.useMemo)(()=>k?.choiceSuggestions&&k.choiceSuggestions.length>0?k.choiceSuggestions:[...o.transcript].reverse().find(e=>e.sender===`princess`&&e.choiceSuggestions&&e.choiceSuggestions.length>0)?.choiceSuggestions,[k,o.transcript]);return(0,j.jsxs)(`div`,{onClick:y,className:`fixed inset-x-0 top-0 bottom-[40px] select-none pointer-events-none overflow-hidden font-sans`,style:{zIndex:a??(r?40:30)},children:[(0,j.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-44 bg-gradient-to-t from-slate-950/35 via-slate-900/10 to-transparent pointer-events-none z-0`}),(0,j.jsxs)(`div`,{className:`relative w-full h-full flex flex-col justify-end pointer-events-none pb-2 sm:pb-3 px-2 sm:px-4 md:px-8`,children:[(0,j.jsxs)(`div`,{className:`relative w-full max-w-5xl lg:max-w-6xl mx-auto flex items-end justify-start pointer-events-none`,children:[(0,j.jsx)(`div`,{className:`relative z-30 shrink-0 pointer-events-auto -mr-6 sm:-mr-10 md:-mr-12 lg:-mr-14`,children:(0,j.jsx)(M,{emotion:o.activeEmotion,floor:o.currentFloor,rhythm:o.currentRhythm,activity:o.currentActivity,isLoading:o.isLoading,onClick:y})}),(0,j.jsx)(`div`,{className:`relative z-20 flex-1 min-w-0 pointer-events-auto mb-1`,children:(0,j.jsx)(F,{characterName:o.companionSettings.name||`Princess Aurelia`,emotion:o.activeEmotion,text:N,isStreaming:k?.isStreaming,isLoading:o.isLoading,choices:P,toolCalls:k?.toolCalls,onSelectChoice:e=>C.sendMessage(e),onSendMessage:e=>C.sendMessage(e),onTypingStatusChange:T,currentFloor:o.currentFloor,bondTier:o.bondTier,satchelCount:o.unlockedLetters.length,isMuted:s,onToggleMute:b,onOpenProgress:()=>u(!0),onOpenSatchel:()=>f(!0),onOpenHistory:()=>h(!0),onMinimize:v,onClose:_})})]}),(0,j.jsxs)(`div`,{className:`absolute bottom-1 right-3.5 pointer-events-none z-30 hidden md:flex flex-col items-center gap-0.5 opacity-65 select-none`,children:[(0,j.jsx)(`svg`,{className:`w-8 h-8 text-[#9cbcdb] drop-shadow-[0_0_6px_rgba(156,188,219,0.5)] rotate-6`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,j.jsx)(`path`,{d:`M12 2 C12 7.8 7.8 12 2 12 C7.8 12 12 16.2 12 22 C12 16.2 16.2 12 22 12 C16.2 12 12 7.8 12 2 Z`})}),(0,j.jsxs)(`div`,{className:`font-mono text-[9px] text-[#7ba4c8] tracking-tight leading-tight text-center`,children:[(0,j.jsx)(`div`,{children:`AlgoSpaced (Beta)`}),(0,j.jsx)(`div`,{children:`Build Jun24 preview`})]})]})]}),l&&(0,j.jsx)(`div`,{className:`pointer-events-auto`,children:(0,j.jsx)(I,{currentFloor:o.currentFloor,totalSolved:o.totalSolved,onClose:()=>u(!1)})}),d&&(0,j.jsx)(`div`,{className:`pointer-events-auto`,children:(0,j.jsx)(L,{unlockedLetters:o.unlockedLetters,spireChronicles:o.spireChronicles,currentFloor:o.currentFloor,heroCodex:o.heroCodex,episodicEvents:o.episodicEvents,recentToolTelemetry:o.recentToolTelemetry,onRemoveCodexItem:C.removeCodexItem,onClose:()=>f(!1)})}),p&&(0,j.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/60 backdrop-blur-xs flex items-center justify-center p-3 sm:p-4 animate-in fade-in duration-200 pointer-events-auto`,onClick:()=>h(!1),children:(0,j.jsxs)(`div`,{className:`bg-[#142335] border-[3px] border-[#5a80a2] rounded-xl max-w-lg w-full h-[80%] max-h-[520px] shadow-[0_16px_40px_rgba(0,0,0,0.85)] flex flex-col overflow-hidden text-white`,onClick:e=>e.stopPropagation(),style:{boxShadow:`inset 0 0 0 1px #0a1420, inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 16px 40px rgba(0, 0, 0, 0.85)`},children:[(0,j.jsxs)(`div`,{className:`bg-[#101b2a] border-b border-[#304f6f] px-4 py-2.5 flex items-center justify-between shrink-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(m,{className:`w-4 h-4 text-[#67b1ec]`}),(0,j.jsxs)(`h4`,{className:`font-mono font-bold text-xs sm:text-sm text-[#e6f0fa] m-0`,children:[`Dialogue Transcript (`,o.transcript.length,` turns)`]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsxs)(`button`,{type:`button`,onClick:x,className:`px-2 py-0.5 bg-rose-950/60 hover:bg-rose-900 border border-rose-700/60 rounded text-[11px] font-mono font-bold text-rose-300 hover:text-white flex items-center gap-1 cursor-pointer mr-1 transition-colors`,title:`Clear Chat History`,children:[(0,j.jsx)(n,{className:`w-3 h-3`}),(0,j.jsx)(`span`,{children:`Clear`})]}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`p-1 hover:bg-[#203a55] rounded text-[#8cb4db] hover:text-white cursor-pointer transition-colors`,title:`Close`,children:(0,j.jsx)(g,{className:`w-4 h-4`})})]})]}),(0,j.jsx)(`div`,{className:`flex-1 p-3 sm:p-4 overflow-y-auto custom-scrollbar flex flex-col gap-2.5 bg-[#0e1824]/90`,children:o.transcript.map((e,t)=>(0,j.jsxs)(`div`,{className:`p-2.5 rounded-lg border font-mono text-xs max-w-[90%] shadow-md ${e.sender===`princess`?`bg-[#182c42] border-[#3e6080] text-[#e6f0fa] self-start`:`bg-[#214365] border-[#5a8bb9] text-white self-end`}`,children:[(0,j.jsx)(`div`,{className:`text-[10px] font-bold mb-1 text-[#f6d267]`,children:e.sender===`princess`?o.companionSettings.name:`Hero`}),(0,j.jsx)(`p`,{className:`font-medium m-0 leading-relaxed whitespace-pre-wrap select-text`,children:e.text})]},e.id||t))})]})})]})}export{R as t};
algospaced-ui/dist/assets/{ProblemSpecPanel-CLbwqTwe.js → ProblemSpecPanel-BRW8UyO6.js} RENAMED
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,Bt as r,G as i,N as a,Q as ee,Rt as o,St as s,U as te,a as c,d as l,et as ne,f as u,ft as re,j as ie,o as ae,ot as oe,p as se,rt as d,xt as ce,y as f}from"./vendor-react-CIO8MTK1.js";import{u as p}from"./index-DnK6BACV.js";import{n as m,t as h}from"./MarkdownRenderer-BMZIn30p.js";import{n as g}from"./ReviewQueue-DmsrlLxn.js";var _=e(r(),1),v=o(),le=[`Arrays & Hashing`,`Two Pointers`,`Sliding Window`,`Stack`,`Binary Search`,`Linked List`,`Trees`,`Tries`,`Heap / Priority Queue`,`Backtracking`,`Graphs`,`Advanced Graphs`,`1-D Dynamic Programming`,`2-D Dynamic Programming`,`Greedy`,`Intervals`,`Math & Geometry`,`Bit Manipulation`];function y(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`sol-${crypto.randomUUID()}`:`sol-${Date.now()}`}var b=({leftTab:e,onSelectLeftTab:r,mobileView:o,isNarrow:b=!1,problem:x,parsed:S,userSolution:ue,officialSolution:de,effectiveReferenceCode:fe,copiedSnippet:C,onCopyText:w,saveRefError:T,aiSolutionLoading:E,aiSolutionError:D,onFetchAiSolution:O,explainLoading:k,explainError:A,explanationText:j,onExplainCode:pe,activeReview:M,onUpdateSolutions:N})=>{let[me,P]=(0,_.useState)(!1),[F,I]=(0,_.useState)(()=>x.id||x.name),[L,R]=(0,_.useState)(0),[z,B]=(0,_.useState)(!1),[V,H]=(0,_.useState)(null),[U,W]=(0,_.useState)({name:``,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!1}),[G,K]=(0,_.useState)(!1),[q,J]=(0,_.useState)(null),Y=x.id||x.name;F!==Y&&(I(Y),P(!1),R(0),B(!1),H(null),J(null));let X=g(x,de,ue),Z=L<X.length?L:0,Q=X[Z];(0,_.useEffect)(()=>{if(q){let e=setTimeout(()=>J(null),3500);return()=>clearTimeout(e)}},[q]);let he=async()=>{if(!U.name.trim()){J({type:`error`,message:`Solution name cannot be empty.`});return}if(!U.code.trim()){J({type:`error`,message:`Solution code cannot be empty.`});return}K(!0),J(null);try{let e;if(V)e=X.map(e=>e.id===V?{...e,name:U.name.trim(),pattern:U.pattern.trim()||`General Algorithm`,time_complexity:U.time_complexity.trim()||`O(N)`,space_complexity:U.space_complexity.trim()||`O(1)`,code:U.code,explanation:U.explanation.trim(),is_optimal:U.is_optimal}:U.is_optimal&&e.id!==V?{...e,is_optimal:!1}:e);else{let t={id:y(),name:U.name.trim(),pattern:U.pattern.trim()||`General Algorithm`,time_complexity:U.time_complexity.trim()||`O(N)`,space_complexity:U.space_complexity.trim()||`O(1)`,code:U.code,explanation:U.explanation.trim(),is_optimal:U.is_optimal||X.length===0};e=t.is_optimal?[...X.map(e=>({...e,is_optimal:!1})),t]:[...X,t]}let t=e.find(e=>e.is_optimal)||e[0];x.id&&await p(x.id,e,t?.time_complexity,t?.space_complexity,x),N?.(e),J({type:`success`,message:V?`Solution updated successfully!`:`New solution added to problem dossier!`}),B(!1),H(null),R(V?Z:e.length-1)}catch(e){let t=e instanceof Error?e.message:`Failed to save solution.`;J({type:`error`,message:t})}finally{K(!1)}},ge=async e=>{if(X.length<=1){J({type:`error`,message:`Problem must have at least one solution.`});return}if(window.confirm(`Are you sure you want to remove this solution?`)){K(!0);try{let t=X.filter(t=>t.id!==e);!t.some(e=>e.is_optimal)&&t.length>0&&(t[0].is_optimal=!0);let n=t.find(e=>e.is_optimal)||t[0];x.id&&await p(x.id,t,n?.time_complexity,n?.space_complexity,x),N?.(t),R(0),J({type:`success`,message:`Solution removed successfully.`})}catch(e){let t=e instanceof Error?e.message:`Failed to delete solution.`;J({type:`error`,message:t})}finally{K(!1)}}},$=e=>`cursor-pointer font-arcade text-[7.5px] min-[400px]:text-[8px] sm:text-[8.5px] transition-all flex items-center justify-center gap-1 sm:gap-1.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-ink-black select-none whitespace-nowrap shrink-0 ${e?`h-10 px-2 sm:px-2.5 bg-paper-white text-ink-black font-extrabold border-t-2 border-x-2 border-b-0 border-ink-black relative z-10 -mb-[2px] pb-[10px] shadow-[0_-2px_0_0_rgba(30,41,59,0.06)] after:content-[''] after:absolute after:-bottom-[2px] after:left-0 after:right-0 after:h-[2.5px] after:bg-paper-white after:z-10`:`h-9 px-2 sm:px-2.5 bg-[#e8e4da] text-slate-700 hover:bg-[#efece3] hover:text-ink-black font-bold border-2 border-ink-black relative z-0 mb-0`}`;return(0,v.jsxs)(`div`,{className:`w-full ${b?`flex flex-1`:`lg:w-[49%] flex`} flex-col bg-paper-white border-b-[3px] lg:border-b-0 ${b?``:`lg:border-r-[3px]`} border-ink-black overflow-hidden ${b&&o!==`spec`&&o!==`ref`?`hidden`:`flex`}`,children:[(0,v.jsxs)(`div`,{className:`shrink-0 bg-[#f4f1ea] border-b-2 border-ink-black px-1.5 sm:px-2.5 pt-2 flex items-end gap-1 relative z-10 overflow-x-auto no-scrollbar`,children:[(0,v.jsxs)(`button`,{onClick:()=>r(`spec`),className:$(e===`spec`),children:[(0,v.jsx)(ee,{className:`w-3 h-3 text-purple-700 shrink-0`}),(0,v.jsx)(`span`,{children:b?`SPEC`:`SPECIFICATIONS`})]}),(0,v.jsxs)(`button`,{onClick:()=>r(`ref`),className:$(e===`ref`),children:[(0,v.jsx)(oe,{className:`w-3 h-3 text-blue-700 shrink-0`}),(0,v.jsx)(`span`,{children:b?`SOL (${X.length})`:`SOLUTIONS (${X.length})`})]}),(0,v.jsxs)(`button`,{onClick:()=>r(`leitner`),className:$(e===`leitner`),children:[(0,v.jsx)(u,{className:`w-3 h-3 text-emerald-700 shrink-0`}),(0,v.jsx)(`span`,{className:`whitespace-nowrap`,children:b?`FSRS`:`FSRS STATS`})]})]}),(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto no-scrollbar p-4 sm:p-5 space-y-4`,children:[e===`spec`&&(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,v.jsx)(`div`,{children:(0,v.jsx)(`h2`,{className:`text-base sm:text-lg font-extrabold text-ink-black font-headline-md leading-tight m-0 select-text`,children:x.name||`Algorithm Problem`})}),S.description&&(0,v.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200`,children:[(0,v.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold mb-2 flex items-center gap-1`,children:[(0,v.jsx)(s,{className:`w-3 h-3 text-primary`}),`PROBLEM DESCRIPTION`]}),(0,v.jsx)(`div`,{className:`font-sans text-xs sm:text-[13px] text-slate-800 leading-relaxed space-y-2 font-medium`,children:S.description.split(`
2
- `).map((e,t)=>e.trim()?(0,v.jsx)(`p`,{className:`m-0 leading-relaxed whitespace-pre-wrap select-text`,children:m(e)},t):(0,v.jsx)(`div`,{className:`h-1.5`},t))})]}),S.examples.length>0&&(0,v.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200 space-y-2.5`,children:[(0,v.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,v.jsx)(c,{className:`w-3 h-3 text-amber-500`}),`EXAMPLES (`,S.examples.length,`)`]}),(0,v.jsx)(`div`,{className:`space-y-2.5`,children:S.examples.map((e,t)=>(0,v.jsxs)(`div`,{className:`p-3 bg-slate-50 border border-slate-200 space-y-2 text-xs`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-primary`,children:[`EXAMPLE `,t+1]}),e.input&&(0,v.jsxs)(`button`,{onClick:()=>w(e.input,`ex-${t}`),className:`px-2 py-0.5 bg-white hover:bg-slate-100 border border-ink-black text-[9px] font-arcade text-ink-black flex items-center gap-1 cursor-pointer`,title:`Copy input data`,children:[(0,v.jsx)(d,{className:`w-2.5 h-2.5`}),C===`ex-${t}`?`COPIED!`:`COPY`]})]}),e.input&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`span`,{className:`text-[9px] font-arcade text-trash-gray font-bold uppercase block`,children:`Input:`}),(0,v.jsx)(`div`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono p-2 border border-ink-black text-[11px] break-all select-text`,children:e.input})]}),e.output&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`span`,{className:`text-[9px] font-arcade text-trash-gray font-bold uppercase block`,children:`Output:`}),(0,v.jsx)(`div`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono p-2 border border-ink-black text-[11px] break-all select-text`,children:e.output})]}),e.explanation&&(0,v.jsxs)(`div`,{className:`text-[11px] font-sans text-slate-600 bg-white p-2 border border-slate-200`,children:[(0,v.jsx)(`span`,{className:`font-bold text-slate-700`,children:`Explanation: `}),m(e.explanation)]})]},t))})]}),S.constraints.length>0&&(0,v.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200`,children:[(0,v.jsx)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold mb-2`,children:`CONSTRAINTS`}),(0,v.jsx)(`ul`,{className:`space-y-1.5 list-none m-0 p-0`,children:S.constraints.map((e,t)=>(0,v.jsxs)(`li`,{className:`flex items-start gap-2 text-xs`,children:[(0,v.jsx)(`span`,{className:`text-primary font-bold select-none`,children:`•`}),(0,v.jsx)(`code`,{className:`bg-slate-100 text-ink-black font-code-mono px-2 py-0.5 border border-slate-300 text-[11px] select-text`,children:e})]},t))})]})]}),me?(0,v.jsxs)(`div`,{className:`p-3 bg-amber-50 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex flex-wrap items-center justify-between gap-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,v.jsx)(c,{className:`w-4 h-4 text-amber-600 shrink-0`}),(0,v.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black tracking-wide uppercase`,children:`OPTIMAL TARGET:`}),(0,v.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-2 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`T: `,x.optimal_time||`O(N)`]}),(0,v.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-2 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`S: `,x.optimal_space||`O(1)`]})]}),(0,v.jsxs)(`button`,{type:`button`,onClick:()=>P(!1),className:`px-2 py-0.5 bg-white hover:bg-slate-100 border border-ink-black font-arcade text-[8px] text-trash-gray hover:text-ink-black cursor-pointer flex items-center gap-1`,title:`Conceal target complexity`,children:[(0,v.jsx)(ne,{className:`w-2.5 h-2.5`}),(0,v.jsx)(`span`,{children:`HIDE`})]})]}):(0,v.jsxs)(`div`,{className:`p-3 bg-amber-50/70 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex items-center justify-between gap-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(te,{className:`w-4 h-4 text-amber-700 shrink-0`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black tracking-wide uppercase block`,children:`OPTIMAL COMPLEXITY TARGET`}),(0,v.jsx)(`span`,{className:`text-[10px] font-sans text-slate-600 font-semibold`,children:`Hidden to test active recall before coding`})]})]}),(0,v.jsxs)(`button`,{type:`button`,onClick:()=>P(!0),className:`px-2.5 py-1 bg-white hover:bg-amber-100 border-2 border-ink-black font-arcade text-[8.5px] font-bold text-ink-black shadow-[1.5px_1.5px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center gap-1.5 shrink-0`,title:`Click to reveal target time and space complexity`,children:[(0,v.jsx)(t,{className:`w-3 h-3 text-amber-700`}),(0,v.jsx)(`span`,{children:`REVEAL TARGET`})]})]})]}),e===`ref`&&(0,v.jsxs)(`div`,{className:`space-y-4`,children:[q&&(0,v.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black text-xs font-bold flex items-center justify-between shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${q.type===`success`?`bg-emerald-100 text-emerald-900 border-emerald-700`:`bg-rose-100 text-rose-900 border-rose-700`}`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[q.type===`success`?(0,v.jsx)(re,{className:`w-4 h-4 text-emerald-700 shrink-0`}):(0,v.jsx)(l,{className:`w-4 h-4 text-rose-700 shrink-0`}),(0,v.jsx)(`span`,{children:q.message})]}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>J(null),className:`text-slate-600 hover:text-ink-black cursor-pointer`,children:(0,v.jsx)(ae,{className:`w-3.5 h-3.5`})})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1 p-1 bg-slate-200/90 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] overflow-x-auto no-scrollbar`,children:[X.map((e,t)=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{R(t),B(!1),H(null)},className:`py-1 px-2 rounded-full font-arcade text-[8px] font-bold flex items-center justify-center gap-1 border-2 border-ink-black transition-all cursor-pointer whitespace-nowrap shrink-0 ${Z===t&&!z&&!V?`bg-sky-600 text-white shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] -translate-y-0.5`:`bg-white text-ink-black hover:bg-sky-50 shadow-none`}`,title:e.name?`${e.name} (${e.pattern||`Algorithm`})`:`Solution ${t+1}`,children:[e.is_optimal?(0,v.jsx)(f,{className:`w-3 h-3 text-amber-300`}):(0,v.jsx)(s,{className:`w-3 h-3`}),(0,v.jsx)(`span`,{children:`Sol ${t+1}`}),e.is_optimal&&(0,v.jsx)(`span`,{className:`text-[6.5px] px-1 py-0.2 bg-amber-300 text-ink-black border border-ink-black font-extrabold rounded-full tracking-tight`,children:`OPTIMAL`})]},e.id||t)),(0,v.jsx)(`button`,{type:`button`,onClick:()=>{B(!0),H(null),W({name:`Method ${X.length+1}`,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!1})},className:`h-6 w-6 rounded-full font-arcade text-[9px] font-bold flex items-center justify-center border-2 border-ink-black cursor-pointer shrink-0 active:translate-y-0.5 transition-all shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] ${z?`bg-emerald-600 text-white`:`bg-amber-300 text-ink-black hover:bg-amber-200`}`,title:`Add another solution / method for this problem`,"aria-label":`Add Solution`,children:(0,v.jsx)(ie,{className:`w-3 h-3 stroke-[2.5]`})})]}),z||V?(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between pb-2 border-b-2 border-dashed border-ink-black`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(a,{className:`w-4 h-4 text-purple-700`}),(0,v.jsx)(`span`,{className:`font-arcade text-[10px] font-bold text-ink-black uppercase`,children:V?`EDIT SOLUTION`:`ADD NEW SOLUTION / METHOD`})]}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>{B(!1),H(null)},className:`text-xs font-arcade text-trash-gray hover:text-rose-600 cursor-pointer font-bold`,children:`CANCEL`})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Solution / Method Name`}),(0,v.jsx)(`input`,{type:`text`,value:U.name,onChange:e=>W({...U,name:e.target.value}),placeholder:`e.g. One-Pass Hash Map, Two Pointers`,className:`w-full p-2 border-2 border-ink-black text-xs font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Pattern / Strategy`}),(0,v.jsx)(`select`,{value:U.pattern,onChange:e=>W({...U,pattern:e.target.value}),className:`w-full p-2 border-2 border-ink-black text-xs font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`,children:le.map(e=>(0,v.jsx)(`option`,{value:e,children:e},e))})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Time Complexity`}),(0,v.jsx)(`input`,{type:`text`,value:U.time_complexity,onChange:e=>W({...U,time_complexity:e.target.value}),placeholder:`e.g. O(N), O(N log N), O(N^2)`,className:`w-full p-2 border-2 border-ink-black text-xs font-code-mono font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Space Complexity`}),(0,v.jsx)(`input`,{type:`text`,value:U.space_complexity,onChange:e=>W({...U,space_complexity:e.target.value}),placeholder:`e.g. O(1), O(N)`,className:`w-full p-2 border-2 border-ink-black text-xs font-code-mono font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase`,children:`Python Reference Code`}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>W({...U,code:fe}),className:`text-[8.5px] font-arcade text-sky-700 hover:underline cursor-pointer`,children:`Paste Current Code`})]}),(0,v.jsx)(`textarea`,{rows:8,value:U.code,onChange:e=>W({...U,code:e.target.value}),placeholder:`class Solution:
3
  def solve(self, nums):
4
- ...`,className:`w-full p-2.5 border-2 border-ink-black bg-[#1E293B] text-[#4ADE80] font-code-mono text-xs focus:outline-none no-scrollbar`})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Intuition / How to Solve (Optional)`}),(0,v.jsx)(`textarea`,{rows:3,value:U.explanation,onChange:e=>W({...U,explanation:e.target.value}),placeholder:`Key insight, trade-offs, and state tracking notes...`,className:`w-full p-2 border-2 border-ink-black text-xs bg-[#fdf8e1] focus:outline-none focus:bg-white no-scrollbar`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`input`,{type:`checkbox`,id:`is_optimal_solution`,checked:U.is_optimal,onChange:e=>W({...U,is_optimal:e.target.checked}),className:`w-4 h-4 border-2 border-ink-black rounded cursor-pointer accent-emerald-600`}),(0,v.jsx)(`label`,{htmlFor:`is_optimal_solution`,className:`font-arcade text-[9px] font-bold text-ink-black cursor-pointer`,children:`SET AS OPTIMAL / PRIMARY APPROACH FOR THIS PROBLEM`})]}),(0,v.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t-2 border-dashed border-ink-black`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>{B(!1),H(null)},className:`px-3 py-1.5 bg-slate-100 hover:bg-slate-200 border-2 border-ink-black font-arcade text-[9px] font-bold text-ink-black cursor-pointer`,children:`CANCEL`}),(0,v.jsxs)(`button`,{type:`button`,disabled:G,onClick:he,className:`px-4 py-1.5 bg-emerald-500 hover:bg-emerald-400 border-2 border-ink-black font-arcade text-[9px] font-bold text-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer disabled:opacity-50 flex items-center gap-1.5`,children:[G&&(0,v.jsx)(n,{className:`w-3 h-3 animate-spin`}),(0,v.jsx)(`span`,{children:V?`UPDATE SOLUTION`:`SAVE SOLUTION`})]})]})]}):Q?(0,v.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pb-3 border-b border-slate-200`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap min-w-0`,children:[(0,v.jsx)(`h3`,{className:`font-headline-md font-extrabold text-sm sm:text-base text-ink-black m-0 select-text break-words`,children:Q.name||`Solution ${Z+1}`}),Q.is_optimal&&(0,v.jsx)(`span`,{className:`px-2 py-0.5 bg-amber-300 border border-ink-black font-arcade text-[8px] font-bold text-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] shrink-0`,children:`★ OPTIMAL`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap sm:ml-auto`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray uppercase`,children:`Pattern:`}),(0,v.jsx)(`span`,{className:`px-2 py-0.5 bg-purple-50 border border-purple-300 font-arcade text-[8.5px] text-purple-800 font-bold`,children:Q.pattern||`General Algorithm`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,v.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-1.5 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`T: `,Q.time_complexity||`O(N)`]}),(0,v.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-1.5 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`S: `,Q.space_complexity||`O(1)`]})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{H(Q.id),B(!1),W({name:Q.name,pattern:Q.pattern,time_complexity:Q.time_complexity,space_complexity:Q.space_complexity,code:Q.code,explanation:Q.explanation||``,is_optimal:!!Q.is_optimal})},className:`px-2 py-1 bg-white hover:bg-slate-100 border border-ink-black text-ink-black font-arcade text-[8px] font-bold flex items-center gap-1 cursor-pointer`,title:`Edit this solution`,children:[(0,v.jsx)(a,{className:`w-3 h-3 text-slate-700`}),(0,v.jsx)(`span`,{className:`hidden sm:inline`,children:`EDIT`})]}),X.length>1&&(0,v.jsx)(`button`,{type:`button`,onClick:()=>ge(Q.id),className:`px-1.5 py-1 bg-white hover:bg-rose-50 border border-ink-black text-rose-700 font-arcade text-[8px] font-bold flex items-center gap-1 cursor-pointer`,title:`Delete this solution`,children:(0,v.jsx)(se,{className:`w-3 h-3`})})]})]})]}),Q.code?(0,v.jsxs)(`div`,{className:`border border-ink-black bg-[#0f172a] overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`bg-[#1e293b] px-2.5 sm:px-3 py-1.5 border-b border-ink-black flex items-center justify-between gap-1.5 flex-wrap min-w-0`,children:[(0,v.jsx)(`span`,{className:`font-arcade text-[8px] text-slate-300 font-bold uppercase truncate min-w-0 flex-1`,children:b?`PYTHON 3`:`PYTHON 3 IMPLEMENTATION`}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>pe(Q.code,Q.pattern,Q.time_complexity,Q.space_complexity),disabled:k,className:`px-2 py-0.5 bg-purple-50 hover:bg-purple-100 text-purple-800 border border-ink-black text-[9px] font-arcade font-bold flex items-center gap-1 cursor-pointer shrink-0 disabled:opacity-50 active:translate-y-0.5 transition-all`,title:`Explain this solution with AI`,children:[k?(0,v.jsx)(n,{className:`w-2.5 h-2.5 animate-spin text-purple-700`}):(0,v.jsx)(f,{className:`w-2.5 h-2.5 text-purple-600`}),(0,v.jsx)(`span`,{children:`Explain✦`})]}),(0,v.jsxs)(`button`,{onClick:()=>w(Q.code,`sol-${Q.id}`),className:`px-2 py-0.5 bg-white hover:bg-slate-100 text-ink-black border border-ink-black text-[9px] font-arcade font-bold flex items-center gap-1 cursor-pointer shrink-0 active:translate-y-0.5 transition-all`,title:`Copy solution code`,children:[(0,v.jsx)(d,{className:`w-2.5 h-2.5`}),C===`sol-${Q.id}`?`COPIED!`:`COPY`]})]})]}),(0,v.jsx)(`div`,{className:`p-3 text-xs overflow-x-auto max-h-80 no-scrollbar`,children:(0,v.jsx)(`pre`,{className:`font-code-mono text-[#4ADE80] text-[11px] leading-relaxed select-text m-0`,children:(0,v.jsx)(`code`,{children:Q.code})})})]}):(0,v.jsxs)(`div`,{className:`p-4 bg-amber-50 border border-dashed border-amber-300 text-center space-y-3`,children:[(0,v.jsx)(`p`,{className:`text-xs font-sans text-stone-700`,children:`No code implementation archived for this solution yet.`}),(0,v.jsx)(`button`,{onClick:O,disabled:E,className:`px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer inline-flex items-center gap-2 disabled:opacity-50`,children:E?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(n,{className:`w-3.5 h-3.5 animate-spin`}),(0,v.jsx)(`span`,{children:`Generating solution...`})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(f,{className:`w-3.5 h-3.5 text-amber-300`}),(0,v.jsx)(`span`,{children:`Generate solution`})]})}),D&&(0,v.jsx)(`div`,{className:`text-xs text-rose-600 font-medium`,children:D})]}),Q.explanation&&(0,v.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200 space-y-1.5 select-text`,children:[(0,v.jsx)(`span`,{className:`font-arcade text-[8.5px] text-trash-gray uppercase font-bold block`,children:`SOLUTION INTUITION & STRATEGY:`}),(0,v.jsx)(h,{content:Q.explanation})]})]}),Q.code&&(0,v.jsxs)(`div`,{className:`space-y-3`,children:[A&&(0,v.jsx)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold`,children:A}),j&&(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-2 select-text`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 pb-2 border-b-2 border-dashed border-ink-black`,children:[(0,v.jsx)(ce,{className:`w-4 h-4 text-purple-600`}),(0,v.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:[`Gemini Code Breakdown (`,Q.name,`)`]})]}),(0,v.jsx)(`div`,{className:`max-h-96 overflow-y-auto no-scrollbar pt-1 select-text`,children:(0,v.jsx)(h,{content:j})})]})]})]}):null,T&&(0,v.jsxs)(`div`,{className:`p-2.5 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-bold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(244,63,94,1)]`,children:[(0,v.jsx)(l,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,v.jsx)(`div`,{className:`flex-1`,children:T})]})]}),e===`leitner`&&(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,v.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,v.jsx)(i,{className:`w-3 h-3 text-purple-600`}),`SPACED REPETITION PROGRESSION`]}),(0,v.jsx)(`div`,{className:`space-y-2`,children:[{state:0,label:`NEW`,color:`#3b82f6`},{state:1,label:`LEARNING`,color:`#f59e0b`},{state:2,label:`REVIEW`,color:`#10b981`},{state:3,label:`RELEARNING`,color:`#ef4444`}].map(e=>{let t=(M.fsrs_state??0)===e.state;return(0,v.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black flex items-center justify-between transition-all ${t?`bg-amber-100 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] translate-x-1 font-bold`:`bg-slate-50 opacity-70`}`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`w-5 h-5 border border-ink-black flex items-center justify-center font-arcade text-[9px] text-white font-bold`,style:{backgroundColor:e.color},children:e.state}),(0,v.jsx)(`span`,{className:`font-arcade text-[9px] text-ink-black`,children:e.label})]}),(0,v.jsx)(`div`,{className:`flex items-center gap-2`,children:t&&(0,v.jsx)(`span`,{className:`px-1.5 py-0.5 bg-emerald-500 text-white font-arcade text-[7px] border border-ink-black font-bold`,children:`CURRENT`})})]},e.state)})})]}),(0,v.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,v.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,v.jsx)(u,{className:`w-3 h-3 text-emerald-600`}),`PERFORMANCE METRICS`]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`p-2.5 bg-slate-50 border border-ink-black`,children:[(0,v.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase`,children:`Total Reviews`}),(0,v.jsx)(`span`,{className:`font-headline-md text-lg font-bold text-ink-black`,children:M.total_attempts||0})]}),(0,v.jsxs)(`div`,{className:`p-2.5 bg-slate-50 border border-ink-black`,children:[(0,v.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase`,children:`Correct Recall`}),(0,v.jsx)(`span`,{className:`font-headline-md text-lg font-bold text-emerald-600`,children:M.times_correct||0})]})]}),(0,v.jsxs)(`div`,{className:`text-xs font-sans text-slate-600 pt-1`,children:[`Next Due Date:`,` `,(0,v.jsx)(`span`,{className:`font-code-mono font-bold text-ink-black`,children:M.next_review?new Date(M.next_review).toLocaleDateString():`Today`})]})]})]})]})]})};export{b as ProblemSpecPanel};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,F as n,G as ee,Ht as r,M as i,N as te,Tt as a,a as o,d as s,f as c,ht as ne,lt as re,nt as ie,o as ae,ot as l,p as oe,q as se,rt as u,tt as ce,wt as le,x as d}from"./vendor-react-hnaVBnLv.js";import{u as f}from"./index-DVWZ15xt.js";import{n as p,t as m}from"./MarkdownRenderer-D8UdFpnD.js";import{n as h}from"./ReviewQueue-CltGWQpb.js";var g=e(r(),1),_=t(),ue=[`Arrays & Hashing`,`Two Pointers`,`Sliding Window`,`Stack`,`Binary Search`,`Linked List`,`Trees`,`Tries`,`Heap / Priority Queue`,`Backtracking`,`Graphs`,`Advanced Graphs`,`1-D Dynamic Programming`,`2-D Dynamic Programming`,`Greedy`,`Intervals`,`Math & Geometry`,`Bit Manipulation`];function v(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`sol-${crypto.randomUUID()}`:`sol-${Date.now()}`}var y=({leftTab:e,onSelectLeftTab:t,mobileView:r,isNarrow:y=!1,problem:b,parsed:x,userSolution:S,officialSolution:C,effectiveReferenceCode:de,copiedSnippet:w,onCopyText:T,saveRefError:E,aiSolutionLoading:D,aiSolutionError:O,onFetchAiSolution:fe,explainLoading:k,explainError:A,explanationText:j,onExplainCode:pe,activeReview:M,onUpdateSolutions:N})=>{let[me,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(()=>b.id||b.name),[L,R]=(0,g.useState)(0),[z,B]=(0,g.useState)(!1),[V,H]=(0,g.useState)(null),[U,W]=(0,g.useState)({name:``,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!1}),[G,K]=(0,g.useState)(!1),[q,J]=(0,g.useState)(null),Y=b.id||b.name;F!==Y&&(I(Y),P(!1),R(0),B(!1),H(null),J(null));let X=h(b,C,S),Z=L<X.length?L:0,Q=X[Z];(0,g.useEffect)(()=>{if(q){let e=setTimeout(()=>J(null),3500);return()=>clearTimeout(e)}},[q]);let he=async()=>{if(!U.name.trim()){J({type:`error`,message:`Solution name cannot be empty.`});return}if(!U.code.trim()){J({type:`error`,message:`Solution code cannot be empty.`});return}K(!0),J(null);try{let e;if(V)e=X.map(e=>e.id===V?{...e,name:U.name.trim(),pattern:U.pattern.trim()||`General Algorithm`,time_complexity:U.time_complexity.trim()||`O(N)`,space_complexity:U.space_complexity.trim()||`O(1)`,code:U.code,explanation:U.explanation.trim(),is_optimal:U.is_optimal}:U.is_optimal&&e.id!==V?{...e,is_optimal:!1}:e);else{let t={id:v(),name:U.name.trim(),pattern:U.pattern.trim()||`General Algorithm`,time_complexity:U.time_complexity.trim()||`O(N)`,space_complexity:U.space_complexity.trim()||`O(1)`,code:U.code,explanation:U.explanation.trim(),is_optimal:U.is_optimal||X.length===0};e=t.is_optimal?[...X.map(e=>({...e,is_optimal:!1})),t]:[...X,t]}let t=e.find(e=>e.is_optimal)||e[0];b.id&&await f(b.id,e,t?.time_complexity,t?.space_complexity,b),N?.(e),J({type:`success`,message:V?`Solution updated successfully!`:`New solution added to problem dossier!`}),B(!1),H(null),R(V?Z:e.length-1)}catch(e){let t=e instanceof Error?e.message:`Failed to save solution.`;J({type:`error`,message:t})}finally{K(!1)}},ge=async e=>{if(X.length<=1){J({type:`error`,message:`Problem must have at least one solution.`});return}if(window.confirm(`Are you sure you want to remove this solution?`)){K(!0);try{let t=X.filter(t=>t.id!==e);!t.some(e=>e.is_optimal)&&t.length>0&&(t[0].is_optimal=!0);let n=t.find(e=>e.is_optimal)||t[0];b.id&&await f(b.id,t,n?.time_complexity,n?.space_complexity,b),N?.(t),R(0),J({type:`success`,message:`Solution removed successfully.`})}catch(e){let t=e instanceof Error?e.message:`Failed to delete solution.`;J({type:`error`,message:t})}finally{K(!1)}}},$=e=>`cursor-pointer font-arcade text-[7.5px] min-[400px]:text-[8px] sm:text-[8.5px] transition-all flex items-center justify-center gap-1 sm:gap-1.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-ink-black select-none whitespace-nowrap shrink-0 ${e?`h-10 px-2 sm:px-2.5 bg-paper-white text-ink-black font-extrabold border-t-2 border-x-2 border-b-0 border-ink-black relative z-10 -mb-[2px] pb-[10px] shadow-[0_-2px_0_0_rgba(30,41,59,0.06)] after:content-[''] after:absolute after:-bottom-[2px] after:left-0 after:right-0 after:h-[2.5px] after:bg-paper-white after:z-10`:`h-9 px-2 sm:px-2.5 bg-[#e8e4da] text-slate-700 hover:bg-[#efece3] hover:text-ink-black font-bold border-2 border-ink-black relative z-0 mb-0`}`;return(0,_.jsxs)(`div`,{className:`w-full ${y?`flex flex-1`:`lg:w-[49%] flex`} flex-col bg-paper-white border-b-[3px] lg:border-b-0 ${y?``:`lg:border-r-[3px]`} border-ink-black overflow-hidden ${y&&r!==`spec`&&r!==`ref`?`hidden`:`flex`}`,children:[(0,_.jsxs)(`div`,{className:`shrink-0 bg-[#f4f1ea] border-b-2 border-ink-black px-1.5 sm:px-2.5 pt-2 flex items-end gap-1 relative z-10 overflow-x-auto no-scrollbar`,children:[(0,_.jsxs)(`button`,{onClick:()=>t(`spec`),className:$(e===`spec`),children:[(0,_.jsx)(ce,{className:`w-3 h-3 text-purple-700 shrink-0`}),(0,_.jsx)(`span`,{children:y?`SPEC`:`SPECIFICATIONS`})]}),(0,_.jsxs)(`button`,{onClick:()=>t(`ref`),className:$(e===`ref`),children:[(0,_.jsx)(re,{className:`w-3 h-3 text-blue-700 shrink-0`}),(0,_.jsx)(`span`,{children:y?`SOL (${X.length})`:`SOLUTIONS (${X.length})`})]}),(0,_.jsxs)(`button`,{onClick:()=>t(`fsrs`),className:$(e===`fsrs`),children:[(0,_.jsx)(c,{className:`w-3 h-3 text-emerald-700 shrink-0`}),(0,_.jsx)(`span`,{className:`whitespace-nowrap`,children:y?`FSRS`:`FSRS STATS`})]})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto no-scrollbar p-4 sm:p-5 space-y-4`,children:[e===`spec`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,_.jsx)(`div`,{children:(0,_.jsx)(`h2`,{className:`text-base sm:text-lg font-extrabold text-ink-black font-headline-md leading-tight m-0 select-text`,children:b.name||`Algorithm Problem`})}),x.description&&(0,_.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200`,children:[(0,_.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold mb-2 flex items-center gap-1`,children:[(0,_.jsx)(a,{className:`w-3 h-3 text-primary`}),`PROBLEM DESCRIPTION`]}),(0,_.jsx)(`div`,{className:`font-sans text-xs sm:text-[13px] text-slate-800 leading-relaxed space-y-2 font-medium`,children:x.description.split(`
2
+ `).map((e,t)=>e.trim()?(0,_.jsx)(`p`,{className:`m-0 leading-relaxed whitespace-pre-wrap select-text`,children:p(e)},t):(0,_.jsx)(`div`,{className:`h-1.5`},t))})]}),x.examples.length>0&&(0,_.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200 space-y-2.5`,children:[(0,_.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,_.jsx)(o,{className:`w-3 h-3 text-amber-500`}),`EXAMPLES (`,x.examples.length,`)`]}),(0,_.jsx)(`div`,{className:`space-y-2.5`,children:x.examples.map((e,t)=>(0,_.jsxs)(`div`,{className:`p-3 bg-slate-50 border border-slate-200 space-y-2 text-xs`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-primary`,children:[`EXAMPLE `,t+1]}),e.input&&(0,_.jsxs)(`button`,{onClick:()=>T(e.input,`ex-${t}`),className:`px-2 py-0.5 bg-white hover:bg-slate-100 border border-ink-black text-[9px] font-arcade text-ink-black flex items-center gap-1 cursor-pointer`,title:`Copy input data`,children:[(0,_.jsx)(l,{className:`w-2.5 h-2.5`}),w===`ex-${t}`?`COPIED!`:`COPY`]})]}),e.input&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`span`,{className:`text-[9px] font-arcade text-trash-gray font-bold uppercase block`,children:`Input:`}),(0,_.jsx)(`div`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono p-2 border border-ink-black text-[11px] break-all select-text`,children:e.input})]}),e.output&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`span`,{className:`text-[9px] font-arcade text-trash-gray font-bold uppercase block`,children:`Output:`}),(0,_.jsx)(`div`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono p-2 border border-ink-black text-[11px] break-all select-text`,children:e.output})]}),e.explanation&&(0,_.jsxs)(`div`,{className:`text-[11px] font-sans text-slate-600 bg-white p-2 border border-slate-200`,children:[(0,_.jsx)(`span`,{className:`font-bold text-slate-700`,children:`Explanation: `}),p(e.explanation)]})]},t))})]}),x.constraints.length>0&&(0,_.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200`,children:[(0,_.jsx)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold mb-2`,children:`CONSTRAINTS`}),(0,_.jsx)(`ul`,{className:`space-y-1.5 list-none m-0 p-0`,children:x.constraints.map((e,t)=>(0,_.jsxs)(`li`,{className:`flex items-start gap-2 text-xs`,children:[(0,_.jsx)(`span`,{className:`text-primary font-bold select-none`,children:`•`}),(0,_.jsx)(`code`,{className:`bg-slate-100 text-ink-black font-code-mono px-2 py-0.5 border border-slate-300 text-[11px] select-text`,children:e})]},t))})]})]}),me?(0,_.jsxs)(`div`,{className:`p-3 bg-amber-50 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex flex-wrap items-center justify-between gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,_.jsx)(o,{className:`w-4 h-4 text-amber-600 shrink-0`}),(0,_.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black tracking-wide uppercase`,children:`OPTIMAL TARGET:`}),(0,_.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-2 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`T: `,b.optimal_time||`O(N)`]}),(0,_.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-2 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`S: `,b.optimal_space||`O(1)`]})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>P(!1),className:`px-2 py-0.5 bg-white hover:bg-slate-100 border border-ink-black font-arcade text-[8px] text-trash-gray hover:text-ink-black cursor-pointer flex items-center gap-1`,title:`Conceal target complexity`,children:[(0,_.jsx)(u,{className:`w-2.5 h-2.5`}),(0,_.jsx)(`span`,{children:`HIDE`})]})]}):(0,_.jsxs)(`div`,{className:`p-3 bg-amber-50/70 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex items-center justify-between gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(ee,{className:`w-4 h-4 text-amber-700 shrink-0`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black tracking-wide uppercase block`,children:`OPTIMAL COMPLEXITY TARGET`}),(0,_.jsx)(`span`,{className:`text-[10px] font-sans text-slate-600 font-semibold`,children:`Hidden to test active recall before coding`})]})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>P(!0),className:`px-2.5 py-1 bg-white hover:bg-amber-100 border-2 border-ink-black font-arcade text-[8.5px] font-bold text-ink-black shadow-[1.5px_1.5px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center gap-1.5 shrink-0`,title:`Click to reveal target time and space complexity`,children:[(0,_.jsx)(ie,{className:`w-3 h-3 text-amber-700`}),(0,_.jsx)(`span`,{children:`REVEAL TARGET`})]})]})]}),e===`ref`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[q&&(0,_.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black text-xs font-bold flex items-center justify-between shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${q.type===`success`?`bg-emerald-100 text-emerald-900 border-emerald-700`:`bg-rose-100 text-rose-900 border-rose-700`}`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[q.type===`success`?(0,_.jsx)(ne,{className:`w-4 h-4 text-emerald-700 shrink-0`}):(0,_.jsx)(s,{className:`w-4 h-4 text-rose-700 shrink-0`}),(0,_.jsx)(`span`,{children:q.message})]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>J(null),className:`text-slate-600 hover:text-ink-black cursor-pointer`,children:(0,_.jsx)(ae,{className:`w-3.5 h-3.5`})})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1 p-1 bg-slate-200/90 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] overflow-x-auto no-scrollbar`,children:[X.map((e,t)=>(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{R(t),B(!1),H(null)},className:`py-1 px-2 rounded-full font-arcade text-[8px] font-bold flex items-center justify-center gap-1 border-2 border-ink-black transition-all cursor-pointer whitespace-nowrap shrink-0 ${Z===t&&!z&&!V?`bg-sky-600 text-white shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] -translate-y-0.5`:`bg-white text-ink-black hover:bg-sky-50 shadow-none`}`,title:e.name?`${e.name} (${e.pattern||`Algorithm`})`:`Solution ${t+1}`,children:[e.is_optimal?(0,_.jsx)(d,{className:`w-3 h-3 text-amber-300`}):(0,_.jsx)(a,{className:`w-3 h-3`}),(0,_.jsx)(`span`,{children:`Sol ${t+1}`}),e.is_optimal&&(0,_.jsx)(`span`,{className:`text-[6.5px] px-1 py-0.2 bg-amber-300 text-ink-black border border-ink-black font-extrabold rounded-full tracking-tight`,children:`OPTIMAL`})]},e.id||t)),(0,_.jsx)(`button`,{type:`button`,onClick:()=>{B(!0),H(null),W({name:`Method ${X.length+1}`,pattern:`Arrays & Hashing`,time_complexity:`O(N)`,space_complexity:`O(1)`,code:``,explanation:``,is_optimal:!1})},className:`h-6 w-6 rounded-full font-arcade text-[9px] font-bold flex items-center justify-center border-2 border-ink-black cursor-pointer shrink-0 active:translate-y-0.5 transition-all shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] ${z?`bg-emerald-600 text-white`:`bg-amber-300 text-ink-black hover:bg-amber-200`}`,title:`Add another solution / method for this problem`,"aria-label":`Add Solution`,children:(0,_.jsx)(te,{className:`w-3 h-3 stroke-[2.5]`})})]}),z||V?(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between pb-2 border-b-2 border-dashed border-ink-black`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(n,{className:`w-4 h-4 text-purple-700`}),(0,_.jsx)(`span`,{className:`font-arcade text-[10px] font-bold text-ink-black uppercase`,children:V?`EDIT SOLUTION`:`ADD NEW SOLUTION / METHOD`})]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>{B(!1),H(null)},className:`text-xs font-arcade text-trash-gray hover:text-rose-600 cursor-pointer font-bold`,children:`CANCEL`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Solution / Method Name`}),(0,_.jsx)(`input`,{type:`text`,value:U.name,onChange:e=>W({...U,name:e.target.value}),placeholder:`e.g. One-Pass Hash Map, Two Pointers`,className:`w-full p-2 border-2 border-ink-black text-xs font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Pattern / Strategy`}),(0,_.jsx)(`select`,{value:U.pattern,onChange:e=>W({...U,pattern:e.target.value}),className:`w-full p-2 border-2 border-ink-black text-xs font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`,children:ue.map(e=>(0,_.jsx)(`option`,{value:e,children:e},e))})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Time Complexity`}),(0,_.jsx)(`input`,{type:`text`,value:U.time_complexity,onChange:e=>W({...U,time_complexity:e.target.value}),placeholder:`e.g. O(N), O(N log N), O(N^2)`,className:`w-full p-2 border-2 border-ink-black text-xs font-code-mono font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Space Complexity`}),(0,_.jsx)(`input`,{type:`text`,value:U.space_complexity,onChange:e=>W({...U,space_complexity:e.target.value}),placeholder:`e.g. O(1), O(N)`,className:`w-full p-2 border-2 border-ink-black text-xs font-code-mono font-bold bg-[#fdf8e1] focus:outline-none focus:bg-white`})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase`,children:`Python Reference Code`}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>W({...U,code:de}),className:`text-[8.5px] font-arcade text-sky-700 hover:underline cursor-pointer`,children:`Paste Current Code`})]}),(0,_.jsx)(`textarea`,{rows:8,value:U.code,onChange:e=>W({...U,code:e.target.value}),placeholder:`class Solution:
3
  def solve(self, nums):
4
+ ...`,className:`w-full p-2.5 border-2 border-ink-black bg-[#1E293B] text-[#4ADE80] font-code-mono text-xs focus:outline-none no-scrollbar`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-arcade text-[8.5px] font-bold text-trash-gray uppercase block`,children:`Intuition / How to Solve (Optional)`}),(0,_.jsx)(`textarea`,{rows:3,value:U.explanation,onChange:e=>W({...U,explanation:e.target.value}),placeholder:`Key insight, trade-offs, and state tracking notes...`,className:`w-full p-2 border-2 border-ink-black text-xs bg-[#fdf8e1] focus:outline-none focus:bg-white no-scrollbar`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`input`,{type:`checkbox`,id:`is_optimal_solution`,checked:U.is_optimal,onChange:e=>W({...U,is_optimal:e.target.checked}),className:`w-4 h-4 border-2 border-ink-black rounded cursor-pointer accent-emerald-600`}),(0,_.jsx)(`label`,{htmlFor:`is_optimal_solution`,className:`font-arcade text-[9px] font-bold text-ink-black cursor-pointer`,children:`SET AS OPTIMAL / PRIMARY APPROACH FOR THIS PROBLEM`})]}),(0,_.jsxs)(`div`,{className:`flex items-center justify-end gap-2 pt-2 border-t-2 border-dashed border-ink-black`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:()=>{B(!1),H(null)},className:`px-3 py-1.5 bg-slate-100 hover:bg-slate-200 border-2 border-ink-black font-arcade text-[9px] font-bold text-ink-black cursor-pointer`,children:`CANCEL`}),(0,_.jsxs)(`button`,{type:`button`,disabled:G,onClick:he,className:`px-4 py-1.5 bg-emerald-500 hover:bg-emerald-400 border-2 border-ink-black font-arcade text-[9px] font-bold text-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer disabled:opacity-50 flex items-center gap-1.5`,children:[G&&(0,_.jsx)(i,{className:`w-3 h-3 animate-spin`}),(0,_.jsx)(`span`,{children:V?`UPDATE SOLUTION`:`SAVE SOLUTION`})]})]})]}):Q?(0,_.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3.5`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pb-3 border-b border-slate-200`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap min-w-0`,children:[(0,_.jsx)(`h3`,{className:`font-headline-md font-extrabold text-sm sm:text-base text-ink-black m-0 select-text break-words`,children:Q.name||`Solution ${Z+1}`}),Q.is_optimal&&(0,_.jsx)(`span`,{className:`px-2 py-0.5 bg-amber-300 border border-ink-black font-arcade text-[8px] font-bold text-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] shrink-0`,children:`★ OPTIMAL`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap sm:ml-auto`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,_.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray uppercase`,children:`Pattern:`}),(0,_.jsx)(`span`,{className:`px-2 py-0.5 bg-purple-50 border border-purple-300 font-arcade text-[8.5px] text-purple-800 font-bold`,children:Q.pattern||`General Algorithm`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,_.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-1.5 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`T: `,Q.time_complexity||`O(N)`]}),(0,_.jsxs)(`code`,{className:`bg-[#1E293B] text-[#4ADE80] font-code-mono px-1.5 py-0.5 text-[11px] border border-ink-black font-bold`,children:[`S: `,Q.space_complexity||`O(1)`]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto`,children:[(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{H(Q.id),B(!1),W({name:Q.name,pattern:Q.pattern,time_complexity:Q.time_complexity,space_complexity:Q.space_complexity,code:Q.code,explanation:Q.explanation||``,is_optimal:!!Q.is_optimal})},className:`px-2 py-1 bg-white hover:bg-slate-100 border border-ink-black text-ink-black font-arcade text-[8px] font-bold flex items-center gap-1 cursor-pointer`,title:`Edit this solution`,children:[(0,_.jsx)(n,{className:`w-3 h-3 text-slate-700`}),(0,_.jsx)(`span`,{className:`hidden sm:inline`,children:`EDIT`})]}),X.length>1&&(0,_.jsx)(`button`,{type:`button`,onClick:()=>ge(Q.id),className:`px-1.5 py-1 bg-white hover:bg-rose-50 border border-ink-black text-rose-700 font-arcade text-[8px] font-bold flex items-center gap-1 cursor-pointer`,title:`Delete this solution`,children:(0,_.jsx)(oe,{className:`w-3 h-3`})})]})]})]}),Q.code?(0,_.jsxs)(`div`,{className:`border border-ink-black bg-[#0f172a] overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`bg-[#1e293b] px-2.5 sm:px-3 py-1.5 border-b border-ink-black flex items-center justify-between gap-1.5 flex-wrap min-w-0`,children:[(0,_.jsx)(`span`,{className:`font-arcade text-[8px] text-slate-300 font-bold uppercase truncate min-w-0 flex-1`,children:y?`PYTHON 3`:`PYTHON 3 IMPLEMENTATION`}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,_.jsxs)(`button`,{type:`button`,onClick:()=>pe(Q.code,Q.pattern,Q.time_complexity,Q.space_complexity),disabled:k,className:`px-2 py-0.5 bg-purple-50 hover:bg-purple-100 text-purple-800 border border-ink-black text-[9px] font-arcade font-bold flex items-center gap-1 cursor-pointer shrink-0 disabled:opacity-50 active:translate-y-0.5 transition-all`,title:`Explain this solution with AI`,children:[k?(0,_.jsx)(i,{className:`w-2.5 h-2.5 animate-spin text-purple-700`}):(0,_.jsx)(d,{className:`w-2.5 h-2.5 text-purple-600`}),(0,_.jsx)(`span`,{children:`Explain✦`})]}),(0,_.jsxs)(`button`,{onClick:()=>T(Q.code,`sol-${Q.id}`),className:`px-2 py-0.5 bg-white hover:bg-slate-100 text-ink-black border border-ink-black text-[9px] font-arcade font-bold flex items-center gap-1 cursor-pointer shrink-0 active:translate-y-0.5 transition-all`,title:`Copy solution code`,children:[(0,_.jsx)(l,{className:`w-2.5 h-2.5`}),w===`sol-${Q.id}`?`COPIED!`:`COPY`]})]})]}),(0,_.jsx)(`div`,{className:`p-3 text-xs overflow-x-auto max-h-80 no-scrollbar`,children:(0,_.jsx)(`pre`,{className:`font-code-mono text-[#4ADE80] text-[11px] leading-relaxed select-text m-0`,children:(0,_.jsx)(`code`,{children:Q.code})})})]}):(0,_.jsxs)(`div`,{className:`p-4 bg-amber-50 border border-dashed border-amber-300 text-center space-y-3`,children:[(0,_.jsx)(`p`,{className:`text-xs font-sans text-stone-700`,children:`No code implementation archived for this solution yet.`}),(0,_.jsx)(`button`,{onClick:fe,disabled:D,className:`px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer inline-flex items-center gap-2 disabled:opacity-50`,children:D?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5 animate-spin`}),(0,_.jsx)(`span`,{children:`Generating solution...`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(d,{className:`w-3.5 h-3.5 text-amber-300`}),(0,_.jsx)(`span`,{children:`Generate solution`})]})}),O&&(0,_.jsx)(`div`,{className:`text-xs text-rose-600 font-medium`,children:O})]}),Q.explanation&&(0,_.jsxs)(`div`,{className:`pt-3.5 border-t border-slate-200 space-y-1.5 select-text`,children:[(0,_.jsx)(`span`,{className:`font-arcade text-[8.5px] text-trash-gray uppercase font-bold block`,children:`SOLUTION INTUITION & STRATEGY:`}),(0,_.jsx)(m,{content:Q.explanation})]})]}),Q.code&&(0,_.jsxs)(`div`,{className:`space-y-3`,children:[A&&(0,_.jsx)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold`,children:A}),j&&(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-2 select-text`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 pb-2 border-b-2 border-dashed border-ink-black`,children:[(0,_.jsx)(le,{className:`w-4 h-4 text-purple-600`}),(0,_.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:[`Gemini Code Breakdown (`,Q.name,`)`]})]}),(0,_.jsx)(`div`,{className:`max-h-96 overflow-y-auto no-scrollbar pt-1 select-text`,children:(0,_.jsx)(m,{content:j})})]})]})]}):null,E&&(0,_.jsxs)(`div`,{className:`p-2.5 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-bold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(244,63,94,1)]`,children:[(0,_.jsx)(s,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,_.jsx)(`div`,{className:`flex-1`,children:E})]})]}),e===`fsrs`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,_.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,_.jsx)(se,{className:`w-3 h-3 text-purple-600`}),`SPACED REPETITION PROGRESSION`]}),(0,_.jsx)(`div`,{className:`space-y-2`,children:[{state:0,label:`NEW`,color:`#3b82f6`},{state:1,label:`LEARNING`,color:`#f59e0b`},{state:2,label:`REVIEW`,color:`#10b981`},{state:3,label:`RELEARNING`,color:`#ef4444`}].map(e=>{let t=(M.fsrs_state??0)===e.state;return(0,_.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black flex items-center justify-between transition-all ${t?`bg-amber-100 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] translate-x-1 font-bold`:`bg-slate-50 opacity-70`}`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`w-5 h-5 border border-ink-black flex items-center justify-center font-arcade text-[9px] text-white font-bold`,style:{backgroundColor:e.color},children:e.state}),(0,_.jsx)(`span`,{className:`font-arcade text-[9px] text-ink-black`,children:e.label})]}),(0,_.jsx)(`div`,{className:`flex items-center gap-2`,children:t&&(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 bg-emerald-500 text-white font-arcade text-[7px] border border-ink-black font-bold`,children:`CURRENT`})})]},e.state)})})]}),(0,_.jsxs)(`div`,{className:`p-4 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-3`,children:[(0,_.jsxs)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold flex items-center gap-1.5`,children:[(0,_.jsx)(c,{className:`w-3 h-3 text-emerald-600`}),`PERFORMANCE METRICS`]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`p-2.5 bg-slate-50 border border-ink-black`,children:[(0,_.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase`,children:`Total Reviews`}),(0,_.jsx)(`span`,{className:`font-headline-md text-lg font-bold text-ink-black`,children:M.total_attempts||0})]}),(0,_.jsxs)(`div`,{className:`p-2.5 bg-slate-50 border border-ink-black`,children:[(0,_.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase`,children:`Correct Recall`}),(0,_.jsx)(`span`,{className:`font-headline-md text-lg font-bold text-emerald-600`,children:M.times_correct||0})]})]}),(0,_.jsxs)(`div`,{className:`text-xs font-sans text-slate-600 pt-1`,children:[`Next Due Date:`,` `,(0,_.jsx)(`span`,{className:`font-code-mono font-bold text-ink-black`,children:M.next_review?new Date(M.next_review).toLocaleDateString():`Today`})]})]})]})]})]})};export{y as ProblemSpecPanel};
algospaced-ui/dist/assets/{PythonChallenge-BOgiGe52.js → PythonChallenge-CQdOe4Q2.js} RENAMED
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Rt as n}from"./vendor-react-CIO8MTK1.js";import{s as r}from"./firebaseClient-DZobvwSx.js";import{t as i}from"./MarkdownRenderer-BMZIn30p.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(null),[n,s]=(0,a.useState)(``),[c,l]=(0,a.useState)(!1),[u,d]=(0,a.useState)([]),[f,p]=(0,a.useState)(``),[m,h]=(0,a.useState)(!0),[g,_]=(0,a.useState)(0),v=async()=>{h(!0),p(``);try{let{data:{session:e}}=await r.auth.getSession();if(!e){p(`Unauthenticated session`);return}let n=await fetch(`/api/challenges/python/daily`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(n.ok){let e=await n.json();t(e),s(e.starter_code),_(e.total_score)}else p(`Failed to load challenge from server.`)}catch{p(`Connection timed out.`)}finally{h(!1)}};return(0,a.useEffect)(()=>{v()},[]),m?(0,o.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col items-center justify-center font-arcade text-[10px]`,children:[(0,o.jsx)(`div`,{className:`animate-bounce mb-2`,children:`LOADING CHALLENGE...`}),(0,o.jsx)(`div`,{className:`w-48 h-4 bg-white border-[3px] border-ink-black overflow-hidden relative`,children:(0,o.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-[#9d4edd] w-2/3 animate-pulse border-r-2 border-ink-black`})})]}):e?(0,o.jsx)(`div`,{className:`w-full h-full bg-paper-white text-ink-black flex flex-col overflow-hidden text-xs md:text-sm`,children:(0,o.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 custom-scrollbar flex flex-col gap-4`,children:[(0,o.jsxs)(`div`,{className:`flex justify-between items-center bg-slate-100 border-[3px] border-ink-black p-3`,children:[(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`span`,{className:`px-2 py-0.5 border-2 border-ink-black font-bold uppercase text-[9px] ${e.difficulty===`Easy`?`bg-green-200 text-green-800`:e.difficulty===`Medium`?`bg-yellow-200 text-yellow-800`:`bg-red-200 text-red-800`}`,children:e.difficulty}),(0,o.jsxs)(`span`,{className:`bg-blue-100 text-blue-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:[`+`,e.points,` PTS`]}),e.completed?(0,o.jsx)(`span`,{className:`bg-emerald-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`COMPLETED`}):(0,o.jsx)(`span`,{className:`bg-rose-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`INCOMPLETE`})]}),(0,o.jsxs)(`div`,{className:`font-arcade text-[8px] text-purple-700 font-bold bg-white border-2 border-ink-black px-2 py-0.5 shadow-[1px_1px_0_0_#1E293B]`,children:[`TOTAL SCORE: `,g]})]}),(0,o.jsxs)(`div`,{className:`border-2 border-ink-black bg-slate-50 p-3 rounded font-sans leading-relaxed text-xs`,children:[(0,o.jsxs)(`h3`,{className:`font-bold border-b border-slate-300 pb-1 mb-2 uppercase tracking-wide text-primary-purple flex items-center gap-1`,children:[(0,o.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`description`}),`Problem: `,e.title]}),(0,o.jsx)(i,{content:e.description})]}),(0,o.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-[220px]`,children:[(0,o.jsxs)(`div`,{className:`flex justify-between items-center mb-1`,children:[(0,o.jsxs)(`span`,{className:`font-bold text-[10px] tracking-wide uppercase flex items-center gap-1`,children:[(0,o.jsx)(`span`,{className:`material-symbols-outlined text-sm text-purple-600`,children:`code`}),`Write Python Solution:`]}),(0,o.jsx)(`button`,{onClick:()=>s(e.starter_code),className:`text-[9px] underline text-blue-600 hover:text-blue-800 cursor-pointer font-sans`,children:`Reset Starter Code`})]}),(0,o.jsx)(`textarea`,{value:n,onChange:e=>s(e.target.value),className:`flex-1 w-full bg-slate-900 text-[#4ADE80] font-mono p-3 border-[3px] border-ink-black rounded outline-none focus:ring-2 focus:ring-primary-purple text-xs leading-relaxed resize-none`,placeholder:`# Write your python code here`,spellCheck:`false`})]}),(0,o.jsx)(`div`,{className:`shrink-0`,children:(0,o.jsx)(`button`,{disabled:c,onClick:async()=>{l(!0),p(``),d([]);try{let{data:{session:e}}=await r.auth.getSession();if(!e){p(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/python/submit`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({code:n})});if(i.ok){let e=await i.json();e.success?(d(e.results),e.all_passed&&(_(e.total_score),t(e=>e?{...e,completed:!0}:null))):p(e.error)}else p(`Submission failed at server host.`)}catch{p(`Network connection lost.`)}finally{l(!1)}},className:`w-full bg-highlight-pink text-white font-window-title font-bold py-2 px-4 border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none hover:bg-pink-400 transition-all disabled:opacity-50 cursor-pointer text-center text-xs`,children:c?`EXECUTING TEST CASES...`:`SUBMIT SOLUTION`})}),f&&(0,o.jsxs)(`div`,{className:`border-[3px] border-red-500 bg-red-50 text-red-800 p-3 font-mono text-xs whitespace-pre-wrap`,children:[(0,o.jsx)(`div`,{className:`font-bold mb-1`,children:`COMPILER / RUNTIME ERROR:`}),f]}),u.length>0&&(0,o.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-slate-100 p-3`,children:[(0,o.jsx)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 uppercase`,children:`Test Case Executions:`}),(0,o.jsx)(`div`,{className:`space-y-1.5 font-mono text-xs`,children:u.map((e,t)=>(0,o.jsxs)(`div`,{className:`flex flex-col p-2 border border-slate-300 bg-white`,children:[(0,o.jsxs)(`div`,{className:`flex justify-between`,children:[(0,o.jsxs)(`span`,{className:`font-bold`,children:[`Test Case `,t+1,`:`]}),(0,o.jsx)(`span`,{className:`font-bold uppercase ${e.status===`passed`?`text-green-600`:`text-red-600`}`,children:e.status})]}),(0,o.jsxs)(`div`,{className:`text-[10px] text-slate-500 mt-1`,children:[(0,o.jsxs)(`div`,{children:[`Input: `,JSON.stringify(e.input)]}),e.status===`passed`&&(0,o.jsxs)(`div`,{children:[`Output: `,JSON.stringify(e.got)]}),e.status===`failed`&&(0,o.jsxs)(`div`,{className:`text-red-700`,children:[`Expected: `,JSON.stringify(e.expected),` | Got: `,JSON.stringify(e.got)]}),e.status===`error`&&(0,o.jsxs)(`div`,{className:`text-red-700 font-semibold`,children:[`Error: `,e.error]})]})]},t))})]})]})}):(0,o.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col items-center justify-center font-sans text-center gap-3`,children:[(0,o.jsx)(`span`,{className:`material-symbols-outlined text-red-500 text-4xl`,children:`error`}),(0,o.jsx)(`div`,{className:`font-bold text-ink-black text-sm`,children:f||`No active challenge found.`}),(0,o.jsx)(`button`,{onClick:v,className:`px-3 py-1.5 bg-yellow-400 hover:bg-yellow-300 border-[3px] border-ink-black text-xs font-bold font-window-title cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:`RETRY`})]})}export{s as default};
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n}from"./vendor-react-hnaVBnLv.js";import{s as r}from"./firebaseClient-DZobvwSx.js";import{t as i}from"./MarkdownRenderer-D8UdFpnD.js";var a=e(n(),1),o=t();function s(){let[e,t]=(0,a.useState)(null),[n,s]=(0,a.useState)(``),[c,l]=(0,a.useState)(!1),[u,d]=(0,a.useState)([]),[f,p]=(0,a.useState)(``),[m,h]=(0,a.useState)(!0),[g,_]=(0,a.useState)(0),v=async()=>{h(!0),p(``);try{let{data:{session:e}}=await r.auth.getSession();if(!e){p(`Unauthenticated session`);return}let n=await fetch(`/api/challenges/python/daily`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(n.ok){let e=await n.json();t(e),s(e.starter_code),_(e.total_score)}else p(`Failed to load challenge from server.`)}catch{p(`Connection timed out.`)}finally{h(!1)}};return(0,a.useEffect)(()=>{v()},[]),m?(0,o.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col items-center justify-center font-arcade text-[10px]`,children:[(0,o.jsx)(`div`,{className:`animate-bounce mb-2`,children:`LOADING CHALLENGE...`}),(0,o.jsx)(`div`,{className:`w-48 h-4 bg-white border-[3px] border-ink-black overflow-hidden relative`,children:(0,o.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-[#9d4edd] w-2/3 animate-pulse border-r-2 border-ink-black`})})]}):e?(0,o.jsx)(`div`,{className:`w-full h-full bg-paper-white text-ink-black flex flex-col overflow-hidden text-xs md:text-sm`,children:(0,o.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 custom-scrollbar flex flex-col gap-4`,children:[(0,o.jsxs)(`div`,{className:`flex justify-between items-center bg-slate-100 border-[3px] border-ink-black p-3`,children:[(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`span`,{className:`px-2 py-0.5 border-2 border-ink-black font-bold uppercase text-[9px] ${e.difficulty===`Easy`?`bg-green-200 text-green-800`:e.difficulty===`Medium`?`bg-yellow-200 text-yellow-800`:`bg-red-200 text-red-800`}`,children:e.difficulty}),(0,o.jsxs)(`span`,{className:`bg-blue-100 text-blue-800 px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:[`+`,e.points,` PTS`]}),e.completed?(0,o.jsx)(`span`,{className:`bg-emerald-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`COMPLETED`}):(0,o.jsx)(`span`,{className:`bg-rose-500 text-white px-2 py-0.5 border-2 border-ink-black font-bold text-[9px]`,children:`INCOMPLETE`})]}),(0,o.jsxs)(`div`,{className:`font-arcade text-[8px] text-purple-700 font-bold bg-white border-2 border-ink-black px-2 py-0.5 shadow-[1px_1px_0_0_#1E293B]`,children:[`TOTAL SCORE: `,g]})]}),(0,o.jsxs)(`div`,{className:`border-2 border-ink-black bg-slate-50 p-3 rounded font-sans leading-relaxed text-xs`,children:[(0,o.jsxs)(`h3`,{className:`font-bold border-b border-slate-300 pb-1 mb-2 uppercase tracking-wide text-primary-purple flex items-center gap-1`,children:[(0,o.jsx)(`span`,{className:`material-symbols-outlined text-sm`,children:`description`}),`Problem: `,e.title]}),(0,o.jsx)(i,{content:e.description})]}),(0,o.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-[220px]`,children:[(0,o.jsxs)(`div`,{className:`flex justify-between items-center mb-1`,children:[(0,o.jsxs)(`span`,{className:`font-bold text-[10px] tracking-wide uppercase flex items-center gap-1`,children:[(0,o.jsx)(`span`,{className:`material-symbols-outlined text-sm text-purple-600`,children:`code`}),`Write Python Solution:`]}),(0,o.jsx)(`button`,{onClick:()=>s(e.starter_code),className:`text-[9px] underline text-blue-600 hover:text-blue-800 cursor-pointer font-sans`,children:`Reset Starter Code`})]}),(0,o.jsx)(`textarea`,{value:n,onChange:e=>s(e.target.value),className:`flex-1 w-full bg-slate-900 text-[#4ADE80] font-mono p-3 border-[3px] border-ink-black rounded outline-none focus:ring-2 focus:ring-primary-purple text-xs leading-relaxed resize-none`,placeholder:`# Write your python code here`,spellCheck:`false`})]}),(0,o.jsx)(`div`,{className:`shrink-0`,children:(0,o.jsx)(`button`,{disabled:c,onClick:async()=>{l(!0),p(``),d([]);try{let{data:{session:e}}=await r.auth.getSession();if(!e){p(`Unauthenticated session`);return}let i=await fetch(`/api/challenges/python/submit`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({code:n})});if(i.ok){let e=await i.json();e.success?(d(e.results),e.all_passed&&(_(e.total_score),t(e=>e?{...e,completed:!0}:null))):p(e.error)}else p(`Submission failed at server host.`)}catch{p(`Network connection lost.`)}finally{l(!1)}},className:`w-full bg-highlight-pink text-white font-window-title font-bold py-2 px-4 border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none hover:bg-pink-400 transition-all disabled:opacity-50 cursor-pointer text-center text-xs`,children:c?`EXECUTING TEST CASES...`:`SUBMIT SOLUTION`})}),f&&(0,o.jsxs)(`div`,{className:`border-[3px] border-red-500 bg-red-50 text-red-800 p-3 font-mono text-xs whitespace-pre-wrap`,children:[(0,o.jsx)(`div`,{className:`font-bold mb-1`,children:`COMPILER / RUNTIME ERROR:`}),f]}),u.length>0&&(0,o.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-slate-100 p-3`,children:[(0,o.jsx)(`div`,{className:`font-bold text-[10px] border-b border-slate-300 pb-1 mb-2 uppercase`,children:`Test Case Executions:`}),(0,o.jsx)(`div`,{className:`space-y-1.5 font-mono text-xs`,children:u.map((e,t)=>(0,o.jsxs)(`div`,{className:`flex flex-col p-2 border border-slate-300 bg-white`,children:[(0,o.jsxs)(`div`,{className:`flex justify-between`,children:[(0,o.jsxs)(`span`,{className:`font-bold`,children:[`Test Case `,t+1,`:`]}),(0,o.jsx)(`span`,{className:`font-bold uppercase ${e.status===`passed`?`text-green-600`:`text-red-600`}`,children:e.status})]}),(0,o.jsxs)(`div`,{className:`text-[10px] text-slate-500 mt-1`,children:[(0,o.jsxs)(`div`,{children:[`Input: `,JSON.stringify(e.input)]}),e.status===`passed`&&(0,o.jsxs)(`div`,{children:[`Output: `,JSON.stringify(e.got)]}),e.status===`failed`&&(0,o.jsxs)(`div`,{className:`text-red-700`,children:[`Expected: `,JSON.stringify(e.expected),` | Got: `,JSON.stringify(e.got)]}),e.status===`error`&&(0,o.jsxs)(`div`,{className:`text-red-700 font-semibold`,children:[`Error: `,e.error]})]})]},t))})]})]})}):(0,o.jsxs)(`div`,{className:`w-full h-full bg-paper-white p-6 flex flex-col items-center justify-center font-sans text-center gap-3`,children:[(0,o.jsx)(`span`,{className:`material-symbols-outlined text-red-500 text-4xl`,children:`error`}),(0,o.jsx)(`div`,{className:`font-bold text-ink-black text-sm`,children:f||`No active challenge found.`}),(0,o.jsx)(`button`,{onClick:v,className:`px-3 py-1.5 bg-yellow-400 hover:bg-yellow-300 border-[3px] border-ink-black text-xs font-bold font-window-title cursor-pointer shadow-[2px_2px_0px_rgba(0,0,0,1)] active:translate-y-0.5 active:shadow-none`,children:`RETRY`})]})}export{s as default};
algospaced-ui/dist/assets/ReviewQueue-CltGWQpb.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProblemSpecPanel-BRW8UyO6.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-react-hnaVBnLv.js","assets/vendor-codemirror-By0wlJeM.js","assets/index-DVWZ15xt.js","assets/firebaseClient-DZobvwSx.js","assets/vendor-firebase-DSIO3PIf.js","assets/vendor-ui-ZXcm-2wU.js","assets/index-BsU9BpJx.css","assets/MarkdownRenderer-D8UdFpnD.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{A as n,Bt as r,Et as i,F as a,Ht as o,M as s,O as c,P as l,St as u,Tt as d,X as f,a as p,d as m,et as h,ht as g,it as _,lt as v,mt as y,p as b,pt as x,q as S,s as C,st as w,t as T,tt as E,u as D,x as O,xt as ee,yt as k}from"./vendor-react-hnaVBnLv.js";import{r as A,s as j}from"./firebaseClient-DZobvwSx.js";import{b as M,c as N,n as P,o as te,r as F,s as I,t as L}from"./index-DVWZ15xt.js";import{o as ne,r as re}from"./githubSyncService-x0Mm_uEl.js";import{t as ie}from"./confetti.module-Uxh4CK4s.js";import"./MarkdownRenderer-D8UdFpnD.js";import"./PrincessChamber-abJShfI5.js";import{A as R,C as z,I as B,S as V,p as ae,t as oe,x as se,y as ce}from"./vendor-codemirror-By0wlJeM.js";var H=t(o(),1),U=r();function le(e){if(!e)return{description:``,examples:[],constraints:[]};let t=e.description||``,n=[],r=[];if(Array.isArray(e.examples)&&e.examples.length>0&&(n=e.examples.map(e=>typeof e==`string`?{input:e,output:``}:{input:e?.input||``,output:e?.output||``,explanation:e?.explanation||``})),Array.isArray(e.constraints)&&e.constraints.length>0?r=e.constraints.map(e=>String(e).replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean):typeof e.constraints==`string`&&e.constraints.trim()&&(r=e.constraints.split(`
3
+ `).map(e=>e.replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean)),n.length===0||r.length===0){let e=t.search(/\bExample\s*\d*:/i),i=t.search(/\bConstraints\s*:/i),a=-1;if(e!==-1&&i!==-1?a=Math.min(e,i):e===-1?i!==-1&&(a=i):a=e,a!==-1){let e=t.substring(0,a).trim(),i=t.substring(a),o=i,s=``,c=i.search(/\bConstraints\s*:/i);if(c!==-1&&(o=i.substring(0,c).trim(),s=i.substring(c).replace(/\bConstraints\s*:/i,``).trim()),n.length===0&&o){let e=/\bExample\s*(\d*)\s*:/gi,t=[],r;for(;(r=e.exec(o))!==null;)t.push({index:r.index,text:r[0]});for(let e=0;e<t.length;e++){let r=t[e].index+t[e].text.length,i=e+1<t.length?t[e+1].index:o.length,a=o.substring(r,i).trim(),s=a.match(/Input:\s*([\s\S]+?)(?=(?:Output:|Explanation:|$))/i),c=a.match(/Output:\s*([\s\S]+?)(?=(?:Explanation:|$))/i),l=a.match(/Explanation:\s*([\s\S]+)/i),u=s?s[1].trim():``,d=c?c[1].trim():``,f=l?l[1].trim():``;u||d?n.push({input:u,output:d,explanation:f}):a&&n.push({input:a,output:``,explanation:``})}}r.length===0&&s&&(r=s.split(`
4
+ `).map(e=>e.replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean)),(n.length>0||r.length>0)&&(t=e)}}return{description:t,examples:n,constraints:r}}function ue(e,t,n,r){let i=e=>!e||/^Method\s*\d*$/i.test(e.trim())||e.trim().toLowerCase()===`standard`,a=(e||t||`Algorithm Problem`).trim(),o=null;if(t&&a.toLowerCase().startsWith(t.toLowerCase())){let e=a.slice(t.length).trim();if(a=t,e){let t=e.match(/^[-\s]*Method\s*(\d+)\s*\((.+)\)$/i);if(t){let e=parseInt(t[1],10),n=t[2].trim();i(n)?e>1&&(o=`Method ${e}`):o=n}else{let t=e.match(/^[-\s]*Method\s*(\d+)/i);if(t){let e=parseInt(t[1],10);e>1&&(o=`Method ${e}`)}else{let t=e.match(/^[-\s]*\((.+)\)$/);if(t){let e=t[1].trim();i(e)||(o=e)}else{let t=e.match(/^[-\s]+([^-]+)$/);t&&!i(t[1])&&(o=t[1].trim())}}}}}else{let e=a.match(/^(.*?)\s*-\s*Method\s*(\d+)\s*\((.+)\)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10),n=e[3].trim();i(n)?t>1&&(o=`Method ${t}`):o=n}else{let e=a.match(/^(.*?)\s*-\s*Method\s*(\d+)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10);t>1&&(o=`Method ${t}`)}else{let e=a.match(/^(.*?)\s*\(\s*Method\s*(\d+)\s*\)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10);t>1&&(o=`Method ${t}`)}}}}let s=`General Algorithm`;return i(n)?i(r)?o&&!i(o)&&(s=o):s=r.trim():s=n.trim(),{cleanTitle:a,approachVariant:o,pattern:s}}function de(e,t,n){if(!e)return[];if(Array.isArray(e.solutions)&&e.solutions.length>0)return e.solutions;let r=[],i=t||e.reference_code||``,a=e.pattern||`General Algorithm`,o=e.optimal_time||`O(N)`,s=e.optimal_space||`O(1)`;return(i||a)&&r.push({id:`sol-1`,name:e.approach_variant||`Optimal Solution`,pattern:a,time_complexity:o,space_complexity:s,code:i,explanation:e.how_to_solve||``,is_optimal:!0}),n&&n.trim()&&n.trim()!==i.trim()&&r.push({id:`sol-2`,name:`Personal Solution`,pattern:a,time_complexity:o,space_complexity:s,code:n,is_optimal:!1}),r}function W(e){if(e&&e!==`sandbox-user-id`)return e;try{let e=A();if(e?.user?.id&&e.user.id!==`sandbox-user-id`)return e.user.id}catch{}return`guest`}function fe({overrideProblemId:e,refreshTrigger:t,onClearOverride:n}){let[r,i]=(0,H.useState)([]),[a,o]=(0,H.useState)(!0),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(``),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(()=>{try{return A()?.user?.id}catch{return}}),C=(0,H.useRef)(!1),w=(0,H.useRef)(n),T=(0,H.useRef)(!1);(0,H.useEffect)(()=>{w.current=n});let E=(0,H.useCallback)(async(t=!0)=>{t?(o(!0),m(null),c(null),g(``),C.current=!1):m(null);let n=W(x);try{if(typeof navigator<`u`&&!navigator.onLine)throw Error(`Network connection offline.`);let{data:{session:r}}=await j.auth.getSession(),a=r?r.access_token:`sandbox`;r?.user?.id&&(S(r.user.id),n=W(r.user.id));let o={Authorization:`Bearer ${a}`},s=new AbortController,l=setTimeout(()=>s.abort(),4e3),u;try{u=await fetch(`/api/reviews/due`,{headers:o,signal:s.signal})}finally{clearTimeout(l)}if(!u.ok)throw Error(`Failed to load review queue: HTTP ${u.status}`);let d=await u.json();if(Array.isArray(d)||(d=[]),e){let t=String(e).trim().toLowerCase(),n=d.findIndex(e=>{let n=e.problems;return!!(e.problem_id&&String(e.problem_id).trim().toLowerCase()===t||n?.id&&String(n.id).trim().toLowerCase()===t||n?.problem_number!==void 0&&n?.problem_number!==null&&String(n.problem_number)===t||n?.name&&n.name.trim().toLowerCase()===t)});if(n>0){let[e]=d.splice(n,1);d.unshift(e)}else if(n===-1){let t=null,n=await fetch(`/api/reviews/problems/id/${e}`,{headers:o});if(n.ok){let e=await n.json();Array.isArray(e)&&e.length>0&&(t=e[0])}if(!t){let n=/^\d+$/.test(e),r=F(n?parseInt(e,10):void 0,e);if(r)try{let e=await N(r);if(e?.problem_id){let n=await fetch(`/api/reviews/problems/id/${e.problem_id}`,{headers:o});if(n.ok){let e=await n.json();Array.isArray(e)&&e.length>0&&(t=e[0])}}}catch(e){console.error(`Failed to auto-activate problem for override review:`,e)}}t&&d.unshift(t)}}i(d),c(null);try{localStorage.setItem(`algospaced_review_queue_${n}`,JSON.stringify(d))}catch{}if(d&&d.length>0){if(t){let e=d[0],t=e.problems,n=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),r=F(n,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;g(r)}}else try{let e=await fetch(`/api/journey-progress`,{headers:o});if(e.ok){let t=await e.json();v(I(new Set(t))??null)}else v(I(new Set)??null)}catch{v(I(new Set)??null)}}catch(e){console.error(`Error fetching review queue:`,e);let r=e instanceof Error?e.message:`Network error loading review queue.`,a=!1;try{let e=localStorage.getItem(`algospaced_review_queue_${n}`);if(e){let n=JSON.parse(e);if(Array.isArray(n)&&n.length>0&&(i(n),a=!0,c(null),t)){let e=n[0],t=e.problems,r=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=F(r,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;g(i)}}}catch(e){console.warn(`Failed to parse cached review items:`,e)}a||c(r)}finally{o(!1)}},[e,x]);(0,H.useEffect)(()=>{if(T.current){T.current=!1;return}let e=!1,t=setTimeout(()=>{e||E(!0)},0);return()=>{e=!0,clearTimeout(t)}},[E,t]),(0,H.useEffect)(()=>{if(!a&&!s&&r.length===0&&!e&&!C.current){C.current=!0;try{ie({particleCount:90,spread:70,origin:{y:.6}})}catch{}}},[a,s,r.length,e]);let D=(0,H.useCallback)(async t=>{if(r.length===0||l)return;let n=r[0];if(!n||!n.id)return;u(!0),f(t),m(null);let a=[...r];try{let{data:{session:r}}=await j.auth.getSession(),o=r?r.access_token:`sandbox`,s=await fetch(`/api/reviews/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${o}`},body:JSON.stringify({review_id:n.id,fsrs_state:n.fsrs_state??0,fsrs_step:n.fsrs_step??0,fsrs_stability:n.fsrs_stability??0,fsrs_difficulty:n.fsrs_difficulty??0,fsrs_elapsed_days:n.fsrs_elapsed_days??0,fsrs_scheduled_days:n.fsrs_scheduled_days??0,fsrs_reps:n.fsrs_reps??0,fsrs_lapses:n.fsrs_lapses??0,last_reviewed:n.last_reviewed,rating:t})});if(s.ok){let r=n?.problems?.name||``,a=n?.problems?.pattern||``,o=`Correct`;o=t===1?`Incorrect`:t===2?`Mixed`:`Correct`,M.addReviewEvent(o,r,a).catch(()=>{});let s=re(),l=h.trim()||n?.problems?.reference_code||``;s.token&&s.repoName&&s.autoCommit&&l&&ne({token:s.token,repo:s.repoName,branch:s.branch,problem_number:n?.problems?.problem_number,problem_name:r||`Algorithm Problem`,pattern:a||`Algorithms`,difficulty:n?.problems?.difficulty||`Medium`,optimal_time:n?.problems?.optimal_time||`O(N)`,optimal_space:n?.problems?.optimal_space||`O(1)`,description:n?.problems?.description||``,code:l}).catch(e=>{console.warn(`GitHub background auto-commit failed:`,e)}),e&&w.current&&(T.current=!0,w.current()),i(e=>{let t=e.slice(1);try{let e=W(x);localStorage.setItem(`algospaced_review_queue_${e}`,JSON.stringify(t))}catch{}if(t.length>0){let e=t[0],n=e.problems,r=n?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=F(r,n?.id||e?.problem_id,n?.name)?.starter_code||n?.starter_code||``;g(i)}else g(``);return t}),c(null),E(!1)}else{let e=await s.json().catch(()=>({}));m(e.detail||`Server returned error (${s.status}). Please try again.`),i(a)}}catch(e){console.error(`Error logging review completion:`,e);let t=e instanceof Error?e.message:`Network connection failed while logging review.`;m(t),i(a)}finally{u(!1),f(null)}},[r,l,e,E,h,x]),O=(0,H.useCallback)(async()=>{if(_&&!y){b(!0);try{await N(_),await E()}catch(e){console.error(`Failed to activate next milestone:`,e)}finally{b(!1)}}},[_,y,E]),ee=(0,H.useCallback)(()=>{let e=r[0],t=e?.problems,n=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=F(n,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;g(i)},[r]);return{reviews:r,setReviews:i,loading:a,queueError:s,submitting:l,submittingRating:d,gradeError:p,setGradeError:m,code:h,setCode:g,nextMilestone:_,activatingMilestone:y,currentUserId:x,fetchQueue:E,handleGrade:D,handleSelectCard:(0,H.useCallback)(t=>{if(t<=0||t>=r.length||l)return;e&&w.current&&(T.current=!0,w.current());let n=r[t];if(!n)return;let a=n.problems,o=a?.problem_number??(/^\d+$/.test(n?.problem_id||``)?parseInt(n.problem_id,10):void 0),s=F(o,a?.id||n?.problem_id,a?.name)?.starter_code||a?.starter_code||``;g(s),i(e=>{let t=e.findIndex(e=>e.id&&e.id===n.id||e===n);return t<=0?e:[e[t],...e.slice(0,t),...e.slice(t+1)]})},[r,l,e]),handleActivateNextMilestone:O,handleResetStarterCode:ee}}function pe(){return{sandboxRunning:P(e=>e.sandboxRunning),sandboxResults:P(e=>e.sandboxResults),sandboxError:P(e=>e.sandboxError),savingReference:P(e=>e.savingReference),savedRefSuccess:P(e=>e.savedRefSuccess),saveRefError:P(e=>e.saveRefError),handleRunSandbox:P(e=>e.handleRunSandbox),handleSaveReference:P(e=>e.handleSaveReference),resetSandbox:P(e=>e.resetSandbox)}}function me(){return{aiLoading:P(e=>e.aiLoading),aiResult:P(e=>e.aiResult),aiError:P(e=>e.aiError),explainLoading:P(e=>e.explainLoading),explanationText:P(e=>e.explanationText),explainError:P(e=>e.explainError),aiSolutionLoading:P(e=>e.aiSolutionLoading),aiSolutionError:P(e=>e.aiSolutionError),handleAiEvaluation:P(e=>e.handleAiEvaluation),handleExplainCode:P(e=>e.handleExplainCode),handleFetchAiSolution:P(e=>e.handleFetchAiSolution),resetAiState:P(e=>e.resetAiState)}}var he=({problem:e,totalInQueue:t,reviews:n=[],onSelectCard:r,onOpenCreateProblem:i,onOpenEditProblem:o})=>{let[s,c]=(0,H.useState)(!1),u=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return s&&(document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t)),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[s]);let d=e.problem_number?`https://leetcode.com/problemset/all/?search=${e.problem_number}`:`https://leetcode.com/problemset/all/?search=${encodeURIComponent(e.name||``)}`;return(0,U.jsxs)(`div`,{className:`shrink-0 bg-paper-white border-b-[3px] border-ink-black px-2.5 sm:px-4 py-2 flex flex-wrap items-center justify-between gap-2 shadow-[0_2px_0_0_rgba(30,41,59,0.05)] relative z-40`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap min-w-0`,children:[(0,U.jsxs)(`div`,{className:`relative shrink-0`,ref:u,children:[(0,U.jsxs)(`button`,{onClick:()=>c(e=>!e),className:`h-7 inline-flex items-center gap-1.5 px-2 sm:px-2.5 bg-amber-300 hover:bg-amber-200 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Click to view all cards due in today's queue`,children:[(0,U.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-ping shrink-0`}),(0,U.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] font-bold text-ink-black tracking-wide whitespace-nowrap`,children:`CARD 1 OF ${t}`}),t>1&&(0,U.jsx)(ee,{className:`w-3 h-3 text-ink-black transition-transform shrink-0 ${s?`rotate-180`:``}`})]}),s&&n.length>0&&(0,U.jsxs)(`div`,{className:`absolute top-9 left-0 z-50 w-64 min-[400px]:w-72 sm:w-80 bg-paper-white border-[3px] border-ink-black gadget-shadow p-3 space-y-2 max-w-[calc(100vw-32px)]`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between border-b-2 border-ink-black pb-1.5 font-arcade text-[9px] font-bold text-ink-black`,children:[(0,U.jsx)(`span`,{children:`DAILY QUEUE (${n.length} CARDS)`}),(0,U.jsx)(`button`,{onClick:()=>c(!1),className:`px-1 hover:text-rose-600 font-bold cursor-pointer`,title:`Close`,children:`✕`})]}),(0,U.jsx)(`div`,{className:`text-[7.5px] font-arcade text-trash-gray uppercase -mt-0.5`,children:`Click any card to solve it now:`}),(0,U.jsx)(`div`,{className:`max-h-60 overflow-y-auto no-scrollbar space-y-1.5 pr-1`,children:n.map((e,t)=>{let n=e.problems,i=n?.problem_number,a=i==null?void 0:te(i),{cleanTitle:o,approachVariant:s}=ue(n?.name||``,a?.name),u=s?`${o} (${s})`:o,d=t===0,f=n?.difficulty,p=f?f.toUpperCase():`EASY`,m=f===`Easy`?`bg-emerald-600 text-white`:f===`Medium`?`bg-amber-400 text-ink-black`:`bg-rose-600 text-white`;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{d||r?.(t),c(!1)},className:`group w-full text-left p-2 border-2 border-ink-black text-xs flex items-center justify-between gap-2 cursor-pointer transition-all duration-150 select-none ${d?`bg-amber-100 font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:`bg-white hover:bg-amber-50 hover:translate-x-0.5 active:translate-y-0.5 active:shadow-none shadow-[2px_2px_0px_0px_rgba(30,41,59,0.25)]`}`,title:d?`Currently active card`:`Jump to #${t+1}: ${u}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 truncate min-w-0`,children:[(0,U.jsxs)(`span`,{className:`font-arcade text-[9px] text-trash-gray shrink-0`,children:[`#`,t+1]}),i!=null&&(0,U.jsxs)(`span`,{className:`font-arcade text-[8px] font-bold px-1 py-0.2 bg-amber-300 border border-ink-black shrink-0`,children:[`LC #`,i]}),(0,U.jsx)(`span`,{className:`truncate`,children:u})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[d?(0,U.jsx)(`span`,{className:`text-[7.5px] font-arcade font-extrabold px-1 py-0.5 bg-amber-300 text-ink-black border border-ink-black shrink-0`,children:`NOW`}):(0,U.jsx)(l,{className:`w-2.5 h-2.5 fill-ink-black text-ink-black opacity-0 group-hover:opacity-100 transition-opacity shrink-0`}),(0,U.jsx)(`span`,{className:`text-[8px] font-arcade font-bold px-1.5 py-0.5 border border-ink-black shrink-0 ${m}`,children:p})]})]},e.id||t)})})]})]}),e.problem_number!==void 0&&e.problem_number!==null&&(0,U.jsx)(`span`,{className:`h-7 inline-flex items-center px-2 font-arcade text-[8px] sm:text-[9px] font-bold bg-amber-200 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-ink-black shrink-0 select-none whitespace-nowrap`,children:e.problem_number>0?`LC #${e.problem_number}`:`CUSTOM`}),(0,U.jsx)(`span`,{className:`h-7 inline-flex items-center px-2 font-arcade text-[8px] sm:text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] shrink-0 select-none whitespace-nowrap ${e.difficulty===`Easy`?`bg-emerald-600 text-white`:e.difficulty===`Medium`?`bg-amber-400 text-ink-black`:`bg-rose-600 text-white`}`,children:e.difficulty?e.difficulty.toUpperCase():`EASY`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 flex-wrap justify-end`,children:[(0,U.jsxs)(`button`,{onClick:i,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-purple-50 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Create or Import Problem`,children:[(0,U.jsx)(y,{className:`w-3 h-3 text-purple-600 shrink-0`}),(0,U.jsx)(`span`,{className:`hidden min-[480px]:inline`,children:`ADD`})]}),o&&(0,U.jsxs)(`button`,{onClick:o,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-emerald-50 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Edit Problem Specification`,children:[(0,U.jsx)(a,{className:`w-3 h-3 text-emerald-600 shrink-0`}),(0,U.jsx)(`span`,{className:`hidden min-[480px]:inline`,children:`EDIT`})]}),e.google_doc_url&&(0,U.jsxs)(`a`,{href:e.google_doc_url,target:`_blank`,rel:`noreferrer`,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Open Google Doc Notes`,children:[(0,U.jsx)(`span`,{children:`DOC`}),(0,U.jsx)(_,{className:`w-2.5 h-2.5 text-primary shrink-0`})]}),(0,U.jsxs)(`a`,{href:d,target:`_blank`,rel:`noreferrer`,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Search LeetCode`,children:[(0,U.jsx)(`span`,{children:`LC`}),(0,U.jsx)(_,{className:`w-2.5 h-2.5 text-amber-600 shrink-0`})]})]})]})},ge=se.mark({class:`cm-indent-dot cm-indent-dot-primary`}),_e=se.mark({class:`cm-indent-dot cm-indent-dot-secondary`});function G(e){let t=new B;for(let{from:n,to:r}of e.visibleRanges){let i=n;for(;i<r;){let n=e.state.doc.lineAt(i),r=n.text,a=0;for(;a<r.length&&(r[a]===` `||r[a]===` `);){let e=n.from+a,i=e+1,o=a%4==0||r[a]===` `;t.add(e,i,o?ge:_e),a++}i=n.to+1}}return t.finish()}var ve=z.fromClass(class{decorations;constructor(e){this.decorations=G(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=G(e.view))}},{decorations:e=>e.decorations}),ye=V.theme({"&":{backgroundColor:`#0c111d`,color:`#f1f5f9`,height:`100%`,fontSize:`13px`,fontFamily:`var(--font-code, "JetBrains Mono", "Fira Code", monospace)`},".cm-scroller":{overflow:`auto`,fontFamily:`inherit`,lineHeight:`1.65`},".cm-content":{caretColor:`#4ade80`,padding:`12px 0`},"&.cm-focused .cm-cursor":{borderLeftColor:`#4ade80`,borderLeftWidth:`2px`,filter:`drop-shadow(0 0 5px rgba(74, 222, 128, 0.8))`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`rgba(56, 189, 248, 0.25) !important`},".cm-gutters":{backgroundColor:`#070a12`,color:`#475569`,borderRight:`2px solid #1e293b`,paddingRight:`6px`,userSelect:`none`},".cm-activeLineGutter":{backgroundColor:`#131b2e`,color:`#38bdf8`,fontWeight:`700`},".cm-activeLine, &.cm-focused .cm-activeLine":{backgroundColor:`#0f172a !important`},".cm-line":{padding:`0 10px`},".cm-indent-dot":{position:`relative`,display:`inline-block`},".cm-indent-dot::before":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,userSelect:`none`,lineHeight:`0`,fontFamily:`monospace`},".cm-indent-dot-primary::before":{content:`"•"`,color:`#38bdf8`,fontSize:`9px`,opacity:`0.85`},".cm-indent-dot-secondary::before":{content:`"·"`,color:`#64748b`,fontSize:`11px`,opacity:`0.5`},"&.cm-focused .cm-matchingBracket, .cm-matchingBracket":{backgroundColor:`rgba(74, 222, 128, 0.2)`,outline:`1px solid #4ade80`,borderRadius:`2px`,color:`#86efac !important`},".cm-placeholder":{color:`#64748b`,fontStyle:`italic`},".cm-scroller::-webkit-scrollbar":{width:`6px`,height:`6px`},".cm-scroller::-webkit-scrollbar-track":{backgroundColor:`#070a12`},".cm-scroller::-webkit-scrollbar-thumb":{backgroundColor:`#1e293b`,borderRadius:`3px`,border:`1px solid #334155`},".cm-scroller::-webkit-scrollbar-thumb:hover":{backgroundColor:`#38bdf8`}}),be=[oe(),ce.of(` `),R.of([ae]),ve,ye,V.contentAttributes.of({"aria-label":`Python Code Editor`})],K=[{id:`python`,name:`Python`,version:`3.14`}],xe=({className:e=`w-3.5 h-3.5`})=>(0,U.jsxs)(`svg`,{viewBox:`0 0 128 128`,className:e,xmlns:`http://www.w3.org/2000/svg`,children:[(0,U.jsx)(`path`,{d:`M63.454 4.018c-14.775 0-23.774 6.425-23.774 18.775v13.626h24.168v3.424H30.082C17.518 39.843 8 47.962 8 63.673c0 15.65 8.358 23.486 21.056 23.486h11.905v-16.89c0-13.064 11.233-24.113 24.331-24.113h23.773V32.793c0-11.83-9.988-19.775-23.773-19.775H63.454v-9zm-9.845 7.426a3.84 3.84 0 0 1 3.86 3.84 3.84 3.84 0 0 1-3.86 3.841 3.84 3.84 0 0 1-3.86-3.84 3.84 3.84 0 0 1 3.86-3.841z`,fill:`#387eb8`}),(0,U.jsx)(`path`,{d:`M64.546 123.982c14.775 0 23.774-6.425 23.774-18.775V91.581H64.152v-3.424h33.766c12.564 0 22.082-8.119 22.082-23.83 0-15.65-8.358-23.486-21.056-23.486H87.04v16.89c0 13.064-11.234 24.113-24.332 24.113H38.934v13.363c0 11.83 9.989 19.775 23.774 19.775h1.838v9zm9.845-7.426a3.84 3.84 0 0 1-3.86-3.84 3.84 3.84 0 0 1 3.86-3.841 3.84 3.84 0 0 1 3.86 3.84 3.84 3.84 0 0 1-3.86 3.841z`,fill:`#ffe052`})]}),Se=({mobileView:e,isNarrow:t=!1,isAutocompleteEnabled:r,onToggleAutocomplete:a,onResetStarterCode:o,code:d,onChangeCode:p,sandboxRunning:v,sandboxError:y,sandboxResults:S,onRunSandbox:C,savingReference:w,savedRefSuccess:E,saveRefError:D,onSaveReference:k,aiLoading:A,aiError:j,aiResult:M,onAiEvaluation:N,optimalTime:P,optimalSpace:te,onPushToGitHub:F,pushingToGitHub:I,githubPushedUrl:L,githubPushError:ne})=>{let[re,ie]=(0,H.useState)(`python`),[R,z]=(0,H.useState)(!1),B=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=e=>{B.current&&!B.current.contains(e.target)&&z(!1)},t=e=>{e.key===`Escape`&&z(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[]);let V=K.find(e=>e.id===re)??K[0];return(0,U.jsxs)(`div`,{className:`w-full ${t?`flex flex-1`:`lg:w-[51%] flex`} flex-col bg-[#fffdfa] overflow-y-auto no-scrollbar ${t&&e!==`code`?`hidden`:`flex`}`,children:[(0,U.jsxs)(`div`,{className:`shrink-0 bg-[#f7f5ed] border-b-2 border-ink-black p-2 sm:px-3 flex flex-wrap items-center justify-between gap-1.5 sm:gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap`,children:[(0,U.jsxs)(`div`,{className:`relative`,ref:B,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>z(e=>!e),className:`h-7 px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center gap-1.5 font-arcade text-[9px] font-bold text-ink-black cursor-pointer transition-all select-none`,title:`Select programming language`,"aria-expanded":R,"aria-haspopup":`listbox`,children:[(0,U.jsx)(xe,{className:`w-3.5 h-3.5 shrink-0`}),(0,U.jsx)(`span`,{children:V.name}),(0,U.jsx)(ee,{className:`w-3 h-3 text-ink-black transition-transform duration-150 ${R?`rotate-180`:``}`})]}),R&&(0,U.jsxs)(`div`,{className:`absolute top-full mt-1.5 left-0 z-50 w-52 bg-paper-white border-[3px] border-ink-black gadget-shadow p-1.5 space-y-1`,role:`listbox`,children:[(0,U.jsx)(`div`,{className:`px-2 py-1 text-[8px] font-arcade font-bold text-trash-gray uppercase border-b border-slate-200`,children:`SELECT LANGUAGE`}),K.map(e=>{let t=re===e.id;return(0,U.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{ie(e.id),z(!1)},className:`w-full flex items-center justify-between px-2.5 py-1.5 border-2 border-ink-black text-left transition-all cursor-pointer ${t?`bg-amber-200 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] font-bold text-ink-black`:`bg-white hover:bg-slate-100 text-slate-800`}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[9px]`,children:[(0,U.jsx)(xe,{className:`w-3.5 h-3.5 shrink-0`}),(0,U.jsx)(`span`,{children:e.name})]}),(0,U.jsxs)(`span`,{className:`font-mono text-[8px] font-bold px-1.5 py-0.5 bg-white border border-ink-black text-slate-700 shadow-[1px_1px_0px_0px_rgba(30,41,59,0.3)]`,children:[`v`,e.version]})]},e.id)})]})]}),(0,U.jsx)(`div`,{className:`h-4 w-[2px] bg-slate-300 mx-0.5 hidden sm:block`}),(0,U.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>a(e.target.checked),className:`sr-only peer`,"aria-label":`Toggle code editor autocompletion`}),(0,U.jsx)(`div`,{className:`relative w-7 h-3.5 bg-slate-300 border border-ink-black rounded-full peer peer-checked:bg-grass-green transition-all after:content-[''] after:absolute after:top-[1px] after:left-[2px] after:bg-white after:border after:border-ink-black after:rounded-full after:h-2 after:w-2 after:transition-all peer-checked:after:translate-x-3`}),(0,U.jsx)(`span`,{className:`text-[7.5px] min-[400px]:text-[8px] font-arcade font-bold text-trash-gray peer-checked:text-ink-black whitespace-nowrap`,children:`AUTOCOMPLETE`})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,U.jsx)(`button`,{onClick:o,className:`w-7 h-7 bg-white hover:bg-slate-100 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-ink-black flex items-center justify-center cursor-pointer transition-all`,title:`Reset to starter code`,"aria-label":`Reset to starter code`,children:(0,U.jsx)(n,{className:`w-3.5 h-3.5`})}),(0,U.jsx)(`button`,{onClick:()=>p(``),className:`w-7 h-7 bg-white hover:bg-rose-50 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-rose-700 flex items-center justify-center cursor-pointer transition-all`,title:`Clear editor`,"aria-label":`Clear editor`,children:(0,U.jsx)(b,{className:`w-3.5 h-3.5 text-rose-600`})}),k&&(0,U.jsx)(`button`,{onClick:k,disabled:w||!d.trim(),className:`w-7 h-7 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all ${E?`bg-emerald-600 hover:bg-emerald-500 text-white`:`bg-amber-400 hover:bg-amber-300 text-ink-black`}`,title:w?`Saving solution to personal database...`:E?`Saved to personal database!`:`Overwrite saved solution with studio code`,"aria-label":`Overwrite saved solution with studio code`,children:w?(0,U.jsx)(s,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):E?(0,U.jsx)(g,{className:`w-3.5 h-3.5 text-white`}):(0,U.jsx)(c,{className:`w-3.5 h-3.5 text-ink-black`})}),F&&(0,U.jsx)(`button`,{onClick:F,disabled:I||!d.trim(),className:`w-7 h-7 bg-[#24292e] hover:bg-black border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:I?`Pushing to GitHub...`:`Push solution to GitHub repository`,"aria-label":`Push to GitHub`,children:I?(0,U.jsx)(s,{className:`w-3.5 h-3.5 animate-spin text-yellow-300`}):(0,U.jsx)(h,{className:`w-3.5 h-3.5 text-yellow-300`})})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,U.jsx)(`button`,{onClick:C,disabled:v||!d.trim(),className:`w-7 h-7 bg-emerald-600 hover:bg-emerald-500 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:v?`Running sandbox tests...`:`Run tests in local sandbox`,"aria-label":`Run tests`,children:v?(0,U.jsx)(s,{className:`w-3.5 h-3.5 animate-spin`}):(0,U.jsx)(l,{className:`w-3.5 h-3.5 fill-white text-white ml-0.5`})}),(0,U.jsx)(`button`,{onClick:N,disabled:A||!d.trim(),className:`w-7 h-7 bg-purple-600 hover:bg-purple-500 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:A?`Evaluating code with Gemini...`:`Gemini Eval (AI code review & complexity)`,"aria-label":`Gemini Eval`,children:A?(0,U.jsx)(s,{className:`w-3.5 h-3.5 animate-spin`}):(0,U.jsx)(O,{className:`w-3.5 h-3.5 text-amber-300`})})]})]}),(0,U.jsxs)(`div`,{className:`p-4 sm:p-5 flex-1 flex flex-col space-y-4`,children:[(0,U.jsx)(`div`,{className:`flex-1 flex flex-col min-h-[300px] sm:min-h-[360px] border-[3px] border-ink-black shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] bg-[#0c111d] overflow-hidden`,children:(0,U.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,U.jsx)(T,{value:d,onChange:p,placeholder:`def solve(nums):
5
+ # Write your solution from memory here...`,height:`100%`,theme:`dark`,extensions:be,basicSetup:{autocompletion:r,lineNumbers:!0,foldGutter:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,rectangularSelection:!0,crosshairCursor:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,closeBracketsKeymap:!0,defaultKeymap:!0,searchKeymap:!0,historyKeymap:!0,foldKeymap:!0,completionKeymap:!0,lintKeymap:!0},className:`w-full h-full text-xs font-code-mono`})})}),E&&(0,U.jsxs)(`div`,{className:`p-3 bg-[#f0fdf4] border-2 border-emerald-600 text-emerald-950 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,U.jsx)(g,{className:`w-4 h-4 text-emerald-600 shrink-0`}),(0,U.jsx)(`span`,{children:`Successfully saved studio code as your personal reference solution!`})]}),D&&(0,U.jsxs)(`div`,{className:`p-3 bg-rose-50 border-2 border-rose-500 text-rose-800 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,U.jsx)(m,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,U.jsx)(`span`,{children:D})]}),L&&(0,U.jsxs)(`div`,{className:`p-3 bg-[#f0fdf4] border-2 border-emerald-600 text-emerald-950 text-xs font-semibold flex items-center justify-between shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(g,{className:`w-4 h-4 text-emerald-600 shrink-0`}),(0,U.jsx)(`span`,{children:`Successfully pushed solution to your GitHub repository!`})]}),(0,U.jsxs)(`a`,{href:L,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] font-bold text-blue-700 hover:text-blue-900 underline flex items-center gap-1`,children:[(0,U.jsx)(`span`,{children:`View on GitHub`}),(0,U.jsx)(_,{className:`w-3 h-3`})]})]}),ne&&(0,U.jsxs)(`div`,{className:`p-3 bg-rose-50 border-2 border-rose-500 text-rose-800 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,U.jsx)(m,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,U.jsx)(`span`,{children:ne})]}),v&&(0,U.jsxs)(`div`,{className:`p-3 border-2 border-ink-black bg-emerald-50 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] flex items-center gap-3 animate-pulse`,children:[(0,U.jsx)(s,{className:`w-5 h-5 text-emerald-600 animate-spin shrink-0`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h4`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:`Running...`}),(0,U.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray font-semibold mt-0.5`,children:`Executing against test cases...`})]})]}),y&&(0,U.jsxs)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex items-center gap-2`,children:[(0,U.jsx)(m,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,U.jsx)(`span`,{children:y})]}),S&&(0,U.jsxs)(`div`,{className:`border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3.5 ${S.status===`passed`?`bg-[#f0fdf4]`:`bg-[#fff1f2]`}`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-2 pb-2.5 border-b-2 border-dashed border-ink-black`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,U.jsx)(`div`,{className:`w-8 h-8 border-2 border-ink-black flex items-center justify-center font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${S.status===`passed`?`bg-grass-green text-ink-black`:`bg-rose-500 text-white`}`,children:S.status===`passed`?(0,U.jsx)(u,{className:`w-5 h-5 stroke-[3]`}):(0,U.jsx)(m,{className:`w-4 h-4`})}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`font-arcade text-[10px] font-bold text-ink-black flex items-center gap-1.5 uppercase`,children:S.status===`passed`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{children:`ALL TESTS PASSED`}),(0,U.jsx)(g,{className:`w-3.5 h-3.5 text-emerald-600 inline`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{children:S.status===`error`?`EXECUTION ERROR`:`TESTS FAILED`}),(0,U.jsx)(x,{className:`w-3.5 h-3.5 text-rose-600 inline`})]})}),(0,U.jsxs)(`div`,{className:`font-sans text-[11px] text-slate-600 font-semibold`,children:[S.passed_count??0,` of `,S.total_tests??0,` test cases passed (`,(S.duration_ms??0).toFixed(1),`ms)`]})]})]}),S.status===`passed`&&(0,U.jsxs)(`button`,{onClick:k,disabled:w,className:`px-3 py-1.5 bg-white hover:bg-emerald-100 border-2 border-ink-black text-ink-black font-arcade text-[8px] font-bold flex items-center gap-1.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 disabled:opacity-50`,children:[w?(0,U.jsx)(s,{className:`w-3 h-3 animate-spin`}):E?(0,U.jsx)(g,{className:`w-3.5 h-3.5 text-emerald-600`}):(0,U.jsx)(c,{className:`w-3.5 h-3.5 text-blue-600`}),(0,U.jsx)(`span`,{children:E?`SAVED TO DB!`:`SAVE AS OFFICIAL SOLUTION`})]})]}),D&&(0,U.jsx)(`div`,{className:`p-2 border border-rose-500 bg-rose-100 text-rose-800 text-[11px] font-semibold`,children:D}),S.results&&S.results.length>0&&(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray uppercase font-bold block`,children:`TEST CASE BREAKDOWN:`}),(0,U.jsx)(`div`,{className:`space-y-1.5 max-h-56 overflow-y-auto custom-scrollbar`,children:S.results.map((e,t)=>(0,U.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black text-xs font-mono shadow-[2px_2px_0px_0px_rgba(30,41,59,0.3)] ${e.passed?`bg-white`:`bg-rose-50`}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between font-arcade text-[8px] mb-1`,children:[(0,U.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`CASE #`,t+1]}),(0,U.jsx)(`span`,{className:e.passed?`text-emerald-700 font-bold`:`text-rose-700 font-bold`,children:e.passed?`✓ PASSED`:`✗ FAILED`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-1.5 text-[10px]`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`text-slate-500 block`,children:`Input:`}),(0,U.jsx)(`span`,{className:`font-code-mono text-ink-black font-semibold break-all`,children:JSON.stringify(e.input)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`text-slate-500 block`,children:`Expected:`}),(0,U.jsx)(`span`,{className:`font-code-mono text-emerald-700 font-semibold break-all`,children:JSON.stringify(e.expected)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`text-slate-500 block`,children:`Output:`}),(0,U.jsx)(`span`,{className:`font-code-mono font-semibold break-all ${e.passed?`text-emerald-700`:`text-rose-700`}`,children:e.output===void 0?`None`:JSON.stringify(e.output)})]})]}),e.error&&(0,U.jsx)(`div`,{className:`mt-1.5 p-1.5 bg-rose-100 text-rose-900 text-[10px] font-mono border border-rose-300 break-all`,children:e.error})]},t))})]}),S.error&&(0,U.jsx)(`div`,{className:`p-3 bg-[#1E293B] text-rose-400 font-code-mono text-[11px] border-2 border-ink-black overflow-x-auto whitespace-pre-wrap select-text`,children:S.error}),S.status===`passed`&&(0,U.jsx)(`div`,{className:`p-2 bg-emerald-100/70 border border-emerald-300 text-emerald-900 text-xs flex items-center justify-between`,children:(0,U.jsx)(`span`,{className:`font-sans font-medium`,children:`✨ All unit tests passed. Rate your recall below.`})})]}),A&&(0,U.jsxs)(`div`,{className:`p-4 border-2 border-ink-black bg-amber-50 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] flex items-center gap-3 animate-pulse`,children:[(0,U.jsx)(s,{className:`w-6 h-6 text-purple-600 animate-spin shrink-0`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h4`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:`ANALYZING...`}),(0,U.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray font-semibold mt-0.5`,children:`Checking edge cases, bounds, and Big-O efficiency against optimal constraints...`})]})]}),j&&(0,U.jsx)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:j}),M&&(0,U.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-[#fefce8] p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between pb-3 border-b-2 border-dashed border-ink-black`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`w-9 h-9 border-2 border-ink-black flex items-center justify-center font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${M.is_correct?`bg-grass-green text-ink-black`:`bg-rose-500 text-white`}`,children:M.is_correct?(0,U.jsx)(u,{className:`w-5 h-5 stroke-[3]`}):(0,U.jsx)(i,{className:`w-5 h-5`})}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`font-arcade text-[10px] font-bold text-ink-black flex items-center gap-1.5`,children:M.is_correct?(0,U.jsxs)(U.Fragment,{children:[`STATUS: PASSED`,(0,U.jsx)(g,{className:`w-3.5 h-3.5 text-emerald-600 inline`})]}):(0,U.jsxs)(U.Fragment,{children:[`STATUS: FAILED`,(0,U.jsx)(x,{className:`w-3.5 h-3.5 text-rose-600 inline`})]})}),(0,U.jsx)(`span`,{className:`font-sans text-[11px] text-slate-600 font-semibold`,children:M.is_correct?`Algorithm matches expected logic and patterns.`:`Bugs or edge-case failures detected.`})]})]}),(0,U.jsx)(`span`,{className:`font-arcade text-[9px] px-2 py-1 border-2 border-ink-black uppercase font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${M.is_correct?`bg-emerald-100 text-emerald-800`:`bg-rose-100 text-rose-800`}`,children:M.is_correct?`CORRECT`:`INCORRECT`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,U.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase font-bold`,children:`Time Complexity`}),(0,U.jsxs)(`div`,{className:`flex items-baseline gap-2 mt-1`,children:[(0,U.jsx)(`span`,{className:`font-code-mono text-xs font-bold text-ink-black`,children:M.detected_complexity?.time||`N/A`}),(0,U.jsxs)(`span`,{className:`text-[10px] font-sans text-slate-500 font-semibold`,children:[`(Target: `,P||`O(N)`,`)`]})]})]}),(0,U.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,U.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase font-bold`,children:`Space Complexity`}),(0,U.jsxs)(`div`,{className:`flex items-baseline gap-2 mt-1`,children:[(0,U.jsx)(`span`,{className:`font-code-mono text-xs font-bold text-ink-black`,children:M.detected_complexity?.space||`N/A`}),(0,U.jsxs)(`span`,{className:`text-[10px] font-sans text-slate-500 font-semibold`,children:[`(Target: `,te||`O(1)`,`)`]})]})]})]}),M.bugs&&M.bugs.length>0&&(0,U.jsxs)(`div`,{className:`p-3 bg-white border-2 border-ink-black space-y-1.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,U.jsxs)(`span`,{className:`font-arcade text-[8px] text-rose-600 uppercase font-bold block flex items-center gap-1`,children:[(0,U.jsx)(m,{className:`w-3 h-3 text-rose-500`}),`TRACES & EDGE CASE ISSUES:`]}),(0,U.jsx)(`ul`,{className:`list-disc list-inside text-xs text-slate-800 space-y-1 font-semibold pl-1`,children:M.bugs.map((e,t)=>(0,U.jsx)(`li`,{className:`leading-relaxed select-text`,children:e},t))})]}),M.key_suggestion&&(0,U.jsxs)(`div`,{className:`p-3 bg-amber-50 border-2 border-ink-black space-y-1 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,U.jsxs)(`span`,{className:`font-arcade text-[8px] text-amber-700 uppercase font-bold block flex items-center gap-1`,children:[(0,U.jsx)(O,{className:`w-3 h-3 text-amber-500`}),`TIP:`]}),(0,U.jsx)(`p`,{className:`text-xs text-slate-800 font-medium leading-relaxed m-0 select-text`,children:M.key_suggestion})]}),(0,U.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-dashed border-ink-black flex items-center justify-between`,children:[(0,U.jsxs)(`span`,{className:`text-xs font-bold text-ink-black flex items-center gap-1.5`,children:[(0,U.jsx)(f,{className:`w-4 h-4 text-primary`}),`Recommendation:`]}),(0,U.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-purple-700`,children:M.is_correct?`Rate your recall below.`:`Review issues and rate recall below.`})]})]})]})]})},Ce=({gradeError:e,onDismissGradeError:t,submitting:n,submittingRating:r,onGrade:i})=>(0,U.jsx)(`div`,{className:`shrink-0 bg-[#f8f5eb] border-t-[3px] border-ink-black p-2 sm:p-3 flex flex-col items-stretch gap-1.5 sm:gap-2 shadow-[0_-3px_0_0_rgba(30,41,59,0.08)]`,children:(0,U.jsxs)(`div`,{className:`w-full flex flex-col`,children:[e&&(0,U.jsxs)(`div`,{className:`p-2.5 mb-2 bg-red-100 border-2 border-red-500 text-red-800 text-xs font-semibold shadow-[2px_2px_0px_0px_#1E293B] flex items-center justify-between`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(m,{className:`w-4 h-4 text-red-600 shrink-0`}),e]}),(0,U.jsx)(`button`,{onClick:t,className:`text-red-900 font-bold hover:underline cursor-pointer ml-2 text-xs`,children:`Dismiss`})]}),(0,U.jsxs)(`div`,{className:`flex gap-1.5 sm:gap-2.5 w-full`,children:[(0,U.jsx)(`button`,{onClick:()=>i(1),disabled:n,className:`flex-1 min-w-0 bg-[#dc2626] hover:bg-[#b91c1c] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-white flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 1 on keyboard`,children:r===1?(0,U.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,U.jsx)(s,{className:`w-3.5 h-3.5 animate-spin`})}):(0,U.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,U.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/20 rounded shrink-0`,children:`1`}),(0,U.jsx)(`span`,{className:`truncate`,children:`Again`})]})}),(0,U.jsx)(`button`,{onClick:()=>i(2),disabled:n,className:`flex-1 min-w-0 bg-[#ff9933] hover:bg-[#ff8000] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 2 on keyboard`,children:r===2?(0,U.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,U.jsx)(s,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,U.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,U.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`2`}),(0,U.jsx)(`span`,{className:`truncate`,children:`Hard`})]})}),(0,U.jsx)(`button`,{onClick:()=>i(3),disabled:n,className:`flex-1 min-w-0 bg-[#4ade80] hover:bg-[#22c55e] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 3 on keyboard`,children:r===3?(0,U.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,U.jsx)(s,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,U.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,U.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`3`}),(0,U.jsx)(`span`,{className:`truncate`,children:`Good`})]})}),(0,U.jsx)(`button`,{onClick:()=>i(4),disabled:n,className:`flex-1 min-w-0 bg-[#60a5fa] hover:bg-[#3b82f6] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 4 on keyboard`,children:r===4?(0,U.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,U.jsx)(s,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,U.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,U.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`4`}),(0,U.jsx)(`span`,{className:`truncate`,children:`Easy`})]})})]})]})}),we=({nextMilestone:e,activatingMilestone:t,onActivateNextMilestone:r,onOpenCardManager:i,onOpenJourney:a,onOpenCreateProblem:o,onOpenWindow:c,overrideProblemId:l,onClearOverride:d})=>(0,U.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] p-6 overflow-y-auto custom-scrollbar`,children:(0,U.jsxs)(`div`,{className:`w-full max-w-lg bg-paper-white border-[4px] border-ink-black gadget-shadow p-6 sm:p-8 relative overflow-hidden text-center space-y-6`,children:[(0,U.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-3 bg-gradient-to-r from-grass-green via-amber-300 to-highlight-pink`}),(0,U.jsxs)(`div`,{className:`relative inline-block mt-2`,children:[(0,U.jsx)(`div`,{className:`w-20 h-20 bg-amber-300 border-[3px] border-ink-black rounded-2xl flex items-center justify-center mx-auto gadget-shadow rotate-[-3deg] hover:rotate-0 transition-transform`,children:(0,U.jsx)(D,{className:`w-10 h-10 text-ink-black stroke-[2.5]`})}),(0,U.jsx)(`div`,{className:`absolute -bottom-2 -right-2 bg-grass-green border-2 border-ink-black px-2 py-0.5 font-arcade text-[8px] text-ink-black font-bold uppercase shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:`100% DONE`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-1 bg-emerald-100 border-2 border-ink-black text-emerald-800 font-arcade text-[9px] font-bold`,children:[(0,U.jsx)(u,{className:`w-3 h-3 stroke-[3]`}),` ALL CARDS COMPLETED FOR TODAY`]}),(0,U.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold text-ink-black font-headline-md tracking-tight`,children:`You're all caught up for today. Keep it up.`}),(0,U.jsx)(`p`,{className:`text-xs sm:text-sm font-sans text-trash-gray max-w-md mx-auto leading-relaxed font-semibold`,children:`All reviews for today are finished. Next reviews are scheduled for tomorrow.`})]}),e&&(0,U.jsxs)(`div`,{className:`p-4 sm:p-5 bg-gradient-to-br from-amber-50 to-orange-50 border-[3px] border-ink-black gadget-shadow text-left space-y-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-amber-800 uppercase tracking-wider flex items-center gap-1.5`,children:[(0,U.jsx)(w,{className:`w-3.5 h-3.5 text-amber-600`}),`NEXT UNEXPLORED MILESTONE`]}),(0,U.jsxs)(`span`,{className:`font-mono text-[10px] font-bold px-2 py-0.5 rounded bg-amber-900/10 text-amber-900 border border-amber-900/20`,children:[`LC #`,e.problem_number]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h3`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black truncate`,children:e.name}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 flex-wrap`,children:[(0,U.jsx)(`span`,{className:`px-2 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${e.difficulty===`Easy`?`bg-emerald-600`:e.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:e.difficulty}),(0,U.jsx)(`span`,{className:`px-2 py-0.5 rounded font-arcade text-[8px] bg-purple-100 text-purple-800 border border-purple-300 font-bold`,children:e.pattern}),(0,U.jsxs)(`span`,{className:`text-[11px] font-code-mono text-slate-600`,children:[`T: `,e.time_complexity,` | S: `,e.space_complexity]})]})]}),(0,U.jsx)(`button`,{onClick:r,disabled:t,className:`px-4 py-2.5 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 flex items-center justify-center gap-1.5 disabled:opacity-50`,children:t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(s,{className:`w-3.5 h-3.5 animate-spin`}),(0,U.jsx)(`span`,{children:`ACTIVATING...`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(O,{className:`w-3.5 h-3.5 text-amber-700`}),(0,U.jsx)(`span`,{children:`ACTIVATE & REVIEW NOW`})]})})]})]}),(0,U.jsxs)(`div`,{className:`p-4 sm:p-5 bg-gradient-to-r from-sky-100 via-sky-200 to-indigo-100 border-[3px] border-ink-black gadget-shadow text-left flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-sky-900 uppercase flex items-center gap-1.5`,children:[(0,U.jsx)(p,{className:`w-3.5 h-3.5 text-sky-700`}),`DECK BROWSER & CARD MANAGER`]}),(0,U.jsx)(`h3`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black`,children:`Want to Manage or Reschedule Cards?`}),(0,U.jsx)(`p`,{className:`font-sans text-xs text-trash-gray font-semibold max-w-md`,children:`Browse your full 150-card curriculum, reschedule intervals, or enroll new topics in the Anki-style Card Manager.`})]}),(0,U.jsxs)(`button`,{onClick:()=>{i?i():c?.(`cardManager`)},className:`px-4 py-2.5 bg-sky-400 hover:bg-sky-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 flex items-center gap-1.5`,children:[(0,U.jsx)(p,{className:`w-3.5 h-3.5 text-sky-950`}),(0,U.jsx)(`span`,{children:`OPEN CARD MANAGER`})]})]}),(0,U.jsxs)(`div`,{className:`border-t-[3px] border-dashed border-ink-black pt-5 space-y-3`,children:[(0,U.jsx)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold text-left`,children:`CONTINUE PRACTICING:`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2.5`,children:[(0,U.jsxs)(`button`,{onClick:a,className:`p-3 bg-amber-100 hover:bg-amber-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(w,{className:`w-4 h-4 text-amber-600`}),(0,U.jsx)(k,{className:`w-3 h-3 text-ink-black`})]}),(0,U.jsxs)(`div`,{className:`mt-2`,children:[(0,U.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Journey Trail`}),(0,U.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`150 Curated nodes`})]})]}),(0,U.jsxs)(`button`,{onClick:o,className:`p-3 bg-purple-100 hover:bg-purple-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(y,{className:`w-4 h-4 text-purple-700`}),(0,U.jsx)(k,{className:`w-3 h-3 text-ink-black`})]}),(0,U.jsxs)(`div`,{className:`mt-2`,children:[(0,U.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Add Problem`}),(0,U.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`New LeetCode entry`})]})]}),(0,U.jsxs)(`button`,{onClick:()=>c?.(`companion`),className:`p-3 bg-yellow-100 hover:bg-yellow-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:`material-symbols-outlined text-amber-600 text-lg`,children:`castle`}),(0,U.jsx)(k,{className:`w-3 h-3 text-ink-black`})]}),(0,U.jsxs)(`div`,{className:`mt-2`,children:[(0,U.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Princess Tower`}),(0,U.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`Visit Aurelia`})]})]}),(0,U.jsxs)(`button`,{onClick:()=>{i?i():c?.(`cardManager`)},className:`p-3 bg-cyan-100 hover:bg-cyan-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(S,{className:`w-4 h-4 text-cyan-700`}),(0,U.jsx)(k,{className:`w-3 h-3 text-ink-black`})]}),(0,U.jsxs)(`div`,{className:`mt-2`,children:[(0,U.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Card Manager`}),(0,U.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`Anki Deck Browser`})]})]})]})]}),l&&d&&(0,U.jsxs)(`button`,{onClick:d,className:`mt-3 bg-white hover:bg-slate-100 border-[3px] border-ink-black text-ink-black font-bold px-4 py-2 text-xs uppercase tracking-wide shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer inline-flex items-center gap-2`,children:[(0,U.jsx)(n,{className:`w-3.5 h-3.5`}),` Return to Scheduled Queue`]})]})}),Te=e({default:()=>De}),Ee=(0,H.lazy)(()=>L(()=>import(`./ProblemSpecPanel-BRW8UyO6.js`).then(e=>({default:e.ProblemSpecPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])));function De({overrideProblemId:e,onClearOverride:t,onOpenWindow:r,onOpenJourney:i,onOpenCreateProblem:a,onOpenEditProblem:o,onOpenCardManager:c,refreshTrigger:l}){let[u,f]=(0,H.useState)(null),p=u!==null&&u<780,[h,g]=(0,H.useState)(`spec`),[_,y]=(0,H.useState)(`spec`),[b,x]=(0,H.useState)(null),S=(0,H.useCallback)(e=>{e&&(f(e.clientWidth),new ResizeObserver(e=>{for(let t of e)f(t.contentRect.width)}).observe(e))},[]),[w,T]=(0,H.useState)(()=>localStorage.getItem(`isAutocompleteEnabled`)!==`false`),{reviews:D,setReviews:O,loading:ee,queueError:k,submitting:A,submittingRating:j,gradeError:M,setGradeError:N,code:P,setCode:te,nextMilestone:I,activatingMilestone:L,fetchQueue:ie,handleGrade:R,handleSelectCard:z,handleActivateNextMilestone:B,handleResetStarterCode:V}=fe({overrideProblemId:e,refreshTrigger:l,onClearOverride:t}),{sandboxRunning:ae,sandboxResults:oe,sandboxError:se,savingReference:ce,savedRefSuccess:de,saveRefError:W,handleRunSandbox:ge,handleSaveReference:_e,resetSandbox:G}=pe(),{aiLoading:ve,aiResult:ye,aiError:be,explainLoading:K,explanationText:xe,explainError:Te,aiSolutionLoading:De,aiSolutionError:Oe,handleAiEvaluation:ke,handleExplainCode:Ae,handleFetchAiSolution:je,resetAiState:q}=me(),[Me,Ne]=(0,H.useState)(!1),[Pe,Fe]=(0,H.useState)(null),[Ie,J]=(0,H.useState)(null),Le=(0,H.useCallback)(async()=>{if(D.length===0)return;let e=D[0]?.problems||{},t=P.trim()||e.reference_code||``;if(!t){J(`Please write or save code before pushing to GitHub.`),setTimeout(()=>J(null),4e3);return}let n=re();if(!n.token){r&&r(`github`);return}Ne(!0),J(null),Fe(null);try{let r=await ne({token:n.token,repo:n.repoName,branch:n.branch,problem_number:e.problem_number,problem_name:e.name||`Algorithm Problem`,pattern:e.pattern||`Algorithms`,difficulty:e.difficulty||`Medium`,optimal_time:e.optimal_time||`O(N)`,optimal_space:e.optimal_space||`O(1)`,description:e.description||``,code:t});Fe(r.html_url),setTimeout(()=>Fe(null),8e3)}catch(e){J(e.message||`Failed to push solution to GitHub.`),setTimeout(()=>J(null),5e3)}finally{Ne(!1)}},[D,P,r]),Re=D[0]?.id||D[0]?.problem_id,ze=(0,H.useRef)(void 0);(0,H.useEffect)(()=>{Re&&ze.current!==Re&&(ze.current=Re,q(),G())},[Re,q,G]);let Y=(0,H.useCallback)(e=>{q(),G(),R(e)},[R,q,G]),Be=(0,H.useCallback)(e=>{q(),G(),z(e)},[z,q,G]);(0,H.useEffect)(()=>{let e=e=>{let t=e.target;t?.closest(`.cm-editor`)||t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable||D.length===0||A||(e.key===`1`?(e.preventDefault(),Y(1)):e.key===`2`?(e.preventDefault(),Y(2)):e.key===`3`?(e.preventDefault(),Y(3)):e.key===`4`&&(e.preventDefault(),Y(4)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Y,D.length,A]);let Ve=(e,t)=>{navigator.clipboard.writeText(e),x(t),setTimeout(()=>x(null),1800)},He=(0,H.useCallback)(()=>{i?i():r?.(`journey`)},[i,r]),Ue=(0,H.useCallback)(()=>{a?a():r?.(`createProblem`)},[a,r]),We=(0,H.useCallback)(e=>{O(t=>{if(t.length===0)return t;let n=[...t],r=n[0];return r&&r.problems&&(r.problems={...r.problems,solutions:e}),n})},[O]);if(ee)return(0,U.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] text-ink-black`,children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-4 p-8 bg-paper-white border-[3px] border-ink-black gadget-shadow text-center max-w-xs`,children:[(0,U.jsx)(`div`,{className:`w-12 h-12 bg-amber-200 border-2 border-ink-black flex items-center justify-center animate-spin`,children:(0,U.jsx)(s,{className:`w-6 h-6 text-ink-black`})}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`font-arcade text-xs text-ink-black uppercase tracking-wider font-bold`,children:`LOADING QUEUE`}),(0,U.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray mt-1 font-semibold`,children:`Fetching scheduled FSRS review cards...`})]})]})});if(k&&D.length===0)return(0,U.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] p-6 overflow-y-auto custom-scrollbar`,children:(0,U.jsxs)(`div`,{className:`w-full max-w-md bg-paper-white border-[4px] border-ink-black gadget-shadow p-6 sm:p-8 relative overflow-hidden text-center space-y-6`,children:[(0,U.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-3 bg-gradient-to-r from-red-500 via-amber-400 to-red-500`}),(0,U.jsxs)(`div`,{className:`relative inline-block mt-2`,children:[(0,U.jsx)(`div`,{className:`w-20 h-20 bg-rose-200 border-[3px] border-ink-black rounded-2xl flex items-center justify-center mx-auto gadget-shadow rotate-[-2deg]`,children:(0,U.jsx)(C,{className:`w-10 h-10 text-rose-700 stroke-[2.5]`})}),(0,U.jsx)(`div`,{className:`absolute -bottom-2 -right-2 bg-rose-500 text-white border-2 border-ink-black px-2 py-0.5 font-arcade text-[8px] font-bold uppercase shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:`OFFLINE`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-1 bg-rose-100 border-2 border-ink-black text-rose-800 font-arcade text-[9px] font-bold`,children:[(0,U.jsx)(m,{className:`w-3.5 h-3.5 stroke-[2.5] text-rose-600`}),` CONNECTION ERROR`]}),(0,U.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold text-ink-black font-headline-md tracking-tight`,children:`Queue Unavailable`}),(0,U.jsx)(`p`,{className:`font-sans text-xs sm:text-sm text-trash-gray font-semibold leading-relaxed max-w-sm mx-auto`,children:`Unable to reach the server to fetch your scheduled review cards. Check your connection or retry below.`})]}),(0,U.jsxs)(`div`,{className:`pt-2 flex flex-col sm:flex-row gap-3 justify-center items-center`,children:[(0,U.jsxs)(`button`,{onClick:()=>void ie(!0),className:`w-full sm:w-auto px-6 py-2.5 bg-amber-300 hover:bg-amber-400 border-[3px] border-ink-black font-arcade text-xs font-bold text-ink-black gadget-shadow active:translate-x-0.5 active:translate-y-0.5 active:shadow-none transition-all flex items-center justify-center gap-2 cursor-pointer`,children:[(0,U.jsx)(n,{className:`w-4 h-4`}),(0,U.jsx)(`span`,{children:`RETRY CONNECTION`})]}),(i||r)&&(0,U.jsx)(`button`,{onClick:He,className:`w-full sm:w-auto px-5 py-2.5 bg-paper-white hover:bg-warm-sand-bg border-[3px] border-ink-black font-arcade text-xs font-bold text-ink-black gadget-shadow active:translate-x-0.5 active:translate-y-0.5 active:shadow-none transition-all flex items-center justify-center gap-2 cursor-pointer`,children:(0,U.jsx)(`span`,{children:`OPEN JOURNEY MAP`})})]})]})});if(D.length===0)return(0,U.jsx)(we,{nextMilestone:I,activatingMilestone:L,onActivateNextMilestone:B,onOpenCardManager:c||(()=>r?.(`cardManager`)),onOpenJourney:He,onOpenCreateProblem:Ue,onOpenWindow:r,overrideProblemId:e,onClearOverride:t});let X=D[0],Z=X?.problems,Ge=Z?.problem_number??(/^\d+$/.test(X?.problem_id||``)?parseInt(X.problem_id,10):void 0),Q=F(Ge,Z?.id||X?.problem_id,Z?.name),{cleanTitle:Ke,approachVariant:qe,pattern:Je}=ue(Z?.name,Q?.name,Z?.pattern,Q?.pattern),$={...Q,...Z,id:Z?.id||Q?.id||X?.problem_id,name:Ke,problem_number:Z?.problem_number??Q?.problem_number,pattern:Je,approach_variant:qe,difficulty:Z?.difficulty||Q?.difficulty||`Medium`,reference_code:Z?.reference_code||Q?.reference_solution||``,starter_code:Q?.starter_code||Z?.starter_code||``,description:Z?.description||Q?.description||``,optimal_time:Z?.optimal_time||Q?.time_complexity||`O(N)`,optimal_space:Z?.optimal_space||Q?.space_complexity||`O(1)`,examples:Z?.examples&&Z.examples.length>0?Z.examples:Q?.examples,constraints:Z?.constraints||Q?.constraints,how_to_solve:Z?.how_to_solve||``,solutions:Z?.solutions&&Z.solutions.length>0?Z.solutions:Q?.solutions},Ye=le({...Q,...$,examples:$.examples&&$.examples.length>0?$.examples:Q?.examples,constraints:$.constraints&&(Array.isArray($.constraints)?$.constraints.length>0:$.constraints)?$.constraints:Q?.constraints}),Xe=Q?.reference_solution||``,Ze=Z?.reference_code||``,Qe=Ze&&(!Xe||Ze.trim()!==Xe.trim())?Ze:``,$e=Qe||Xe||Ze||``;return(0,U.jsxs)(`div`,{ref:S,className:`w-full h-full bg-[#fdf8e1] flex flex-col overflow-hidden select-none`,children:[(0,U.jsx)(he,{problem:$,totalInQueue:D.length,reviews:D,overrideProblemId:e,onSelectCard:Be,onOpenCreateProblem:Ue,onOpenEditProblem:()=>{o?o($):r?.(`editProblem`)}}),(0,U.jsxs)(`div`,{className:`${p?`flex`:`hidden`} shrink-0 bg-amber-100 border-b-[3px] border-ink-black px-2.5 sm:px-3 py-1.5 gap-1.5 sm:gap-2 overflow-x-auto no-scrollbar`,children:[(0,U.jsxs)(`button`,{onClick:()=>{y(`spec`),g(`spec`)},className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${_===`spec`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,U.jsx)(E,{className:`w-3 h-3 shrink-0`}),(0,U.jsx)(`span`,{children:`SPEC`})]}),(0,U.jsxs)(`button`,{onClick:()=>y(`code`),className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${_===`code`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,U.jsx)(v,{className:`w-3 h-3 shrink-0`}),(0,U.jsx)(`span`,{children:`CODE STUDIO`})]}),(0,U.jsxs)(`button`,{onClick:()=>{y(`ref`),g(`ref`)},className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${_===`ref`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,U.jsx)(d,{className:`w-3 h-3 shrink-0`}),(0,U.jsx)(`span`,{children:`SOLUTION`})]})]}),(0,U.jsxs)(`div`,{className:`flex-1 flex ${p?`flex-col`:`flex-row`} overflow-hidden min-h-0`,children:[(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-8 bg-paper-white ${p?`h-64`:`border-r-[4px] border-ink-black`} font-sans text-xs text-trash-gray select-none`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2 font-arcade text-[10px] text-ink-black`,children:[(0,U.jsx)(s,{className:`w-4 h-4 animate-spin text-[#0ea5e9]`}),(0,U.jsx)(`span`,{children:`Loading Problem Spec...`})]})}),children:(0,U.jsx)(Ee,{leftTab:h,onSelectLeftTab:e=>{g(e),e===`ref`?y(`ref`):e===`spec`&&y(`spec`)},mobileView:_,isNarrow:p,problem:$,parsed:Ye,userSolution:Qe,officialSolution:Xe,effectiveReferenceCode:$e,copiedSnippet:b,onCopyText:Ve,saveRefError:W,aiSolutionLoading:De,aiSolutionError:Oe,onFetchAiSolution:()=>je(X,e=>{O(t=>t.map((t,n)=>n===0?{...t,problems:{...$||{},...t.problems||{},reference_code:e}}:t))}),explainLoading:K,explainError:Te,explanationText:xe,onExplainCode:(e,t,n,r)=>Ae(X,e,t,n,r),activeReview:X,onUpdateSolutions:We,onEditProblem:()=>{o?o($):r?.(`editProblem`)}})}),(0,U.jsx)(Se,{mobileView:_,isNarrow:p,isAutocompleteEnabled:w,onToggleAutocomplete:e=>{T(e),localStorage.setItem(`isAutocompleteEnabled`,String(e))},onResetStarterCode:V,code:P,onChangeCode:te,sandboxRunning:ae,sandboxError:se,sandboxResults:oe,onRunSandbox:()=>ge(X,P),savingReference:ce,savedRefSuccess:de,saveRefError:W,onSaveReference:()=>_e(X,P,(e,t)=>{O(n=>n.map((n,r)=>r===0?{...n,problem_id:t||n.problem_id,problems:{...$||{},...n.problems||{},id:t||n.problems?.id||n.problem_id,reference_code:e}}:n))}),aiLoading:ve,aiError:be,aiResult:ye,onAiEvaluation:()=>ke(X,P),optimalTime:$.optimal_time||`O(N)`,optimalSpace:$.optimal_space||`O(1)`,onPushToGitHub:Le,pushingToGitHub:Me,githubPushedUrl:Pe,githubPushError:Ie})]}),(0,U.jsx)(Ce,{gradeError:M,onDismissGradeError:()=>N(null),submitting:A,submittingRating:j,onGrade:Y})]})}export{De as default,de as n,Te as t};
algospaced-ui/dist/assets/ReviewQueue-DmsrlLxn.js DELETED
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProblemSpecPanel-CLbwqTwe.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-react-CIO8MTK1.js","assets/vendor-codemirror-By0wlJeM.js","assets/index-DnK6BACV.js","assets/firebaseClient-DZobvwSx.js","assets/vendor-firebase-DSIO3PIf.js","assets/vendor-ui-ZXcm-2wU.js","assets/index-tlaKBeUb.css","assets/MarkdownRenderer-BMZIn30p.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{A as n,Bt as r,Ct as i,E as a,J as o,M as s,N as c,O as l,Q as u,Rt as d,St as f,Z as p,a as m,d as h,dt as g,ft as _,gt as v,it as y,ot as b,p as x,s as S,t as C,tt as w,u as T,ut as E,vt as D,y as O,yt as k}from"./vendor-react-CIO8MTK1.js";import{r as A,s as j}from"./firebaseClient-DZobvwSx.js";import{b as M,c as N,n as P,o as F,r as I,s as L,t as R}from"./index-DnK6BACV.js";import{o as ee,r as te}from"./githubSyncService-x0Mm_uEl.js";import{t as ne}from"./confetti.module-Uxh4CK4s.js";import re from"./OnboardingModal-DmgTXeeL.js";import"./MarkdownRenderer-BMZIn30p.js";import"./PrincessChamber-5t89aBn-.js";import{A as z,C as B,I as V,S as H,p as ie,t as ae,x as oe,y as se}from"./vendor-codemirror-By0wlJeM.js";var U=t(r(),1),W=d();function ce(e){if(!e)return{description:``,examples:[],constraints:[]};let t=e.description||``,n=[],r=[];if(Array.isArray(e.examples)&&e.examples.length>0&&(n=e.examples.map(e=>typeof e==`string`?{input:e,output:``}:{input:e?.input||``,output:e?.output||``,explanation:e?.explanation||``})),Array.isArray(e.constraints)&&e.constraints.length>0?r=e.constraints.map(e=>String(e).replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean):typeof e.constraints==`string`&&e.constraints.trim()&&(r=e.constraints.split(`
3
- `).map(e=>e.replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean)),n.length===0||r.length===0){let e=t.search(/\bExample\s*\d*:/i),i=t.search(/\bConstraints\s*:/i),a=-1;if(e!==-1&&i!==-1?a=Math.min(e,i):e===-1?i!==-1&&(a=i):a=e,a!==-1){let e=t.substring(0,a).trim(),i=t.substring(a),o=i,s=``,c=i.search(/\bConstraints\s*:/i);if(c!==-1&&(o=i.substring(0,c).trim(),s=i.substring(c).replace(/\bConstraints\s*:/i,``).trim()),n.length===0&&o){let e=/\bExample\s*(\d*)\s*:/gi,t=[],r;for(;(r=e.exec(o))!==null;)t.push({index:r.index,text:r[0]});for(let e=0;e<t.length;e++){let r=t[e].index+t[e].text.length,i=e+1<t.length?t[e+1].index:o.length,a=o.substring(r,i).trim(),s=a.match(/Input:\s*([\s\S]+?)(?=(?:Output:|Explanation:|$))/i),c=a.match(/Output:\s*([\s\S]+?)(?=(?:Explanation:|$))/i),l=a.match(/Explanation:\s*([\s\S]+)/i),u=s?s[1].trim():``,d=c?c[1].trim():``,f=l?l[1].trim():``;u||d?n.push({input:u,output:d,explanation:f}):a&&n.push({input:a,output:``,explanation:``})}}r.length===0&&s&&(r=s.split(`
4
- `).map(e=>e.replace(/^[\u2022\-*]\s*/,``).trim()).filter(Boolean)),(n.length>0||r.length>0)&&(t=e)}}return{description:t,examples:n,constraints:r}}function le(e,t,n,r){let i=e=>!e||/^Method\s*\d*$/i.test(e.trim())||e.trim().toLowerCase()===`standard`,a=(e||t||`Algorithm Problem`).trim(),o=null;if(t&&a.toLowerCase().startsWith(t.toLowerCase())){let e=a.slice(t.length).trim();if(a=t,e){let t=e.match(/^[-\s]*Method\s*(\d+)\s*\((.+)\)$/i);if(t){let e=parseInt(t[1],10),n=t[2].trim();i(n)?e>1&&(o=`Method ${e}`):o=n}else{let t=e.match(/^[-\s]*Method\s*(\d+)/i);if(t){let e=parseInt(t[1],10);e>1&&(o=`Method ${e}`)}else{let t=e.match(/^[-\s]*\((.+)\)$/);if(t){let e=t[1].trim();i(e)||(o=e)}else{let t=e.match(/^[-\s]+([^-]+)$/);t&&!i(t[1])&&(o=t[1].trim())}}}}}else{let e=a.match(/^(.*?)\s*-\s*Method\s*(\d+)\s*\((.+)\)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10),n=e[3].trim();i(n)?t>1&&(o=`Method ${t}`):o=n}else{let e=a.match(/^(.*?)\s*-\s*Method\s*(\d+)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10);t>1&&(o=`Method ${t}`)}else{let e=a.match(/^(.*?)\s*\(\s*Method\s*(\d+)\s*\)$/i);if(e){a=e[1].trim();let t=parseInt(e[2],10);t>1&&(o=`Method ${t}`)}}}}let s=`General Algorithm`;return i(n)?i(r)?o&&!i(o)&&(s=o):s=r.trim():s=n.trim(),{cleanTitle:a,approachVariant:o,pattern:s}}function ue(e,t,n){if(!e)return[];if(Array.isArray(e.solutions)&&e.solutions.length>0)return e.solutions;let r=[],i=t||e.reference_code||``,a=e.pattern||`General Algorithm`,o=e.optimal_time||`O(N)`,s=e.optimal_space||`O(1)`;return(i||a)&&r.push({id:`sol-1`,name:e.approach_variant||`Optimal Solution`,pattern:a,time_complexity:o,space_complexity:s,code:i,explanation:e.how_to_solve||``,is_optimal:!0}),n&&n.trim()&&n.trim()!==i.trim()&&r.push({id:`sol-2`,name:`Personal Solution`,pattern:a,time_complexity:o,space_complexity:s,code:n,is_optimal:!1}),r}function de(e){if(e&&e!==`sandbox-user-id`)return e;try{let e=A();if(e?.user?.id&&e.user.id!==`sandbox-user-id`)return e.user.id}catch{}return`guest`}function fe({overrideProblemId:e,refreshTrigger:t,onClearOverride:n,onOpenOnboarding:r,setIsOnboardingOpen:i}){let[a,o]=(0,U.useState)([]),[s,c]=(0,U.useState)(!0),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(null),[_,v]=(0,U.useState)(``),[y,b]=(0,U.useState)(null),[x,S]=(0,U.useState)(!1),[C,w]=(0,U.useState)(()=>{try{return A()?.user?.id}catch{return}}),T=(0,U.useRef)(!1),E=(0,U.useRef)(r),D=(0,U.useRef)(i),O=(0,U.useRef)(n),k=(0,U.useRef)(!1);(0,U.useEffect)(()=>{E.current=r,D.current=i,O.current=n});let P=(0,U.useCallback)(()=>{E.current?E.current():D.current&&D.current(!0)},[]),F=(0,U.useCallback)(async(t=!0)=>{t?(c(!0),g(null),u(null),v(``),T.current=!1):g(null);let n=de(C);try{if(typeof navigator<`u`&&!navigator.onLine)throw Error(`Network connection offline.`);let{data:{session:r}}=await j.auth.getSession(),i=r?r.access_token:`sandbox`;r?.user?.id&&(w(r.user.id),n=de(r.user.id));let a={Authorization:`Bearer ${i}`},s=new AbortController,c=setTimeout(()=>s.abort(),4e3),l;try{l=await fetch(`/api/reviews/due`,{headers:a,signal:s.signal})}finally{clearTimeout(c)}if(!l.ok)throw Error(`Failed to load review queue: HTTP ${l.status}`);let d=await l.json();if(Array.isArray(d)||(d=[]),e){let t=String(e).trim().toLowerCase(),n=d.findIndex(e=>{let n=e.problems;return!!(e.problem_id&&String(e.problem_id).trim().toLowerCase()===t||n?.id&&String(n.id).trim().toLowerCase()===t||n?.problem_number!==void 0&&n?.problem_number!==null&&String(n.problem_number)===t||n?.name&&n.name.trim().toLowerCase()===t)});if(n>0){let[e]=d.splice(n,1);d.unshift(e)}else if(n===-1){let t=null,n=await fetch(`/api/reviews/problems/id/${e}`,{headers:a});if(n.ok){let e=await n.json();Array.isArray(e)&&e.length>0&&(t=e[0])}if(!t){let n=/^\d+$/.test(e),r=I(n?parseInt(e,10):void 0,e);if(r)try{let e=await N(r);if(e?.problem_id){let n=await fetch(`/api/reviews/problems/id/${e.problem_id}`,{headers:a});if(n.ok){let e=await n.json();Array.isArray(e)&&e.length>0&&(t=e[0])}}}catch(e){console.error(`Failed to auto-activate problem for override review:`,e)}}t&&d.unshift(t)}}o(d),u(null);try{localStorage.setItem(`algospaced_review_queue_${n}`,JSON.stringify(d))}catch{}let f=r?.user?.id,p=f===`sandbox-user-id`||!f?`sandbox`:f;if(!localStorage.getItem(`algospaced_onboarding_done_${p}`)&&!e&&P(),d&&d.length>0){if(t){let e=d[0],t=e.problems,n=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),r=I(n,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;v(r)}}else try{let e=await fetch(`/api/journey-progress`,{headers:a});if(e.ok){let t=await e.json();b(L(new Set(t))??null)}else b(L(new Set)??null)}catch{b(L(new Set)??null)}}catch(e){console.error(`Error fetching review queue:`,e);let r=e instanceof Error?e.message:`Network error loading review queue.`,i=!1;try{let e=localStorage.getItem(`algospaced_review_queue_${n}`);if(e){let n=JSON.parse(e);if(Array.isArray(n)&&n.length>0&&(o(n),i=!0,u(null),t)){let e=n[0],t=e.problems,r=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=I(r,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;v(i)}}}catch(e){console.warn(`Failed to parse cached review items:`,e)}i||u(r)}finally{c(!1)}},[e,P,C]);(0,U.useEffect)(()=>{if(k.current){k.current=!1;return}let e=!1,t=setTimeout(()=>{e||F(!0)},0);return()=>{e=!0,clearTimeout(t)}},[F,t]),(0,U.useEffect)(()=>{if(!s&&!l&&a.length===0&&!e&&!T.current){T.current=!0;try{ne({particleCount:90,spread:70,origin:{y:.6}})}catch{}}},[s,l,a.length,e]);let R=(0,U.useCallback)(async t=>{if(a.length===0||d)return;let n=a[0];if(!n||!n.id)return;f(!0),m(t),g(null);let r=[...a];try{let{data:{session:i}}=await j.auth.getSession(),a=i?i.access_token:`sandbox`,s=await fetch(`/api/reviews/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${a}`},body:JSON.stringify({review_id:n.id,fsrs_state:n.fsrs_state??0,fsrs_stability:n.fsrs_stability??0,fsrs_difficulty:n.fsrs_difficulty??0,fsrs_elapsed_days:n.fsrs_elapsed_days??0,fsrs_scheduled_days:n.fsrs_scheduled_days??0,fsrs_reps:n.fsrs_reps??0,fsrs_lapses:n.fsrs_lapses??0,last_reviewed:n.last_reviewed,rating:t})});if(s.ok){let r=n?.problems?.name||``,i=n?.problems?.pattern||``,a=`Correct`;a=t===1?`Incorrect`:t===2?`Mixed`:`Correct`,M.addReviewEvent(a,r,i).catch(()=>{});let s=te(),c=_.trim()||n?.problems?.reference_code||``;s.token&&s.repoName&&s.autoCommit&&c&&ee({token:s.token,repo:s.repoName,branch:s.branch,problem_number:n?.problems?.problem_number,problem_name:r||`Algorithm Problem`,pattern:i||`Algorithms`,difficulty:n?.problems?.difficulty||`Medium`,optimal_time:n?.problems?.optimal_time||`O(N)`,optimal_space:n?.problems?.optimal_space||`O(1)`,description:n?.problems?.description||``,code:c}).catch(e=>{console.warn(`GitHub background auto-commit failed:`,e)}),e&&O.current&&(k.current=!0,O.current()),o(e=>{let t=e.slice(1);try{let e=de(C);localStorage.setItem(`algospaced_review_queue_${e}`,JSON.stringify(t))}catch{}if(t.length>0){let e=t[0],n=e.problems,r=n?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),i=I(r,n?.id||e?.problem_id,n?.name)?.starter_code||n?.starter_code||``;v(i)}else v(``);return t}),u(null),F(!1)}else{let e=await s.json().catch(()=>({}));g(e.detail||`Server returned error (${s.status}). Please try again.`),o(r)}}catch(e){console.error(`Error logging review completion:`,e);let t=e instanceof Error?e.message:`Network connection failed while logging review.`;g(t),o(r)}finally{f(!1),m(null)}},[a,d,e,F,_,C]),re=(0,U.useCallback)(async()=>{if(y&&!x){S(!0);try{await N(y),await F()}catch(e){console.error(`Failed to activate next milestone:`,e)}finally{S(!1)}}},[y,x,F]),z=(0,U.useCallback)(()=>{let e=a[0],t=e?.problems,n=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),r=I(n,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;v(r)},[a]);return{reviews:a,setReviews:o,loading:s,queueError:l,submitting:d,submittingRating:p,gradeError:h,setGradeError:g,code:_,setCode:v,nextMilestone:y,activatingMilestone:x,currentUserId:C,fetchQueue:F,handleGrade:R,handleSelectCard:(0,U.useCallback)(t=>{if(t<=0||t>=a.length||d)return;e&&O.current&&(k.current=!0,O.current());let n=a[t];if(!n)return;let r=n.problems,i=r?.problem_number??(/^\d+$/.test(n?.problem_id||``)?parseInt(n.problem_id,10):void 0),s=I(i,r?.id||n?.problem_id,r?.name)?.starter_code||r?.starter_code||``;v(s),o(e=>{let t=e.findIndex(e=>e.id&&e.id===n.id||e===n);return t<=0?e:[e[t],...e.slice(0,t),...e.slice(t+1)]})},[a,d,e]),handleActivateNextMilestone:re,handleResetStarterCode:z}}function pe(){return{sandboxRunning:P(e=>e.sandboxRunning),sandboxResults:P(e=>e.sandboxResults),sandboxError:P(e=>e.sandboxError),savingReference:P(e=>e.savingReference),savedRefSuccess:P(e=>e.savedRefSuccess),saveRefError:P(e=>e.saveRefError),handleRunSandbox:P(e=>e.handleRunSandbox),handleSaveReference:P(e=>e.handleSaveReference),resetSandbox:P(e=>e.resetSandbox)}}function me(){return{aiLoading:P(e=>e.aiLoading),aiResult:P(e=>e.aiResult),aiError:P(e=>e.aiError),explainLoading:P(e=>e.explainLoading),explanationText:P(e=>e.explanationText),explainError:P(e=>e.explainError),aiSolutionLoading:P(e=>e.aiSolutionLoading),aiSolutionError:P(e=>e.aiSolutionError),handleAiEvaluation:P(e=>e.handleAiEvaluation),handleExplainCode:P(e=>e.handleExplainCode),handleFetchAiSolution:P(e=>e.handleFetchAiSolution),resetAiState:P(e=>e.resetAiState)}}var he=({problem:e,totalInQueue:t,reviews:n=[],onSelectCard:r,onOpenCreateProblem:i,onOpenEditProblem:a})=>{let[o,l]=(0,U.useState)(!1),u=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&l(!1)},t=e=>{e.key===`Escape`&&l(!1)};return o&&(document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t)),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]);let d=e.problem_number?`https://leetcode.com/problemset/all/?search=${e.problem_number}`:`https://leetcode.com/problemset/all/?search=${encodeURIComponent(e.name||``)}`;return(0,W.jsxs)(`div`,{className:`shrink-0 bg-paper-white border-b-[3px] border-ink-black px-2.5 sm:px-4 py-2 flex flex-wrap items-center justify-between gap-2 shadow-[0_2px_0_0_rgba(30,41,59,0.05)] relative z-40`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap min-w-0`,children:[(0,W.jsxs)(`div`,{className:`relative shrink-0`,ref:u,children:[(0,W.jsxs)(`button`,{onClick:()=>l(e=>!e),className:`h-7 inline-flex items-center gap-1.5 px-2 sm:px-2.5 bg-amber-300 hover:bg-amber-200 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Click to view all cards due in today's queue`,children:[(0,W.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-ping shrink-0`}),(0,W.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] font-bold text-ink-black tracking-wide whitespace-nowrap`,children:`CARD 1 OF ${t}`}),t>1&&(0,W.jsx)(D,{className:`w-3 h-3 text-ink-black transition-transform shrink-0 ${o?`rotate-180`:``}`})]}),o&&n.length>0&&(0,W.jsxs)(`div`,{className:`absolute top-9 left-0 z-50 w-64 min-[400px]:w-72 sm:w-80 bg-paper-white border-[3px] border-ink-black gadget-shadow p-3 space-y-2 max-w-[calc(100vw-32px)]`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-b-2 border-ink-black pb-1.5 font-arcade text-[9px] font-bold text-ink-black`,children:[(0,W.jsx)(`span`,{children:`DAILY QUEUE (${n.length} CARDS)`}),(0,W.jsx)(`button`,{onClick:()=>l(!1),className:`px-1 hover:text-rose-600 font-bold cursor-pointer`,title:`Close`,children:`✕`})]}),(0,W.jsx)(`div`,{className:`text-[7.5px] font-arcade text-trash-gray uppercase -mt-0.5`,children:`Click any card to solve it now:`}),(0,W.jsx)(`div`,{className:`max-h-60 overflow-y-auto no-scrollbar space-y-1.5 pr-1`,children:n.map((e,t)=>{let n=e.problems,i=n?.problem_number,a=i==null?void 0:F(i),{cleanTitle:o,approachVariant:c}=le(n?.name||``,a?.name),u=c?`${o} (${c})`:o,d=t===0,f=n?.difficulty,p=f?f.toUpperCase():`EASY`,m=f===`Easy`?`bg-emerald-600 text-white`:f===`Medium`?`bg-amber-400 text-ink-black`:`bg-rose-600 text-white`;return(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{d||r?.(t),l(!1)},className:`group w-full text-left p-2 border-2 border-ink-black text-xs flex items-center justify-between gap-2 cursor-pointer transition-all duration-150 select-none ${d?`bg-amber-100 font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`:`bg-white hover:bg-amber-50 hover:translate-x-0.5 active:translate-y-0.5 active:shadow-none shadow-[2px_2px_0px_0px_rgba(30,41,59,0.25)]`}`,title:d?`Currently active card`:`Jump to #${t+1}: ${u}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 truncate min-w-0`,children:[(0,W.jsxs)(`span`,{className:`font-arcade text-[9px] text-trash-gray shrink-0`,children:[`#`,t+1]}),i!=null&&(0,W.jsxs)(`span`,{className:`font-arcade text-[8px] font-bold px-1 py-0.2 bg-amber-300 border border-ink-black shrink-0`,children:[`LC #`,i]}),(0,W.jsx)(`span`,{className:`truncate`,children:u})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[d?(0,W.jsx)(`span`,{className:`text-[7.5px] font-arcade font-extrabold px-1 py-0.5 bg-amber-300 text-ink-black border border-ink-black shrink-0`,children:`NOW`}):(0,W.jsx)(s,{className:`w-2.5 h-2.5 fill-ink-black text-ink-black opacity-0 group-hover:opacity-100 transition-opacity shrink-0`}),(0,W.jsx)(`span`,{className:`text-[8px] font-arcade font-bold px-1.5 py-0.5 border border-ink-black shrink-0 ${m}`,children:p})]})]},e.id||t)})})]})]}),e.problem_number!==void 0&&e.problem_number!==null&&(0,W.jsx)(`span`,{className:`h-7 inline-flex items-center px-2 font-arcade text-[8px] sm:text-[9px] font-bold bg-amber-200 border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-ink-black shrink-0 select-none whitespace-nowrap`,children:e.problem_number>0?`LC #${e.problem_number}`:`CUSTOM`}),(0,W.jsx)(`span`,{className:`h-7 inline-flex items-center px-2 font-arcade text-[8px] sm:text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] shrink-0 select-none whitespace-nowrap ${e.difficulty===`Easy`?`bg-emerald-600 text-white`:e.difficulty===`Medium`?`bg-amber-400 text-ink-black`:`bg-rose-600 text-white`}`,children:e.difficulty?e.difficulty.toUpperCase():`EASY`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 flex-wrap justify-end`,children:[(0,W.jsxs)(`button`,{onClick:i,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-purple-50 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Create or Import Problem`,children:[(0,W.jsx)(g,{className:`w-3 h-3 text-purple-600 shrink-0`}),(0,W.jsx)(`span`,{className:`hidden min-[480px]:inline`,children:`ADD`})]}),a&&(0,W.jsxs)(`button`,{onClick:a,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-emerald-50 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Edit Problem Specification`,children:[(0,W.jsx)(c,{className:`w-3 h-3 text-emerald-600 shrink-0`}),(0,W.jsx)(`span`,{className:`hidden min-[480px]:inline`,children:`EDIT`})]}),e.google_doc_url&&(0,W.jsxs)(`a`,{href:e.google_doc_url,target:`_blank`,rel:`noreferrer`,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Open Google Doc Notes`,children:[(0,W.jsx)(`span`,{children:`DOC`}),(0,W.jsx)(w,{className:`w-2.5 h-2.5 text-primary shrink-0`})]}),(0,W.jsxs)(`a`,{href:d,target:`_blank`,rel:`noreferrer`,className:`h-7 inline-flex items-center gap-1 px-2 sm:px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black text-ink-black text-[8px] sm:text-[9px] font-arcade font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0`,title:`Search LeetCode`,children:[(0,W.jsx)(`span`,{children:`LC`}),(0,W.jsx)(w,{className:`w-2.5 h-2.5 text-amber-600 shrink-0`})]})]})]})},ge=oe.mark({class:`cm-indent-dot cm-indent-dot-primary`}),_e=oe.mark({class:`cm-indent-dot cm-indent-dot-secondary`});function ve(e){let t=new V;for(let{from:n,to:r}of e.visibleRanges){let i=n;for(;i<r;){let n=e.state.doc.lineAt(i),r=n.text,a=0;for(;a<r.length&&(r[a]===` `||r[a]===` `);){let e=n.from+a,i=e+1,o=a%4==0||r[a]===` `;t.add(e,i,o?ge:_e),a++}i=n.to+1}}return t.finish()}var ye=B.fromClass(class{decorations;constructor(e){this.decorations=ve(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=ve(e.view))}},{decorations:e=>e.decorations}),be=H.theme({"&":{backgroundColor:`#0c111d`,color:`#f1f5f9`,height:`100%`,fontSize:`13px`,fontFamily:`var(--font-code, "JetBrains Mono", "Fira Code", monospace)`},".cm-scroller":{overflow:`auto`,fontFamily:`inherit`,lineHeight:`1.65`},".cm-content":{caretColor:`#4ade80`,padding:`12px 0`},"&.cm-focused .cm-cursor":{borderLeftColor:`#4ade80`,borderLeftWidth:`2px`,filter:`drop-shadow(0 0 5px rgba(74, 222, 128, 0.8))`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`rgba(56, 189, 248, 0.25) !important`},".cm-gutters":{backgroundColor:`#070a12`,color:`#475569`,borderRight:`2px solid #1e293b`,paddingRight:`6px`,userSelect:`none`},".cm-activeLineGutter":{backgroundColor:`#131b2e`,color:`#38bdf8`,fontWeight:`700`},".cm-activeLine, &.cm-focused .cm-activeLine":{backgroundColor:`#0f172a !important`},".cm-line":{padding:`0 10px`},".cm-indent-dot":{position:`relative`,display:`inline-block`},".cm-indent-dot::before":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,userSelect:`none`,lineHeight:`0`,fontFamily:`monospace`},".cm-indent-dot-primary::before":{content:`"•"`,color:`#38bdf8`,fontSize:`9px`,opacity:`0.85`},".cm-indent-dot-secondary::before":{content:`"·"`,color:`#64748b`,fontSize:`11px`,opacity:`0.5`},"&.cm-focused .cm-matchingBracket, .cm-matchingBracket":{backgroundColor:`rgba(74, 222, 128, 0.2)`,outline:`1px solid #4ade80`,borderRadius:`2px`,color:`#86efac !important`},".cm-placeholder":{color:`#64748b`,fontStyle:`italic`},".cm-scroller::-webkit-scrollbar":{width:`6px`,height:`6px`},".cm-scroller::-webkit-scrollbar-track":{backgroundColor:`#070a12`},".cm-scroller::-webkit-scrollbar-thumb":{backgroundColor:`#1e293b`,borderRadius:`3px`,border:`1px solid #334155`},".cm-scroller::-webkit-scrollbar-thumb:hover":{backgroundColor:`#38bdf8`}}),xe=[ae(),se.of(` `),z.of([ie]),ye,be,H.contentAttributes.of({"aria-label":`Python Code Editor`})],G=[{id:`python`,name:`Python`,version:`3.14`}],Se=({className:e=`w-3.5 h-3.5`})=>(0,W.jsxs)(`svg`,{viewBox:`0 0 128 128`,className:e,xmlns:`http://www.w3.org/2000/svg`,children:[(0,W.jsx)(`path`,{d:`M63.454 4.018c-14.775 0-23.774 6.425-23.774 18.775v13.626h24.168v3.424H30.082C17.518 39.843 8 47.962 8 63.673c0 15.65 8.358 23.486 21.056 23.486h11.905v-16.89c0-13.064 11.233-24.113 24.331-24.113h23.773V32.793c0-11.83-9.988-19.775-23.773-19.775H63.454v-9zm-9.845 7.426a3.84 3.84 0 0 1 3.86 3.84 3.84 3.84 0 0 1-3.86 3.841 3.84 3.84 0 0 1-3.86-3.84 3.84 3.84 0 0 1 3.86-3.841z`,fill:`#387eb8`}),(0,W.jsx)(`path`,{d:`M64.546 123.982c14.775 0 23.774-6.425 23.774-18.775V91.581H64.152v-3.424h33.766c12.564 0 22.082-8.119 22.082-23.83 0-15.65-8.358-23.486-21.056-23.486H87.04v16.89c0 13.064-11.234 24.113-24.332 24.113H38.934v13.363c0 11.83 9.989 19.775 23.774 19.775h1.838v9zm9.845-7.426a3.84 3.84 0 0 1-3.86-3.84 3.84 3.84 0 0 1 3.86-3.841 3.84 3.84 0 0 1 3.86 3.84 3.84 3.84 0 0 1-3.86 3.841z`,fill:`#ffe052`})]}),Ce=({mobileView:e,isNarrow:t=!1,isAutocompleteEnabled:r,onToggleAutocomplete:c,onResetStarterCode:u,code:d,onChangeCode:f,sandboxRunning:m,sandboxError:g,sandboxResults:v,onRunSandbox:y,savingReference:b,savedRefSuccess:S,saveRefError:T,onSaveReference:A,aiLoading:j,aiError:M,aiResult:N,onAiEvaluation:P,optimalTime:F,optimalSpace:I,onPushToGitHub:L,pushingToGitHub:R,githubPushedUrl:ee,githubPushError:te})=>{let[ne,re]=(0,U.useState)(`python`),[z,B]=(0,U.useState)(!1),V=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=e=>{V.current&&!V.current.contains(e.target)&&B(!1)},t=e=>{e.key===`Escape`&&B(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[]);let H=G.find(e=>e.id===ne)??G[0];return(0,W.jsxs)(`div`,{className:`w-full ${t?`flex flex-1`:`lg:w-[51%] flex`} flex-col bg-[#fffdfa] overflow-y-auto no-scrollbar ${t&&e!==`code`?`hidden`:`flex`}`,children:[(0,W.jsxs)(`div`,{className:`shrink-0 bg-[#f7f5ed] border-b-2 border-ink-black p-2 sm:px-3 flex flex-wrap items-center justify-between gap-1.5 sm:gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap`,children:[(0,W.jsxs)(`div`,{className:`relative`,ref:V,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>B(e=>!e),className:`h-7 px-2.5 bg-white hover:bg-slate-100 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center gap-1.5 font-arcade text-[9px] font-bold text-ink-black cursor-pointer transition-all select-none`,title:`Select programming language`,"aria-expanded":z,"aria-haspopup":`listbox`,children:[(0,W.jsx)(Se,{className:`w-3.5 h-3.5 shrink-0`}),(0,W.jsx)(`span`,{children:H.name}),(0,W.jsx)(D,{className:`w-3 h-3 text-ink-black transition-transform duration-150 ${z?`rotate-180`:``}`})]}),z&&(0,W.jsxs)(`div`,{className:`absolute top-full mt-1.5 left-0 z-50 w-52 bg-paper-white border-[3px] border-ink-black gadget-shadow p-1.5 space-y-1`,role:`listbox`,children:[(0,W.jsx)(`div`,{className:`px-2 py-1 text-[8px] font-arcade font-bold text-trash-gray uppercase border-b border-slate-200`,children:`SELECT LANGUAGE`}),G.map(e=>{let t=ne===e.id;return(0,W.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{re(e.id),B(!1)},className:`w-full flex items-center justify-between px-2.5 py-1.5 border-2 border-ink-black text-left transition-all cursor-pointer ${t?`bg-amber-200 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] font-bold text-ink-black`:`bg-white hover:bg-slate-100 text-slate-800`}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[9px]`,children:[(0,W.jsx)(Se,{className:`w-3.5 h-3.5 shrink-0`}),(0,W.jsx)(`span`,{children:e.name})]}),(0,W.jsxs)(`span`,{className:`font-mono text-[8px] font-bold px-1.5 py-0.5 bg-white border border-ink-black text-slate-700 shadow-[1px_1px_0px_0px_rgba(30,41,59,0.3)]`,children:[`v`,e.version]})]},e.id)})]})]}),(0,W.jsx)(`div`,{className:`h-4 w-[2px] bg-slate-300 mx-0.5 hidden sm:block`}),(0,W.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>c(e.target.checked),className:`sr-only peer`,"aria-label":`Toggle code editor autocompletion`}),(0,W.jsx)(`div`,{className:`relative w-7 h-3.5 bg-slate-300 border border-ink-black rounded-full peer peer-checked:bg-grass-green transition-all after:content-[''] after:absolute after:top-[1px] after:left-[2px] after:bg-white after:border after:border-ink-black after:rounded-full after:h-2 after:w-2 after:transition-all peer-checked:after:translate-x-3`}),(0,W.jsx)(`span`,{className:`text-[7.5px] min-[400px]:text-[8px] font-arcade font-bold text-trash-gray peer-checked:text-ink-black whitespace-nowrap`,children:`AUTOCOMPLETE`})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,W.jsx)(`button`,{onClick:u,className:`w-7 h-7 bg-white hover:bg-slate-100 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-ink-black flex items-center justify-center cursor-pointer transition-all`,title:`Reset to starter code`,"aria-label":`Reset to starter code`,children:(0,W.jsx)(l,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(`button`,{onClick:()=>f(``),className:`w-7 h-7 bg-white hover:bg-rose-50 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-rose-700 flex items-center justify-center cursor-pointer transition-all`,title:`Clear editor`,"aria-label":`Clear editor`,children:(0,W.jsx)(x,{className:`w-3.5 h-3.5 text-rose-600`})}),A&&(0,W.jsx)(`button`,{onClick:A,disabled:b||!d.trim(),className:`w-7 h-7 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all ${S?`bg-emerald-600 hover:bg-emerald-500 text-white`:`bg-amber-400 hover:bg-amber-300 text-ink-black`}`,title:b?`Saving solution to personal database...`:S?`Saved to personal database!`:`Overwrite saved solution with studio code`,"aria-label":`Overwrite saved solution with studio code`,children:b?(0,W.jsx)(n,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):S?(0,W.jsx)(_,{className:`w-3.5 h-3.5 text-white`}):(0,W.jsx)(a,{className:`w-3.5 h-3.5 text-ink-black`})}),L&&(0,W.jsx)(`button`,{onClick:L,disabled:R||!d.trim(),className:`w-7 h-7 bg-[#24292e] hover:bg-black border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:R?`Pushing to GitHub...`:`Push solution to GitHub repository`,"aria-label":`Push to GitHub`,children:R?(0,W.jsx)(n,{className:`w-3.5 h-3.5 animate-spin text-yellow-300`}):(0,W.jsx)(p,{className:`w-3.5 h-3.5 text-yellow-300`})})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,W.jsx)(`button`,{onClick:y,disabled:m||!d.trim(),className:`w-7 h-7 bg-emerald-600 hover:bg-emerald-500 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:m?`Running sandbox tests...`:`Run tests in local sandbox`,"aria-label":`Run tests`,children:m?(0,W.jsx)(n,{className:`w-3.5 h-3.5 animate-spin`}):(0,W.jsx)(s,{className:`w-3.5 h-3.5 fill-white text-white ml-0.5`})}),(0,W.jsx)(`button`,{onClick:P,disabled:j||!d.trim(),className:`w-7 h-7 bg-purple-600 hover:bg-purple-500 border-2 border-ink-black shadow-[1px_1px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none text-white flex items-center justify-center cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-all`,title:j?`Evaluating code with Gemini...`:`Gemini Eval (AI code review & complexity)`,"aria-label":`Gemini Eval`,children:j?(0,W.jsx)(n,{className:`w-3.5 h-3.5 animate-spin`}):(0,W.jsx)(O,{className:`w-3.5 h-3.5 text-amber-300`})})]})]}),(0,W.jsxs)(`div`,{className:`p-4 sm:p-5 flex-1 flex flex-col space-y-4`,children:[(0,W.jsx)(`div`,{className:`flex-1 flex flex-col min-h-[300px] sm:min-h-[360px] border-[3px] border-ink-black shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] bg-[#0c111d] overflow-hidden`,children:(0,W.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,W.jsx)(C,{value:d,onChange:f,placeholder:`def solve(nums):
5
- # Write your solution from memory here...`,height:`100%`,theme:`dark`,extensions:xe,basicSetup:{autocompletion:r,lineNumbers:!0,foldGutter:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,rectangularSelection:!0,crosshairCursor:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,closeBracketsKeymap:!0,defaultKeymap:!0,searchKeymap:!0,historyKeymap:!0,foldKeymap:!0,completionKeymap:!0,lintKeymap:!0},className:`w-full h-full text-xs font-code-mono`})})}),S&&(0,W.jsxs)(`div`,{className:`p-3 bg-[#f0fdf4] border-2 border-emerald-600 text-emerald-950 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,W.jsx)(_,{className:`w-4 h-4 text-emerald-600 shrink-0`}),(0,W.jsx)(`span`,{children:`Successfully saved studio code as your personal reference solution!`})]}),T&&(0,W.jsxs)(`div`,{className:`p-3 bg-rose-50 border-2 border-rose-500 text-rose-800 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,W.jsx)(h,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,W.jsx)(`span`,{children:T})]}),ee&&(0,W.jsxs)(`div`,{className:`p-3 bg-[#f0fdf4] border-2 border-emerald-600 text-emerald-950 text-xs font-semibold flex items-center justify-between shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(_,{className:`w-4 h-4 text-emerald-600 shrink-0`}),(0,W.jsx)(`span`,{children:`Successfully pushed solution to your GitHub repository!`})]}),(0,W.jsxs)(`a`,{href:ee,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] font-bold text-blue-700 hover:text-blue-900 underline flex items-center gap-1`,children:[(0,W.jsx)(`span`,{children:`View on GitHub`}),(0,W.jsx)(w,{className:`w-3 h-3`})]})]}),te&&(0,W.jsxs)(`div`,{className:`p-3 bg-rose-50 border-2 border-rose-500 text-rose-800 text-xs font-semibold flex items-center gap-2 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,W.jsx)(h,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,W.jsx)(`span`,{children:te})]}),m&&(0,W.jsxs)(`div`,{className:`p-3 border-2 border-ink-black bg-emerald-50 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] flex items-center gap-3 animate-pulse`,children:[(0,W.jsx)(n,{className:`w-5 h-5 text-emerald-600 animate-spin shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:`Running...`}),(0,W.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray font-semibold mt-0.5`,children:`Executing against test cases...`})]})]}),g&&(0,W.jsxs)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] flex items-center gap-2`,children:[(0,W.jsx)(h,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,W.jsx)(`span`,{children:g})]}),v&&(0,W.jsxs)(`div`,{className:`border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-3.5 ${v.status===`passed`?`bg-[#f0fdf4]`:`bg-[#fff1f2]`}`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-2 pb-2.5 border-b-2 border-dashed border-ink-black`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,W.jsx)(`div`,{className:`w-8 h-8 border-2 border-ink-black flex items-center justify-center font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${v.status===`passed`?`bg-grass-green text-ink-black`:`bg-rose-500 text-white`}`,children:v.status===`passed`?(0,W.jsx)(k,{className:`w-5 h-5 stroke-[3]`}):(0,W.jsx)(h,{className:`w-4 h-4`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`font-arcade text-[10px] font-bold text-ink-black flex items-center gap-1.5 uppercase`,children:v.status===`passed`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`ALL TESTS PASSED`}),(0,W.jsx)(_,{className:`w-3.5 h-3.5 text-emerald-600 inline`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:v.status===`error`?`EXECUTION ERROR`:`TESTS FAILED`}),(0,W.jsx)(E,{className:`w-3.5 h-3.5 text-rose-600 inline`})]})}),(0,W.jsxs)(`div`,{className:`font-sans text-[11px] text-slate-600 font-semibold`,children:[v.passed_count??0,` of `,v.total_tests??0,` test cases passed (`,(v.duration_ms??0).toFixed(1),`ms)`]})]})]}),v.status===`passed`&&(0,W.jsxs)(`button`,{onClick:A,disabled:b,className:`px-3 py-1.5 bg-white hover:bg-emerald-100 border-2 border-ink-black text-ink-black font-arcade text-[8px] font-bold flex items-center gap-1.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 disabled:opacity-50`,children:[b?(0,W.jsx)(n,{className:`w-3 h-3 animate-spin`}):S?(0,W.jsx)(_,{className:`w-3.5 h-3.5 text-emerald-600`}):(0,W.jsx)(a,{className:`w-3.5 h-3.5 text-blue-600`}),(0,W.jsx)(`span`,{children:S?`SAVED TO DB!`:`SAVE AS OFFICIAL SOLUTION`})]})]}),T&&(0,W.jsx)(`div`,{className:`p-2 border border-rose-500 bg-rose-100 text-rose-800 text-[11px] font-semibold`,children:T}),v.results&&v.results.length>0&&(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray uppercase font-bold block`,children:`TEST CASE BREAKDOWN:`}),(0,W.jsx)(`div`,{className:`space-y-1.5 max-h-56 overflow-y-auto custom-scrollbar`,children:v.results.map((e,t)=>(0,W.jsxs)(`div`,{className:`p-2.5 border-2 border-ink-black text-xs font-mono shadow-[2px_2px_0px_0px_rgba(30,41,59,0.3)] ${e.passed?`bg-white`:`bg-rose-50`}`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between font-arcade text-[8px] mb-1`,children:[(0,W.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`CASE #`,t+1]}),(0,W.jsx)(`span`,{className:e.passed?`text-emerald-700 font-bold`:`text-rose-700 font-bold`,children:e.passed?`✓ PASSED`:`✗ FAILED`})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-1.5 text-[10px]`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`text-slate-500 block`,children:`Input:`}),(0,W.jsx)(`span`,{className:`font-code-mono text-ink-black font-semibold break-all`,children:JSON.stringify(e.input)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`text-slate-500 block`,children:`Expected:`}),(0,W.jsx)(`span`,{className:`font-code-mono text-emerald-700 font-semibold break-all`,children:JSON.stringify(e.expected)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`text-slate-500 block`,children:`Output:`}),(0,W.jsx)(`span`,{className:`font-code-mono font-semibold break-all ${e.passed?`text-emerald-700`:`text-rose-700`}`,children:e.output===void 0?`None`:JSON.stringify(e.output)})]})]}),e.error&&(0,W.jsx)(`div`,{className:`mt-1.5 p-1.5 bg-rose-100 text-rose-900 text-[10px] font-mono border border-rose-300 break-all`,children:e.error})]},t))})]}),v.error&&(0,W.jsx)(`div`,{className:`p-3 bg-[#1E293B] text-rose-400 font-code-mono text-[11px] border-2 border-ink-black overflow-x-auto whitespace-pre-wrap select-text`,children:v.error}),v.status===`passed`&&(0,W.jsx)(`div`,{className:`p-2 bg-emerald-100/70 border border-emerald-300 text-emerald-900 text-xs flex items-center justify-between`,children:(0,W.jsx)(`span`,{className:`font-sans font-medium`,children:`✨ All unit tests passed. Rate your recall below.`})})]}),j&&(0,W.jsxs)(`div`,{className:`p-4 border-2 border-ink-black bg-amber-50 shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] flex items-center gap-3 animate-pulse`,children:[(0,W.jsx)(n,{className:`w-6 h-6 text-purple-600 animate-spin shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:`ANALYZING...`}),(0,W.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray font-semibold mt-0.5`,children:`Checking edge cases, bounds, and Big-O efficiency against optimal constraints...`})]})]}),M&&(0,W.jsx)(`div`,{className:`p-3 border-2 border-rose-500 bg-rose-50 text-rose-800 text-xs font-semibold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:M}),N&&(0,W.jsxs)(`div`,{className:`border-[3px] border-ink-black bg-[#fefce8] p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between pb-3 border-b-2 border-dashed border-ink-black`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`w-9 h-9 border-2 border-ink-black flex items-center justify-center font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${N.is_correct?`bg-grass-green text-ink-black`:`bg-rose-500 text-white`}`,children:N.is_correct?(0,W.jsx)(k,{className:`w-5 h-5 stroke-[3]`}):(0,W.jsx)(i,{className:`w-5 h-5`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`font-arcade text-[10px] font-bold text-ink-black flex items-center gap-1.5`,children:N.is_correct?(0,W.jsxs)(W.Fragment,{children:[`STATUS: PASSED`,(0,W.jsx)(_,{className:`w-3.5 h-3.5 text-emerald-600 inline`})]}):(0,W.jsxs)(W.Fragment,{children:[`STATUS: FAILED`,(0,W.jsx)(E,{className:`w-3.5 h-3.5 text-rose-600 inline`})]})}),(0,W.jsx)(`span`,{className:`font-sans text-[11px] text-slate-600 font-semibold`,children:N.is_correct?`Algorithm matches expected logic and patterns.`:`Bugs or edge-case failures detected.`})]})]}),(0,W.jsx)(`span`,{className:`font-arcade text-[9px] px-2 py-1 border-2 border-ink-black uppercase font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] ${N.is_correct?`bg-emerald-100 text-emerald-800`:`bg-rose-100 text-rose-800`}`,children:N.is_correct?`CORRECT`:`INCORRECT`})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,W.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase font-bold`,children:`Time Complexity`}),(0,W.jsxs)(`div`,{className:`flex items-baseline gap-2 mt-1`,children:[(0,W.jsx)(`span`,{className:`font-code-mono text-xs font-bold text-ink-black`,children:N.detected_complexity?.time||`N/A`}),(0,W.jsxs)(`span`,{className:`text-[10px] font-sans text-slate-500 font-semibold`,children:[`(Target: `,F||`O(N)`,`)`]})]})]}),(0,W.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,W.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase font-bold`,children:`Space Complexity`}),(0,W.jsxs)(`div`,{className:`flex items-baseline gap-2 mt-1`,children:[(0,W.jsx)(`span`,{className:`font-code-mono text-xs font-bold text-ink-black`,children:N.detected_complexity?.space||`N/A`}),(0,W.jsxs)(`span`,{className:`text-[10px] font-sans text-slate-500 font-semibold`,children:[`(Target: `,I||`O(1)`,`)`]})]})]})]}),N.bugs&&N.bugs.length>0&&(0,W.jsxs)(`div`,{className:`p-3 bg-white border-2 border-ink-black space-y-1.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,W.jsxs)(`span`,{className:`font-arcade text-[8px] text-rose-600 uppercase font-bold block flex items-center gap-1`,children:[(0,W.jsx)(h,{className:`w-3 h-3 text-rose-500`}),`TRACES & EDGE CASE ISSUES:`]}),(0,W.jsx)(`ul`,{className:`list-disc list-inside text-xs text-slate-800 space-y-1 font-semibold pl-1`,children:N.bugs.map((e,t)=>(0,W.jsx)(`li`,{className:`leading-relaxed select-text`,children:e},t))})]}),N.key_suggestion&&(0,W.jsxs)(`div`,{className:`p-3 bg-amber-50 border-2 border-ink-black space-y-1 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:[(0,W.jsxs)(`span`,{className:`font-arcade text-[8px] text-amber-700 uppercase font-bold block flex items-center gap-1`,children:[(0,W.jsx)(O,{className:`w-3 h-3 text-amber-500`}),`TIP:`]}),(0,W.jsx)(`p`,{className:`text-xs text-slate-800 font-medium leading-relaxed m-0 select-text`,children:N.key_suggestion})]}),(0,W.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-dashed border-ink-black flex items-center justify-between`,children:[(0,W.jsxs)(`span`,{className:`text-xs font-bold text-ink-black flex items-center gap-1.5`,children:[(0,W.jsx)(o,{className:`w-4 h-4 text-primary`}),`Recommendation:`]}),(0,W.jsx)(`span`,{className:`font-arcade text-[9px] font-bold text-purple-700`,children:N.is_correct?`Rate your recall below.`:`Review issues and rate recall below.`})]})]})]})]})},we=({gradeError:e,onDismissGradeError:t,submitting:r,submittingRating:i,onGrade:a})=>(0,W.jsx)(`div`,{className:`shrink-0 bg-[#f8f5eb] border-t-[3px] border-ink-black p-2 sm:p-3 flex flex-col items-stretch gap-1.5 sm:gap-2 shadow-[0_-3px_0_0_rgba(30,41,59,0.08)]`,children:(0,W.jsxs)(`div`,{className:`w-full flex flex-col`,children:[e&&(0,W.jsxs)(`div`,{className:`p-2.5 mb-2 bg-red-100 border-2 border-red-500 text-red-800 text-xs font-semibold shadow-[2px_2px_0px_0px_#1E293B] flex items-center justify-between`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(h,{className:`w-4 h-4 text-red-600 shrink-0`}),e]}),(0,W.jsx)(`button`,{onClick:t,className:`text-red-900 font-bold hover:underline cursor-pointer ml-2 text-xs`,children:`Dismiss`})]}),(0,W.jsxs)(`div`,{className:`flex gap-1.5 sm:gap-2.5 w-full`,children:[(0,W.jsx)(`button`,{onClick:()=>a(1),disabled:r,className:`flex-1 min-w-0 bg-[#dc2626] hover:bg-[#b91c1c] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-white flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 1 on keyboard`,children:i===1?(0,W.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,W.jsx)(n,{className:`w-3.5 h-3.5 animate-spin`})}):(0,W.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,W.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/20 rounded shrink-0`,children:`1`}),(0,W.jsx)(`span`,{className:`truncate`,children:`Again`})]})}),(0,W.jsx)(`button`,{onClick:()=>a(2),disabled:r,className:`flex-1 min-w-0 bg-[#ff9933] hover:bg-[#ff8000] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 2 on keyboard`,children:i===2?(0,W.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,W.jsx)(n,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,W.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,W.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`2`}),(0,W.jsx)(`span`,{className:`truncate`,children:`Hard`})]})}),(0,W.jsx)(`button`,{onClick:()=>a(3),disabled:r,className:`flex-1 min-w-0 bg-[#4ade80] hover:bg-[#22c55e] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 3 on keyboard`,children:i===3?(0,W.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,W.jsx)(n,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,W.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,W.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`3`}),(0,W.jsx)(`span`,{className:`truncate`,children:`Good`})]})}),(0,W.jsx)(`button`,{onClick:()=>a(4),disabled:r,className:`flex-1 min-w-0 bg-[#60a5fa] hover:bg-[#3b82f6] border-2 sm:border-[3px] border-ink-black py-2 sm:py-2.5 px-1 sm:px-2 arcade-btn cursor-pointer disabled:opacity-60 text-ink-black flex flex-col items-center justify-center font-bold transition-all select-none`,title:`Press 4 on keyboard`,children:i===4?(0,W.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,W.jsx)(n,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,W.jsxs)(`div`,{className:`flex items-center gap-1 font-headline-md text-[10px] min-[400px]:text-xs sm:text-sm font-extrabold tracking-wide uppercase truncate`,children:[(0,W.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`4`}),(0,W.jsx)(`span`,{className:`truncate`,children:`Easy`})]})})]})]})}),Te=({nextMilestone:e,activatingMilestone:t,onActivateNextMilestone:r,onOpenOnboarding:i,onOpenJourney:a,onOpenCreateProblem:o,onOpenWindow:s,overrideProblemId:c,onClearOverride:u,hasCustomOnboardingModal:d,isOnboardingOpen:p,onCloseOnboarding:h,onCompletedOnboarding:_,currentUserId:b})=>(0,W.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] p-6 overflow-y-auto custom-scrollbar`,children:(0,W.jsxs)(`div`,{className:`w-full max-w-lg bg-paper-white border-[4px] border-ink-black gadget-shadow p-6 sm:p-8 relative overflow-hidden text-center space-y-6`,children:[(0,W.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-3 bg-gradient-to-r from-grass-green via-amber-300 to-highlight-pink`}),(0,W.jsxs)(`div`,{className:`relative inline-block mt-2`,children:[(0,W.jsx)(`div`,{className:`w-20 h-20 bg-amber-300 border-[3px] border-ink-black rounded-2xl flex items-center justify-center mx-auto gadget-shadow rotate-[-3deg] hover:rotate-0 transition-transform`,children:(0,W.jsx)(T,{className:`w-10 h-10 text-ink-black stroke-[2.5]`})}),(0,W.jsx)(`div`,{className:`absolute -bottom-2 -right-2 bg-grass-green border-2 border-ink-black px-2 py-0.5 font-arcade text-[8px] text-ink-black font-bold uppercase shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:`100% DONE`})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-1 bg-emerald-100 border-2 border-ink-black text-emerald-800 font-arcade text-[9px] font-bold`,children:[(0,W.jsx)(k,{className:`w-3 h-3 stroke-[3]`}),` ALL CARDS COMPLETED FOR TODAY`]}),(0,W.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold text-ink-black font-headline-md tracking-tight`,children:`You're all caught up for today. Keep it up.`}),(0,W.jsx)(`p`,{className:`text-xs sm:text-sm font-sans text-trash-gray max-w-md mx-auto leading-relaxed font-semibold`,children:`All reviews for today are finished. Next reviews are scheduled for tomorrow.`})]}),e&&(0,W.jsxs)(`div`,{className:`p-4 sm:p-5 bg-gradient-to-br from-amber-50 to-orange-50 border-[3px] border-ink-black gadget-shadow text-left space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-amber-800 uppercase tracking-wider flex items-center gap-1.5`,children:[(0,W.jsx)(y,{className:`w-3.5 h-3.5 text-amber-600`}),`NEXT UNEXPLORED MILESTONE`]}),(0,W.jsxs)(`span`,{className:`font-mono text-[10px] font-bold px-2 py-0.5 rounded bg-amber-900/10 text-amber-900 border border-amber-900/20`,children:[`LC #`,e.problem_number]})]}),(0,W.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h3`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black truncate`,children:e.name}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 flex-wrap`,children:[(0,W.jsx)(`span`,{className:`px-2 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${e.difficulty===`Easy`?`bg-emerald-600`:e.difficulty===`Medium`?`bg-amber-600`:`bg-rose-600`}`,children:e.difficulty}),(0,W.jsx)(`span`,{className:`px-2 py-0.5 rounded font-arcade text-[8px] bg-purple-100 text-purple-800 border border-purple-300 font-bold`,children:e.pattern}),(0,W.jsxs)(`span`,{className:`text-[11px] font-code-mono text-slate-600`,children:[`T: `,e.time_complexity,` | S: `,e.space_complexity]})]})]}),(0,W.jsx)(`button`,{onClick:r,disabled:t,className:`px-4 py-2.5 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 flex items-center justify-center gap-1.5 disabled:opacity-50`,children:t?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(n,{className:`w-3.5 h-3.5 animate-spin`}),(0,W.jsx)(`span`,{children:`ACTIVATING...`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(O,{className:`w-3.5 h-3.5 text-amber-700`}),(0,W.jsx)(`span`,{children:`ACTIVATE & REVIEW NOW`})]})})]})]}),(0,W.jsxs)(`div`,{className:`p-4 sm:p-5 bg-gradient-to-r from-amber-100 via-amber-200 to-yellow-100 border-[3px] border-ink-black gadget-shadow text-left flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-amber-900 uppercase flex items-center gap-1.5`,children:[(0,W.jsx)(m,{className:`w-3.5 h-3.5 text-amber-700`}),`FAST-TRACK EXPEDITION ENROLLMENT`]}),(0,W.jsx)(`h3`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black`,children:`Already Solved Problems Elsewhere?`}),(0,W.jsx)(`p`,{className:`font-sans text-xs text-trash-gray font-semibold max-w-md`,children:`Check off problems you've already solved elsewhere to seed your review queue.`})]}),(0,W.jsxs)(`button`,{onClick:i,className:`px-4 py-2.5 bg-amber-400 hover:bg-amber-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer shrink-0 flex items-center gap-1.5`,children:[(0,W.jsx)(m,{className:`w-3.5 h-3.5 text-amber-900`}),(0,W.jsx)(`span`,{children:`OPEN 150-PROBLEM CHECKLIST`})]})]}),(0,W.jsxs)(`div`,{className:`border-t-[3px] border-dashed border-ink-black pt-5 space-y-3`,children:[(0,W.jsx)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold text-left`,children:`CONTINUE PRACTICING:`}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2.5`,children:[(0,W.jsxs)(`button`,{onClick:a,className:`p-3 bg-amber-100 hover:bg-amber-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(y,{className:`w-4 h-4 text-amber-600`}),(0,W.jsx)(v,{className:`w-3 h-3 text-ink-black`})]}),(0,W.jsxs)(`div`,{className:`mt-2`,children:[(0,W.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Journey Trail`}),(0,W.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`150 Curated nodes`})]})]}),(0,W.jsxs)(`button`,{onClick:o,className:`p-3 bg-purple-100 hover:bg-purple-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(g,{className:`w-4 h-4 text-purple-700`}),(0,W.jsx)(v,{className:`w-3 h-3 text-ink-black`})]}),(0,W.jsxs)(`div`,{className:`mt-2`,children:[(0,W.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Add Problem`}),(0,W.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`New LeetCode entry`})]})]}),(0,W.jsxs)(`button`,{onClick:()=>s?.(`companion`),className:`p-3 bg-yellow-100 hover:bg-yellow-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`material-symbols-outlined text-amber-600 text-lg`,children:`castle`}),(0,W.jsx)(v,{className:`w-3 h-3 text-ink-black`})]}),(0,W.jsxs)(`div`,{className:`mt-2`,children:[(0,W.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Princess Tower`}),(0,W.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`Visit Aurelia`})]})]}),(0,W.jsxs)(`button`,{onClick:()=>s?.(`computer`),className:`p-3 bg-cyan-100 hover:bg-cyan-200 border-[3px] border-ink-black text-left flex flex-col justify-between gadget-shadow active:translate-y-1 active:shadow-none transition-all cursor-pointer`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(f,{className:`w-4 h-4 text-cyan-700`}),(0,W.jsx)(v,{className:`w-3 h-3 text-ink-black`})]}),(0,W.jsxs)(`div`,{className:`mt-2`,children:[(0,W.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`File Explorer`}),(0,W.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`Browse all files`})]})]})]})]}),c&&u&&(0,W.jsxs)(`button`,{onClick:u,className:`mt-3 bg-white hover:bg-slate-100 border-[3px] border-ink-black text-ink-black font-bold px-4 py-2 text-xs uppercase tracking-wide shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer inline-flex items-center gap-2`,children:[(0,W.jsx)(l,{className:`w-3.5 h-3.5`}),` Return to Scheduled Queue`]}),!d&&(0,W.jsx)(re,{isOpen:p,onClose:h,onCompleted:_,userId:b})]})}),Ee=e({default:()=>Oe}),De=(0,U.lazy)(()=>R(()=>import(`./ProblemSpecPanel-CLbwqTwe.js`).then(e=>({default:e.ProblemSpecPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])));function Oe({overrideProblemId:e,onClearOverride:t,onOpenWindow:r,onOpenJourney:i,onOpenCreateProblem:a,onOpenEditProblem:o,onOpenOnboarding:s,refreshTrigger:c}){let[d,p]=(0,U.useState)(null),m=d!==null&&d<780,[g,_]=(0,U.useState)(`spec`),[v,y]=(0,U.useState)(`spec`),[x,C]=(0,U.useState)(null),w=(0,U.useCallback)(e=>{e&&(p(e.clientWidth),new ResizeObserver(e=>{for(let t of e)p(t.contentRect.width)}).observe(e))},[]),[T,E]=(0,U.useState)(!1),[D,O]=(0,U.useState)(()=>localStorage.getItem(`isAutocompleteEnabled`)!==`false`),{reviews:k,setReviews:A,loading:j,queueError:M,submitting:N,submittingRating:P,gradeError:F,setGradeError:L,code:R,setCode:ne,nextMilestone:z,activatingMilestone:B,currentUserId:V,fetchQueue:H,handleGrade:ie,handleSelectCard:ae,handleActivateNextMilestone:oe,handleResetStarterCode:se}=fe({overrideProblemId:e,refreshTrigger:c,onClearOverride:t,onOpenOnboarding:s,setIsOnboardingOpen:E}),{sandboxRunning:ue,sandboxResults:de,sandboxError:ge,savingReference:_e,savedRefSuccess:ve,saveRefError:ye,handleRunSandbox:be,handleSaveReference:xe,resetSandbox:G}=pe(),{aiLoading:Se,aiResult:Ee,aiError:Oe,explainLoading:ke,explanationText:Ae,explainError:je,aiSolutionLoading:Me,aiSolutionError:Ne,handleAiEvaluation:Pe,handleExplainCode:Fe,handleFetchAiSolution:Ie,resetAiState:K}=me(),[Le,Re]=(0,U.useState)(!1),[ze,Be]=(0,U.useState)(null),[Ve,q]=(0,U.useState)(null),He=(0,U.useCallback)(async()=>{if(k.length===0)return;let e=k[0]?.problems||{},t=R.trim()||e.reference_code||``;if(!t){q(`Please write or save code before pushing to GitHub.`),setTimeout(()=>q(null),4e3);return}let n=te();if(!n.token){r&&r(`github`);return}Re(!0),q(null),Be(null);try{let r=await ee({token:n.token,repo:n.repoName,branch:n.branch,problem_number:e.problem_number,problem_name:e.name||`Algorithm Problem`,pattern:e.pattern||`Algorithms`,difficulty:e.difficulty||`Medium`,optimal_time:e.optimal_time||`O(N)`,optimal_space:e.optimal_space||`O(1)`,description:e.description||``,code:t});Be(r.html_url),setTimeout(()=>Be(null),8e3)}catch(e){q(e.message||`Failed to push solution to GitHub.`),setTimeout(()=>q(null),5e3)}finally{Re(!1)}},[k,R,r]),J=k[0]?.id||k[0]?.problem_id,Ue=(0,U.useRef)(void 0);(0,U.useEffect)(()=>{J&&Ue.current!==J&&(Ue.current=J,K(),G())},[J,K,G]);let Y=(0,U.useCallback)(e=>{K(),G(),ie(e)},[ie,K,G]),We=(0,U.useCallback)(e=>{K(),G(),ae(e)},[ae,K,G]);(0,U.useEffect)(()=>{let e=e=>{let t=e.target;t?.closest(`.cm-editor`)||t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable||k.length===0||N||(e.key===`1`?(e.preventDefault(),Y(1)):e.key===`2`?(e.preventDefault(),Y(2)):e.key===`3`?(e.preventDefault(),Y(3)):e.key===`4`&&(e.preventDefault(),Y(4)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Y,k.length,N]);let Ge=(e,t)=>{navigator.clipboard.writeText(e),C(t),setTimeout(()=>C(null),1800)},Ke=(0,U.useCallback)(()=>{i?i():r?.(`journey`)},[i,r]),qe=(0,U.useCallback)(()=>{a?a():r?.(`createProblem`)},[a,r]),Je=(0,U.useCallback)(()=>{s?s():E(!0)},[s]),Ye=(0,U.useCallback)(e=>{A(t=>{if(t.length===0)return t;let n=[...t],r=n[0];return r&&r.problems&&(r.problems={...r.problems,solutions:e}),n})},[A]);if(j)return(0,W.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] text-ink-black`,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-4 p-8 bg-paper-white border-[3px] border-ink-black gadget-shadow text-center max-w-xs`,children:[(0,W.jsx)(`div`,{className:`w-12 h-12 bg-amber-200 border-2 border-ink-black flex items-center justify-center animate-spin`,children:(0,W.jsx)(n,{className:`w-6 h-6 text-ink-black`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-arcade text-xs text-ink-black uppercase tracking-wider font-bold`,children:`LOADING QUEUE`}),(0,W.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray mt-1 font-semibold`,children:`Fetching scheduled FSRS review cards...`})]})]})});if(M&&k.length===0)return(0,W.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] p-6 overflow-y-auto custom-scrollbar`,children:(0,W.jsxs)(`div`,{className:`w-full max-w-md bg-paper-white border-[4px] border-ink-black gadget-shadow p-6 sm:p-8 relative overflow-hidden text-center space-y-6`,children:[(0,W.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-3 bg-gradient-to-r from-red-500 via-amber-400 to-red-500`}),(0,W.jsxs)(`div`,{className:`relative inline-block mt-2`,children:[(0,W.jsx)(`div`,{className:`w-20 h-20 bg-rose-200 border-[3px] border-ink-black rounded-2xl flex items-center justify-center mx-auto gadget-shadow rotate-[-2deg]`,children:(0,W.jsx)(S,{className:`w-10 h-10 text-rose-700 stroke-[2.5]`})}),(0,W.jsx)(`div`,{className:`absolute -bottom-2 -right-2 bg-rose-500 text-white border-2 border-ink-black px-2 py-0.5 font-arcade text-[8px] font-bold uppercase shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]`,children:`OFFLINE`})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2.5 py-1 bg-rose-100 border-2 border-ink-black text-rose-800 font-arcade text-[9px] font-bold`,children:[(0,W.jsx)(h,{className:`w-3.5 h-3.5 stroke-[2.5] text-rose-600`}),` CONNECTION ERROR`]}),(0,W.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-extrabold text-ink-black font-headline-md tracking-tight`,children:`Queue Unavailable`}),(0,W.jsx)(`p`,{className:`font-sans text-xs sm:text-sm text-trash-gray font-semibold leading-relaxed max-w-sm mx-auto`,children:`Unable to reach the server to fetch your scheduled review cards. Check your connection or retry below.`})]}),(0,W.jsxs)(`div`,{className:`pt-2 flex flex-col sm:flex-row gap-3 justify-center items-center`,children:[(0,W.jsxs)(`button`,{onClick:()=>void H(!0),className:`w-full sm:w-auto px-6 py-2.5 bg-amber-300 hover:bg-amber-400 border-[3px] border-ink-black font-arcade text-xs font-bold text-ink-black gadget-shadow active:translate-x-0.5 active:translate-y-0.5 active:shadow-none transition-all flex items-center justify-center gap-2 cursor-pointer`,children:[(0,W.jsx)(l,{className:`w-4 h-4`}),(0,W.jsx)(`span`,{children:`RETRY CONNECTION`})]}),(i||r)&&(0,W.jsx)(`button`,{onClick:Ke,className:`w-full sm:w-auto px-5 py-2.5 bg-paper-white hover:bg-warm-sand-bg border-[3px] border-ink-black font-arcade text-xs font-bold text-ink-black gadget-shadow active:translate-x-0.5 active:translate-y-0.5 active:shadow-none transition-all flex items-center justify-center gap-2 cursor-pointer`,children:(0,W.jsx)(`span`,{children:`OPEN JOURNEY MAP`})})]})]})});if(k.length===0)return(0,W.jsx)(Te,{nextMilestone:z,activatingMilestone:B,onActivateNextMilestone:oe,onOpenOnboarding:Je,onOpenJourney:Ke,onOpenCreateProblem:qe,onOpenWindow:r,overrideProblemId:e,onClearOverride:t,hasCustomOnboardingModal:!!s,isOnboardingOpen:T,onCloseOnboarding:()=>E(!1),onCompletedOnboarding:H,currentUserId:V});let X=k[0],Z=X?.problems,Xe=Z?.problem_number??(/^\d+$/.test(X?.problem_id||``)?parseInt(X.problem_id,10):void 0),Q=I(Xe,Z?.id||X?.problem_id,Z?.name),{cleanTitle:Ze,approachVariant:Qe,pattern:$e}=le(Z?.name,Q?.name,Z?.pattern,Q?.pattern),$={...Q,...Z,id:Z?.id||Q?.id||X?.problem_id,name:Ze,problem_number:Z?.problem_number??Q?.problem_number,pattern:$e,approach_variant:Qe,difficulty:Z?.difficulty||Q?.difficulty||`Medium`,reference_code:Z?.reference_code||Q?.reference_solution||``,starter_code:Q?.starter_code||Z?.starter_code||``,description:Z?.description||Q?.description||``,optimal_time:Z?.optimal_time||Q?.time_complexity||`O(N)`,optimal_space:Z?.optimal_space||Q?.space_complexity||`O(1)`,examples:Z?.examples&&Z.examples.length>0?Z.examples:Q?.examples,constraints:Z?.constraints||Q?.constraints,how_to_solve:Z?.how_to_solve||``,solutions:Z?.solutions&&Z.solutions.length>0?Z.solutions:Q?.solutions},et=ce({...Q,...$,examples:$.examples&&$.examples.length>0?$.examples:Q?.examples,constraints:$.constraints&&(Array.isArray($.constraints)?$.constraints.length>0:$.constraints)?$.constraints:Q?.constraints}),tt=Q?.reference_solution||``,nt=Z?.reference_code||``,rt=nt&&(!tt||nt.trim()!==tt.trim())?nt:``,it=rt||tt||nt||``;return(0,W.jsxs)(`div`,{ref:w,className:`w-full h-full bg-[#fdf8e1] flex flex-col overflow-hidden select-none`,children:[(0,W.jsx)(he,{problem:$,totalInQueue:k.length,reviews:k,overrideProblemId:e,onSelectCard:We,onOpenCreateProblem:qe,onOpenEditProblem:()=>{o?o($):r?.(`editProblem`)}}),(0,W.jsxs)(`div`,{className:`${m?`flex`:`hidden`} shrink-0 bg-amber-100 border-b-[3px] border-ink-black px-2.5 sm:px-3 py-1.5 gap-1.5 sm:gap-2 overflow-x-auto no-scrollbar`,children:[(0,W.jsxs)(`button`,{onClick:()=>{y(`spec`),_(`spec`)},className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${v===`spec`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,W.jsx)(u,{className:`w-3 h-3 shrink-0`}),(0,W.jsx)(`span`,{children:`SPEC`})]}),(0,W.jsxs)(`button`,{onClick:()=>y(`code`),className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${v===`code`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,W.jsx)(b,{className:`w-3 h-3 shrink-0`}),(0,W.jsx)(`span`,{children:`CODE STUDIO`})]}),(0,W.jsxs)(`button`,{onClick:()=>{y(`ref`),_(`ref`)},className:`px-2.5 sm:px-3 py-1 text-[9px] font-arcade font-bold border-2 border-ink-black transition-all cursor-pointer flex items-center gap-1.5 whitespace-nowrap ${v===`ref`?`bg-paper-white translate-y-0.5 shadow-none text-ink-black`:`bg-white shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] text-trash-gray`}`,children:[(0,W.jsx)(f,{className:`w-3 h-3 shrink-0`}),(0,W.jsx)(`span`,{children:`SOLUTION`})]})]}),(0,W.jsxs)(`div`,{className:`flex-1 flex ${m?`flex-col`:`flex-row`} overflow-hidden min-h-0`,children:[(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-8 bg-paper-white ${m?`h-64`:`border-r-[4px] border-ink-black`} font-sans text-xs text-trash-gray select-none`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-arcade text-[10px] text-ink-black`,children:[(0,W.jsx)(n,{className:`w-4 h-4 animate-spin text-[#0ea5e9]`}),(0,W.jsx)(`span`,{children:`Loading Problem Spec...`})]})}),children:(0,W.jsx)(De,{leftTab:g,onSelectLeftTab:e=>{_(e),e===`ref`?y(`ref`):e===`spec`&&y(`spec`)},mobileView:v,isNarrow:m,problem:$,parsed:et,userSolution:rt,officialSolution:tt,effectiveReferenceCode:it,copiedSnippet:x,onCopyText:Ge,saveRefError:ye,aiSolutionLoading:Me,aiSolutionError:Ne,onFetchAiSolution:()=>Ie(X,e=>{A(t=>t.map((t,n)=>n===0?{...t,problems:{...$||{},...t.problems||{},reference_code:e}}:t))}),explainLoading:ke,explainError:je,explanationText:Ae,onExplainCode:(e,t,n,r)=>Fe(X,e,t,n,r),activeReview:X,onUpdateSolutions:Ye,onEditProblem:()=>{o?o($):r?.(`editProblem`)}})}),(0,W.jsx)(Ce,{mobileView:v,isNarrow:m,isAutocompleteEnabled:D,onToggleAutocomplete:e=>{O(e),localStorage.setItem(`isAutocompleteEnabled`,String(e))},onResetStarterCode:se,code:R,onChangeCode:ne,sandboxRunning:ue,sandboxError:ge,sandboxResults:de,onRunSandbox:()=>be(X,R),savingReference:_e,savedRefSuccess:ve,saveRefError:ye,onSaveReference:()=>xe(X,R,(e,t)=>{A(n=>n.map((n,r)=>r===0?{...n,problem_id:t||n.problem_id,problems:{...$||{},...n.problems||{},id:t||n.problems?.id||n.problem_id,reference_code:e}}:n))}),aiLoading:Se,aiError:Oe,aiResult:Ee,onAiEvaluation:()=>Pe(X,R),optimalTime:$.optimal_time||`O(N)`,optimalSpace:$.optimal_space||`O(1)`,onPushToGitHub:He,pushingToGitHub:Le,githubPushedUrl:ze,githubPushError:Ve})]}),(0,W.jsx)(we,{gradeError:F,onDismissGradeError:()=>L(null),submitting:N,submittingRating:P,onGrade:Y}),!s&&(0,W.jsx)(re,{isOpen:T,onClose:()=>E(!1),onCompleted:H,userId:V})]})}export{Oe as default,ue as n,Ee as t};
 
 
 
 
 
 
algospaced-ui/dist/assets/Settings-ACJ113RL.js DELETED
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,Bt as r,E as i,J as a,K as o,O as s,Rt as c,Z as l,a as ee,at as u,d,et as f,ft as p,mt as m,nt as h,tt as g,x as _,y as v}from"./vendor-react-CIO8MTK1.js";import{_ as y,d as b,f as x,h as S,m as C,p as w}from"./index-DnK6BACV.js";import{a as te,i as ne,n as re,r as T,s as E,t as D}from"./githubSyncService-x0Mm_uEl.js";var O=e(r(),1),k=c(),A=[{id:`default`,name:`Default`,desc:`Subject to Availability`},{id:`groq`,name:`Groq`,badge:`Fastest`,desc:`Llama 3.3 & Qwen`,keyPrefix:`gsk_...`,portalUrl:`https://console.groq.com/keys`},{id:`gemini`,name:`Google Gemini`,desc:`Gemini 2.5 / 3.5`,keyPrefix:`AIzaSy...`,portalUrl:`https://aistudio.google.com/app/apikey`},{id:`openrouter`,name:`OpenRouter`,desc:`Multi-Provider`,keyPrefix:`sk-or-v1-...`,portalUrl:`https://openrouter.ai/keys`}];function j(){let[e,r]=(0,O.useState)(()=>localStorage.getItem(`algospaced_custom_ai_provider`)||`default`),[c,j]=(0,O.useState)(()=>localStorage.getItem(`algospaced_custom_api_key`)||localStorage.getItem(`sandbox_gemini_api_key`)||``),[M,N]=(0,O.useState)(!1),[P,F]=(0,O.useState)(null),[I,L]=(0,O.useState)(()=>b()),[R,z]=(0,O.useState)(null),[B,V]=(0,O.useState)(()=>x().currentFloor),[H,U]=(0,O.useState)(()=>T()),[W,G]=(0,O.useState)(()=>ne()),[K,q]=(0,O.useState)(!1),[J,Y]=(0,O.useState)(null),X=!!(H.token&&(H.username||W?.login)),Z=!!(c.trim()&&e!=="default"),Q=e!=="default"&&!c.trim(),$=A.find(t=>t.id===e),ie=e=>{r(e),localStorage.setItem(`algospaced_custom_ai_provider`,e),F(e==="default"?{type:`info`,text:`Switched to Server Default (Shared Pool).`}:{type:`info`,text:`Switched to ${e.toUpperCase()}.`}),setTimeout(()=>F(null),3e3)},ae=()=>{let t=c.trim();if(!t){F({type:`error`,text:`Please enter an API key for ${e.toUpperCase()}.`}),setTimeout(()=>F(null),3e3);return}localStorage.setItem(`algospaced_custom_api_key`,t),localStorage.setItem(`sandbox_gemini_api_key`,t),localStorage.setItem(`algospaced_custom_ai_provider`,e),F({type:`success`,text:`${e.toUpperCase()} API key saved successfully.`}),setTimeout(()=>F(null),3e3)},oe=()=>{localStorage.removeItem(`algospaced_custom_api_key`),localStorage.removeItem(`sandbox_gemini_api_key`),j(``),F({type:`info`,text:`Cleared custom API key.`}),setTimeout(()=>F(null),3e3)},se=()=>{localStorage.removeItem(`algospaced_custom_api_key`),localStorage.removeItem(`sandbox_gemini_api_key`),localStorage.setItem(`algospaced_custom_ai_provider`,`default`),j(``),r(`default`),F({type:`info`,text:`Reset to Server Default provider.`}),setTimeout(()=>F(null),3e3)},ce=()=>{C(I),z({type:`success`,text:`Princess Companion settings saved!`}),setTimeout(()=>z(null),3e3)},le=()=>{L(S),C(S),z({type:`info`,text:`Reset companion to default settings.`}),setTimeout(()=>z(null),3e3)},ue=()=>{if(window.confirm(`Are you sure you want to reset your Spire Journey progress back to 0 problems?`)){let e=w();V(e.currentFloor),z({type:`info`,text:`Spire journey progress reset to 0 problems.`}),setTimeout(()=>z(null),3e3)}},de=async()=>{q(!0),Y(null);try{let{token:e,user:t}=await re();G(t);let n=T();U(n);try{await te(e,n.repoName,n.isPrivate)}catch{}Y({type:`success`,text:`Connected to GitHub as @${t.login}!`}),setTimeout(()=>Y(null),4e3)}catch(e){Y({type:`error`,text:e.message||`GitHub connection failed.`}),setTimeout(()=>Y(null),5e3)}finally{q(!1)}},fe=()=>{D(),U(T()),G(null),Y({type:`info`,text:`Disconnected from GitHub.`}),setTimeout(()=>Y(null),3e3)},pe=e=>{E({autoCommit:e}),U(t=>({...t,autoCommit:e})),Y({type:`info`,text:e?`Auto-commit enabled for review submissions.`:`Auto-commit disabled.`}),setTimeout(()=>Y(null),3e3)};return(0,k.jsxs)(`div`,{className:`w-full h-full bg-[#fdf8e1] p-5 sm:p-6 flex flex-col gap-4 select-none font-sans text-ink-black overflow-y-auto custom-scrollbar`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-b-[3px] border-ink-black pb-2.5`,children:[(0,k.jsxs)(`h3`,{className:`font-headline-md font-bold text-sm m-0 flex items-center gap-2 tracking-wide`,children:[(0,k.jsx)(o,{className:`w-4 h-4 text-ink-black`}),`API & AI Configuration`]}),(0,k.jsx)(`p`,{className:`text-[11px] text-trash-gray font-medium m-0`,children:`Configure your AI model provider..`})]}),(0,k.jsx)(`div`,{className:`px-4 py-3 border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] transition-all ${Z?`bg-emerald-50`:Q?`bg-rose-50`:`bg-amber-50/70`}`,children:(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Z?(0,k.jsx)(ee,{className:`w-4 h-4 text-emerald-600 shrink-0`}):Q?(0,k.jsx)(m,{className:`w-4 h-4 text-rose-600 shrink-0`}):(0,k.jsx)(h,{className:`w-4 h-4 text-amber-600 shrink-0`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`text-xs font-bold font-headline-md text-ink-black flex items-center gap-1.5`,children:(0,k.jsxs)(`span`,{children:[`Active:`,` `,Z?`${e.toUpperCase()} (Custom Key)`:Q?`${e.toUpperCase()} (Key Required)`:`Default`]})}),(0,k.jsx)(`div`,{className:`text-[10px] text-trash-gray font-medium`,children:Z?`Requests are routed directly through your personal API key.`:Q?`Enter your API key below to activate this provider.`:`Using basic, free built-in developer keys with auto-failover.`})]})]}),(0,k.jsx)(`span`,{className:`px-2 py-0.5 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black shrink-0 ${Z?`bg-emerald-300 text-emerald-950`:Q?`bg-rose-300 text-rose-950`:`bg-amber-200 text-amber-950`}`,children:Z?`ACTIVE`:Q?`NEEDS KEY`:`LIMITED`})]})}),(0,k.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider mb-2 font-headline-md flex items-center gap-1.5`,children:[(0,k.jsx)(h,{className:`w-3.5 h-3.5 text-ink-black`}),`Select Provider`]}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:A.map(t=>{let n=e===t.id;return(0,k.jsxs)(`button`,{type:`button`,onClick:()=>ie(t.id),className:`p-2.5 border-[2px] text-left transition-all cursor-pointer flex flex-col justify-between rounded ${n?`border-ink-black bg-[#ffe24c] shadow-[2px_2px_0px_0px_#1E293B] font-bold`:`border-slate-300 bg-slate-50 hover:bg-slate-100 text-slate-700`}`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,k.jsx)(`span`,{className:`text-xs font-bold font-headline-md`,children:t.name}),t.badge&&(0,k.jsx)(`span`,{className:`text-[8px] font-bold uppercase px-1 py-0.2 bg-orange-100 text-orange-700 rounded border border-orange-300`,children:t.badge})]}),(0,k.jsx)(`span`,{className:`text-[9px] mt-1 text-slate-600 leading-tight block`,children:t.desc})]},t.id)})})]}),e==="default"?(0,k.jsxs)(`div`,{className:`p-3.5 bg-slate-50 border border-slate-200 rounded flex items-start gap-3`,children:[(0,k.jsx)(d,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs text-slate-700`,children:[(0,k.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`Shared Quotas (`,(0,k.jsx)(`i`,{children:`limited`}),`)`]}),(0,k.jsx)(`p`,{className:`text-[11px] text-trash-gray m-0 leading-relaxed`,children:`Powered by shared, basic developer keys. Because limits are shared with everyone, requests may fail. Use your own provider keys above for stable performance.`})]})]}):(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md flex items-center gap-1.5`,children:[(0,k.jsx)(o,{className:`w-3.5 h-3.5 text-ink-black`}),$?.name,` API Key`]}),$?.portalUrl&&(0,k.jsxs)(`a`,{href:$.portalUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-[10px] text-sky-600 hover:text-sky-800 font-medium flex items-center gap-1 no-underline`,children:[(0,k.jsx)(`span`,{children:`Get API Key`}),(0,k.jsx)(g,{className:`w-3 h-3`})]})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(`input`,{type:M?`text`:`password`,value:c,onChange:e=>j(e.target.value),placeholder:`Enter ${$?.keyPrefix||`API Key`}`,className:`w-full bg-white border-[2px] border-ink-black rounded py-2 pl-3 pr-9 text-ink-black placeholder-slate-400 focus:outline-none focus:border-sky-600 text-xs font-code-mono`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>N(!M),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-trash-gray hover:text-ink-black cursor-pointer bg-transparent border-0 outline-none p-1`,title:M?`Hide API key`:`Show API key`,children:M?(0,k.jsx)(f,{className:`w-3.5 h-3.5`}):(0,k.jsx)(t,{className:`w-3.5 h-3.5`})})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-trash-gray font-medium`,children:[(0,k.jsx)(_,{className:`w-3.5 h-3.5 text-emerald-600 shrink-0`}),(0,k.jsx)(`span`,{children:`Stored locally in your browser. Sent directly via request headers.`})]}),(0,k.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,k.jsxs)(`button`,{onClick:ae,className:`flex-1 flex items-center justify-center gap-1.5 py-2 border-[2px] border-ink-black bg-[#ffe24c] hover:bg-yellow-300 text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:[(0,k.jsx)(i,{className:`w-3.5 h-3.5`}),`Save Key`]}),c&&(0,k.jsx)(`button`,{onClick:oe,className:`px-3 py-2 border-[2px] border-slate-300 bg-white hover:bg-slate-50 text-xs font-bold text-slate-700 hover:text-rose-600 shadow-[2px_2px_0px_0px_rgba(0,0,0,0.05)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:`Clear Key`})]})]}),P&&(0,k.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${P.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:P.type===`error`?`bg-rose-100 border-rose-600 text-rose-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[P.type===`success`?(0,k.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}):P.type===`error`?(0,k.jsx)(m,{className:`w-3.5 h-3.5 shrink-0`}):(0,k.jsx)(a,{className:`w-3.5 h-3.5 shrink-0`}),P.text]}),e!=="default"&&(0,k.jsx)(`div`,{className:`pt-2 border-t border-slate-200 flex justify-end`,children:(0,k.jsxs)(`button`,{onClick:se,className:`flex items-center gap-1.5 py-1.5 px-3 border border-slate-300 bg-slate-50 hover:bg-slate-100 text-[11px] font-bold text-slate-600 hover:text-ink-black transition-all cursor-pointer rounded`,children:[(0,k.jsx)(s,{className:`w-3 h-3 text-slate-500`}),`Reset to Server Default`]})})]}),(0,k.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,k.jsx)(`div`,{className:`w-8 h-8 rounded bg-[#24292e] border-[2px] border-ink-black flex items-center justify-center text-white shadow-[1px_1px_0px_0px_#1E293B]`,children:(0,k.jsx)(l,{className:`w-4 h-4 text-white`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black m-0 flex items-center gap-2`,children:`GitHub Solutions Sync & Auto-Commit`}),(0,k.jsx)(`p`,{className:`text-[10px] text-trash-gray font-medium m-0`,children:`Sync solutions to personal GitHub repository and commit automatically on submission`})]})]}),(0,k.jsx)(`span`,{className:`px-2 py-0.5 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black shrink-0 ${X?`bg-emerald-300 text-emerald-950`:`bg-slate-200 text-slate-800`}`,children:X?`CONNECTED`:`DISCONNECTED`})]}),X?(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-2 p-3 bg-slate-50 border border-slate-200 rounded`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[W?.avatar_url&&(0,k.jsx)(`img`,{src:W.avatar_url,alt:W.login,className:`w-7 h-7 rounded-full border border-ink-black`}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`span`,{className:`text-xs font-bold text-ink-black`,children:[`@`,W?.login||H.username]}),(0,k.jsxs)(`span`,{className:`text-[11px] text-slate-600 font-mono block`,children:[H.username,`/`,H.repoName,` (`,H.branch,`)`]})]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`a`,{href:`https://github.com/${H.username}/${H.repoName}`,target:`_blank`,rel:`noopener noreferrer`,className:`px-2.5 py-1 text-[11px] font-bold bg-white hover:bg-slate-100 text-ink-black border border-slate-300 rounded no-underline flex items-center gap-1 cursor-pointer`,children:[(0,k.jsx)(g,{className:`w-3 h-3`}),(0,k.jsx)(`span`,{children:`View Repo`})]}),(0,k.jsx)(`button`,{type:`button`,onClick:fe,className:`px-2.5 py-1 text-[11px] font-bold bg-white hover:bg-rose-50 text-rose-700 border border-rose-300 rounded cursor-pointer`,children:`Disconnect`})]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-emerald-50/50 border border-emerald-300 rounded cursor-pointer`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:H.autoCommit,onChange:e=>pe(e.target.checked),className:`w-4 h-4 accent-emerald-600 cursor-pointer`}),(0,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,k.jsxs)(`span`,{className:`text-[10px] text-trash-gray`,children:[`Automatically pushes your code to `,H.repoName,` whenever you grade a review card.`]})]})]})]}):(0,k.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 p-3.5 bg-slate-50 border border-slate-200 rounded`,children:[(0,k.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,k.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Connect your GitHub Account (1-Click OAuth)`}),(0,k.jsx)(`p`,{className:`text-[11px] text-trash-gray m-0`,children:`Grant repository access to automatically sync your DSA problem solutions as you study.`})]}),(0,k.jsx)(`button`,{type:`button`,onClick:de,disabled:K,className:`px-4 py-2 bg-[#24292e] hover:bg-black text-white text-xs font-bold uppercase rounded border-2 border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none flex items-center gap-2 shrink-0 cursor-pointer disabled:opacity-50`,children:K?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n,{className:`w-3.5 h-3.5 animate-spin`}),(0,k.jsx)(`span`,{children:`CONNECTING...`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(l,{className:`w-3.5 h-3.5 text-yellow-300`}),(0,k.jsx)(`span`,{children:`CONNECT GITHUB`})]})})]}),J&&(0,k.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${J.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:J.type===`error`?`bg-rose-100 border-rose-600 text-rose-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[J.type===`success`?(0,k.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}):J.type===`error`?(0,k.jsx)(m,{className:`w-3.5 h-3.5 shrink-0`}):(0,k.jsx)(a,{className:`w-3.5 h-3.5 shrink-0`}),J.text]})]}),(0,k.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`div`,{className:`w-7 h-7 rounded bg-[#FFE24C] border-[2px] border-ink-black flex items-center justify-center shadow-[1px_1px_0px_0px_#1E293B]`,children:(0,k.jsx)(v,{className:`w-4 h-4 text-ink-black`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black m-0`,children:`Princess AI Companion & RPG Settings`}),(0,k.jsx)(`p`,{className:`text-[10px] text-trash-gray font-medium m-0`,children:`Trapped Princess Persona, Study Break Timer & 8-bit RPG Audio`})]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-bold text-ink-black font-headline-md uppercase`,children:I.enabled?`Enabled`:`Disabled`}),(0,k.jsx)(`input`,{type:`checkbox`,checked:I.enabled,onChange:e=>L(t=>({...t,enabled:e.target.checked})),className:`w-4 h-4 accent-amber-500 cursor-pointer`})]})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Companion Name`}),(0,k.jsx)(`input`,{type:`text`,value:I.name,onChange:e=>L(t=>({...t,name:e.target.value})),placeholder:`e.g. Princess Aurelia`,className:`bg-white border-[2px] border-ink-black rounded py-2 px-3 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600`})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md flex items-center gap-1`,children:[(0,k.jsx)(u,{className:`w-3.5 h-3.5 text-amber-700`}),`Study Break Reminder`]}),(0,k.jsxs)(`select`,{value:I.breakIntervalMinutes,onChange:e=>L(t=>({...t,breakIntervalMinutes:Number(e.target.value)})),className:`bg-white border-[2px] border-ink-black rounded py-2 px-3 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600 cursor-pointer`,children:[(0,k.jsx)(`option`,{value:25,children:`Every 25 Minutes (Classic Pomodoro)`}),(0,k.jsx)(`option`,{value:45,children:`Every 45 Minutes`}),(0,k.jsx)(`option`,{value:60,children:`Every 60 Minutes`}),(0,k.jsx)(`option`,{value:0,children:`Disabled (No automatic break popups)`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Princess Backstory & Persona Prompt`}),(0,k.jsx)(`textarea`,{rows:2,value:I.backstory,onChange:e=>L(t=>({...t,backstory:e.target.value})),placeholder:`Describe her background, tone, and connection to your DSA studies...`,className:`bg-white border-[2px] border-ink-black rounded p-2.5 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600 resize-y`})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1`,children:[(0,k.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-white border border-slate-300 rounded cursor-pointer hover:border-ink-black transition-all`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:I.soundEnabled,onChange:e=>{let t=e.target.checked;L(e=>({...e,soundEnabled:t})),y(!t)},className:`w-4 h-4 accent-amber-500 cursor-pointer`}),(0,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`8-bit Sound Effects`}),(0,k.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Audio chimes & fanfare`})]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-white border border-slate-300 rounded cursor-pointer hover:border-ink-black transition-all`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:I.autoPopupEnabled,onChange:e=>L(t=>({...t,autoPopupEnabled:e.target.checked})),className:`w-4 h-4 accent-amber-500 cursor-pointer`}),(0,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Spontaneous RPG Popups`}),(0,k.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Speech bubbles for breaks & milestones`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-slate-200`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:ce,className:`flex items-center gap-1.5 py-2 px-4 border-[2px] border-ink-black bg-[#ffe24c] hover:bg-yellow-300 text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:[(0,k.jsx)(i,{className:`w-3.5 h-3.5`}),`Save Companion Settings`]}),(0,k.jsx)(`button`,{type:`button`,onClick:le,className:`py-2 px-3 border border-slate-300 bg-white hover:bg-slate-50 text-xs font-bold text-slate-700 transition-all cursor-pointer rounded`,children:`Default Persona`})]}),(0,k.jsxs)(`button`,{type:`button`,onClick:ue,className:`flex items-center gap-1 py-1.5 px-3 border border-rose-300 bg-rose-50 hover:bg-rose-100 text-rose-700 text-[11px] font-bold transition-all cursor-pointer rounded`,children:[(0,k.jsx)(s,{className:`w-3 h-3 text-rose-500`}),(0,k.jsxs)(`span`,{children:[`Reset Journey (`,B,`/150 LC)`]})]})]}),R&&(0,k.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${R.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[(0,k.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),R.text]})]}),(0,k.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(a,{className:`w-3.5 h-3.5 text-[#0ea5e9]`}),(0,k.jsx)(`h4`,{className:`text-xs font-bold uppercase font-headline-md m-0`,children:`Get Free API Keys`})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-2 text-[10px]`,children:[(0,k.jsxs)(`a`,{href:`https://console.groq.com/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`Groq Cloud`}),(0,k.jsx)(g,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Fast inference with generous free rate limits.`})]}),(0,k.jsxs)(`a`,{href:`https://aistudio.google.com/app/apikey`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`Google AI Studio`}),(0,k.jsx)(g,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Free Gemini Flash API quota.`})]}),(0,k.jsxs)(`a`,{href:`https://openrouter.ai/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`OpenRouter`}),(0,k.jsx)(g,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Unified API for open-weights models.`})]})]})]})]})}export{j as default};
 
 
algospaced-ui/dist/assets/Settings-BVuXk3LW.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,Bt as n,C as r,Ht as i,J as a,M as ee,O as o,X as s,_t as c,a as l,at as u,ct as d,d as te,et as f,ht as p,it as m,nt as h,rt as g,x as _}from"./vendor-react-hnaVBnLv.js";import{_ as v,d as ne,f as re,h as y,m as b,p as x}from"./index-DVWZ15xt.js";import{a as S,i as C,n as w,r as T,s as E,t as D}from"./githubSyncService-x0Mm_uEl.js";var O=e(i(),1),k=n(),A=[{id:`default`,name:`Default`,desc:`Subject to Availability`},{id:`groq`,name:`Groq`,badge:`Fastest`,desc:`Llama 3.3 & Qwen`,keyPrefix:`gsk_...`,portalUrl:`https://console.groq.com/keys`},{id:`gemini`,name:`Google Gemini`,desc:`Gemini 2.5 / 3.5`,keyPrefix:`AIzaSy...`,portalUrl:`https://aistudio.google.com/app/apikey`},{id:`openrouter`,name:`OpenRouter`,desc:`Multi-Provider`,keyPrefix:`sk-or-v1-...`,portalUrl:`https://openrouter.ai/keys`}];function j(){let[e,n]=(0,O.useState)(()=>localStorage.getItem(`algospaced_custom_ai_provider`)||`default`),[i,j]=(0,O.useState)(()=>localStorage.getItem(`algospaced_custom_api_key`)||localStorage.getItem(`sandbox_gemini_api_key`)||``),[M,ie]=(0,O.useState)(!1),[N,P]=(0,O.useState)(null),[F,I]=(0,O.useState)(()=>ne()),[L,R]=(0,O.useState)(null),[z,B]=(0,O.useState)(()=>re().currentFloor),[V,H]=(0,O.useState)(()=>T()),[U,W]=(0,O.useState)(()=>C()),[G,K]=(0,O.useState)(!1),[q,J]=(0,O.useState)(null),Y=!!(V.token&&(V.username||U?.login)),X=!!(i.trim()&&e!=="default"),Z=e!=="default"&&!i.trim(),Q=A.find(t=>t.id===e),ae=e=>{n(e),localStorage.setItem(`algospaced_custom_ai_provider`,e),P(e==="default"?{type:`info`,text:`Switched to Server Default (Shared Pool).`}:{type:`info`,text:`Switched to ${e.toUpperCase()}.`}),setTimeout(()=>P(null),3e3)},oe=()=>{let t=i.trim();if(!t){P({type:`error`,text:`Please enter an API key for ${e.toUpperCase()}.`}),setTimeout(()=>P(null),3e3);return}localStorage.setItem(`algospaced_custom_api_key`,t),localStorage.setItem(`sandbox_gemini_api_key`,t),localStorage.setItem(`algospaced_custom_ai_provider`,e),P({type:`success`,text:`${e.toUpperCase()} API key saved successfully.`}),setTimeout(()=>P(null),3e3)},$=()=>{localStorage.removeItem(`algospaced_custom_api_key`),localStorage.removeItem(`sandbox_gemini_api_key`),j(``),P({type:`info`,text:`Cleared custom API key.`}),setTimeout(()=>P(null),3e3)},se=()=>{localStorage.removeItem(`algospaced_custom_api_key`),localStorage.removeItem(`sandbox_gemini_api_key`),localStorage.setItem(`algospaced_custom_ai_provider`,`default`),j(``),n(`default`),P({type:`info`,text:`Reset to Server Default provider.`}),setTimeout(()=>P(null),3e3)},ce=()=>{b(F),R({type:`success`,text:`Princess Companion settings saved!`}),setTimeout(()=>R(null),3e3)},le=()=>{I(y),b(y),R({type:`info`,text:`Reset companion to default settings.`}),setTimeout(()=>R(null),3e3)},ue=()=>{if(window.confirm(`Are you sure you want to reset your Spire Journey progress back to 0 problems?`)){let e=x();B(e.currentFloor),R({type:`info`,text:`Spire journey progress reset to 0 problems.`}),setTimeout(()=>R(null),3e3)}},de=async()=>{K(!0),J(null);try{let{token:e,user:t}=await w();W(t);let n=T();H(n);try{await S(e,n.repoName,n.isPrivate)}catch{}J({type:`success`,text:`Connected to GitHub as @${t.login}!`}),setTimeout(()=>J(null),4e3)}catch(e){J({type:`error`,text:e.message||`GitHub connection failed.`}),setTimeout(()=>J(null),5e3)}finally{K(!1)}},fe=()=>{D(),H(T()),W(null),J({type:`info`,text:`Disconnected from GitHub.`}),setTimeout(()=>J(null),3e3)},pe=e=>{E({autoCommit:e}),H(t=>({...t,autoCommit:e})),J({type:`info`,text:e?`Auto-commit enabled for review submissions.`:`Auto-commit disabled.`}),setTimeout(()=>J(null),3e3)};return(0,k.jsxs)(`div`,{className:`w-full h-full bg-[#fdf8e1] p-5 sm:p-6 flex flex-col gap-4 select-none font-sans text-ink-black overflow-y-auto custom-scrollbar`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-b-[3px] border-ink-black pb-2.5`,children:[(0,k.jsxs)(`h3`,{className:`font-headline-md font-bold text-sm m-0 flex items-center gap-2 tracking-wide`,children:[(0,k.jsx)(a,{className:`w-4 h-4 text-ink-black`}),`API & AI Configuration`]}),(0,k.jsx)(`p`,{className:`text-[11px] text-trash-gray font-medium m-0`,children:`Configure your AI model provider..`})]}),(0,k.jsx)(`div`,{className:`px-4 py-3 border-[3px] border-ink-black shadow-[3px_3px_0px_0px_rgba(30,41,59,1)] transition-all ${X?`bg-emerald-50`:Z?`bg-rose-50`:`bg-amber-50/70`}`,children:(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[X?(0,k.jsx)(l,{className:`w-4 h-4 text-emerald-600 shrink-0`}):Z?(0,k.jsx)(c,{className:`w-4 h-4 text-rose-600 shrink-0`}):(0,k.jsx)(u,{className:`w-4 h-4 text-amber-600 shrink-0`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`text-xs font-bold font-headline-md text-ink-black flex items-center gap-1.5`,children:(0,k.jsxs)(`span`,{children:[`Active:`,` `,X?`${e.toUpperCase()} (Custom Key)`:Z?`${e.toUpperCase()} (Key Required)`:`Default`]})}),(0,k.jsx)(`div`,{className:`text-[10px] text-trash-gray font-medium`,children:X?`Requests are routed directly through your personal API key.`:Z?`Enter your API key below to activate this provider.`:`Using basic, free built-in developer keys with auto-failover.`})]})]}),(0,k.jsx)(`span`,{className:`px-2 py-0.5 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black shrink-0 ${X?`bg-emerald-300 text-emerald-950`:Z?`bg-rose-300 text-rose-950`:`bg-amber-200 text-amber-950`}`,children:X?`ACTIVE`:Z?`NEEDS KEY`:`LIMITED`})]})}),(0,k.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider mb-2 font-headline-md flex items-center gap-1.5`,children:[(0,k.jsx)(u,{className:`w-3.5 h-3.5 text-ink-black`}),`Select Provider`]}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:A.map(t=>{let n=e===t.id;return(0,k.jsxs)(`button`,{type:`button`,onClick:()=>ae(t.id),className:`p-2.5 border-[2px] text-left transition-all cursor-pointer flex flex-col justify-between rounded ${n?`border-ink-black bg-[#ffe24c] shadow-[2px_2px_0px_0px_#1E293B] font-bold`:`border-slate-300 bg-slate-50 hover:bg-slate-100 text-slate-700`}`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,k.jsx)(`span`,{className:`text-xs font-bold font-headline-md`,children:t.name}),t.badge&&(0,k.jsx)(`span`,{className:`text-[8px] font-bold uppercase px-1 py-0.2 bg-orange-100 text-orange-700 rounded border border-orange-300`,children:t.badge})]}),(0,k.jsx)(`span`,{className:`text-[9px] mt-1 text-slate-600 leading-tight block`,children:t.desc})]},t.id)})})]}),e==="default"?(0,k.jsxs)(`div`,{className:`p-3.5 bg-slate-50 border border-slate-200 rounded flex items-start gap-3`,children:[(0,k.jsx)(te,{className:`w-4 h-4 text-amber-500 shrink-0 mt-0.5`}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs text-slate-700`,children:[(0,k.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`Shared Quotas (`,(0,k.jsx)(`i`,{children:`limited`}),`)`]}),(0,k.jsx)(`p`,{className:`text-[11px] text-trash-gray m-0 leading-relaxed`,children:`Powered by shared, basic developer keys. Because limits are shared with everyone, requests may fail. Use your own provider keys above for stable performance.`})]})]}):(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md flex items-center gap-1.5`,children:[(0,k.jsx)(a,{className:`w-3.5 h-3.5 text-ink-black`}),Q?.name,` API Key`]}),Q?.portalUrl&&(0,k.jsxs)(`a`,{href:Q.portalUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-[10px] text-sky-600 hover:text-sky-800 font-medium flex items-center gap-1 no-underline`,children:[(0,k.jsx)(`span`,{children:`Get API Key`}),(0,k.jsx)(m,{className:`w-3 h-3`})]})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(`input`,{type:M?`text`:`password`,value:i,onChange:e=>j(e.target.value),placeholder:`Enter ${Q?.keyPrefix||`API Key`}`,className:`w-full bg-white border-[2px] border-ink-black rounded py-2 pl-3 pr-9 text-ink-black placeholder-slate-400 focus:outline-none focus:border-sky-600 text-xs font-code-mono`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>ie(!M),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-trash-gray hover:text-ink-black cursor-pointer bg-transparent border-0 outline-none p-1`,title:M?`Hide API key`:`Show API key`,children:M?(0,k.jsx)(g,{className:`w-3.5 h-3.5`}):(0,k.jsx)(h,{className:`w-3.5 h-3.5`})})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-trash-gray font-medium`,children:[(0,k.jsx)(r,{className:`w-3.5 h-3.5 text-emerald-600 shrink-0`}),(0,k.jsx)(`span`,{children:`Stored locally in your browser. Sent directly via request headers.`})]}),(0,k.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,k.jsxs)(`button`,{onClick:oe,className:`flex-1 flex items-center justify-center gap-1.5 py-2 border-[2px] border-ink-black bg-[#ffe24c] hover:bg-yellow-300 text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:[(0,k.jsx)(o,{className:`w-3.5 h-3.5`}),`Save Key`]}),i&&(0,k.jsx)(`button`,{onClick:$,className:`px-3 py-2 border-[2px] border-slate-300 bg-white hover:bg-slate-50 text-xs font-bold text-slate-700 hover:text-rose-600 shadow-[2px_2px_0px_0px_rgba(0,0,0,0.05)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:`Clear Key`})]})]}),N&&(0,k.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${N.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:N.type===`error`?`bg-rose-100 border-rose-600 text-rose-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[N.type===`success`?(0,k.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}):N.type===`error`?(0,k.jsx)(c,{className:`w-3.5 h-3.5 shrink-0`}):(0,k.jsx)(s,{className:`w-3.5 h-3.5 shrink-0`}),N.text]}),e!=="default"&&(0,k.jsx)(`div`,{className:`pt-2 border-t border-slate-200 flex justify-end`,children:(0,k.jsxs)(`button`,{onClick:se,className:`flex items-center gap-1.5 py-1.5 px-3 border border-slate-300 bg-slate-50 hover:bg-slate-100 text-[11px] font-bold text-slate-600 hover:text-ink-black transition-all cursor-pointer rounded`,children:[(0,k.jsx)(t,{className:`w-3 h-3 text-slate-500`}),`Reset to Server Default`]})})]}),(0,k.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,k.jsx)(`div`,{className:`w-8 h-8 rounded bg-[#24292e] border-[2px] border-ink-black flex items-center justify-center text-white shadow-[1px_1px_0px_0px_#1E293B]`,children:(0,k.jsx)(f,{className:`w-4 h-4 text-white`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black m-0 flex items-center gap-2`,children:`GitHub Solutions Sync & Auto-Commit`}),(0,k.jsx)(`p`,{className:`text-[10px] text-trash-gray font-medium m-0`,children:`Sync solutions to personal GitHub repository and commit automatically on submission`})]})]}),(0,k.jsx)(`span`,{className:`px-2 py-0.5 text-[9px] font-bold font-arcade uppercase border-2 border-ink-black shrink-0 ${Y?`bg-emerald-300 text-emerald-950`:`bg-slate-200 text-slate-800`}`,children:Y?`CONNECTED`:`DISCONNECTED`})]}),Y?(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-2 p-3 bg-slate-50 border border-slate-200 rounded`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[U?.avatar_url&&(0,k.jsx)(`img`,{src:U.avatar_url,alt:U.login,className:`w-7 h-7 rounded-full border border-ink-black`}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`span`,{className:`text-xs font-bold text-ink-black`,children:[`@`,U?.login||V.username]}),(0,k.jsxs)(`span`,{className:`text-[11px] text-slate-600 font-mono block`,children:[V.username,`/`,V.repoName,` (`,V.branch,`)`]})]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`a`,{href:`https://github.com/${V.username}/${V.repoName}`,target:`_blank`,rel:`noopener noreferrer`,className:`px-2.5 py-1 text-[11px] font-bold bg-white hover:bg-slate-100 text-ink-black border border-slate-300 rounded no-underline flex items-center gap-1 cursor-pointer`,children:[(0,k.jsx)(m,{className:`w-3 h-3`}),(0,k.jsx)(`span`,{children:`View Repo`})]}),(0,k.jsx)(`button`,{type:`button`,onClick:fe,className:`px-2.5 py-1 text-[11px] font-bold bg-white hover:bg-rose-50 text-rose-700 border border-rose-300 rounded cursor-pointer`,children:`Disconnect`})]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-emerald-50/50 border border-emerald-300 rounded cursor-pointer`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:V.autoCommit,onChange:e=>pe(e.target.checked),className:`w-4 h-4 accent-emerald-600 cursor-pointer`}),(0,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Auto-commit on every submission`}),(0,k.jsxs)(`span`,{className:`text-[10px] text-trash-gray`,children:[`Automatically pushes your code to `,V.repoName,` whenever you grade a review card.`]})]})]})]}):(0,k.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 p-3.5 bg-slate-50 border border-slate-200 rounded`,children:[(0,k.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,k.jsx)(`span`,{className:`text-xs font-bold text-ink-black block`,children:`Connect your GitHub Account (1-Click OAuth)`}),(0,k.jsx)(`p`,{className:`text-[11px] text-trash-gray m-0`,children:`Grant repository access to automatically sync your DSA problem solutions as you study.`})]}),(0,k.jsx)(`button`,{type:`button`,onClick:de,disabled:G,className:`px-4 py-2 bg-[#24292e] hover:bg-black text-white text-xs font-bold uppercase rounded border-2 border-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none flex items-center gap-2 shrink-0 cursor-pointer disabled:opacity-50`,children:G?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(ee,{className:`w-3.5 h-3.5 animate-spin`}),(0,k.jsx)(`span`,{children:`CONNECTING...`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f,{className:`w-3.5 h-3.5 text-yellow-300`}),(0,k.jsx)(`span`,{children:`CONNECT GITHUB`})]})})]}),q&&(0,k.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${q.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:q.type===`error`?`bg-rose-100 border-rose-600 text-rose-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[q.type===`success`?(0,k.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}):q.type===`error`?(0,k.jsx)(c,{className:`w-3.5 h-3.5 shrink-0`}):(0,k.jsx)(s,{className:`w-3.5 h-3.5 shrink-0`}),q.text]})]}),(0,k.jsxs)(`div`,{className:`bg-[#FFFDF0] border-[3px] border-ink-black p-4 sm:p-5 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between border-b-[2px] border-ink-black pb-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`div`,{className:`w-7 h-7 rounded bg-[#FFE24C] border-[2px] border-ink-black flex items-center justify-center shadow-[1px_1px_0px_0px_#1E293B]`,children:(0,k.jsx)(_,{className:`w-4 h-4 text-ink-black`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`font-headline-md font-bold text-xs uppercase text-ink-black m-0`,children:`Princess AI Companion & RPG Settings`}),(0,k.jsx)(`p`,{className:`text-[10px] text-trash-gray font-medium m-0`,children:`Trapped Princess Persona, Study Break Timer & 8-bit RPG Audio`})]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-bold text-ink-black font-headline-md uppercase`,children:F.enabled?`Enabled`:`Disabled`}),(0,k.jsx)(`input`,{type:`checkbox`,checked:F.enabled,onChange:e=>I(t=>({...t,enabled:e.target.checked})),className:`w-4 h-4 accent-amber-500 cursor-pointer`})]})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Companion Name`}),(0,k.jsx)(`input`,{type:`text`,value:F.name,onChange:e=>I(t=>({...t,name:e.target.value})),placeholder:`e.g. Princess Aurelia`,className:`bg-white border-[2px] border-ink-black rounded py-2 px-3 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600`})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsxs)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md flex items-center gap-1`,children:[(0,k.jsx)(d,{className:`w-3.5 h-3.5 text-amber-700`}),`Study Break Reminder`]}),(0,k.jsxs)(`select`,{value:F.breakIntervalMinutes,onChange:e=>I(t=>({...t,breakIntervalMinutes:Number(e.target.value)})),className:`bg-white border-[2px] border-ink-black rounded py-2 px-3 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600 cursor-pointer`,children:[(0,k.jsx)(`option`,{value:25,children:`Every 25 Minutes (Classic Pomodoro)`}),(0,k.jsx)(`option`,{value:45,children:`Every 45 Minutes`}),(0,k.jsx)(`option`,{value:60,children:`Every 60 Minutes`}),(0,k.jsx)(`option`,{value:0,children:`Disabled (No automatic break popups)`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsx)(`label`,{className:`block text-xs font-bold text-ink-black uppercase tracking-wider font-headline-md`,children:`Princess Backstory & Persona Prompt`}),(0,k.jsx)(`textarea`,{rows:2,value:F.backstory,onChange:e=>I(t=>({...t,backstory:e.target.value})),placeholder:`Describe her background, tone, and connection to your DSA studies...`,className:`bg-white border-[2px] border-ink-black rounded p-2.5 text-ink-black text-xs font-sans font-medium focus:outline-none focus:border-amber-600 resize-y`})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1`,children:[(0,k.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-white border border-slate-300 rounded cursor-pointer hover:border-ink-black transition-all`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:F.soundEnabled,onChange:e=>{let t=e.target.checked;I(e=>({...e,soundEnabled:t})),v(!t)},className:`w-4 h-4 accent-amber-500 cursor-pointer`}),(0,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`8-bit Sound Effects`}),(0,k.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Audio chimes & fanfare`})]})]}),(0,k.jsxs)(`label`,{className:`flex items-center gap-2.5 p-2.5 bg-white border border-slate-300 rounded cursor-pointer hover:border-ink-black transition-all`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:F.autoPopupEnabled,onChange:e=>I(t=>({...t,autoPopupEnabled:e.target.checked})),className:`w-4 h-4 accent-amber-500 cursor-pointer`}),(0,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`span`,{className:`font-bold text-ink-black block`,children:`Spontaneous RPG Popups`}),(0,k.jsx)(`span`,{className:`text-[10px] text-trash-gray`,children:`Speech bubbles for breaks & milestones`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2 border-t border-slate-200`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:ce,className:`flex items-center gap-1.5 py-2 px-4 border-[2px] border-ink-black bg-[#ffe24c] hover:bg-yellow-300 text-xs font-bold text-ink-black shadow-[2px_2px_0px_0px_#1E293B] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer rounded uppercase`,children:[(0,k.jsx)(o,{className:`w-3.5 h-3.5`}),`Save Companion Settings`]}),(0,k.jsx)(`button`,{type:`button`,onClick:le,className:`py-2 px-3 border border-slate-300 bg-white hover:bg-slate-50 text-xs font-bold text-slate-700 transition-all cursor-pointer rounded`,children:`Default Persona`})]}),(0,k.jsxs)(`button`,{type:`button`,onClick:ue,className:`flex items-center gap-1 py-1.5 px-3 border border-rose-300 bg-rose-50 hover:bg-rose-100 text-rose-700 text-[11px] font-bold transition-all cursor-pointer rounded`,children:[(0,k.jsx)(t,{className:`w-3 h-3 text-rose-500`}),(0,k.jsxs)(`span`,{children:[`Reset Journey (`,z,`/150 LC)`]})]})]}),L&&(0,k.jsxs)(`div`,{className:`p-2.5 border-[2px] border-ink-black text-xs font-medium rounded flex items-center gap-2 ${L.type===`success`?`bg-emerald-100 border-emerald-600 text-emerald-900`:`bg-sky-100 border-sky-600 text-sky-900`}`,children:[(0,k.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),L.text]})]}),(0,k.jsxs)(`div`,{className:`bg-white border-[3px] border-ink-black p-4 shadow-[4px_4px_0px_0px_rgba(30,41,59,1)] flex flex-col gap-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(s,{className:`w-3.5 h-3.5 text-[#0ea5e9]`}),(0,k.jsx)(`h4`,{className:`text-xs font-bold uppercase font-headline-md m-0`,children:`Get Free API Keys`})]}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-2 text-[10px]`,children:[(0,k.jsxs)(`a`,{href:`https://console.groq.com/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`Groq Cloud`}),(0,k.jsx)(m,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Fast inference with generous free rate limits.`})]}),(0,k.jsxs)(`a`,{href:`https://aistudio.google.com/app/apikey`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`Google AI Studio`}),(0,k.jsx)(m,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Free Gemini Flash API quota.`})]}),(0,k.jsxs)(`a`,{href:`https://openrouter.ai/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`p-2.5 border border-slate-200 hover:border-ink-black hover:bg-slate-50 rounded flex flex-col justify-between gap-1 transition-all no-underline text-inherit cursor-pointer`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between font-bold text-ink-black`,children:[(0,k.jsx)(`span`,{children:`OpenRouter`}),(0,k.jsx)(m,{className:`w-3 h-3 text-slate-400`})]}),(0,k.jsx)(`p`,{className:`m-0 text-trash-gray leading-normal`,children:`Unified API for open-weights models.`})]})]})]})]})}export{j as default};
algospaced-ui/dist/assets/TerminalEmulator-C2zR6yON.js DELETED
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Rt as n}from"./vendor-react-CIO8MTK1.js";import{s as r}from"./firebaseClient-DZobvwSx.js";import{n as i}from"./index-DnK6BACV.js";var a=e(t(),1),o=n();function s(e,t){if(e.length===0||t.length===0)return[`Empty result set.`];let n={};e.forEach(e=>{n[e]=e.length}),t.forEach(t=>{e.forEach(e=>{let r=t[e]!==null&&t[e]!==void 0?String(t[e]):`NULL`;r.length>(n[e]||0)&&(n[e]=r.length)})});let r=`+`+e.map(e=>`-`.repeat(n[e]+2)).join(`+`)+`+`,i=[r,`|`+e.map(e=>` ${e.padEnd(n[e])} `).join(`|`)+`|`,r];return t.forEach(t=>{let r=`|`+e.map(e=>` ${(t[e]!==null&&t[e]!==void 0?String(t[e]):`NULL`).padEnd(n[e])} `).join(`|`)+`|`;i.push(r)}),i.push(r),i}function c({onOpenWindow:e,onClose:t}){let[n,c]=(0,a.useState)([`AlgoSpaced OS [Version 1.0.24-beta]`,`(c) Retro Arcade Systems. All rights reserved.`,``,`Type "help" for a list of available commands.`,``]),[l,u]=(0,a.useState)(``),d=(0,a.useRef)(null);(0,a.useEffect)(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[n]);let f=e=>{let t=e.trim(),n=/[^\s"']+|"([^"]*)"|'([^']*)'/g,r=[],i;for(;(i=n.exec(t))!==null;)r.push(i[1]||i[2]||i[0]);return{command:r[0]?.toLowerCase()||``,args:r.slice(1)}},p=async n=>{let a=n.trim();if(a===``){c(e=>[...e,`$`]);return}let{command:o,args:l}=f(a),u=[`$ ${a}`];switch(o){case`help`:u.push(`Available commands:`,` help - Display this documentation`,` ps - Inspect OS process table (PIDs & task states)`,` streak - Retrieve your active Leitner combo streak metrics`,` sync - Run google drive file import sync`,` reviews - Fetch Leetcode numbers due for daily review`,` python play - Open Daily Python Challenge window`,` sql play - Open Interactive SQL Playground window`,` db init - Initialize SQL session and open playground window`,` db status - Check active SQL session objectives`,` db query [Q] - Execute query and format results inside CLI`,` open - Open window (usage: open queue | journey | system | python | db)`,` clear - Clear terminal buffer`,` exit - Close the terminal shell`);break;case`ps`:case`top`:{let e=Object.values(i.getState().processes);if(e.length===0)u.push(`No background processes currently in table.`);else{u.push(`AlgoSpaced OS Process Table:`);let t=s([`PID`,`APP`,`STATUS`,`NAME`],e.map(e=>({PID:e.pid.substring(0,16),APP:e.appId,STATUS:e.status.toUpperCase(),NAME:e.title.substring(0,24)})));u.push(...t)}break}case`clear`:c([]);return;case`exit`:u.push(`Closing terminal session...`),setTimeout(()=>{t()},500);break;case`open`:{let t=l[0]?.toLowerCase();t===`queue`||t===`daily`||t===`reviews`?(e(`queue`),u.push(`Launching Daily Queue window...`)):t===`journey`||t===`path`||t===`map`?(e(`journey`),u.push(`Launching Journey Path window...`)):t===`system`||t===`computer`||t===`sys`?(e(`computer`),u.push(`Launching System Information window...`)):t===`python`||t===`challenge`?(e(`python`),u.push(`Launching Daily Python Challenge window...`)):t===`db`||t===`mysql`||t===`sql`?(e(`mysql`),u.push(`Launching MySQL Playground window...`)):u.push(`Usage: open [queue | journey | system | python | db]`);break}case`streak`:u.push(`Connecting to streak.sys database...`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/streak`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();u.push(`Database Response:`,` Active Streak: ${e.current_streak} days`,` Max Combo: ${e.longest_streak} days`,` Last Activity: ${e.last_active_date?new Date(e.last_active_date).toLocaleDateString():`N/A`}`)}else u.push(`Error: Failed to query database endpoint`)}catch{u.push(`Error: Connection timed out`)}break;case`sync`:u.push(`Initializing Google Drive synchronization sync.exe...`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/sync`,{method:`POST`,headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();u.push(`Sync Result: ${e.message}`)}else u.push(`Error: Sync command failed at backend host`)}catch{u.push(`Error: Cloud host unreachable`)}break;case`reviews`:u.push(`Querying leitner_cards partition...`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/reviews/due`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();e.length===0?u.push(`Queue status: CLEAR! 0 cards due.`):u.push(`Queue status: ${e.length} card(s) due:`,...e.map(e=>` - LeetCode ${e.problems?.problem_number??`?`}: ${e.problems?.name??`Unknown`} (Box ${e.box_level??1})`))}else u.push(`Error: Failed to fetch due items`)}catch{u.push(`Error: Database connection lost`)}break;case`python`:l[0]?.toLowerCase()===`play`?(u.push(`Launching Daily Python Challenge window...`),e(`python`)):u.push(`Usage: python play`);break;case`sql`:case`mysql`:case`db`:{let t=l[0]?.toLowerCase();if(t===`play`)u.push(`Launching MySQL Playground window...`),e(`mysql`);else if(t===`init`){u.push(`Initializing MySQL Playground and launching window...`),e(`mysql`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/init?refresh=true`,{method:`POST`,headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();u.push(`Database Session Created: "${e.title}"`,`Objective: ${e.objective}`)}else u.push(`Error: Failed to initialize DB session on backend host.`)}catch{u.push(`Error: Server connection lost.`)}}else if(t===`status`){u.push(`Fetching SQL playground status...`),e(`mysql`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/status`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();e.active?u.push(`Active SQL Challenge: "${e.title}"`,`Objective: ${e.objective}`,`Status: ${e.completed?`COMPLETED (Done)`:`IN PROGRESS`}`):u.push(e.message)}else u.push(`Error: Failed to fetch DB status.`)}catch{u.push(`Error: Server timed out.`)}}else if(t===`query`){let t=a.toLowerCase().indexOf(`query`),n=t===-1?``:a.substring(t+5).trim().replace(/^["']|["']$/g,``);if(!n){u.push(`Usage: db query [SQL Statement] - Remember to wrap query in double quotes.`);break}u.push(`Running query: ${n}`),e(`mysql`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/query`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({query:n})});if(t.ok){let e=await t.json();e.success?(u.push(`Query OK. Affected ${e.rows_affected} rows.`,...s(e.columns,e.rows)),e.is_correct&&u.push(`OBJECTIVE ACHIEVED! Congratulations.`)):u.push(`SQL Error: ${e.error}`)}else u.push(`Error: SQL execution failed.`)}catch{u.push(`Error: Database server unreachable.`)}}else u.push(`Usage: sql play | db init | db status | db query "SELECT..."`);break}default:u.push(`Command not recognized: "${o}". Type "help" for a list of available actions.`)}c(e=>[...e,...u,``])};return(0,o.jsxs)(`div`,{className:`w-full h-full bg-[#1E293B] text-[#4ADE80] font-code-mono p-4 flex flex-col overflow-hidden text-xs md:text-sm select-text`,children:[(0,o.jsx)(`div`,{ref:d,className:`flex-1 overflow-y-auto mb-2 custom-scrollbar space-y-1`,children:n.map((e,t)=>(0,o.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed min-h-[1.2em]`,children:e},t))}),(0,o.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p(l),u(``)},className:`flex items-center gap-1.5 border-t border-slate-700 pt-2 shrink-0 select-none`,children:[(0,o.jsx)(`span`,{className:`font-bold text-[#ffcc00]`,children:`$`}),(0,o.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),className:`flex-1 bg-transparent text-[#4ADE80] outline-none border-none p-0 focus:ring-0 font-code-mono text-xs md:text-sm`,autoFocus:!0,placeholder:`Type command...`})]})]})}export{c as default};
 
 
algospaced-ui/dist/assets/TerminalEmulator-CZed0tiA.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ht as n}from"./vendor-react-hnaVBnLv.js";import{s as r}from"./firebaseClient-DZobvwSx.js";import{n as i}from"./index-DVWZ15xt.js";var a=e(n(),1),o=t();function s(e,t){if(e.length===0||t.length===0)return[`Empty result set.`];let n={};e.forEach(e=>{n[e]=e.length}),t.forEach(t=>{e.forEach(e=>{let r=t[e]!==null&&t[e]!==void 0?String(t[e]):`NULL`;r.length>(n[e]||0)&&(n[e]=r.length)})});let r=`+`+e.map(e=>`-`.repeat(n[e]+2)).join(`+`)+`+`,i=[r,`|`+e.map(e=>` ${e.padEnd(n[e])} `).join(`|`)+`|`,r];return t.forEach(t=>{let r=`|`+e.map(e=>` ${(t[e]!==null&&t[e]!==void 0?String(t[e]):`NULL`).padEnd(n[e])} `).join(`|`)+`|`;i.push(r)}),i.push(r),i}function c({onOpenWindow:e,onClose:t}){let[n,c]=(0,a.useState)([`AlgoSpaced OS [Version 1.0.24-beta]`,`(c) Retro Arcade Systems. All rights reserved.`,``,`Type "help" for a list of available commands.`,``]),[l,u]=(0,a.useState)(``),d=(0,a.useRef)(null);(0,a.useEffect)(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[n]);let f=e=>{let t=e.trim(),n=/[^\s"']+|"([^"]*)"|'([^']*)'/g,r=[],i;for(;(i=n.exec(t))!==null;)r.push(i[1]||i[2]||i[0]);return{command:r[0]?.toLowerCase()||``,args:r.slice(1)}},p=async n=>{let a=n.trim();if(a===``){c(e=>[...e,`$`]);return}let{command:o,args:l}=f(a),u=[`$ ${a}`];switch(o){case`help`:u.push(`Available commands:`,` help - Display this documentation`,` ps - Inspect OS process table (PIDs & task states)`,` streak - Retrieve your active review streak metrics`,` sync - Run google drive file import sync`,` reviews - Fetch Leetcode numbers due for daily review`,` python play - Open Daily Python Challenge window`,` sql play - Open Interactive SQL Playground window`,` db init - Initialize SQL session and open playground window`,` db status - Check active SQL session objectives`,` db query [Q] - Execute query and format results inside CLI`,` open - Open window (usage: open queue | journey | system | python | db)`,` clear - Clear terminal buffer`,` exit - Close the terminal shell`);break;case`ps`:case`top`:{let e=Object.values(i.getState().processes);if(e.length===0)u.push(`No background processes currently in table.`);else{u.push(`AlgoSpaced OS Process Table:`);let t=s([`PID`,`APP`,`STATUS`,`NAME`],e.map(e=>({PID:e.pid.substring(0,16),APP:e.appId,STATUS:e.status.toUpperCase(),NAME:e.title.substring(0,24)})));u.push(...t)}break}case`clear`:c([]);return;case`exit`:u.push(`Closing terminal session...`),setTimeout(()=>{t()},500);break;case`open`:{let t=l[0]?.toLowerCase();t===`queue`||t===`daily`||t===`reviews`?(e(`queue`),u.push(`Launching Daily Queue window...`)):t===`journey`||t===`path`||t===`map`?(e(`journey`),u.push(`Launching Journey Path window...`)):t===`system`||t===`computer`||t===`sys`?(e(`computer`),u.push(`Launching System Information window...`)):t===`python`||t===`challenge`?(e(`python`),u.push(`Launching Daily Python Challenge window...`)):t===`db`||t===`mysql`||t===`sql`?(e(`mysql`),u.push(`Launching MySQL Playground window...`)):u.push(`Usage: open [queue | journey | system | python | db]`);break}case`streak`:u.push(`Connecting to streak.sys database...`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/streak`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();u.push(`Database Response:`,` Active Streak: ${e.current_streak} days`,` Max Combo: ${e.longest_streak} days`,` Last Activity: ${e.last_active_date?new Date(e.last_active_date).toLocaleDateString():`N/A`}`)}else u.push(`Error: Failed to query database endpoint`)}catch{u.push(`Error: Connection timed out`)}break;case`sync`:u.push(`Initializing Google Drive synchronization sync.exe...`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/sync`,{method:`POST`,headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();u.push(`Sync Result: ${e.message}`)}else u.push(`Error: Sync command failed at backend host`)}catch{u.push(`Error: Cloud host unreachable`)}break;case`reviews`:u.push(`Querying fsrs_cards partition...`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/reviews/due`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();if(e.length===0)u.push(`Queue status: CLEAR! 0 cards due.`);else{let t={0:`New`,1:`Learning`,2:`Review`,3:`Relearning`};u.push(`Queue status: ${e.length} card(s) due:`,...e.map(e=>` - LeetCode ${e.problems?.problem_number??`?`}: ${e.problems?.name??`Unknown`} (${t[e.fsrs_state??0]??`New`})`))}}else u.push(`Error: Failed to fetch due items`)}catch{u.push(`Error: Database connection lost`)}break;case`python`:l[0]?.toLowerCase()===`play`?(u.push(`Launching Daily Python Challenge window...`),e(`python`)):u.push(`Usage: python play`);break;case`sql`:case`mysql`:case`db`:{let t=l[0]?.toLowerCase();if(t===`play`)u.push(`Launching MySQL Playground window...`),e(`mysql`);else if(t===`init`){u.push(`Initializing MySQL Playground and launching window...`),e(`mysql`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/init?refresh=true`,{method:`POST`,headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();u.push(`Database Session Created: "${e.title}"`,`Objective: ${e.objective}`)}else u.push(`Error: Failed to initialize DB session on backend host.`)}catch{u.push(`Error: Server connection lost.`)}}else if(t===`status`){u.push(`Fetching SQL playground status...`),e(`mysql`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/status`,{headers:{Authorization:`Bearer ${e.access_token}`}});if(t.ok){let e=await t.json();e.active?u.push(`Active SQL Challenge: "${e.title}"`,`Objective: ${e.objective}`,`Status: ${e.completed?`COMPLETED (Done)`:`IN PROGRESS`}`):u.push(e.message)}else u.push(`Error: Failed to fetch DB status.`)}catch{u.push(`Error: Server timed out.`)}}else if(t===`query`){let t=a.toLowerCase().indexOf(`query`),n=t===-1?``:a.substring(t+5).trim().replace(/^["']|["']$/g,``);if(!n){u.push(`Usage: db query [SQL Statement] - Remember to wrap query in double quotes.`);break}u.push(`Running query: ${n}`),e(`mysql`);try{let{data:{session:e}}=await r.auth.getSession();if(!e){u.push(`Error: Unauthenticated session`);break}let t=await fetch(`/api/challenges/mysql/query`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e.access_token}`},body:JSON.stringify({query:n})});if(t.ok){let e=await t.json();e.success?(u.push(`Query OK. Affected ${e.rows_affected} rows.`,...s(e.columns,e.rows)),e.is_correct&&u.push(`OBJECTIVE ACHIEVED! Congratulations.`)):u.push(`SQL Error: ${e.error}`)}else u.push(`Error: SQL execution failed.`)}catch{u.push(`Error: Database server unreachable.`)}}else u.push(`Usage: sql play | db init | db status | db query "SELECT..."`);break}default:u.push(`Command not recognized: "${o}". Type "help" for a list of available actions.`)}c(e=>[...e,...u,``])};return(0,o.jsxs)(`div`,{className:`w-full h-full bg-[#1E293B] text-[#4ADE80] font-code-mono p-4 flex flex-col overflow-hidden text-xs md:text-sm select-text`,children:[(0,o.jsx)(`div`,{ref:d,className:`flex-1 overflow-y-auto mb-2 custom-scrollbar space-y-1`,children:n.map((e,t)=>(0,o.jsx)(`div`,{className:`whitespace-pre-wrap leading-relaxed min-h-[1.2em]`,children:e},t))}),(0,o.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),p(l),u(``)},className:`flex items-center gap-1.5 border-t border-slate-700 pt-2 shrink-0 select-none`,children:[(0,o.jsx)(`span`,{className:`font-bold text-[#ffcc00]`,children:`$`}),(0,o.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),className:`flex-1 bg-transparent text-[#4ADE80] outline-none border-none p-0 focus:ring-0 font-code-mono text-xs md:text-sm`,autoFocus:!0,placeholder:`Type command...`})]})]})}export{c as default};
algospaced-ui/dist/assets/index-BsU9BpJx.css ADDED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/assets/{index-DnK6BACV.js → index-DVWZ15xt.js} RENAMED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/assets/index-tlaKBeUb.css DELETED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/assets/vendor-react-CIO8MTK1.js DELETED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/assets/vendor-react-hnaVBnLv.js ADDED
The diff for this file is too large to render. See raw diff
 
algospaced-ui/dist/index.html CHANGED
@@ -21,14 +21,14 @@
21
  rel="stylesheet"
22
  href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&amp;family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&amp;family=Be+Vietnam+Pro:wght@500;700&amp;family=Courier+Prime:wght@400;700&amp;family=Press+Start+2P&amp;family=Cinzel:wght@500;700;900&amp;family=Cinzel+Decorative:wght@700;900&amp;family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&amp;family=Kalam:wght@400;700&amp;display=swap"
23
  />
24
- <script type="module" crossorigin src="/assets/index-DnK6BACV.js"></script>
25
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
26
  <link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-By0wlJeM.js">
27
- <link rel="modulepreload" crossorigin href="/assets/vendor-react-CIO8MTK1.js">
28
  <link rel="modulepreload" crossorigin href="/assets/vendor-firebase-DSIO3PIf.js">
29
  <link rel="modulepreload" crossorigin href="/assets/firebaseClient-DZobvwSx.js">
30
  <link rel="modulepreload" crossorigin href="/assets/vendor-ui-ZXcm-2wU.js">
31
- <link rel="stylesheet" crossorigin href="/assets/index-tlaKBeUb.css">
32
  <link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
33
 
34
  <body>
 
21
  rel="stylesheet"
22
  href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&amp;family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&amp;family=Be+Vietnam+Pro:wght@500;700&amp;family=Courier+Prime:wght@400;700&amp;family=Press+Start+2P&amp;family=Cinzel:wght@500;700;900&amp;family=Cinzel+Decorative:wght@700;900&amp;family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&amp;family=Kalam:wght@400;700&amp;display=swap"
23
  />
24
+ <script type="module" crossorigin src="/assets/index-DVWZ15xt.js"></script>
25
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
26
  <link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-By0wlJeM.js">
27
+ <link rel="modulepreload" crossorigin href="/assets/vendor-react-hnaVBnLv.js">
28
  <link rel="modulepreload" crossorigin href="/assets/vendor-firebase-DSIO3PIf.js">
29
  <link rel="modulepreload" crossorigin href="/assets/firebaseClient-DZobvwSx.js">
30
  <link rel="modulepreload" crossorigin href="/assets/vendor-ui-ZXcm-2wU.js">
31
+ <link rel="stylesheet" crossorigin href="/assets/index-BsU9BpJx.css">
32
  <link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
33
 
34
  <body>
algospaced-ui/dist/llms.txt CHANGED
@@ -2,7 +2,7 @@
2
 
3
  > AlgoSpaced is a gamified spaced repetition and active recall web application for mastering Data Structures and Algorithms (DSA).
4
 
5
- AlgoSpaced integrates the FSRS (Free Spaced Repetition Scheduler) and Leitner box model with an interactive Python 3.14 browser sandbox, LeetCode style problem catalog, and retro-arcade operating system interface.
6
 
7
  ## Core Features and Links
8
  - [Daily Review Queue](/): Spaced repetition flashcards with interactive active-recall code studio.
 
2
 
3
  > AlgoSpaced is a gamified spaced repetition and active recall web application for mastering Data Structures and Algorithms (DSA).
4
 
5
+ AlgoSpaced integrates the FSRS (Free Spaced Repetition Scheduler) with an interactive Python 3.14 browser sandbox, LeetCode style problem catalog, and retro-arcade operating system interface.
6
 
7
  ## Core Features and Links
8
  - [Daily Review Queue](/): Spaced repetition flashcards with interactive active-recall code studio.
algospaced-ui/dist/sw.js CHANGED
@@ -1 +1 @@
1
- if(!self.define){let s,e={};const r=(r,l)=>(r=new URL(r+".js",l).href,e[r]||new Promise(e=>{if("document"in self){const s=document.createElement("script");s.src=r,s.onload=e,document.head.appendChild(s)}else s=r,importScripts(r),e()}).then(()=>{let s=e[r];if(!s)throw new Error(`Module ${r} didn’t register its module`);return s}));self.define=(l,n)=>{const i=s||("document"in self?document.currentScript.src:"")||location.href;if(e[i])return;let u={};const o=s=>r(s,i),t={module:{uri:i},exports:u,require:o};e[i]=Promise.all(l.map(s=>t[s]||o(s))).then(s=>(n(...s),u))}}define(["./workbox-9c191d2f"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"loader.css",revision:"fe561cfc0908978c7b17dcf5d0ce1075"},{url:"loader-init.js",revision:"3d0342fa97370ec97880bb98818cd608"},{url:"index.html",revision:"0bef10bf5a14476194a6dac7c6104dfc"},{url:"assets/vendor-ui-ZXcm-2wU.js",revision:null},{url:"assets/vendor-react-CIO8MTK1.js",revision:null},{url:"assets/vendor-katex-DtkCqjBQ.css",revision:null},{url:"assets/vendor-katex-Balf574a.js",revision:null},{url:"assets/vendor-firebase-DSIO3PIf.js",revision:null},{url:"assets/vendor-codemirror-By0wlJeM.js",revision:null},{url:"assets/TerminalEmulator-C2zR6yON.js",revision:null},{url:"assets/Settings-ACJ113RL.js",revision:null},{url:"assets/rolldown-runtime-hePW80VL.js",revision:null},{url:"assets/ReviewQueue-DmsrlLxn.js",revision:null},{url:"assets/PythonChallenge-BOgiGe52.js",revision:null},{url:"assets/ProblemSpecPanel-CLbwqTwe.js",revision:null},{url:"assets/PrincessChamber-5t89aBn-.js",revision:null},{url:"assets/OnboardingModal-DmgTXeeL.js",revision:null},{url:"assets/MySQLPlayground-CDRacqFf.js",revision:null},{url:"assets/MarkdownRenderer-BMZIn30p.js",revision:null},{url:"assets/KatexRenderer-HIhDCm0G.js",revision:null},{url:"assets/JourneyPath-Dpd3IPxF.js",revision:null},{url:"assets/index-tlaKBeUb.css",revision:null},{url:"assets/index-DnK6BACV.js",revision:null},{url:"assets/GitHubSyncWindow-DHS56rys.js",revision:null},{url:"assets/githubSyncService-x0Mm_uEl.js",revision:null},{url:"assets/firebaseClient-DZobvwSx.js",revision:null},{url:"assets/FileExplorer-CJE9LlAj.js",revision:null},{url:"assets/CreateProblemForm-Cej3QR08.js",revision:null},{url:"assets/confetti.module-Uxh4CK4s.js",revision:null},{url:"assets/Auth-DHdm5r3r.js",revision:null},{url:"manifest.webmanifest",revision:"7c8ff056d2e188c868d851bcb349e28e"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))});
 
1
+ if(!self.define){let s,e={};const r=(r,l)=>(r=new URL(r+".js",l).href,e[r]||new Promise(e=>{if("document"in self){const s=document.createElement("script");s.src=r,s.onload=e,document.head.appendChild(s)}else s=r,importScripts(r),e()}).then(()=>{let s=e[r];if(!s)throw new Error(`Module ${r} didn’t register its module`);return s}));self.define=(l,n)=>{const i=s||("document"in self?document.currentScript.src:"")||location.href;if(e[i])return;let u={};const t=s=>r(s,i),o={module:{uri:i},exports:u,require:t};e[i]=Promise.all(l.map(s=>o[s]||t(s))).then(s=>(n(...s),u))}}define(["./workbox-9c191d2f"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"loader.css",revision:"fe561cfc0908978c7b17dcf5d0ce1075"},{url:"loader-init.js",revision:"3d0342fa97370ec97880bb98818cd608"},{url:"index.html",revision:"af59fb115d7311a1378fc0a9c8a20111"},{url:"assets/vendor-ui-ZXcm-2wU.js",revision:null},{url:"assets/vendor-react-hnaVBnLv.js",revision:null},{url:"assets/vendor-katex-DtkCqjBQ.css",revision:null},{url:"assets/vendor-katex-Balf574a.js",revision:null},{url:"assets/vendor-firebase-DSIO3PIf.js",revision:null},{url:"assets/vendor-codemirror-By0wlJeM.js",revision:null},{url:"assets/TerminalEmulator-CZed0tiA.js",revision:null},{url:"assets/Settings-BVuXk3LW.js",revision:null},{url:"assets/rolldown-runtime-hePW80VL.js",revision:null},{url:"assets/ReviewQueue-CltGWQpb.js",revision:null},{url:"assets/PythonChallenge-CQdOe4Q2.js",revision:null},{url:"assets/ProblemSpecPanel-BRW8UyO6.js",revision:null},{url:"assets/PrincessChamber-abJShfI5.js",revision:null},{url:"assets/MySQLPlayground-iGzsbjAa.js",revision:null},{url:"assets/MarkdownRenderer-D8UdFpnD.js",revision:null},{url:"assets/KatexRenderer-DVt2cqHc.js",revision:null},{url:"assets/JourneyPath-BhAvKOiu.js",revision:null},{url:"assets/index-DVWZ15xt.js",revision:null},{url:"assets/index-BsU9BpJx.css",revision:null},{url:"assets/GitHubSyncWindow-CrRFKIeu.js",revision:null},{url:"assets/githubSyncService-x0Mm_uEl.js",revision:null},{url:"assets/firebaseClient-DZobvwSx.js",revision:null},{url:"assets/FileExplorer-D3FrJW-x.js",revision:null},{url:"assets/CreateProblemForm-Ccz3TNzp.js",revision:null},{url:"assets/confetti.module-Uxh4CK4s.js",revision:null},{url:"assets/CardManager-BEhyd34f.js",revision:null},{url:"assets/Auth-CphacI2S.js",revision:null},{url:"manifest.webmanifest",revision:"7c8ff056d2e188c868d851bcb349e28e"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("index.html")))});
algospaced-ui/package.json CHANGED
@@ -8,7 +8,7 @@
8
  "build": "node node_modules/typescript7/bin/tsc -b && vite build",
9
  "typecheck": "node node_modules/typescript7/bin/tsc -b",
10
  "lint": "eslint .",
11
- "test": "node --experimental-strip-types --test tests/offlineAuth.test.mjs tests/offlineReviewQueue.test.mjs",
12
  "preview": "vite preview"
13
  },
14
  "dependencies": {
 
8
  "build": "node node_modules/typescript7/bin/tsc -b && vite build",
9
  "typecheck": "node node_modules/typescript7/bin/tsc -b",
10
  "lint": "eslint .",
11
+ "test": "node --experimental-strip-types --test tests/offlineAuth.test.mjs tests/offlineReviewQueue.test.mjs tests/cardManager.test.mjs",
12
  "preview": "vite preview"
13
  },
14
  "dependencies": {
algospaced-ui/public/llms.txt CHANGED
@@ -2,7 +2,7 @@
2
 
3
  > AlgoSpaced is a gamified spaced repetition and active recall web application for mastering Data Structures and Algorithms (DSA).
4
 
5
- AlgoSpaced integrates the FSRS (Free Spaced Repetition Scheduler) and Leitner box model with an interactive Python 3.14 browser sandbox, LeetCode style problem catalog, and retro-arcade operating system interface.
6
 
7
  ## Core Features and Links
8
  - [Daily Review Queue](/): Spaced repetition flashcards with interactive active-recall code studio.
 
2
 
3
  > AlgoSpaced is a gamified spaced repetition and active recall web application for mastering Data Structures and Algorithms (DSA).
4
 
5
+ AlgoSpaced integrates the FSRS (Free Spaced Repetition Scheduler) with an interactive Python 3.14 browser sandbox, LeetCode style problem catalog, and retro-arcade operating system interface.
6
 
7
  ## Core Features and Links
8
  - [Daily Review Queue](/): Spaced repetition flashcards with interactive active-recall code studio.
algospaced-ui/src/App.tsx CHANGED
@@ -7,7 +7,6 @@ import PrincessDialoguePopup from './components/PrincessDialoguePopup';
7
  import { useWindowManager } from './hooks/useWindowManager';
8
 
9
  const Auth = lazy(() => import('./components/Auth'));
10
- const OnboardingModal = lazy(() => import('./components/OnboardingModal'));
11
  import { useSystemStats } from './hooks/useSystemStats';
12
  import { useWallpaper } from './hooks/useWallpaper';
13
  import { useCompanionEvents } from './hooks/useCompanionEvents';
@@ -19,7 +18,6 @@ import { DesktopWindowContainer } from './components/desktop/DesktopWindowContai
19
  export default function App() {
20
  const [user, setUser] = useState<AuthUser | null>(() => authService.getInitialUser());
21
  const [isLoadingAuth, setIsLoadingAuth] = useState(() => !authService.getInitialUser());
22
- const [isOnboardingOpen, setIsOnboardingOpen] = useState(false);
23
  const [isStartOpen, setIsStartOpen] = useState(false);
24
 
25
  // Desktop icons & context menu refs
@@ -35,7 +33,6 @@ export default function App() {
35
  const {
36
  openWindow,
37
  toggleWindowMinimize,
38
- triggerRefreshExplorer,
39
  isAnyWindowOpen
40
  } = useWindowManager(closeStartMenu);
41
 
@@ -88,21 +85,6 @@ export default function App() {
88
  }
89
  }, [isLoadingAuth]);
90
 
91
- // Prompt onboarding for first-time session
92
- useEffect(() => {
93
- if (!isLoadingAuth && user) {
94
- const rawUid = user.id;
95
- const uid = rawUid === 'sandbox-user-id' || !rawUid ? 'sandbox' : rawUid;
96
- const onbDone = localStorage.getItem(`algospaced_onboarding_done_${uid}`);
97
- if (!onbDone) {
98
- const timer = setTimeout(() => {
99
- setIsOnboardingOpen(true);
100
- }, 0);
101
- return () => clearTimeout(timer);
102
- }
103
- }
104
- }, [isLoadingAuth, user]);
105
-
106
  const handleContextMenu = (e: React.MouseEvent) => {
107
  const target = e.target as HTMLElement;
108
  if (
@@ -154,6 +136,17 @@ export default function App() {
154
  badgeShadowColor: '#fde047',
155
  action: () => openWindow('queue')
156
  },
 
 
 
 
 
 
 
 
 
 
 
157
  {
158
  id: 'journey',
159
  label: (
@@ -297,7 +290,6 @@ export default function App() {
297
  {/* Floating Windows Shell Containers */}
298
  <DesktopWindowContainer
299
  isMobile={isMobile}
300
- setIsOnboardingOpen={setIsOnboardingOpen}
301
  wallpaperUrl={wallpaperUrl}
302
  setWallpaperUrl={setWallpaperUrl}
303
  syncing={syncing}
@@ -311,10 +303,6 @@ export default function App() {
311
  onToggleStart={() => setIsStartOpen(prev => !prev)}
312
  onCloseStart={() => setIsStartOpen(false)}
313
  onOpenWindow={openWindow}
314
- onOpenOnboarding={() => {
315
- setIsStartOpen(false);
316
- setIsOnboardingOpen(true);
317
- }}
318
  onTriggerSync={triggerSync}
319
  onSignOut={handleSignOut}
320
  isMobile={isMobile}
@@ -331,18 +319,6 @@ export default function App() {
331
  {/* Reactive Princess Toast HUD */}
332
  <PrincessToast onOpenCompanionWindow={() => openWindow('companion')} />
333
 
334
- {/* Expedition Onboarding & Fast-Track Checklist Modal */}
335
- {isOnboardingOpen && (
336
- <Suspense fallback={null}>
337
- <OnboardingModal
338
- isOpen={isOnboardingOpen}
339
- onClose={() => setIsOnboardingOpen(false)}
340
- onCompleted={triggerRefreshExplorer}
341
- userId={user?.id || 'sandbox'}
342
- />
343
- </Suspense>
344
- )}
345
-
346
  {/* Retro Desktop Context Menu */}
347
  <DesktopContextMenu
348
  isOpen={contextMenu.visible}
 
7
  import { useWindowManager } from './hooks/useWindowManager';
8
 
9
  const Auth = lazy(() => import('./components/Auth'));
 
10
  import { useSystemStats } from './hooks/useSystemStats';
11
  import { useWallpaper } from './hooks/useWallpaper';
12
  import { useCompanionEvents } from './hooks/useCompanionEvents';
 
18
  export default function App() {
19
  const [user, setUser] = useState<AuthUser | null>(() => authService.getInitialUser());
20
  const [isLoadingAuth, setIsLoadingAuth] = useState(() => !authService.getInitialUser());
 
21
  const [isStartOpen, setIsStartOpen] = useState(false);
22
 
23
  // Desktop icons & context menu refs
 
33
  const {
34
  openWindow,
35
  toggleWindowMinimize,
 
36
  isAnyWindowOpen
37
  } = useWindowManager(closeStartMenu);
38
 
 
85
  }
86
  }, [isLoadingAuth]);
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  const handleContextMenu = (e: React.MouseEvent) => {
89
  const target = e.target as HTMLElement;
90
  if (
 
136
  badgeShadowColor: '#fde047',
137
  action: () => openWindow('queue')
138
  },
139
+ {
140
+ id: 'cardManager',
141
+ label: (
142
+ <>
143
+ CARD<br />MANAGER
144
+ </>
145
+ ),
146
+ icon: 'style',
147
+ badgeShadowColor: '#38bdf8',
148
+ action: () => openWindow('cardManager')
149
+ },
150
  {
151
  id: 'journey',
152
  label: (
 
290
  {/* Floating Windows Shell Containers */}
291
  <DesktopWindowContainer
292
  isMobile={isMobile}
 
293
  wallpaperUrl={wallpaperUrl}
294
  setWallpaperUrl={setWallpaperUrl}
295
  syncing={syncing}
 
303
  onToggleStart={() => setIsStartOpen(prev => !prev)}
304
  onCloseStart={() => setIsStartOpen(false)}
305
  onOpenWindow={openWindow}
 
 
 
 
306
  onTriggerSync={triggerSync}
307
  onSignOut={handleSignOut}
308
  isMobile={isMobile}
 
319
  {/* Reactive Princess Toast HUD */}
320
  <PrincessToast onOpenCompanionWindow={() => openWindow('companion')} />
321
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  {/* Retro Desktop Context Menu */}
323
  <DesktopContextMenu
324
  isOpen={contextMenu.visible}
algospaced-ui/src/components/DesktopContextMenu.tsx CHANGED
@@ -160,6 +160,17 @@ export default function DesktopContextMenu({
160
  Daily Queue
161
  </button>
162
 
 
 
 
 
 
 
 
 
 
 
 
163
  <button
164
  onClick={() => {
165
  onOpenWindow('terminal');
 
160
  Daily Queue
161
  </button>
162
 
163
+ <button
164
+ onClick={() => {
165
+ onOpenWindow('cardManager');
166
+ onClose();
167
+ }}
168
+ className="px-3 py-1.5 hover:bg-[#38bdf8] hover:text-ink-black flex items-center gap-2 text-xs font-bold transition-colors text-left cursor-pointer"
169
+ >
170
+ <span className="material-symbols-outlined text-base">style</span>
171
+ Card Manager
172
+ </button>
173
+
174
  <button
175
  onClick={() => {
176
  onOpenWindow('terminal');
algospaced-ui/src/components/FileExplorer.tsx CHANGED
@@ -8,7 +8,9 @@ interface ProblemFile {
8
  difficulty: string;
9
  reference_code: string;
10
  description: string | null;
11
- box_level: number | null;
 
 
12
  next_review: string | null;
13
  last_reviewed: string | null;
14
  times_correct: number;
@@ -342,11 +344,11 @@ export default function FileExplorer({
342
  const completedSolutions = problems.filter(p => p.reference_code && p.reference_code.trim()).length;
343
  const completionPercent = totalProblems > 0 ? Math.round((completedSolutions / totalProblems) * 100) : 0;
344
 
345
- const boxCounts = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0 };
346
  problems.forEach(p => {
347
- if (p.box_level !== null && p.box_level !== undefined) {
348
- const lvl = p.box_level as 1|2|3|4|5;
349
- if (lvl >= 1 && lvl <= 5) boxCounts[lvl]++;
350
  }
351
  });
352
 
@@ -470,21 +472,26 @@ export default function FileExplorer({
470
  </div>
471
  </div>
472
 
473
- {/* Box Level Counts visual bar charts */}
474
  <div className="space-y-1.5 mt-2">
475
- <span className="text-[9px] uppercase text-slate-500 block">Leitner Distribution:</span>
476
- {([1, 2, 3, 4, 5] as const).map(boxNum => {
477
- const count = boxCounts[boxNum];
478
- const maxCount = Math.max(...Object.values(boxCounts), 1);
 
 
 
 
 
479
  const barWidth = Math.max(8, Math.round((count / maxCount) * 100));
480
 
481
  return (
482
- <div key={boxNum} className="flex items-center gap-2">
483
- <span className="w-9 font-mono text-[10px] text-slate-400">Box {boxNum}:</span>
484
  <div className="flex-1 h-3 bg-white border border-ink-black overflow-hidden relative">
485
  <div
486
- style={{ width: `${barWidth}%` }}
487
- className="h-full bg-[#0ea5e9] border-r border-ink-black transition-all"
488
  />
489
  </div>
490
  <span className="w-4 text-right font-mono text-[10px] text-slate-600">{count}</span>
@@ -734,7 +741,7 @@ export default function FileExplorer({
734
  onClick={() => setModalTab('properties')}
735
  className={`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${modalTab === 'properties' ? 'bg-white translate-y-[2px]' : 'bg-slate-300 hover:bg-slate-100'}`}
736
  >
737
- LEITNER PROPERTIES
738
  </button>
739
  </div>
740
 
@@ -792,7 +799,7 @@ export default function FileExplorer({
792
  </div>
793
  )}
794
 
795
- {/* TAB CONTENT: Leitner properties */}
796
  {modalTab === 'properties' && (
797
  <div className="flex-1 p-6 overflow-y-auto custom-scrollbar bg-slate-50 font-sans leading-relaxed select-text flex flex-col gap-4">
798
  <h3 className="font-arcade text-[10px] border-b border-slate-300 pb-1 text-slate-500">Card Diagnostics</h3>
@@ -800,7 +807,19 @@ export default function FileExplorer({
800
  <div className="grid grid-cols-2 gap-4">
801
  <div className="border-[3px] border-ink-black bg-white p-3 space-y-2">
802
  <span className="text-[9px] font-arcade text-[#0ea5e9] block">Scheduling Status</span>
803
- <div>Leitner Combo Box: <span className="font-mono font-bold text-lg text-sky-600">{previewFile.box_level || 'N/A (Box 1)'}</span></div>
 
 
 
 
 
 
 
 
 
 
 
 
804
  <div>Next Review Date: <span className="font-mono text-xs font-semibold">{previewFile.next_review ? new Date(previewFile.next_review).toLocaleString() : 'N/A (Due)'}</span></div>
805
  <div>Last Reviewed: <span className="font-mono text-xs font-semibold">{previewFile.last_reviewed ? new Date(previewFile.last_reviewed).toLocaleDateString() : 'Never'}</span></div>
806
  </div>
 
8
  difficulty: string;
9
  reference_code: string;
10
  description: string | null;
11
+ fsrs_state?: number | null;
12
+ fsrs_stability?: number;
13
+ fsrs_difficulty?: number;
14
  next_review: string | null;
15
  last_reviewed: string | null;
16
  times_correct: number;
 
344
  const completedSolutions = problems.filter(p => p.reference_code && p.reference_code.trim()).length;
345
  const completionPercent = totalProblems > 0 ? Math.round((completedSolutions / totalProblems) * 100) : 0;
346
 
347
+ const fsrsCounts = { 0: 0, 1: 0, 2: 0, 3: 0 };
348
  problems.forEach(p => {
349
+ if (p.fsrs_state !== null && p.fsrs_state !== undefined) {
350
+ const st = p.fsrs_state as 0 | 1 | 2 | 3;
351
+ if (st >= 0 && st <= 3) fsrsCounts[st]++;
352
  }
353
  });
354
 
 
472
  </div>
473
  </div>
474
 
475
+ {/* FSRS State Counts visual bar charts */}
476
  <div className="space-y-1.5 mt-2">
477
+ <span className="text-[9px] uppercase text-slate-500 block">FSRS Distribution:</span>
478
+ {([
479
+ { state: 0, label: 'New', color: '#3b82f6' },
480
+ { state: 1, label: 'Learn', color: '#f59e0b' },
481
+ { state: 2, label: 'Review', color: '#10b981' },
482
+ { state: 3, label: 'Relearn', color: '#ef4444' }
483
+ ] as const).map(item => {
484
+ const count = fsrsCounts[item.state];
485
+ const maxCount = Math.max(...Object.values(fsrsCounts), 1);
486
  const barWidth = Math.max(8, Math.round((count / maxCount) * 100));
487
 
488
  return (
489
+ <div key={item.state} className="flex items-center gap-2">
490
+ <span className="w-12 font-mono text-[10px] text-slate-400">{item.label}:</span>
491
  <div className="flex-1 h-3 bg-white border border-ink-black overflow-hidden relative">
492
  <div
493
+ style={{ width: `${barWidth}%`, backgroundColor: item.color }}
494
+ className="h-full border-r border-ink-black transition-all"
495
  />
496
  </div>
497
  <span className="w-4 text-right font-mono text-[10px] text-slate-600">{count}</span>
 
741
  onClick={() => setModalTab('properties')}
742
  className={`px-4 py-2 border-r-2 border-ink-black font-bold text-[11px] cursor-pointer ${modalTab === 'properties' ? 'bg-white translate-y-[2px]' : 'bg-slate-300 hover:bg-slate-100'}`}
743
  >
744
+ FSRS PROPERTIES
745
  </button>
746
  </div>
747
 
 
799
  </div>
800
  )}
801
 
802
+ {/* TAB CONTENT: FSRS properties */}
803
  {modalTab === 'properties' && (
804
  <div className="flex-1 p-6 overflow-y-auto custom-scrollbar bg-slate-50 font-sans leading-relaxed select-text flex flex-col gap-4">
805
  <h3 className="font-arcade text-[10px] border-b border-slate-300 pb-1 text-slate-500">Card Diagnostics</h3>
 
807
  <div className="grid grid-cols-2 gap-4">
808
  <div className="border-[3px] border-ink-black bg-white p-3 space-y-2">
809
  <span className="text-[9px] font-arcade text-[#0ea5e9] block">Scheduling Status</span>
810
+ <div>FSRS State: <span className="font-mono font-bold text-sm text-sky-600">
811
+ {previewFile.fsrs_state !== null && previewFile.fsrs_state !== undefined
812
+ ? (previewFile.fsrs_state === 0
813
+ ? 'New (0)'
814
+ : previewFile.fsrs_state === 1
815
+ ? 'Learning (1)'
816
+ : previewFile.fsrs_state === 2
817
+ ? 'Review (2)'
818
+ : 'Relearning (3)')
819
+ : 'Unenrolled'}
820
+ </span></div>
821
+ <div>Stability: <span className="font-mono text-xs font-semibold">{previewFile.fsrs_stability !== undefined ? `${previewFile.fsrs_stability.toFixed(1)} days` : '0.0 days'}</span></div>
822
+ <div>Difficulty: <span className="font-mono text-xs font-semibold">{previewFile.fsrs_difficulty !== undefined ? `${previewFile.fsrs_difficulty.toFixed(1)}/10` : '0.0/10'}</span></div>
823
  <div>Next Review Date: <span className="font-mono text-xs font-semibold">{previewFile.next_review ? new Date(previewFile.next_review).toLocaleString() : 'N/A (Due)'}</span></div>
824
  <div>Last Reviewed: <span className="font-mono text-xs font-semibold">{previewFile.last_reviewed ? new Date(previewFile.last_reviewed).toLocaleDateString() : 'Never'}</span></div>
825
  </div>
algospaced-ui/src/components/OnboardingModal.tsx DELETED
@@ -1,600 +0,0 @@
1
- import { useState, useMemo, useEffect } from 'react';
2
- import {
3
- Sparkles,
4
- Zap,
5
- Check,
6
- Search,
7
- X,
8
- ArrowLeft,
9
- RefreshCw,
10
- CheckCircle2,
11
- CheckSquare,
12
- Square,
13
- Compass,
14
- BookOpen,
15
- ChevronDown,
16
- ChevronUp
17
- } from 'lucide-react';
18
- import {
19
- getAllCatalogProblems,
20
- getAllPatterns,
21
- getCatalogProblemByNumber,
22
- type CatalogProblem
23
- } from '../services/catalogService';
24
- import { batchActivateProblems } from '../services/reviewService';
25
-
26
- interface OnboardingModalProps {
27
- isOpen: boolean;
28
- onClose: () => void;
29
- onCompleted: () => void;
30
- userId?: string;
31
- }
32
-
33
- const STARTER_PROBLEM_NUMBERS = [217, 242, 1, 49, 20]; // Foundational starter pack
34
-
35
- export default function OnboardingModal({
36
- isOpen,
37
- onClose,
38
- onCompleted,
39
- userId
40
- }: OnboardingModalProps) {
41
- const [step, setStep] = useState<'welcome' | 'checklist'>('welcome');
42
- const [selectedNumbers, setSelectedNumbers] = useState<Set<number>>(new Set());
43
- const [searchQuery, setSearchQuery] = useState('');
44
- const [selectedPatternFilter, setSelectedPatternFilter] = useState<string>('ALL');
45
- const [expandedPatterns, setExpandedPatterns] = useState<Record<string, boolean>>({});
46
- const [isSubmitting, setIsSubmitting] = useState(false);
47
- const [statusMessage, setStatusMessage] = useState<string | null>(null);
48
- const [errorMessage, setErrorMessage] = useState<string | null>(null);
49
-
50
- const getStorageKey = () => {
51
- const id = userId === 'sandbox-user-id' ? 'sandbox' : (userId || 'sandbox');
52
- return `algospaced_onboarding_done_${id}`;
53
- };
54
-
55
- useEffect(() => {
56
- if (isOpen) {
57
- const done = localStorage.getItem(getStorageKey());
58
- setStep(done ? 'checklist' : 'welcome');
59
- setErrorMessage(null);
60
- setStatusMessage(null);
61
- }
62
- }, [isOpen, userId]);
63
-
64
- const allProblems = useMemo(() => getAllCatalogProblems(), []);
65
- const allPatterns = useMemo(() => getAllPatterns(), []);
66
-
67
- // Filtered problems based on search and pattern
68
- const filteredProblems = useMemo(() => {
69
- const q = searchQuery.trim().toLowerCase();
70
- return allProblems.filter((p) => {
71
- const matchesPattern = selectedPatternFilter === 'ALL' || p.pattern === selectedPatternFilter;
72
- if (!matchesPattern) return false;
73
- if (!q) return true;
74
- return (
75
- p.name.toLowerCase().includes(q) ||
76
- p.problem_number.toString().includes(q) ||
77
- p.pattern.toLowerCase().includes(q) ||
78
- p.difficulty.toLowerCase().includes(q)
79
- );
80
- });
81
- }, [allProblems, searchQuery, selectedPatternFilter]);
82
-
83
- // Group filtered problems by pattern
84
- const groupedProblems = useMemo(() => {
85
- const map = new Map<string, CatalogProblem[]>();
86
- for (const p of filteredProblems) {
87
- const list = map.get(p.pattern) || [];
88
- list.push(p);
89
- map.set(p.pattern, list);
90
- }
91
- return map;
92
- }, [filteredProblems]);
93
-
94
- if (!isOpen) return null;
95
-
96
- const markOnboardingDone = () => {
97
- localStorage.setItem(getStorageKey(), 'true');
98
- };
99
-
100
- const handleStartFromScratch = async () => {
101
- setIsSubmitting(true);
102
- setErrorMessage(null);
103
- setStatusMessage('Enrolling 5 foundational starter problems...');
104
-
105
- try {
106
- const starterProbs = STARTER_PROBLEM_NUMBERS.map((num) =>
107
- getCatalogProblemByNumber(num)
108
- ).filter((p): p is CatalogProblem => p !== undefined);
109
-
110
- await batchActivateProblems(starterProbs);
111
- markOnboardingDone();
112
- setStatusMessage('All 5 starter problems enrolled into Box 1!');
113
- setTimeout(() => {
114
- onCompleted();
115
- onClose();
116
- }, 700);
117
- } catch (err) {
118
- console.error('Failed to start from scratch:', err);
119
- setErrorMessage(err instanceof Error ? err.message : 'Failed to enroll starter problems');
120
- setIsSubmitting(false);
121
- }
122
- };
123
-
124
- const toggleProblemSelection = (problemNumber: number) => {
125
- setSelectedNumbers((prev) => {
126
- const next = new Set(prev);
127
- if (next.has(problemNumber)) {
128
- next.delete(problemNumber);
129
- } else {
130
- next.add(problemNumber);
131
- }
132
- return next;
133
- });
134
- };
135
-
136
- const togglePatternSelection = (patternName: string) => {
137
- const patternProbs = allProblems.filter((p) => p.pattern === patternName);
138
- const allSelected = patternProbs.every((p) => selectedNumbers.has(p.problem_number));
139
-
140
- setSelectedNumbers((prev) => {
141
- const next = new Set(prev);
142
- for (const p of patternProbs) {
143
- if (allSelected) {
144
- next.delete(p.problem_number);
145
- } else {
146
- next.add(p.problem_number);
147
- }
148
- }
149
- return next;
150
- });
151
- };
152
-
153
- const selectByDifficulty = (difficulty: 'Easy' | 'Medium' | 'Hard') => {
154
- setSelectedNumbers((prev) => {
155
- const next = new Set(prev);
156
- for (const p of allProblems) {
157
- if (p.difficulty === difficulty) {
158
- next.add(p.problem_number);
159
- }
160
- }
161
- return next;
162
- });
163
- };
164
-
165
- const selectAll = () => {
166
- setSelectedNumbers(new Set(allProblems.map((p) => p.problem_number)));
167
- };
168
-
169
- const clearAll = () => {
170
- setSelectedNumbers(new Set());
171
- };
172
-
173
- const togglePatternExpand = (pat: string) => {
174
- setExpandedPatterns((prev) => ({
175
- ...prev,
176
- [pat]: !prev[pat]
177
- }));
178
- };
179
-
180
- const handleEnrollFastTrack = async () => {
181
- if (selectedNumbers.size === 0) return;
182
- setIsSubmitting(true);
183
- setErrorMessage(null);
184
- setStatusMessage(`Enrolling ${selectedNumbers.size} problems into FSRS...`);
185
-
186
- try {
187
- const chosenProblems = allProblems.filter((p) => selectedNumbers.has(p.problem_number));
188
- await batchActivateProblems(chosenProblems);
189
- markOnboardingDone();
190
- setStatusMessage(`Successfully enrolled ${chosenProblems.length} problems!`);
191
- setTimeout(() => {
192
- onCompleted();
193
- onClose();
194
- }, 700);
195
- } catch (err) {
196
- console.error('Failed to batch activate:', err);
197
- setErrorMessage(err instanceof Error ? err.message : 'Failed to enroll problems');
198
- setIsSubmitting(false);
199
- }
200
- };
201
-
202
- return (
203
- <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/75 backdrop-blur-sm p-3 sm:p-6 overflow-y-auto">
204
- <div className="w-full max-w-4xl max-h-[92vh] bg-paper-white border-[4px] border-ink-black gadget-shadow flex flex-col relative overflow-hidden text-ink-black">
205
- {/* Top retro arcade title bar */}
206
- <div className="h-10 bg-gradient-to-r from-amber-400 via-amber-300 to-grass-green border-b-[3px] border-ink-black px-4 flex items-center justify-between shrink-0">
207
- <div className="flex items-center gap-2">
208
- <span className="w-3 h-3 rounded-full bg-rose-500 border border-ink-black" />
209
- <span className="w-3 h-3 rounded-full bg-amber-500 border border-ink-black" />
210
- <span className="w-3 h-3 rounded-full bg-emerald-500 border border-ink-black" />
211
- <span className="font-arcade text-[11px] font-bold tracking-wider text-ink-black uppercase ml-2 flex items-center gap-1.5">
212
- <Compass className="w-4 h-4 text-amber-900" />
213
- GET STARTED
214
- </span>
215
- </div>
216
- <button
217
- onClick={() => {
218
- markOnboardingDone();
219
- onClose();
220
- }}
221
- disabled={isSubmitting}
222
- className="p-1 hover:bg-black/10 rounded transition-colors text-ink-black cursor-pointer border-0"
223
- title="Dismiss for now"
224
- >
225
- <X className="w-4 h-4" />
226
- </button>
227
- </div>
228
-
229
- {/* Step 1: Welcome & Path Selection */}
230
- {step === 'welcome' && (
231
- <div className="p-6 sm:p-10 space-y-8 overflow-y-auto custom-scrollbar text-center">
232
- <div className="space-y-3">
233
- <div className="inline-flex items-center gap-2 px-3 py-1 bg-amber-100 border-2 border-ink-black font-arcade text-[10px] font-bold text-amber-900 uppercase">
234
- <Sparkles className="w-3.5 h-3.5 text-amber-700" />
235
- WELCOME TO ALGOSPACED
236
- </div>
237
- <h1 className="font-headline-md text-2xl sm:text-4xl font-extrabold text-ink-black tracking-tight">
238
- How would you like to begin your journey?
239
- </h1>
240
- <p className="font-sans text-xs sm:text-sm text-trash-gray max-w-xl mx-auto leading-relaxed font-semibold">
241
- AlgoSpaced uses a 5-box Leitner spaced repetition engine. Choose how to seed your active practice cards.
242
- </p>
243
- </div>
244
-
245
- {/* Path Selection Cards */}
246
- <div className="grid grid-cols-1 md:grid-cols-2 gap-6 max-w-2xl mx-auto text-left">
247
- {/* Option A: Start From Scratch */}
248
- <div className="p-5 sm:p-6 bg-gradient-to-br from-emerald-50 to-emerald-100/60 border-[3px] border-ink-black gadget-shadow hover:translate-y-[-2px] transition-all flex flex-col justify-between space-y-4">
249
- <div className="space-y-3">
250
- <div className="w-12 h-12 bg-grass-green border-2 border-ink-black rounded-xl flex items-center justify-center shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]">
251
- <BookOpen className="w-6 h-6 text-ink-black stroke-[2.5]" />
252
- </div>
253
- <div>
254
- <span className="font-arcade text-[8px] font-bold text-emerald-800 uppercase tracking-wide">
255
- RECOMMENDED FOR BEGINNERS
256
- </span>
257
- <h2 className="font-headline-md text-lg sm:text-xl font-bold text-ink-black mt-0.5">
258
- 🌱 Start From Scratch
259
- </h2>
260
- </div>
261
- <p className="font-sans text-xs text-trash-gray leading-relaxed font-semibold">
262
- Begin with the 5 foundational starter problems: Contains Duplicate, Valid Anagram, Two Sum, Group Anagrams, and Valid Parentheses.
263
- </p>
264
- </div>
265
-
266
- <button
267
- onClick={handleStartFromScratch}
268
- disabled={isSubmitting}
269
- className="w-full py-3 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[10px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center justify-center gap-2 disabled:opacity-50"
270
- >
271
- {isSubmitting ? (
272
- <>
273
- <RefreshCw className="w-4 h-4 animate-spin" />
274
- <span>INITIALIZING...</span>
275
- </>
276
- ) : (
277
- <>
278
- <Check className="w-4 h-4 stroke-[3]" />
279
- <span>START FRESH (5 PROBLEMS)</span>
280
- </>
281
- )}
282
- </button>
283
- </div>
284
-
285
- {/* Option B: Fast-Track Checklist */}
286
- <div className="p-5 sm:p-6 bg-gradient-to-br from-amber-50 to-orange-100/60 border-[3px] border-ink-black gadget-shadow hover:translate-y-[-2px] transition-all flex flex-col justify-between space-y-4">
287
- <div className="space-y-3">
288
- <div className="w-12 h-12 bg-amber-400 border-2 border-ink-black rounded-xl flex items-center justify-center shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]">
289
- <Zap className="w-6 h-6 text-ink-black stroke-[2.5]" />
290
- </div>
291
- <div>
292
- <span className="font-arcade text-[8px] font-bold text-amber-800 uppercase tracking-wide">
293
- IF YOU'VE ALREADY SOLVED SOME PROBLEMS ELSEWHERE
294
- </span>
295
- <h2 className="font-headline-md text-lg sm:text-xl font-bold text-ink-black mt-0.5">
296
- ⚡ Fast-Track Checklist
297
- </h2>
298
- </div>
299
- <p className="font-sans text-xs text-trash-gray leading-relaxed font-semibold">
300
- Already solved some problems? Check off problems you've already solved elsewhere to seed your review queue and update your progress.
301
- </p>
302
- </div>
303
-
304
- <button
305
- onClick={() => setStep('checklist')}
306
- disabled={isSubmitting}
307
- className="w-full py-3 bg-amber-400 hover:bg-amber-300 text-ink-black font-arcade text-[10px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center justify-center gap-2"
308
- >
309
- <span>SELECT WHAT I KNOW (150 POOL)</span>
310
- <ArrowLeft className="w-4 h-4 rotate-180" />
311
- </button>
312
- </div>
313
- </div>
314
-
315
- {statusMessage && (
316
- <p className="font-arcade text-[10px] text-emerald-700 font-bold animate-pulse">
317
- {statusMessage}
318
- </p>
319
- )}
320
- {errorMessage && (
321
- <p className="font-arcade text-[10px] text-rose-600 font-bold">
322
- {errorMessage}
323
- </p>
324
- )}
325
- </div>
326
- )}
327
-
328
- {/* Step 2: 150-Problem Catalog Checklist */}
329
- {step === 'checklist' && (
330
- <div className="flex-1 flex flex-col overflow-hidden">
331
- {/* Top Toolbar: Search, Filters & Box Selector */}
332
- <div className="p-3 sm:p-4 bg-amber-50/60 border-b-[2px] border-ink-black shrink-0 space-y-3">
333
- <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-3">
334
- <div className="flex items-center gap-2">
335
- <button
336
- onClick={() => setStep('welcome')}
337
- className="px-2.5 py-1.5 bg-paper-white hover:bg-slate-100 border-2 border-ink-black font-arcade text-[9px] font-bold text-ink-black flex items-center gap-1 cursor-pointer transition-colors shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]"
338
- >
339
- <ArrowLeft className="w-3.5 h-3.5" />
340
- BACK
341
- </button>
342
- <h2 className="font-headline-md text-base sm:text-lg font-bold text-ink-black">
343
- Fast-Track Catalog Checklist
344
- </h2>
345
- </div>
346
-
347
- <div className="flex items-center gap-2 bg-paper-white border-2 border-ink-black p-1.5 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]">
348
- <span className="font-arcade text-[8px] font-bold text-trash-gray px-1 uppercase">
349
- FSRS STATE:
350
- </span>
351
- <span className="px-2 py-1 font-arcade text-[9px] font-bold bg-amber-400 text-ink-black border border-ink-black">
352
- ALL START AS 'NEW'
353
- </span>
354
- </div>
355
- </div>
356
-
357
- {/* Search Bar & Quick Bulk Actions */}
358
- <div className="flex flex-col sm:flex-row gap-2 items-center justify-between">
359
- <div className="relative w-full sm:w-72">
360
- <Search className="w-3.5 h-3.5 text-trash-gray absolute left-3 top-1/2 -translate-y-1/2" />
361
- <input
362
- type="text"
363
- value={searchQuery}
364
- onChange={(e) => setSearchQuery(e.target.value)}
365
- placeholder="Search by title, number, or pattern..."
366
- aria-label="Search problems by title, number, or pattern"
367
- className="w-full pl-8 pr-3 py-1.5 bg-paper-white border-2 border-ink-black font-sans text-xs text-ink-black font-medium outline-none focus:bg-amber-50"
368
- />
369
- {searchQuery && (
370
- <button
371
- onClick={() => setSearchQuery('')}
372
- aria-label="Clear search"
373
- className="absolute right-2 top-1/2 -translate-y-1/2 text-trash-gray hover:text-ink-black p-0.5 cursor-pointer"
374
- >
375
- <X className="w-3 h-3" />
376
- </button>
377
- )}
378
- </div>
379
-
380
- <div className="flex items-center gap-1.5 flex-wrap w-full sm:w-auto justify-end">
381
- <button
382
- onClick={() => selectByDifficulty('Easy')}
383
- className="px-2 py-1 bg-emerald-100 hover:bg-emerald-200 border border-emerald-800 text-emerald-900 font-arcade text-[8px] font-bold cursor-pointer transition-colors"
384
- >
385
- + ALL EASY
386
- </button>
387
- <button
388
- onClick={() => selectByDifficulty('Medium')}
389
- className="px-2 py-1 bg-amber-100 hover:bg-amber-200 border border-amber-800 text-amber-900 font-arcade text-[8px] font-bold cursor-pointer transition-colors"
390
- >
391
- + ALL MEDIUM
392
- </button>
393
- <button
394
- onClick={selectAll}
395
- className="px-2 py-1 bg-purple-100 hover:bg-purple-200 border border-purple-800 text-purple-900 font-arcade text-[8px] font-bold cursor-pointer transition-colors"
396
- >
397
- SELECT ALL (150)
398
- </button>
399
- <button
400
- onClick={clearAll}
401
- className="px-2 py-1 bg-slate-100 hover:bg-slate-200 border border-slate-700 text-slate-800 font-arcade text-[8px] font-bold cursor-pointer transition-colors"
402
- >
403
- CLEAR
404
- </button>
405
- </div>
406
- </div>
407
-
408
- {/* Pattern Filter Tags */}
409
- <div className="flex items-center gap-1.5 overflow-x-auto custom-scrollbar pb-1 text-[8px] font-arcade font-bold">
410
- <button
411
- onClick={() => setSelectedPatternFilter('ALL')}
412
- className={`px-2 py-0.5 border cursor-pointer shrink-0 transition-colors ${selectedPatternFilter === 'ALL'
413
- ? 'bg-ink-black text-amber-300 border-ink-black'
414
- : 'bg-paper-white text-trash-gray border-slate-300 hover:text-ink-black'
415
- }`}
416
- >
417
- ALL PATTERNS ({allProblems.length})
418
- </button>
419
- {allPatterns.map((pat) => {
420
- const count = allProblems.filter((p) => p.pattern === pat).length;
421
- const isSelected = selectedPatternFilter === pat;
422
- return (
423
- <button
424
- key={pat}
425
- onClick={() => setSelectedPatternFilter(pat)}
426
- className={`px-2 py-0.5 border cursor-pointer shrink-0 transition-colors ${isSelected
427
- ? 'bg-ink-black text-amber-300 border-ink-black'
428
- : 'bg-paper-white text-trash-gray border-slate-300 hover:text-ink-black'
429
- }`}
430
- >
431
- {pat.toUpperCase()} ({count})
432
- </button>
433
- );
434
- })}
435
- </div>
436
- </div>
437
-
438
- {/* Checklist Scrollable Body */}
439
- <div className="flex-1 overflow-y-auto p-4 sm:p-6 custom-scrollbar space-y-4 bg-slate-50/50">
440
- {Array.from(groupedProblems.entries()).map(([patternName, probs]) => {
441
- const patternSelectedCount = probs.filter((p) =>
442
- selectedNumbers.has(p.problem_number)
443
- ).length;
444
- const isAllPatternSelected = patternSelectedCount === probs.length;
445
- const isExpanded = expandedPatterns[patternName] !== false; // default open
446
-
447
- return (
448
- <div
449
- key={patternName}
450
- className="bg-paper-white border-2 border-ink-black gadget-shadow overflow-hidden"
451
- >
452
- {/* Pattern Section Header */}
453
- <div className="px-3.5 py-2.5 bg-gradient-to-r from-amber-100 to-amber-50 border-b-2 border-ink-black flex items-center justify-between">
454
- <div className="flex items-center gap-2">
455
- <button
456
- onClick={() => togglePatternExpand(patternName)}
457
- className="p-1 hover:bg-black/10 rounded cursor-pointer transition-colors text-ink-black"
458
- >
459
- {isExpanded ? (
460
- <ChevronUp className="w-3.5 h-3.5" />
461
- ) : (
462
- <ChevronDown className="w-3.5 h-3.5" />
463
- )}
464
- </button>
465
- <span className="font-headline-md text-xs sm:text-sm font-bold text-ink-black">
466
- {patternName}
467
- </span>
468
- <span className="font-arcade text-[8px] font-bold px-1.5 py-0.5 rounded bg-amber-900/10 text-amber-900 border border-amber-900/20">
469
- {patternSelectedCount} / {probs.length} selected
470
- </span>
471
- </div>
472
-
473
- <button
474
- onClick={() => togglePatternSelection(patternName)}
475
- className="px-2 py-1 font-arcade text-[8px] font-bold border border-ink-black bg-paper-white hover:bg-amber-200 transition-colors cursor-pointer flex items-center gap-1 shadow-[1px_1px_0px_0px_rgba(30,41,59,1)]"
476
- >
477
- {isAllPatternSelected ? (
478
- <>
479
- <CheckSquare className="w-3 h-3 text-emerald-600" />
480
- <span>DESELECT ALL</span>
481
- </>
482
- ) : (
483
- <>
484
- <Square className="w-3 h-3 text-slate-500" />
485
- <span>SELECT ALL</span>
486
- </>
487
- )}
488
- </button>
489
- </div>
490
-
491
- {/* Problems Grid */}
492
- {isExpanded && (
493
- <div className="p-3 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2">
494
- {probs.map((p) => {
495
- const isChecked = selectedNumbers.has(p.problem_number);
496
- return (
497
- <div
498
- key={p.problem_number}
499
- onClick={() => toggleProblemSelection(p.problem_number)}
500
- className={`p-2.5 border-2 transition-all cursor-pointer select-none flex items-start gap-2.5 ${isChecked
501
- ? 'bg-amber-50/80 border-amber-600 shadow-[2px_2px_0px_0px_#d97706]'
502
- : 'bg-paper-white border-slate-300 hover:border-ink-black'
503
- }`}
504
- >
505
- <div className="mt-0.5 shrink-0">
506
- {isChecked ? (
507
- <CheckSquare className="w-4 h-4 text-emerald-600 stroke-[2.5]" />
508
- ) : (
509
- <Square className="w-4 h-4 text-slate-400 stroke-[2]" />
510
- )}
511
- </div>
512
-
513
- <div className="min-w-0 flex-1">
514
- <div className="flex items-center gap-1.5">
515
- <span className="font-mono text-[9px] font-bold text-trash-gray">
516
- #{p.problem_number}
517
- </span>
518
- <span
519
- className={`px-1.5 py-0.2 rounded font-arcade text-[7px] font-bold uppercase text-white ${p.difficulty === 'Easy'
520
- ? 'bg-emerald-600'
521
- : p.difficulty === 'Medium'
522
- ? 'bg-amber-600'
523
- : 'bg-rose-600'
524
- }`}
525
- >
526
- {p.difficulty}
527
- </span>
528
- </div>
529
- <h3 className="font-headline-md text-xs font-bold text-ink-black truncate mt-0.5">
530
- {p.name}
531
- </h3>
532
- <div className="text-[10px] font-code-mono text-slate-500 truncate mt-0.5">
533
- T: {p.time_complexity} | S: {p.space_complexity}
534
- </div>
535
- </div>
536
- </div>
537
- );
538
- })}
539
- </div>
540
- )}
541
- </div>
542
- );
543
- })}
544
-
545
- {groupedProblems.size === 0 && (
546
- <div className="p-8 text-center bg-paper-white border-2 border-dashed border-slate-300 text-trash-gray space-y-2">
547
- <Search className="w-8 h-8 mx-auto text-slate-400" />
548
- <p className="font-arcade text-xs font-bold">NO MATCHING PROBLEMS FOUND</p>
549
- <p className="text-xs font-sans">Try searching another keyword or clearing filters.</p>
550
- </div>
551
- )}
552
- </div>
553
-
554
- {/* Bottom Sticky Action Bar */}
555
- <div className="p-3 sm:p-4 bg-paper-white border-t-[3px] border-ink-black shrink-0 flex flex-col sm:flex-row items-center justify-between gap-3 shadow-[0px_-4px_10px_rgba(0,0,0,0.05)]">
556
- <div className="flex items-center gap-2">
557
- <div className="w-7 h-7 rounded-lg bg-emerald-100 border border-emerald-800 flex items-center justify-center">
558
- <CheckCircle2 className="w-4 h-4 text-emerald-700" />
559
- </div>
560
- <div>
561
- <span className="font-arcade text-[10px] font-bold text-ink-black">
562
- {selectedNumbers.size} of {allProblems.length} PROBLEMS SELECTED
563
- </span>
564
- <div className="font-sans text-[11px] text-trash-gray font-semibold">
565
- Target: FSRS (New)
566
- </div>
567
- </div>
568
- </div>
569
-
570
- <div className="flex items-center gap-2 w-full sm:w-auto justify-end">
571
- {errorMessage && (
572
- <span className="font-arcade text-[9px] text-rose-600 font-bold mr-2 truncate">
573
- {errorMessage}
574
- </span>
575
- )}
576
- <button
577
- onClick={handleEnrollFastTrack}
578
- disabled={selectedNumbers.size === 0 || isSubmitting}
579
- className="w-full sm:w-auto px-6 py-2.5 bg-gradient-to-r from-amber-400 to-grass-green hover:from-amber-300 hover:to-emerald-400 text-ink-black font-arcade text-[10px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 active:shadow-none transition-all cursor-pointer flex items-center justify-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed"
580
- >
581
- {isSubmitting ? (
582
- <>
583
- <RefreshCw className="w-3.5 h-3.5 animate-spin" />
584
- <span>ENROLLING...</span>
585
- </>
586
- ) : (
587
- <>
588
- <Zap className="w-3.5 h-3.5 text-amber-900" />
589
- <span>ENROLL {selectedNumbers.size} PROBLEMS (FSRS)</span>
590
- </>
591
- )}
592
- </button>
593
- </div>
594
- </div>
595
- </div>
596
- )}
597
- </div>
598
- </div>
599
- );
600
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
algospaced-ui/src/components/ReviewQueue.tsx CHANGED
@@ -1,6 +1,5 @@
1
  import { useState, useEffect, useCallback, useRef, lazy, Suspense } from 'react';
2
  import { RefreshCw, FileText, Code, BookOpen, WifiOff, AlertTriangle, RotateCcw } from 'lucide-react';
3
- import OnboardingModal from './OnboardingModal';
4
  import { findCatalogProblem } from '../services/catalogService';
5
  import { parseProblemContent, parseProblemTitle } from '../utils/problemContentParser';
6
  import { getGitHubConfig, pushSolutionToGitHub } from '../services/githubSyncService';
@@ -23,7 +22,7 @@ export interface ReviewQueueProps {
23
  onOpenJourney?: () => void;
24
  onOpenCreateProblem?: () => void;
25
  onOpenEditProblem?: (problem: ProblemItem) => void;
26
- onOpenOnboarding?: () => void;
27
  refreshTrigger?: number;
28
  }
29
 
@@ -34,12 +33,12 @@ export default function ReviewQueue({
34
  onOpenJourney,
35
  onOpenCreateProblem,
36
  onOpenEditProblem,
37
- onOpenOnboarding,
38
  refreshTrigger
39
  }: ReviewQueueProps) {
40
  const [containerWidth, setContainerWidth] = useState<number | null>(null);
41
  const isNarrow = containerWidth !== null ? containerWidth < 780 : false;
42
- const [leftTab, setLeftTab] = useState<'spec' | 'ref' | 'leitner'>('spec');
43
  const [mobileView, setMobileView] = useState<'spec' | 'code' | 'ref'>('spec');
44
  const [copiedSnippet, setCopiedSnippet] = useState<string | null>(null);
45
 
@@ -53,7 +52,6 @@ export default function ReviewQueue({
53
  });
54
  observer.observe(node);
55
  }, []);
56
- const [isOnboardingOpen, setIsOnboardingOpen] = useState(false);
57
 
58
  const [isAutocompleteEnabled, setIsAutocompleteEnabled] = useState<boolean>(() => {
59
  const saved = localStorage.getItem('isAutocompleteEnabled');
@@ -73,7 +71,6 @@ export default function ReviewQueue({
73
  setCode,
74
  nextMilestone,
75
  activatingMilestone,
76
- currentUserId,
77
  fetchQueue,
78
  handleGrade,
79
  handleSelectCard,
@@ -82,9 +79,7 @@ export default function ReviewQueue({
82
  } = useReviewQueue({
83
  overrideProblemId,
84
  refreshTrigger,
85
- onClearOverride,
86
- onOpenOnboarding,
87
- setIsOnboardingOpen
88
  });
89
 
90
  const {
@@ -245,14 +240,6 @@ export default function ReviewQueue({
245
  else onOpenWindow?.('createProblem');
246
  }, [onOpenCreateProblem, onOpenWindow]);
247
 
248
- const handleOpenOnboardingInternal = useCallback(() => {
249
- if (onOpenOnboarding) {
250
- onOpenOnboarding();
251
- } else {
252
- setIsOnboardingOpen(true);
253
- }
254
- }, [onOpenOnboarding]);
255
-
256
  const handleUpdateSolutions = useCallback((updatedSolutions: ProblemSolution[]) => {
257
  setReviews((prev) => {
258
  if (prev.length === 0) return prev;
@@ -344,17 +331,12 @@ export default function ReviewQueue({
344
  nextMilestone={nextMilestone}
345
  activatingMilestone={activatingMilestone}
346
  onActivateNextMilestone={handleActivateNextMilestone}
347
- onOpenOnboarding={handleOpenOnboardingInternal}
348
  onOpenJourney={handleOpenJourney}
349
  onOpenCreateProblem={handleOpenCreateProblem}
350
  onOpenWindow={onOpenWindow}
351
  overrideProblemId={overrideProblemId}
352
  onClearOverride={onClearOverride}
353
- hasCustomOnboardingModal={Boolean(onOpenOnboarding)}
354
- isOnboardingOpen={isOnboardingOpen}
355
- onCloseOnboarding={() => setIsOnboardingOpen(false)}
356
- onCompletedOnboarding={fetchQueue}
357
- currentUserId={currentUserId}
358
  />
359
  );
360
  }
@@ -603,15 +585,6 @@ export default function ReviewQueue({
603
  submittingRating={submittingRating}
604
  onGrade={handleGradeWithReset}
605
  />
606
-
607
- {!onOpenOnboarding && (
608
- <OnboardingModal
609
- isOpen={isOnboardingOpen}
610
- onClose={() => setIsOnboardingOpen(false)}
611
- onCompleted={fetchQueue}
612
- userId={currentUserId}
613
- />
614
- )}
615
  </div>
616
  );
617
  }
 
1
  import { useState, useEffect, useCallback, useRef, lazy, Suspense } from 'react';
2
  import { RefreshCw, FileText, Code, BookOpen, WifiOff, AlertTriangle, RotateCcw } from 'lucide-react';
 
3
  import { findCatalogProblem } from '../services/catalogService';
4
  import { parseProblemContent, parseProblemTitle } from '../utils/problemContentParser';
5
  import { getGitHubConfig, pushSolutionToGitHub } from '../services/githubSyncService';
 
22
  onOpenJourney?: () => void;
23
  onOpenCreateProblem?: () => void;
24
  onOpenEditProblem?: (problem: ProblemItem) => void;
25
+ onOpenCardManager?: () => void;
26
  refreshTrigger?: number;
27
  }
28
 
 
33
  onOpenJourney,
34
  onOpenCreateProblem,
35
  onOpenEditProblem,
36
+ onOpenCardManager,
37
  refreshTrigger
38
  }: ReviewQueueProps) {
39
  const [containerWidth, setContainerWidth] = useState<number | null>(null);
40
  const isNarrow = containerWidth !== null ? containerWidth < 780 : false;
41
+ const [leftTab, setLeftTab] = useState<'spec' | 'ref' | 'fsrs'>('spec');
42
  const [mobileView, setMobileView] = useState<'spec' | 'code' | 'ref'>('spec');
43
  const [copiedSnippet, setCopiedSnippet] = useState<string | null>(null);
44
 
 
52
  });
53
  observer.observe(node);
54
  }, []);
 
55
 
56
  const [isAutocompleteEnabled, setIsAutocompleteEnabled] = useState<boolean>(() => {
57
  const saved = localStorage.getItem('isAutocompleteEnabled');
 
71
  setCode,
72
  nextMilestone,
73
  activatingMilestone,
 
74
  fetchQueue,
75
  handleGrade,
76
  handleSelectCard,
 
79
  } = useReviewQueue({
80
  overrideProblemId,
81
  refreshTrigger,
82
+ onClearOverride
 
 
83
  });
84
 
85
  const {
 
240
  else onOpenWindow?.('createProblem');
241
  }, [onOpenCreateProblem, onOpenWindow]);
242
 
 
 
 
 
 
 
 
 
243
  const handleUpdateSolutions = useCallback((updatedSolutions: ProblemSolution[]) => {
244
  setReviews((prev) => {
245
  if (prev.length === 0) return prev;
 
331
  nextMilestone={nextMilestone}
332
  activatingMilestone={activatingMilestone}
333
  onActivateNextMilestone={handleActivateNextMilestone}
334
+ onOpenCardManager={onOpenCardManager || (() => onOpenWindow?.('cardManager'))}
335
  onOpenJourney={handleOpenJourney}
336
  onOpenCreateProblem={handleOpenCreateProblem}
337
  onOpenWindow={onOpenWindow}
338
  overrideProblemId={overrideProblemId}
339
  onClearOverride={onClearOverride}
 
 
 
 
 
340
  />
341
  );
342
  }
 
585
  submittingRating={submittingRating}
586
  onGrade={handleGradeWithReset}
587
  />
 
 
 
 
 
 
 
 
 
588
  </div>
589
  );
590
  }
algospaced-ui/src/components/TerminalEmulator.tsx CHANGED
@@ -95,7 +95,7 @@ export default function TerminalEmulator({ onOpenWindow, onClose }: TerminalEmul
95
  'Available commands:',
96
  ' help - Display this documentation',
97
  ' ps - Inspect OS process table (PIDs & task states)',
98
- ' streak - Retrieve your active Leitner combo streak metrics',
99
  ' sync - Run google drive file import sync',
100
  ' reviews - Fetch Leetcode numbers due for daily review',
101
  ' python play - Open Daily Python Challenge window',
@@ -206,7 +206,7 @@ export default function TerminalEmulator({ onOpenWindow, onClose }: TerminalEmul
206
  }
207
  break;
208
  case 'reviews':
209
- output.push('Querying leitner_cards partition...');
210
  try {
211
  const { data: { session } } = await supabase.auth.getSession();
212
  if (!session) {
@@ -226,11 +226,17 @@ export default function TerminalEmulator({ onOpenWindow, onClose }: TerminalEmul
226
  problem_number?: number;
227
  name?: string;
228
  };
229
- box_level?: number;
230
  }
 
 
 
 
 
 
231
  output.push(
232
  `Queue status: ${data.length} card(s) due:`,
233
- ...(data as DueReviewResponse[]).map((r) => ` - LeetCode ${r.problems?.problem_number ?? '?'}: ${r.problems?.name ?? 'Unknown'} (Box ${r.box_level ?? 1})`)
234
  );
235
  }
236
  } else {
 
95
  'Available commands:',
96
  ' help - Display this documentation',
97
  ' ps - Inspect OS process table (PIDs & task states)',
98
+ ' streak - Retrieve your active review streak metrics',
99
  ' sync - Run google drive file import sync',
100
  ' reviews - Fetch Leetcode numbers due for daily review',
101
  ' python play - Open Daily Python Challenge window',
 
206
  }
207
  break;
208
  case 'reviews':
209
+ output.push('Querying fsrs_cards partition...');
210
  try {
211
  const { data: { session } } = await supabase.auth.getSession();
212
  if (!session) {
 
226
  problem_number?: number;
227
  name?: string;
228
  };
229
+ fsrs_state?: number;
230
  }
231
+ const stateNames: Record<number, string> = {
232
+ 0: 'New',
233
+ 1: 'Learning',
234
+ 2: 'Review',
235
+ 3: 'Relearning'
236
+ };
237
  output.push(
238
  `Queue status: ${data.length} card(s) due:`,
239
+ ...(data as DueReviewResponse[]).map((r) => ` - LeetCode ${r.problems?.problem_number ?? '?'}: ${r.problems?.name ?? 'Unknown'} (${stateNames[r.fsrs_state ?? 0] ?? 'New'})`)
240
  );
241
  }
242
  } else {
algospaced-ui/src/components/card-manager/CardManager.tsx ADDED
@@ -0,0 +1,1344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect, useMemo, useCallback } from 'react';
2
+ import {
3
+ Layers,
4
+ Search,
5
+ RefreshCw,
6
+ PlusCircle,
7
+ Play,
8
+ RotateCcw,
9
+ Trash2,
10
+ Edit,
11
+ CheckSquare,
12
+ Square,
13
+ Check,
14
+ Copy,
15
+ Folder,
16
+ ArrowUpDown,
17
+ Tag,
18
+ Sparkles,
19
+ Zap,
20
+ Info
21
+ } from 'lucide-react';
22
+ import {
23
+ fetchManagedCards,
24
+ resetCardReviews,
25
+ deleteCustomCard,
26
+ deleteCustomCards,
27
+ enrollCatalogCards,
28
+ type ManagedCard
29
+ } from '../../services/cardManagerService';
30
+ import type { ProblemItem } from '../../types/reviewTypes';
31
+
32
+ interface CardManagerProps {
33
+ onOpenQueue: () => void;
34
+ onOpenCreateProblem: () => void;
35
+ onOpenEditProblem: (problem: ProblemItem) => void;
36
+ onSelectProblemForReview: (problemId: string) => void;
37
+ refreshTrigger?: number;
38
+ onRefreshExplorer?: () => void;
39
+ }
40
+
41
+ type DeckFilterType = 'all' | 'due' | 'enrolled' | 'new' | 'learning' | 'reviewing' | 'relearning';
42
+ type SortField = 'number' | 'name' | 'pattern' | 'difficulty' | 'state' | 'due' | 'retention';
43
+ type SortOrder = 'asc' | 'desc';
44
+ type InspectorTab = 'front' | 'back' | 'stats';
45
+
46
+ export default function CardManager({
47
+ onOpenQueue,
48
+ onOpenCreateProblem,
49
+ onOpenEditProblem,
50
+ onSelectProblemForReview,
51
+ refreshTrigger,
52
+ onRefreshExplorer
53
+ }: CardManagerProps) {
54
+ const [cards, setCards] = useState<ManagedCard[]>([]);
55
+ const [loading, setLoading] = useState(true);
56
+ const [error, setError] = useState<string | null>(null);
57
+
58
+ // Filter & Search states
59
+ const [searchQuery, setSearchQuery] = useState('');
60
+ const [selectedDeck, setSelectedDeck] = useState<DeckFilterType>('all');
61
+ const [selectedPattern, setSelectedPattern] = useState<string>('ALL');
62
+ const [selectedDifficulty, setSelectedDifficulty] = useState<string>('ALL');
63
+
64
+ // Sorting
65
+ const [sortField, setSortField] = useState<SortField>('number');
66
+ const [sortOrder, setSortOrder] = useState<SortOrder>('asc');
67
+
68
+ // Selection & Inspector
69
+ const [selectedCardIds, setSelectedCardIds] = useState<Set<string>>(new Set());
70
+ const [activeCardId, setActiveCardId] = useState<string | null>(null);
71
+ const [inspectorTab, setInspectorTab] = useState<InspectorTab>('front');
72
+ const [isCopied, setIsCopied] = useState(false);
73
+
74
+ // Operational states
75
+ const [actionLoading, setActionLoading] = useState(false);
76
+ const [statusMessage, setStatusMessage] = useState<string | null>(null);
77
+
78
+ // Mobile sub-view tab ('table' vs 'inspector')
79
+ const [mobileView, setMobileView] = useState<'table' | 'inspector'>('table');
80
+
81
+ const loadCards = useCallback(async () => {
82
+ setLoading(true);
83
+ setError(null);
84
+ try {
85
+ const data = await fetchManagedCards();
86
+ setCards(data);
87
+ if (data.length > 0 && !activeCardId) {
88
+ setActiveCardId(data[0].id);
89
+ }
90
+ } catch (err: unknown) {
91
+ const msg = err instanceof Error ? err.message : 'Failed to load card database';
92
+ setError(msg);
93
+ } finally {
94
+ setLoading(false);
95
+ }
96
+ }, [activeCardId]);
97
+
98
+ useEffect(() => {
99
+ loadCards();
100
+ }, [loadCards, refreshTrigger]);
101
+
102
+ // Statistics calculation for all cards
103
+ const stats = useMemo(() => {
104
+ let dueCount = 0;
105
+ let enrolledCount = 0;
106
+ let newCount = 0;
107
+ let learningCount = 0;
108
+ let reviewingCount = 0;
109
+ let relearningCount = 0;
110
+
111
+ for (const c of cards) {
112
+ if (c.is_enrolled) {
113
+ enrolledCount++;
114
+ if (c.is_due) dueCount++;
115
+ const state = c.fsrs_state ?? 0;
116
+ if (state === 1) learningCount++;
117
+ else if (state === 2) reviewingCount++;
118
+ else if (state === 3) relearningCount++;
119
+ } else {
120
+ newCount++;
121
+ }
122
+ }
123
+
124
+ return {
125
+ total: cards.length,
126
+ due: dueCount,
127
+ enrolled: enrolledCount,
128
+ newCards: newCount,
129
+ learning: learningCount,
130
+ reviewing: reviewingCount,
131
+ relearning: relearningCount
132
+ };
133
+ }, [cards]);
134
+
135
+ // Unique patterns list with counts
136
+ const patternList = useMemo(() => {
137
+ const counts = new Map<string, number>();
138
+ for (const c of cards) {
139
+ counts.set(c.pattern, (counts.get(c.pattern) || 0) + 1);
140
+ }
141
+ const arr = Array.from(counts.entries()).map(([pattern, count]) => ({ pattern, count }));
142
+ arr.sort((a, b) => a.pattern.localeCompare(b.pattern));
143
+ return arr;
144
+ }, [cards]);
145
+
146
+ // Filtering cards
147
+ const filteredCards = useMemo(() => {
148
+ const q = searchQuery.trim().toLowerCase();
149
+ return cards.filter((card) => {
150
+ // 1. Deck state filter
151
+ if (selectedDeck === 'due' && !card.is_due) return false;
152
+ if (selectedDeck === 'enrolled' && !card.is_enrolled) return false;
153
+ if (selectedDeck === 'new' && card.is_enrolled) return false;
154
+ if (selectedDeck === 'learning' && (!card.is_enrolled || card.fsrs_state !== 1)) return false;
155
+ if (selectedDeck === 'reviewing' && (!card.is_enrolled || card.fsrs_state !== 2)) return false;
156
+ if (selectedDeck === 'relearning' && (!card.is_enrolled || card.fsrs_state !== 3)) return false;
157
+
158
+ // 2. Pattern filter
159
+ if (selectedPattern !== 'ALL' && card.pattern !== selectedPattern) return false;
160
+
161
+ // 3. Difficulty filter
162
+ if (selectedDifficulty !== 'ALL' && card.difficulty !== selectedDifficulty) return false;
163
+
164
+ // 4. Text query
165
+ if (q) {
166
+ const matchesNum = card.problem_number ? String(card.problem_number).includes(q) : false;
167
+ const matchesName = card.name.toLowerCase().includes(q);
168
+ const matchesPattern = card.pattern.toLowerCase().includes(q);
169
+ const matchesDiff = card.difficulty.toLowerCase().includes(q);
170
+ if (!matchesNum && !matchesName && !matchesPattern && !matchesDiff) return false;
171
+ }
172
+
173
+ return true;
174
+ });
175
+ }, [cards, selectedDeck, selectedPattern, selectedDifficulty, searchQuery]);
176
+
177
+ // Sorting filtered cards
178
+ const sortedCards = useMemo(() => {
179
+ const list = [...filteredCards];
180
+ list.sort((a, b) => {
181
+ let cmp = 0;
182
+ switch (sortField) {
183
+ case 'number': {
184
+ const numA = a.problem_number ?? 999999;
185
+ const numB = b.problem_number ?? 999999;
186
+ cmp = numA - numB;
187
+ break;
188
+ }
189
+ case 'name':
190
+ cmp = a.name.localeCompare(b.name);
191
+ break;
192
+ case 'pattern':
193
+ cmp = a.pattern.localeCompare(b.pattern);
194
+ break;
195
+ case 'difficulty': {
196
+ const diffWeight: Record<string, number> = { Easy: 1, Medium: 2, Hard: 3 };
197
+ cmp = (diffWeight[a.difficulty] || 2) - (diffWeight[b.difficulty] || 2);
198
+ break;
199
+ }
200
+ case 'state': {
201
+ const stateA = a.fsrs_state ?? -1;
202
+ const stateB = b.fsrs_state ?? -1;
203
+ cmp = stateA - stateB;
204
+ break;
205
+ }
206
+ case 'due': {
207
+ const dateA = a.next_review ? new Date(a.next_review).getTime() : 9999999999999;
208
+ const dateB = b.next_review ? new Date(b.next_review).getTime() : 9999999999999;
209
+ cmp = dateA - dateB;
210
+ break;
211
+ }
212
+ case 'retention': {
213
+ const rateA = a.total_attempts > 0 ? a.times_correct / a.total_attempts : 0;
214
+ const rateB = b.total_attempts > 0 ? b.times_correct / b.total_attempts : 0;
215
+ cmp = rateA - rateB;
216
+ break;
217
+ }
218
+ }
219
+ return sortOrder === 'asc' ? cmp : -cmp;
220
+ });
221
+ return list;
222
+ }, [filteredCards, sortField, sortOrder]);
223
+
224
+ // Active inspected card
225
+ const activeCard = useMemo(() => {
226
+ if (!activeCardId && sortedCards.length > 0) return sortedCards[0];
227
+ return cards.find((c) => c.id === activeCardId) || sortedCards[0] || null;
228
+ }, [cards, activeCardId, sortedCards]);
229
+
230
+ const toggleSort = (field: SortField) => {
231
+ if (sortField === field) {
232
+ setSortOrder(prev => (prev === 'asc' ? 'desc' : 'asc'));
233
+ } else {
234
+ setSortField(field);
235
+ setSortOrder('asc');
236
+ }
237
+ };
238
+
239
+ const toggleSelectCard = (id: string, e: React.MouseEvent) => {
240
+ e.stopPropagation();
241
+ setSelectedCardIds(prev => {
242
+ const next = new Set(prev);
243
+ if (next.has(id)) next.delete(id);
244
+ else next.add(id);
245
+ return next;
246
+ });
247
+ };
248
+
249
+ // Filtered cards selection state
250
+ const isAllFilteredSelected = useMemo(
251
+ () => sortedCards.length > 0 && sortedCards.every(c => selectedCardIds.has(c.id)),
252
+ [sortedCards, selectedCardIds]
253
+ );
254
+
255
+ const toggleSelectAllFiltered = () => {
256
+ setSelectedCardIds(prev => {
257
+ const next = new Set(prev);
258
+ if (isAllFilteredSelected) {
259
+ for (const c of sortedCards) {
260
+ next.delete(c.id);
261
+ }
262
+ } else {
263
+ for (const c of sortedCards) {
264
+ next.add(c.id);
265
+ }
266
+ }
267
+ return next;
268
+ });
269
+ };
270
+
271
+ // Custom problems in current selection
272
+ const customSelected = useMemo(
273
+ () => cards.filter(c => selectedCardIds.has(c.id) && c.is_custom),
274
+ [cards, selectedCardIds]
275
+ );
276
+
277
+ // Batch Delete selected custom cards
278
+ const handleBatchDeleteCustom = async () => {
279
+ if (customSelected.length === 0) return;
280
+ if (!confirm(`Are you sure you want to delete ${customSelected.length} custom cards?`)) return;
281
+
282
+ setActionLoading(true);
283
+ try {
284
+ const count = await deleteCustomCards(customSelected.map(c => c.id));
285
+ setStatusMessage(`Deleted ${count} custom cards.`);
286
+ setSelectedCardIds(prev => {
287
+ const next = new Set(prev);
288
+ for (const c of customSelected) next.delete(c.id);
289
+ return next;
290
+ });
291
+ await loadCards();
292
+ onRefreshExplorer?.();
293
+ } catch (err: unknown) {
294
+ const msg = err instanceof Error ? err.message : 'Batch delete failed';
295
+ setError(msg);
296
+ } finally {
297
+ setActionLoading(false);
298
+ setTimeout(() => setStatusMessage(null), 3500);
299
+ }
300
+ };
301
+
302
+ // Batch Enroll selected cards
303
+ const handleBatchEnroll = async () => {
304
+ const toEnroll = cards.filter(c => selectedCardIds.has(c.id) && !c.is_enrolled && c.catalogProblem);
305
+ if (toEnroll.length === 0) {
306
+ setStatusMessage('No unenrolled catalog cards in current selection.');
307
+ setTimeout(() => setStatusMessage(null), 3000);
308
+ return;
309
+ }
310
+
311
+ setActionLoading(true);
312
+ try {
313
+ const count = await enrollCatalogCards(toEnroll.map(c => c.catalogProblem!));
314
+ setStatusMessage(`Enrolled ${count} cards into Daily Queue!`);
315
+ setSelectedCardIds(new Set());
316
+ await loadCards();
317
+ onRefreshExplorer?.();
318
+ } catch (err: unknown) {
319
+ const msg = err instanceof Error ? err.message : 'Enrollment failed';
320
+ setError(msg);
321
+ } finally {
322
+ setActionLoading(false);
323
+ setTimeout(() => setStatusMessage(null), 3500);
324
+ }
325
+ };
326
+
327
+ // Batch Reset selected cards
328
+ const handleBatchReset = async () => {
329
+ const enrolledSelected = cards.filter(c => selectedCardIds.has(c.id) && c.is_enrolled);
330
+ if (enrolledSelected.length === 0) {
331
+ setStatusMessage('No active cards in selection to reset.');
332
+ setTimeout(() => setStatusMessage(null), 3000);
333
+ return;
334
+ }
335
+
336
+ setActionLoading(true);
337
+ try {
338
+ await resetCardReviews(enrolledSelected.map(c => c.id));
339
+ setStatusMessage(`Reset ${enrolledSelected.length} cards to initial FSRS state due today!`);
340
+ setSelectedCardIds(new Set());
341
+ await loadCards();
342
+ onRefreshExplorer?.();
343
+ } catch (err: unknown) {
344
+ const msg = err instanceof Error ? err.message : 'Reset failed';
345
+ setError(msg);
346
+ } finally {
347
+ setActionLoading(false);
348
+ setTimeout(() => setStatusMessage(null), 3500);
349
+ }
350
+ };
351
+
352
+ // Single card actions
353
+ const handleSingleReset = async (card: ManagedCard) => {
354
+ setActionLoading(true);
355
+ try {
356
+ await resetCardReviews([card.id]);
357
+ setStatusMessage(`Reset #${card.problem_number ?? '—'} ${card.name} for FSRS!`);
358
+ await loadCards();
359
+ onRefreshExplorer?.();
360
+ } catch (err: unknown) {
361
+ const msg = err instanceof Error ? err.message : 'Reset failed';
362
+ setError(msg);
363
+ } finally {
364
+ setActionLoading(false);
365
+ setTimeout(() => setStatusMessage(null), 3500);
366
+ }
367
+ };
368
+
369
+ const handleSingleEnroll = async (card: ManagedCard) => {
370
+ if (!card.catalogProblem) return;
371
+ setActionLoading(true);
372
+ try {
373
+ await enrollCatalogCards([card.catalogProblem]);
374
+ setStatusMessage(`Enrolled #${card.problem_number ?? '—'} ${card.name} into review queue!`);
375
+ await loadCards();
376
+ onRefreshExplorer?.();
377
+ } catch (err: unknown) {
378
+ const msg = err instanceof Error ? err.message : 'Enrollment failed';
379
+ setError(msg);
380
+ } finally {
381
+ setActionLoading(false);
382
+ setTimeout(() => setStatusMessage(null), 3500);
383
+ }
384
+ };
385
+
386
+ const handleSingleDelete = async (card: ManagedCard) => {
387
+ if (!confirm(`Are you sure you want to delete custom card "${card.name}"?`)) return;
388
+ setActionLoading(true);
389
+ try {
390
+ await deleteCustomCard(card.id);
391
+ setStatusMessage(`Deleted custom card "${card.name}"`);
392
+ await loadCards();
393
+ onRefreshExplorer?.();
394
+ } catch (err: unknown) {
395
+ const msg = err instanceof Error ? err.message : 'Delete failed';
396
+ setError(msg);
397
+ } finally {
398
+ setActionLoading(false);
399
+ setTimeout(() => setStatusMessage(null), 3500);
400
+ }
401
+ };
402
+
403
+ const handleReviewNow = useCallback((card: ManagedCard) => {
404
+ onSelectProblemForReview(card.id);
405
+ onOpenQueue();
406
+ }, [onSelectProblemForReview, onOpenQueue]);
407
+
408
+ const handleEditCard = (card: ManagedCard) => {
409
+ const problemItem: ProblemItem = {
410
+ id: card.id,
411
+ name: card.name,
412
+ problem_number: card.problem_number,
413
+ pattern: card.pattern,
414
+ difficulty: card.difficulty,
415
+ description: card.description,
416
+ examples: card.examples,
417
+ constraints: card.constraints,
418
+ optimal_time: card.optimal_time,
419
+ optimal_space: card.optimal_space,
420
+ starter_code: card.starter_code,
421
+ reference_code: card.reference_code,
422
+ how_to_solve: card.how_to_solve,
423
+ solutions: card.solutions
424
+ };
425
+ onOpenEditProblem(problemItem);
426
+ };
427
+
428
+ const copyReferenceCode = () => {
429
+ if (!activeCard?.reference_code) return;
430
+ navigator.clipboard.writeText(activeCard.reference_code);
431
+ setIsCopied(true);
432
+ setTimeout(() => setIsCopied(false), 2000);
433
+ };
434
+
435
+ const formatDueDate = (dateStr: string | null | undefined, isDue: boolean, isEnrolled: boolean) => {
436
+ if (!isEnrolled) return 'Not enrolled';
437
+ if (!dateStr) return 'Due now';
438
+ if (isDue) return 'Due today';
439
+ const d = new Date(dateStr);
440
+ const now = new Date();
441
+ const diffDays = Math.ceil((d.getTime() - now.getTime()) / (1000 * 60 * 60 * 24));
442
+ if (diffDays <= 1) return 'Tomorrow';
443
+ return `In ${diffDays}d`;
444
+ };
445
+
446
+ // Keyboard navigation across cards (Up/Down arrow, Space to flip tab, Enter to review)
447
+ useEffect(() => {
448
+ const handleKeyDown = (e: KeyboardEvent) => {
449
+ const target = e.target as HTMLElement;
450
+ if (
451
+ target.tagName === 'INPUT' ||
452
+ target.tagName === 'TEXTAREA' ||
453
+ target.tagName === 'SELECT' ||
454
+ target.isContentEditable
455
+ ) {
456
+ return;
457
+ }
458
+
459
+ if (sortedCards.length === 0) return;
460
+
461
+ const currentIdx = sortedCards.findIndex(c => c.id === activeCard?.id);
462
+
463
+ if (e.key === 'ArrowDown') {
464
+ e.preventDefault();
465
+ const nextIdx = currentIdx < sortedCards.length - 1 ? currentIdx + 1 : 0;
466
+ setActiveCardId(sortedCards[nextIdx].id);
467
+ } else if (e.key === 'ArrowUp') {
468
+ e.preventDefault();
469
+ const prevIdx = currentIdx > 0 ? currentIdx - 1 : sortedCards.length - 1;
470
+ setActiveCardId(sortedCards[prevIdx].id);
471
+ } else if (e.key === ' ' || e.code === 'Space') {
472
+ e.preventDefault();
473
+ setInspectorTab(prev => (prev === 'front' ? 'back' : 'front'));
474
+ } else if (e.key === 'Enter') {
475
+ if (activeCard?.is_enrolled) {
476
+ e.preventDefault();
477
+ handleReviewNow(activeCard);
478
+ }
479
+ }
480
+ };
481
+
482
+ window.addEventListener('keydown', handleKeyDown);
483
+ return () => window.removeEventListener('keydown', handleKeyDown);
484
+ }, [sortedCards, activeCard, handleReviewNow]);
485
+
486
+ return (
487
+ <div className="w-full h-full flex flex-col bg-[#fdf8e1] font-sans text-ink-black select-none overflow-hidden">
488
+ {/* 1. Header Toolbar (Anki Deck Browser Banner) */}
489
+ <div className="bg-slate-900 text-white border-b-[3px] border-ink-black px-4 py-2.5 flex flex-wrap items-center justify-between gap-3 shrink-0">
490
+ <div className="flex items-center gap-2.5">
491
+ <div className="w-8 h-8 rounded bg-sky-500 border-2 border-white flex items-center justify-center shadow-[2px_2px_0px_0px_rgba(0,0,0,0.5)]">
492
+ <Layers className="w-5 h-5 text-white stroke-[2.5]" />
493
+ </div>
494
+ <div>
495
+ <h1 className="font-arcade text-xs sm:text-sm font-bold tracking-wider text-amber-300 uppercase flex items-center gap-1.5">
496
+ MANAGE FSRS
497
+ </h1>
498
+ <p className="text-[10px] text-slate-300 font-mono">
499
+ Browse, filter, and reschedule spaced-repetition cards
500
+ </p>
501
+ </div>
502
+ </div>
503
+
504
+ {/* Global Stats Badges */}
505
+ <div className="flex items-center gap-1.5 sm:gap-2 flex-wrap text-[10px] font-mono">
506
+ <button
507
+ onClick={() => setSelectedDeck('all')}
508
+ className={`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${selectedDeck === 'all' ? 'bg-sky-500 text-white font-bold' : 'bg-slate-800 text-slate-300 hover:bg-slate-700'
509
+ }`}
510
+ >
511
+ Total: <span className="font-bold">{stats.total}</span>
512
+ </button>
513
+ <button
514
+ onClick={() => setSelectedDeck('due')}
515
+ className={`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${selectedDeck === 'due' ? 'bg-rose-500 text-white font-bold' : 'bg-slate-800 text-rose-300 hover:bg-slate-700'
516
+ }`}
517
+ >
518
+ Due Today: <span className="font-bold">{stats.due}</span>
519
+ </button>
520
+ <button
521
+ onClick={() => setSelectedDeck('enrolled')}
522
+ className={`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${selectedDeck === 'enrolled' ? 'bg-emerald-600 text-white font-bold' : 'bg-slate-800 text-emerald-300 hover:bg-slate-700'
523
+ }`}
524
+ >
525
+ In Review: <span className="font-bold">{stats.enrolled}</span>
526
+ </button>
527
+ <button
528
+ onClick={() => setSelectedDeck('learning')}
529
+ className={`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${selectedDeck === 'learning' ? 'bg-amber-500 text-slate-900 font-bold' : 'bg-slate-800 text-amber-300 hover:bg-slate-700'
530
+ }`}
531
+ >
532
+ Learning: <span className="font-bold">{stats.learning}</span>
533
+ </button>
534
+ <button
535
+ onClick={() => setSelectedDeck('reviewing')}
536
+ className={`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${selectedDeck === 'reviewing' ? 'bg-emerald-600 text-white font-bold' : 'bg-slate-800 text-emerald-300 hover:bg-slate-700'
537
+ }`}
538
+ >
539
+ Review: <span className="font-bold">{stats.reviewing}</span>
540
+ </button>
541
+ <button
542
+ onClick={() => setSelectedDeck('relearning')}
543
+ className={`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${selectedDeck === 'relearning' ? 'bg-rose-600 text-white font-bold' : 'bg-slate-800 text-rose-300 hover:bg-slate-700'
544
+ }`}
545
+ >
546
+ Relearning: <span className="font-bold">{stats.relearning}</span>
547
+ </button>
548
+ <button
549
+ onClick={() => setSelectedDeck('new')}
550
+ className={`px-2 py-0.5 border border-slate-700 rounded transition-colors cursor-pointer ${selectedDeck === 'new' ? 'bg-indigo-600 text-white font-bold' : 'bg-slate-800 text-indigo-300 hover:bg-slate-700'
551
+ }`}
552
+ >
553
+ Unenrolled: <span className="font-bold">{stats.newCards}</span>
554
+ </button>
555
+ </div>
556
+
557
+ {/* Global Actions */}
558
+ <div className="flex items-center gap-2">
559
+ <button
560
+ onClick={onOpenCreateProblem}
561
+ className="px-2.5 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black border-2 border-white rounded font-arcade text-[9px] font-bold shadow-[2px_2px_0px_0px_rgba(0,0,0,0.5)] active:translate-y-0.5 cursor-pointer flex items-center gap-1"
562
+ >
563
+ <PlusCircle className="w-3.5 h-3.5" />
564
+ <span>ADD CARD</span>
565
+ </button>
566
+ <button
567
+ onClick={loadCards}
568
+ disabled={loading}
569
+ className="p-1 bg-slate-800 hover:bg-slate-700 text-slate-200 border border-slate-600 rounded cursor-pointer disabled:opacity-50"
570
+ title="Refresh Deck"
571
+ >
572
+ <RefreshCw className={`w-3.5 h-3.5 ${loading ? 'animate-spin' : ''}`} />
573
+ </button>
574
+ </div>
575
+ </div>
576
+
577
+ {/* Status or Alert Notification Banner */}
578
+ {statusMessage && (
579
+ <div className="bg-amber-300 border-b-2 border-ink-black px-4 py-1.5 text-xs font-bold text-ink-black flex items-center justify-between shrink-0">
580
+ <div className="flex items-center gap-2">
581
+ <Sparkles className="w-4 h-4 text-amber-800" />
582
+ <span>{statusMessage}</span>
583
+ </div>
584
+ <button onClick={() => setStatusMessage(null)} className="text-xs hover:opacity-75 cursor-pointer">✕</button>
585
+ </div>
586
+ )}
587
+ {error && (
588
+ <div className="bg-rose-100 border-b-2 border-rose-400 px-4 py-1.5 text-xs font-semibold text-rose-800 flex items-center justify-between shrink-0">
589
+ <span>{error}</span>
590
+ <button onClick={() => setError(null)} className="text-xs hover:opacity-75 cursor-pointer">✕</button>
591
+ </div>
592
+ )}
593
+
594
+ {/* Mobile Tab Switcher */}
595
+ <div className="sm:hidden flex border-b-2 border-ink-black bg-white shrink-0">
596
+ <button
597
+ onClick={() => setMobileView('table')}
598
+ className={`flex-1 py-2 font-arcade text-[10px] font-bold text-center border-r border-ink-black ${mobileView === 'table' ? 'bg-amber-300 text-ink-black' : 'text-slate-600'
599
+ }`}
600
+ >
601
+ CARDS LIST ({sortedCards.length})
602
+ </button>
603
+ <button
604
+ onClick={() => setMobileView('inspector')}
605
+ className={`flex-1 py-2 font-arcade text-[10px] font-bold text-center ${mobileView === 'inspector' ? 'bg-amber-300 text-ink-black' : 'text-slate-600'
606
+ }`}
607
+ >
608
+ INSPECTOR {activeCard ? `#${activeCard.problem_number ?? ''}` : ''}
609
+ </button>
610
+ </div>
611
+
612
+ {/* 2. Main Workspace Body (3-Column Layout: Left Sidebar + Center Table + Right Inspector) */}
613
+ <div className="flex-1 flex overflow-hidden">
614
+ {/* LEFT COLUMN: Deck / Category / Tag Tree */}
615
+ <aside className="w-56 bg-[#f7f0cf] border-r-[3px] border-ink-black flex flex-col shrink-0 overflow-y-auto custom-scrollbar hidden md:flex">
616
+ <div className="p-3 border-b-2 border-ink-black/20">
617
+ <span className="font-arcade text-[9px] font-bold text-ink-black uppercase tracking-wider flex items-center gap-1.5">
618
+ <Folder className="w-3.5 h-3.5 text-amber-700" /> DECKS & STATES
619
+ </span>
620
+ </div>
621
+
622
+ <div className="p-2 space-y-1 text-xs">
623
+ <button
624
+ onClick={() => setSelectedDeck('all')}
625
+ className={`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${selectedDeck === 'all' ? 'bg-ink-black text-amber-300 font-bold' : 'hover:bg-amber-200/60 text-ink-black font-semibold'
626
+ }`}
627
+ >
628
+ <span>📁 All Cards</span>
629
+ <span className="font-mono text-[10px] opacity-80">{stats.total}</span>
630
+ </button>
631
+ <button
632
+ onClick={() => setSelectedDeck('due')}
633
+ className={`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${selectedDeck === 'due' ? 'bg-ink-black text-rose-300 font-bold' : 'hover:bg-amber-200/60 text-rose-900 font-semibold'
634
+ }`}
635
+ >
636
+ <span className="flex items-center gap-1">⏰ Due Today</span>
637
+ <span className="font-mono text-[10px] font-bold text-rose-600">{stats.due}</span>
638
+ </button>
639
+ <button
640
+ onClick={() => setSelectedDeck('enrolled')}
641
+ className={`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${selectedDeck === 'enrolled' ? 'bg-ink-black text-emerald-300 font-bold' : 'hover:bg-amber-200/60 text-ink-black font-semibold'
642
+ }`}
643
+ >
644
+ <span>📥 In Review</span>
645
+ <span className="font-mono text-[10px] opacity-80">{stats.enrolled}</span>
646
+ </button>
647
+ <button
648
+ onClick={() => setSelectedDeck('new')}
649
+ className={`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${selectedDeck === 'new' ? 'bg-ink-black text-sky-300 font-bold' : 'hover:bg-amber-200/60 text-ink-black font-semibold'
650
+ }`}
651
+ >
652
+ <span>🆕 Unenrolled (Catalog)</span>
653
+ <span className="font-mono text-[10px] opacity-80">{stats.newCards}</span>
654
+ </button>
655
+ <button
656
+ onClick={() => setSelectedDeck('learning')}
657
+ className={`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${selectedDeck === 'learning' ? 'bg-ink-black text-amber-300 font-bold' : 'hover:bg-amber-200/60 text-ink-black font-semibold'
658
+ }`}
659
+ >
660
+ <span>🔄 Learning (State 1)</span>
661
+ <span className="font-mono text-[10px] opacity-80">{stats.learning}</span>
662
+ </button>
663
+ <button
664
+ onClick={() => setSelectedDeck('reviewing')}
665
+ className={`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${selectedDeck === 'reviewing' ? 'bg-ink-black text-emerald-300 font-bold' : 'hover:bg-amber-200/60 text-ink-black font-semibold'
666
+ }`}
667
+ >
668
+ <span>📈 Review (State 2)</span>
669
+ <span className="font-mono text-[10px] opacity-80">{stats.reviewing}</span>
670
+ </button>
671
+ <button
672
+ onClick={() => setSelectedDeck('relearning')}
673
+ className={`w-full text-left px-2.5 py-1.5 rounded flex items-center justify-between cursor-pointer transition-colors ${selectedDeck === 'relearning' ? 'bg-ink-black text-rose-300 font-bold' : 'hover:bg-amber-200/60 text-ink-black font-semibold'
674
+ }`}
675
+ >
676
+ <span>🔁 Relearning (State 3)</span>
677
+ <span className="font-mono text-[10px] opacity-80">{stats.relearning}</span>
678
+ </button>
679
+ </div>
680
+
681
+ <div className="p-3 border-t-2 border-ink-black/20">
682
+ <span className="font-arcade text-[9px] font-bold text-ink-black uppercase tracking-wider flex items-center gap-1.5">
683
+ <Tag className="w-3.5 h-3.5 text-purple-700" /> PATTERNS (TAGS)
684
+ </span>
685
+ </div>
686
+
687
+ <div className="p-2 space-y-0.5 text-xs flex-1">
688
+ <button
689
+ onClick={() => setSelectedPattern('ALL')}
690
+ className={`w-full text-left px-2.5 py-1 rounded flex items-center justify-between cursor-pointer transition-colors ${selectedPattern === 'ALL' ? 'bg-purple-900 text-white font-bold' : 'hover:bg-purple-100 text-ink-black font-semibold'
691
+ }`}
692
+ >
693
+ <span>All Patterns</span>
694
+ <span className="font-mono text-[10px] opacity-80">{cards.length}</span>
695
+ </button>
696
+ {patternList.map(({ pattern, count }) => (
697
+ <button
698
+ key={pattern}
699
+ onClick={() => setSelectedPattern(pattern)}
700
+ className={`w-full text-left px-2.5 py-1 rounded flex items-center justify-between cursor-pointer transition-colors text-[11px] ${selectedPattern === pattern ? 'bg-purple-900 text-white font-bold' : 'hover:bg-purple-100 text-ink-black'
701
+ }`}
702
+ >
703
+ <span className="truncate">{pattern}</span>
704
+ <span className="font-mono text-[10px] opacity-80 shrink-0 ml-1">{count}</span>
705
+ </button>
706
+ ))}
707
+ </div>
708
+ </aside>
709
+
710
+ {/* CENTER COLUMN: Search bar + Multi-Select Actions + Card Table */}
711
+ <div className={`flex-1 flex flex-col min-w-0 bg-white border-r-[3px] border-ink-black ${mobileView === 'inspector' ? 'hidden sm:flex' : 'flex'}`}>
712
+ {/* Quick Search & Filter Controls */}
713
+ <div className="p-3 bg-[#fdf8e1] border-b-2 border-ink-black flex flex-wrap items-center justify-between gap-2 shrink-0">
714
+ <div className="relative flex-1 min-w-[200px]">
715
+ <Search className="w-4 h-4 absolute left-2.5 top-2.5 text-slate-500" />
716
+ <input
717
+ type="text"
718
+ value={searchQuery}
719
+ onChange={e => setSearchQuery(e.target.value)}
720
+ placeholder="Search by card #, title, pattern, or keyword..."
721
+ className="w-full pl-8 pr-3 py-1.5 bg-white border-2 border-ink-black text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-sky-500 shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]"
722
+ />
723
+ {searchQuery && (
724
+ <button
725
+ onClick={() => setSearchQuery('')}
726
+ className="absolute right-2.5 top-2 text-slate-400 hover:text-ink-black text-xs cursor-pointer"
727
+ >
728
+ ✕
729
+ </button>
730
+ )}
731
+ </div>
732
+
733
+ <div className="flex items-center gap-2">
734
+ <select
735
+ aria-label="Filter cards by difficulty"
736
+ value={selectedDifficulty}
737
+ onChange={e => setSelectedDifficulty(e.target.value)}
738
+ className="px-2.5 py-1.5 bg-white border-2 border-ink-black text-xs font-bold shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] cursor-pointer"
739
+ >
740
+ <option value="ALL">All Difficulties</option>
741
+ <option value="Easy">Easy</option>
742
+ <option value="Medium">Medium</option>
743
+ <option value="Hard">Hard</option>
744
+ </select>
745
+
746
+ <span className="text-[11px] font-mono text-slate-600 font-semibold hidden lg:inline">
747
+ {sortedCards.length} matching cards
748
+ </span>
749
+ </div>
750
+ </div>
751
+
752
+ {/* Sticky Multi-Select Batch Actions Bar */}
753
+ {selectedCardIds.size > 0 && (
754
+ <div className="bg-sky-100 border-b-2 border-ink-black px-3 py-2 flex items-center justify-between gap-2 shrink-0 animate-in fade-in flex-wrap">
755
+ <div className="flex items-center gap-2">
756
+ <span className="font-arcade text-[10px] font-bold text-sky-900 uppercase">
757
+ {selectedCardIds.size} SELECTED
758
+ {customSelected.length > 0 && ` (${customSelected.length} custom)`}
759
+ </span>
760
+ <button
761
+ onClick={() => setSelectedCardIds(new Set())}
762
+ className="text-xs text-sky-800 underline hover:text-sky-950 cursor-pointer"
763
+ >
764
+ Clear
765
+ </button>
766
+ </div>
767
+
768
+ <div className="flex items-center gap-2 flex-wrap">
769
+ <button
770
+ onClick={handleBatchEnroll}
771
+ disabled={actionLoading}
772
+ className="px-3 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50"
773
+ >
774
+ <Zap className="w-3.5 h-3.5 text-amber-900" />
775
+ <span>ADD TO QUEUE</span>
776
+ </button>
777
+ <button
778
+ onClick={handleBatchReset}
779
+ disabled={actionLoading}
780
+ className="px-3 py-1 bg-amber-300 hover:bg-amber-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50"
781
+ >
782
+ <RotateCcw className="w-3.5 h-3.5" />
783
+ <span>RESET PROGRESS</span>
784
+ </button>
785
+ {customSelected.length > 0 && (
786
+ <button
787
+ onClick={handleBatchDeleteCustom}
788
+ disabled={actionLoading}
789
+ className="px-3 py-1 bg-rose-200 hover:bg-rose-300 text-rose-950 font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50"
790
+ >
791
+ <Trash2 className="w-3.5 h-3.5 text-rose-700" />
792
+ <span>DELETE CUSTOM ({customSelected.length})</span>
793
+ </button>
794
+ )}
795
+ </div>
796
+ </div>
797
+ )}
798
+
799
+ {/* Anki Card Data Table */}
800
+ <div className="flex-1 overflow-y-auto custom-scrollbar">
801
+ <table className="w-full text-left border-collapse text-xs">
802
+ <thead className="sticky top-0 bg-[#f4ebd0] border-b-2 border-ink-black font-arcade text-[9px] font-bold text-ink-black z-10 select-none">
803
+ <tr>
804
+ <th className="p-2 w-8 text-center border-r border-ink-black/20">
805
+ <button
806
+ onClick={toggleSelectAllFiltered}
807
+ className="cursor-pointer flex items-center justify-center mx-auto text-ink-black"
808
+ title="Select all matching cards"
809
+ >
810
+ {isAllFilteredSelected ? (
811
+ <CheckSquare className="w-4 h-4 text-sky-700" />
812
+ ) : (
813
+ <Square className="w-4 h-4" />
814
+ )}
815
+ </button>
816
+ </th>
817
+ <th
818
+ onClick={() => toggleSort('number')}
819
+ className="p-2 w-16 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20"
820
+ >
821
+ <div className="flex items-center gap-1">
822
+ <span>#</span>
823
+ <ArrowUpDown className="w-3 h-3 opacity-60" />
824
+ </div>
825
+ </th>
826
+ <th
827
+ onClick={() => toggleSort('name')}
828
+ className="p-2 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20"
829
+ >
830
+ <div className="flex items-center gap-1">
831
+ <span>CARD TITLE</span>
832
+ <ArrowUpDown className="w-3 h-3 opacity-60" />
833
+ </div>
834
+ </th>
835
+ <th
836
+ onClick={() => toggleSort('pattern')}
837
+ className="p-2 hidden md:table-cell cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20"
838
+ >
839
+ <div className="flex items-center gap-1">
840
+ <span>DECK / PATTERN</span>
841
+ <ArrowUpDown className="w-3 h-3 opacity-60" />
842
+ </div>
843
+ </th>
844
+ <th
845
+ onClick={() => toggleSort('difficulty')}
846
+ className="p-2 w-20 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20"
847
+ >
848
+ <div className="flex items-center gap-1">
849
+ <span>DIFF</span>
850
+ <ArrowUpDown className="w-3 h-3 opacity-60" />
851
+ </div>
852
+ </th>
853
+ <th
854
+ onClick={() => toggleSort('state')}
855
+ className="p-2 w-24 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20"
856
+ >
857
+ <div className="flex items-center gap-1">
858
+ <span>FSRS STATE</span>
859
+ <ArrowUpDown className="w-3 h-3 opacity-60" />
860
+ </div>
861
+ </th>
862
+ <th
863
+ onClick={() => toggleSort('due')}
864
+ className="p-2 w-24 cursor-pointer hover:bg-amber-200/50 border-r border-ink-black/20"
865
+ >
866
+ <div className="flex items-center gap-1">
867
+ <span>DUE</span>
868
+ <ArrowUpDown className="w-3 h-3 opacity-60" />
869
+ </div>
870
+ </th>
871
+ <th
872
+ onClick={() => toggleSort('retention')}
873
+ className="p-2 w-20 hidden lg:table-cell cursor-pointer hover:bg-amber-200/50"
874
+ >
875
+ <div className="flex items-center gap-1">
876
+ <span>RETENTION</span>
877
+ <ArrowUpDown className="w-3 h-3 opacity-60" />
878
+ </div>
879
+ </th>
880
+ </tr>
881
+ </thead>
882
+ <tbody className="divide-y divide-slate-200">
883
+ {sortedCards.length === 0 ? (
884
+ <tr>
885
+ <td colSpan={8} className="p-8 text-center text-trash-gray font-mono">
886
+ No cards match current filter criteria.
887
+ </td>
888
+ </tr>
889
+ ) : (
890
+ sortedCards.map((card) => {
891
+ const isSelected = selectedCardIds.has(card.id);
892
+ const isActive = activeCard?.id === card.id;
893
+
894
+ return (
895
+ <tr
896
+ key={card.id}
897
+ onClick={() => {
898
+ setActiveCardId(card.id);
899
+ setMobileView('inspector');
900
+ }}
901
+ onDoubleClick={() => {
902
+ if (card.is_enrolled) {
903
+ handleReviewNow(card);
904
+ } else {
905
+ handleEditCard(card);
906
+ }
907
+ }}
908
+ className={`cursor-pointer transition-colors ${isActive
909
+ ? 'bg-sky-100 font-semibold'
910
+ : isSelected
911
+ ? 'bg-amber-50'
912
+ : 'hover:bg-slate-50'
913
+ }`}
914
+ >
915
+ <td
916
+ className="p-2 text-center"
917
+ onClick={e => toggleSelectCard(card.id, e)}
918
+ >
919
+ {isSelected ? (
920
+ <CheckSquare className="w-4 h-4 text-sky-600 mx-auto" />
921
+ ) : (
922
+ <Square className="w-4 h-4 text-slate-400 mx-auto" />
923
+ )}
924
+ </td>
925
+ <td className="p-2 font-mono text-[11px] font-bold text-slate-700">
926
+ {card.problem_number ? `#${card.problem_number}` : '—'}
927
+ </td>
928
+ <td className="p-2">
929
+ <div className="flex items-center gap-1.5">
930
+ <span className="font-semibold text-ink-black truncate">{card.name}</span>
931
+ {card.is_custom && (
932
+ <span className="px-1.5 py-0.2 rounded bg-purple-100 text-purple-800 border border-purple-300 text-[8px] font-bold uppercase shrink-0">
933
+ CUSTOM
934
+ </span>
935
+ )}
936
+ </div>
937
+ </td>
938
+ <td className="p-2 hidden md:table-cell text-slate-600 text-[11px] truncate">
939
+ {card.pattern}
940
+ </td>
941
+ <td className="p-2">
942
+ <span
943
+ className={`px-1.5 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${card.difficulty === 'Easy'
944
+ ? 'bg-emerald-600'
945
+ : card.difficulty === 'Medium'
946
+ ? 'bg-amber-600'
947
+ : 'bg-rose-600'
948
+ }`}
949
+ >
950
+ {card.difficulty}
951
+ </span>
952
+ </td>
953
+ <td className="p-2">
954
+ {card.is_enrolled ? (
955
+ <span className="inline-flex items-center gap-1 font-mono text-[10px] font-bold text-slate-800">
956
+ <span
957
+ className={`w-2 h-2 rounded-full ${
958
+ (card.fsrs_state ?? 0) === 2
959
+ ? 'bg-emerald-500'
960
+ : (card.fsrs_state ?? 0) === 1
961
+ ? 'bg-amber-500'
962
+ : (card.fsrs_state ?? 0) === 3
963
+ ? 'bg-rose-500'
964
+ : 'bg-blue-500'
965
+ }`}
966
+ />
967
+ {(card.fsrs_state ?? 0) === 0
968
+ ? 'New'
969
+ : (card.fsrs_state ?? 0) === 1
970
+ ? 'Learning'
971
+ : (card.fsrs_state ?? 0) === 2
972
+ ? 'Review'
973
+ : 'Relearning'}
974
+ </span>
975
+ ) : (
976
+ <span className="text-[10px] font-mono text-slate-400 uppercase font-semibold">
977
+ Unenrolled
978
+ </span>
979
+ )}
980
+ </td>
981
+ <td className="p-2 font-mono text-[10px]">
982
+ <span
983
+ className={
984
+ card.is_due
985
+ ? 'text-rose-600 font-bold bg-rose-50 px-1 py-0.5 rounded border border-rose-200'
986
+ : 'text-slate-600'
987
+ }
988
+ >
989
+ {formatDueDate(card.next_review, card.is_due, card.is_enrolled)}
990
+ </span>
991
+ </td>
992
+ <td className="p-2 hidden lg:table-cell font-mono text-[10px] text-slate-600">
993
+ {card.total_attempts > 0 ? (
994
+ <span>
995
+ {card.times_correct}/{card.total_attempts}{' '}
996
+ <span className="text-[9px] text-slate-400">
997
+ ({Math.round((card.times_correct / card.total_attempts) * 100)}%)
998
+ </span>
999
+ </span>
1000
+ ) : (
1001
+ <span className="text-slate-400">—</span>
1002
+ )}
1003
+ </td>
1004
+ </tr>
1005
+ );
1006
+ })
1007
+ )}
1008
+ </tbody>
1009
+ </table>
1010
+ </div>
1011
+ </div>
1012
+
1013
+ {/* RIGHT COLUMN: Anki Card Inspector & Detail Pane */}
1014
+ <aside className={`w-full sm:w-80 lg:w-96 bg-[#fdf8e1] flex flex-col shrink-0 overflow-hidden ${mobileView === 'table' ? 'hidden sm:flex' : 'flex'}`}>
1015
+ {activeCard ? (
1016
+ <div className="flex-1 flex flex-col h-full overflow-hidden">
1017
+ {/* Inspector Header */}
1018
+ <div className="p-4 bg-[#f8efcd] border-b-2 border-ink-black space-y-2 shrink-0">
1019
+ <div className="flex items-center justify-between">
1020
+ <span className="font-arcade text-[9px] font-bold text-amber-900 uppercase flex items-center gap-1">
1021
+ <Info className="w-3.5 h-3.5 text-amber-700" /> CARD INSPECTOR
1022
+ </span>
1023
+ <div className="flex items-center gap-1">
1024
+ <span
1025
+ className={`px-1.5 py-0.5 rounded font-arcade text-[8px] font-bold uppercase text-white ${activeCard.difficulty === 'Easy'
1026
+ ? 'bg-emerald-600'
1027
+ : activeCard.difficulty === 'Medium'
1028
+ ? 'bg-amber-600'
1029
+ : 'bg-rose-600'
1030
+ }`}
1031
+ >
1032
+ {activeCard.difficulty}
1033
+ </span>
1034
+ <span className="font-mono text-[10px] font-bold px-1.5 py-0.5 bg-white border border-ink-black rounded">
1035
+ {activeCard.problem_number ? `#${activeCard.problem_number}` : 'Custom'}
1036
+ </span>
1037
+ </div>
1038
+ </div>
1039
+
1040
+ <h3 className="font-headline-md text-base font-extrabold text-ink-black leading-tight">
1041
+ {activeCard.name}
1042
+ </h3>
1043
+
1044
+ <div className="flex items-center gap-1.5 flex-wrap text-[10px] font-mono text-slate-700">
1045
+ <span className="bg-purple-100 text-purple-900 px-2 py-0.5 rounded border border-purple-200 font-semibold">
1046
+ {activeCard.pattern}
1047
+ </span>
1048
+ {activeCard.optimal_time && (
1049
+ <span className="bg-slate-100 px-1.5 py-0.5 rounded border border-slate-300">
1050
+ T: {activeCard.optimal_time}
1051
+ </span>
1052
+ )}
1053
+ {activeCard.optimal_space && (
1054
+ <span className="bg-slate-100 px-1.5 py-0.5 rounded border border-slate-300">
1055
+ S: {activeCard.optimal_space}
1056
+ </span>
1057
+ )}
1058
+ </div>
1059
+
1060
+ {/* Card Inspector Action Bar */}
1061
+ <div className="flex items-center gap-1.5 pt-2 flex-wrap">
1062
+ {activeCard.is_enrolled ? (
1063
+ <>
1064
+ <button
1065
+ onClick={() => handleReviewNow(activeCard)}
1066
+ className="px-2.5 py-1 bg-grass-green hover:bg-emerald-400 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1"
1067
+ >
1068
+ <Play className="w-3 h-3 fill-ink-black" />
1069
+ <span>REVIEW NOW</span>
1070
+ </button>
1071
+ <button
1072
+ onClick={() => handleSingleReset(activeCard)}
1073
+ disabled={actionLoading}
1074
+ className="px-2 py-1 bg-amber-200 hover:bg-amber-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50"
1075
+ title="Reset interval to initial FSRS state due today"
1076
+ >
1077
+ <RotateCcw className="w-3 h-3" />
1078
+ <span>RESET</span>
1079
+ </button>
1080
+ </>
1081
+ ) : (
1082
+ <button
1083
+ onClick={() => handleSingleEnroll(activeCard)}
1084
+ disabled={actionLoading || !activeCard.catalogProblem}
1085
+ className="px-2.5 py-1 bg-sky-400 hover:bg-sky-300 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50"
1086
+ >
1087
+ <PlusCircle className="w-3 h-3" />
1088
+ <span>ENROLL CARD</span>
1089
+ </button>
1090
+ )}
1091
+
1092
+ <button
1093
+ onClick={() => handleEditCard(activeCard)}
1094
+ className="px-2 py-1 bg-white hover:bg-slate-100 text-ink-black font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1"
1095
+ >
1096
+ <Edit className="w-3 h-3" />
1097
+ <span>EDIT</span>
1098
+ </button>
1099
+
1100
+ {activeCard.is_custom && (
1101
+ <button
1102
+ onClick={() => handleSingleDelete(activeCard)}
1103
+ disabled={actionLoading}
1104
+ className="px-2 py-1 bg-rose-200 hover:bg-rose-300 text-rose-950 font-arcade text-[9px] font-bold border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] active:translate-y-0.5 cursor-pointer flex items-center gap-1 disabled:opacity-50"
1105
+ >
1106
+ <Trash2 className="w-3 h-3 text-rose-700" />
1107
+ <span>DELETE</span>
1108
+ </button>
1109
+ )}
1110
+ </div>
1111
+ </div>
1112
+
1113
+ {/* Inspector Tab Selector */}
1114
+ <div className="flex border-b-2 border-ink-black bg-white shrink-0">
1115
+ <button
1116
+ onClick={() => setInspectorTab('front')}
1117
+ className={`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center border-r border-ink-black/20 cursor-pointer ${inspectorTab === 'front' ? 'bg-amber-300 text-ink-black' : 'text-slate-600 hover:bg-slate-50'
1118
+ }`}
1119
+ >
1120
+ QUESTION
1121
+ </button>
1122
+ <button
1123
+ onClick={() => setInspectorTab('back')}
1124
+ className={`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center border-r border-ink-black/20 cursor-pointer ${inspectorTab === 'back' ? 'bg-amber-300 text-ink-black' : 'text-slate-600 hover:bg-slate-50'
1125
+ }`}
1126
+ >
1127
+ SHOW ANSWER
1128
+ </button>
1129
+ <button
1130
+ onClick={() => setInspectorTab('stats')}
1131
+ className={`flex-1 py-1.5 font-arcade text-[9px] font-bold text-center cursor-pointer ${inspectorTab === 'stats' ? 'bg-amber-300 text-ink-black' : 'text-slate-600 hover:bg-slate-50'
1132
+ }`}
1133
+ >
1134
+ SRS INFO
1135
+ </button>
1136
+ </div>
1137
+
1138
+ {/* Inspector Tab Content Area */}
1139
+ <div className="flex-1 p-4 overflow-y-auto custom-scrollbar space-y-4">
1140
+ {/* TAB 1: QUESTION */}
1141
+ {inspectorTab === 'front' && (
1142
+ <div className="space-y-3">
1143
+ <div>
1144
+ <span className="font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1">
1145
+ PROBLEM DESCRIPTION
1146
+ </span>
1147
+ <div className="p-3 bg-white border-2 border-ink-black text-xs font-semibold leading-relaxed shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] whitespace-pre-wrap">
1148
+ {activeCard.description || 'No description provided.'}
1149
+ </div>
1150
+ </div>
1151
+
1152
+ {activeCard.examples && (Array.isArray(activeCard.examples) ? activeCard.examples.length > 0 : true) && (
1153
+ <div>
1154
+ <span className="font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1">
1155
+ EXAMPLES
1156
+ </span>
1157
+ <div className="space-y-1.5">
1158
+ {Array.isArray(activeCard.examples) ? (
1159
+ activeCard.examples.map((ex, idx) => {
1160
+ if (typeof ex === 'string') {
1161
+ return (
1162
+ <div key={idx} className="p-2 bg-white border border-slate-300 text-[11px] font-mono">
1163
+ {ex}
1164
+ </div>
1165
+ );
1166
+ }
1167
+ return (
1168
+ <div key={idx} className="p-2 bg-white border border-slate-300 text-[11px] font-mono space-y-0.5">
1169
+ {ex.input && <div><span className="font-bold text-slate-700">Input:</span> {ex.input}</div>}
1170
+ {ex.output && <div><span className="font-bold text-slate-700">Output:</span> {ex.output}</div>}
1171
+ {ex.explanation && <div className="text-slate-500 italic text-[10px]">{ex.explanation}</div>}
1172
+ </div>
1173
+ );
1174
+ })
1175
+ ) : (
1176
+ <div className="p-2 bg-white border border-slate-300 text-[11px] font-mono">
1177
+ {String(activeCard.examples)}
1178
+ </div>
1179
+ )}
1180
+ </div>
1181
+ </div>
1182
+ )}
1183
+
1184
+ {activeCard.constraints && (Array.isArray(activeCard.constraints) ? activeCard.constraints.length > 0 : true) && (
1185
+ <div>
1186
+ <span className="font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1">
1187
+ CONSTRAINTS
1188
+ </span>
1189
+ <div className="p-2.5 bg-slate-50 border border-slate-300 text-[11px] font-mono space-y-1 text-slate-700">
1190
+ {Array.isArray(activeCard.constraints) ? (
1191
+ activeCard.constraints.map((c, i) => <div key={i}>• {c}</div>)
1192
+ ) : (
1193
+ <div>• {String(activeCard.constraints)}</div>
1194
+ )}
1195
+ </div>
1196
+ </div>
1197
+ )}
1198
+ </div>
1199
+ )}
1200
+
1201
+ {/* TAB 2: SHOW ANSWER (SOLUTION & CODE) */}
1202
+ {inspectorTab === 'back' && (
1203
+ <div className="space-y-3">
1204
+ <div className="flex items-center justify-between">
1205
+ <span className="font-arcade text-[8px] font-bold text-trash-gray uppercase">
1206
+ REFERENCE SOLUTION (PYTHON)
1207
+ </span>
1208
+ {activeCard.reference_code && (
1209
+ <button
1210
+ onClick={copyReferenceCode}
1211
+ className="px-2 py-0.5 bg-white hover:bg-slate-100 text-ink-black border border-ink-black text-[9px] font-bold rounded flex items-center gap-1 cursor-pointer"
1212
+ >
1213
+ {isCopied ? <Check className="w-3 h-3 text-emerald-600" /> : <Copy className="w-3 h-3" />}
1214
+ <span>{isCopied ? 'COPIED!' : 'COPY'}</span>
1215
+ </button>
1216
+ )}
1217
+ </div>
1218
+
1219
+ <div className="relative">
1220
+ <pre className="p-3 bg-slate-900 text-emerald-400 font-mono text-[11px] rounded border-2 border-ink-black overflow-x-auto shadow-[2px_2px_0px_0px_rgba(30,41,59,1)]">
1221
+ <code>{activeCard.reference_code || '# No reference code available.'}</code>
1222
+ </pre>
1223
+ </div>
1224
+
1225
+ {activeCard.how_to_solve && (
1226
+ <div>
1227
+ <span className="font-arcade text-[8px] font-bold text-trash-gray uppercase block mb-1">
1228
+ HOW TO SOLVE & STRATEGY
1229
+ </span>
1230
+ <div className="p-2.5 bg-white border border-slate-300 text-xs font-semibold leading-relaxed">
1231
+ {activeCard.how_to_solve}
1232
+ </div>
1233
+ </div>
1234
+ )}
1235
+ </div>
1236
+ )}
1237
+
1238
+ {/* TAB 3: SRS INFO & RETENTION STATS */}
1239
+ {inspectorTab === 'stats' && (
1240
+ <div className="space-y-3">
1241
+ <div className="p-3 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-2">
1242
+ <span className="font-arcade text-[9px] font-bold text-ink-black uppercase block border-b pb-1">
1243
+ FSRS REVIEW STATE
1244
+ </span>
1245
+ <div className="grid grid-cols-2 gap-2 text-xs">
1246
+ <div>
1247
+ <div className="text-[10px] text-trash-gray font-semibold">Current State</div>
1248
+ <div className="font-arcade text-base font-bold text-sky-700">
1249
+ {activeCard.is_enrolled
1250
+ ? (activeCard.fsrs_state ?? 0) === 0
1251
+ ? 'New (0)'
1252
+ : (activeCard.fsrs_state ?? 0) === 1
1253
+ ? 'Learning (1)'
1254
+ : (activeCard.fsrs_state ?? 0) === 2
1255
+ ? 'Review (2)'
1256
+ : 'Relearning (3)'
1257
+ : 'Unenrolled'}
1258
+ </div>
1259
+ </div>
1260
+ <div>
1261
+ <div className="text-[10px] text-trash-gray font-semibold">Status</div>
1262
+ <div className="font-arcade text-xs font-bold text-emerald-700">
1263
+ {activeCard.is_due ? 'Due Today' : activeCard.is_enrolled ? 'Scheduled' : 'Catalog New'}
1264
+ </div>
1265
+ </div>
1266
+ <div>
1267
+ <div className="text-[10px] text-trash-gray font-semibold">Stability</div>
1268
+ <div className="font-mono text-sm font-bold text-slate-800">
1269
+ {activeCard.fsrs_stability !== undefined ? `${activeCard.fsrs_stability.toFixed(1)}d` : '0.0d'}
1270
+ </div>
1271
+ </div>
1272
+ <div>
1273
+ <div className="text-[10px] text-trash-gray font-semibold">Difficulty</div>
1274
+ <div className="font-mono text-sm font-bold text-amber-700">
1275
+ {activeCard.fsrs_difficulty !== undefined ? `${activeCard.fsrs_difficulty.toFixed(1)}/10` : '0.0/10'}
1276
+ </div>
1277
+ </div>
1278
+ <div>
1279
+ <div className="text-[10px] text-trash-gray font-semibold">Total Attempts</div>
1280
+ <div className="font-mono text-sm font-bold text-slate-800">
1281
+ {activeCard.total_attempts}
1282
+ </div>
1283
+ </div>
1284
+ <div>
1285
+ <div className="text-[10px] text-trash-gray font-semibold">Times Correct</div>
1286
+ <div className="font-mono text-sm font-bold text-emerald-600">
1287
+ {activeCard.times_correct}
1288
+ </div>
1289
+ </div>
1290
+ <div className="col-span-2 pt-1 border-t border-slate-200">
1291
+ <div className="text-[10px] text-trash-gray font-semibold">Retention Success Rate</div>
1292
+ <div className="flex items-center gap-2 mt-1">
1293
+ <div className="flex-1 h-3 bg-slate-200 rounded-full overflow-hidden border border-slate-300">
1294
+ <div
1295
+ className="h-full bg-emerald-500 rounded-full"
1296
+ style={{
1297
+ width: `${activeCard.total_attempts > 0
1298
+ ? Math.round((activeCard.times_correct / activeCard.total_attempts) * 100)
1299
+ : 0
1300
+ }%`
1301
+ }}
1302
+ />
1303
+ </div>
1304
+ <span className="font-mono text-xs font-bold text-slate-800">
1305
+ {activeCard.total_attempts > 0
1306
+ ? `${Math.round((activeCard.times_correct / activeCard.total_attempts) * 100)}%`
1307
+ : '0%'}
1308
+ </span>
1309
+ </div>
1310
+ </div>
1311
+ </div>
1312
+ </div>
1313
+
1314
+ <div className="p-3 bg-white border-2 border-ink-black shadow-[2px_2px_0px_0px_rgba(30,41,59,1)] space-y-1.5 text-xs">
1315
+ <span className="font-arcade text-[9px] font-bold text-ink-black uppercase block border-b pb-1">
1316
+ TIMESTAMPS
1317
+ </span>
1318
+ <div className="flex items-center justify-between text-slate-700">
1319
+ <span className="text-[11px] font-semibold">Next Review:</span>
1320
+ <span className="font-mono text-[10px]">
1321
+ {activeCard.next_review ? new Date(activeCard.next_review).toLocaleString() : 'Not scheduled'}
1322
+ </span>
1323
+ </div>
1324
+ <div className="flex items-center justify-between text-slate-700">
1325
+ <span className="text-[11px] font-semibold">Last Reviewed:</span>
1326
+ <span className="font-mono text-[10px]">
1327
+ {activeCard.last_reviewed ? new Date(activeCard.last_reviewed).toLocaleString() : 'Never'}
1328
+ </span>
1329
+ </div>
1330
+ </div>
1331
+ </div>
1332
+ )}
1333
+ </div>
1334
+ </div>
1335
+ ) : (
1336
+ <div className="flex-1 flex items-center justify-center p-6 text-center text-trash-gray font-mono text-xs">
1337
+ Select a card to view its Front, Back, and SRS details.
1338
+ </div>
1339
+ )}
1340
+ </aside>
1341
+ </div>
1342
+ </div>
1343
+ );
1344
+ }
algospaced-ui/src/components/desktop/DesktopStartMenu.tsx CHANGED
@@ -3,7 +3,6 @@ import React from 'react';
3
  interface DesktopStartMenuProps extends React.HTMLAttributes<HTMLDivElement> {
4
  isOpen: boolean;
5
  onOpenWindow: (id: string) => void;
6
- onOpenOnboarding: () => void;
7
  onTriggerSync: () => void;
8
  onSignOut: () => void;
9
  style?: React.CSSProperties;
@@ -14,7 +13,6 @@ export const DesktopStartMenu = React.forwardRef<HTMLDivElement, DesktopStartMen
14
  {
15
  isOpen,
16
  onOpenWindow,
17
- onOpenOnboarding,
18
  onTriggerSync,
19
  onSignOut,
20
  style,
@@ -52,6 +50,15 @@ export const DesktopStartMenu = React.forwardRef<HTMLDivElement, DesktopStartMen
52
  </span>
53
  Daily Queue
54
  </button>
 
 
 
 
 
 
 
 
 
55
  <button
56
  onClick={() => onOpenWindow('journey')}
57
  className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
@@ -61,15 +68,6 @@ export const DesktopStartMenu = React.forwardRef<HTMLDivElement, DesktopStartMen
61
  </span>
62
  Journey Path
63
  </button>
64
- <button
65
- onClick={onOpenOnboarding}
66
- className="w-full text-left hover:bg-amber-100 px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
67
- >
68
- <span className="material-symbols-outlined text-lg text-amber-600" style={{ fontVariationSettings: "'FILL' 1" }}>
69
- bolt
70
- </span>
71
- Fast-Track Checklist
72
- </button>
73
  <button
74
  onClick={onTriggerSync}
75
  className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
 
3
  interface DesktopStartMenuProps extends React.HTMLAttributes<HTMLDivElement> {
4
  isOpen: boolean;
5
  onOpenWindow: (id: string) => void;
 
6
  onTriggerSync: () => void;
7
  onSignOut: () => void;
8
  style?: React.CSSProperties;
 
13
  {
14
  isOpen,
15
  onOpenWindow,
 
16
  onTriggerSync,
17
  onSignOut,
18
  style,
 
50
  </span>
51
  Daily Queue
52
  </button>
53
+ <button
54
+ onClick={() => onOpenWindow('cardManager')}
55
+ className="w-full text-left hover:bg-sky-100 px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
56
+ >
57
+ <span className="material-symbols-outlined text-lg text-sky-600" style={{ fontVariationSettings: "'FILL' 1" }}>
58
+ style
59
+ </span>
60
+ Card Manager
61
+ </button>
62
  <button
63
  onClick={() => onOpenWindow('journey')}
64
  className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
 
68
  </span>
69
  Journey Path
70
  </button>
 
 
 
 
 
 
 
 
 
71
  <button
72
  onClick={onTriggerSync}
73
  className="w-full text-left hover:bg-secondary-container px-3 py-1.5 border-2 border-transparent hover:border-ink-black transition-colors cursor-pointer flex items-center gap-2"
algospaced-ui/src/components/desktop/DesktopTaskbar.tsx CHANGED
@@ -28,6 +28,7 @@ interface TaskbarItemDef {
28
 
29
  const TASKBAR_ITEMS: TaskbarItemDef[] = [
30
  { id: 'queue', title: 'Daily Queue', shortTitle: 'Queue', icon: 'view_list' },
 
31
  { id: 'journey', title: 'Journey Path', shortTitle: 'Journey', icon: 'route' },
32
  { id: 'terminal', title: 'Terminal', shortTitle: 'Terminal', icon: 'terminal' },
33
  { id: 'sync', title: 'Drive Sync', shortTitle: 'Sync', icon: 'cloud_sync' },
@@ -50,7 +51,6 @@ interface DesktopTaskbarProps {
50
  onToggleWindow?: (id: WindowId | string) => void;
51
  time: string;
52
  onOpenWindow?: (id: string) => void;
53
- onOpenOnboarding?: () => void;
54
  onTriggerSync?: () => void;
55
  onSignOut?: () => void;
56
  }
@@ -65,7 +65,6 @@ export const DesktopTaskbar: React.FC<DesktopTaskbarProps> = ({
65
  onToggleWindow: propsOnToggleWindow,
66
  time,
67
  onOpenWindow,
68
- onOpenOnboarding,
69
  onTriggerSync,
70
  onSignOut,
71
  }) => {
@@ -181,10 +180,6 @@ export const DesktopTaskbar: React.FC<DesktopTaskbarProps> = ({
181
  if (onOpenWindow) onOpenWindow(id);
182
  else storeOpenWindow(id);
183
  }}
184
- onOpenOnboarding={() => {
185
- handleCloseStart();
186
- onOpenOnboarding?.();
187
- }}
188
  onTriggerSync={() => {
189
  handleCloseStart();
190
  onTriggerSync?.();
 
28
 
29
  const TASKBAR_ITEMS: TaskbarItemDef[] = [
30
  { id: 'queue', title: 'Daily Queue', shortTitle: 'Queue', icon: 'view_list' },
31
+ { id: 'cardManager', title: 'Card Manager', shortTitle: 'Cards', icon: 'style', color: '#0284c7' },
32
  { id: 'journey', title: 'Journey Path', shortTitle: 'Journey', icon: 'route' },
33
  { id: 'terminal', title: 'Terminal', shortTitle: 'Terminal', icon: 'terminal' },
34
  { id: 'sync', title: 'Drive Sync', shortTitle: 'Sync', icon: 'cloud_sync' },
 
51
  onToggleWindow?: (id: WindowId | string) => void;
52
  time: string;
53
  onOpenWindow?: (id: string) => void;
 
54
  onTriggerSync?: () => void;
55
  onSignOut?: () => void;
56
  }
 
65
  onToggleWindow: propsOnToggleWindow,
66
  time,
67
  onOpenWindow,
 
68
  onTriggerSync,
69
  onSignOut,
70
  }) => {
 
180
  if (onOpenWindow) onOpenWindow(id);
181
  else storeOpenWindow(id);
182
  }}
 
 
 
 
183
  onTriggerSync={() => {
184
  handleCloseStart();
185
  onTriggerSync?.();
algospaced-ui/src/components/desktop/DesktopWindowContainer.tsx CHANGED
@@ -14,6 +14,7 @@ const Settings = lazy(() => import('../Settings'));
14
  const CreateProblemForm = lazy(() => import('../CreateProblemForm'));
15
  const PrincessChamber = lazy(() => import('../../features/companion/components/PrincessChamber'));
16
  const GitHubSyncWindow = lazy(() => import('../GitHubSyncWindow'));
 
17
 
18
 
19
  interface DesktopWindowContainerProps {
@@ -31,7 +32,6 @@ interface DesktopWindowContainerProps {
31
  handleSelectProblemForReview?: (problemId: string) => void;
32
  refreshExplorerTrigger?: number;
33
  triggerRefreshExplorer?: () => void;
34
- setIsOnboardingOpen: (open: boolean) => void;
35
  wallpaperUrl: string;
36
  setWallpaperUrl: (url: string) => void;
37
  syncing: boolean;
@@ -54,7 +54,6 @@ export const DesktopWindowContainer: React.FC<DesktopWindowContainerProps> = ({
54
  handleSelectProblemForReview: propsHandleSelectProblem,
55
  refreshExplorerTrigger: propsRefreshExplorerTrigger,
56
  triggerRefreshExplorer: propsTriggerRefreshExplorer,
57
- setIsOnboardingOpen,
58
  wallpaperUrl,
59
  setWallpaperUrl,
60
  syncing,
@@ -91,7 +90,7 @@ export const DesktopWindowContainer: React.FC<DesktopWindowContainerProps> = ({
91
  const handleClearOverride = useCallback(() => setOverrideProblemId(null), [setOverrideProblemId]);
92
  const handleOpenJourney = useCallback(() => openWindow('journey'), [openWindow]);
93
  const handleOpenCreateProblem = useCallback(() => openWindow('createProblem'), [openWindow]);
94
- const handleOpenOnboarding = useCallback(() => setIsOnboardingOpen(true), [setIsOnboardingOpen]);
95
 
96
  return (
97
  <>
@@ -126,7 +125,7 @@ export const DesktopWindowContainer: React.FC<DesktopWindowContainerProps> = ({
126
  onOpenJourney={handleOpenJourney}
127
  onOpenCreateProblem={handleOpenCreateProblem}
128
  onOpenEditProblem={openEditProblem}
129
- onOpenOnboarding={handleOpenOnboarding}
130
  refreshTrigger={refreshExplorerTrigger}
131
  />
132
  </Suspense>
@@ -231,7 +230,7 @@ export const DesktopWindowContainer: React.FC<DesktopWindowContainerProps> = ({
231
  </div>
232
  ) : (
233
  <div className="p-3 bg-white border-[3px] border-ink-black text-xs font-semibold text-ink-black leading-relaxed shadow-[2px_2px_0px_0px_#1E293B]">
234
- {syncResult || 'Idle. Ready to synchronize Leitner box data logs from Sheets drive storage.'}
235
  </div>
236
  )}
237
  </div>
@@ -495,6 +494,44 @@ export const DesktopWindowContainer: React.FC<DesktopWindowContainerProps> = ({
495
  </Suspense>
496
  )}
497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  </>
499
  );
500
  };
 
14
  const CreateProblemForm = lazy(() => import('../CreateProblemForm'));
15
  const PrincessChamber = lazy(() => import('../../features/companion/components/PrincessChamber'));
16
  const GitHubSyncWindow = lazy(() => import('../GitHubSyncWindow'));
17
+ const CardManager = lazy(() => import('../card-manager/CardManager'));
18
 
19
 
20
  interface DesktopWindowContainerProps {
 
32
  handleSelectProblemForReview?: (problemId: string) => void;
33
  refreshExplorerTrigger?: number;
34
  triggerRefreshExplorer?: () => void;
 
35
  wallpaperUrl: string;
36
  setWallpaperUrl: (url: string) => void;
37
  syncing: boolean;
 
54
  handleSelectProblemForReview: propsHandleSelectProblem,
55
  refreshExplorerTrigger: propsRefreshExplorerTrigger,
56
  triggerRefreshExplorer: propsTriggerRefreshExplorer,
 
57
  wallpaperUrl,
58
  setWallpaperUrl,
59
  syncing,
 
90
  const handleClearOverride = useCallback(() => setOverrideProblemId(null), [setOverrideProblemId]);
91
  const handleOpenJourney = useCallback(() => openWindow('journey'), [openWindow]);
92
  const handleOpenCreateProblem = useCallback(() => openWindow('createProblem'), [openWindow]);
93
+ const handleOpenCardManager = useCallback(() => openWindow('cardManager'), [openWindow]);
94
 
95
  return (
96
  <>
 
125
  onOpenJourney={handleOpenJourney}
126
  onOpenCreateProblem={handleOpenCreateProblem}
127
  onOpenEditProblem={openEditProblem}
128
+ onOpenCardManager={handleOpenCardManager}
129
  refreshTrigger={refreshExplorerTrigger}
130
  />
131
  </Suspense>
 
230
  </div>
231
  ) : (
232
  <div className="p-3 bg-white border-[3px] border-ink-black text-xs font-semibold text-ink-black leading-relaxed shadow-[2px_2px_0px_0px_#1E293B]">
233
+ {syncResult || 'Idle. Ready to synchronize review data logs from Sheets drive storage.'}
234
  </div>
235
  )}
236
  </div>
 
494
  </Suspense>
495
  )}
496
 
497
+ {/* 10. Anki Card Manager Window */}
498
+ {windows.cardManager?.isOpen && (
499
+ <WindowShell
500
+ id="cardManager"
501
+ title="FSRS Card Manager"
502
+ icon="style"
503
+ isOpen={windows.cardManager.isOpen}
504
+ isMinimized={windows.cardManager.isMinimized}
505
+ onClose={() => closeWindow('cardManager')}
506
+ onMinimize={() => minimizeWindow('cardManager')}
507
+ activeWindow={activeWindow}
508
+ setActiveWindow={setActiveWindow}
509
+ defaultWidth="1020px"
510
+ defaultHeight="700px"
511
+ minWidth={520}
512
+ minHeight={420}
513
+ titleBarColor="#0284c7"
514
+ isMobile={isMobile}
515
+ >
516
+ <Suspense
517
+ fallback={
518
+ <div className="p-6 font-arcade text-xs text-trash-gray uppercase animate-pulse">
519
+ Loading CardManager.exe...
520
+ </div>
521
+ }
522
+ >
523
+ <CardManager
524
+ onOpenQueue={() => openWindow('queue')}
525
+ onOpenCreateProblem={() => openWindow('createProblem')}
526
+ onOpenEditProblem={openEditProblem}
527
+ onSelectProblemForReview={handleSelectProblemForReview}
528
+ refreshTrigger={refreshExplorerTrigger}
529
+ onRefreshExplorer={triggerRefreshExplorer}
530
+ />
531
+ </Suspense>
532
+ </WindowShell>
533
+ )}
534
+
535
  </>
536
  );
537
  };
algospaced-ui/src/components/desktop/MobileMetroScreen.tsx CHANGED
@@ -74,6 +74,19 @@ export const MobileMetroScreen: React.FC<MobileMetroScreenProps> = ({
74
  </span>
75
  </button>
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  {/* Journey Path Tile */}
78
  <button
79
  onClick={() => onToggleWindow('journey')}
 
74
  </span>
75
  </button>
76
 
77
+ {/* Card Manager Tile */}
78
+ <button
79
+ onClick={() => onToggleWindow('cardManager')}
80
+ className="bg-[#0284c7] text-white border-[3px] border-ink-black p-4 flex flex-col justify-between aspect-square gadget-shadow active:translate-y-1 active:translate-x-1 active:shadow-none select-none text-left cursor-pointer transition-all"
81
+ >
82
+ <span className="material-symbols-outlined text-3xl align-top" style={{ fontVariationSettings: "'FILL' 1" }}>
83
+ style
84
+ </span>
85
+ <span className="font-arcade text-[8px] font-bold tracking-tight uppercase leading-tight">
86
+ CARD<br />MANAGER
87
+ </span>
88
+ </button>
89
+
90
  {/* Journey Path Tile */}
91
  <button
92
  onClick={() => onToggleWindow('journey')}
algospaced-ui/src/components/map/CurvyPathAndNodes.tsx CHANGED
@@ -1,3 +1,4 @@
 
1
  import type { MapNode, MapTheme } from '../../types/mapTypes';
2
  import { buildPathString, buildSubPathString } from '../../data/mapData';
3
 
@@ -22,73 +23,170 @@ export const CurvyPathAndNodes: React.FC<CurvyPathAndNodesProps> = ({
22
  hoveredNodeIndex,
23
  setHoveredNodeIndex,
24
  }) => {
 
 
25
  // Find highest completed index in sequence to light the continuous trail
26
  const highestCompletedIdx = nodes.reduce((maxIdx, node, idx) => {
27
  return completions.has(node.id) ? Math.max(maxIdx, idx) : maxIdx;
28
  }, -1);
29
 
30
  const litIndex = Math.max(activeNodeIndex, highestCompletedIdx);
31
-
32
  const fullPathD = buildPathString(nodes);
33
  const litPathD = buildSubPathString(nodes, litIndex);
34
- const activeNode = activeNodeIndex >= 0 && activeNodeIndex < nodes.length ? nodes[activeNodeIndex] : null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  return (
37
  <g id="curvy-path-nodes-layer">
38
- {/* 1. Base Unlit Pencil Path (Sketchy Hand-Drawn Dotted Trail) */}
39
- <g id="unlit-path">
40
  <path
41
  d={fullPathD}
42
  fill="none"
43
  stroke={theme.pencilShade}
44
- strokeWidth="3.2"
45
- strokeDasharray="6 7"
46
  strokeLinecap="round"
47
  strokeLinejoin="round"
48
- opacity={0.65}
49
  />
50
  <path
51
  d={fullPathD}
52
  fill="none"
53
  stroke={theme.pencilColor}
54
  strokeWidth="2.2"
55
- strokeDasharray="5 6"
56
  strokeLinecap="round"
57
  strokeLinejoin="round"
58
  opacity={0.85}
59
  />
60
  </g>
61
 
62
- {/* 2. Illuminated Lit-Up Path (Glowing Golden Trail) */}
63
  {litIndex > 0 && litPathD && (
64
  <g id="lit-path">
 
65
  <path
66
  d={litPathD}
67
  fill="none"
68
- stroke="#f59e0b"
69
- strokeWidth="14"
70
  strokeLinecap="round"
71
  strokeLinejoin="round"
72
- opacity={0.35}
73
  filter="url(#goldenGlow)"
74
  />
 
 
 
 
 
 
 
 
 
 
 
75
  <path
76
  d={litPathD}
77
  fill="none"
78
  stroke="url(#goldPathGradient)"
79
- strokeWidth="6"
80
  strokeLinecap="round"
81
  strokeLinejoin="round"
82
- filter="url(#goldenGlow)"
83
  />
 
84
  <path
85
  d={litPathD}
86
  fill="none"
87
- stroke="#fffbeb"
88
- strokeWidth="2.4"
 
89
  strokeLinecap="round"
90
  strokeLinejoin="round"
91
- opacity={0.95}
92
  />
93
  </g>
94
  )}
@@ -100,7 +198,8 @@ export const CurvyPathAndNodes: React.FC<CurvyPathAndNodesProps> = ({
100
  const isLit = idx <= litIndex || isCompleted;
101
  const isActive = idx === activeNodeIndex;
102
  const isHovered = hoveredNodeIndex === idx;
103
- const isMilestone = (idx + 1) % 25 === 0 || idx === 0 || idx === nodes.length - 1;
 
104
 
105
  return (
106
  <g
@@ -118,112 +217,154 @@ export const CurvyPathAndNodes: React.FC<CurvyPathAndNodesProps> = ({
118
  {/* Invisible larger hit target */}
119
  <circle cx="0" cy="0" r="18" fill="transparent" />
120
 
121
- {/* UNLIT NODE STATE */}
 
 
 
122
  {!isLit && !isCompleted && (
123
  <g>
124
  <circle
125
- cx="1"
126
- cy="1.5"
127
- r={isMilestone ? 6.5 : 4.5}
128
  fill={theme.pencilShade}
129
- opacity={0.4}
130
  />
131
  <circle
132
  cx="0"
133
  cy="0"
134
- r={isMilestone ? 6 : 4}
135
- fill={theme.id === 'parchment' ? '#f0e5ce' : '#28221b'}
136
  stroke={theme.pencilColor}
137
- strokeWidth={isMilestone ? 2 : 1.4}
138
  />
139
- {isMilestone && (
140
- <circle cx="0" cy="0" r="2" fill={theme.pencilColor} />
 
 
 
 
 
 
 
 
141
  )}
142
  </g>
143
  )}
144
 
145
- {/* LIT / COMPLETED NODE STATE */}
146
  {isLit && !isActive && (
147
  <g filter="url(#nodeGlow)">
 
148
  <circle
149
  cx="0"
150
  cy="0"
151
- r={isMilestone ? 10 : 7}
152
- fill={isCompleted ? '#10b981' : '#f59e0b'}
153
- opacity={0.4}
 
154
  />
 
155
  <circle
156
  cx="0"
157
  cy="0"
158
- r={isMilestone ? 7 : 5}
159
- fill={isCompleted ? '#34d399' : '#fbbf24'}
160
- stroke="#fffbeb"
161
- strokeWidth="1.6"
 
162
  />
163
- <circle cx="0" cy="0" r={isMilestone ? 2.5 : 1.8} fill="#ffffff" />
 
 
 
 
 
 
 
 
164
  </g>
165
  )}
166
 
167
- {/* ACTIVE CURRENT NODE STATE */}
168
  {isActive && (
169
  <g id="active-node-beacon">
170
  <circle
171
  cx="0"
172
  cy="0"
173
- r="12"
174
  fill="none"
175
- stroke="#f59e0b"
176
- strokeWidth="2.5"
177
  className="beacon-wave"
178
  />
179
  <circle
180
  cx="0"
181
  cy="0"
182
- r="12"
183
  fill="none"
184
- stroke="#fbbf24"
185
- strokeWidth="2"
186
  className="beacon-wave-delayed"
187
  />
 
188
 
189
- <circle cx="0" cy="0" r="20" fill="url(#beaconGlow)" />
190
-
191
  <circle
192
  cx="0"
193
  cy="0"
194
  r="9.5"
195
- fill={isCompleted ? '#10b981' : '#f59e0b'}
196
- stroke="#ffffff"
197
- strokeWidth="2.4"
198
- filter="url(#goldenGlow)"
 
 
 
 
 
 
 
 
 
 
 
 
199
  />
200
- <circle cx="0" cy="0" r="4.5" fill="#ffffff" />
201
 
202
- {/* Floating Explorer Waypoint Marker Flag */}
203
- <g transform="translate(0, -18)">
204
- <line x1="0" y1="0" x2="0" y2="10" stroke="#f59e0b" strokeWidth="2.2" />
205
- <polygon
206
- points="0,-10 7,-4 0,2 -7,-4"
207
- fill={isCompleted ? '#10b981' : '#ef4444'}
208
- stroke="#ffffff"
209
- strokeWidth="1.5"
210
- filter="url(#nodeGlow)"
 
 
 
 
 
 
 
 
211
  />
212
- <circle cx="0" cy="-4" r="2" fill="#ffffff" />
213
  </g>
214
  </g>
215
  )}
216
 
217
- {/* Hover highlight ring */}
218
  {isHovered && !isActive && (
219
  <circle
220
  cx="0"
221
  cy="0"
222
  r="13"
223
  fill="none"
224
- stroke="#f59e0b"
225
- strokeWidth="2"
226
- strokeDasharray="3 3"
227
  />
228
  )}
229
 
@@ -231,13 +372,22 @@ export const CurvyPathAndNodes: React.FC<CurvyPathAndNodesProps> = ({
231
  {(showNodeNumbers || isMilestone || isHovered) && (
232
  <text
233
  x="0"
234
- y={isMilestone ? -13 : -10}
235
  textAnchor="middle"
236
- fill={isCompleted ? '#059669' : isLit ? '#d97706' : theme.pencilColor}
237
- className={`font-pencil font-bold select-none ${
238
- isMilestone ? 'text-[13px]' : 'text-[10px]'
239
- }`}
240
- opacity={isLit ? 1 : 0.75}
 
 
 
 
 
 
 
 
 
241
  >
242
  {node.id < 0 ? `P${idx + 1}` : node.id}
243
  </text>
@@ -247,49 +397,62 @@ export const CurvyPathAndNodes: React.FC<CurvyPathAndNodesProps> = ({
247
  })}
248
  </g>
249
 
250
- {/* 4. Active Node Tooltip Banner on Canvas */}
251
  {activeNode && (
252
  <g
253
- transform={`translate(${activeNode.x}, ${activeNode.y - 42})`}
254
  className="pointer-events-none select-none transition-all duration-300"
 
255
  >
256
- <rect
257
- x="-80"
258
- y="-24"
259
- width="160"
260
- height="32"
261
- rx="6"
262
- fill={theme.id === 'parchment' ? '#2a221b' : '#14120f'}
263
- stroke="#f59e0b"
 
 
264
  strokeWidth="1.8"
265
- filter="url(#nodeGlow)"
 
 
 
 
 
 
 
266
  />
 
267
  <polygon
268
- points="-6,8 6,8 0,14"
269
- fill={theme.id === 'parchment' ? '#2a221b' : '#14120f'}
270
- stroke="#f59e0b"
271
- strokeWidth="1.8"
272
  />
273
  <text
274
  x="0"
275
- y="-8"
276
  textAnchor="middle"
277
- fill="#fef08a"
278
- className="font-cinzel font-bold text-[12px] tracking-wider"
279
  >
280
- NODE {activeNode.sequenceIndex + 1} / {nodes.length}
281
  </text>
282
  <text
283
  x="0"
284
  y="4"
285
  textAnchor="middle"
286
- fill="#ffffff"
287
- className="font-garamond italic font-semibold text-[11px]"
288
  >
289
- {activeNode.name.length > 20 ? activeNode.name.substring(0, 18) + '…' : activeNode.name}
 
 
290
  </text>
291
  </g>
292
  )}
293
  </g>
294
  );
295
- };
 
1
+ import React from 'react';
2
  import type { MapNode, MapTheme } from '../../types/mapTypes';
3
  import { buildPathString, buildSubPathString } from '../../data/mapData';
4
 
 
23
  hoveredNodeIndex,
24
  setHoveredNodeIndex,
25
  }) => {
26
+ const isDark = theme.id !== 'parchment';
27
+
28
  // Find highest completed index in sequence to light the continuous trail
29
  const highestCompletedIdx = nodes.reduce((maxIdx, node, idx) => {
30
  return completions.has(node.id) ? Math.max(maxIdx, idx) : maxIdx;
31
  }, -1);
32
 
33
  const litIndex = Math.max(activeNodeIndex, highestCompletedIdx);
 
34
  const fullPathD = buildPathString(nodes);
35
  const litPathD = buildSubPathString(nodes, litIndex);
36
+
37
+ const activeNode =
38
+ activeNodeIndex >= 0 && activeNodeIndex < nodes.length ? nodes[activeNodeIndex] : null;
39
+
40
+ // Render hand-drawn mini-landmarks at milestone waypoints (every 25th node)
41
+ const renderMilestoneLandmark = (idx: number, isLit: boolean, isCompleted: boolean) => {
42
+ // Do not draw a mini-landmark on the final node since the Huge Stone Tower is already there
43
+ if (idx === nodes.length - 1) return null;
44
+
45
+ const stroke = theme.pencilColor;
46
+ const fillTone = isCompleted
47
+ ? '#b91c1c'
48
+ : isLit
49
+ ? '#d97706'
50
+ : isDark
51
+ ? '#2c241b'
52
+ : '#dfd1b4';
53
+
54
+ if (idx === 0) {
55
+ // Waypoint 1: Explorer's Basecamp Tent
56
+ return (
57
+ <g transform="translate(0, -10)" pointerEvents="none">
58
+ <path
59
+ d="M -11,4 L 0,-11 L 11,4 Z"
60
+ fill={fillTone}
61
+ stroke={stroke}
62
+ strokeWidth="1.5"
63
+ strokeLinejoin="round"
64
+ />
65
+ <path d="M -3,4 L 0,-3 L 3,4 Z" fill={stroke} />
66
+ <line x1="0" y1="-11" x2="0" y2="-17" stroke={stroke} strokeWidth="1.3" />
67
+ <polygon points="0,-17 7,-14 0,-11" fill={isCompleted ? '#991b1b' : '#d97706'} />
68
+ </g>
69
+ );
70
+ }
71
+
72
+ const milestoneTier = Math.round((idx + 1) / 25) % 3;
73
+ if (milestoneTier === 1) {
74
+ // Node 25, 100...: Wayfarer's Campfire
75
+ return (
76
+ <g transform="translate(0, -9)" pointerEvents="none">
77
+ <line x1="-8" y1="3" x2="8" y2="-1" stroke={stroke} strokeWidth="2" strokeLinecap="round" />
78
+ <line x1="-8" y1="-1" x2="8" y2="3" stroke={stroke} strokeWidth="2" strokeLinecap="round" />
79
+ <path
80
+ d="M -5,0 C -6,-7 -1,-9 0,-14 C 2,-9 6,-7 5,0 Z"
81
+ fill={isLit || isCompleted ? '#ea580c' : fillTone}
82
+ stroke={stroke}
83
+ strokeWidth="1.2"
84
+ />
85
+ </g>
86
+ );
87
+ } else if (milestoneTier === 2) {
88
+ // Node 50, 125...: Stone Watchtower
89
+ return (
90
+ <g transform="translate(0, -9)" pointerEvents="none">
91
+ <path
92
+ d="M -7,3 L -5,-12 L 5,-12 L 7,3 Z"
93
+ fill={fillTone}
94
+ stroke={stroke}
95
+ strokeWidth="1.5"
96
+ />
97
+ <path
98
+ d="M -7,-12 L -7,-16 L -3,-16 L -3,-12 L 3,-12 L 3,-16 L 7,-16 L 7,-12 Z"
99
+ fill={fillTone}
100
+ stroke={stroke}
101
+ strokeWidth="1.3"
102
+ />
103
+ </g>
104
+ );
105
+ } else {
106
+ // Node 75, 150...: Mountain Arch Gatehouse
107
+ return (
108
+ <g transform="translate(0, -9)" pointerEvents="none">
109
+ <path
110
+ d="M -9,3 L -9,-12 L 9,-12 L 9,3 L 4,3 L 4,-5 C 4,-9 -4,-9 -4,-5 L -4,3 Z"
111
+ fill={fillTone}
112
+ stroke={stroke}
113
+ strokeWidth="1.5"
114
+ strokeLinejoin="round"
115
+ />
116
+ </g>
117
+ );
118
+ }
119
+ };
120
 
121
  return (
122
  <g id="curvy-path-nodes-layer">
123
+ {/* 1. Base Unlit Surveyor's Trail (Double-Inked Cartographic Footpath) */}
124
+ <g id="unlit-path" filter="url(#quillInk)">
125
  <path
126
  d={fullPathD}
127
  fill="none"
128
  stroke={theme.pencilShade}
129
+ strokeWidth="4.2"
130
+ strokeDasharray="2 8"
131
  strokeLinecap="round"
132
  strokeLinejoin="round"
133
+ opacity={0.45}
134
  />
135
  <path
136
  d={fullPathD}
137
  fill="none"
138
  stroke={theme.pencilColor}
139
  strokeWidth="2.2"
140
+ strokeDasharray="7 6"
141
  strokeLinecap="round"
142
  strokeLinejoin="round"
143
  opacity={0.85}
144
  />
145
  </g>
146
 
147
+ {/* 2. Illuminated Lit-Up Path (Sepia-Cased Alchemical Gold Leaf Trail) */}
148
  {litIndex > 0 && litPathD && (
149
  <g id="lit-path">
150
+ {/* Warm Alchemical Aura */}
151
  <path
152
  d={litPathD}
153
  fill="none"
154
+ stroke="#d97706"
155
+ strokeWidth="10"
156
  strokeLinecap="round"
157
  strokeLinejoin="round"
158
+ opacity={0.28}
159
  filter="url(#goldenGlow)"
160
  />
161
+ {/* Dark Sepia Ink Casing so the gold leaf pops on light parchment */}
162
+ <path
163
+ d={litPathD}
164
+ fill="none"
165
+ stroke={theme.pencilColor}
166
+ strokeWidth="6.8"
167
+ strokeLinecap="round"
168
+ strokeLinejoin="round"
169
+ opacity={0.85}
170
+ />
171
+ {/* Burnished Gold Leaf Core */}
172
  <path
173
  d={litPathD}
174
  fill="none"
175
  stroke="url(#goldPathGradient)"
176
+ strokeWidth="4.2"
177
  strokeLinecap="round"
178
  strokeLinejoin="round"
 
179
  />
180
+ {/* Fine Center Ink Highlight */}
181
  <path
182
  d={litPathD}
183
  fill="none"
184
+ stroke="#fef3c7"
185
+ strokeWidth="1.3"
186
+ strokeDasharray="12 6"
187
  strokeLinecap="round"
188
  strokeLinejoin="round"
189
+ opacity={0.8}
190
  />
191
  </g>
192
  )}
 
198
  const isLit = idx <= litIndex || isCompleted;
199
  const isActive = idx === activeNodeIndex;
200
  const isHovered = hoveredNodeIndex === idx;
201
+ const isMilestone =
202
+ (idx + 1) % 25 === 0 || idx === 0 || idx === nodes.length - 1;
203
 
204
  return (
205
  <g
 
217
  {/* Invisible larger hit target */}
218
  <circle cx="0" cy="0" r="18" fill="transparent" />
219
 
220
+ {/* Milestone Mini-Landmark Illustration */}
221
+ {isMilestone && renderMilestoneLandmark(idx, isLit, isCompleted)}
222
+
223
+ {/* UNLIT NODE STATE (Hand-Inked Cartographic Ring / X-Mark) */}
224
  {!isLit && !isCompleted && (
225
  <g>
226
  <circle
227
+ cx="0.8"
228
+ cy="1.2"
229
+ r={isMilestone ? 7.5 : 4.5}
230
  fill={theme.pencilShade}
231
+ opacity={0.35}
232
  />
233
  <circle
234
  cx="0"
235
  cy="0"
236
+ r={isMilestone ? 7 : 4.2}
237
+ fill={isDark ? '#28221b' : '#efe3c9'}
238
  stroke={theme.pencilColor}
239
+ strokeWidth={isMilestone ? 2 : 1.5}
240
  />
241
+ {isMilestone ? (
242
+ /* Cartographic X-Mark inside Milestone Ring */
243
+ <path
244
+ d="M -3,-3 L 3,3 M -3,3 L 3,-3"
245
+ stroke={theme.pencilColor}
246
+ strokeWidth="1.6"
247
+ strokeLinecap="round"
248
+ />
249
+ ) : (
250
+ <circle cx="0" cy="0" r="1.3" fill={theme.pencilColor} />
251
  )}
252
  </g>
253
  )}
254
 
255
+ {/* LIT / COMPLETED NODE STATE (Crimson Wax Seal or Brass Astrolabe) */}
256
  {isLit && !isActive && (
257
  <g filter="url(#nodeGlow)">
258
+ {/* Outer Stamped Rim */}
259
  <circle
260
  cx="0"
261
  cy="0"
262
+ r={isMilestone ? 9 : 6}
263
+ fill={isCompleted ? 'url(#waxSealGradient)' : 'url(#brassNodeGradient)'}
264
+ stroke={theme.pencilColor}
265
+ strokeWidth="1.5"
266
  />
267
+ {/* Inner Embossed Wax Ring */}
268
  <circle
269
  cx="0"
270
  cy="0"
271
+ r={isMilestone ? 6.2 : 3.8}
272
+ fill="none"
273
+ stroke="#fef3c7"
274
+ strokeWidth="0.9"
275
+ opacity={0.75}
276
  />
277
+ {/* Center Stamped Emblem */}
278
+ {isMilestone ? (
279
+ <polygon
280
+ points="0,-4.5 1.3,-1.3 4.5,0 1.3,1.3 0,4.5 -1.3,1.3 -4.5,0 -1.3,-1.3"
281
+ fill="#fef3c7"
282
+ />
283
+ ) : (
284
+ <circle cx="0" cy="0" r="1.6" fill="#fef3c7" />
285
+ )}
286
  </g>
287
  )}
288
 
289
+ {/* ACTIVE CURRENT NODE STATE (Surveyor's Compass Beacon & Pennant) */}
290
  {isActive && (
291
  <g id="active-node-beacon">
292
  <circle
293
  cx="0"
294
  cy="0"
295
+ r="13"
296
  fill="none"
297
+ stroke="#b45309"
298
+ strokeWidth="2"
299
  className="beacon-wave"
300
  />
301
  <circle
302
  cx="0"
303
  cy="0"
304
+ r="13"
305
  fill="none"
306
+ stroke="#d97706"
307
+ strokeWidth="1.5"
308
  className="beacon-wave-delayed"
309
  />
310
+ <circle cx="0" cy="0" r="22" fill="url(#beaconGlow)" />
311
 
312
+ {/* Outer Compass Ring */}
 
313
  <circle
314
  cx="0"
315
  cy="0"
316
  r="9.5"
317
+ fill={isCompleted ? 'url(#waxSealGradient)' : 'url(#brassNodeGradient)'}
318
+ stroke={theme.pencilColor}
319
+ strokeWidth="2.2"
320
+ filter="url(#nodeGlow)"
321
+ />
322
+ <circle
323
+ cx="0"
324
+ cy="0"
325
+ r="6.5"
326
+ fill="none"
327
+ stroke="#fef3c7"
328
+ strokeWidth="1"
329
+ />
330
+ <polygon
331
+ points="0,-4.5 1.4,-1.4 4.5,0 1.4,1.4 0,4.5 -1.4,1.4 -4.5,0 -1.4,-1.4"
332
+ fill="#fef3c7"
333
  />
 
334
 
335
+ {/* Explorer's Heraldic Pennant Flag */}
336
+ <g transform="translate(0, -19)" filter="url(#nodeGlow)">
337
+ <line
338
+ x1="0"
339
+ y1="-12"
340
+ x2="0"
341
+ y2="11"
342
+ stroke={theme.pencilColor}
343
+ strokeWidth="2.2"
344
+ strokeLinecap="round"
345
+ />
346
+ <path
347
+ d="M 0,-12 L 15,-7 L 11,-3 L 15,1 L 0,-2 Z"
348
+ fill={isCompleted ? '#991b1b' : '#b45309'}
349
+ stroke="#fef3c7"
350
+ strokeWidth="1.2"
351
+ strokeLinejoin="round"
352
  />
353
+ <circle cx="0" cy="-13" r="2" fill="#fbbf24" stroke={theme.pencilColor} strokeWidth="0.9" />
354
  </g>
355
  </g>
356
  )}
357
 
358
+ {/* Hover Ink Caliper Ring */}
359
  {isHovered && !isActive && (
360
  <circle
361
  cx="0"
362
  cy="0"
363
  r="13"
364
  fill="none"
365
+ stroke={isCompleted ? '#991b1b' : '#b45309'}
366
+ strokeWidth="1.8"
367
+ strokeDasharray="4 3"
368
  />
369
  )}
370
 
 
372
  {(showNodeNumbers || isMilestone || isHovered) && (
373
  <text
374
  x="0"
375
+ y={isMilestone ? 19 : -10}
376
  textAnchor="middle"
377
+ fill={
378
+ isCompleted
379
+ ? isDark
380
+ ? '#fca5a5'
381
+ : '#7f1d1d'
382
+ : isLit
383
+ ? isDark
384
+ ? '#fcd34d'
385
+ : '#92400e'
386
+ : theme.pencilColor
387
+ }
388
+ className={`font-pencil font-bold select-none ${isMilestone ? 'text-[12px]' : 'text-[10px]'
389
+ }`}
390
+ opacity={isLit ? 1 : 0.78}
391
  >
392
  {node.id < 0 ? `P${idx + 1}` : node.id}
393
  </text>
 
397
  })}
398
  </g>
399
 
400
+ {/* 4. Active Node Tattered Scroll Tooltip Banner on Canvas */}
401
  {activeNode && (
402
  <g
403
+ transform={`translate(${activeNode.x}, ${activeNode.y - 46})`}
404
  className="pointer-events-none select-none transition-all duration-300"
405
+ filter="url(#nodeGlow)"
406
  >
407
+ {/* Notched Parchment Scroll Body */}
408
+ <path
409
+ d="M -88,-24
410
+ Q 0,-28 88,-24
411
+ L 81,-7
412
+ L 88,10
413
+ Q 0,14 -88,10
414
+ L -81,-7 Z"
415
+ fill={isDark ? '#221b14' : '#f4e8cf'}
416
+ stroke={theme.pencilColor}
417
  strokeWidth="1.8"
418
+ strokeLinejoin="round"
419
+ />
420
+ {/* Inner Scroll Rule */}
421
+ <path
422
+ d="M -78,-20 Q 0,-24 78,-20 M -78,6 Q 0,10 78,6"
423
+ fill="none"
424
+ stroke={theme.pencilShade}
425
+ strokeWidth="0.8"
426
  />
427
+ {/* Pointer Tail */}
428
  <polygon
429
+ points="-6,10 6,10 0,17"
430
+ fill={isDark ? '#221b14' : '#f4e8cf'}
431
+ stroke={theme.pencilColor}
432
+ strokeWidth="1.6"
433
  />
434
  <text
435
  x="0"
436
+ y="-9"
437
  textAnchor="middle"
438
+ fill={isDark ? '#fbbf24' : '#7c2d12'}
439
+ className="font-cinzel font-bold text-[11px] tracking-wider"
440
  >
441
+ WAYPOINT {activeNode.sequenceIndex + 1} OF {nodes.length}
442
  </text>
443
  <text
444
  x="0"
445
  y="4"
446
  textAnchor="middle"
447
+ fill={isDark ? '#f4ebd9' : '#2c1d11'}
448
+ className="font-garamond italic font-bold text-[12px]"
449
  >
450
+ {activeNode.name.length > 22
451
+ ? activeNode.name.substring(0, 20) + '…'
452
+ : activeNode.name}
453
  </text>
454
  </g>
455
  )}
456
  </g>
457
  );
458
+ };
algospaced-ui/src/components/map/MapBorderAndFilters.tsx CHANGED
@@ -13,76 +13,208 @@ export const MapBorderAndFilters: React.FC<MapBorderAndFiltersProps> = ({
13
  }) => {
14
  const isDark = theme.id !== 'parchment';
15
  const strokeColor = theme.pencilColor;
 
16
  const tickFill = isDark ? '#2e261f' : '#3d2f21';
17
 
18
  return (
19
  <>
20
- {/* 1. SVG Definitions for Filters, Glows & Gradients */}
21
  <defs>
22
- {/* Radiant Golden Glow for Illuminated Path */}
23
- <filter id="goldenGlow" x="-50%" y="-50%" width="200%" height="200%">
24
- <feGaussianBlur in="SourceGraphic" stdDeviation="4" result="blur1" />
25
- <feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur2" />
26
- <feGaussianBlur in="SourceGraphic" stdDeviation="22" result="blur3" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  <feColorMatrix
28
- in="blur3"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  type="matrix"
30
  values="
31
- 1 0 0 0 1
32
- 0 0.8 0 0 0.7
33
- 0 0 0.2 0 0
34
- 0 0 0 1.8 0"
35
- result="coloredBlur"
36
  />
37
  <feMerge>
38
- <feMergeNode in="coloredBlur" />
39
- <feMergeNode in="blur2" />
40
  <feMergeNode in="blur1" />
41
  <feMergeNode in="SourceGraphic" />
42
  </feMerge>
43
  </filter>
44
 
45
- {/* Soft Node Glow */}
46
- <filter id="nodeGlow" x="-100%" y="-100%" width="300%" height="300%">
47
- <feGaussianBlur in="SourceGraphic" stdDeviation="6" result="blur" />
48
- <feMerge>
49
- <feMergeNode in="blur" />
50
- <feMergeNode in="SourceGraphic" />
51
- </feMerge>
 
 
52
  </filter>
53
 
54
- {/* Linear Gradient for Path Illumination */}
55
  <linearGradient id="goldPathGradient" x1="0%" y1="0%" x2="100%" y2="100%">
56
- <stop offset="0%" stopColor="#f59e0b" stopOpacity="0.95" />
57
- <stop offset="50%" stopColor="#fbbf24" stopOpacity="1" />
58
- <stop offset="100%" stopColor="#fef08a" stopOpacity="1" />
59
  </linearGradient>
60
 
61
- {/* Beacon Radial Gradient */}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  <radialGradient id="beaconGlow" cx="50%" cy="50%" r="50%">
63
- <stop offset="0%" stopColor="#fffbeb" stopOpacity="1" />
64
- <stop offset="40%" stopColor="#f59e0b" stopOpacity="0.8" />
65
- <stop offset="75%" stopColor="#d97706" stopOpacity="0.3" />
66
- <stop offset="100%" stopColor="#b45309" stopOpacity="0" />
 
 
 
 
 
 
 
67
  </radialGradient>
68
  </defs>
69
 
70
- {/* 2. Optional Grid Lines */}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  {showGrid && (
72
- <g id="grid-lines" stroke={strokeColor} strokeWidth="0.6" strokeDasharray="3 7" opacity={isDark ? 0.15 : 0.22}>
 
 
 
 
 
 
 
73
  {Array.from({ length: 13 }).map((_, i) => {
74
  const x = (i + 1) * 200;
75
- return <line key={`gx-${i}`} x1={x} y1="0" x2={x} y2={MAP_HEIGHT} />;
76
  })}
77
  {Array.from({ length: 7 }).map((_, i) => {
78
  const y = (i + 1) * 200;
79
- return <line key={`gy-${i}`} x1="0" y1={y} x2={MAP_WIDTH} y2={y} />;
80
  })}
81
  </g>
82
  )}
83
 
84
- {/* 3. Antique Map Border */}
85
- <g id="map-border" pointerEvents="none">
86
  <rect
87
  x="12"
88
  y="12"
@@ -90,7 +222,7 @@ export const MapBorderAndFilters: React.FC<MapBorderAndFiltersProps> = ({
90
  height={MAP_HEIGHT - 24}
91
  fill="none"
92
  stroke={strokeColor}
93
- strokeWidth="6"
94
  />
95
 
96
  <rect
@@ -98,7 +230,7 @@ export const MapBorderAndFilters: React.FC<MapBorderAndFiltersProps> = ({
98
  y="20"
99
  width={MAP_WIDTH - 40}
100
  height="14"
101
- fill={isDark ? '#231e17' : '#eee2ca'}
102
  stroke={strokeColor}
103
  strokeWidth="1.5"
104
  />
@@ -107,17 +239,16 @@ export const MapBorderAndFilters: React.FC<MapBorderAndFiltersProps> = ({
107
  y={MAP_HEIGHT - 34}
108
  width={MAP_WIDTH - 40}
109
  height="14"
110
- fill={isDark ? '#231e17' : '#eee2ca'}
111
  stroke={strokeColor}
112
  strokeWidth="1.5"
113
  />
114
-
115
  <rect
116
  x="20"
117
  y="20"
118
  width="14"
119
  height={MAP_HEIGHT - 40}
120
- fill={isDark ? '#231e17' : '#eee2ca'}
121
  stroke={strokeColor}
122
  strokeWidth="1.5"
123
  />
@@ -126,34 +257,36 @@ export const MapBorderAndFilters: React.FC<MapBorderAndFiltersProps> = ({
126
  y="20"
127
  width="14"
128
  height={MAP_HEIGHT - 40}
129
- fill={isDark ? '#231e17' : '#eee2ca'}
130
  stroke={strokeColor}
131
  strokeWidth="1.5"
132
  />
133
 
 
134
  {Array.from({ length: 32 }).map((_, i) => {
135
  if (i % 2 === 0) return null;
136
  const segW = (MAP_WIDTH - 40) / 32;
137
  return (
138
  <React.Fragment key={`ruler-h-${i}`}>
139
- <rect
140
- x={20 + i * segW}
141
- y="20"
142
- width={segW}
143
- height="14"
144
- fill={tickFill}
145
- />
146
- <rect
147
- x={20 + i * segW}
148
- y={MAP_HEIGHT - 34}
149
- width={segW}
150
- height="14"
151
- fill={tickFill}
152
- />
153
  </React.Fragment>
154
  );
155
  })}
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  <rect
158
  x="38"
159
  y="38"
@@ -161,40 +294,62 @@ export const MapBorderAndFilters: React.FC<MapBorderAndFiltersProps> = ({
161
  height={MAP_HEIGHT - 76}
162
  fill="none"
163
  stroke={strokeColor}
164
- strokeWidth="2"
 
 
 
 
 
 
 
 
 
165
  />
166
 
167
- <g transform="translate(38, 38)" stroke={strokeColor} strokeWidth="1.6" fill="none">
168
- <path d="M 0,0 L 45,0 C 25,25 25,25 0,45 Z" fill={isDark ? '#2f271f' : '#e6d7bc'} />
169
- <circle cx="20" cy="20" r="4" fill={strokeColor} />
170
- <line x1="0" y1="0" x2="40" y2="40" />
171
- </g>
172
- <g transform={`translate(${MAP_WIDTH - 38}, 38)`} stroke={strokeColor} strokeWidth="1.6" fill="none">
173
- <path d="M 0,0 L -45,0 C -25,25 -25,25 0,45 Z" fill={isDark ? '#2f271f' : '#e6d7bc'} />
174
- <circle cx="-20" cy="20" r="4" fill={strokeColor} />
175
- <line x1="0" y1="0" x2="-40" y2="40" />
176
- </g>
177
- <g transform={`translate(38, ${MAP_HEIGHT - 38})`} stroke={strokeColor} strokeWidth="1.6" fill="none">
178
- <path d="M 0,0 L 45,0 C 25,-25 25,-25 0,-45 Z" fill={isDark ? '#2f271f' : '#e6d7bc'} />
179
- <circle cx="20" cy="-20" r="4" fill={strokeColor} />
180
- <line x1="0" y1="0" x2="40" y2="-40" />
181
- </g>
182
- <g transform={`translate(${MAP_WIDTH - 38}, ${MAP_HEIGHT - 38})`} stroke={strokeColor} strokeWidth="1.6" fill="none">
183
- <path d="M 0,0 L -45,0 C -25,-25 -25,-25 0,-45 Z" fill={isDark ? '#2f271f' : '#e6d7bc'} />
184
- <circle cx="-20" cy="-20" r="4" fill={strokeColor} />
185
- <line x1="0" y1="0" x2="-40" y2="-40" />
186
- </g>
 
187
 
188
- <g transform="translate(480, 1445)" stroke={strokeColor}>
189
- <rect x="0" y="0" width="180" height="8" fill="none" strokeWidth="1.2" />
 
 
 
190
  <rect x="0" y="0" width="45" height="8" fill={strokeColor} />
191
  <rect x="90" y="0" width="45" height="8" fill={strokeColor} />
192
- <text x="0" y="-5" textAnchor="middle" fill={isDark ? '#d4c2a5' : '#4d3926'} className="font-garamond text-[12px] font-bold">0</text>
193
- <text x="45" y="-5" textAnchor="middle" fill={isDark ? '#d4c2a5' : '#4d3926'} className="font-garamond text-[12px] font-bold">25</text>
194
- <text x="90" y="-5" textAnchor="middle" fill={isDark ? '#d4c2a5' : '#4d3926'} className="font-garamond text-[12px] font-bold">50</text>
195
- <text x="180" y="-5" textAnchor="middle" fill={isDark ? '#d4c2a5' : '#4d3926'} className="font-garamond text-[12px] font-bold">100 Leagues</text>
 
 
 
 
 
 
 
 
 
196
  </g>
197
  </g>
198
  </>
199
  );
200
- };
 
13
  }) => {
14
  const isDark = theme.id !== 'parchment';
15
  const strokeColor = theme.pencilColor;
16
+ const shadeColor = theme.pencilShade;
17
  const tickFill = isDark ? '#2e261f' : '#3d2f21';
18
 
19
  return (
20
  <>
21
+ {/* 1. SVG Definitions for Quill Ink, Parchment Fiber Grain, & Gradients */}
22
  <defs>
23
+ {/* Hand-Inked Quill Wobble Filter for Terrain & Borders */}
24
+ <filter id="quillInk" x="-2%" y="-2%" width="104%" height="104%">
25
+ <feTurbulence
26
+ type="fractalNoise"
27
+ baseFrequency="0.038"
28
+ numOctaves="2"
29
+ seed="14"
30
+ result="paperFiber"
31
+ />
32
+ <feDisplacementMap
33
+ in="SourceGraphic"
34
+ in2="paperFiber"
35
+ scale="1.7"
36
+ xChannelSelector="R"
37
+ yChannelSelector="G"
38
+ result="wobbledInk"
39
+ />
40
+ </filter>
41
+
42
+ {/* Full-Canvas Procedural Vellum / Parchment Fiber Texture */}
43
+ <filter id="vellumGrain" x="0%" y="0%" width="100%" height="100%">
44
+ <feTurbulence
45
+ type="fractalNoise"
46
+ baseFrequency="0.04"
47
+ numOctaves="4"
48
+ seed="5"
49
+ result="fineNoise"
50
+ />
51
  <feColorMatrix
52
+ type="matrix"
53
+ values={
54
+ isDark
55
+ ? '0 0 0 0 0.08 0 0 0 0 0.06 0 0 0 0 0.04 0 0 0 0.14 0'
56
+ : '0 0 0 0 0.52 0 0 0 0 0.38 0 0 0 0 0.22 0 0 0 0.09 0'
57
+ }
58
+ />
59
+ </filter>
60
+
61
+ {/* Warm Alchemical Gold Glow for Illuminated Path */}
62
+ <filter id="goldenGlow" x="-40%" y="-40%" width="180%" height="180%">
63
+ <feGaussianBlur in="SourceGraphic" stdDeviation="2.5" result="blur1" />
64
+ <feGaussianBlur in="SourceGraphic" stdDeviation="6" result="blur2" />
65
+ <feColorMatrix
66
+ in="blur2"
67
  type="matrix"
68
  values="
69
+ 1 0 0 0 0.85
70
+ 0 0.65 0 0 0.45
71
+ 0 0 0.15 0 0.05
72
+ 0 0 0 0.9 0"
73
+ result="warmAura"
74
  />
75
  <feMerge>
76
+ <feMergeNode in="warmAura" />
 
77
  <feMergeNode in="blur1" />
78
  <feMergeNode in="SourceGraphic" />
79
  </feMerge>
80
  </filter>
81
 
82
+ {/* Subtle Drop Shadow for Wax Seals and Landmarks */}
83
+ <filter id="nodeGlow" x="-60%" y="-60%" width="220%" height="220%">
84
+ <feDropShadow
85
+ dx="0.8"
86
+ dy="1.5"
87
+ stdDeviation="1.4"
88
+ floodColor={isDark ? '#000000' : '#2b1d0e'}
89
+ floodOpacity="0.45"
90
+ />
91
  </filter>
92
 
93
+ {/* Burnished Gold Leaf Gradient for Lit Trail */}
94
  <linearGradient id="goldPathGradient" x1="0%" y1="0%" x2="100%" y2="100%">
95
+ <stop offset="0%" stopColor="#92400e" stopOpacity="0.95" />
96
+ <stop offset="45%" stopColor="#d97706" stopOpacity="1" />
97
+ <stop offset="100%" stopColor="#f59e0b" stopOpacity="1" />
98
  </linearGradient>
99
 
100
+ {/* Crimson Wax Seal Gradient for Solved Nodes */}
101
+ <radialGradient id="waxSealGradient" cx="35%" cy="35%" r="65%">
102
+ <stop offset="0%" stopColor="#dc2626" />
103
+ <stop offset="55%" stopColor="#991b1b" />
104
+ <stop offset="100%" stopColor="#5c1111" />
105
+ </radialGradient>
106
+
107
+ {/* Brass Astrolabe Gradient for Lit Unsolved Nodes */}
108
+ <radialGradient id="brassNodeGradient" cx="35%" cy="35%" r="65%">
109
+ <stop offset="0%" stopColor="#fcd34d" />
110
+ <stop offset="60%" stopColor="#d97706" />
111
+ <stop offset="100%" stopColor="#78350f" />
112
+ </radialGradient>
113
+
114
+ {/* Active Waypoint Lantern Radial Glow */}
115
  <radialGradient id="beaconGlow" cx="50%" cy="50%" r="50%">
116
+ <stop offset="0%" stopColor="#fef3c7" stopOpacity="0.85" />
117
+ <stop offset="45%" stopColor="#d97706" stopOpacity="0.45" />
118
+ <stop offset="80%" stopColor="#92400e" stopOpacity="0.15" />
119
+ <stop offset="100%" stopColor="#78350f" stopOpacity="0" />
120
+ </radialGradient>
121
+
122
+ {/* Corner Age Darkening Vignette */}
123
+ <radialGradient id="parchmentEdgeBurn" cx="50%" cy="50%" r="55%">
124
+ <stop offset="0%" stopColor="#8c6239" stopOpacity="0" />
125
+ <stop offset="82%" stopColor="#8c6239" stopOpacity={isDark ? '0.05' : '0.08'} />
126
+ <stop offset="100%" stopColor="#4a2c11" stopOpacity={isDark ? '0.28' : '0.25'} />
127
  </radialGradient>
128
  </defs>
129
 
130
+ {/* 2. Physical Parchment Fiber Texture, Edge Burn & Satchel Fold Creases */}
131
+ <g id="parchment-aging-artifacts" pointerEvents="none">
132
+ {/* Full-Canvas Fine Vellum Fiber Overlay */}
133
+ <rect
134
+ x="0"
135
+ y="0"
136
+ width={MAP_WIDTH}
137
+ height={MAP_HEIGHT}
138
+ filter="url(#vellumGrain)"
139
+ />
140
+
141
+ {/* Burnt/Aged Perimeter Wash */}
142
+ <rect
143
+ x="0"
144
+ y="0"
145
+ width={MAP_WIDTH}
146
+ height={MAP_HEIGHT}
147
+ fill="url(#parchmentEdgeBurn)"
148
+ />
149
+
150
+ {/* Map Fold Creases (8-Panel Satchel Fold Lines) */}
151
+ <g opacity={isDark ? 0.14 : 0.18} filter="url(#quillInk)">
152
+ {[650, 1300, 1950].map((fx) => (
153
+ <React.Fragment key={`fold-v-${fx}`}>
154
+ <line
155
+ x1={fx}
156
+ y1="38"
157
+ x2={fx}
158
+ y2={MAP_HEIGHT - 38}
159
+ stroke={strokeColor}
160
+ strokeWidth="1"
161
+ strokeDasharray="24 6 42 8"
162
+ />
163
+ <line
164
+ x1={fx + 1.5}
165
+ y1="38"
166
+ x2={fx + 1.5}
167
+ y2={MAP_HEIGHT - 38}
168
+ stroke={isDark ? '#f5ebd6' : '#ffffff'}
169
+ strokeWidth="0.8"
170
+ opacity="0.45"
171
+ />
172
+ </React.Fragment>
173
+ ))}
174
+ <line
175
+ x1="38"
176
+ y1={MAP_HEIGHT / 2}
177
+ x2={MAP_WIDTH - 38}
178
+ y2={MAP_HEIGHT / 2}
179
+ stroke={strokeColor}
180
+ strokeWidth="1"
181
+ strokeDasharray="28 6 48 8"
182
+ />
183
+ <line
184
+ x1="38"
185
+ y1={MAP_HEIGHT / 2 + 1.5}
186
+ x2={MAP_WIDTH - 38}
187
+ y2={MAP_HEIGHT / 2 + 1.5}
188
+ stroke={isDark ? '#f5ebd6' : '#ffffff'}
189
+ strokeWidth="0.8"
190
+ opacity="0.45"
191
+ />
192
+ </g>
193
+ </g>
194
+
195
+ {/* 3. Optional Cartographic Coordinate Grid */}
196
  {showGrid && (
197
+ <g
198
+ id="grid-lines"
199
+ stroke={strokeColor}
200
+ strokeWidth="0.7"
201
+ strokeDasharray="4 6"
202
+ opacity={isDark ? 0.16 : 0.24}
203
+ pointerEvents="none"
204
+ >
205
  {Array.from({ length: 13 }).map((_, i) => {
206
  const x = (i + 1) * 200;
207
+ return <line key={`gx-${i}`} x1={x} y1="38" x2={x} y2={MAP_HEIGHT - 38} />;
208
  })}
209
  {Array.from({ length: 7 }).map((_, i) => {
210
  const y = (i + 1) * 200;
211
+ return <line key={`gy-${i}`} x1="38" y1={y} x2={MAP_WIDTH - 38} y2={y} />;
212
  })}
213
  </g>
214
  )}
215
 
216
+ {/* 4. Hand-Inked Antique Map Border */}
217
+ <g id="map-border" pointerEvents="none" filter="url(#quillInk)">
218
  <rect
219
  x="12"
220
  y="12"
 
222
  height={MAP_HEIGHT - 24}
223
  fill="none"
224
  stroke={strokeColor}
225
+ strokeWidth="5.5"
226
  />
227
 
228
  <rect
 
230
  y="20"
231
  width={MAP_WIDTH - 40}
232
  height="14"
233
+ fill={isDark ? '#231e17' : '#e9dec5'}
234
  stroke={strokeColor}
235
  strokeWidth="1.5"
236
  />
 
239
  y={MAP_HEIGHT - 34}
240
  width={MAP_WIDTH - 40}
241
  height="14"
242
+ fill={isDark ? '#231e17' : '#e9dec5'}
243
  stroke={strokeColor}
244
  strokeWidth="1.5"
245
  />
 
246
  <rect
247
  x="20"
248
  y="20"
249
  width="14"
250
  height={MAP_HEIGHT - 40}
251
+ fill={isDark ? '#231e17' : '#e9dec5'}
252
  stroke={strokeColor}
253
  strokeWidth="1.5"
254
  />
 
257
  y="20"
258
  width="14"
259
  height={MAP_HEIGHT - 40}
260
+ fill={isDark ? '#231e17' : '#e9dec5'}
261
  stroke={strokeColor}
262
  strokeWidth="1.5"
263
  />
264
 
265
+ {/* Horizontal Alternating Degree Blocks */}
266
  {Array.from({ length: 32 }).map((_, i) => {
267
  if (i % 2 === 0) return null;
268
  const segW = (MAP_WIDTH - 40) / 32;
269
  return (
270
  <React.Fragment key={`ruler-h-${i}`}>
271
+ <rect x={20 + i * segW} y="20" width={segW} height="14" fill={tickFill} />
272
+ <rect x={20 + i * segW} y={MAP_HEIGHT - 34} width={segW} height="14" fill={tickFill} />
 
 
 
 
 
 
 
 
 
 
 
 
273
  </React.Fragment>
274
  );
275
  })}
276
 
277
+ {/* Vertical Alternating Degree Blocks */}
278
+ {Array.from({ length: 18 }).map((_, i) => {
279
+ if (i % 2 === 0) return null;
280
+ const segH = (MAP_HEIGHT - 40) / 18;
281
+ return (
282
+ <React.Fragment key={`ruler-v-${i}`}>
283
+ <rect x="20" y={20 + i * segH} width="14" height={segH} fill={tickFill} />
284
+ <rect x={MAP_WIDTH - 34} y={20 + i * segH} width="14" height={segH} fill={tickFill} />
285
+ </React.Fragment>
286
+ );
287
+ })}
288
+
289
+ {/* Inner Double Framing Rule */}
290
  <rect
291
  x="38"
292
  y="38"
 
294
  height={MAP_HEIGHT - 76}
295
  fill="none"
296
  stroke={strokeColor}
297
+ strokeWidth="2.2"
298
+ />
299
+ <rect
300
+ x="43"
301
+ y="43"
302
+ width={MAP_WIDTH - 86}
303
+ height={MAP_HEIGHT - 86}
304
+ fill="none"
305
+ stroke={shadeColor}
306
+ strokeWidth="0.9"
307
  />
308
 
309
+ {/* Ornate Renaissance Corner Spandrels */}
310
+ {[
311
+ { tx: 38, ty: 38, sx: 1, sy: 1 },
312
+ { tx: MAP_WIDTH - 38, ty: 38, sx: -1, sy: 1 },
313
+ { tx: 38, ty: MAP_HEIGHT - 38, sx: 1, sy: -1 },
314
+ { tx: MAP_WIDTH - 38, ty: MAP_HEIGHT - 38, sx: -1, sy: -1 },
315
+ ].map((corner, idx) => (
316
+ <g
317
+ key={`corner-${idx}`}
318
+ transform={`translate(${corner.tx}, ${corner.ty}) scale(${corner.sx}, ${corner.sy})`}
319
+ stroke={strokeColor}
320
+ strokeWidth="1.6"
321
+ fill="none"
322
+ >
323
+ <path d="M 0,0 L 62,0 C 36,18 18,36 0,62 Z" fill={isDark ? '#2a221a' : '#dfd0b2'} />
324
+ <path d="M 0,0 L 48,0 C 28,14 14,28 0,48 Z" fill="none" strokeWidth="1" />
325
+ <circle cx="18" cy="18" r="4.5" fill={strokeColor} />
326
+ <circle cx="18" cy="18" r="8" fill="none" strokeWidth="0.9" />
327
+ <line x1="0" y1="0" x2="46" y2="46" />
328
+ </g>
329
+ ))}
330
 
331
+ {/* Engraved Cartographic Scale Bar & Divider Calipers */}
332
+ <g transform="translate(480, 1442)" stroke={strokeColor}>
333
+ <path d="M 90,-34 L 78,-12 M 90,-34 L 102,-12" strokeWidth="1.6" fill="none" />
334
+ <circle cx="90" cy="-36" r="3" fill={strokeColor} />
335
+ <rect x="0" y="0" width="180" height="8" fill={isDark ? '#1e1914' : '#f3e8d2'} strokeWidth="1.4" />
336
  <rect x="0" y="0" width="45" height="8" fill={strokeColor} />
337
  <rect x="90" y="0" width="45" height="8" fill={strokeColor} />
338
+ <line x1="0" y1="4" x2="180" y2="4" strokeWidth="0.7" />
339
+ <text x="0" y="-5" textAnchor="middle" fill={isDark ? '#d4c2a5' : '#4d3926'} className="font-garamond text-[12px] font-bold">
340
+ 0
341
+ </text>
342
+ <text x="45" y="-5" textAnchor="middle" fill={isDark ? '#d4c2a5' : '#4d3926'} className="font-garamond text-[12px] font-bold">
343
+ 25
344
+ </text>
345
+ <text x="90" y="-5" textAnchor="middle" fill={isDark ? '#d4c2a5' : '#4d3926'} className="font-garamond text-[12px] font-bold">
346
+ 50
347
+ </text>
348
+ <text x="180" y="-5" textAnchor="middle" fill={isDark ? '#d4c2a5' : '#4d3926'} className="font-garamond text-[12px] font-bold">
349
+ 100 Leagues
350
+ </text>
351
  </g>
352
  </g>
353
  </>
354
  );
355
+ };
algospaced-ui/src/components/map/MapControls.tsx CHANGED
@@ -1,3 +1,4 @@
 
1
  import type { MapTheme } from '../../types/mapTypes';
2
  import {
3
  Volume2,
@@ -57,21 +58,26 @@ export const MapControls: React.FC<MapControlsProps> = ({
57
  }) => {
58
  const isDark = theme.id !== 'parchment';
59
 
 
 
 
 
 
60
  return (
61
  <div className="flex flex-wrap items-center justify-between gap-2 px-1 text-xs select-none">
62
  {/* Left Side: Track selector & Map Layer Options */}
63
  <div className="flex items-center gap-1.5 flex-wrap">
64
  {/* Active Track Switcher */}
65
  {tracks && tracks.length > 0 && onTrackChange && (
66
- <div className="flex items-center gap-1.5 bg-black/30 backdrop-blur-md px-2.5 py-1.5 rounded-xl border border-black/20 shadow-md">
67
- <Route className="w-3.5 h-3.5 text-amber-500" />
68
- <span className="font-cinzel text-[10px] font-bold tracking-wider text-amber-600 dark:text-amber-400 uppercase hidden sm:inline">
69
  Track:
70
  </span>
71
  <select
72
  value={activeTrack}
73
  onChange={(e) => onTrackChange(e.target.value)}
74
- className="bg-transparent border-none text-xs font-cinzel font-bold text-amber-700 dark:text-amber-300 cursor-pointer focus:outline-none"
75
  >
76
  {tracks.map((t) => (
77
  <option key={t.id} value={t.id} className="bg-stone-900 text-stone-200">
@@ -87,13 +93,15 @@ export const MapControls: React.FC<MapControlsProps> = ({
87
  id="toggle-sound-btn"
88
  onClick={onToggleSound}
89
  title={soundEnabled ? 'Mute Audio' : 'Enable Audio'}
90
- className={`flex items-center gap-1 px-2.5 py-1.5 rounded-xl border backdrop-blur-md shadow-md transition-all cursor-pointer ${
91
  soundEnabled
92
- ? 'bg-amber-500/20 border-amber-500/50 text-amber-600 dark:text-amber-400'
93
- : 'bg-black/20 border-black/10 text-stone-500'
94
- }`}
95
  >
96
- {soundEnabled ? <Volume2 className="w-3.5 h-3.5" /> : <VolumeX className="w-3.5 h-3.5" />}
 
 
 
 
97
  <span className="font-garamond font-semibold hidden sm:inline">Audio</span>
98
  </button>
99
 
@@ -102,13 +110,14 @@ export const MapControls: React.FC<MapControlsProps> = ({
102
  id="toggle-autocenter-btn"
103
  onClick={onToggleAutoCenter}
104
  title="Auto-Center on Active Node"
105
- className={`flex items-center gap-1 px-2.5 py-1.5 rounded-xl border backdrop-blur-md shadow-md transition-all cursor-pointer ${
106
  autoCenterOnActive
107
- ? 'bg-amber-500/20 border-amber-500/50 text-amber-600 dark:text-amber-400'
108
- : 'bg-black/20 border-black/10 text-stone-500'
109
- }`}
110
  >
111
- <Compass className="w-3.5 h-3.5" />
 
 
 
112
  <span className="font-garamond font-semibold hidden sm:inline">Auto-Track</span>
113
  </button>
114
 
@@ -117,13 +126,13 @@ export const MapControls: React.FC<MapControlsProps> = ({
117
  id="toggle-labels-btn"
118
  onClick={onToggleLabels}
119
  title="Toggle Geographical Labels"
120
- className={`flex items-center gap-1 px-2.5 py-1.5 rounded-xl border backdrop-blur-md shadow-md transition-all cursor-pointer ${
121
  showLabels
122
- ? 'bg-amber-500/20 border-amber-500/50 text-amber-600 dark:text-amber-400'
123
- : 'bg-black/20 border-black/10 text-stone-500'
124
- }`}
125
  >
126
- <Layers className="w-3.5 h-3.5" />
 
 
127
  <span className="font-garamond font-semibold hidden sm:inline">Labels</span>
128
  </button>
129
 
@@ -132,11 +141,9 @@ export const MapControls: React.FC<MapControlsProps> = ({
132
  id="toggle-grid-btn"
133
  onClick={onToggleGrid}
134
  title="Toggle Coordinate Grid"
135
- className={`px-2.5 py-1.5 rounded-xl border backdrop-blur-md shadow-md font-garamond font-semibold transition-all cursor-pointer ${
136
  showGrid
137
- ? 'bg-amber-500/20 border-amber-500/50 text-amber-600 dark:text-amber-400'
138
- : 'bg-black/20 border-black/10 text-stone-500'
139
- }`}
140
  >
141
  Grid
142
  </button>
@@ -146,11 +153,9 @@ export const MapControls: React.FC<MapControlsProps> = ({
146
  id="toggle-numbers-btn"
147
  onClick={onToggleNodeNumbers}
148
  title="Toggle All Node Numbers"
149
- className={`px-2.5 py-1.5 rounded-xl border backdrop-blur-md shadow-md font-garamond font-semibold transition-all cursor-pointer ${
150
  showNodeNumbers
151
- ? 'bg-amber-500/20 border-amber-500/50 text-amber-600 dark:text-amber-400'
152
- : 'bg-black/20 border-black/10 text-stone-500'
153
- }`}
154
  >
155
  #s
156
  </button>
@@ -160,13 +165,13 @@ export const MapControls: React.FC<MapControlsProps> = ({
160
  id="toggle-theme-btn"
161
  onClick={onToggleTheme}
162
  title="Switch Map Lighting Style"
163
- className={`flex items-center gap-1 px-2.5 py-1.5 rounded-xl border backdrop-blur-md shadow-md transition-all cursor-pointer ${
164
- isDark
165
- ? 'bg-amber-500/20 border-amber-500/50 text-amber-300'
166
- : 'bg-amber-900/10 border-amber-900/20 text-amber-900'
167
- }`}
168
  >
169
- {isDark ? <Sun className="w-3.5 h-3.5" /> : <Moon className="w-3.5 h-3.5" />}
 
 
 
 
170
  <span className="font-garamond font-semibold hidden sm:inline">
171
  {isDark ? 'Day' : 'Night'}
172
  </span>
@@ -174,12 +179,12 @@ export const MapControls: React.FC<MapControlsProps> = ({
174
  </div>
175
 
176
  {/* Right Side: Zoom & Camera Controls */}
177
- <div className="flex items-center gap-1 bg-black/30 backdrop-blur-md p-1 rounded-xl border border-black/20 shadow-md">
178
  <button
179
  id="zoom-in-btn"
180
  onClick={onZoomIn}
181
  title="Zoom In"
182
- className="p-1.5 rounded-lg hover:bg-white/10 text-stone-300 cursor-pointer"
183
  >
184
  <ZoomIn className="w-4 h-4" />
185
  </button>
@@ -187,7 +192,7 @@ export const MapControls: React.FC<MapControlsProps> = ({
187
  id="zoom-out-btn"
188
  onClick={onZoomOut}
189
  title="Zoom Out"
190
- className="p-1.5 rounded-lg hover:bg-white/10 text-stone-300 cursor-pointer"
191
  >
192
  <ZoomOut className="w-4 h-4" />
193
  </button>
@@ -195,7 +200,7 @@ export const MapControls: React.FC<MapControlsProps> = ({
195
  id="center-active-btn"
196
  onClick={onCenterActiveNode}
197
  title="Focus Active Node"
198
- className="p-1.5 rounded-lg hover:bg-white/10 text-stone-300 cursor-pointer"
199
  >
200
  <Compass className="w-4 h-4 text-amber-400" />
201
  </button>
@@ -203,11 +208,11 @@ export const MapControls: React.FC<MapControlsProps> = ({
203
  id="reset-zoom-btn"
204
  onClick={onResetZoom}
205
  title="Fit Entire Map"
206
- className="p-1.5 rounded-lg hover:bg-white/10 text-stone-300 cursor-pointer"
207
  >
208
  <Maximize2 className="w-4 h-4" />
209
  </button>
210
  </div>
211
  </div>
212
  );
213
- };
 
1
+ import React from 'react';
2
  import type { MapTheme } from '../../types/mapTypes';
3
  import {
4
  Volume2,
 
58
  }) => {
59
  const isDark = theme.id !== 'parchment';
60
 
61
+ const getToggleBtnStyle = (isActive: boolean) =>
62
+ isActive
63
+ ? 'bg-[#2a2017]/90 border-amber-500/70 text-amber-300 shadow-md'
64
+ : 'bg-[#1c1610]/75 border-stone-700/70 text-stone-300 hover:text-amber-200 hover:bg-[#2a2017]/85 shadow-md';
65
+
66
  return (
67
  <div className="flex flex-wrap items-center justify-between gap-2 px-1 text-xs select-none">
68
  {/* Left Side: Track selector & Map Layer Options */}
69
  <div className="flex items-center gap-1.5 flex-wrap">
70
  {/* Active Track Switcher */}
71
  {tracks && tracks.length > 0 && onTrackChange && (
72
+ <div className="flex items-center gap-1.5 bg-[#1c1610]/85 backdrop-blur-md px-3 py-1.5 rounded-xl border border-amber-500/40 shadow-md">
73
+ <Route className="w-3.5 h-3.5 text-amber-400" />
74
+ <span className="font-cinzel text-[10px] font-bold tracking-wider text-amber-400 uppercase hidden sm:inline">
75
  Track:
76
  </span>
77
  <select
78
  value={activeTrack}
79
  onChange={(e) => onTrackChange(e.target.value)}
80
+ className="bg-transparent border-none text-xs font-cinzel font-bold text-amber-200 cursor-pointer focus:outline-none"
81
  >
82
  {tracks.map((t) => (
83
  <option key={t.id} value={t.id} className="bg-stone-900 text-stone-200">
 
93
  id="toggle-sound-btn"
94
  onClick={onToggleSound}
95
  title={soundEnabled ? 'Mute Audio' : 'Enable Audio'}
96
+ className={`flex items-center gap-1.5 px-2.5 py-1.5 rounded-xl border backdrop-blur-md transition-all cursor-pointer ${getToggleBtnStyle(
97
  soundEnabled
98
+ )}`}
 
 
99
  >
100
+ {soundEnabled ? (
101
+ <Volume2 className="w-3.5 h-3.5 text-amber-400" />
102
+ ) : (
103
+ <VolumeX className="w-3.5 h-3.5 text-stone-400" />
104
+ )}
105
  <span className="font-garamond font-semibold hidden sm:inline">Audio</span>
106
  </button>
107
 
 
110
  id="toggle-autocenter-btn"
111
  onClick={onToggleAutoCenter}
112
  title="Auto-Center on Active Node"
113
+ className={`flex items-center gap-1.5 px-2.5 py-1.5 rounded-xl border backdrop-blur-md transition-all cursor-pointer ${getToggleBtnStyle(
114
  autoCenterOnActive
115
+ )}`}
 
 
116
  >
117
+ <Compass
118
+ className={`w-3.5 h-3.5 ${autoCenterOnActive ? 'text-amber-400' : 'text-stone-400'
119
+ }`}
120
+ />
121
  <span className="font-garamond font-semibold hidden sm:inline">Auto-Track</span>
122
  </button>
123
 
 
126
  id="toggle-labels-btn"
127
  onClick={onToggleLabels}
128
  title="Toggle Geographical Labels"
129
+ className={`flex items-center gap-1.5 px-2.5 py-1.5 rounded-xl border backdrop-blur-md transition-all cursor-pointer ${getToggleBtnStyle(
130
  showLabels
131
+ )}`}
 
 
132
  >
133
+ <Layers
134
+ className={`w-3.5 h-3.5 ${showLabels ? 'text-amber-400' : 'text-stone-400'}`}
135
+ />
136
  <span className="font-garamond font-semibold hidden sm:inline">Labels</span>
137
  </button>
138
 
 
141
  id="toggle-grid-btn"
142
  onClick={onToggleGrid}
143
  title="Toggle Coordinate Grid"
144
+ className={`px-2.5 py-1.5 rounded-xl border backdrop-blur-md font-garamond font-semibold transition-all cursor-pointer ${getToggleBtnStyle(
145
  showGrid
146
+ )}`}
 
 
147
  >
148
  Grid
149
  </button>
 
153
  id="toggle-numbers-btn"
154
  onClick={onToggleNodeNumbers}
155
  title="Toggle All Node Numbers"
156
+ className={`px-2.5 py-1.5 rounded-xl border backdrop-blur-md font-garamond font-semibold transition-all cursor-pointer ${getToggleBtnStyle(
157
  showNodeNumbers
158
+ )}`}
 
 
159
  >
160
  #s
161
  </button>
 
165
  id="toggle-theme-btn"
166
  onClick={onToggleTheme}
167
  title="Switch Map Lighting Style"
168
+ className="flex items-center gap-1.5 px-2.5 py-1.5 rounded-xl border backdrop-blur-md bg-[#1c1610]/85 border-stone-700/70 text-amber-200 hover:border-amber-500/60 shadow-md transition-all cursor-pointer"
 
 
 
 
169
  >
170
+ {isDark ? (
171
+ <Sun className="w-3.5 h-3.5 text-amber-400" />
172
+ ) : (
173
+ <Moon className="w-3.5 h-3.5 text-amber-400" />
174
+ )}
175
  <span className="font-garamond font-semibold hidden sm:inline">
176
  {isDark ? 'Day' : 'Night'}
177
  </span>
 
179
  </div>
180
 
181
  {/* Right Side: Zoom & Camera Controls */}
182
+ <div className="flex items-center gap-1 bg-[#1c1610]/85 backdrop-blur-md p-1 rounded-xl border border-stone-700/70 shadow-md">
183
  <button
184
  id="zoom-in-btn"
185
  onClick={onZoomIn}
186
  title="Zoom In"
187
+ className="p-1.5 rounded-lg hover:bg-white/10 text-stone-200 cursor-pointer"
188
  >
189
  <ZoomIn className="w-4 h-4" />
190
  </button>
 
192
  id="zoom-out-btn"
193
  onClick={onZoomOut}
194
  title="Zoom Out"
195
+ className="p-1.5 rounded-lg hover:bg-white/10 text-stone-200 cursor-pointer"
196
  >
197
  <ZoomOut className="w-4 h-4" />
198
  </button>
 
200
  id="center-active-btn"
201
  onClick={onCenterActiveNode}
202
  title="Focus Active Node"
203
+ className="p-1.5 rounded-lg hover:bg-white/10 text-stone-200 cursor-pointer"
204
  >
205
  <Compass className="w-4 h-4 text-amber-400" />
206
  </button>
 
208
  id="reset-zoom-btn"
209
  onClick={onResetZoom}
210
  title="Fit Entire Map"
211
+ className="p-1.5 rounded-lg hover:bg-white/10 text-stone-200 cursor-pointer"
212
  >
213
  <Maximize2 className="w-4 h-4" />
214
  </button>
215
  </div>
216
  </div>
217
  );
218
+ };
algospaced-ui/src/components/map/NodeDetailCard.tsx CHANGED
@@ -364,7 +364,7 @@ export const NodeDetailCard: React.FC<NodeDetailCardProps> = ({
364
  ) : (
365
  <Zap className="w-3.5 h-3.5 text-amber-500" />
366
  )}
367
- <span>{activatedSuccess ? 'Added to Box 1!' : 'Learned Today'}</span>
368
  </button>
369
 
370
  <button
 
364
  ) : (
365
  <Zap className="w-3.5 h-3.5 text-amber-500" />
366
  )}
367
+ <span>{activatedSuccess ? 'Enrolled in Queue!' : 'Learned Today'}</span>
368
  </button>
369
 
370
  <button
algospaced-ui/src/components/map/PencilMapCanvas.tsx CHANGED
@@ -52,7 +52,6 @@ export const PencilMapCanvas: React.FC<PencilMapCanvasProps> = ({
52
  if (!containerRef.current || nodeIdx < 0 || nodeIdx >= nodes.length) return;
53
  const node = nodes[nodeIdx];
54
  const { clientWidth, clientHeight } = containerRef.current;
55
-
56
  const currentScale = transformRef.current.scale;
57
  const targetScale = Math.max(currentScale, 0.9);
58
  const targetX = clientWidth / 2 - node.x * targetScale;
@@ -79,7 +78,7 @@ export const PencilMapCanvas: React.FC<PencilMapCanvasProps> = ({
79
  const { clientWidth, clientHeight } = containerRef.current;
80
  const scaleX = clientWidth / MAP_WIDTH;
81
  const scaleY = clientHeight / MAP_HEIGHT;
82
- const fitScale = Math.min(scaleX, scaleY) * 0.90;
83
  const initialX = (clientWidth - MAP_WIDTH * fitScale) / 2;
84
  const initialY = (clientHeight - MAP_HEIGHT * fitScale) / 2;
85
 
@@ -197,9 +196,8 @@ export const PencilMapCanvas: React.FC<PencilMapCanvasProps> = ({
197
  <div
198
  id="pencil-map-container"
199
  ref={containerRef}
200
- className={`relative w-full h-full overflow-hidden canvas-interactive select-none ${
201
- isParchmentDark ? 'parchment-dark-bg' : 'parchment-bg'
202
- }`}
203
  onWheel={handleWheel}
204
  onMouseDown={handleMouseDown}
205
  onMouseMove={handleMouseMove}
@@ -211,9 +209,8 @@ export const PencilMapCanvas: React.FC<PencilMapCanvasProps> = ({
211
  >
212
  {/* Vintage Vignette Overlay */}
213
  <div
214
- className={`absolute inset-0 pointer-events-none z-10 ${
215
- isParchmentDark ? 'map-dark-vignette' : 'map-vignette'
216
- }`}
217
  />
218
 
219
  {/* SVG Canvas with Transform Matrix */}
@@ -225,14 +222,20 @@ export const PencilMapCanvas: React.FC<PencilMapCanvasProps> = ({
225
  style={{
226
  transform: `translate(${transform.x}px, ${transform.y}px) scale(${transform.scale})`,
227
  transformOrigin: '0 0',
228
- transition: isDirectInteracting ? 'none' : 'transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)',
 
 
229
  }}
230
  className="absolute top-0 left-0"
231
  >
232
  <MapBorderAndFilters theme={theme} showGrid={showGrid} />
233
-
234
- <TerrainDrawings theme={theme} showLabels={showLabels} finalNode={nodes[nodes.length - 1]} />
235
-
 
 
 
 
236
  <CurvyPathAndNodes
237
  nodes={nodes}
238
  activeNodeIndex={activeNodeIndex}
@@ -246,4 +249,4 @@ export const PencilMapCanvas: React.FC<PencilMapCanvasProps> = ({
246
  </svg>
247
  </div>
248
  );
249
- };
 
52
  if (!containerRef.current || nodeIdx < 0 || nodeIdx >= nodes.length) return;
53
  const node = nodes[nodeIdx];
54
  const { clientWidth, clientHeight } = containerRef.current;
 
55
  const currentScale = transformRef.current.scale;
56
  const targetScale = Math.max(currentScale, 0.9);
57
  const targetX = clientWidth / 2 - node.x * targetScale;
 
78
  const { clientWidth, clientHeight } = containerRef.current;
79
  const scaleX = clientWidth / MAP_WIDTH;
80
  const scaleY = clientHeight / MAP_HEIGHT;
81
+ const fitScale = Math.min(scaleX, scaleY) * 0.9;
82
  const initialX = (clientWidth - MAP_WIDTH * fitScale) / 2;
83
  const initialY = (clientHeight - MAP_HEIGHT * fitScale) / 2;
84
 
 
196
  <div
197
  id="pencil-map-container"
198
  ref={containerRef}
199
+ className={`relative w-full h-full overflow-hidden canvas-interactive select-none ${isParchmentDark ? 'parchment-dark-bg' : 'parchment-bg'
200
+ }`}
 
201
  onWheel={handleWheel}
202
  onMouseDown={handleMouseDown}
203
  onMouseMove={handleMouseMove}
 
209
  >
210
  {/* Vintage Vignette Overlay */}
211
  <div
212
+ className={`absolute inset-0 pointer-events-none z-10 ${isParchmentDark ? 'map-dark-vignette' : 'map-vignette'
213
+ }`}
 
214
  />
215
 
216
  {/* SVG Canvas with Transform Matrix */}
 
222
  style={{
223
  transform: `translate(${transform.x}px, ${transform.y}px) scale(${transform.scale})`,
224
  transformOrigin: '0 0',
225
+ transition: isDirectInteracting
226
+ ? 'none'
227
+ : 'transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)',
228
  }}
229
  className="absolute top-0 left-0"
230
  >
231
  <MapBorderAndFilters theme={theme} showGrid={showGrid} />
232
+ <TerrainDrawings
233
+ theme={theme}
234
+ showLabels={showLabels}
235
+ finalNode={nodes[nodes.length - 1]}
236
+ completedCount={completions.size}
237
+ totalNodes={nodes.length}
238
+ />
239
  <CurvyPathAndNodes
240
  nodes={nodes}
241
  activeNodeIndex={activeNodeIndex}
 
249
  </svg>
250
  </div>
251
  );
252
+ };