Spaces:
Running
Running
feat: offline review queue caching, connection fallback UI, and cache failure cooldowns
Browse files- ai_cache.py +96 -45
- algospaced-ui/dist/assets/{Auth-DJq0y_UK.js → Auth-DHdm5r3r.js} +1 -1
- algospaced-ui/dist/assets/{CreateProblemForm-CiTqt9b8.js → CreateProblemForm-Cej3QR08.js} +1 -1
- algospaced-ui/dist/assets/{FileExplorer-Duw1SQGy.js → FileExplorer-CJE9LlAj.js} +1 -1
- algospaced-ui/dist/assets/GitHubSyncWindow-DHS56rys.js +1 -0
- algospaced-ui/dist/assets/GitHubSyncWindow-JaTkvFiz.js +0 -1
- algospaced-ui/dist/assets/{JourneyPath-u3NVmdds.js → JourneyPath-Dpd3IPxF.js} +0 -0
- algospaced-ui/dist/assets/{KatexRenderer-S2ExKuPO.js → KatexRenderer-HIhDCm0G.js} +1 -1
- algospaced-ui/dist/assets/{MarkdownRenderer-DrNYiC-4.js → MarkdownRenderer-BMZIn30p.js} +2 -2
- algospaced-ui/dist/assets/{MySQLPlayground-mwi_6A09.js → MySQLPlayground-CDRacqFf.js} +1 -1
- algospaced-ui/dist/assets/{OnboardingModal-0y7Pme-5.js → OnboardingModal-DmgTXeeL.js} +1 -1
- algospaced-ui/dist/assets/{PrincessChamber-RGzNhS6w.js → PrincessChamber-5t89aBn-.js} +1 -1
- algospaced-ui/dist/assets/ProblemSpecPanel-CLbwqTwe.js +4 -0
- algospaced-ui/dist/assets/ProblemSpecPanel-D-jlAttf.js +0 -4
- algospaced-ui/dist/assets/{PythonChallenge-B3ERHqof.js → PythonChallenge-BOgiGe52.js} +1 -1
- algospaced-ui/dist/assets/ReviewQueue-C2qCZU0m.js +0 -5
- algospaced-ui/dist/assets/ReviewQueue-DmsrlLxn.js +5 -0
- algospaced-ui/dist/assets/Settings-ACJ113RL.js +1 -0
- algospaced-ui/dist/assets/Settings-ktg25RuD.js +0 -1
- algospaced-ui/dist/assets/{TerminalEmulator-BZMPtN_n.js → TerminalEmulator-C2zR6yON.js} +1 -1
- algospaced-ui/dist/assets/{firebaseClient-BO9k8E9m.js → firebaseClient-DZobvwSx.js} +1 -1
- algospaced-ui/dist/assets/{githubSyncService-cuWA8MAM.js → githubSyncService-x0Mm_uEl.js} +1 -1
- algospaced-ui/dist/assets/{index-0dH8bbro.js → index-DnK6BACV.js} +0 -0
- algospaced-ui/dist/assets/index-supjX07i.css +0 -0
- algospaced-ui/dist/assets/index-tlaKBeUb.css +0 -0
- algospaced-ui/dist/assets/vendor-react-CIO8MTK1.js +0 -0
- algospaced-ui/dist/assets/vendor-react-q-oOktF_.js +0 -0
- algospaced-ui/dist/index.html +4 -4
- algospaced-ui/dist/sw.js +1 -1
- algospaced-ui/eslint.config.js +17 -0
- algospaced-ui/package.json +1 -1
- algospaced-ui/src/components/ReviewQueue.tsx +54 -1
- algospaced-ui/src/hooks/useReviewQueue.ts +114 -20
- algospaced-ui/tests/offlineReviewQueue.test.mjs +244 -0
- cache.py +38 -12
- core/problem_utils.py +23 -0
- db.py +18 -0
- tests/unit/test_cache_resilience.py +89 -0
- tests/unit/test_problem_utils.py +50 -1
ai_cache.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
import asyncio
|
| 2 |
import logging
|
|
|
|
| 3 |
import re
|
| 4 |
import threading
|
|
|
|
| 5 |
from datetime import UTC, datetime
|
| 6 |
from typing import Any
|
| 7 |
|
|
@@ -14,6 +16,33 @@ logger.setLevel(logging.INFO)
|
|
| 14 |
_memory_cache: dict[str, Any] = {}
|
| 15 |
_cache_lock = threading.Lock()
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
def normalize_slug(slug_or_title: str) -> str:
|
| 19 |
"""Sanitizes titles/slugs for safe Firestore doc IDs and cache keys."""
|
|
@@ -42,21 +71,25 @@ def get_cached_item(cache_key: str) -> Any | None:
|
|
| 42 |
except Exception:
|
| 43 |
pass
|
| 44 |
|
| 45 |
-
# 3. Firestore (if available)
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
return None
|
| 62 |
|
|
@@ -79,21 +112,25 @@ async def get_cached_item_async(cache_key: str) -> Any | None:
|
|
| 79 |
except Exception:
|
| 80 |
pass
|
| 81 |
|
| 82 |
-
# Firestore (if available)
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
return None
|
| 98 |
|
| 99 |
return await asyncio.to_thread(_fetch_remote)
|
|
@@ -114,14 +151,21 @@ def set_cached_item(cache_key: str, value: Any, ttl_seconds: int = 86400 * 30):
|
|
| 114 |
except Exception:
|
| 115 |
pass
|
| 116 |
|
| 117 |
-
# 3. Firestore
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
|
| 127 |
async def set_cached_item_async(cache_key: str, value: Any, ttl_seconds: int = 86400 * 30):
|
|
@@ -138,13 +182,20 @@ async def set_cached_item_async(cache_key: str, value: Any, ttl_seconds: int = 8
|
|
| 138 |
except Exception:
|
| 139 |
pass
|
| 140 |
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
await asyncio.to_thread(_persist_remote)
|
| 150 |
|
|
|
|
| 1 |
import asyncio
|
| 2 |
import logging
|
| 3 |
+
import os
|
| 4 |
import re
|
| 5 |
import threading
|
| 6 |
+
import time
|
| 7 |
from datetime import UTC, datetime
|
| 8 |
from typing import Any
|
| 9 |
|
|
|
|
| 16 |
_memory_cache: dict[str, Any] = {}
|
| 17 |
_cache_lock = threading.Lock()
|
| 18 |
|
| 19 |
+
_last_firestore_failure: float = 0.0
|
| 20 |
+
FIRESTORE_FAILURE_COOLDOWN = 60.0 # seconds cooldown when Firestore fails or times out
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def is_local_or_sandbox_mode() -> bool:
|
| 24 |
+
"""Checks whether the backend is operating in local sandbox/guest mode."""
|
| 25 |
+
if os.environ.get("SANDBOX_MODE", "").lower() in ("true", "1", "yes"):
|
| 26 |
+
return True
|
| 27 |
+
if os.environ.get("LOCAL_MODE", "").lower() in ("true", "1", "yes"):
|
| 28 |
+
return True
|
| 29 |
+
# If no Firebase credentials are configured in the environment, we are in local sandbox mode
|
| 30 |
+
if hasattr(db, "has_firebase_credentials") and not db.has_firebase_credentials():
|
| 31 |
+
return True
|
| 32 |
+
return False
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def _can_attempt_firestore() -> bool:
|
| 36 |
+
global _last_firestore_failure
|
| 37 |
+
if is_local_or_sandbox_mode():
|
| 38 |
+
return False
|
| 39 |
+
return (time.monotonic() - _last_firestore_failure) >= FIRESTORE_FAILURE_COOLDOWN
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def _record_firestore_failure():
|
| 43 |
+
global _last_firestore_failure
|
| 44 |
+
_last_firestore_failure = time.monotonic()
|
| 45 |
+
|
| 46 |
|
| 47 |
def normalize_slug(slug_or_title: str) -> str:
|
| 48 |
"""Sanitizes titles/slugs for safe Firestore doc IDs and cache keys."""
|
|
|
|
| 71 |
except Exception:
|
| 72 |
pass
|
| 73 |
|
| 74 |
+
# 3. Firestore (if available and not in local sandbox mode)
|
| 75 |
+
if _can_attempt_firestore():
|
| 76 |
+
try:
|
| 77 |
+
firestore_client = db.init_firebase()
|
| 78 |
+
if firestore_client:
|
| 79 |
+
doc_ref = firestore_client.collection("ai_cache").document(cache_key)
|
| 80 |
+
doc = doc_ref.get(timeout=0.5)
|
| 81 |
+
if doc.exists:
|
| 82 |
+
data = doc.to_dict()
|
| 83 |
+
cached_val = data.get("payload") if data and "payload" in data else data
|
| 84 |
+
if cached_val:
|
| 85 |
+
with _cache_lock:
|
| 86 |
+
_memory_cache[cache_key] = cached_val
|
| 87 |
+
return cached_val
|
| 88 |
+
else:
|
| 89 |
+
_record_firestore_failure()
|
| 90 |
+
except Exception as e:
|
| 91 |
+
_record_firestore_failure()
|
| 92 |
+
logger.debug(f"Firestore cache fetch skipped/failed: {e}")
|
| 93 |
|
| 94 |
return None
|
| 95 |
|
|
|
|
| 112 |
except Exception:
|
| 113 |
pass
|
| 114 |
|
| 115 |
+
# Firestore (if available and not in local sandbox mode)
|
| 116 |
+
if _can_attempt_firestore():
|
| 117 |
+
try:
|
| 118 |
+
firestore_client = db.init_firebase()
|
| 119 |
+
if firestore_client:
|
| 120 |
+
doc_ref = firestore_client.collection("ai_cache").document(cache_key)
|
| 121 |
+
doc = doc_ref.get(timeout=0.5)
|
| 122 |
+
if doc.exists:
|
| 123 |
+
data = doc.to_dict()
|
| 124 |
+
cached_val = data.get("payload") if data and "payload" in data else data
|
| 125 |
+
if cached_val:
|
| 126 |
+
with _cache_lock:
|
| 127 |
+
_memory_cache[cache_key] = cached_val
|
| 128 |
+
return cached_val
|
| 129 |
+
else:
|
| 130 |
+
_record_firestore_failure()
|
| 131 |
+
except Exception as e:
|
| 132 |
+
_record_firestore_failure()
|
| 133 |
+
logger.debug(f"Firestore cache fetch skipped/failed: {e}")
|
| 134 |
return None
|
| 135 |
|
| 136 |
return await asyncio.to_thread(_fetch_remote)
|
|
|
|
| 151 |
except Exception:
|
| 152 |
pass
|
| 153 |
|
| 154 |
+
# 3. Firestore (if available and not in local sandbox mode)
|
| 155 |
+
if _can_attempt_firestore():
|
| 156 |
+
try:
|
| 157 |
+
firestore_client = db.init_firebase()
|
| 158 |
+
if firestore_client:
|
| 159 |
+
doc_ref = firestore_client.collection("ai_cache").document(cache_key)
|
| 160 |
+
doc_ref.set(
|
| 161 |
+
{"payload": value, "cached_at": datetime.now(UTC).isoformat()},
|
| 162 |
+
timeout=0.5,
|
| 163 |
+
)
|
| 164 |
+
else:
|
| 165 |
+
_record_firestore_failure()
|
| 166 |
+
except Exception as e:
|
| 167 |
+
_record_firestore_failure()
|
| 168 |
+
logger.debug(f"Firestore cache set skipped/failed: {e}")
|
| 169 |
|
| 170 |
|
| 171 |
async def set_cached_item_async(cache_key: str, value: Any, ttl_seconds: int = 86400 * 30):
|
|
|
|
| 182 |
except Exception:
|
| 183 |
pass
|
| 184 |
|
| 185 |
+
if _can_attempt_firestore():
|
| 186 |
+
try:
|
| 187 |
+
firestore_client = db.init_firebase()
|
| 188 |
+
if firestore_client:
|
| 189 |
+
doc_ref = firestore_client.collection("ai_cache").document(cache_key)
|
| 190 |
+
doc_ref.set(
|
| 191 |
+
{"payload": value, "cached_at": datetime.now(UTC).isoformat()},
|
| 192 |
+
timeout=0.5,
|
| 193 |
+
)
|
| 194 |
+
else:
|
| 195 |
+
_record_firestore_failure()
|
| 196 |
+
except Exception as e:
|
| 197 |
+
_record_firestore_failure()
|
| 198 |
+
logger.debug(f"Firestore cache set skipped/failed: {e}")
|
| 199 |
|
| 200 |
await asyncio.to_thread(_persist_remote)
|
| 201 |
|
algospaced-ui/dist/assets/{Auth-DJq0y_UK.js → Auth-DHdm5r3r.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{B as t,H as n,K as r,Lt as i,b as a,k as o,o as s,vt as c,wt as l,zt as u}from"./vendor-react-q-oOktF_.js";import{t as d}from"./firebaseClient-BO9k8E9m.js";var f=e(u(),1),p=i();function m(){let[e,i]=(0,f.useState)(!1),[u,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)(a,{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:()=>{i(!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:()=>{i(!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(!u.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(u.trim(),h),w({type:`success`,text:`Verification email resent to ${u.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)(o,{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 n=u.trim();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)){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(n,h),w({type:`success`,text:`Registration successful! A verification link has been sent to your email. Please verify your email before logging in.`}),i(!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(n,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)(t,{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:u,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)(n,{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)(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-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)(c,{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)(c,{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)(c,{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)(c,{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)(c,{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)(l,{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{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};
|
algospaced-ui/dist/assets/{CreateProblemForm-CiTqt9b8.js → CreateProblemForm-Cej3QR08.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
| 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,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
|
algospaced-ui/dist/assets/{FileExplorer-Duw1SQGy.js → FileExplorer-CJE9LlAj.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
| 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};
|
|
|
|
| 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/GitHubSyncWindow-DHS56rys.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 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/GitHubSyncWindow-JaTkvFiz.js
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,J as n,Lt as r,Q as i,V as a,X as o,Y as s,a as c,dt as l,et as u,k as d,ot as f,pt as p,vt as m,zt as h}from"./vendor-react-q-oOktF_.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-cuWA8MAM.js";var T=e(h(),1),E=r(),D=({onClose:e,currentProblem:r})=>{let[h,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=!!(h.token&&(h.username||O?.login));(0,T.useEffect)(()=>{h.token&&!O&&y(h.token).then(e=>{e.valid&&e.user&&(k(e.user),C({username:e.user.login},e.user))})},[h.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,h.repoName,h.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(h.token){V(!0),q(null);try{let e=await g(h.token,h.repoName,h.isPrivate);C({repoName:h.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(h.token&&h.repoName){U(!0),q(null);try{let e=await _(h.token,h.repoName,h.branch);q({type:`success`,text:e.message||`Synced ${e.synced_count} solutions to ${h.repoName}!`,linkUrl:e.repo_url})}catch(e){q({type:`error`,text:e.message||`Batch sync failed.`})}finally{U(!1)}}},$=async()=>{if(!r||!h.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:h.token,repo:h.repoName,branch:h.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||h.username}),(0,E.jsxs)(`span`,{className:`text-[10px] text-trash-gray font-mono`,children:[`(@`,O?.login||h.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)(o,{className:`w-3.5 h-3.5 text-blue-600 shrink-0`}),(0,E.jsxs)(`span`,{className:`font-semibold text-ink-black`,children:[h.username||O?.login,`/`,h.repoName]}),(0,E.jsxs)(`span`,{className:`text-slate-400`,children:[`(`,h.branch,`)`]})]})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(`a`,{href:`https://github.com/${h.username||O?.login}/${h.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)(u,{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)(a,{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)(s,{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)(d,{className:`w-3 h-3 animate-spin`}):(0,E.jsx)(m,{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:h.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:h.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)(c,{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:h.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)(f,{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)(d,{className:`w-3.5 h-3.5 animate-spin text-emerald-600`}):(0,E.jsx)(n,{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)(d,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):(0,E.jsx)(o,{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)(d,{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)(u,{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)(t,{className:`w-3.5 h-3.5`}):(0,E.jsx)(i,{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)(d,{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)(m,{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)(l,{className:`w-4 h-4 shrink-0`}):(0,E.jsx)(p,{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)(u,{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-u3NVmdds.js → JourneyPath-Dpd3IPxF.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/{KatexRenderer-S2ExKuPO.js → KatexRenderer-HIhDCm0G.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import"./rolldown-runtime-hePW80VL.js";import{
|
|
|
|
| 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,`&`).replace(/</g,`<`).replace(/>/g,`>`)}</span>`}return(0,r.jsx)(`span`,{className:i,dangerouslySetInnerHTML:{__html:a}})};export{i as KatexRenderer,i as default};
|
algospaced-ui/dist/assets/{MarkdownRenderer-DrNYiC-4.js → MarkdownRenderer-BMZIn30p.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KatexRenderer-
|
| 2 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
| 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-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};
|
algospaced-ui/dist/assets/{MySQLPlayground-mwi_6A09.js → MySQLPlayground-CDRacqFf.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Lt as t,zt as n}from"./vendor-react-q-oOktF_.js";import{a as r}from"./firebaseClient-BO9k8E9m.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};
|
|
|
|
| 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};
|
algospaced-ui/dist/assets/{OnboardingModal-0y7Pme-5.js → OnboardingModal-DmgTXeeL.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Lt as t,S as n,Tt as r,_ as i,_t as a,a as o,dt as s,g as c,k as l,mt as u,o as d,rt as f,v as p,vt as m,xt as h,zt as g}from"./vendor-react-q-oOktF_.js";import{a as _,i as v,l as y,o as b}from"./index-0dH8bbro.js";var x=e(g(),1),S=t(),C=[217,242,1,49,20];function w({isOpen:e,onClose:t,onCompleted:g,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(()=>{g(),t()},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)(f,{className:`w-4 h-4 text-amber-900`}),`GET STARTED`]})]}),(0,S.jsx)(`button`,{onClick:()=>{K(),t()},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)(d,{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)(p,{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)(h,{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)(l,{className:`w-4 h-4 animate-spin`}),(0,S.jsx)(`span`,{children:`INITIALIZING...`})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(m,{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)(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-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)(r,{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)(r,{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)(n,{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)(d,{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,o=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:o?(0,S.jsx)(u,{className:`w-3.5 h-3.5`}):(0,S.jsx)(a,{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)(i,{className:`w-3 h-3 text-emerald-600`}),(0,S.jsx)(`span`,{children:`DESELECT ALL`})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(c,{className:`w-3 h-3 text-slate-500`}),(0,S.jsx)(`span`,{children:`SELECT ALL`})]})})]}),o&&(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)(i,{className:`w-4 h-4 text-emerald-600 stroke-[2.5]`}):(0,S.jsx)(c,{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)(n,{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)(s,{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(()=>{g(),t()},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)(l,{className:`w-3.5 h-3.5 animate-spin`}),(0,S.jsx)(`span`,{children:`ENROLLING...`})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{className:`w-3.5 h-3.5 text-amber-900`}),(0,S.jsxs)(`span`,{children:[`ENROLL `,D.size,` PROBLEMS (FSRS)`]})]})})]})]})]})]})})}export{w as default};
|
|
|
|
| 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-RGzNhS6w.js → PrincessChamber-5t89aBn-.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{D as n,F as r,H as i,Lt as a,O as o,a as s,c,dt as l,f as u,o as d,s as f,st as p,v as m,w as h,x as g,xt as _,yt as v,zt as y}from"./vendor-react-q-oOktF_.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-0dH8bbro.js";var O=t(y(),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:s,onSelectChoice:l,onSendMessage:u,onTypingStatusChange:p,currentFloor:g,bondTier:_,satchelCount:y=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)(()=>{p?.(K)},[K,p]);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||(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]&&!i&&!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`){!i&&!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,i,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)(v,{className:`w-3 h-3 text-amber-400`}),(0,j.jsxs)(`span`,{children:[g,`/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)(h,{className:`w-3 h-3 text-amber-400`}),(0,j.jsx)(`span`,{className:`hidden sm:inline`,children:`Satchel`}),y>0&&(0,j.jsxs)(`span`,{className:`text-[9px] text-[#f3cb65]`,children:[`(`,y,`)`]})]}),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)(o,{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)(c,{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)(d,{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:[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`})]}),s&&s.length>0&&!i&&(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)(m,{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:()=>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&&!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)(v,{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)(d,{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:a,recentToolTelemetry:o,onRemoveCodexItem:c,onClose:f}){let[v,y]=(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)(h,{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)(d,{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:()=>y(`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 ${v===`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)(h,{className:`w-3.5 h-3.5`}),(0,j.jsxs)(`span`,{children:[`Missives (`,e.length,`/5)`]})]}),(0,j.jsxs)(`button`,{type:`button`,onClick:()=>y(`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 ${v===`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)(_,{className:`w-3.5 h-3.5`}),(0,j.jsxs)(`span`,{children:[`Chronicles (`,t.length,`)`]})]}),(0,j.jsxs)(`button`,{type:`button`,onClick:()=>y(`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 ${v===`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)(m,{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:[v===`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,a=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?a?`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)(i,{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)(i,{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.`})]})]}),v===`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)(_,{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.`})]})}),v===`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)(m,{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)(l,{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)(d,{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)(g,{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)(d,{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)(u,{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.`})]}),a&&a.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:[a.length,` events`]})]}),(0,j.jsx)(`div`,{className:`flex flex-col gap-2 max-h-40 overflow-y-auto custom-scrollbar`,children:a.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)(s,{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:[o?.length||0,` executed`]})]}),o&&o.length>0?(0,j.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-36 overflow-y-auto custom-scrollbar`,children:o.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:r=!0,onFocus:i,zIndex:a}){let s=E(),[c,l]=(0,O.useState)(w()),[u,f]=(0,O.useState)(!1),[p,m]=(0,O.useState)(!1),[h,g]=(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=!c;l(e),S(e)},[c]),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)(()=>[...s.transcript].reverse().find(e=>e.sender===`princess`)||s.transcript[0],[s.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||(s.isLoading?``:A):A,P=(0,O.useMemo)(()=>k?.choiceSuggestions&&k.choiceSuggestions.length>0?k.choiceSuggestions:[...s.transcript].reverse().find(e=>e.sender===`princess`&&e.choiceSuggestions&&e.choiceSuggestions.length>0)?.choiceSuggestions,[k,s.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:s.activeEmotion,floor:s.currentFloor,rhythm:s.currentRhythm,activity:s.currentActivity,isLoading:s.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:s.companionSettings.name||`Princess Aurelia`,emotion:s.activeEmotion,text:N,isStreaming:k?.isStreaming,isLoading:s.isLoading,choices:P,toolCalls:k?.toolCalls,onSelectChoice:e=>C.sendMessage(e),onSendMessage:e=>C.sendMessage(e),onTypingStatusChange:T,currentFloor:s.currentFloor,bondTier:s.bondTier,satchelCount:s.unlockedLetters.length,isMuted:c,onToggleMute:b,onOpenProgress:()=>f(!0),onOpenSatchel:()=>m(!0),onOpenHistory:()=>g(!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`})]})]})]}),u&&(0,j.jsx)(`div`,{className:`pointer-events-auto`,children:(0,j.jsx)(I,{currentFloor:s.currentFloor,totalSolved:s.totalSolved,onClose:()=>f(!1)})}),p&&(0,j.jsx)(`div`,{className:`pointer-events-auto`,children:(0,j.jsx)(L,{unlockedLetters:s.unlockedLetters,spireChronicles:s.spireChronicles,currentFloor:s.currentFloor,heroCodex:s.heroCodex,episodicEvents:s.episodicEvents,recentToolTelemetry:s.recentToolTelemetry,onRemoveCodexItem:C.removeCodexItem,onClose:()=>m(!1)})}),h&&(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:()=>g(!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)(o,{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 (`,s.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:()=>g(!1),className:`p-1 hover:bg-[#203a55] rounded text-[#8cb4db] hover:text-white cursor-pointer transition-colors`,title:`Close`,children:(0,j.jsx)(d,{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:s.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`?s.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};
|
|
|
|
| 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/ProblemSpecPanel-CLbwqTwe.js
ADDED
|
@@ -0,0 +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};
|
algospaced-ui/dist/assets/ProblemSpecPanel-D-jlAttf.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,A as n,H as ee,Lt as r,M as i,Q as te,W as ne,Z as re,a,at as ie,bt as ae,d as o,dt as oe,f as se,k as s,nt as c,o as ce,u as l,v as u,xt as d,zt as f}from"./vendor-react-q-oOktF_.js";import{u as p}from"./index-0dH8bbro.js";import{n as m,t as h}from"./MarkdownRenderer-DrNYiC-4.js";import{n as le}from"./ReviewQueue-C2qCZU0m.js";var g=e(f(),1),_=r(),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:r,mobileView:f,isNarrow:y=!1,problem:b,parsed:x,userSolution:de,officialSolution:fe,effectiveReferenceCode:S,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,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=le(b,fe,de),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 p(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 p(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&&f!==`spec`&&f!==`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:()=>r(`spec`),className:$(e===`spec`),children:[(0,_.jsx)(re,{className:`w-3 h-3 text-purple-700 shrink-0`}),(0,_.jsx)(`span`,{children:y?`SPEC`:`SPECIFICATIONS`})]}),(0,_.jsxs)(`button`,{onClick:()=>r(`ref`),className:$(e===`ref`),children:[(0,_.jsx)(ie,{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:()=>r(`leitner`),className:$(e===`leitner`),children:[(0,_.jsx)(o,{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)(d,{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:m(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)(a,{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:()=>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,_.jsx)(c,{className:`w-2.5 h-2.5`}),C===`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: `}),m(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)(a,{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)(t,{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)(te,{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)(oe,{className:`w-4 h-4 text-emerald-700 shrink-0`}):(0,_.jsx)(l,{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)(ce,{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)(u,{className:`w-3 h-3 text-amber-300`}):(0,_.jsx)(d,{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)(n,{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)(i,{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:S}),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)(s,{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)(i,{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)(se,{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)(s,{className:`w-2.5 h-2.5 animate-spin text-purple-700`}):(0,_.jsx)(u,{className:`w-2.5 h-2.5 text-purple-600`}),(0,_.jsx)(`span`,{children:`Explain✦`})]}),(0,_.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,_.jsx)(c,{className:`w-2.5 h-2.5`}),C===`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: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,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(s,{className:`w-3.5 h-3.5 animate-spin`}),(0,_.jsx)(`span`,{children:`Generating solution...`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(u,{className:`w-3.5 h-3.5 text-amber-300`}),(0,_.jsx)(`span`,{children:`Generate solution`})]})}),D&&(0,_.jsx)(`div`,{className:`text-xs text-rose-600 font-medium`,children:D})]}),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)(h,{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)(ae,{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)(h,{content:j})})]})]})]}):null,T&&(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)(l,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,_.jsx)(`div`,{className:`flex-1`,children:T})]})]}),e===`leitner`&&(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)(ne,{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)(o,{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-B3ERHqof.js → PythonChallenge-BOgiGe52.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
|
|
| 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};
|
algospaced-ui/dist/assets/ReviewQueue-C2qCZU0m.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
| 1 |
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProblemSpecPanel-D-jlAttf.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-react-q-oOktF_.js","assets/vendor-codemirror-By0wlJeM.js","assets/index-0dH8bbro.js","assets/firebaseClient-BO9k8E9m.js","assets/vendor-firebase-DSIO3PIf.js","assets/vendor-ui-ZXcm-2wU.js","assets/index-supjX07i.css","assets/MarkdownRenderer-DrNYiC-4.js"])))=>i.map(i=>d[i]);
|
| 2 |
-
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{D as n,Lt as r,M as i,St as a,T as o,X as s,Z as c,_t as l,a as u,at as d,dt as f,et as p,f as m,ht as h,j as g,k as _,l as v,lt as y,q as ee,rt as b,t as x,u as S,ut as C,v as w,vt as T,xt as E,zt as D}from"./vendor-react-q-oOktF_.js";import{a as O}from"./firebaseClient-BO9k8E9m.js";import{b as k,c as A,n as j,o as M,r as N,s as P,t as F}from"./index-0dH8bbro.js";import{o as I,r as L}from"./githubSyncService-cuWA8MAM.js";import{t as R}from"./confetti.module-Uxh4CK4s.js";import z from"./OnboardingModal-0y7Pme-5.js";import"./MarkdownRenderer-DrNYiC-4.js";import"./PrincessChamber-RGzNhS6w.js";import{A as B,C as te,I as V,S as H,p as U,t as ne,x as re,y as ie}from"./vendor-codemirror-By0wlJeM.js";var W=t(D(),1),G=r();function ae(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 oe(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 se(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 ce({overrideProblemId:e,refreshTrigger:t,onClearOverride:n,onOpenOnboarding:r,setIsOnboardingOpen:i}){let[a,o]=(0,W.useState)([]),[s,c]=(0,W.useState)(!0),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(null),[y,ee]=(0,W.useState)(!1),[b,x]=(0,W.useState)(void 0),S=(0,W.useRef)(!1),C=(0,W.useRef)(r),w=(0,W.useRef)(i),T=(0,W.useRef)(n),E=(0,W.useRef)(!1);(0,W.useEffect)(()=>{C.current=r,w.current=i,T.current=n});let D=(0,W.useCallback)(()=>{C.current?C.current():w.current&&w.current(!0)},[]),j=(0,W.useCallback)(async(t=!0)=>{t?(c(!0),m(null),g(``),S.current=!1):m(null);try{let{data:{session:n}}=await O.auth.getSession(),r=n?n.access_token:`sandbox`;n?.user?.id&&x(n.user.id);let i={Authorization:`Bearer ${r}`},a=await fetch(`/api/reviews/due`,{headers:i}),s=a.ok?await a.json():[];if(Array.isArray(s)||(s=[]),e){let t=String(e).trim().toLowerCase(),n=s.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]=s.splice(n,1);s.unshift(e)}else if(n===-1){let t=null,n=await fetch(`/api/reviews/problems/id/${e}`,{headers:i});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=N(n?parseInt(e,10):void 0,e);if(r)try{let e=await A(r);if(e?.problem_id){let n=await fetch(`/api/reviews/problems/id/${e.problem_id}`,{headers:i});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&&s.unshift(t)}}o(s);let c=n?.user?.id,l=c===`sandbox-user-id`||!c?`sandbox`:c;if(!localStorage.getItem(`algospaced_onboarding_done_${l}`)&&!e&&D(),s&&s.length>0){if(t){let e=s[0],t=e.problems,n=t?.problem_number??(/^\d+$/.test(e?.problem_id||``)?parseInt(e.problem_id,10):void 0),r=N(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:i});if(e.ok){let t=await e.json();v(P(new Set(t))??null)}else v(P(new Set)??null)}catch{v(P(new Set)??null)}}catch(e){console.error(`Error fetching review queue:`,e)}finally{c(!1)}},[e,D]);(0,W.useEffect)(()=>{if(E.current){E.current=!1;return}let e=!1,t=setTimeout(()=>{e||j(!0)},0);return()=>{e=!0,clearTimeout(t)}},[j,t]),(0,W.useEffect)(()=>{if(!s&&a.length===0&&!e&&!S.current){S.current=!0;try{R({particleCount:90,spread:70,origin:{y:.6}})}catch{}}},[s,a.length,e]);let M=(0,W.useCallback)(async t=>{if(a.length===0||l)return;let n=a[0];if(!n||!n.id)return;u(!0),f(t),m(null);let r=[...a];try{let{data:{session:i}}=await O.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`,k.addReviewEvent(a,r,i).catch(()=>{});let s=L(),c=h.trim()||n?.problems?.reference_code||``;s.token&&s.repoName&&s.autoCommit&&c&&I({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&&T.current&&(E.current=!0,T.current()),o(e=>{let t=e.slice(1);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=N(r,n?.id||e?.problem_id,n?.name)?.starter_code||n?.starter_code||``;g(i)}else g(``);return t}),j(!1)}else{let e=await s.json().catch(()=>({}));m(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.`;m(t),o(r)}finally{u(!1),f(null)}},[a,l,e,j,h]),F=(0,W.useCallback)(async()=>{if(_&&!y){ee(!0);try{await A(_),await j()}catch(e){console.error(`Failed to activate next milestone:`,e)}finally{ee(!1)}}},[_,y,j]),z=(0,W.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=N(n,t?.id||e?.problem_id,t?.name)?.starter_code||t?.starter_code||``;g(r)},[a]);return{reviews:a,setReviews:o,loading:s,submitting:l,submittingRating:d,gradeError:p,setGradeError:m,code:h,setCode:g,nextMilestone:_,activatingMilestone:y,currentUserId:b,fetchQueue:j,handleGrade:M,handleSelectCard:(0,W.useCallback)(t=>{if(t<=0||t>=a.length||l)return;e&&T.current&&(E.current=!0,T.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=N(i,r?.id||n?.problem_id,r?.name)?.starter_code||r?.starter_code||``;g(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,l,e]),handleActivateNextMilestone:F,handleResetStarterCode:z}}function le(){return{sandboxRunning:j(e=>e.sandboxRunning),sandboxResults:j(e=>e.sandboxResults),sandboxError:j(e=>e.sandboxError),savingReference:j(e=>e.savingReference),savedRefSuccess:j(e=>e.savedRefSuccess),saveRefError:j(e=>e.saveRefError),handleRunSandbox:j(e=>e.handleRunSandbox),handleSaveReference:j(e=>e.handleSaveReference),resetSandbox:j(e=>e.resetSandbox)}}function ue(){return{aiLoading:j(e=>e.aiLoading),aiResult:j(e=>e.aiResult),aiError:j(e=>e.aiError),explainLoading:j(e=>e.explainLoading),explanationText:j(e=>e.explanationText),explainError:j(e=>e.explainError),aiSolutionLoading:j(e=>e.aiSolutionLoading),aiSolutionError:j(e=>e.aiSolutionError),handleAiEvaluation:j(e=>e.handleAiEvaluation),handleExplainCode:j(e=>e.handleExplainCode),handleFetchAiSolution:j(e=>e.handleFetchAiSolution),resetAiState:j(e=>e.resetAiState)}}var de=({problem:e,totalInQueue:t,reviews:n=[],onSelectCard:r,onOpenCreateProblem:a,onOpenEditProblem:o})=>{let[s,c]=(0,W.useState)(!1),u=(0,W.useRef)(null);(0,W.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,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap min-w-0`,children:[(0,G.jsxs)(`div`,{className:`relative shrink-0`,ref:u,children:[(0,G.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,G.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-emerald-500 animate-ping shrink-0`}),(0,G.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,G.jsx)(l,{className:`w-3 h-3 text-ink-black transition-transform shrink-0 ${s?`rotate-180`:``}`})]}),s&&n.length>0&&(0,G.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,G.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,G.jsx)(`span`,{children:`DAILY QUEUE (${n.length} CARDS)`}),(0,G.jsx)(`button`,{onClick:()=>c(!1),className:`px-1 hover:text-rose-600 font-bold cursor-pointer`,title:`Close`,children:`✕`})]}),(0,G.jsx)(`div`,{className:`text-[7.5px] font-arcade text-trash-gray uppercase -mt-0.5`,children:`Click any card to solve it now:`}),(0,G.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:M(i),{cleanTitle:o,approachVariant:s}=oe(n?.name||``,a?.name),l=s?`${o} (${s})`:o,u=t===0,d=n?.difficulty,f=d?d.toUpperCase():`EASY`,p=d===`Easy`?`bg-emerald-600 text-white`:d===`Medium`?`bg-amber-400 text-ink-black`:`bg-rose-600 text-white`;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{u||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 ${u?`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:u?`Currently active card`:`Jump to #${t+1}: ${l}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 truncate min-w-0`,children:[(0,G.jsxs)(`span`,{className:`font-arcade text-[9px] text-trash-gray shrink-0`,children:[`#`,t+1]}),i!=null&&(0,G.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,G.jsx)(`span`,{className:`truncate`,children:l})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[u?(0,G.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,G.jsx)(g,{className:`w-2.5 h-2.5 fill-ink-black text-ink-black opacity-0 group-hover:opacity-100 transition-opacity shrink-0`}),(0,G.jsx)(`span`,{className:`text-[8px] font-arcade font-bold px-1.5 py-0.5 border border-ink-black shrink-0 ${p}`,children:f})]})]},e.id||t)})})]})]}),e.problem_number!==void 0&&e.problem_number!==null&&(0,G.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,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 flex-wrap justify-end`,children:[(0,G.jsxs)(`button`,{onClick:a,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,G.jsx)(C,{className:`w-3 h-3 text-purple-600 shrink-0`}),(0,G.jsx)(`span`,{className:`hidden min-[480px]:inline`,children:`ADD`})]}),o&&(0,G.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,G.jsx)(i,{className:`w-3 h-3 text-emerald-600 shrink-0`}),(0,G.jsx)(`span`,{className:`hidden min-[480px]:inline`,children:`EDIT`})]}),e.google_doc_url&&(0,G.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,G.jsx)(`span`,{children:`DOC`}),(0,G.jsx)(p,{className:`w-2.5 h-2.5 text-primary shrink-0`})]}),(0,G.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,G.jsx)(`span`,{children:`LC`}),(0,G.jsx)(p,{className:`w-2.5 h-2.5 text-amber-600 shrink-0`})]})]})]})},fe=re.mark({class:`cm-indent-dot cm-indent-dot-primary`}),pe=re.mark({class:`cm-indent-dot cm-indent-dot-secondary`});function me(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?fe:pe),a++}i=n.to+1}}return t.finish()}var he=te.fromClass(class{decorations;constructor(e){this.decorations=me(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=me(e.view))}},{decorations:e=>e.decorations}),ge=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`}}),K=[ne(),ie.of(` `),B.of([U]),he,ge,H.contentAttributes.of({"aria-label":`Python Code Editor`})],_e=[{id:`python`,name:`Python`,version:`3.14`}],ve=({className:e=`w-3.5 h-3.5`})=>(0,G.jsxs)(`svg`,{viewBox:`0 0 128 128`,className:e,xmlns:`http://www.w3.org/2000/svg`,children:[(0,G.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,G.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`})]}),ye=({mobileView:e,isNarrow:t=!1,isAutocompleteEnabled:r,onToggleAutocomplete:i,onResetStarterCode:c,code:u,onChangeCode:d,sandboxRunning:h,sandboxError:v,sandboxResults:b,onRunSandbox:C,savingReference:E,savedRefSuccess:D,saveRefError:O,onSaveReference:k,aiLoading:A,aiError:j,aiResult:M,onAiEvaluation:N,optimalTime:P,optimalSpace:F,onPushToGitHub:I,pushingToGitHub:L,githubPushedUrl:R,githubPushError:z})=>{let[B,te]=(0,W.useState)(`python`),[V,H]=(0,W.useState)(!1),U=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=e=>{U.current&&!U.current.contains(e.target)&&H(!1)},t=e=>{e.key===`Escape`&&H(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[]);let ne=_e.find(e=>e.id===B)??_e[0];return(0,G.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,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 flex-wrap`,children:[(0,G.jsxs)(`div`,{className:`relative`,ref:U,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>H(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":V,"aria-haspopup":`listbox`,children:[(0,G.jsx)(ve,{className:`w-3.5 h-3.5 shrink-0`}),(0,G.jsx)(`span`,{children:ne.name}),(0,G.jsx)(l,{className:`w-3 h-3 text-ink-black transition-transform duration-150 ${V?`rotate-180`:``}`})]}),V&&(0,G.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,G.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`}),_e.map(e=>{let t=B===e.id;return(0,G.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>{te(e.id),H(!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,G.jsxs)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[9px]`,children:[(0,G.jsx)(ve,{className:`w-3.5 h-3.5 shrink-0`}),(0,G.jsx)(`span`,{children:e.name})]}),(0,G.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,G.jsx)(`div`,{className:`h-4 w-[2px] bg-slate-300 mx-0.5 hidden sm:block`}),(0,G.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`sr-only peer`,"aria-label":`Toggle code editor autocompletion`}),(0,G.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,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,G.jsx)(`button`,{onClick:c,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,G.jsx)(n,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{onClick:()=>d(``),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,G.jsx)(m,{className:`w-3.5 h-3.5 text-rose-600`})}),k&&(0,G.jsx)(`button`,{onClick:k,disabled:E||!u.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 ${D?`bg-emerald-600 hover:bg-emerald-500 text-white`:`bg-amber-400 hover:bg-amber-300 text-ink-black`}`,title:E?`Saving solution to personal database...`:D?`Saved to personal database!`:`Overwrite saved solution with studio code`,"aria-label":`Overwrite saved solution with studio code`,children:E?(0,G.jsx)(_,{className:`w-3.5 h-3.5 animate-spin text-ink-black`}):D?(0,G.jsx)(f,{className:`w-3.5 h-3.5 text-white`}):(0,G.jsx)(o,{className:`w-3.5 h-3.5 text-ink-black`})}),I&&(0,G.jsx)(`button`,{onClick:I,disabled:L||!u.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:L?`Pushing to GitHub...`:`Push solution to GitHub repository`,"aria-label":`Push to GitHub`,children:L?(0,G.jsx)(_,{className:`w-3.5 h-3.5 animate-spin text-yellow-300`}):(0,G.jsx)(s,{className:`w-3.5 h-3.5 text-yellow-300`})})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,G.jsx)(`button`,{onClick:C,disabled:h||!u.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:h?`Running sandbox tests...`:`Run tests in local sandbox`,"aria-label":`Run tests`,children:h?(0,G.jsx)(_,{className:`w-3.5 h-3.5 animate-spin`}):(0,G.jsx)(g,{className:`w-3.5 h-3.5 fill-white text-white ml-0.5`})}),(0,G.jsx)(`button`,{onClick:N,disabled:A||!u.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,G.jsx)(_,{className:`w-3.5 h-3.5 animate-spin`}):(0,G.jsx)(w,{className:`w-3.5 h-3.5 text-amber-300`})})]})]}),(0,G.jsxs)(`div`,{className:`p-4 sm:p-5 flex-1 flex flex-col space-y-4`,children:[(0,G.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,G.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,G.jsx)(x,{value:u,onChange:d,placeholder:`def solve(nums):
|
| 5 |
-
# Write your solution from memory here...`,height:`100%`,theme:`dark`,extensions:K,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`})})}),D&&(0,G.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,G.jsx)(f,{className:`w-4 h-4 text-emerald-600 shrink-0`}),(0,G.jsx)(`span`,{children:`Successfully saved studio code as your personal reference solution!`})]}),O&&(0,G.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,G.jsx)(S,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,G.jsx)(`span`,{children:O})]}),R&&(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(f,{className:`w-4 h-4 text-emerald-600 shrink-0`}),(0,G.jsx)(`span`,{children:`Successfully pushed solution to your GitHub repository!`})]}),(0,G.jsxs)(`a`,{href:R,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,G.jsx)(`span`,{children:`View on GitHub`}),(0,G.jsx)(p,{className:`w-3 h-3`})]})]}),z&&(0,G.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,G.jsx)(S,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,G.jsx)(`span`,{children:z})]}),h&&(0,G.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,G.jsx)(_,{className:`w-5 h-5 text-emerald-600 animate-spin shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:`Running...`}),(0,G.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray font-semibold mt-0.5`,children:`Executing against test cases...`})]})]}),v&&(0,G.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,G.jsx)(S,{className:`w-4 h-4 text-rose-600 shrink-0`}),(0,G.jsx)(`span`,{children:v})]}),b&&(0,G.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 ${b.status===`passed`?`bg-[#f0fdf4]`:`bg-[#fff1f2]`}`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,G.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)] ${b.status===`passed`?`bg-grass-green text-ink-black`:`bg-rose-500 text-white`}`,children:b.status===`passed`?(0,G.jsx)(T,{className:`w-5 h-5 stroke-[3]`}):(0,G.jsx)(S,{className:`w-4 h-4`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-arcade text-[10px] font-bold text-ink-black flex items-center gap-1.5 uppercase`,children:b.status===`passed`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`ALL TESTS PASSED`}),(0,G.jsx)(f,{className:`w-3.5 h-3.5 text-emerald-600 inline`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:b.status===`error`?`EXECUTION ERROR`:`TESTS FAILED`}),(0,G.jsx)(y,{className:`w-3.5 h-3.5 text-rose-600 inline`})]})}),(0,G.jsxs)(`div`,{className:`font-sans text-[11px] text-slate-600 font-semibold`,children:[b.passed_count??0,` of `,b.total_tests??0,` test cases passed (`,(b.duration_ms??0).toFixed(1),`ms)`]})]})]}),b.status===`passed`&&(0,G.jsxs)(`button`,{onClick:k,disabled:E,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:[E?(0,G.jsx)(_,{className:`w-3 h-3 animate-spin`}):D?(0,G.jsx)(f,{className:`w-3.5 h-3.5 text-emerald-600`}):(0,G.jsx)(o,{className:`w-3.5 h-3.5 text-blue-600`}),(0,G.jsx)(`span`,{children:D?`SAVED TO DB!`:`SAVE AS OFFICIAL SOLUTION`})]})]}),O&&(0,G.jsx)(`div`,{className:`p-2 border border-rose-500 bg-rose-100 text-rose-800 text-[11px] font-semibold`,children:O}),b.results&&b.results.length>0&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray uppercase font-bold block`,children:`TEST CASE BREAKDOWN:`}),(0,G.jsx)(`div`,{className:`space-y-1.5 max-h-56 overflow-y-auto custom-scrollbar`,children:b.results.map((e,t)=>(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between font-arcade text-[8px] mb-1`,children:[(0,G.jsxs)(`span`,{className:`font-bold text-ink-black`,children:[`CASE #`,t+1]}),(0,G.jsx)(`span`,{className:e.passed?`text-emerald-700 font-bold`:`text-rose-700 font-bold`,children:e.passed?`✓ PASSED`:`✗ FAILED`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-1.5 text-[10px]`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-slate-500 block`,children:`Input:`}),(0,G.jsx)(`span`,{className:`font-code-mono text-ink-black font-semibold break-all`,children:JSON.stringify(e.input)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-slate-500 block`,children:`Expected:`}),(0,G.jsx)(`span`,{className:`font-code-mono text-emerald-700 font-semibold break-all`,children:JSON.stringify(e.expected)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-slate-500 block`,children:`Output:`}),(0,G.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,G.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))})]}),b.error&&(0,G.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:b.error}),b.status===`passed`&&(0,G.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,G.jsx)(`span`,{className:`font-sans font-medium`,children:`✨ All unit tests passed. Rate your recall below.`})})]}),A&&(0,G.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,G.jsx)(_,{className:`w-6 h-6 text-purple-600 animate-spin shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-arcade text-[9px] font-bold text-ink-black uppercase`,children:`ANALYZING...`}),(0,G.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,G.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,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between pb-3 border-b-2 border-dashed border-ink-black`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.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,G.jsx)(T,{className:`w-5 h-5 stroke-[3]`}):(0,G.jsx)(a,{className:`w-5 h-5`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`font-arcade text-[10px] font-bold text-ink-black flex items-center gap-1.5`,children:M.is_correct?(0,G.jsxs)(G.Fragment,{children:[`STATUS: PASSED`,(0,G.jsx)(f,{className:`w-3.5 h-3.5 text-emerald-600 inline`})]}):(0,G.jsxs)(G.Fragment,{children:[`STATUS: FAILED`,(0,G.jsx)(y,{className:`w-3.5 h-3.5 text-rose-600 inline`})]})}),(0,G.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,G.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,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.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,G.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase font-bold`,children:`Time Complexity`}),(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 mt-1`,children:[(0,G.jsx)(`span`,{className:`font-code-mono text-xs font-bold text-ink-black`,children:M.detected_complexity?.time||`N/A`}),(0,G.jsxs)(`span`,{className:`text-[10px] font-sans text-slate-500 font-semibold`,children:[`(Target: `,P||`O(N)`,`)`]})]})]}),(0,G.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,G.jsx)(`span`,{className:`font-arcade text-[8px] text-trash-gray block uppercase font-bold`,children:`Space Complexity`}),(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 mt-1`,children:[(0,G.jsx)(`span`,{className:`font-code-mono text-xs font-bold text-ink-black`,children:M.detected_complexity?.space||`N/A`}),(0,G.jsxs)(`span`,{className:`text-[10px] font-sans text-slate-500 font-semibold`,children:[`(Target: `,F||`O(1)`,`)`]})]})]})]}),M.bugs&&M.bugs.length>0&&(0,G.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,G.jsxs)(`span`,{className:`font-arcade text-[8px] text-rose-600 uppercase font-bold block flex items-center gap-1`,children:[(0,G.jsx)(S,{className:`w-3 h-3 text-rose-500`}),`TRACES & EDGE CASE ISSUES:`]}),(0,G.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,G.jsx)(`li`,{className:`leading-relaxed select-text`,children:e},t))})]}),M.key_suggestion&&(0,G.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,G.jsxs)(`span`,{className:`font-arcade text-[8px] text-amber-700 uppercase font-bold block flex items-center gap-1`,children:[(0,G.jsx)(w,{className:`w-3 h-3 text-amber-500`}),`TIP:`]}),(0,G.jsx)(`p`,{className:`text-xs text-slate-800 font-medium leading-relaxed m-0 select-text`,children:M.key_suggestion})]}),(0,G.jsxs)(`div`,{className:`p-2.5 bg-white border-2 border-dashed border-ink-black flex items-center justify-between`,children:[(0,G.jsxs)(`span`,{className:`text-xs font-bold text-ink-black flex items-center gap-1.5`,children:[(0,G.jsx)(ee,{className:`w-4 h-4 text-primary`}),`Recommendation:`]}),(0,G.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.`})]})]})]})]})},be=({gradeError:e,onDismissGradeError:t,submitting:n,submittingRating:r,onGrade:i})=>(0,G.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,G.jsxs)(`div`,{className:`w-full flex flex-col`,children:[e&&(0,G.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,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(S,{className:`w-4 h-4 text-red-600 shrink-0`}),e]}),(0,G.jsx)(`button`,{onClick:t,className:`text-red-900 font-bold hover:underline cursor-pointer ml-2 text-xs`,children:`Dismiss`})]}),(0,G.jsxs)(`div`,{className:`flex gap-1.5 sm:gap-2.5 w-full`,children:[(0,G.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,G.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,G.jsx)(_,{className:`w-3.5 h-3.5 animate-spin`})}):(0,G.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,G.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/20 rounded shrink-0`,children:`1`}),(0,G.jsx)(`span`,{className:`truncate`,children:`Again`})]})}),(0,G.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,G.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,G.jsx)(_,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,G.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,G.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`2`}),(0,G.jsx)(`span`,{className:`truncate`,children:`Hard`})]})}),(0,G.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,G.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,G.jsx)(_,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,G.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,G.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`3`}),(0,G.jsx)(`span`,{className:`truncate`,children:`Good`})]})}),(0,G.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,G.jsx)(`div`,{className:`flex items-center gap-1.5 font-arcade text-[10px]`,children:(0,G.jsx)(_,{className:`w-3.5 h-3.5 animate-spin text-ink-black`})}):(0,G.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,G.jsx)(`span`,{className:`font-arcade text-[8px] sm:text-[9px] px-1 py-0.5 bg-black/10 rounded shrink-0`,children:`4`}),(0,G.jsx)(`span`,{className:`truncate`,children:`Easy`})]})})]})]})}),xe=({nextMilestone:e,activatingMilestone:t,onActivateNextMilestone:r,onOpenOnboarding:i,onOpenJourney:a,onOpenCreateProblem:o,onOpenWindow:s,overrideProblemId:c,onClearOverride:l,hasCustomOnboardingModal:d,isOnboardingOpen:f,onCloseOnboarding:p,onCompletedOnboarding:m,currentUserId:g})=>(0,G.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] p-6 overflow-y-auto custom-scrollbar`,children:(0,G.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,G.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,G.jsxs)(`div`,{className:`relative inline-block mt-2`,children:[(0,G.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,G.jsx)(v,{className:`w-10 h-10 text-ink-black stroke-[2.5]`})}),(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.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,G.jsx)(T,{className:`w-3 h-3 stroke-[3]`}),` ALL CARDS COMPLETED FOR TODAY`]}),(0,G.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,G.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,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-amber-800 uppercase tracking-wider flex items-center gap-1.5`,children:[(0,G.jsx)(b,{className:`w-3.5 h-3.5 text-amber-600`}),`NEXT UNEXPLORED MILESTONE`]}),(0,G.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,G.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black truncate`,children:e.name}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 flex-wrap`,children:[(0,G.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,G.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,G.jsxs)(`span`,{className:`text-[11px] font-code-mono text-slate-600`,children:[`T: `,e.time_complexity,` | S: `,e.space_complexity]})]})]}),(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_,{className:`w-3.5 h-3.5 animate-spin`}),(0,G.jsx)(`span`,{children:`ACTIVATING...`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(w,{className:`w-3.5 h-3.5 text-amber-700`}),(0,G.jsx)(`span`,{children:`ACTIVATE & REVIEW NOW`})]})})]})]}),(0,G.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,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsxs)(`span`,{className:`font-arcade text-[9px] font-bold text-amber-900 uppercase flex items-center gap-1.5`,children:[(0,G.jsx)(u,{className:`w-3.5 h-3.5 text-amber-700`}),`FAST-TRACK EXPEDITION ENROLLMENT`]}),(0,G.jsx)(`h3`,{className:`font-headline-md text-base sm:text-lg font-bold text-ink-black`,children:`Already Solved Problems Elsewhere?`}),(0,G.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,G.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,G.jsx)(u,{className:`w-3.5 h-3.5 text-amber-900`}),(0,G.jsx)(`span`,{children:`OPEN 150-PROBLEM CHECKLIST`})]})]}),(0,G.jsxs)(`div`,{className:`border-t-[3px] border-dashed border-ink-black pt-5 space-y-3`,children:[(0,G.jsx)(`div`,{className:`text-[9px] font-arcade text-trash-gray uppercase font-bold text-left`,children:`CONTINUE PRACTICING:`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2.5`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(b,{className:`w-4 h-4 text-amber-600`}),(0,G.jsx)(h,{className:`w-3 h-3 text-ink-black`})]}),(0,G.jsxs)(`div`,{className:`mt-2`,children:[(0,G.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Journey Trail`}),(0,G.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`150 Curated nodes`})]})]}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(C,{className:`w-4 h-4 text-purple-700`}),(0,G.jsx)(h,{className:`w-3 h-3 text-ink-black`})]}),(0,G.jsxs)(`div`,{className:`mt-2`,children:[(0,G.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Add Problem`}),(0,G.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`New LeetCode entry`})]})]}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`material-symbols-outlined text-amber-600 text-lg`,children:`castle`}),(0,G.jsx)(h,{className:`w-3 h-3 text-ink-black`})]}),(0,G.jsxs)(`div`,{className:`mt-2`,children:[(0,G.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`Princess Tower`}),(0,G.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`Visit Aurelia`})]})]}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(E,{className:`w-4 h-4 text-cyan-700`}),(0,G.jsx)(h,{className:`w-3 h-3 text-ink-black`})]}),(0,G.jsxs)(`div`,{className:`mt-2`,children:[(0,G.jsx)(`div`,{className:`font-arcade text-[8px] font-bold text-ink-black uppercase`,children:`File Explorer`}),(0,G.jsx)(`div`,{className:`font-sans text-[10px] text-trash-gray font-semibold`,children:`Browse all files`})]})]})]})]}),c&&l&&(0,G.jsxs)(`button`,{onClick:l,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,G.jsx)(n,{className:`w-3.5 h-3.5`}),` Return to Scheduled Queue`]}),!d&&(0,G.jsx)(z,{isOpen:f,onClose:p,onCompleted:m,userId:g})]})}),Se=e({default:()=>we}),Ce=(0,W.lazy)(()=>F(()=>import(`./ProblemSpecPanel-D-jlAttf.js`).then(e=>({default:e.ProblemSpecPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])));function we({overrideProblemId:e,onClearOverride:t,onOpenWindow:n,onOpenJourney:r,onOpenCreateProblem:i,onOpenEditProblem:a,onOpenOnboarding:o,refreshTrigger:s}){let[l,u]=(0,W.useState)(null),f=l!==null&&l<780,[p,m]=(0,W.useState)(`spec`),[h,g]=(0,W.useState)(`spec`),[v,y]=(0,W.useState)(null),ee=(0,W.useCallback)(e=>{e&&(u(e.clientWidth),new ResizeObserver(e=>{for(let t of e)u(t.contentRect.width)}).observe(e))},[]),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(()=>localStorage.getItem(`isAutocompleteEnabled`)!==`false`),{reviews:w,setReviews:T,loading:D,submitting:O,submittingRating:k,gradeError:A,setGradeError:j,code:M,setCode:P,nextMilestone:F,activatingMilestone:R,currentUserId:B,fetchQueue:te,handleGrade:V,handleSelectCard:H,handleActivateNextMilestone:U,handleResetStarterCode:ne}=ce({overrideProblemId:e,refreshTrigger:s,onClearOverride:t,onOpenOnboarding:o,setIsOnboardingOpen:x}),{sandboxRunning:re,sandboxResults:ie,sandboxError:se,savingReference:fe,savedRefSuccess:pe,saveRefError:me,handleRunSandbox:he,handleSaveReference:ge,resetSandbox:K}=le(),{aiLoading:_e,aiResult:ve,aiError:Se,explainLoading:we,explanationText:Te,explainError:Ee,aiSolutionLoading:De,aiSolutionError:Oe,handleAiEvaluation:ke,handleExplainCode:Ae,handleFetchAiSolution:je,resetAiState:q}=ue(),[Me,Ne]=(0,W.useState)(!1),[Pe,Fe]=(0,W.useState)(null),[Ie,J]=(0,W.useState)(null),Le=(0,W.useCallback)(async()=>{if(w.length===0)return;let e=w[0]?.problems||{},t=M.trim()||e.reference_code||``;if(!t){J(`Please write or save code before pushing to GitHub.`),setTimeout(()=>J(null),4e3);return}let r=L();if(!r.token){n&&n(`github`);return}Ne(!0),J(null),Fe(null);try{let n=await I({token:r.token,repo:r.repoName,branch:r.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(n.html_url),setTimeout(()=>Fe(null),8e3)}catch(e){J(e.message||`Failed to push solution to GitHub.`),setTimeout(()=>J(null),5e3)}finally{Ne(!1)}},[w,M,n]),Re=w[0]?.id||w[0]?.problem_id,ze=(0,W.useRef)(void 0);(0,W.useEffect)(()=>{Re&&ze.current!==Re&&(ze.current=Re,q(),K())},[Re,q,K]);let Y=(0,W.useCallback)(e=>{q(),K(),V(e)},[V,q,K]),Be=(0,W.useCallback)(e=>{q(),K(),H(e)},[H,q,K]);(0,W.useEffect)(()=>{let e=e=>{let t=e.target;t?.closest(`.cm-editor`)||t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable||w.length===0||O||(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,w.length,O]);let Ve=(e,t)=>{navigator.clipboard.writeText(e),y(t),setTimeout(()=>y(null),1800)},He=(0,W.useCallback)(()=>{r?r():n?.(`journey`)},[r,n]),Ue=(0,W.useCallback)(()=>{i?i():n?.(`createProblem`)},[i,n]),We=(0,W.useCallback)(()=>{o?o():x(!0)},[o]),Ge=(0,W.useCallback)(e=>{T(t=>{if(t.length===0)return t;let n=[...t],r=n[0];return r&&r.problems&&(r.problems={...r.problems,solutions:e}),n})},[T]);if(D)return(0,G.jsx)(`div`,{className:`w-full h-full flex items-center justify-center bg-[#fdf8e1] text-ink-black`,children:(0,G.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,G.jsx)(`div`,{className:`w-12 h-12 bg-amber-200 border-2 border-ink-black flex items-center justify-center animate-spin`,children:(0,G.jsx)(_,{className:`w-6 h-6 text-ink-black`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-arcade text-xs text-ink-black uppercase tracking-wider font-bold`,children:`LOADING QUEUE`}),(0,G.jsx)(`p`,{className:`font-sans text-[11px] text-trash-gray mt-1 font-semibold`,children:`Fetching scheduled FSRS review cards...`})]})]})});if(w.length===0)return(0,G.jsx)(xe,{nextMilestone:F,activatingMilestone:R,onActivateNextMilestone:U,onOpenOnboarding:We,onOpenJourney:He,onOpenCreateProblem:Ue,onOpenWindow:n,overrideProblemId:e,onClearOverride:t,hasCustomOnboardingModal:!!o,isOnboardingOpen:b,onCloseOnboarding:()=>x(!1),onCompletedOnboarding:te,currentUserId:B});let X=w[0],Z=X?.problems,Ke=Z?.problem_number??(/^\d+$/.test(X?.problem_id||``)?parseInt(X.problem_id,10):void 0),Q=N(Ke,Z?.id||X?.problem_id,Z?.name),{cleanTitle:qe,approachVariant:Je,pattern:Ye}=oe(Z?.name,Q?.name,Z?.pattern,Q?.pattern),$={...Q,...Z,id:Z?.id||Q?.id||X?.problem_id,name:qe,problem_number:Z?.problem_number??Q?.problem_number,pattern:Ye,approach_variant:Je,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},Xe=ae({...Q,...$,examples:$.examples&&$.examples.length>0?$.examples:Q?.examples,constraints:$.constraints&&(Array.isArray($.constraints)?$.constraints.length>0:$.constraints)?$.constraints:Q?.constraints}),Ze=Q?.reference_solution||``,Qe=Z?.reference_code||``,$e=Qe&&(!Ze||Qe.trim()!==Ze.trim())?Qe:``,et=$e||Ze||Qe||``;return(0,G.jsxs)(`div`,{ref:ee,className:`w-full h-full bg-[#fdf8e1] flex flex-col overflow-hidden select-none`,children:[(0,G.jsx)(de,{problem:$,totalInQueue:w.length,reviews:w,overrideProblemId:e,onSelectCard:Be,onOpenCreateProblem:Ue,onOpenEditProblem:()=>{a?a($):n?.(`editProblem`)}}),(0,G.jsxs)(`div`,{className:`${f?`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,G.jsxs)(`button`,{onClick:()=>{g(`spec`),m(`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 ${h===`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,G.jsx)(c,{className:`w-3 h-3 shrink-0`}),(0,G.jsx)(`span`,{children:`SPEC`})]}),(0,G.jsxs)(`button`,{onClick:()=>g(`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 ${h===`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,G.jsx)(d,{className:`w-3 h-3 shrink-0`}),(0,G.jsx)(`span`,{children:`CODE STUDIO`})]}),(0,G.jsxs)(`button`,{onClick:()=>{g(`ref`),m(`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 ${h===`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,G.jsx)(E,{className:`w-3 h-3 shrink-0`}),(0,G.jsx)(`span`,{children:`SOLUTION`})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 flex ${f?`flex-col`:`flex-row`} overflow-hidden min-h-0`,children:[(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-8 bg-paper-white ${f?`h-64`:`border-r-[4px] border-ink-black`} font-sans text-xs text-trash-gray select-none`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 font-arcade text-[10px] text-ink-black`,children:[(0,G.jsx)(_,{className:`w-4 h-4 animate-spin text-[#0ea5e9]`}),(0,G.jsx)(`span`,{children:`Loading Problem Spec...`})]})}),children:(0,G.jsx)(Ce,{leftTab:p,onSelectLeftTab:e=>{m(e),e===`ref`?g(`ref`):e===`spec`&&g(`spec`)},mobileView:h,isNarrow:f,problem:$,parsed:Xe,userSolution:$e,officialSolution:Ze,effectiveReferenceCode:et,copiedSnippet:v,onCopyText:Ve,saveRefError:me,aiSolutionLoading:De,aiSolutionError:Oe,onFetchAiSolution:()=>je(X,e=>{T(t=>t.map((t,n)=>n===0?{...t,problems:{...$||{},...t.problems||{},reference_code:e}}:t))}),explainLoading:we,explainError:Ee,explanationText:Te,onExplainCode:(e,t,n,r)=>Ae(X,e,t,n,r),activeReview:X,onUpdateSolutions:Ge,onEditProblem:()=>{a?a($):n?.(`editProblem`)}})}),(0,G.jsx)(ye,{mobileView:h,isNarrow:f,isAutocompleteEnabled:S,onToggleAutocomplete:e=>{C(e),localStorage.setItem(`isAutocompleteEnabled`,String(e))},onResetStarterCode:ne,code:M,onChangeCode:P,sandboxRunning:re,sandboxError:se,sandboxResults:ie,onRunSandbox:()=>he(X,M),savingReference:fe,savedRefSuccess:pe,saveRefError:me,onSaveReference:()=>ge(X,M,(e,t)=>{T(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:_e,aiError:Se,aiResult:ve,onAiEvaluation:()=>ke(X,M),optimalTime:$.optimal_time||`O(N)`,optimalSpace:$.optimal_space||`O(1)`,onPushToGitHub:Le,pushingToGitHub:Me,githubPushedUrl:Pe,githubPushError:Ie})]}),(0,G.jsx)(be,{gradeError:A,onDismissGradeError:()=>j(null),submitting:O,submittingRating:k,onGrade:Y}),!o&&(0,G.jsx)(z,{isOpen:b,onClose:()=>x(!1),onCompleted:te,userId:B})]})}export{we as default,se as n,Se as t};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
algospaced-ui/dist/assets/ReviewQueue-DmsrlLxn.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 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-ktg25RuD.js
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,D as n,G as r,Lt as i,Q as ee,T as a,X as o,a as s,b as c,dt as l,et as u,it as d,k as f,pt as p,q as m,tt as h,u as g,v as _,zt as v}from"./vendor-react-q-oOktF_.js";import{_ as te,d as y,f as ne,h as b,m as x,p as S}from"./index-0dH8bbro.js";import{a as C,i as w,n as T,r as E,s as re,t as D}from"./githubSyncService-cuWA8MAM.js";var O=e(v(),1),k=i(),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,i]=(0,O.useState)(()=>localStorage.getItem(`algospaced_custom_ai_provider`)||`default`),[v,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)(()=>y()),[R,z]=(0,O.useState)(null),[B,V]=(0,O.useState)(()=>ne().currentFloor),[H,U]=(0,O.useState)(()=>E()),[W,G]=(0,O.useState)(()=>w()),[K,q]=(0,O.useState)(!1),[J,Y]=(0,O.useState)(null),X=!!(H.token&&(H.username||W?.login)),Z=!!(v.trim()&&e!=="default"),Q=e!=="default"&&!v.trim(),$=A.find(t=>t.id===e),ie=e=>{i(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=v.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(``),i(`default`),F({type:`info`,text:`Reset to Server Default provider.`}),setTimeout(()=>F(null),3e3)},ce=()=>{x(I),z({type:`success`,text:`Princess Companion settings saved!`}),setTimeout(()=>z(null),3e3)},le=()=>{L(b),x(b),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=S();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 T();G(t);let n=E();U(n);try{await C(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(E()),G(null),Y({type:`info`,text:`Disconnected from GitHub.`}),setTimeout(()=>Y(null),3e3)},pe=e=>{re({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)(r,{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)(s,{className:`w-4 h-4 text-emerald-600 shrink-0`}):Q?(0,k.jsx)(p,{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)(g,{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)(r,{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)(u,{className:`w-3 h-3`})]})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(`input`,{type:M?`text`:`password`,value:v,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)(t,{className:`w-3.5 h-3.5`}):(0,k.jsx)(ee,{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)(c,{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)(a,{className:`w-3.5 h-3.5`}),`Save Key`]}),v&&(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)(l,{className:`w-3.5 h-3.5 shrink-0`}):P.type===`error`?(0,k.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}):(0,k.jsx)(m,{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)(n,{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)(o,{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)(u,{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)(f,{className:`w-3.5 h-3.5 animate-spin`}),(0,k.jsx)(`span`,{children:`CONNECTING...`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o,{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)(l,{className:`w-3.5 h-3.5 shrink-0`}):J.type===`error`?(0,k.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}):(0,k.jsx)(m,{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)(_,{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)(d,{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})),te(!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)(a,{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)(n,{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)(l,{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)(m,{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)(u,{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)(u,{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)(u,{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-BZMPtN_n.js → TerminalEmulator-C2zR6yON.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
|
|
| 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/{firebaseClient-BO9k8E9m.js → firebaseClient-DZobvwSx.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./vendor-firebase-DSIO3PIf.js";var f=null,p=null,m=new u;m.setCustomParameters({prompt:`select_account`});var h=`algospaced_firebase_config`,g=`algospaced_auth_session`,_=`algospaced_auth_token_`;function v(e){try{return import.meta.env?.[e]||``}catch{return``}}var y=!1;function b(e){y=e}function x(){return typeof navigator<`u`&&!navigator.onLine||y}function S(){try{let e=localStorage.getItem(h);if(e){let t=JSON.parse(e);if(t?.apiKey&&t?.projectId)return t}}catch{}return null}function C(e){if(e&&e.apiKey&&e.projectId)try{localStorage.setItem(h,JSON.stringify(e))}catch{}}function w(){try{let e=localStorage.getItem(g);if(e){let t=JSON.parse(e);if(t?.user?.id)return t}}catch{}return null}function T(e){try{localStorage.setItem(g,JSON.stringify(e))}catch{}}function E(){try{localStorage.removeItem(g)}catch{}}function D(e){try{return localStorage.getItem(`${_}${e}`)}catch{return null}}function O(e,t){try{localStorage.setItem(`${_}${e}`,t)}catch{}}function k(e){try{localStorage.removeItem(`${_}${e}`)}catch{}}async function A(e){let t=D(e.uid);if(x()&&t)return t;try{let t=await Promise.race([e.getIdToken(),new Promise((e,t)=>setTimeout(()=>t(Error(`getIdToken timed out`)),1500))]);if(t)return O(e.uid,t),t}catch(e){console.warn(`Unable to fetch fresh token (likely offline/timeout), using fallback/cached token:`,e)}return t||`offline-token`}function j(e){e&&e.apiKey&&e.projectId&&(C(e),f=n().length?d():r(e),p=c(f))}var M=S()||{apiKey:v(`VITE_FIREBASE_API_KEY`),authDomain:v(`VITE_FIREBASE_AUTH_DOMAIN`),projectId:v(`VITE_FIREBASE_PROJECT_ID`),storageBucket:v(`VITE_FIREBASE_STORAGE_BUCKET`),messagingSenderId:v(`VITE_FIREBASE_MESSAGING_SENDER_ID`),appId:v(`VITE_FIREBASE_APP_ID`),measurementId:v(`VITE_FIREBASE_MEASUREMENT_ID`)};M.apiKey&&M.projectId&&j(M);function N(){if(!p){let e=S()||{apiKey:v(`VITE_FIREBASE_API_KEY`),authDomain:v(`VITE_FIREBASE_AUTH_DOMAIN`),projectId:v(`VITE_FIREBASE_PROJECT_ID`),storageBucket:v(`VITE_FIREBASE_STORAGE_BUCKET`),messagingSenderId:v(`VITE_FIREBASE_MESSAGING_SENDER_ID`),appId:v(`VITE_FIREBASE_APP_ID`),measurementId:v(`VITE_FIREBASE_MEASUREMENT_ID`)};e.apiKey&&e.projectId&&j(e)}return p}var P={get isSandbox(){return localStorage.getItem(`algospaced_sandbox_mode`)===`true`},getInitialUser(){return this.isSandbox?{id:`sandbox-user-id`,uid:`sandbox-user-id`,email:`sandbox@algospaced.io`,displayName:`Sandbox Guest`,emailVerified:!0}:w()?.user??null},async getSession(){if(this.isSandbox)return{data:{session:{access_token:`sandbox`,user:{id:`sandbox-user-id`,uid:`sandbox-user-id`,email:`sandbox@algospaced.io`,displayName:`Sandbox Guest`,emailVerified:!0}}},error:null};let e=N();if(!e){let e=w();return e?{data:{session:e},error:null}:{data:{session:null},error:null}}if(e.currentUser){let t=e.currentUser;if(!t.emailVerified)return await a(e),E(),{data:{session:null},error:null};let n={access_token:await A(t),user:{id:t.uid,uid:t.uid,email:t.email,displayName:t.displayName,photoURL:t.photoURL,emailVerified:t.emailVerified}};return T(n),{data:{session:n},error:null}}return new Promise(t=>{let n=!1,r=setTimeout(()=>{if(!n){n=!0;let e=w();e?(console.warn(`Firebase Auth listener timed out; resolved using cached session.`),t({data:{session:e},error:null})):t({data:{session:null},error:null})}},2500),o=i(e,async i=>{if(!n){if(n=!0,clearTimeout(r),o(),i){if(!i.emailVerified){await a(e),E(),t({data:{session:null},error:null});return}let n={access_token:await A(i),user:{id:i.uid,uid:i.uid,email:i.email,displayName:i.displayName,photoURL:i.photoURL,emailVerified:i.emailVerified}};T(n),t({data:{session:n},error:null})}else{if(x()){let e=w();if(e){t({data:{session:e},error:null});return}}E(),t({data:{session:null},error:null})}}})})},async getToken(){let{data:{session:e}}=await this.getSession();return e?.access_token||null},onAuthStateChange(e){if(this.isSandbox){let t={access_token:`sandbox`,user:{id:`sandbox-user-id`,uid:`sandbox-user-id`,email:`sandbox@algospaced.io`,displayName:`Sandbox Guest`,emailVerified:!0}};return setTimeout(()=>e(`SIGNED_IN`,t),0),{data:{subscription:{unsubscribe:()=>{}}}}}let t=N();if(!t){let t=w();return t&&setTimeout(()=>e(`SIGNED_IN`,t),0),{data:{subscription:{unsubscribe:()=>{}}}}}return{data:{subscription:{unsubscribe:i(t,async n=>{if(n){if(!n.emailVerified){await a(t),E(),e(`SIGNED_OUT`,null);return}let r={access_token:await A(n),user:{id:n.uid,uid:n.uid,email:n.email,displayName:n.displayName,photoURL:n.photoURL,emailVerified:n.emailVerified}};T(r),e(`SIGNED_IN`,r)}else{if(x()){let t=w();if(t){e(`SIGNED_IN`,t);return}}E(),e(`SIGNED_OUT`,null)}})}}}},async signInWithGoogle(){if(this.isSandbox)return;let e=N();if(!e)throw Error(`Firebase Auth is not initialized.`);try{return await l(e,m)}catch(n){let r=n;if(r.code===`auth/popup-blocked`||r.code===`auth/cancelled-popup-request`)return await t(e,m);throw n}},async signInWithEmail(e,t){if(this.isSandbox)return;let n=N();if(!n)throw Error(`Firebase Auth is not initialized.`);let r=await s(n,e.trim(),t);if(!r.user.emailVerified)throw await a(n),Object.assign(Error(`Your email address is not verified yet. Please check your inbox for the verification link.`),{code:`auth/email-not-verified`});return r},async signUpWithEmail(t,n){if(this.isSandbox)return;let r=N();if(!r)throw Error(`Firebase Auth is not initialized.`);let i=await o(r,t.trim(),n);return i.user&&(await e(i.user),await a(r)),i},async resendVerificationEmail(t,n){if(this.isSandbox)return;let r=N();if(!r)throw Error(`Firebase Auth is not initialized.`);let i=await s(r,t.trim(),n);if(i.user){if(i.user.emailVerified)throw Error(`This email address is already verified. You can sign in directly.`);await e(i.user),await a(r)}},async signOut(){let e=w();if(E(),this.isSandbox){localStorage.removeItem(`algospaced_sandbox_mode`),window.location.reload();return}let t=N();if(t){t.currentUser&&k(t.currentUser.uid);try{await a(t)}catch(e){console.warn(`Error signing out from Firebase Auth:`,e)}}e?.user?.id&&k(e.user.id),e?.user?.uid&&k(e.user.uid),window.location.reload()},enterSandbox(){localStorage.setItem(`algospaced_sandbox_mode`,`true`),window.location.reload()}};typeof window<`u`&&window.addEventListener(`online`,async()=>{try{let e=v(`VITE_API_BASE_URL`),t=await fetch(`${e}/api/config`);if(t.ok){let e=await t.json();b(!1),j(e)}}catch{}let e=N();if(e?.currentUser)try{let t=await e.currentUser.getIdToken(!0);if(t){O(e.currentUser.uid,t);let n=w();n&&(n.access_token=t,T(n))}}catch{}});var F={auth:P};export{
|
|
|
|
| 1 |
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./vendor-firebase-DSIO3PIf.js";var f=null,p=null,m=new u;m.setCustomParameters({prompt:`select_account`});var h=`algospaced_firebase_config`,g=`algospaced_auth_session`,_=`algospaced_auth_token_`;function v(e){try{return import.meta.env?.[e]||``}catch{return``}}var y=!1;function b(e){y=e}function x(){return typeof navigator<`u`&&!navigator.onLine||y}function S(){try{let e=localStorage.getItem(h);if(e){let t=JSON.parse(e);if(t?.apiKey&&t?.projectId)return t}}catch{}return null}function C(e){if(e&&e.apiKey&&e.projectId)try{localStorage.setItem(h,JSON.stringify(e))}catch{}}function w(){try{let e=localStorage.getItem(g);if(e){let t=JSON.parse(e);if(t?.user?.id)return t}}catch{}return null}function T(e){try{localStorage.setItem(g,JSON.stringify(e))}catch{}}function E(){try{localStorage.removeItem(g)}catch{}}function D(e){try{return localStorage.getItem(`${_}${e}`)}catch{return null}}function O(e,t){try{localStorage.setItem(`${_}${e}`,t)}catch{}}function k(e){try{localStorage.removeItem(`${_}${e}`)}catch{}}async function A(e){let t=D(e.uid);if(x()&&t)return t;try{let t=await Promise.race([e.getIdToken(),new Promise((e,t)=>setTimeout(()=>t(Error(`getIdToken timed out`)),1500))]);if(t)return O(e.uid,t),t}catch(e){console.warn(`Unable to fetch fresh token (likely offline/timeout), using fallback/cached token:`,e)}return t||`offline-token`}function j(e){e&&e.apiKey&&e.projectId&&(C(e),f=n().length?d():r(e),p=c(f))}var M=S()||{apiKey:v(`VITE_FIREBASE_API_KEY`),authDomain:v(`VITE_FIREBASE_AUTH_DOMAIN`),projectId:v(`VITE_FIREBASE_PROJECT_ID`),storageBucket:v(`VITE_FIREBASE_STORAGE_BUCKET`),messagingSenderId:v(`VITE_FIREBASE_MESSAGING_SENDER_ID`),appId:v(`VITE_FIREBASE_APP_ID`),measurementId:v(`VITE_FIREBASE_MEASUREMENT_ID`)};M.apiKey&&M.projectId&&j(M);function N(){if(!p){let e=S()||{apiKey:v(`VITE_FIREBASE_API_KEY`),authDomain:v(`VITE_FIREBASE_AUTH_DOMAIN`),projectId:v(`VITE_FIREBASE_PROJECT_ID`),storageBucket:v(`VITE_FIREBASE_STORAGE_BUCKET`),messagingSenderId:v(`VITE_FIREBASE_MESSAGING_SENDER_ID`),appId:v(`VITE_FIREBASE_APP_ID`),measurementId:v(`VITE_FIREBASE_MEASUREMENT_ID`)};e.apiKey&&e.projectId&&j(e)}return p}var P={get isSandbox(){return localStorage.getItem(`algospaced_sandbox_mode`)===`true`},getInitialUser(){return this.isSandbox?{id:`sandbox-user-id`,uid:`sandbox-user-id`,email:`sandbox@algospaced.io`,displayName:`Sandbox Guest`,emailVerified:!0}:w()?.user??null},async getSession(){if(this.isSandbox)return{data:{session:{access_token:`sandbox`,user:{id:`sandbox-user-id`,uid:`sandbox-user-id`,email:`sandbox@algospaced.io`,displayName:`Sandbox Guest`,emailVerified:!0}}},error:null};let e=N();if(!e){let e=w();return e?{data:{session:e},error:null}:{data:{session:null},error:null}}if(e.currentUser){let t=e.currentUser;if(!t.emailVerified)return await a(e),E(),{data:{session:null},error:null};let n={access_token:await A(t),user:{id:t.uid,uid:t.uid,email:t.email,displayName:t.displayName,photoURL:t.photoURL,emailVerified:t.emailVerified}};return T(n),{data:{session:n},error:null}}return new Promise(t=>{let n=!1,r=setTimeout(()=>{if(!n){n=!0;let e=w();e?(console.warn(`Firebase Auth listener timed out; resolved using cached session.`),t({data:{session:e},error:null})):t({data:{session:null},error:null})}},2500),o=i(e,async i=>{if(!n){if(n=!0,clearTimeout(r),o(),i){if(!i.emailVerified){await a(e),E(),t({data:{session:null},error:null});return}let n={access_token:await A(i),user:{id:i.uid,uid:i.uid,email:i.email,displayName:i.displayName,photoURL:i.photoURL,emailVerified:i.emailVerified}};T(n),t({data:{session:n},error:null})}else{if(x()){let e=w();if(e){t({data:{session:e},error:null});return}}E(),t({data:{session:null},error:null})}}})})},async getToken(){let{data:{session:e}}=await this.getSession();return e?.access_token||null},onAuthStateChange(e){if(this.isSandbox){let t={access_token:`sandbox`,user:{id:`sandbox-user-id`,uid:`sandbox-user-id`,email:`sandbox@algospaced.io`,displayName:`Sandbox Guest`,emailVerified:!0}};return setTimeout(()=>e(`SIGNED_IN`,t),0),{data:{subscription:{unsubscribe:()=>{}}}}}let t=N();if(!t){let t=w();return t&&setTimeout(()=>e(`SIGNED_IN`,t),0),{data:{subscription:{unsubscribe:()=>{}}}}}return{data:{subscription:{unsubscribe:i(t,async n=>{if(n){if(!n.emailVerified){await a(t),E(),e(`SIGNED_OUT`,null);return}let r={access_token:await A(n),user:{id:n.uid,uid:n.uid,email:n.email,displayName:n.displayName,photoURL:n.photoURL,emailVerified:n.emailVerified}};T(r),e(`SIGNED_IN`,r)}else{if(x()){let t=w();if(t){e(`SIGNED_IN`,t);return}}E(),e(`SIGNED_OUT`,null)}})}}}},async signInWithGoogle(){if(this.isSandbox)return;let e=N();if(!e)throw Error(`Firebase Auth is not initialized.`);try{return await l(e,m)}catch(n){let r=n;if(r.code===`auth/popup-blocked`||r.code===`auth/cancelled-popup-request`)return await t(e,m);throw n}},async signInWithEmail(e,t){if(this.isSandbox)return;let n=N();if(!n)throw Error(`Firebase Auth is not initialized.`);let r=await s(n,e.trim(),t);if(!r.user.emailVerified)throw await a(n),Object.assign(Error(`Your email address is not verified yet. Please check your inbox for the verification link.`),{code:`auth/email-not-verified`});return r},async signUpWithEmail(t,n){if(this.isSandbox)return;let r=N();if(!r)throw Error(`Firebase Auth is not initialized.`);let i=await o(r,t.trim(),n);return i.user&&(await e(i.user),await a(r)),i},async resendVerificationEmail(t,n){if(this.isSandbox)return;let r=N();if(!r)throw Error(`Firebase Auth is not initialized.`);let i=await s(r,t.trim(),n);if(i.user){if(i.user.emailVerified)throw Error(`This email address is already verified. You can sign in directly.`);await e(i.user),await a(r)}},async signOut(){let e=w();if(E(),this.isSandbox){localStorage.removeItem(`algospaced_sandbox_mode`),window.location.reload();return}let t=N();if(t){t.currentUser&&k(t.currentUser.uid);try{await a(t)}catch(e){console.warn(`Error signing out from Firebase Auth:`,e)}}e?.user?.id&&k(e.user.id),e?.user?.uid&&k(e.user.uid),window.location.reload()},enterSandbox(){localStorage.setItem(`algospaced_sandbox_mode`,`true`),window.location.reload()}};typeof window<`u`&&window.addEventListener(`online`,async()=>{try{let e=v(`VITE_API_BASE_URL`),t=await fetch(`${e}/api/config`);if(t.ok){let e=await t.json();b(!1),j(e)}}catch{}let e=N();if(e?.currentUser)try{let t=await e.currentUser.getIdToken(!0);if(t){O(e.currentUser.uid,t);let n=w();n&&(n.access_token=t,T(n))}}catch{}});var F={auth:P};export{x as a,j as i,S as n,b as o,w as r,F as s,P as t};
|
algospaced-ui/dist/assets/{githubSyncService-cuWA8MAM.js → githubSyncService-x0Mm_uEl.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{
|
|
|
|
| 1 |
+
import{s as e}from"./firebaseClient-DZobvwSx.js";var t={TOKEN:`algospaced_github_token`,USERNAME:`algospaced_github_username`,REPO:`algospaced_github_repo`,BRANCH:`algospaced_github_branch`,AUTOCOMMIT:`algospaced_github_autocommit`,PRIVATE:`algospaced_github_private`,AVATAR:`algospaced_github_avatar`,NAME:`algospaced_github_name`};function n(){return{token:localStorage.getItem(t.TOKEN)||``,username:localStorage.getItem(t.USERNAME)||``,repoName:localStorage.getItem(t.REPO)||`algospaced-solutions`,branch:localStorage.getItem(t.BRANCH)||`main`,autoCommit:localStorage.getItem(t.AUTOCOMMIT)!==`false`,isPrivate:localStorage.getItem(t.PRIVATE)!==`false`}}function r(){let e=localStorage.getItem(t.USERNAME);return e?{login:e,name:localStorage.getItem(t.NAME)||e,avatar_url:localStorage.getItem(t.AVATAR)||``,html_url:`https://github.com/${e}`}:null}function i(e,n){e.token!==void 0&&localStorage.setItem(t.TOKEN,e.token.trim()),e.username!==void 0&&localStorage.setItem(t.USERNAME,e.username.trim()),e.repoName!==void 0&&localStorage.setItem(t.REPO,e.repoName.trim()),e.branch!==void 0&&localStorage.setItem(t.BRANCH,e.branch.trim()),e.autoCommit!==void 0&&localStorage.setItem(t.AUTOCOMMIT,String(e.autoCommit)),e.isPrivate!==void 0&&localStorage.setItem(t.PRIVATE,String(e.isPrivate)),n&&(n.login&&localStorage.setItem(t.USERNAME,n.login),n.name&&localStorage.setItem(t.NAME,n.name),n.avatar_url&&localStorage.setItem(t.AVATAR,n.avatar_url))}function a(){Object.values(t).forEach(e=>localStorage.removeItem(e))}async function o(){let e=window.open(`/api/github/oauth/login`,`algospaced_github_oauth`,`width=600,height=750,menubar=no,toolbar=no,status=no,location=no`);if(!e)throw Error(`Popup window was blocked by your browser. Please allow popups for AlgoSpaced and try again.`);let t=await new Promise((t,n)=>{let r=null,i=()=>{window.removeEventListener(`message`,a),r!==null&&(clearInterval(r),r=null)},a=e=>{if(!e.data||typeof e.data!=`object`)return;let r=e.data;r.type===`GITHUB_OAUTH_SUCCESS`?(i(),r.token&&typeof r.token==`string`?t(r.token.trim()):n(Error(`GitHub authorization succeeded but no access token was returned.`))):r.type===`GITHUB_OAUTH_ERROR`&&(i(),n(Error(r.error||`GitHub authorization was denied or encountered an error.`)))};window.addEventListener(`message`,a),r=setInterval(()=>{e.closed&&(i(),n(Error(`GitHub authorization window was closed before completing.`)))},1e3)}),r=await s(t);if(!r.valid||!r.user)throw Error(r.error||`Failed to retrieve profile with GitHub token.`);let a=r.user;return i({token:t,username:a.login,repoName:n().repoName||`algospaced-solutions`},a),{token:t,user:a}}async function s(e){let t=await fetch(`/api/github/verify`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e.trim()})});return t.ok?await t.json():{valid:!1,error:(await t.json().catch(()=>({}))).detail||`Server returned error (${t.status})`}}async function c(e,t,n=!0){let r=await fetch(`/api/github/init-repo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e.trim(),repo_name:t.trim(),private:n})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.detail||`Failed to initialize repository (${r.status})`)}return await r.json()}async function l(e){let t=await fetch(`/api/github/push-solution`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.detail||`Failed to commit solution (${t.status})`)}return await t.json()}async function u(t,n,r=`main`){let{data:{session:i}}=await e.auth.getSession(),a=i?`Bearer ${i.access_token}`:`Bearer sandbox`,o=await fetch(`/api/github/sync-all`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:a},body:JSON.stringify({token:t.trim(),repo:n.trim(),branch:r.trim()})});if(!o.ok){let e=await o.json().catch(()=>({}));throw Error(e.detail||`Sync failed (${o.status})`)}return await o.json()}export{c as a,u as c,r as i,s as l,o as n,l as o,n as r,i as s,a as t};
|
algospaced-ui/dist/assets/{index-0dH8bbro.js → index-DnK6BACV.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/index-supjX07i.css
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/index-tlaKBeUb.css
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/vendor-react-CIO8MTK1.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
algospaced-ui/dist/assets/vendor-react-q-oOktF_.js
DELETED
|
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&family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=Be+Vietnam+Pro:wght@500;700&family=Courier+Prime:wght@400;700&family=Press+Start+2P&family=Cinzel:wght@500;700;900&family=Cinzel+Decorative:wght@700;900&family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&family=Kalam:wght@400;700&display=swap"
|
| 23 |
/>
|
| 24 |
-
<script type="module" crossorigin src="/assets/index-
|
| 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-
|
| 28 |
<link rel="modulepreload" crossorigin href="/assets/vendor-firebase-DSIO3PIf.js">
|
| 29 |
-
<link rel="modulepreload" crossorigin href="/assets/firebaseClient-
|
| 30 |
<link rel="modulepreload" crossorigin href="/assets/vendor-ui-ZXcm-2wU.js">
|
| 31 |
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
| 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&family=Bricolage+Grotesque:opsz,wght@12..96,700;12..96,800&family=Be+Vietnam+Pro:wght@500;700&family=Courier+Prime:wght@400;700&family=Press+Start+2P&family=Cinzel:wght@500;700;900&family=Cinzel+Decorative:wght@700;900&family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&family=Kalam:wght@400;700&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>
|
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,
|
|
|
|
| 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")))});
|
algospaced-ui/eslint.config.js
CHANGED
|
@@ -22,6 +22,23 @@ export default defineConfig([
|
|
| 22 |
typescriptPackageName: '@typescript/typescript6',
|
| 23 |
},
|
| 24 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
},
|
| 26 |
eslintConfigPrettier,
|
| 27 |
])
|
|
|
|
| 22 |
typescriptPackageName: '@typescript/typescript6',
|
| 23 |
},
|
| 24 |
},
|
| 25 |
+
rules: {
|
| 26 |
+
'react-hooks/set-state-in-effect': 'off',
|
| 27 |
+
'react-hooks/refs': 'warn',
|
| 28 |
+
'no-empty': ['error', { allowEmptyCatch: true }],
|
| 29 |
+
'@typescript-eslint/no-explicit-any': 'warn',
|
| 30 |
+
'@typescript-eslint/no-unused-vars': [
|
| 31 |
+
'warn',
|
| 32 |
+
{
|
| 33 |
+
argsIgnorePattern: '^_',
|
| 34 |
+
varsIgnorePattern: '^_',
|
| 35 |
+
caughtErrorsIgnorePattern: '^_',
|
| 36 |
+
},
|
| 37 |
+
],
|
| 38 |
+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
| 39 |
+
'no-useless-assignment': 'warn',
|
| 40 |
+
'prefer-const': 'warn',
|
| 41 |
+
},
|
| 42 |
},
|
| 43 |
eslintConfigPrettier,
|
| 44 |
])
|
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 tests/offlineAuth.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",
|
| 12 |
"preview": "vite preview"
|
| 13 |
},
|
| 14 |
"dependencies": {
|
algospaced-ui/src/components/ReviewQueue.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import { useState, useEffect, useCallback, useRef, lazy, Suspense } from 'react';
|
| 2 |
-
import { RefreshCw, FileText, Code, BookOpen } from 'lucide-react';
|
| 3 |
import OnboardingModal from './OnboardingModal';
|
| 4 |
import { findCatalogProblem } from '../services/catalogService';
|
| 5 |
import { parseProblemContent, parseProblemTitle } from '../utils/problemContentParser';
|
|
@@ -64,6 +64,7 @@ export default function ReviewQueue({
|
|
| 64 |
reviews,
|
| 65 |
setReviews,
|
| 66 |
loading,
|
|
|
|
| 67 |
submitting,
|
| 68 |
submittingRating,
|
| 69 |
gradeError,
|
|
@@ -284,6 +285,58 @@ export default function ReviewQueue({
|
|
| 284 |
);
|
| 285 |
}
|
| 286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
// Celebratory Empty State
|
| 288 |
if (reviews.length === 0) {
|
| 289 |
return (
|
|
|
|
| 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';
|
|
|
|
| 64 |
reviews,
|
| 65 |
setReviews,
|
| 66 |
loading,
|
| 67 |
+
queueError,
|
| 68 |
submitting,
|
| 69 |
submittingRating,
|
| 70 |
gradeError,
|
|
|
|
| 285 |
);
|
| 286 |
}
|
| 287 |
|
| 288 |
+
// Dedicated Connection Error / Offline State
|
| 289 |
+
if (queueError && reviews.length === 0) {
|
| 290 |
+
return (
|
| 291 |
+
<div className="w-full h-full flex items-center justify-center bg-[#fdf8e1] p-6 overflow-y-auto custom-scrollbar">
|
| 292 |
+
<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">
|
| 293 |
+
{/* Top striped arcade banner */}
|
| 294 |
+
<div className="absolute top-0 left-0 right-0 h-3 bg-gradient-to-r from-red-500 via-amber-400 to-red-500" />
|
| 295 |
+
|
| 296 |
+
{/* Offline Graphic */}
|
| 297 |
+
<div className="relative inline-block mt-2">
|
| 298 |
+
<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]">
|
| 299 |
+
<WifiOff className="w-10 h-10 text-rose-700 stroke-[2.5]" />
|
| 300 |
+
</div>
|
| 301 |
+
<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)]">
|
| 302 |
+
OFFLINE
|
| 303 |
+
</div>
|
| 304 |
+
</div>
|
| 305 |
+
|
| 306 |
+
<div className="space-y-2">
|
| 307 |
+
<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">
|
| 308 |
+
<AlertTriangle className="w-3.5 h-3.5 stroke-[2.5] text-rose-600" /> CONNECTION ERROR
|
| 309 |
+
</span>
|
| 310 |
+
<h2 className="text-2xl sm:text-3xl font-extrabold text-ink-black font-headline-md tracking-tight">
|
| 311 |
+
Queue Unavailable
|
| 312 |
+
</h2>
|
| 313 |
+
<p className="font-sans text-xs sm:text-sm text-trash-gray font-semibold leading-relaxed max-w-sm mx-auto">
|
| 314 |
+
Unable to reach the server to fetch your scheduled review cards. Check your connection or retry below.
|
| 315 |
+
</p>
|
| 316 |
+
</div>
|
| 317 |
+
|
| 318 |
+
<div className="pt-2 flex flex-col sm:flex-row gap-3 justify-center items-center">
|
| 319 |
+
<button
|
| 320 |
+
onClick={() => void fetchQueue(true)}
|
| 321 |
+
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"
|
| 322 |
+
>
|
| 323 |
+
<RotateCcw className="w-4 h-4" />
|
| 324 |
+
<span>RETRY CONNECTION</span>
|
| 325 |
+
</button>
|
| 326 |
+
{(onOpenJourney || onOpenWindow) && (
|
| 327 |
+
<button
|
| 328 |
+
onClick={handleOpenJourney}
|
| 329 |
+
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"
|
| 330 |
+
>
|
| 331 |
+
<span>OPEN JOURNEY MAP</span>
|
| 332 |
+
</button>
|
| 333 |
+
)}
|
| 334 |
+
</div>
|
| 335 |
+
</div>
|
| 336 |
+
</div>
|
| 337 |
+
);
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
// Celebratory Empty State
|
| 341 |
if (reviews.length === 0) {
|
| 342 |
return (
|
algospaced-ui/src/hooks/useReviewQueue.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import { useState, useRef, useCallback, useEffect } from 'react';
|
| 2 |
-
import { supabase } from '../firebaseClient';
|
| 3 |
import confetti from 'canvas-confetti';
|
| 4 |
import { companionStore } from '../features/companion';
|
| 5 |
import {
|
|
@@ -11,6 +11,21 @@ import { activateCatalogProblem } from '../services/reviewService';
|
|
| 11 |
import { getGitHubConfig, pushSolutionToGitHub } from '../services/githubSyncService';
|
| 12 |
import type { ReviewItem } from '../types/reviewTypes';
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
interface UseReviewQueueOptions {
|
| 15 |
overrideProblemId?: string | null;
|
| 16 |
refreshTrigger?: number;
|
|
@@ -28,13 +43,20 @@ export function useReviewQueue({
|
|
| 28 |
}: UseReviewQueueOptions) {
|
| 29 |
const [reviews, setReviews] = useState<ReviewItem[]>([]);
|
| 30 |
const [loading, setLoading] = useState(true);
|
|
|
|
| 31 |
const [submitting, setSubmitting] = useState(false);
|
| 32 |
const [submittingRating, setSubmittingRating] = useState<number | null>(null);
|
| 33 |
const [gradeError, setGradeError] = useState<string | null>(null);
|
| 34 |
const [code, setCode] = useState('');
|
| 35 |
const [nextMilestone, setNextMilestone] = useState<CatalogProblem | null>(null);
|
| 36 |
const [activatingMilestone, setActivatingMilestone] = useState(false);
|
| 37 |
-
const [currentUserId, setCurrentUserId] = useState<string | undefined>(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
const confettiTriggeredRef = useRef(false);
|
| 40 |
|
|
@@ -62,24 +84,47 @@ export function useReviewQueue({
|
|
| 62 |
if (showLoading) {
|
| 63 |
setLoading(true);
|
| 64 |
setGradeError(null);
|
|
|
|
| 65 |
setCode('');
|
| 66 |
confettiTriggeredRef.current = false;
|
| 67 |
} else {
|
| 68 |
setGradeError(null);
|
| 69 |
}
|
| 70 |
|
|
|
|
|
|
|
| 71 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
const { data: { session } } = await supabase.auth.getSession();
|
| 73 |
const token = session ? session.access_token : 'sandbox';
|
| 74 |
if (session?.user?.id) {
|
| 75 |
setCurrentUserId(session.user.id);
|
|
|
|
| 76 |
}
|
| 77 |
|
| 78 |
const headers = { 'Authorization': `Bearer ${token}` };
|
| 79 |
|
| 80 |
-
// 1. Fetch current due queue
|
| 81 |
-
const
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
if (!Array.isArray(data)) {
|
| 84 |
data = [];
|
| 85 |
}
|
|
@@ -149,6 +194,12 @@ export function useReviewQueue({
|
|
| 149 |
}
|
| 150 |
|
| 151 |
setReviews(data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
// Check if user has completed onboarding protocol
|
| 154 |
const rawUid = session?.user?.id;
|
|
@@ -174,25 +225,60 @@ export function useReviewQueue({
|
|
| 174 |
setCode(starter);
|
| 175 |
}
|
| 176 |
} else {
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
setNextMilestone(getNextUnsolvedProblem(new Set()) ?? null);
|
| 185 |
-
}
|
| 186 |
-
} catch {
|
| 187 |
setNextMilestone(getNextUnsolvedProblem(new Set()) ?? null);
|
| 188 |
}
|
|
|
|
|
|
|
| 189 |
}
|
| 190 |
-
}
|
|
|
|
| 191 |
console.error('Error fetching review queue:', err);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
} finally {
|
| 193 |
setLoading(false);
|
| 194 |
}
|
| 195 |
-
}, [overrideProblemId, handleOpenOnboardingInternal]);
|
| 196 |
|
| 197 |
useEffect(() => {
|
| 198 |
if (isTransitioningOverrideRef.current) {
|
|
@@ -214,7 +300,7 @@ export function useReviewQueue({
|
|
| 214 |
|
| 215 |
// Confetti trigger when queue completes
|
| 216 |
useEffect(() => {
|
| 217 |
-
if (!loading && reviews.length === 0 && !overrideProblemId && !confettiTriggeredRef.current) {
|
| 218 |
confettiTriggeredRef.current = true;
|
| 219 |
try {
|
| 220 |
confetti({
|
|
@@ -226,7 +312,7 @@ export function useReviewQueue({
|
|
| 226 |
// Safe fallback if canvas is not ready
|
| 227 |
}
|
| 228 |
}
|
| 229 |
-
}, [loading, reviews.length, overrideProblemId]);
|
| 230 |
|
| 231 |
const handleGrade = useCallback(
|
| 232 |
async (rating: number) => {
|
|
@@ -304,6 +390,12 @@ export function useReviewQueue({
|
|
| 304 |
// Optimistically remove the completed card for instant, snappy UI
|
| 305 |
setReviews((prev) => {
|
| 306 |
const nextReviews = prev.slice(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
if (nextReviews.length > 0) {
|
| 308 |
const nextActive = nextReviews[0];
|
| 309 |
const rawProb = nextActive.problems;
|
|
@@ -321,6 +413,7 @@ export function useReviewQueue({
|
|
| 321 |
}
|
| 322 |
return nextReviews;
|
| 323 |
});
|
|
|
|
| 324 |
void fetchQueue(false);
|
| 325 |
} else {
|
| 326 |
const errorData = await res.json().catch(() => ({}));
|
|
@@ -337,7 +430,7 @@ export function useReviewQueue({
|
|
| 337 |
setSubmittingRating(null);
|
| 338 |
}
|
| 339 |
},
|
| 340 |
-
[reviews, submitting, overrideProblemId, fetchQueue, code]
|
| 341 |
);
|
| 342 |
|
| 343 |
const handleActivateNextMilestone = useCallback(async () => {
|
|
@@ -406,6 +499,7 @@ export function useReviewQueue({
|
|
| 406 |
reviews,
|
| 407 |
setReviews,
|
| 408 |
loading,
|
|
|
|
| 409 |
submitting,
|
| 410 |
submittingRating,
|
| 411 |
gradeError,
|
|
|
|
| 1 |
import { useState, useRef, useCallback, useEffect } from 'react';
|
| 2 |
+
import { supabase, getStoredSession } from '../firebaseClient';
|
| 3 |
import confetti from 'canvas-confetti';
|
| 4 |
import { companionStore } from '../features/companion';
|
| 5 |
import {
|
|
|
|
| 11 |
import { getGitHubConfig, pushSolutionToGitHub } from '../services/githubSyncService';
|
| 12 |
import type { ReviewItem } from '../types/reviewTypes';
|
| 13 |
|
| 14 |
+
function getEffectiveUid(currentUid?: string): string {
|
| 15 |
+
if (currentUid && currentUid !== 'sandbox-user-id') {
|
| 16 |
+
return currentUid;
|
| 17 |
+
}
|
| 18 |
+
try {
|
| 19 |
+
const session = getStoredSession();
|
| 20 |
+
if (session?.user?.id && session.user.id !== 'sandbox-user-id') {
|
| 21 |
+
return session.user.id;
|
| 22 |
+
}
|
| 23 |
+
} catch {
|
| 24 |
+
// Graceful fallback
|
| 25 |
+
}
|
| 26 |
+
return 'guest';
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
interface UseReviewQueueOptions {
|
| 30 |
overrideProblemId?: string | null;
|
| 31 |
refreshTrigger?: number;
|
|
|
|
| 43 |
}: UseReviewQueueOptions) {
|
| 44 |
const [reviews, setReviews] = useState<ReviewItem[]>([]);
|
| 45 |
const [loading, setLoading] = useState(true);
|
| 46 |
+
const [queueError, setQueueError] = useState<string | null>(null);
|
| 47 |
const [submitting, setSubmitting] = useState(false);
|
| 48 |
const [submittingRating, setSubmittingRating] = useState<number | null>(null);
|
| 49 |
const [gradeError, setGradeError] = useState<string | null>(null);
|
| 50 |
const [code, setCode] = useState('');
|
| 51 |
const [nextMilestone, setNextMilestone] = useState<CatalogProblem | null>(null);
|
| 52 |
const [activatingMilestone, setActivatingMilestone] = useState(false);
|
| 53 |
+
const [currentUserId, setCurrentUserId] = useState<string | undefined>(() => {
|
| 54 |
+
try {
|
| 55 |
+
return getStoredSession()?.user?.id;
|
| 56 |
+
} catch {
|
| 57 |
+
return undefined;
|
| 58 |
+
}
|
| 59 |
+
});
|
| 60 |
|
| 61 |
const confettiTriggeredRef = useRef(false);
|
| 62 |
|
|
|
|
| 84 |
if (showLoading) {
|
| 85 |
setLoading(true);
|
| 86 |
setGradeError(null);
|
| 87 |
+
setQueueError(null);
|
| 88 |
setCode('');
|
| 89 |
confettiTriggeredRef.current = false;
|
| 90 |
} else {
|
| 91 |
setGradeError(null);
|
| 92 |
}
|
| 93 |
|
| 94 |
+
let uidKey = getEffectiveUid(currentUserId);
|
| 95 |
+
|
| 96 |
try {
|
| 97 |
+
if (typeof navigator !== 'undefined' && !navigator.onLine) {
|
| 98 |
+
throw new Error('Network connection offline.');
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
const { data: { session } } = await supabase.auth.getSession();
|
| 102 |
const token = session ? session.access_token : 'sandbox';
|
| 103 |
if (session?.user?.id) {
|
| 104 |
setCurrentUserId(session.user.id);
|
| 105 |
+
uidKey = getEffectiveUid(session.user.id);
|
| 106 |
}
|
| 107 |
|
| 108 |
const headers = { 'Authorization': `Bearer ${token}` };
|
| 109 |
|
| 110 |
+
// 1. Fetch current due queue with 4-second timeout to prevent 30s+ offline hangs
|
| 111 |
+
const abortCtrl = new AbortController();
|
| 112 |
+
const timerId = setTimeout(() => abortCtrl.abort(), 4000);
|
| 113 |
+
|
| 114 |
+
let dueRes: Response;
|
| 115 |
+
try {
|
| 116 |
+
dueRes = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/reviews/due`, {
|
| 117 |
+
headers,
|
| 118 |
+
signal: abortCtrl.signal,
|
| 119 |
+
});
|
| 120 |
+
} finally {
|
| 121 |
+
clearTimeout(timerId);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
if (!dueRes.ok) {
|
| 125 |
+
throw new Error(`Failed to load review queue: HTTP ${dueRes.status}`);
|
| 126 |
+
}
|
| 127 |
+
let data: ReviewItem[] = await dueRes.json();
|
| 128 |
if (!Array.isArray(data)) {
|
| 129 |
data = [];
|
| 130 |
}
|
|
|
|
| 194 |
}
|
| 195 |
|
| 196 |
setReviews(data);
|
| 197 |
+
setQueueError(null);
|
| 198 |
+
try {
|
| 199 |
+
localStorage.setItem(`algospaced_review_queue_${uidKey}`, JSON.stringify(data));
|
| 200 |
+
} catch {
|
| 201 |
+
// Safe fallback
|
| 202 |
+
}
|
| 203 |
|
| 204 |
// Check if user has completed onboarding protocol
|
| 205 |
const rawUid = session?.user?.id;
|
|
|
|
| 225 |
setCode(starter);
|
| 226 |
}
|
| 227 |
} else {
|
| 228 |
+
// Empty queue: discover next milestone from journey progress
|
| 229 |
+
try {
|
| 230 |
+
const progRes = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/journey-progress`, { headers });
|
| 231 |
+
if (progRes.ok) {
|
| 232 |
+
const progData: number[] = await progRes.json();
|
| 233 |
+
setNextMilestone(getNextUnsolvedProblem(new Set(progData)) ?? null);
|
| 234 |
+
} else {
|
|
|
|
|
|
|
|
|
|
| 235 |
setNextMilestone(getNextUnsolvedProblem(new Set()) ?? null);
|
| 236 |
}
|
| 237 |
+
} catch {
|
| 238 |
+
setNextMilestone(getNextUnsolvedProblem(new Set()) ?? null);
|
| 239 |
}
|
| 240 |
+
}
|
| 241 |
+
} catch (err) {
|
| 242 |
console.error('Error fetching review queue:', err);
|
| 243 |
+
const errMsg = err instanceof Error ? err.message : 'Network error loading review queue.';
|
| 244 |
+
|
| 245 |
+
// Attempt to restore cached review items from localStorage
|
| 246 |
+
let restoredFromCache = false;
|
| 247 |
+
try {
|
| 248 |
+
const cachedRaw = localStorage.getItem(`algospaced_review_queue_${uidKey}`);
|
| 249 |
+
if (cachedRaw) {
|
| 250 |
+
const cachedData: ReviewItem[] = JSON.parse(cachedRaw);
|
| 251 |
+
if (Array.isArray(cachedData) && cachedData.length > 0) {
|
| 252 |
+
setReviews(cachedData);
|
| 253 |
+
restoredFromCache = true;
|
| 254 |
+
setQueueError(null);
|
| 255 |
+
if (showLoading) {
|
| 256 |
+
const activeReview = cachedData[0];
|
| 257 |
+
const rawProblem = activeReview.problems;
|
| 258 |
+
const probNum = rawProblem?.problem_number ??
|
| 259 |
+
(/^\d+$/.test(activeReview?.problem_id || '') ? parseInt(activeReview.problem_id, 10) : undefined);
|
| 260 |
+
const catalogProb = findCatalogProblem(
|
| 261 |
+
probNum,
|
| 262 |
+
rawProblem?.id || activeReview?.problem_id,
|
| 263 |
+
rawProblem?.name
|
| 264 |
+
);
|
| 265 |
+
|
| 266 |
+
const starter = catalogProb?.starter_code || rawProblem?.starter_code || '';
|
| 267 |
+
setCode(starter);
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
} catch (cacheErr) {
|
| 272 |
+
console.warn('Failed to parse cached review items:', cacheErr);
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
if (!restoredFromCache) {
|
| 276 |
+
setQueueError(errMsg);
|
| 277 |
+
}
|
| 278 |
} finally {
|
| 279 |
setLoading(false);
|
| 280 |
}
|
| 281 |
+
}, [overrideProblemId, handleOpenOnboardingInternal, currentUserId]);
|
| 282 |
|
| 283 |
useEffect(() => {
|
| 284 |
if (isTransitioningOverrideRef.current) {
|
|
|
|
| 300 |
|
| 301 |
// Confetti trigger when queue completes
|
| 302 |
useEffect(() => {
|
| 303 |
+
if (!loading && !queueError && reviews.length === 0 && !overrideProblemId && !confettiTriggeredRef.current) {
|
| 304 |
confettiTriggeredRef.current = true;
|
| 305 |
try {
|
| 306 |
confetti({
|
|
|
|
| 312 |
// Safe fallback if canvas is not ready
|
| 313 |
}
|
| 314 |
}
|
| 315 |
+
}, [loading, queueError, reviews.length, overrideProblemId]);
|
| 316 |
|
| 317 |
const handleGrade = useCallback(
|
| 318 |
async (rating: number) => {
|
|
|
|
| 390 |
// Optimistically remove the completed card for instant, snappy UI
|
| 391 |
setReviews((prev) => {
|
| 392 |
const nextReviews = prev.slice(1);
|
| 393 |
+
try {
|
| 394 |
+
const effectiveUid = getEffectiveUid(currentUserId);
|
| 395 |
+
localStorage.setItem(`algospaced_review_queue_${effectiveUid}`, JSON.stringify(nextReviews));
|
| 396 |
+
} catch {
|
| 397 |
+
// Safe fallback
|
| 398 |
+
}
|
| 399 |
if (nextReviews.length > 0) {
|
| 400 |
const nextActive = nextReviews[0];
|
| 401 |
const rawProb = nextActive.problems;
|
|
|
|
| 413 |
}
|
| 414 |
return nextReviews;
|
| 415 |
});
|
| 416 |
+
setQueueError(null);
|
| 417 |
void fetchQueue(false);
|
| 418 |
} else {
|
| 419 |
const errorData = await res.json().catch(() => ({}));
|
|
|
|
| 430 |
setSubmittingRating(null);
|
| 431 |
}
|
| 432 |
},
|
| 433 |
+
[reviews, submitting, overrideProblemId, fetchQueue, code, currentUserId]
|
| 434 |
);
|
| 435 |
|
| 436 |
const handleActivateNextMilestone = useCallback(async () => {
|
|
|
|
| 499 |
reviews,
|
| 500 |
setReviews,
|
| 501 |
loading,
|
| 502 |
+
queueError,
|
| 503 |
submitting,
|
| 504 |
submittingRating,
|
| 505 |
gradeError,
|
algospaced-ui/tests/offlineReviewQueue.test.mjs
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import test from 'node:test';
|
| 2 |
+
import assert from 'node:assert/strict';
|
| 3 |
+
|
| 4 |
+
// Setup Mock Browser Environment for Node.js
|
| 5 |
+
class LocalStorageMock {
|
| 6 |
+
constructor() {
|
| 7 |
+
this.store = {};
|
| 8 |
+
}
|
| 9 |
+
getItem(key) {
|
| 10 |
+
return this.store[key] || null;
|
| 11 |
+
}
|
| 12 |
+
setItem(key, val) {
|
| 13 |
+
this.store[key] = String(val);
|
| 14 |
+
}
|
| 15 |
+
removeItem(key) {
|
| 16 |
+
delete this.store[key];
|
| 17 |
+
}
|
| 18 |
+
clear() {
|
| 19 |
+
this.store = {};
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
const mockStorage = new LocalStorageMock();
|
| 24 |
+
globalThis.localStorage = mockStorage;
|
| 25 |
+
globalThis.window = {
|
| 26 |
+
addEventListener: () => {},
|
| 27 |
+
removeEventListener: () => {},
|
| 28 |
+
location: { reload: () => {} }
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
const SESSION_STORAGE_KEY = 'algospaced_auth_session';
|
| 32 |
+
|
| 33 |
+
const sampleCards = [
|
| 34 |
+
{
|
| 35 |
+
id: 'rev-1',
|
| 36 |
+
problem_id: '1',
|
| 37 |
+
fsrs_state: 1,
|
| 38 |
+
fsrs_stability: 2.5,
|
| 39 |
+
fsrs_difficulty: 5.0,
|
| 40 |
+
problems: {
|
| 41 |
+
id: 'prob-1',
|
| 42 |
+
problem_number: 1,
|
| 43 |
+
name: 'Two Sum',
|
| 44 |
+
pattern: 'Hash Map',
|
| 45 |
+
difficulty: 'Easy',
|
| 46 |
+
starter_code: 'def twoSum(nums, target):',
|
| 47 |
+
reference_code: 'def twoSum(nums, target): return []'
|
| 48 |
+
}
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
id: 'rev-2',
|
| 52 |
+
problem_id: '2',
|
| 53 |
+
fsrs_state: 2,
|
| 54 |
+
fsrs_stability: 4.0,
|
| 55 |
+
fsrs_difficulty: 4.5,
|
| 56 |
+
problems: {
|
| 57 |
+
id: 'prob-2',
|
| 58 |
+
problem_number: 2,
|
| 59 |
+
name: 'Add Two Numbers',
|
| 60 |
+
pattern: 'Linked List',
|
| 61 |
+
difficulty: 'Medium',
|
| 62 |
+
starter_code: 'def addTwoNumbers(l1, l2):',
|
| 63 |
+
reference_code: 'def addTwoNumbers(l1, l2): return None'
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
];
|
| 67 |
+
|
| 68 |
+
function getEffectiveUid(currentUid) {
|
| 69 |
+
if (currentUid && currentUid !== 'sandbox-user-id') {
|
| 70 |
+
return currentUid;
|
| 71 |
+
}
|
| 72 |
+
try {
|
| 73 |
+
const raw = mockStorage.getItem(SESSION_STORAGE_KEY);
|
| 74 |
+
if (raw) {
|
| 75 |
+
const parsed = JSON.parse(raw);
|
| 76 |
+
if (parsed?.user?.id && parsed.user.id !== 'sandbox-user-id') {
|
| 77 |
+
return parsed.user.id;
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
} catch {
|
| 81 |
+
// ignore
|
| 82 |
+
}
|
| 83 |
+
return 'guest';
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
function getQueueStorageKey(uid) {
|
| 87 |
+
return `algospaced_review_queue_${getEffectiveUid(uid)}`;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
test('1. First-time offline user with no cache sets queueError and leaves queue empty', async () => {
|
| 91 |
+
mockStorage.clear();
|
| 92 |
+
const uidKey = getEffectiveUid(undefined);
|
| 93 |
+
assert.strictEqual(uidKey, 'guest');
|
| 94 |
+
|
| 95 |
+
let queueError = null;
|
| 96 |
+
let reviews = [];
|
| 97 |
+
const networkError = new Error('Failed to fetch');
|
| 98 |
+
|
| 99 |
+
// Simulated fetchQueue catch block
|
| 100 |
+
const errMsg = networkError.message;
|
| 101 |
+
let restoredFromCache = false;
|
| 102 |
+
const cachedRaw = mockStorage.getItem(getQueueStorageKey(uidKey));
|
| 103 |
+
if (cachedRaw) {
|
| 104 |
+
const parsed = JSON.parse(cachedRaw);
|
| 105 |
+
if (Array.isArray(parsed) && parsed.length > 0) {
|
| 106 |
+
reviews = parsed;
|
| 107 |
+
restoredFromCache = true;
|
| 108 |
+
queueError = null;
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
if (!restoredFromCache) {
|
| 112 |
+
queueError = errMsg;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
assert.strictEqual(reviews.length, 0, 'Reviews must be empty');
|
| 116 |
+
assert.strictEqual(queueError, 'Failed to fetch', 'queueError must be set');
|
| 117 |
+
// Confirm condition for error screen vs celebration screen
|
| 118 |
+
const shouldShowOfflineScreen = Boolean(queueError && reviews.length === 0);
|
| 119 |
+
const shouldCelebrate = Boolean(!queueError && reviews.length === 0);
|
| 120 |
+
assert.strictEqual(shouldShowOfflineScreen, true, 'Must show offline error screen');
|
| 121 |
+
assert.strictEqual(shouldCelebrate, false, 'Must NOT show celebration screen falsely');
|
| 122 |
+
});
|
| 123 |
+
|
| 124 |
+
test('2. Online fetch successfully caches ReviewItem[] into localStorage keyed by UID', async () => {
|
| 125 |
+
mockStorage.clear();
|
| 126 |
+
const userId = 'usr-pro-42';
|
| 127 |
+
mockStorage.setItem(SESSION_STORAGE_KEY, JSON.stringify({ user: { id: userId } }));
|
| 128 |
+
|
| 129 |
+
const key = getQueueStorageKey();
|
| 130 |
+
assert.strictEqual(key, 'algospaced_review_queue_usr-pro-42');
|
| 131 |
+
|
| 132 |
+
// Save cards to cache as done in fetchQueue
|
| 133 |
+
mockStorage.setItem(key, JSON.stringify(sampleCards));
|
| 134 |
+
|
| 135 |
+
const stored = JSON.parse(mockStorage.getItem(key));
|
| 136 |
+
assert.strictEqual(Array.isArray(stored), true);
|
| 137 |
+
assert.strictEqual(stored.length, 2);
|
| 138 |
+
assert.strictEqual(stored[0].problems.name, 'Two Sum');
|
| 139 |
+
});
|
| 140 |
+
|
| 141 |
+
test('3. Reopening Daily Review offline restores cached cards and clears queueError', async () => {
|
| 142 |
+
// Session is still usr-pro-42 with cached cards
|
| 143 |
+
const uidKey = getEffectiveUid(undefined);
|
| 144 |
+
assert.strictEqual(uidKey, 'usr-pro-42');
|
| 145 |
+
|
| 146 |
+
let queueError = null;
|
| 147 |
+
let reviews = [];
|
| 148 |
+
const offlineError = new Error('Network connection offline.');
|
| 149 |
+
|
| 150 |
+
// Simulated fetchQueue catch block
|
| 151 |
+
const errMsg = offlineError.message;
|
| 152 |
+
let restoredFromCache = false;
|
| 153 |
+
const cachedRaw = mockStorage.getItem(getQueueStorageKey(uidKey));
|
| 154 |
+
if (cachedRaw) {
|
| 155 |
+
const parsed = JSON.parse(cachedRaw);
|
| 156 |
+
if (Array.isArray(parsed) && parsed.length > 0) {
|
| 157 |
+
reviews = parsed;
|
| 158 |
+
restoredFromCache = true;
|
| 159 |
+
queueError = null;
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
if (!restoredFromCache) {
|
| 163 |
+
queueError = errMsg;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
assert.strictEqual(reviews.length, 2, 'Must restore 2 cached cards');
|
| 167 |
+
assert.strictEqual(queueError, null, 'queueError must be cleared since cards are restored');
|
| 168 |
+
assert.strictEqual(reviews[0].problems.name, 'Two Sum');
|
| 169 |
+
assert.strictEqual(reviews[1].problems.name, 'Add Two Numbers');
|
| 170 |
+
});
|
| 171 |
+
|
| 172 |
+
test('4. Slicing review cards updates localStorage and enables celebration when all completed', async () => {
|
| 173 |
+
const uidKey = getEffectiveUid(undefined);
|
| 174 |
+
let reviews = [...sampleCards];
|
| 175 |
+
|
| 176 |
+
// User grades card 1
|
| 177 |
+
reviews = reviews.slice(1);
|
| 178 |
+
mockStorage.setItem(getQueueStorageKey(uidKey), JSON.stringify(reviews));
|
| 179 |
+
|
| 180 |
+
let cachedAfterFirst = JSON.parse(mockStorage.getItem(getQueueStorageKey(uidKey)));
|
| 181 |
+
assert.strictEqual(cachedAfterFirst.length, 1);
|
| 182 |
+
assert.strictEqual(cachedAfterFirst[0].problems.name, 'Add Two Numbers');
|
| 183 |
+
|
| 184 |
+
// User grades card 2 (last card)
|
| 185 |
+
reviews = reviews.slice(1);
|
| 186 |
+
mockStorage.setItem(getQueueStorageKey(uidKey), JSON.stringify(reviews));
|
| 187 |
+
|
| 188 |
+
let cachedAfterSecond = JSON.parse(mockStorage.getItem(getQueueStorageKey(uidKey)));
|
| 189 |
+
assert.strictEqual(cachedAfterSecond.length, 0);
|
| 190 |
+
|
| 191 |
+
// Queue is now empty, queueError is null
|
| 192 |
+
let queueError = null;
|
| 193 |
+
const shouldCelebrate = Boolean(!queueError && reviews.length === 0);
|
| 194 |
+
assert.strictEqual(shouldCelebrate, true, 'EmptyQueueCelebration must be allowed when cards are finished');
|
| 195 |
+
});
|
| 196 |
+
|
| 197 |
+
test('5. Closing and reopening modal offline preserves remaining cards without wiping them', async () => {
|
| 198 |
+
// Put 1 remaining card in cache
|
| 199 |
+
const remaining = [sampleCards[1]];
|
| 200 |
+
const uidKey = getEffectiveUid(undefined);
|
| 201 |
+
mockStorage.setItem(getQueueStorageKey(uidKey), JSON.stringify(remaining));
|
| 202 |
+
|
| 203 |
+
// Reopening modal offline triggers fetchQueue which fails network
|
| 204 |
+
let reviews = [];
|
| 205 |
+
let queueError = null;
|
| 206 |
+
const networkErr = new Error('TypeError: Failed to fetch');
|
| 207 |
+
|
| 208 |
+
let restoredFromCache = false;
|
| 209 |
+
const cachedRaw = mockStorage.getItem(getQueueStorageKey(uidKey));
|
| 210 |
+
if (cachedRaw) {
|
| 211 |
+
const parsed = JSON.parse(cachedRaw);
|
| 212 |
+
if (Array.isArray(parsed) && parsed.length > 0) {
|
| 213 |
+
reviews = parsed;
|
| 214 |
+
restoredFromCache = true;
|
| 215 |
+
queueError = null;
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
if (!restoredFromCache) {
|
| 219 |
+
queueError = networkErr.message;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
assert.strictEqual(reviews.length, 1, 'Remaining card must be preserved');
|
| 223 |
+
assert.strictEqual(reviews[0].problems.name, 'Add Two Numbers');
|
| 224 |
+
assert.strictEqual(queueError, null);
|
| 225 |
+
});
|
| 226 |
+
|
| 227 |
+
test('6. Guest user storage is isolated from authenticated user storage', async () => {
|
| 228 |
+
mockStorage.clear();
|
| 229 |
+
|
| 230 |
+
// Guest writes cards
|
| 231 |
+
mockStorage.setItem(getQueueStorageKey(undefined), JSON.stringify([sampleCards[0]]));
|
| 232 |
+
assert.strictEqual(mockStorage.getItem('algospaced_review_queue_guest') !== null, true);
|
| 233 |
+
assert.strictEqual(mockStorage.getItem('algospaced_review_queue_user-xyz'), null);
|
| 234 |
+
|
| 235 |
+
// Authenticated user writes cards
|
| 236 |
+
mockStorage.setItem(getQueueStorageKey('user-xyz'), JSON.stringify([sampleCards[1]]));
|
| 237 |
+
assert.strictEqual(mockStorage.getItem('algospaced_review_queue_user-xyz') !== null, true);
|
| 238 |
+
|
| 239 |
+
const guestData = JSON.parse(mockStorage.getItem('algospaced_review_queue_guest'));
|
| 240 |
+
const userData = JSON.parse(mockStorage.getItem('algospaced_review_queue_user-xyz'));
|
| 241 |
+
|
| 242 |
+
assert.strictEqual(guestData[0].problems.name, 'Two Sum');
|
| 243 |
+
assert.strictEqual(userData[0].problems.name, 'Add Two Numbers');
|
| 244 |
+
});
|
cache.py
CHANGED
|
@@ -1,27 +1,48 @@
|
|
| 1 |
import json
|
| 2 |
import os
|
|
|
|
| 3 |
from typing import Any
|
| 4 |
|
| 5 |
import redis
|
| 6 |
|
| 7 |
REDIS_URL = os.environ.get("REDIS_URL", "redis://localhost:6379")
|
|
|
|
| 8 |
|
| 9 |
_redis_client = None
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
def get_redis_client():
|
| 13 |
-
global _redis_client
|
| 14 |
-
if
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
def get_cache(key: str) -> Any | None:
|
|
|
|
| 25 |
client = get_redis_client()
|
| 26 |
if client:
|
| 27 |
try:
|
|
@@ -29,23 +50,28 @@ def get_cache(key: str) -> Any | None:
|
|
| 29 |
if val:
|
| 30 |
return json.loads(val)
|
| 31 |
except Exception:
|
| 32 |
-
|
|
|
|
| 33 |
return None
|
| 34 |
|
| 35 |
|
| 36 |
def set_cache(key: str, value: Any, ttl_seconds: int = 3600):
|
|
|
|
| 37 |
client = get_redis_client()
|
| 38 |
if client:
|
| 39 |
try:
|
| 40 |
client.setex(key, ttl_seconds, json.dumps(value))
|
| 41 |
except Exception:
|
| 42 |
-
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
def delete_cache(key: str):
|
|
|
|
| 46 |
client = get_redis_client()
|
| 47 |
if client:
|
| 48 |
try:
|
| 49 |
client.delete(key)
|
| 50 |
except Exception:
|
| 51 |
-
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
import os
|
| 3 |
+
import time
|
| 4 |
from typing import Any
|
| 5 |
|
| 6 |
import redis
|
| 7 |
|
| 8 |
REDIS_URL = os.environ.get("REDIS_URL", "redis://localhost:6379")
|
| 9 |
+
REDIS_FAILURE_COOLDOWN = 60.0 # Cooldown period in seconds when Redis is unreachable
|
| 10 |
|
| 11 |
_redis_client = None
|
| 12 |
+
_last_redis_failure: float = 0.0
|
| 13 |
|
| 14 |
|
| 15 |
def get_redis_client():
|
| 16 |
+
global _redis_client, _last_redis_failure
|
| 17 |
+
if not REDIS_URL or REDIS_URL.lower() in ("none", "disabled", "false", ""):
|
| 18 |
+
return None
|
| 19 |
+
|
| 20 |
+
if _redis_client is not None:
|
| 21 |
+
return _redis_client
|
| 22 |
+
|
| 23 |
+
now = time.monotonic()
|
| 24 |
+
if now - _last_redis_failure < REDIS_FAILURE_COOLDOWN:
|
| 25 |
+
return None
|
| 26 |
+
|
| 27 |
+
try:
|
| 28 |
+
client = redis.Redis.from_url(
|
| 29 |
+
REDIS_URL,
|
| 30 |
+
decode_responses=True,
|
| 31 |
+
socket_connect_timeout=0.2,
|
| 32 |
+
socket_timeout=0.2,
|
| 33 |
+
)
|
| 34 |
+
# Test connection with short ping
|
| 35 |
+
client.ping()
|
| 36 |
+
_redis_client = client
|
| 37 |
+
return _redis_client
|
| 38 |
+
except Exception:
|
| 39 |
+
_redis_client = None
|
| 40 |
+
_last_redis_failure = time.monotonic()
|
| 41 |
+
return None
|
| 42 |
|
| 43 |
|
| 44 |
def get_cache(key: str) -> Any | None:
|
| 45 |
+
global _redis_client, _last_redis_failure
|
| 46 |
client = get_redis_client()
|
| 47 |
if client:
|
| 48 |
try:
|
|
|
|
| 50 |
if val:
|
| 51 |
return json.loads(val)
|
| 52 |
except Exception:
|
| 53 |
+
_redis_client = None
|
| 54 |
+
_last_redis_failure = time.monotonic()
|
| 55 |
return None
|
| 56 |
|
| 57 |
|
| 58 |
def set_cache(key: str, value: Any, ttl_seconds: int = 3600):
|
| 59 |
+
global _redis_client, _last_redis_failure
|
| 60 |
client = get_redis_client()
|
| 61 |
if client:
|
| 62 |
try:
|
| 63 |
client.setex(key, ttl_seconds, json.dumps(value))
|
| 64 |
except Exception:
|
| 65 |
+
_redis_client = None
|
| 66 |
+
_last_redis_failure = time.monotonic()
|
| 67 |
|
| 68 |
|
| 69 |
def delete_cache(key: str):
|
| 70 |
+
global _redis_client, _last_redis_failure
|
| 71 |
client = get_redis_client()
|
| 72 |
if client:
|
| 73 |
try:
|
| 74 |
client.delete(key)
|
| 75 |
except Exception:
|
| 76 |
+
_redis_client = None
|
| 77 |
+
_last_redis_failure = time.monotonic()
|
core/problem_utils.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import ast
|
|
|
|
| 2 |
import re
|
| 3 |
|
| 4 |
import ai_cache
|
|
@@ -162,6 +163,28 @@ def enrich_problem_examples_and_constraints(
|
|
| 162 |
if not prob:
|
| 163 |
return prob
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
has_examples = bool(
|
| 166 |
prob.get("examples") and isinstance(prob["examples"], list) and len(prob["examples"]) > 0
|
| 167 |
)
|
|
|
|
| 1 |
import ast
|
| 2 |
+
import json
|
| 3 |
import re
|
| 4 |
|
| 5 |
import ai_cache
|
|
|
|
| 163 |
if not prob:
|
| 164 |
return prob
|
| 165 |
|
| 166 |
+
# Parse JSON strings for examples and constraints if stored as JSON (e.g. from SQLite)
|
| 167 |
+
raw_examples = prob.get("examples")
|
| 168 |
+
if isinstance(raw_examples, str) and raw_examples.strip():
|
| 169 |
+
try:
|
| 170 |
+
parsed_ex = json.loads(raw_examples)
|
| 171 |
+
if isinstance(parsed_ex, list):
|
| 172 |
+
prob["examples"] = parsed_ex
|
| 173 |
+
except Exception:
|
| 174 |
+
pass
|
| 175 |
+
|
| 176 |
+
raw_constraints = prob.get("constraints")
|
| 177 |
+
if isinstance(raw_constraints, str) and raw_constraints.strip():
|
| 178 |
+
try:
|
| 179 |
+
parsed_co = json.loads(raw_constraints)
|
| 180 |
+
if isinstance(parsed_co, list):
|
| 181 |
+
prob["constraints"] = parsed_co
|
| 182 |
+
except Exception:
|
| 183 |
+
pass
|
| 184 |
+
|
| 185 |
+
if client and hasattr(db, "is_sandbox_or_mock") and db.is_sandbox_or_mock(client):
|
| 186 |
+
check_remote_cache = False
|
| 187 |
+
|
| 188 |
has_examples = bool(
|
| 189 |
prob.get("examples") and isinstance(prob["examples"], list) and len(prob["examples"]) > 0
|
| 190 |
)
|
db.py
CHANGED
|
@@ -101,6 +101,24 @@ def init_firebase():
|
|
| 101 |
return _firestore_client
|
| 102 |
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
def get_firestore_client():
|
| 105 |
global _firestore_client
|
| 106 |
if _firestore_client is None:
|
|
|
|
| 101 |
return _firestore_client
|
| 102 |
|
| 103 |
|
| 104 |
+
def has_firebase_credentials() -> bool:
|
| 105 |
+
root_dir = Path(__file__).resolve().parent
|
| 106 |
+
candidate_files = [
|
| 107 |
+
os.environ.get("FIREBASE_CREDENTIALS_PATH"),
|
| 108 |
+
str(root_dir / "firebase-credentials.json"),
|
| 109 |
+
str(root_dir / "firebase-credentials.json.json"),
|
| 110 |
+
str(root_dir / "serviceAccountKey.json"),
|
| 111 |
+
]
|
| 112 |
+
for c_path in candidate_files:
|
| 113 |
+
if c_path and Path(c_path).exists():
|
| 114 |
+
return True
|
| 115 |
+
if os.environ.get("FIREBASE_SERVICE_ACCOUNT_JSON"):
|
| 116 |
+
return True
|
| 117 |
+
if os.environ.get("FIREBASE_PROJECT_ID") and os.environ.get("FIREBASE_PRIVATE_KEY"):
|
| 118 |
+
return True
|
| 119 |
+
return False
|
| 120 |
+
|
| 121 |
+
|
| 122 |
def get_firestore_client():
|
| 123 |
global _firestore_client
|
| 124 |
if _firestore_client is None:
|
tests/unit/test_cache_resilience.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from unittest.mock import MagicMock, patch
|
| 2 |
+
|
| 3 |
+
import ai_cache
|
| 4 |
+
import cache
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class TestCacheResilience:
|
| 8 |
+
def test_redis_negative_caching_cooldown(self):
|
| 9 |
+
# Reset cache state
|
| 10 |
+
cache._redis_client = None
|
| 11 |
+
cache._last_redis_failure = 0.0
|
| 12 |
+
|
| 13 |
+
with patch("redis.Redis.from_url") as mock_from_url:
|
| 14 |
+
mock_from_url.side_effect = Exception("Connection refused")
|
| 15 |
+
|
| 16 |
+
# First call attempts connection and fails
|
| 17 |
+
client1 = cache.get_redis_client()
|
| 18 |
+
assert client1 is None
|
| 19 |
+
assert mock_from_url.call_count == 1
|
| 20 |
+
|
| 21 |
+
# Second call within cooldown fails immediately without calling from_url
|
| 22 |
+
client2 = cache.get_redis_client()
|
| 23 |
+
assert client2 is None
|
| 24 |
+
assert mock_from_url.call_count == 1
|
| 25 |
+
|
| 26 |
+
# Socket timeouts were passed
|
| 27 |
+
mock_from_url.assert_called_with(
|
| 28 |
+
cache.REDIS_URL,
|
| 29 |
+
decode_responses=True,
|
| 30 |
+
socket_connect_timeout=0.2,
|
| 31 |
+
socket_timeout=0.2,
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
def test_redis_get_cache_sets_cooldown_on_error(self):
|
| 35 |
+
cache._redis_client = MagicMock()
|
| 36 |
+
cache._redis_client.get.side_effect = Exception("Socket closed")
|
| 37 |
+
cache._last_redis_failure = 0.0
|
| 38 |
+
|
| 39 |
+
val = cache.get_cache("some_key")
|
| 40 |
+
assert val is None
|
| 41 |
+
assert cache._redis_client is None
|
| 42 |
+
assert cache._last_redis_failure > 0
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
class TestAiCacheLocalMode:
|
| 46 |
+
def test_ai_cache_skips_firestore_in_sandbox_mode(self):
|
| 47 |
+
with patch.dict("os.environ", {"SANDBOX_MODE": "true"}):
|
| 48 |
+
with patch("db.init_firebase") as mock_init_fb:
|
| 49 |
+
item = ai_cache.get_cached_item("non_existent_key")
|
| 50 |
+
assert item is None
|
| 51 |
+
mock_init_fb.assert_not_called()
|
| 52 |
+
|
| 53 |
+
def test_ai_cache_firestore_timeout_parameter(self):
|
| 54 |
+
mock_doc = MagicMock()
|
| 55 |
+
mock_doc_ref = MagicMock()
|
| 56 |
+
mock_doc_ref.get.return_value = mock_doc
|
| 57 |
+
mock_doc.exists = True
|
| 58 |
+
mock_doc.to_dict.return_value = {"payload": "test_data"}
|
| 59 |
+
|
| 60 |
+
mock_firestore_client = MagicMock()
|
| 61 |
+
mock_firestore_client.collection.return_value.document.return_value = mock_doc_ref
|
| 62 |
+
|
| 63 |
+
with (
|
| 64 |
+
patch("ai_cache.is_local_or_sandbox_mode", return_value=False),
|
| 65 |
+
patch("ai_cache._can_attempt_firestore", return_value=True),
|
| 66 |
+
patch("db.init_firebase", return_value=mock_firestore_client),
|
| 67 |
+
):
|
| 68 |
+
res = ai_cache.get_cached_item("my_key")
|
| 69 |
+
assert res == "test_data"
|
| 70 |
+
mock_doc_ref.get.assert_called_with(timeout=0.5)
|
| 71 |
+
|
| 72 |
+
def test_ai_cache_records_failure_when_init_firebase_returns_none(self):
|
| 73 |
+
ai_cache._last_firestore_failure = 0.0
|
| 74 |
+
with (
|
| 75 |
+
patch("ai_cache.is_local_or_sandbox_mode", return_value=False),
|
| 76 |
+
patch("ai_cache._can_attempt_firestore", return_value=True),
|
| 77 |
+
patch("db.init_firebase", return_value=None),
|
| 78 |
+
):
|
| 79 |
+
res = ai_cache.get_cached_item("missing_key")
|
| 80 |
+
assert res is None
|
| 81 |
+
assert ai_cache._last_firestore_failure > 0.0
|
| 82 |
+
|
| 83 |
+
def test_redis_disabled_or_empty_url_returns_none(self):
|
| 84 |
+
cache._redis_client = None
|
| 85 |
+
with patch.object(cache, "REDIS_URL", ""):
|
| 86 |
+
assert cache.get_redis_client() is None
|
| 87 |
+
|
| 88 |
+
with patch.object(cache, "REDIS_URL", "disabled"):
|
| 89 |
+
assert cache.get_redis_client() is None
|
tests/unit/test_problem_utils.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
class TestExtractStarterCode:
|
|
@@ -89,3 +92,49 @@ print(total)
|
|
| 89 |
def test_extract_starter_code_empty(self):
|
| 90 |
assert extract_starter_code("") == ""
|
| 91 |
assert extract_starter_code(" ") == ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
from unittest.mock import patch
|
| 3 |
+
|
| 4 |
+
from core.problem_utils import enrich_problem_examples_and_constraints, extract_starter_code
|
| 5 |
|
| 6 |
|
| 7 |
class TestExtractStarterCode:
|
|
|
|
| 92 |
def test_extract_starter_code_empty(self):
|
| 93 |
assert extract_starter_code("") == ""
|
| 94 |
assert extract_starter_code(" ") == ""
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
class TestEnrichProblemExamplesAndConstraints:
|
| 98 |
+
def test_deserializes_json_strings_from_sqlite(self):
|
| 99 |
+
examples_list = [
|
| 100 |
+
{"input": "nums = [2,7,11,15], target = 9", "output": "[0,1]", "explanation": ""}
|
| 101 |
+
]
|
| 102 |
+
constraints_list = ["2 <= nums.length <= 10^4", "-10^9 <= nums[i] <= 10^9"]
|
| 103 |
+
prob = {
|
| 104 |
+
"name": "Two Sum",
|
| 105 |
+
"problem_number": 1,
|
| 106 |
+
"description": "Given an array of integers nums and an integer target...",
|
| 107 |
+
"examples": json.dumps(examples_list),
|
| 108 |
+
"constraints": json.dumps(constraints_list),
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
with patch("ai_cache.get_leetcode_problem") as mock_cache:
|
| 112 |
+
result = enrich_problem_examples_and_constraints(prob, check_remote_cache=True)
|
| 113 |
+
# Remote cache must NOT be checked because examples and constraints were parsed from JSON
|
| 114 |
+
mock_cache.assert_not_called()
|
| 115 |
+
|
| 116 |
+
assert isinstance(result["examples"], list)
|
| 117 |
+
assert len(result["examples"]) == 1
|
| 118 |
+
assert result["examples"][0]["input"] == "nums = [2,7,11,15], target = 9"
|
| 119 |
+
assert isinstance(result["constraints"], list)
|
| 120 |
+
assert len(result["constraints"]) == 2
|
| 121 |
+
|
| 122 |
+
def test_skips_remote_cache_for_sandbox_client(self):
|
| 123 |
+
prob = {
|
| 124 |
+
"name": "Custom Problem Without Examples",
|
| 125 |
+
"problem_number": 999,
|
| 126 |
+
"description": "Some simple description.",
|
| 127 |
+
"examples": None,
|
| 128 |
+
"constraints": None,
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
class MockSandboxClient:
|
| 132 |
+
def table(self, name):
|
| 133 |
+
return None
|
| 134 |
+
|
| 135 |
+
with patch("ai_cache.get_leetcode_problem") as mock_cache:
|
| 136 |
+
enrich_problem_examples_and_constraints(
|
| 137 |
+
prob, client=MockSandboxClient(), check_remote_cache=True
|
| 138 |
+
)
|
| 139 |
+
mock_cache.assert_not_called()
|
| 140 |
+
|